From e515512d88eab18794cf490ad55d4050a8d9f403 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Mon, 14 Jan 2013 13:11:01 -0500 Subject: [PATCH] deco menu needs to be clicked to enter, press 'b' to get out of deco editor too --- src/game/GameController.cpp | 11 +++++------ src/game/GameController.h | 2 +- src/game/GameView.cpp | 33 ++++++++++++++++++++++++++------- src/game/GameView.h | 1 + 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 01b4b139f..0b3568144 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -925,6 +925,11 @@ void GameController::SetActiveMenu(Menu * menu) gameModel->SetColourSelectorVisibility(false); } +std::vector GameController::GetMenuList() +{ + return gameModel->GetMenuList(); +} + void GameController::SetActiveTool(int toolSelection, Tool * tool) { commandInterface->OnActiveToolChanged(toolSelection, tool); @@ -1387,9 +1392,3 @@ void GameController::RunUpdater() Exit(); new UpdateActivity(); } - -std::vector GameController::GetMenuList() -{ - return gameModel->GetMenuList(); -} - diff --git a/src/game/GameController.h b/src/game/GameController.h index 53b83d468..4f82243c6 100644 --- a/src/game/GameController.h +++ b/src/game/GameController.h @@ -98,6 +98,7 @@ public: void ShowGravityGrid(); void SetHudEnable(bool hudState); void SetActiveMenu(Menu * menu); + std::vector GetMenuList(); void SetActiveTool(int toolSelection, Tool * tool); void SetActiveColourPreset(int preset); void SetColour(ui::Colour colour); @@ -148,7 +149,6 @@ public: virtual void NotifyAuthUserChanged(Client * sender); virtual void NotifyNewNotification(Client * sender, std::pair notification); void RunUpdater(); - std::vector GetMenuList(); }; #endif // GAMECONTROLLER_H diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index bd9b879c0..82dd63048 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -185,7 +185,8 @@ GameView::GameView(): recordingIndex(0), toolTipPresence(0), currentSaveType(0), - lastLogEntry(0.0f) + lastLogEntry(0.0f), + lastMenu(NULL) { int currentX = 1; @@ -451,15 +452,25 @@ class GameView::MenuAction: public ui::ButtonAction GameView * v; public: Menu * menu; - MenuAction(GameView * _v, Menu * menu_) { v = _v; menu = menu_; } + bool needsClick = false; + MenuAction(GameView * _v, Menu * menu_) + { + v = _v; + menu = menu_; + if (v->c->GetMenuList()[SC_DECO] == menu) + needsClick = true; + } void MouseEnterCallback(ui::Button * sender) { - if(!ui::Engine::Ref().GetMouseButton()) + if(!needsClick && !ui::Engine::Ref().GetMouseButton()) v->c->SetActiveMenu(menu); } void ActionCallback(ui::Button * sender) { - MouseEnterCallback(sender); + if (needsClick) + v->c->SetActiveMenu(menu); + else + MouseEnterCallback(sender); } }; @@ -674,7 +685,8 @@ void GameView::NotifyToolListChanged(GameModel * sender) AddComponent(tempButton); toolButtons.push_back(tempButton); } - + if (sender->GetActiveMenu() != sender->GetMenuList()[SC_DECO]) + lastMenu = sender->GetActiveMenu(); } void GameView::NotifyColourSelectorVisibilityChanged(GameModel * sender) @@ -1322,8 +1334,15 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool case 'b': if(ctrl) c->SetDecoration(); - else - c->SetActiveMenu(c->GetMenuList()[SC_DECO]); + else + if (colourPicker->GetParentWindow()) + c->SetActiveMenu(lastMenu); + else + { + c->SetDecoration(true); + c->SetPaused(true); + c->SetActiveMenu(c->GetMenuList()[SC_DECO]); + } break; case 'y': c->SwitchAir(); diff --git a/src/game/GameView.h b/src/game/GameView.h index 7474da0e5..ff688d9d7 100644 --- a/src/game/GameView.h +++ b/src/game/GameView.h @@ -56,6 +56,7 @@ private: std::string introTextMessage; int toolIndex; int currentSaveType; + Menu * lastMenu; int infoTipPresence; std::string toolTip;