summaryrefslogtreecommitdiff
path: root/src/gui/game/GameView.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/game/GameView.cpp')
-rw-r--r--src/gui/game/GameView.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp
index 925ff2c..f054793 100644
--- a/src/gui/game/GameView.cpp
+++ b/src/gui/game/GameView.cpp
@@ -189,7 +189,7 @@ GameView::GameView():
toolTipPresence(0),
currentSaveType(0),
lastLogEntry(0.0f),
- lastMenu(NULL)
+ lastMenu(-1)
{
int currentX = 1;
@@ -403,7 +403,6 @@ GameView::GameView():
};
pauseButton = new ui::Button(ui::Point(Size.X-16, Size.Y-16), ui::Point(15, 15), "", "Pause/Resume the simulation"); //Pause
pauseButton->SetIcon(IconPause);
- pauseButton->SetTogglable(true);
pauseButton->SetActionCallback(new PauseAction(this));
AddComponent(pauseButton);
@@ -459,13 +458,13 @@ class GameView::MenuAction: public ui::ButtonAction
{
GameView * v;
public:
- Menu * menu;
+ int menuID;
bool needsClick;
- MenuAction(GameView * _v, Menu * menu_)
+ MenuAction(GameView * _v, int menuID_)
{
v = _v;
- menu = menu_;
- if (v->c->GetMenuList()[SC_DECO] == menu)
+ menuID = menuID_;
+ if (menuID == SC_DECO)
needsClick = true;
else
needsClick = false;
@@ -473,12 +472,12 @@ public:
void MouseEnterCallback(ui::Button * sender)
{
if(!needsClick && !ui::Engine::Ref().GetMouseButton())
- v->c->SetActiveMenu(menu);
+ v->c->SetActiveMenu(menuID);
}
void ActionCallback(ui::Button * sender)
{
if (needsClick)
- v->c->SetActiveMenu(menu);
+ v->c->SetActiveMenu(menuID);
else
MouseEnterCallback(sender);
}
@@ -566,15 +565,14 @@ void GameView::NotifyMenuListChanged(GameModel * sender)
}
toolButtons.clear();
vector<Menu*> menuList = sender->GetMenuList();
- for(vector<Menu*>::reverse_iterator iter = menuList.rbegin(), end = menuList.rend(); iter != end; ++iter)
+ for (int i = menuList.size()-1; i >= 0; i--)
{
std::string tempString = "";
- Menu * item = *iter;
- tempString += item->GetIcon();
- ui::Button * tempButton = new ui::Button(ui::Point(XRES+BARSIZE-16, currentY), ui::Point(15, 15), tempString, item->GetDescription());
+ tempString += menuList[i]->GetIcon();
+ ui::Button * tempButton = new ui::Button(ui::Point(XRES+BARSIZE-16, currentY), ui::Point(15, 15), tempString, menuList[i]->GetDescription());
tempButton->Appearance.Margin = ui::Border(0, 2, 3, 2);
tempButton->SetTogglable(true);
- tempButton->SetActionCallback(new MenuAction(this, item));
+ tempButton->SetActionCallback(new MenuAction(this, i));
currentY-=16;
AddComponent(tempButton);
menuButtons.push_back(tempButton);
@@ -591,6 +589,11 @@ void GameView::SetHudEnable(bool hudState)
showHud = hudState;
}
+bool GameView::GetHudEnable()
+{
+ return showHud;
+}
+
ui::Point GameView::GetMousePosition()
{
return mousePosition;
@@ -643,7 +646,7 @@ void GameView::NotifyToolListChanged(GameModel * sender)
int totalColour;
for(int i = 0; i < menuButtons.size(); i++)
{
- if(((MenuAction*)menuButtons[i]->GetActionCallback())->menu==sender->GetActiveMenu())
+ if(((MenuAction*)menuButtons[i]->GetActionCallback())->menuID==sender->GetActiveMenu())
{
menuButtons[i]->SetToggleState(true);
}
@@ -698,7 +701,7 @@ void GameView::NotifyToolListChanged(GameModel * sender)
AddComponent(tempButton);
toolButtons.push_back(tempButton);
}
- if (sender->GetActiveMenu() != sender->GetMenuList()[SC_DECO])
+ if (sender->GetActiveMenu() != SC_DECO)
lastMenu = sender->GetActiveMenu();
}
@@ -1364,7 +1367,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
{
c->SetDecoration(true);
c->SetPaused(true);
- c->SetActiveMenu(c->GetMenuList()[SC_DECO]);
+ c->SetActiveMenu(SC_DECO);
}
break;
case 'y':