Launch image editor when creating new imageMap
by Joe Rossi · in Torque Game Builder · 12/22/2007 (3:03 pm) · 4 replies
It'd be nice if TGB would automatically open the image builder when you click the "create new imageMap" button. When creating multiple imagemaps in the editor, it can be annoying to have to scroll down and click the new images to set their properties. I think the imageMap builder should behave the same as the other image editors within TGB, and automatically launch the configuration menu.
I patched mine to do this, and anyone with a pro license can fix theirs too. I hope this functionality will be added to a future version of TGB.
tools\imageEditor\scripts\editor.ed.cs
replace your launchNewImageMap function with this:
You may also want to add the following to some other files, to avoid console warnings/spam when you cancel or delete a newly created image. In my opinion, some of these checks should really be in the code anyway...
Same file
add at the top of the function ImageEditor::delete
tools\animationEditor\utility\objectReference.ed.cs
add at the top of function t2dSceneGraph::getImageMapReferenceList
tools\levelEditor\scripts\forms\sideBar\sideBarContentManagement.ed.cs
add at the top of function SBCreateTrash::deleteImageMap
I patched mine to do this, and anyone with a pro license can fix theirs too. I hope this functionality will be added to a future version of TGB.
tools\imageEditor\scripts\editor.ed.cs
replace your launchNewImageMap function with this:
function launchNewImageMap()
{
%dlg = new OpenFileDialog()
{
Filters = $T2D::ImageMapSpec;
ChangePath = false;
MustExist = true;
MultipleFiles = true;
};
%dlg.DefaultPath = $Pref::Dialogs::LastImagePath;
if(%dlg.Execute())
{
// Store last image path
$Pref::Dialogs::LastImagePath = filePath( %dlg.files[0] );
// Loop and add selected files where appropriate
for(%i = 0;%i < %dlg.fileCount;%i++)
{
%fileName = %dlg.files[%i];
%fileOnlyName = fileName( %fileName );
%fileBase = validateDatablockName( fileBase( %fileOnlyName ) @ "ImageMap" );
// [neo, 5/15/2007 - #3117]
// If the image is already in a sub dir of images don't copy it just use
// the same path and update the image map to use it.
%checkPath = expandFilename( "^game/data/images/" );
%fileOnlyPath = filePath( expandFileName( %fileName ) );
%fileBasePath = getSubStr( %fileOnlyPath, 0, strlen( %checkPath ) );
if( %checkPath !$= %fileBasePath )
{
%newFileLocation = expandFilename("^game/data/images/" @ %fileOnlyName );
addResPath( filePath( %newFileLocation ) );
pathCopy( %fileName, %newFileLocation );
}
else
{
// Already exists in data/images or sub dir so just point to it
%newFileLocation = %fileName;
}
// Error of some sort, skip it.
if( !isFile( %newFileLocation ) )
continue;
%datablock = "datablock t2dImageMapDatablock(" @ %fileBase @ ")\n";
%datablock = %datablock SPC "{\n";
%datablock = %datablock SPC "imageName = " @ "\"" @ %newFileLocation @ "\"" @ ";\n";
%datablock = %datablock SPC "imageMode = FULL;\n";
%datablock = %datablock SPC "};";
eval(%datablock);
if( !isObject( %fileBase ) )
continue;
LBProjectObj.addDatablock( %fileBase, false );
$ignoredDatablockSet.add( %fileBase );///PATCH - prevents a warning when you "save" this image
loadImageEditor( %fileBase );///PATCH - launch the editor
}
LBProjectObj.persistToDisk( true, false, false );
// Update object library
// GuiFormManager::SendContentMessage($LBCreateSiderBar, %this, "refreshAll 1"); //PATCH - don't do this
}
%dlg.delete();
}You may also want to add the following to some other files, to avoid console warnings/spam when you cancel or delete a newly created image. In my opinion, some of these checks should really be in the code anyway...
Same file
add at the top of the function ImageEditor::delete
if ( !isobject( %this.sourceDB ) ) return; //PATCH
tools\animationEditor\utility\objectReference.ed.cs
add at the top of function t2dSceneGraph::getImageMapReferenceList
if ( !isobject(%imageMap) ) return; //PATCH
tools\levelEditor\scripts\forms\sideBar\sideBarContentManagement.ed.cs
add at the top of function SBCreateTrash::deleteImageMap
if ( !isobject(%imageMap) ) return; //PATCH
#2
12/23/2007 (10:55 am)
Thanks David, there is one small annoyance I haven't been able to work out. The image names will have a "2" appended to them, instead of the usual naming. Other than that it works good over here.
#3
10/14/2013 (9:17 pm)
But using code to deal with the image editing work is too complicated for me. I prefer to manipulate images with the help of some fine 3rd party tools,and do you have any good suggetions? Thanks in advance.
#4
10/15/2013 (7:28 pm)
This is really good! I did notice the "2" at the end of the ImageMap tag.
Associate David Montgomery-Blake
David MontgomeryBlake