diff options
| author | jacob1 <jfu614@gmail.com> | 2013-05-15 03:50:26 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-05-15 03:50:26 (GMT) |
| commit | 94d21a1679749df49342903545192254a27f8ffc (patch) | |
| tree | 81d4f9771b4821ad29b0dee0240febcb4e08280e /src/gui/game/GameModel.cpp | |
| parent | ab3675d6eea1ce6eeeac713ed44f5cb591ff820f (diff) | |
| download | powder-94d21a1679749df49342903545192254a27f8ffc.zip powder-94d21a1679749df49342903545192254a27f8ffc.tar.gz | |
when called with no arguments, some tpt. functions will act as get functions (unfinished)
Also, redo some menu stuff to use int's instead of Menu *s, and fix bug with toggleable buttons being toggled without triggering their actions
Diffstat (limited to 'src/gui/game/GameModel.cpp')
| -rw-r--r-- | src/gui/game/GameModel.cpp | 64 |
1 files changed, 27 insertions, 37 deletions
diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index 18276d0..960f45a 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -31,7 +31,7 @@ GameModel::GameModel(): colour(255, 0, 0, 255), toolStrength(1.0f), activeColourPreset(-1), - activeMenu(NULL), + activeMenu(-1), edgeMode(0) { sim = new Simulation(); @@ -221,9 +221,9 @@ void GameModel::BuildQuickOptionMenu(GameController * controller) void GameModel::BuildMenus() { - char lastMenu = 0; - if(activeMenu) - lastMenu = activeMenu->GetIcon(); + int lastMenu = -1; + if(activeMenu != -1) + lastMenu = activeMenu; std::string activeToolIdentifiers[3]; if(regularToolset[0]) @@ -346,19 +346,15 @@ void GameModel::BuildMenus() lastTool = activeTools[0]; //Set default menu - activeMenu = menuList[SC_POWDERS]; + activeMenu = SC_POWDERS; - if(lastMenu) + if(lastMenu != -1) //What is this? ... { - for(std::vector<Menu*>::iterator iter = menuList.begin(), end = menuList.end(); iter != end; ++iter) - { - if((*iter)->GetIcon() == lastMenu) - activeMenu = *iter; - } + activeMenu = lastMenu; } - if(activeMenu) - toolList = activeMenu->GetToolList(); + if(activeMenu != -1) + toolList = menuList[activeMenu]->GetToolList(); else toolList = std::vector<Tool*>(); @@ -471,32 +467,26 @@ float GameModel::GetToolStrength() return toolStrength; } -void GameModel::SetActiveMenu(Menu * menu) +void GameModel::SetActiveMenu(int menuID) { - for(int i = 0; i < menuList.size(); i++) + activeMenu = menuID; + toolList = menuList[menuID]->GetToolList(); + notifyToolListChanged(); + + if(menuID == SC_DECO) { - if(menuList[i]==menu) + if(activeTools != decoToolset) { - activeMenu = menu; - toolList = menu->GetToolList(); - notifyToolListChanged(); - - if(menu == menuList[SC_DECO]) - { - if(activeTools != decoToolset) - { - activeTools = decoToolset; - notifyActiveToolsChanged(); - } - } - else - { - if(activeTools != regularToolset) - { - activeTools = regularToolset; - notifyActiveToolsChanged(); - } - } + activeTools = decoToolset; + notifyActiveToolsChanged(); + } + } + else + { + if(activeTools != regularToolset) + { + activeTools = regularToolset; + notifyActiveToolsChanged(); } } } @@ -511,7 +501,7 @@ vector<Tool*> GameModel::GetToolList() return toolList; } -Menu * GameModel::GetActiveMenu() +int GameModel::GetActiveMenu() { return activeMenu; } |
