Corrected the logic for the GenerateComposite import config rule so it only applies if there's any of the ORM maps detected

Added new import config rule: AlwaysPresentImageMaps so it will add entries for the regular map inputs on a material, even if they weren't actually found
Disabled a number of inactive popup menu items
Added Create New Module to normal add asset popup for more obvious/simplified use-flow
Adjusted the editor loading logic so it will properly display the loading splash to inform loading is happening instead of just lagging
Adjusted the assimp shape loader code so if it doesn't find a texture, and thus just sets a material value as the material color, it has a more parsable formatting
This commit is contained in:
Areloch 2019-10-06 01:29:12 -05:00
parent 388b568739
commit ec63be32e3
11 changed files with 322 additions and 269 deletions

View file

@ -346,7 +346,7 @@ bool AssimpShapeLoader::fillGuiTreeView(const char* sourceShapePath, GuiTreeView
{ {
aiColor3D read_color(1.f, 1.f, 1.f); aiColor3D read_color(1.f, 1.f, 1.f);
if (AI_SUCCESS == aiMat->Get(AI_MATKEY_COLOR_DIFFUSE, read_color)) if (AI_SUCCESS == aiMat->Get(AI_MATKEY_COLOR_DIFFUSE, read_color))
texName = String::ToString("Color: (%0.3f, %0.3f, %0.3f)", (F32)read_color.r, (F32)read_color.g, (F32)read_color.b); texName = String::ToString("Color: %0.3f %0.3f %0.3f", (F32)read_color.r, (F32)read_color.g, (F32)read_color.b); //formatted as words for easy parsing
else else
texName = "No Texture"; texName = "No Texture";
} }

View file

@ -16,9 +16,6 @@ function ToolsModule::onCreate(%this)
// to find exactly which subsystems should be readied before kicking things off. // to find exactly which subsystems should be readied before kicking things off.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
new Settings(EditorSettings) { file = "tools/settings.xml"; };
EditorSettings.read();
ModuleDatabase.LoadExplicit( "MainEditor" ); ModuleDatabase.LoadExplicit( "MainEditor" );
ModuleDatabase.LoadExplicit( "Tools_ObjectViewer" ); ModuleDatabase.LoadExplicit( "Tools_ObjectViewer" );
} }

View file

