mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-12 19:31:41 +00:00
Rearranges the right-mouse click popup menus for the world editor and gui editors to a) be organized more logically and b) be more flexible.
This also fixes some insecure behavior relying on %this value eval'ing, which has also been modified to be better. Also fixes up some old calls for getting menubar menus by internal name, which is no longer supported, instead using the findMenu function call.
This commit is contained in:
parent
d6f6bc65a5
commit
fea3724f4e
11 changed files with 305 additions and 498 deletions
|
|
@ -199,7 +199,7 @@ bool PopupMenu::setItem(S32 pos, const char *title, const char* accelerator, con
|
|||
|
||||
void PopupMenu::removeItem(S32 itemPos)
|
||||
{
|
||||
if (mMenuItems.size() < itemPos || itemPos < 0)
|
||||
if (mMenuItems.empty() || mMenuItems.size() < itemPos || itemPos < 0)
|
||||
return;
|
||||
|
||||
mMenuItems.erase(itemPos);
|
||||
|
|
@ -208,7 +208,7 @@ void PopupMenu::removeItem(S32 itemPos)
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
void PopupMenu::enableItem(S32 pos, bool enable)
|
||||
{
|
||||
if (mMenuItems.size() < pos || pos < 0)
|
||||
if (mMenuItems.empty() || mMenuItems.size() < pos || pos < 0)
|
||||
return;
|
||||
|
||||
mMenuItems[pos].enabled = enable;
|
||||
|
|
@ -216,7 +216,7 @@ void PopupMenu::enableItem(S32 pos, bool enable)
|
|||
|
||||
void PopupMenu::checkItem(S32 pos, bool checked)
|
||||
{
|
||||
if (mMenuItems.size() < pos || pos < 0)
|
||||
if (mMenuItems.empty() || mMenuItems.size() < pos || pos < 0)
|
||||
return;
|
||||
|
||||
if (checked && mMenuItems[pos].checkGroup != -1)
|
||||
|
|
@ -243,7 +243,7 @@ void PopupMenu::checkRadioItem(S32 firstPos, S32 lastPos, S32 checkPos)
|
|||
|
||||
bool PopupMenu::isItemChecked(S32 pos)
|
||||
{
|
||||
if (mMenuItems.size() < pos || pos < 0)
|
||||
if (mMenuItems.empty() || mMenuItems.size() < pos || pos < 0)
|
||||
return false;
|
||||
|
||||
return mMenuItems[pos].isChecked;
|
||||
|
|
@ -254,6 +254,11 @@ U32 PopupMenu::getItemCount()
|
|||
return mMenuItems.size();
|
||||
}
|
||||
|
||||
void PopupMenu::clearItems()
|
||||
{
|
||||
mMenuItems.clear();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool PopupMenu::canHandleID(U32 id)
|
||||
{
|
||||
|
|
@ -498,6 +503,11 @@ DefineConsoleMethod(PopupMenu, getItemCount, S32, (), , "()")
|
|||
return object->getItemCount();
|
||||
}
|
||||
|
||||
DefineConsoleMethod(PopupMenu, clearItems, void, (), , "()")
|
||||
{
|
||||
return object->clearItems();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
DefineConsoleMethod(PopupMenu, showPopup, void, (const char * canvasName, S32 x, S32 y), ( -1, -1), "(Canvas,[x, y])")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -137,6 +137,9 @@ public:
|
|||
/// Returns the number of items in the menu.
|
||||
U32 getItemCount();
|
||||
|
||||
///Clears all items
|
||||
void clearItems();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/// Displays this menu as a popup menu and blocks until the user has selected
|
||||
/// an item.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue