summaryrefslogtreecommitdiff
path: root/src/game/GameView.cpp
diff options
context:
space:
mode:
authorSimon 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)
commit8c0678fa48f9598a5ade2d4960c46bfea7e6abef (patch)
tree880535e7984c24948d345932f680ef806baa4cec /src/game/GameView.cpp
parent19c1fa5dcb4c4a2ba9d692e136b17da316a2631b (diff)
downloadpowder-8c0678fa48f9598a5ade2d4960c46bfea7e6abef.zip
powder-8c0678fa48f9598a5ade2d4960c46bfea7e6abef.tar.gz
Begining menu, tool
Diffstat (limited to 'src/game/GameView.cpp')
-rw-r--r--src/game/GameView.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index 7fe4fa5..ed2094d 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -175,6 +175,62 @@ GameView::GameView():
AddComponent(pauseButton);
}
+class GameView::MenuAction: public ui::ButtonAction
+{
+ GameView * v;
+public:
+ Menu * menu;
+ MenuAction(GameView * _v, Menu * menu_) { v = _v; menu = menu_; }
+ void ActionCallback(ui::Button * sender)
+ {
+ v->c->SetActiveMenu(menu);
+ }
+};
+
+void GameView::NotifyMenuListChanged(GameModel * sender)
+{
+ int currentY = YRES+MENUSIZE-36;
+ for(int i = 0; i < menuButtons.size(); i++)
+ {
+ RemoveComponent(menuButtons[i]);
+ delete menuButtons[i];
+ }
+ menuButtons.clear();
+ for(int i = 0; i < toolButtons.size(); i++)
+ {
+ RemoveComponent(toolButtons[i]);
+ delete toolButtons[i];
+ }
+ toolButtons.clear();
+ vector<Menu*> menuList = sender->GetMenuList();
+ for(int i = 0; i < menuList.size(); i++)
+ {
+ std::string tempString = "";
+ tempString += menuList[i]->GetIcon();
+ ui::Button * tempButton = new ui::Button(ui::Point(XRES+BARSIZE-18, currentY), ui::Point(16, 16), tempString);
+ tempButton->SetTogglable(true);
+ tempButton->SetActionCallback(new MenuAction(this, menuList[i]));
+ currentY-=18;
+ AddComponent(tempButton);
+ menuButtons.push_back(tempButton);
+ }
+}
+
+void GameView::NotifyToolListChanged(GameModel * sender)
+{
+ for(int i = 0; i < menuButtons.size(); i++)
+ {
+ if(((MenuAction*)menuButtons[i]->GetActionCallback())->menu==sender->GetActiveMenu())
+ {
+ menuButtons[i]->SetToggleState(true);
+ }
+ else
+ {
+ menuButtons[i]->SetToggleState(false);
+ }
+ }
+}
+
void GameView::NotifyRendererChanged(GameModel * sender)
{
ren = sender->GetRenderer();