@ -1064,7 +1064,7 @@ function ImportAssetWindow::refreshChildItem(%this, %id)
{ {
position = %filePathBtnPos SPC "0"; position = %filePathBtnPos SPC "0";
extent = %height SPC %height; extent = %height SPC %height;
command = "ImportAssetOptionsWindow.findMissingFile(" @ %assetItem @ ");"; command = "ImportAssetWindow.findMissingFile(" @ %assetItem @ ");";
text = "..."; text = "...";
internalName = "InputPathButton"; internalName = "InputPathButton";
tooltip = %toolTip; tooltip = %toolTip;

View file

@ -45,6 +45,8 @@ function setupImportConfigSettingsList()
ImportAssetConfigSettingsList.addNewConfigSetting("Materials/UseDiffuseSuffixOnOriginImage", "Use Diffuse Suffix for Origin Image", "bool", "", "1", ""); ImportAssetConfigSettingsList.addNewConfigSetting("Materials/UseDiffuseSuffixOnOriginImage", "Use Diffuse Suffix for Origin Image", "bool", "", "1", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Materials/UseExistingMaterials", "Use Existing Materials", "bool", "", "1", ""); ImportAssetConfigSettingsList.addNewConfigSetting("Materials/UseExistingMaterials", "Use Existing Materials", "bool", "", "1", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Materials/IgnoreMaterials", "Ignore Materials", "command", "", "", ""); ImportAssetConfigSettingsList.addNewConfigSetting("Materials/IgnoreMaterials", "Ignore Materials", "command", "", "", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Materials/AlwaysPresentImageMaps", "Always Present Image Maps", "bool",
"Wether to always display all normal material map fields, even if an image isn't detected.", "", "");
//Animations //Animations
ImportAssetConfigSettingsList.addNewConfigSetting("Animations/ImportAnimations", "Import Animations", "bool", "", "1", ""); ImportAssetConfigSettingsList.addNewConfigSetting("Animations/ImportAnimations", "Import Animations", "bool", "", "1", "");
@ -289,6 +291,7 @@ function ImportAssetConfigEditorWindow::addNewConfig(%this)
AssetImportSettings.setValue("Materials/CreateComposites", "1"); AssetImportSettings.setValue("Materials/CreateComposites", "1");
AssetImportSettings.setValue("Materials/UseDiffuseSuffixOnOriginImage", "1"); AssetImportSettings.setValue("Materials/UseDiffuseSuffixOnOriginImage", "1");
AssetImportSettings.setValue("Materials/UseExistingMaterials", "1"); AssetImportSettings.setValue("Materials/UseExistingMaterials", "1");
AssetImportSettings.setValue("Materials/AlwaysPresentImageMaps", "0");
//Animations //Animations
AssetImportSettings.setValue("Animations/ImportAnimations", "1"); AssetImportSettings.setValue("Animations/ImportAnimations", "1");

View file

@ -33,23 +33,14 @@ function AssetBrowser::createMaterialAsset(%this)
function AssetBrowser::editMaterialAsset(%this, %assetDef) function AssetBrowser::editMaterialAsset(%this, %assetDef)
{ {
//if(EditorSettings.materialEditMode $= "MaterialEditor") %assetDef.materialDefinitionName.reload();
//{
%assetDef.materialDefinitionName.reload(); EditorGui.setEditor(MaterialEditorPlugin);
EditorGui.setEditor(MaterialEditorPlugin); MaterialEditorGui.currentMaterial = %assetDef.materialDefinitionName;
MaterialEditorGui.setActiveMaterial( %assetDef.materialDefinitionName );
MaterialEditorGui.currentMaterial = %assetDef.materialDefinitionName;
MaterialEditorGui.setActiveMaterial( %assetDef.materialDefinitionName ); AssetBrowser.hideDialog();
AssetBrowser.hideDialog();
/*}
else
{
Canvas.pushDialog(ShaderEditor);
ShaderEditorGraph.loadGraph(%assetDef.shaderGraph);
$ShaderGen::targetShaderFile = filePath(%assetDef.shaderGraph) @"/"@fileBase(%assetDef.shaderGraph);
//} */
} }
function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem) function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem)
@ -93,6 +84,13 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem)
%diffuseAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); %diffuseAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem);
%assetItem.diffuseImageAsset = %diffuseAsset; %assetItem.diffuseImageAsset = %diffuseAsset;
} }
else if(getAssetImportConfigValue("Materials/AlwaysPresentImageMaps", "0") == 1)
{
//In the event we don't have this image asset, but we DO wish to always display the field(affording when names don't aline with
//the material name), then we go ahead and create a blank entry
%suff = getTokenCount(%diffuseTypeSuffixes, ",;") == 0 ? "_albedo" : getToken(%diffuseTypeSuffixes, ",;", 0);
%diffuseAsset = AssetBrowser.addImportingAsset("Image", %assetItem.AssetName @ %suff, %assetItem);
}
} }
//Now, iterate over our comma-delimited suffixes to see if we have any matches. We'll use the first match in each case, if any. //Now, iterate over our comma-delimited suffixes to see if we have any matches. We'll use the first match in each case, if any.
@ -108,28 +106,14 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem)
%normalAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); %normalAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem);
%assetItem.normalImageAsset = %normalAsset; %assetItem.normalImageAsset = %normalAsset;
} }
} else if(getAssetImportConfigValue("Materials/AlwaysPresentImageMaps", "0") == 1)
/*if(%assetItem.specularImageAsset $= "")
{
//Specular
%listCount = getTokenCount(ImportAssetWindow.activeImportConfig.SpecularTypeSuffixes, ",;");
%foundFile = 0;
for(%i=0; %i < %listCount; %i++)
{ {
%entryText = getToken(ImportAssetWindow.activeImportConfig.SpecularTypeSuffixes, ",;", %i); //In the event we don't have this image asset, but we DO wish to always display the field(affording when names don't aline with
//the material name), then we go ahead and create a blank entry
%targetFilePath = %fileDir @ "/" @ %filename @ %entryText @ %fileExt; %suff = getTokenCount(%normalTypeSuffixes, ",;") == 0 ? "_normal" : getToken(%normalTypeSuffixes, ",;", 0);
%foundFile = isFile(%targetFilePath); %normalAsset = AssetBrowser.addImportingAsset("Image", %assetItem.AssetName @ %suff, %assetItem);
if(%foundFile)
{
%specularAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem);
%assetItem.specularImageAsset = %specularAsset;
break;
}
} }
}*/ }
if(%assetItem.metalImageAsset $= "") if(%assetItem.metalImageAsset $= "")
{ {
@ -142,6 +126,13 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem)
%metalAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); %metalAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem);
%assetItem.metalImageAsset = %metalAsset; %assetItem.metalImageAsset = %metalAsset;
} }
else if(getAssetImportConfigValue("Materials/AlwaysPresentImageMaps", "0") == 1)
{
//In the event we don't have this image asset, but we DO wish to always display the field(affording when names don't aline with
//the material name), then we go ahead and create a blank entry
%suff = getTokenCount(%metalnessTypeSuffixes, ",;") == 0 ? "_metalness" : getToken(%metalnessTypeSuffixes, ",;", 0);
%metalAsset = AssetBrowser.addImportingAsset("Image", %assetItem.AssetName @ %suff, %assetItem);
}
} }
if(%assetItem.roughnessImageAsset $= "") if(%assetItem.roughnessImageAsset $= "")
@ -155,6 +146,13 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem)
%roughnessAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); %roughnessAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem);
%assetItem.roughnessImageAsset = %roughnessAsset; %assetItem.roughnessImageAsset = %roughnessAsset;
} }
else if(getAssetImportConfigValue("Materials/AlwaysPresentImageMaps", "0") == 1)
{
//In the event we don't have this image asset, but we DO wish to always display the field(affording when names don't aline with
//the material name), then we go ahead and create a blank entry
%suff = getTokenCount(%roughnessTypeSuffixes, ",;") == 0 ? "_roughness" : getToken(%roughnessTypeSuffixes, ",;", 0);
%roughnessAsset = AssetBrowser.addImportingAsset("Image", %assetItem.AssetName @ %suff, %assetItem);
}
} }
if(%assetItem.smoothnessImageAsset $= "") if(%assetItem.smoothnessImageAsset $= "")
@ -168,6 +166,13 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem)
%smoothnessAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); %smoothnessAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem);
%assetItem.SmoothnessImageAsset = %smoothnessAsset; %assetItem.SmoothnessImageAsset = %smoothnessAsset;
} }
else if(getAssetImportConfigValue("Materials/AlwaysPresentImageMaps", "0") == 1)
{
//In the event we don't have this image asset, but we DO wish to always display the field(affording when names don't aline with
//the material name), then we go ahead and create a blank entry
%suff = getTokenCount(%smoothnessTypeSuffixes, ",;") == 0 ? "_smoothness" : getToken(%smoothnessTypeSuffixes, ",;", 0);
%smoothnessAsset = AssetBrowser.addImportingAsset("Image", %assetItem.AssetName @ %suff, %assetItem);
}
} }
if(%assetItem.AOImageAsset $= "") if(%assetItem.AOImageAsset $= "")
@ -181,6 +186,13 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem)
%AOAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); %AOAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem);
%assetItem.AOImageAsset = %AOAsset; %assetItem.AOImageAsset = %AOAsset;
} }
else if(getAssetImportConfigValue("Materials/AlwaysPresentImageMaps", "0") == 1)
{
//In the event we don't have this image asset, but we DO wish to always display the field(affording when names don't aline with
//the material name), then we go ahead and create a blank entry
%suff = getTokenCount(%aoTypeSuffixes, ",;") == 0 ? "_AO" : getToken(%aoTypeSuffixes, ",;", 0);
%AOAsset = AssetBrowser.addImportingAsset("Image", %assetItem.AssetName @ %suff, %assetItem);
}
} }
if(%assetItem.compositeImageAsset $= "") if(%assetItem.compositeImageAsset $= "")
@ -194,10 +206,20 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem)
%compositeAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); %compositeAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem);
%assetItem.compositeImageAsset = %compositeAsset; %assetItem.compositeImageAsset = %compositeAsset;
} }
else if(getAssetImportConfigValue("Materials/AlwaysPresentImageMaps", "0") == 1)
{
//In the event we don't have this image asset, but we DO wish to always display the field(affording when names don't aline with
//the material name), then we go ahead and create a blank entry
%suff = getTokenCount(%compositeTypeSuffixes, ",;") == 0 ? "_composite" : getToken(%compositeTypeSuffixes, ",;", 0);
%compositeAsset = AssetBrowser.addImportingAsset("Image", %assetItem.AssetName @ %suff, %assetItem);
}
} }
//If after the above we didn't find any, check to see if we should be generating one //If after the above we didn't find any, check to see if we should be generating one
if(%assetItem.compositeImageAsset $= "" && getAssetImportConfigValue("Materials/CreateComposites", "1") == 1) if(%assetItem.compositeImageAsset $= "" &&
(%assetItem.roughnessImageAsset !$= "" || %assetItem.AOImageAsset !$= "" || %assetItem.metalnessImageAsset !$= "") &&
getAssetImportConfigValue("Materials/CreateComposites", "1") == 1 &&
getAssetImportConfigValue("Materials/AlwaysPresentImageMaps", "0") == 0)
{ {
%assetItem.roughnessImageAsset.skip = true; %assetItem.roughnessImageAsset.skip = true;
%assetItem.AOImageAsset.skip = true; %assetItem.AOImageAsset.skip = true;

View file

@ -114,12 +114,20 @@ function AssetBrowser::prepareImportShapeAsset(%this, %assetItem)
} }
else else
{ {
//we need to try and find our material, since the shapeInfo wasn't able to find it automatically //check to see if it's actually just a flat color
%filePath = findImageFile(filePath(%assetItem.filePath), %matName); if(getWordCount(%filePath) == 4 && getWord(%filePath, 0) $= "Color:")
if(%filePath !$= "" && isFile(%filePath)) {
AssetBrowser.addImportingAsset("Material", %filePath, %assetItem); AssetBrowser.addImportingAsset("Material", %matName, %assetItem);
}
else else
AssetBrowser.addImportingAsset("Material", filePath(%assetItem.filePath) @ "/" @ %matName, %assetItem); {
//we need to try and find our material, since the shapeInfo wasn't able to find it automatically
%filePath = findImageFile(filePath(%assetItem.filePath), %matName);
if(%filePath !$= "" && isFile(%filePath))
AssetBrowser.addImportingAsset("Material", %filePath, %assetItem);
else
AssetBrowser.addImportingAsset("Material", filePath(%assetItem.filePath) @ "/" @ %matName, %assetItem);
}
} }
%materialItem = %assetItem.shapeInfo.getNextSibling(%materialItem); %materialItem = %assetItem.shapeInfo.getNextSibling(%materialItem);
@ -133,12 +141,20 @@ function AssetBrowser::prepareImportShapeAsset(%this, %assetItem)
} }
else else
{ {
//we need to try and find our material, since the shapeInfo wasn't able to find it automatically //check to see if it's actually just a flat color
%filePath = findImageFile(filePath(%assetItem.filePath), %matName); if(getWordCount(%filePath) == 4 && getWord(%filePath, 0) $= "Color:")
if(%filePath !$= "" && isFile(%filePath)) {
AssetBrowser.addImportingAsset("Material", %filePath, %assetItem); AssetBrowser.addImportingAsset("Material", %matName, %assetItem);
}
else else
AssetBrowser.addImportingAsset("Material", filePath(%assetItem.filePath) @ "/" @ %matName, %assetItem); {
//we need to try and find our material, since the shapeInfo wasn't able to find it automatically
%filePath = findImageFile(filePath(%assetItem.filePath), %matName);
if(%filePath !$= "" && isFile(%filePath))
AssetBrowser.addImportingAsset("Material", %filePath, %assetItem);
else
AssetBrowser.addImportingAsset("Material", filePath(%assetItem.filePath) @ "/" @ %matName, %assetItem);
}
} }
%materialItem = %assetItem.shapeInfo.getNextSibling(%materialItem); %materialItem = %assetItem.shapeInfo.getNextSibling(%materialItem);

