diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-22 23:24:49 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-22 23:24:49 (GMT) |
| commit | 8c0678fa48f9598a5ade2d4960c46bfea7e6abef (patch) | |
| tree | 880535e7984c24948d345932f680ef806baa4cec /src/game/GameModel.cpp | |
| parent | 19c1fa5dcb4c4a2ba9d692e136b17da316a2631b (diff) | |
| download | powder-8c0678fa48f9598a5ade2d4960c46bfea7e6abef.zip powder-8c0678fa48f9598a5ade2d4960c46bfea7e6abef.tar.gz | |
Begining menu, tool
Diffstat (limited to 'src/game/GameModel.cpp')
| -rw-r--r-- | src/game/GameModel.cpp | 82 |
1 files changed, 77 insertions, 5 deletions
diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp index 3070093..090f46a 100644 --- a/src/game/GameModel.cpp +++ b/src/game/GameModel.cpp @@ -7,7 +7,7 @@ #include "Brush.h" GameModel::GameModel(): - activeElement(1), + activeTool(NULL), sim(NULL), ren(NULL), currentSave(NULL), @@ -15,10 +15,35 @@ GameModel::GameModel(): { sim = new Simulation(); ren = new Renderer(ui::Engine::Ref().g, sim); + + menuList.clear(); + for(int i = 0; i < 12; i++) + { + menuList.push_back(new Menu('q', "Simon")); + } + //Build menus from Simulation elements + for(int i = 0; i < PT_NUM; i++) + { + if(sim->ptypes[i].menusection < 12) + { + Tool * tempTool = new ElementTool(i, sim->ptypes[i].name, 0, 0, 0); + menuList[sim->ptypes[i].menusection]->AddTool(tempTool); + } + } + + activeTool = new ElementTool(1, "TURD", 0, 0, 0); } GameModel::~GameModel() { + for(int i = 0; i < menuList.size(); i++) + { + for(int j = 0; i < menuList[i]->GetToolList().size(); i++) + { + delete menuList[i]->GetToolList()[j]; + } + delete menuList[i]; + } delete sim; delete ren; } @@ -36,22 +61,53 @@ void GameModel::AddObserver(GameView * observer){ observer->NotifyPausedChanged(this); observer->NotifySaveChanged(this); observer->NotifyBrushChanged(this); + observer->NotifyMenuListChanged(this); + observer->NotifyToolListChanged(this); +} + +void GameModel::SetActiveMenu(Menu * menu) +{ + for(int i = 0; i < menuList.size(); i++) + { + if(menuList[i]==menu) + { + activeMenu = menu; + toolList = menu->GetToolList(); + notifyToolListChanged(); + } + } } -int GameModel::GetActiveElement() +vector<Tool*> GameModel::GetToolList() { - return activeElement; + return toolList; } -void GameModel::SetActiveElement(int element) +Menu * GameModel::GetActiveMenu() { - activeElement = element; + return activeMenu; +} + +Tool * GameModel::GetActiveTool() +{ + return activeTool; +} + +void GameModel::SetActiveTool(Tool * tool) +{ + activeTool = tool; +} + +vector<Menu*> GameModel::GetMenuList() +{ + return menuList; } Save * GameModel::GetSave() { return currentSave; } + void GameModel::SetSave(Save * newSave) { currentSave = newSave; @@ -123,3 +179,19 @@ void GameModel::notifyBrushChanged() observers[i]->NotifyBrushChanged(this); } } + +void GameModel::notifyMenuListChanged() +{ + for(int i = 0; i < observers.size(); i++) + { + observers[i]->NotifyMenuListChanged(this); + } +} + +void GameModel::notifyToolListChanged() +{ + for(int i = 0; i < observers.size(); i++) + { + observers[i]->NotifyToolListChanged(this); + } +} |
