Allow hiding menusections

Cherry-picked from 75437c7d4c
This commit is contained in:
jacob1
2016-07-02 11:20:29 -04:00
parent 111468c672
commit 88097496af
3 changed files with 32 additions and 13 deletions

View File

@@ -248,9 +248,18 @@ void GameModel::BuildMenus()
elementTools.clear();
//Create menus
for(int i = 0; i < SC_TOTAL; i++)
for (int i = 1; i < SC_TOOL; i++)
{
menuList.push_back(new Menu((const char)sim->msections[i].icon[0], sim->msections[i].name));
sim->msections[i].doshow = 0;
}
for (int i = 0; i < PT_NUM; i++)
{
if (sim->elements[i].Enabled && sim->elements[i].MenuVisible)
sim->msections[sim->elements[i].MenuSection].doshow = 1;
}
for (int i = 0; i < SC_TOTAL; i++)
{
menuList.push_back(new Menu((const char)sim->msections[i].icon[0], sim->msections[i].name, sim->msections[i].doshow));
}
//Build menus from Simulation elements

View File

@@ -606,6 +606,8 @@ void GameView::NotifyMenuListChanged(GameModel * sender)
toolButtons.clear();
vector<Menu*> menuList = sender->GetMenuList();
for (int i = (int)menuList.size()-1; i >= 0; i--)
{
if (menuList[i]->GetVisible())
{
std::string tempString = "";
tempString += menuList[i]->GetIcon();
@@ -617,6 +619,7 @@ void GameView::NotifyMenuListChanged(GameModel * sender)
AddComponent(tempButton);
menuButtons.push_back(tempButton);
}
}
}
void GameView::SetSample(SimulationSample sample)

View File

@@ -8,11 +8,13 @@ class Menu
char icon;
string description;
vector<Tool*> tools;
bool visible;
public:
Menu(char icon_, string description_):
Menu(char icon_, string description_, int visible_):
icon(icon_),
description(description_),
tools(vector<Tool*>())
tools(vector<Tool*>()),
visible(visible_ ? true : false)
{
}
@@ -41,6 +43,11 @@ public:
return description;
}
bool GetVisible()
{
return visible;
}
void AddTool(Tool * tool_)
{
tools.push_back(tool_);