View file

@ -11,6 +11,8 @@ function AssetBrowser::buildPopupMenus(%this)
item[ 0 ] = "Create New Module" TAB "" TAB "AssetBrowser.CreateNewModule();"; item[ 0 ] = "Create New Module" TAB "" TAB "AssetBrowser.CreateNewModule();";
item[ 1 ] = "Refresh Module Dependencies" TAB "" TAB "AssetBrowser.RefreshModuleDependencies();"; item[ 1 ] = "Refresh Module Dependencies" TAB "" TAB "AssetBrowser.RefreshModuleDependencies();";
}; };
AddNewModulePopup.enableItem(1, false);
} }
if( !isObject( EditAssetPopup ) ) if( !isObject( EditAssetPopup ) )
@ -153,6 +155,8 @@ function AssetBrowser::buildPopupMenus(%this)
item[4] = "Create Level" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"LevelAsset\", AssetBrowser.selectedModule);";//"AssetBrowser.createNewLevelAsset(\"NewLevel\", AssetBrowser.selectedModule);"; item[4] = "Create Level" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"LevelAsset\", AssetBrowser.selectedModule);";//"AssetBrowser.createNewLevelAsset(\"NewLevel\", AssetBrowser.selectedModule);";
item[5] = "-"; item[5] = "-";
item[6] = "Create C++ Asset" TAB AddNewCppAssetPopup; item[6] = "Create C++ Asset" TAB AddNewCppAssetPopup;
item[7] = "-";
item[8] = "Create New Module" TAB "" TAB "AssetBrowser.CreateNewModule();";
}; };
} }

View file

@ -1,53 +1,56 @@
//--- OBJECT WRITE BEGIN --- //--- OBJECT WRITE BEGIN ---
%guiContent = new GuiControl(EditorLoadingGui, EditorGuiGroup) { %guiContent = new GuiControl(EditorLoadingGui,EditorGuiGroup) {
isContainer = "1";
Profile = "GuiOverlayProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "0 0"; position = "0 0";
Extent = "800 600"; extent = "1024 768";
MinExtent = "8 2"; minExtent = "8 2";
canSave = "1"; horizSizing = "right";
Visible = "1"; vertSizing = "bottom";
tooltipprofile = "ToolsGuiToolTipProfile"; profile = "GuiOverlayProfile";
visible = "1";
active = "1";
tooltipProfile = "ToolsGuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "1"; canSaveDynamicFields = "1";
new GuiControl() { new GuiControl() {
isContainer = "1"; position = "389 355";
Profile = "editorMenu_wBorderProfile"; extent = "245 57";
HorizSizing = "center"; minExtent = "8 2";
VertSizing = "center"; horizSizing = "center";
position = "277 271"; vertSizing = "center";
Extent = "245 57"; profile = "ToolsGuiDefaultProfile";
MinExtent = "8 2"; visible = "1";
canSave = "1"; active = "1";
Visible = "1"; tooltipProfile = "ToolsGuiToolTipProfile";
tooltipprofile = "ToolsGuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
isContainer = "1";
internalName = "Dialog"; internalName = "Dialog";
canSave = "1";
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
new GuiTextCtrl() { new GuiTextCtrl() {
text = "Loading the World Editor..."; text = "Loading the Editor...";
maxLength = "1024"; maxLength = "1024";
Margin = "0 0 0 0"; margin = "0 0 0 0";
Padding = "0 0 0 0"; padding = "0 0 0 0";
AnchorTop = "1"; anchorTop = "1";
AnchorBottom = "0"; anchorBottom = "0";
AnchorLeft = "1"; anchorLeft = "1";
AnchorRight = "0"; anchorRight = "0";
isContainer = "0";
Profile = "ToolsGuiTextBoldCenterProfile";
HorizSizing = "width";
VertSizing = "center";
position = "5 19"; position = "5 19";
Extent = "236 18"; extent = "236 18";
MinExtent = "8 2"; minExtent = "8 2";
canSave = "1"; horizSizing = "width";
Visible = "1"; vertSizing = "center";
tooltipprofile = "ToolsGuiToolTipProfile"; profile = "ToolsGuiTextBoldCenterProfile";
visible = "1";
active = "1";
tooltipProfile = "ToolsGuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
}; };

View file

@ -29,7 +29,6 @@ exec("./colorPicker.ed.gui");
exec("./materialSelector.ed.gui"); exec("./materialSelector.ed.gui");
exec("./scriptEditorDlg.ed.gui"); exec("./scriptEditorDlg.ed.gui");
exec("./colladaImport.ed.gui"); exec("./colladaImport.ed.gui");
exec("./EditorLoadingGui.gui");
exec("./GuiEaseEditDlg.ed.gui"); exec("./GuiEaseEditDlg.ed.gui");
exec("./GuiEaseEditDlg.ed.cs"); exec("./GuiEaseEditDlg.ed.cs");
exec("./guiObjectInspector.ed.cs"); exec("./guiObjectInspector.ed.cs");

View file

@ -33,191 +33,200 @@ $Tools::loadFirst = "editorClasses base worldEditor";
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
$Tools::materialEditorList = ""; $Tools::materialEditorList = "";
//--------------------------------------------------------------------------------------------- if(!$Tools::loaded)
// Tools Package.
//---------------------------------------------------------------------------------------------
package Tools
{ {
function loadKeybindings() new Settings(EditorSettings) { file = "tools/settings.xml"; };
EditorSettings.read();
exec( "tools/gui/profiles.ed.cs" );
exec("tools/gui/EditorLoadingGui.gui");
}
function EditorIsActive()
{
return ( isObject(EditorGui) && Canvas.getContent() == EditorGui.getId() );
}
function GuiEditorIsActive()
{
return ( isObject(GuiEditorGui) && Canvas.getContent() == GuiEditorGui.getId() );
}
function loadKeybindings()
{
Parent::loadKeybindings();
}
// Start-up.
function onStart()
{
//First, we want to ensure we don't inadvertently clean up our editor objects by leaving them in the MissionCleanup group, so lets change that real fast
$instantGroup = "";
pushInstantGroup();
echo( " % - Initializing Tools" );
// Default file path when saving from the editor (such as prefabs)
if ($Pref::WorldEditor::LastPath $= "")
{ {
Parent::loadKeybindings(); $Pref::WorldEditor::LastPath = getMainDotCsDir();
} }
// Start-up. // Common GUI stuff.
function onStart() exec( "./gui/cursors.ed.cs" );
{ exec( "./gui/messageBoxes/messageBox.ed.cs" );
//First, we want to ensure we don't inadvertently clean up our editor objects by leaving them in the MissionCleanup group, so lets change that real fast exec( "./editorClasses/gui/panels/navPanelProfiles.ed.cs" );
$instantGroup = "";
pushInstantGroup();
echo( " % - Initializing Tools" );
// Default file path when saving from the editor (such as prefabs)
if ($Pref::WorldEditor::LastPath $= "")
{
$Pref::WorldEditor::LastPath = getMainDotCsDir();
}
// Common GUI stuff.
exec( "./gui/cursors.ed.cs" );
exec( "./gui/profiles.ed.cs" );
exec( "./gui/messageBoxes/messageBox.ed.cs" );
exec( "./editorClasses/gui/panels/navPanelProfiles.ed.cs" );
// Make sure we get editor profiles before any GUI's
// BUG: these dialogs are needed earlier in the init sequence, and should be moved to
// common, along with the guiProfiles they depend on.
exec( "./gui/guiDialogs.ed.cs" );
//%toggle = $Scripts::ignoreDSOs;
//$Scripts::ignoreDSOs = true;
$ignoredDatablockSet = new SimSet();
// fill the list of editors // Make sure we get editor profiles before any GUI's
$editors[count] = getWordCount( $Tools::loadFirst ); // BUG: these dialogs are needed earlier in the init sequence, and should be moved to
for ( %i = 0; %i < $editors[count]; %i++ ) // common, along with the guiProfiles they depend on.
{ exec( "./gui/guiDialogs.ed.cs" );
$editors[%i] = getWord( $Tools::loadFirst, %i );
} //%toggle = $Scripts::ignoreDSOs;
//$Scripts::ignoreDSOs = true;
%pattern = $Tools::resourcePath @ "/*/main.cs";
$ignoredDatablockSet = new SimSet();
// fill the list of editors
$editors[count] = getWordCount( $Tools::loadFirst );
for ( %i = 0; %i < $editors[count]; %i++ )
{
$editors[%i] = getWord( $Tools::loadFirst, %i );
}
%pattern = $Tools::resourcePath @ "/*/main.cs";
%folder = findFirstFile( %pattern );
if ( %folder $= "")
{
// if we have absolutely no matches for main.cs, we look for main.cs.dso
%pattern = $Tools::resourcePath @ "/*/main.cs.dso";
%folder = findFirstFile( %pattern ); %folder = findFirstFile( %pattern );
if ( %folder $= "") }
while ( %folder !$= "" )
{
if( filePath( %folder ) !$= "tools" ) // Skip the actual 'tools' folder...we want the children
{ {
// if we have absolutely no matches for main.cs, we look for main.cs.dso %folder = filePath( %folder );
%pattern = $Tools::resourcePath @ "/*/main.cs.dso"; %editor = fileName( %folder );
%folder = findFirstFile( %pattern ); if ( IsDirectory( %folder ) )
}
while ( %folder !$= "" )
{
if( filePath( %folder ) !$= "tools" ) // Skip the actual 'tools' folder...we want the children
{ {
%folder = filePath( %folder ); // Yes, this sucks and should be done better
%editor = fileName( %folder ); if ( strstr( $Tools::loadFirst, %editor ) == -1 )
if ( IsDirectory( %folder ) )
{ {
// Yes, this sucks and should be done better $editors[$editors[count]] = %editor;
if ( strstr( $Tools::loadFirst, %editor ) == -1 ) $editors[count]++;
{
$editors[$editors[count]] = %editor;
$editors[count]++;
}
} }
} }
%folder = findNextFile( %pattern );
} }
%folder = findNextFile( %pattern );
}
// initialize every editor // initialize every editor
new SimSet( EditorPluginSet ); new SimSet( EditorPluginSet );
%count = $editors[count]; %count = $editors[count];
for ( %i = 0; %i < %count; %i++ ) for ( %i = 0; %i < %count; %i++ )
{ {
exec( "./" @ $editors[%i] @ "/main.cs" ); exec( "./" @ $editors[%i] @ "/main.cs" );
%initializeFunction = "initialize" @ $editors[%i];
if( isFunction( %initializeFunction ) )
call( %initializeFunction );
}
// Popuplate the default SimObject icons that %initializeFunction = "initialize" @ $editors[%i];
// are used by the various editors. if( isFunction( %initializeFunction ) )
EditorIconRegistry::loadFromPath( "tools/classIcons/" ); call( %initializeFunction );
// Load up the tools resources. All the editors are initialized at this point, so
// resources can override, redefine, or add functionality.
Tools::LoadResources( $Tools::resourcePath );
//Now, go through and load any tool-group modules
ModuleDatabase.setModuleExtension("module");
//Any common tool modules
ModuleDatabase.scanModules( "tools", false );
ModuleDatabase.LoadGroup( "Tools" );
//Now that we're done loading, we can set the instant group back
popInstantGroup();
$instantGroup = MissionCleanup;
pushInstantGroup();
$Tools::loaded = true;
} }
function startToolTime(%tool) // Popuplate the default SimObject icons that
{ // are used by the various editors.
if($toolDataToolCount $= "") EditorIconRegistry::loadFromPath( "tools/classIcons/" );
$toolDataToolCount = 0;
if($toolDataToolEntry[%tool] !$= "true")
{
$toolDataToolEntry[%tool] = "true";
$toolDataToolList[$toolDataToolCount] = %tool;
$toolDataToolCount++;
$toolDataClickCount[%tool] = 0;
}
$toolDataStartTime[%tool] = getSimTime();
$toolDataClickCount[%tool]++;
}
function endToolTime(%tool) // Load up the tools resources. All the editors are initialized at this point, so
{ // resources can override, redefine, or add functionality.
%startTime = 0; Tools::LoadResources( $Tools::resourcePath );
if($toolDataStartTime[%tool] !$= "")
%startTime = $toolDataStartTime[%tool];
if($toolDataTotalTime[%tool] $= "")
$toolDataTotalTime[%tool] = 0;
$toolDataTotalTime[%tool] += getSimTime() - %startTime;
}
function dumpToolData() //Now, go through and load any tool-group modules
{ ModuleDatabase.setModuleExtension("module");
%count = $toolDataToolCount;
for(%i=0; %i<%count; %i++)
{
%tool = $toolDataToolList[%i];
%totalTime = $toolDataTotalTime[%tool];
if(%totalTime $= "")
%totalTime = 0;
%clickCount = $toolDataClickCount[%tool];
echo("---");
echo("Tool: " @ %tool);
echo("Time (seconds): " @ %totalTime / 1000);
echo("Activated: " @ %clickCount);
echo("---");
}
}
// Shutdown. //Any common tool modules
function onExit() ModuleDatabase.scanModules( "tools", false );
{ ModuleDatabase.LoadGroup( "Tools" );
if( EditorGui.isInitialized )
EditorGui.shutdown(); //Now that we're done loading, we can set the instant group back
popInstantGroup();
// Free all the icon images in the registry. $instantGroup = MissionCleanup;
EditorIconRegistry::clear(); pushInstantGroup();
// Save any Layouts we might be using $Tools::loaded = true;
//GuiFormManager::SaveLayout(LevelBuilder, Default, User); }
%count = $editors[count];
for (%i = 0; %i < %count; %i++)
{
%destroyFunction = "destroy" @ $editors[%i];
if( isFunction( %destroyFunction ) )
call( %destroyFunction );
}
// Call Parent.
Parent::onExit();
// write out our settings xml file function startToolTime(%tool)
EditorSettings.write(); {
if($toolDataToolCount $= "")
$toolDataToolCount = 0;
if($toolDataToolEntry[%tool] !$= "true")
{
$toolDataToolEntry[%tool] = "true";
$toolDataToolList[$toolDataToolCount] = %tool;
$toolDataToolCount++;
$toolDataClickCount[%tool] = 0;
} }
};
$toolDataStartTime[%tool] = getSimTime();
$toolDataClickCount[%tool]++;
}
function endToolTime(%tool)
{
%startTime = 0;
if($toolDataStartTime[%tool] !$= "")
%startTime = $toolDataStartTime[%tool];
if($toolDataTotalTime[%tool] $= "")
$toolDataTotalTime[%tool] = 0;
$toolDataTotalTime[%tool] += getSimTime() - %startTime;
}
function dumpToolData()
{
%count = $toolDataToolCount;
for(%i=0; %i<%count; %i++)
{
%tool = $toolDataToolList[%i];
%totalTime = $toolDataTotalTime[%tool];
if(%totalTime $= "")
%totalTime = 0;
%clickCount = $toolDataClickCount[%tool];
echo("---");
echo("Tool: " @ %tool);
echo("Time (seconds): " @ %totalTime / 1000);
echo("Activated: " @ %clickCount);
echo("---");
}
}
// Shutdown.
function onExit()
{
if( EditorGui.isInitialized )
EditorGui.shutdown();
// Free all the icon images in the registry.
EditorIconRegistry::clear();
// Save any Layouts we might be using
//GuiFormManager::SaveLayout(LevelBuilder, Default, User);
%count = $editors[count];
for (%i = 0; %i < %count; %i++)
{
%destroyFunction = "destroy" @ $editors[%i];
if( isFunction( %destroyFunction ) )
call( %destroyFunction );
}
// write out our settings xml file
EditorSettings.write();
}
function EditorCreateFakeGameSession(%fileName) function EditorCreateFakeGameSession(%fileName)
{ {
@ -248,7 +257,12 @@ function fastLoadWorldEdit(%val)
{ {
if(!$Tools::loaded) if(!$Tools::loaded)
{ {
canvas.pushDialog( EditorLoadingGui );
canvas.repaint();
onStart(); onStart();
canvas.popDialog(EditorLoadingGui);
} }
%timerId = startPrecisionTimer(); %timerId = startPrecisionTimer();
@ -290,7 +304,7 @@ function fastLoadWorldEdit(%val)
{ {
canvas.pushDialog( EditorLoadingGui ); canvas.pushDialog( EditorLoadingGui );
canvas.repaint(); canvas.repaint();
Editor.open(); Editor.open();
// Cancel the scheduled event to prevent // Cancel the scheduled event to prevent
@ -318,7 +332,12 @@ function fastLoadGUIEdit(%val)
{ {
if(!$Tools::loaded) if(!$Tools::loaded)
{ {
canvas.pushDialog( EditorLoadingGui );
canvas.repaint();
onStart(); onStart();
canvas.popDialog(EditorLoadingGui);
} }
toggleGuiEditor(true); toggleGuiEditor(true);
@ -339,21 +358,7 @@ function Tools::LoadResources( %path )
} }
} }
//-----------------------------------------------------------------------------
// Activate Package.
//-----------------------------------------------------------------------------
activatePackage(Tools);
//This lets us fast-load the editor from the menu //This lets us fast-load the editor from the menu
GlobalActionMap.bind(keyboard, "F11", fastLoadWorldEdit); GlobalActionMap.bind(keyboard, "F11", fastLoadWorldEdit);
GlobalActionMap.bind(keyboard, "F10", fastLoadGUIEdit); GlobalActionMap.bind(keyboard, "F10", fastLoadGUIEdit);
function EditorIsActive()
{
return ( isObject(EditorGui) && Canvas.getContent() == EditorGui.getId() );
}
function GuiEditorIsActive()
{
return ( isObject(GuiEditorGui) && Canvas.getContent() == GuiEditorGui.getId() );
}

View file

@ -105,6 +105,7 @@ function setupEditorVisibilityMenu()
item[ 6 ] = "Show Texel Density" TAB "" TAB "toggleTexelDensityViz();"; item[ 6 ] = "Show Texel Density" TAB "" TAB "toggleTexelDensityViz();";
}; };
%probespopup.enableItem(5, false);
%probespopup.enableItem(6, false); %probespopup.enableItem(6, false);
// //
@ -135,6 +136,9 @@ function setupEditorVisibilityMenu()
item[ 3 ] = "Show Diffuse Light" TAB "" TAB ""; item[ 3 ] = "Show Diffuse Light" TAB "" TAB "";
}; };
%lightspopup.enableItem(2, false);
%lightspopup.enableItem(3, false);
// //
//Probes //Probes
%probespopup = new PopupMenu(EVisibilityProbesOptions) %probespopup = new PopupMenu(EVisibilityProbesOptions)