Merge pull request #1118 from Areloch/MenuBuilderUpdates

Expands functionality of MenuBuilder to act as primary API for building out menus
This commit is contained in:
Brian Roberts 2023-10-22 09:34:58 -05:00 committed by GitHub
commit 0a9ba692ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 547 additions and 1441 deletions

File diff suppressed because it is too large Load diff

View file

@ -110,6 +110,7 @@ public:
void processTick();
void insert(SimObject* pObject, S32 pos);
void remove(SimObject* pObject);
static void initPersistFields();

View file

@ -210,11 +210,31 @@ bool GuiPopupMenuTextListCtrl::onKeyDown(const GuiEvent &event)
void GuiPopupMenuTextListCtrl::onMouseDown(const GuiEvent &event)
{
if(mLastHighlightedMenuIdx != -1)
{
//See if we're trying to click on a submenu
if(mList[mLastHighlightedMenuIdx].text[1] != 1)
{
//yep, so abort
return;
}
}
Parent::onMouseDown(event);
}
void GuiPopupMenuTextListCtrl::onMouseUp(const GuiEvent &event)
{
if (mLastHighlightedMenuIdx != -1)
{
//See if we're trying to click on a submenu
if (mList[mLastHighlightedMenuIdx].text[1] != 1)
{
//yep, so abort
return;
}
}
Parent::onMouseUp(event);
S32 selectionIndex = getSelectedCell().y;

View file

@ -1,485 +0,0 @@
//--- OBJECT WRITE BEGIN ---
$guiContent = new GuiContainer(NewEditorGui) {
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1920 1080";
minExtent = "8 8";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "1";
enabled = "1";
new GuiSplitContainer(NewEditorGuiLayout) {
orientation = "Vertical";
splitterSize = "2";
splitPoint = "1661 100";
fixedPanel = "None";
useMinExtent="0";
fixedSize = "260";
docking = "None";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1921 1081";
minExtent = "64 64";
horizSizing = "width";
vertSizing = "height";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiPanel() {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1659 1081";
minExtent = "0 0";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "Panel1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiSplitContainer(Editor_ToolsMainSplit) {
orientation = "Vertical";
splitterSize = "2";
splitPoint = "230 100";
fixedPanel = "None";
useMinExtent="0";
fixedSize = "1429";
docking = "None";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1659 1081";
minExtent = "64 64";
horizSizing = "width";
vertSizing = "height";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiPanel(Editor_ToolSidebarPanel) {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "228 1081";
minExtent = "0 0";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "Panel1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiWindowCtrl(Editor_ToolsSidebarWindow) {
text = "Tool Settings";
resizeWidth = "0";
resizeHeight = "0";
canMove = "0";
canClose = "0";
canMinimize = "0";
canMaximize = "0";
canCollapse = "0";
edgeSnap = "1";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "228 1081";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "height";
profile = "GuiWindowProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
};
new GuiPanel(Editor_MainWindowPanel) {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "232 0";
extent = "1427 1081";
minExtent = "0 0";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "panel2";
canSave = "1";
canSaveDynamicFields = "0";
new GuiSplitContainer(Editor_MainViewSplit) {
orientation = "Horizontal";
splitterSize = "2";
splitPoint = "182 745";
fixedPanel = "None";
useMinExtent="0";
fixedSize = "273";
docking = "None";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1427 1081";
minExtent = "64 64";
horizSizing = "width";
vertSizing = "height";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiPanel(Editor_MainViewPanel) {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1427 743";
minExtent = "0 0";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "Panel1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiTabBookCtrl(Editor_MainViewTabBook) {
tabPosition = "Top";
tabMargin = "7";
minTabWidth = "64";
tabHeight = "20";
allowReorder = "0";
defaultPage = "-1";
selectedPage = "-1";
frontTabPadding = "0";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1427 743";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "height";
profile = "ToolsGuiTabBookProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiBitmapButtonCtrl(Editor_InspectorSidebarButton) {
bitmap = "tools/gui/images/iconAdd.png";
bitmapMode = "Stretched";
autoFitExtents = "0";
useModifiers = "0";
useStates = "1";
masked = "0";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
position = "1411 61";
extent = "15 15";
minExtent = "8 2";
horizSizing = "left";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiBitmapButtonCtrl(Editor_ToolsSidebarButton) {
bitmap = "tools/gui/images/iconAdd.png";
bitmapMode = "Stretched";
autoFitExtents = "0";
useModifiers = "0";
useStates = "1";
masked = "0";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
position = "0 61";
extent = "15 15";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiBitmapButtonCtrl(Editor_AssetBrowserButton) {
bitmap = "tools/gui/images/iconAdd.png";
bitmapMode = "Stretched";
autoFitExtents = "0";
useModifiers = "0";
useStates = "1";
masked = "0";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
position = "1411 725";
extent = "15 15";
minExtent = "8 2";
horizSizing = "left";
vertSizing = "top";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiBitmapButtonCtrl(Editor_VisibilityOptionsButton) {
bitmap = "tools/gui/images/visible";
bitmapMode = "Stretched";
autoFitExtents = "0";
useModifiers = "0";
useStates = "1";
masked = "0";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
position = "16 30";
extent = "18 18";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
};
new GuiPanel(Editor_AssetBrowserPanel) {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 747";
extent = "1427 334";
minExtent = "16 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "panel2";
canSave = "1";
canSaveDynamicFields = "0";
};
};
};
};
};
new GuiPanel(Editor_InspectorPanel) {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "1663 0";
extent = "258 1081";
minExtent = "0 0";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "panel2";
canSave = "1";
canSaveDynamicFields = "0";
new GuiSplitContainer() {
orientation = "Horizontal";
splitterSize = "2";
splitPoint = "182 556";
fixedPanel = "None";
useMinExtent="0";
fixedSize = "100";
docking = "None";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "258 1081";
minExtent = "64 64";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiPanel(Editor_SceneTreePanel) {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "258 554";
minExtent = "0 0";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "Panel1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiPanel(Editor_PropertiesPanel) {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 558";
extent = "258 523";
minExtent = "0 0";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "panel2";
canSave = "1";
canSaveDynamicFields = "0";
};
};
};
};
};
//--- OBJECT WRITE END ---

View file

@ -0,0 +1,14 @@
<ModuleDefinition
ModuleId="EditorCore"
VersionId="1"
Description="Core module that acts as the backbone of the editor suite"
ScriptFile="editorCore"
CreateFunction="onCreate"
DestroyFunction="onDestroy"
Group="Tools">
<DeclaredAssets
canSave="true"
canSaveDynamicFields="true"
Extension="asset.taml"
Recurse="true" />
</ModuleDefinition>

View file

@ -0,0 +1,12 @@
function EditorCore::onCreate(%this)
{
exec("./scripts/menuBar/menuBuilder.ed.tscript");
MenuBuilder::init();
}
function EditorCore::onDestroy(%this)
{
MenuBuilder::clearMenus();
}

View file

@ -0,0 +1,443 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Menu Builder Helper Class
//-----------------------------------------------------------------------------
/// @class MenuBuilder
/// @brief Create Dynamic Context and MenuBar Menus
///
///
/// Summary : The MenuBuilder script class exists merely as a helper for creating
/// popup menu's for use in torque editors. It is setup as a single
/// object with dynamic fields starting with item[0]..[n] that describe
/// how to create the menu in question. An example is below.
///
/// isPopup : isPopup is a persistent field on PopupMenu console class which
/// when specified to true will allow you to perform .showPopup(x,y)
/// commands which allow popupmenu's to be used/reused as menubar menus
/// as well as context menus.
///
/// barPosition : barPosition indicates which index on the menu bar (0 = leftmost)
/// to place this menu if it is attached. Use the attachToMenuBar() command
/// to attach a menu.
///
/// barName : barName specifies the visible name of a menu item that is attached
/// to the global menubar.
///
/// canvas : The GuiCanvas object the menu should be attached to. This defaults to
/// the global Canvas object if unspecified.
///
/// Remarks : If you wish to use a menu as a context popup menu, isPopup must be
/// specified as true at the creation time of the menu.
///
///
/// @li @b item[n] (String) TAB (String) TAB (String) : <c>A Menu Item Definition.</c>
/// @code item[0] = "Open File..." TAB "Ctrl O" TAB "Something::OpenFile"; @endcode
///
/// @li @b isPopup (bool) : <c>If Specified the menu will be considered a popup menu and should be used via .showPopup()</c>
/// @code isPopup = true; @endcode
///
///
/// Example : Creating a @b MenuBar Menu
/// @code
/// %%editMenu = new PopupMenu()
/// {
/// barPosition = 3;
/// barName = "View";
/// superClass = "MenuBuilder";
/// item[0] = "Undo" TAB "Ctrl Z" TAB "levelBuilderUndo(1);";
/// item[1] = "Redo" TAB "Ctrl Y" TAB "levelBuilderRedo(1);";
/// item[2] = "-";
/// };
///
/// %%editMenu.attachToMenuBar( 1, "Edit" );
///
/// @endcode
///
///
/// Example : Creating a @b Context (Popup) Menu
/// @code
/// %%contextMenu = new PopupMenu()
/// {
/// superClass = MenuBuilder;
/// isPopup = true;
/// item[0] = "My Super Cool Item" TAB "Ctrl 2" TAB "echo(\"Clicked Super Cool Item\");";
/// item[1] = "-";
/// };
///
/// %%contextMenu.showPopup();
/// @endcode
///
///
/// Example : Modifying a Menu
/// @code
/// %%editMenu = new PopupMenu()
/// {
/// item[0] = "Foo" TAB "Ctrl F" TAB "echo(\"clicked Foo\")";
/// item[1] = "-";
/// };
/// %%editMenu.addItem( 2, "Bar" TAB "Ctrl B" TAB "echo(\"clicked Bar\")" );
/// %%editMenu.removeItem( 0 );
/// %%editMenu.addItem( 0, "Modified Foo" TAB "Ctrl F" TAB "echo(\"clicked modified Foo\")" );
/// @endcode
///
///
/// @see PopupMenu
///
//------------------------------------------------------------------------------
//==============================================================================
// Static functions for managing the menus
// Static function
function MenuBuilder::init()
{
new ArrayObject(MenuBuilderMenuList){};
}
// Static function
function MenuBuilder::clearMenus()
{
MenuBuilderMenuList.empty();
}
// Static function
function MenuBuilder::addMenuToMenubar(%menuBar, %menu, %pos)
{
if(%pos $= "")
%pos = -1; //if we don't specify, throw it on the end
%menuBar.insert(%menu, %pos);
}
// Static function
function MenuBuilder::newMenu(%title, %className)
{
if(%title $= "")
{
error("MenuBuilder::newMenu() - menu requires title!");
return 0;
}
if(%className $= "")
%className = "EditorWorldMenu";
%newMenu = new PopupMenu() {
superClass = "MenuBuilder";
class = %className;
barTitle = %title;
numItems = 0;
isSubmenu = false;
};
MenuBuilderMenuList.add(%newMenu);
return %newMenu;
}
function MenuBuilder::newItem(%this, %itemLabel, %command, %accelerator, %pos, %icon)
{
if(%pos < 0)
{
error("MenuBuilder::addItem() - position must be greater than 0!");
return;
}
if(%pos $= "")
{
%pos = %this.numItems;
}
else
{
//ok, we need to nudge all indexed items up from the insert position and up
for(%i = %this.numItems; %i > %pos; %i--)
{
%this.item[%i+1] = %this.item[%i];
}
}
if(isObject(%command))
%this.item[%pos] = %itemLabel TAB %command;
else
%this.item[%pos] = %itemLabel TAB %accelerator TAB %command TAB %icon;
%this.numItems++;
%this.reloadItems();
}
function MenuBuilder::newSubmenu(%this, %title, %className, %pos)
{
if(%title $= "")
{
error("MenuBuilder::addSubmenu() - menu requires title!");
return 0;
}
if(%pos < 0)
{
error("MenuBuilder::addSubmenu() - position must be greater than 0!");
return;
}
if(%className $= "")
%className = "EditorWorldMenu";
%newMenu = new PopupMenu() {
superClass = "MenuBuilder";
class = %className;
barTitle = %title;
numItems = 0;
isSubmenu = true;
};
%this.newItem(%pos, %title TAB %newMenu);
return %newMenu;
}
function MenuBuilder::newSeparator(%this, %pos)
{
if(%pos < 0)
{
error("MenuBuilder::addItem() - position must be greater than 0!");
return;
}
if(%pos $= "")
{
%pos = %this.numItems;
}
else
{
//ok, we need to nudge all indexed items up from the insert position and up
for(%i = %this.numItems; %i > %pos; %i--)
{
%this.item[%i+1] = %this.item[%i];
}
}
%this.item[%pos] = "-";
%this.numItems++;
%this.reloadItems();
}
// Static function
function MenuBuilder::findMenu(%title)
{
for(%i=0; %i < MenuBuilderMenuList.count(); %i++)
{
%menu = MenuBuilderMenuList.getObject(%i);
if(%menu.barTitle $= %title)
{
return %menu;
}
}
return 0;
}
function MenuBuilder::findMenu(%this, %title)
{
for(%i=0; %i < %this.numItems; %i++)
{
%item = %this.item[%i];
%menu = getField(%item, 1);
if(isObject(%menu))
{
if(%menu.barTitle $= %title)
return %menu;
}
}
return 0;
}
function MenuBuilder::findItem(%this, %itemLabel)
{
for(%i=0; %i < %this.numItems; %i++)
{
%item = %this.item[%i];
if(getField(%item, 0) $= %itemLabel)
return %i;
}
return -1;
}
//==============================================================================
//==============================================================================
// Adds one item to the menu.
// if %item is skipped or "", we will use %item[#], which was set when the menu was created.
// if %item is provided, then we update %item[#].
function MenuBuilder::addItem(%this, %pos, %item)
{
if(%item $= "")
%item = %this.item[%pos];
if(%item !$= %this.item[%pos])
%this.item[%pos] = %item;
%name = getField(%item, 0);
%accel = getField(%item, 1);
%cmd = getField(%item, 2);
%bitmapIdx = getField(%item, 3);
// We replace the [this] token with our object ID
%cmd = strreplace( %cmd, "[this]", %this );
%this.item[%pos] = setField( %item, 2, %cmd );
if(isObject(%accel))
{
// If %accel is an object, we want to add a sub menu
%this.insertSubmenu(%pos, %name, %accel);
}
else
{
%this.insertItem(%pos, %name !$= "-" ? %name : "", %accel, %cmd, %bitmapIdx $= "" ? -1 : %bitmapIdx);
}
}
function MenuBuilder::appendItem(%this, %item)
{
%this.addItem(%this.getItemCount(), %item);
}
function MenuBuilder::onAdd(%this)
{
if(! isObject(%this.canvas))
%this.canvas = Canvas;
for(%i = 0;%this.item[%i] !$= "";%i++)
{
%this.addItem(%i);
}
}
function MenuBuilder::reloadItems(%this)
{
%this.clearItems();
for(%i = 0;%this.item[%i] !$= "";%i++)
{
%this.addItem(%i);
}
}
function MenuBuilder::onRemove(%this)
{
if(%this.isMethod("removeFromMenuBar"))
%this.removeFromMenuBar();
}
//////////////////////////////////////////////////////////////////////////
function MenuBuilder::onSelectItem(%this, %id, %text)
{
%cmd = getField(%this.item[%id], 2);
if(%cmd !$= "")
{
eval( %cmd );
return true;
}
return false;
}
/// Sets a new name on an existing menu item.
function MenuBuilder::setItemName( %this, %id, %name )
{
%item = %this.item[%id];
%accel = getField(%item, 1);
%this.setItem( %id, %name, %accel );
}
/// Sets a new command on an existing menu item.
function MenuBuilder::setItemCommand( %this, %id, %command )
{
%this.item[%id] = setField( %this.item[%id], 2, %command );
}
/// (SimID this)
/// Wraps the attachToMenuBar call so that it does not require knowledge of
/// barName or barIndex to be removed/attached. This makes the individual
/// MenuBuilder items very easy to add and remove dynamically from a bar.
///
function MenuBuilder::attachToMenuBar( %this )
{
if( %this.barName $= "" )
{
error("MenuBuilder::attachToMenuBar - Menu property 'barName' not specified.");
return false;
}
if( %this.barPosition < 0 )
{
error("MenuBuilder::attachToMenuBar - Menu " SPC %this.barName SPC "property 'barPosition' is invalid, must be zero or greater.");
return false;
}
Parent::attachToMenuBar( %this, %this.canvas, %this.barPosition, %this.barName );
}
//////////////////////////////////////////////////////////////////////////
// Callbacks from PopupMenu. These callbacks are now passed on to submenus
// in C++, which was previously not the case. Thus, no longer anything to
// do in these. I am keeping the callbacks in case they are needed later.
function MenuBuilder::onAttachToMenuBar(%this, %canvas, %pos, %title)
{
}
function MenuBuilder::onRemoveFromMenuBar(%this, %canvas)
{
}
//////////////////////////////////////////////////////////////////////////
/// Method called to setup default state for the menu. Expected to be overriden
/// on an individual menu basis. See the mission editor for an example.
function MenuBuilder::setupDefaultState(%this)
{
for(%i = 0;%this.item[%i] !$= "";%i++)
{
%name = getField(%this.item[%i], 0);
%accel = getField(%this.item[%i], 1);
%cmd = getField(%this.item[%i], 2);
// Pass on to sub menus
if(isObject(%accel))
%accel.setupDefaultState();
}
}
/// Method called to easily enable or disable all items in a menu.
function MenuBuilder::enableAllItems(%this, %enable)
{
for(%i = 0; %this.item[%i] !$= ""; %i++)
{
%this.enableItem(%i, %enable);
}
}

View file

@ -123,7 +123,7 @@
<Setting
name="documentationReference">../../../Documentation/Torque 3D - Script Manual.chm</Setting>
<Setting
name="documentationURL">http://www.garagegames.com/products/torque-3d/documentation/user</Setting>
name="documentationURL">https://docs.torque3d.org</Setting>
</Group>
<Group
name="Library">
@ -410,9 +410,9 @@
<Setting
name="documentationReference">../../../Documentation/Torque 3D - Script Manual.chm</Setting>
<Setting
name="documentationURL">http://www.garagegames.com/products/torque-3d/documentation/user</Setting>
name="documentationURL">https://docs.torque3d.org</Setting>
<Setting
name="forumURL">http://www.garagegames.com/products/torque-3d/forums</Setting>
name="forumURL">https://torque3d.org/</Setting>
</Group>
<Group
name="Grid">

View file

@ -16,7 +16,7 @@ function ToolsModule::onCreate(%this)
// to find exactly which subsystems should be readied before kicking things off.
// ----------------------------------------------------------------------------
//ModuleDatabase.LoadExplicit( "MainEditor" );
ModuleDatabase.LoadExplicit( "EditorCore" );
//ModuleDatabase.LoadExplicit( "Tools_ObjectViewer" );
}

View file

@ -364,19 +364,18 @@ function EditorGui::buildMenus(%this)
%this.menuBar.insert(%toolsMenu);
// Help Menu
%helpMenu = new PopupMenu()
{
superClass = "MenuBuilder";
class = "EditorHelpMenu";
barTitle = "Help";
item[0] = "Online Documentation..." TAB "Alt F1" TAB "gotoWebPage(EWorldEditor.documentationURL);";
item[1] = "Offline User Guide..." TAB "" TAB "gotoWebPage(EWorldEditor.documentationLocal);";
item[2] = "Offline Reference Guide..." TAB "" TAB "shellexecute(EWorldEditor.documentationReference);";
item[3] = "Torque 3D Forums..." TAB "" TAB "gotoWebPage(EWorldEditor.forumURL);";
};
%this.menuBar.insert(%helpMenu);
%helpMenu = MenuBuilder::newMenu("Help", "EditorHelpMenu");
%helpMenu.newItem("Online Documentation...", "gotoWebPage(EWorldEditor.documentationURL);", "Alt F1");
%helpMenu.newItem("Offline User Guide...", "gotoWebPage(EWorldEditor.documentationLocal);");
%helpMenu.newItem("Offline Reference Guide...", "shellexecute(EWorldEditor.documentationReference);");
%helpMenu.newItem("Torque 3D Forums...", "gotoWebPage(EWorldEditor.forumURL);");
//These files don't currently exist, so we're going to disable them until such a time
//as they exist again
%helpMenu.enableItem(1, false);
%helpMenu.enableItem(2, false);
MenuBuilder::addMenuToMenubar(%this.menubar, %helpMenu);
// Menus that are added/removed dynamically (temporary)