Make elem.free rebuild menus (fixes #649)
Also make sure removed elements don't stay selected.
This commit is contained in:
parent
75e6ece184
commit
8897c6daea
@ -353,22 +353,21 @@ void GameModel::BuildMenus()
|
|||||||
decoToolset[2] = GetToolFromIdentifier("DEFAULT_UI_SAMPLE");
|
decoToolset[2] = GetToolFromIdentifier("DEFAULT_UI_SAMPLE");
|
||||||
decoToolset[3] = GetToolFromIdentifier("DEFAULT_PT_NONE");
|
decoToolset[3] = GetToolFromIdentifier("DEFAULT_PT_NONE");
|
||||||
|
|
||||||
//Set default tools
|
|
||||||
regularToolset[0] = GetToolFromIdentifier("DEFAULT_PT_DUST");
|
|
||||||
regularToolset[1] = GetToolFromIdentifier("DEFAULT_PT_NONE");
|
|
||||||
regularToolset[2] = GetToolFromIdentifier("DEFAULT_UI_SAMPLE");
|
|
||||||
regularToolset[3] = GetToolFromIdentifier("DEFAULT_PT_NONE");
|
|
||||||
|
|
||||||
|
|
||||||
if(activeToolIdentifiers[0].length())
|
|
||||||
regularToolset[0] = GetToolFromIdentifier(activeToolIdentifiers[0]);
|
regularToolset[0] = GetToolFromIdentifier(activeToolIdentifiers[0]);
|
||||||
if(activeToolIdentifiers[1].length())
|
|
||||||
regularToolset[1] = GetToolFromIdentifier(activeToolIdentifiers[1]);
|
regularToolset[1] = GetToolFromIdentifier(activeToolIdentifiers[1]);
|
||||||
if(activeToolIdentifiers[2].length())
|
|
||||||
regularToolset[2] = GetToolFromIdentifier(activeToolIdentifiers[2]);
|
regularToolset[2] = GetToolFromIdentifier(activeToolIdentifiers[2]);
|
||||||
if(activeToolIdentifiers[3].length())
|
|
||||||
regularToolset[3] = GetToolFromIdentifier(activeToolIdentifiers[3]);
|
regularToolset[3] = GetToolFromIdentifier(activeToolIdentifiers[3]);
|
||||||
|
|
||||||
|
//Set default tools
|
||||||
|
if (!regularToolset[0])
|
||||||
|
regularToolset[0] = GetToolFromIdentifier("DEFAULT_PT_DUST");
|
||||||
|
if (!regularToolset[1])
|
||||||
|
regularToolset[1] = GetToolFromIdentifier("DEFAULT_PT_NONE");
|
||||||
|
if (!regularToolset[2])
|
||||||
|
regularToolset[2] = GetToolFromIdentifier("DEFAULT_UI_SAMPLE");
|
||||||
|
if (!regularToolset[3])
|
||||||
|
regularToolset[3] = GetToolFromIdentifier("DEFAULT_PT_NONE");
|
||||||
|
|
||||||
lastTool = activeTools[0];
|
lastTool = activeTools[0];
|
||||||
|
|
||||||
//Set default menu
|
//Set default menu
|
||||||
@ -412,24 +411,26 @@ void GameModel::BuildFavoritesMenu()
|
|||||||
notifyLastToolChanged();
|
notifyLastToolChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
Tool * GameModel::GetToolFromIdentifier(ByteString identifier)
|
Tool *GameModel::GetToolFromIdentifier(ByteString const &identifier)
|
||||||
{
|
{
|
||||||
for (std::vector<Menu*>::iterator iter = menuList.begin(), end = menuList.end(); iter != end; ++iter)
|
for (auto *menu : menuList)
|
||||||
{
|
{
|
||||||
std::vector<Tool*> menuTools = (*iter)->GetToolList();
|
for (auto *tool : menu->GetToolList())
|
||||||
for (std::vector<Tool*>::iterator titer = menuTools.begin(), tend = menuTools.end(); titer != tend; ++titer)
|
|
||||||
{
|
{
|
||||||
if (identifier == (*titer)->GetIdentifier())
|
if (identifier == tool->GetIdentifier())
|
||||||
return *titer;
|
{
|
||||||
|
return tool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (std::vector<Tool*>::iterator iter = extraElementTools.begin(), end = extraElementTools.end(); iter != end; ++iter)
|
|
||||||
{
|
|
||||||
if (identifier == (*iter)->GetIdentifier())
|
|
||||||
return *iter;
|
|
||||||
}
|
}
|
||||||
|
for (auto *extra : extraElementTools)
|
||||||
return NULL;
|
{
|
||||||
|
if (identifier == extra->GetIdentifier())
|
||||||
|
{
|
||||||
|
return extra;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameModel::SetEdgeMode(int edgeMode)
|
void GameModel::SetEdgeMode(int edgeMode)
|
||||||
|
@ -147,7 +147,7 @@ public:
|
|||||||
float GetToolStrength();
|
float GetToolStrength();
|
||||||
Tool * GetLastTool();
|
Tool * GetLastTool();
|
||||||
void SetLastTool(Tool * newTool);
|
void SetLastTool(Tool * newTool);
|
||||||
Tool * GetToolFromIdentifier(ByteString identifier);
|
Tool *GetToolFromIdentifier(ByteString const &identifier);
|
||||||
Tool * GetElementTool(int elementID);
|
Tool * GetElementTool(int elementID);
|
||||||
std::vector<Tool*> GetToolList();
|
std::vector<Tool*> GetToolList();
|
||||||
std::vector<Tool*> GetUnlistedTools();
|
std::vector<Tool*> GetUnlistedTools();
|
||||||
|
@ -2876,6 +2876,7 @@ int LuaScriptInterface::elements_free(lua_State * l)
|
|||||||
}
|
}
|
||||||
|
|
||||||
luacon_sim->elements[id].Enabled = false;
|
luacon_sim->elements[id].Enabled = false;
|
||||||
|
luacon_model->BuildMenus();
|
||||||
|
|
||||||
lua_getglobal(l, "elements");
|
lua_getglobal(l, "elements");
|
||||||
lua_pushnil(l);
|
lua_pushnil(l);
|
||||||
|
Reference in New Issue
Block a user