mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
Adds an Add menubar item to the World Editor menubar that populates SceneObject classes for spawnablility based on the categories assigned to the class itself
This commit is contained in:
parent
083e367be1
commit
4bf7b0d5c0
2 changed files with 96 additions and 35 deletions
|
|
@ -465,6 +465,52 @@ function EditorGui::buildMenus(%this)
|
|||
Item[24] = "Unmount Selected Object" TAB "" TAB "EditorUnmount();";
|
||||
};
|
||||
}
|
||||
|
||||
%addMenu = MenuBuilder::newMenu("Add");
|
||||
|
||||
%enumeratedClasses = enumerateConsoleClasses("SceneObject");
|
||||
for(%c=0; %c < getFieldCount(%enumeratedClasses); %c++)
|
||||
{
|
||||
%class = getField(%enumeratedClasses, %c);
|
||||
|
||||
%category = getCategoryOfClass(%class);
|
||||
|
||||
if(%category $= "")
|
||||
{
|
||||
error("Attempted to fetch category of class " @ %class @ " but none were found.");
|
||||
continue;
|
||||
}
|
||||
|
||||
%parentMenu = %addMenu; //start at the top
|
||||
for(%cat=0; %cat < getFieldCount(%category); %cat++)
|
||||
{
|
||||
%subCat = getField(%category, %cat);
|
||||
%targetSubmenu = %parentMenu.findMenu(%subCat);
|
||||
if(!isObject(%targetSubmenu))
|
||||
{
|
||||
%targetSubmenu = %parentMenu.newSubmenu(%subCat);
|
||||
}
|
||||
|
||||
%parentMenu = %targetSubmenu;
|
||||
}
|
||||
|
||||
%buildfunc = "";
|
||||
%class = %class;
|
||||
%method = "build" @ %buildfunc;
|
||||
if( !ObjectBuilderGui.isMethod( %method ) )
|
||||
%method = "build" @ %class;
|
||||
|
||||
if( !ObjectBuilderGui.isMethod( %method ) )
|
||||
%cmd = "return new " @ %class @ "();";
|
||||
else
|
||||
%cmd = "ObjectBuilderGui." @ %method @ "();";
|
||||
|
||||
%createCmd = "ObjectBuilderGui.newObjectCallback = \"ObjectCreator.onFinishCreateObject\"; ObjectCreator.createObject( \"" @ %cmd @ "\" );";
|
||||
|
||||
%targetSubmenu.newItem(%class, %createCmd, "");
|
||||
}
|
||||
|
||||
MenuBuilder::addMenuToMenubar(%this.menubar, %addMenu, 4);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue