Add remaining buttons for game screen

This commit is contained in:
Simon Robertshaw 2012-01-22 11:15:34 +00:00
parent 57ab7bca76
commit 91bb5a8b78
2 changed files with 74 additions and 33 deletions

View File

@ -9,22 +9,8 @@ GameView::GameView():
isMouseDown(false), isMouseDown(false),
ren(NULL) ren(NULL)
{ {
int currentX = 1;
//Set up UI //Set up UI
class PauseAction : public ui::ButtonAction
{
GameView * v;
public:
PauseAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender)
{
v->c->SetPaused(sender->GetToggleState());
}
};
pauseButton = new ui::Button(ui::Point(Size.X-18, Size.Y-18), ui::Point(16, 16), "\x90"); //Pause
pauseButton->SetTogglable(true);
pauseButton->SetActionCallback(new PauseAction(this));
AddComponent(pauseButton);
class SearchAction : public ui::ButtonAction class SearchAction : public ui::ButtonAction
{ {
GameView * v; GameView * v;
@ -35,7 +21,8 @@ GameView::GameView():
v->c->OpenSearch(); v->c->OpenSearch();
} }
}; };
searchButton = new ui::Button(ui::Point(1, Size.Y-18), ui::Point(16, 16), "\x81"); //Open searchButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16), "\x81"); //Open
currentX+=18;
searchButton->SetTogglable(false); searchButton->SetTogglable(false);
searchButton->SetActionCallback(new SearchAction(this)); searchButton->SetActionCallback(new SearchAction(this));
AddComponent(searchButton); AddComponent(searchButton);
@ -50,8 +37,8 @@ GameView::GameView():
v->c->OpenSearch(); // TODO call proper function v->c->OpenSearch(); // TODO call proper function
} }
}; };
reloadButton = new ui::Button(ui::Point(16, Size.Y-18), ui::Point(16, 16), "\x91"); // TODO Position? reloadButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16), "\x91"); // TODO Position?
reloadButton->SetTogglable(false); currentX+=18;
reloadButton->SetActionCallback(new ReloadAction(this)); reloadButton->SetActionCallback(new ReloadAction(this));
AddComponent(reloadButton); AddComponent(reloadButton);
@ -65,8 +52,8 @@ GameView::GameView():
v->c->OpenSearch(); // TODO call proper function v->c->OpenSearch(); // TODO call proper function
} }
}; };
saveSimulationButton = new ui::Button(ui::Point(32, Size.Y-18), ui::Point(152, 16), "\x82"); // TODO All arguments saveSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(Size.X/5, 16), "\x82"); // TODO All arguments
saveSimulationButton->SetTogglable(false); currentX+=(Size.X/5)+2;
saveSimulationButton->SetActionCallback(new SaveSimulationAction(this)); saveSimulationButton->SetActionCallback(new SaveSimulationAction(this));
AddComponent(saveSimulationButton); AddComponent(saveSimulationButton);
@ -80,8 +67,8 @@ GameView::GameView():
v->c->OpenSearch(); // TODO call proper function v->c->OpenSearch(); // TODO call proper function
} }
}; };
upVoteButton = new ui::Button(ui::Point(184, Size.Y-18), ui::Point(16, 16), "\xCB"); // TODO All arguments upVoteButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16), "\xCB"); // TODO All arguments
upVoteButton->SetTogglable(false); currentX+=16;
upVoteButton->SetActionCallback(new UpVoteAction(this)); upVoteButton->SetActionCallback(new UpVoteAction(this));
AddComponent(upVoteButton); AddComponent(upVoteButton);
@ -95,8 +82,8 @@ GameView::GameView():
v->c->OpenSearch(); // TODO call proper function v->c->OpenSearch(); // TODO call proper function
} }
}; };
downVoteButton = new ui::Button(ui::Point(200, Size.Y-18), ui::Point(16, 16), "\xCA"); // TODO All arguments downVoteButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16), "\xCA"); // TODO All arguments
downVoteButton->SetTogglable(false); currentX+=18;
downVoteButton->SetActionCallback(new DownVoteAction(this)); downVoteButton->SetActionCallback(new DownVoteAction(this));
AddComponent(downVoteButton); AddComponent(downVoteButton);
@ -110,14 +97,52 @@ GameView::GameView():
v->c->OpenSearch(); // TODO call proper function v->c->OpenSearch(); // TODO call proper function
} }
}; };
tagSimulationButton = new ui::Button(ui::Point(216, Size.Y-18), ui::Point(152, 16), "\x83"); // TODO All arguments tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(Size.X-(currentX+176), 16), "\x83"); // TODO All arguments
tagSimulationButton->SetTogglable(false); currentX+=Size.X-(currentX+176);
tagSimulationButton->SetActionCallback(new TagSimulationAction(this)); tagSimulationButton->SetActionCallback(new TagSimulationAction(this));
AddComponent(tagSimulationButton); AddComponent(tagSimulationButton);
//simul option class ClearSimAction : public ui::ButtonAction
//erase all {
// login GameView * v;
public:
ClearSimAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender)
{
v->c->SetPaused(sender->GetToggleState()); // TODO call proper function
}
};
clearSimButton = new ui::Button(ui::Point(Size.X-174, Size.Y-18), ui::Point(16, 16), "C"); // TODO All arguments
clearSimButton->SetActionCallback(new ClearSimAction(this));
AddComponent(clearSimButton);
class LoginAction : public ui::ButtonAction
{
GameView * v;
public:
LoginAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender)
{
v->c->SetPaused(sender->GetToggleState()); // TODO call proper function
}
};
loginButton = new ui::Button(ui::Point(Size.X-156, Size.Y-18), ui::Point(100, 16), "\xDA Login"); // TODO All arguments
loginButton->SetActionCallback(new LoginAction(this));
AddComponent(loginButton);
class SimulationOptionAction : public ui::ButtonAction
{
GameView * v;
public:
SimulationOptionAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender)
{
v->c->SetPaused(sender->GetToggleState()); // TODO call proper function
}
};
simulationOptionButton = new ui::Button(ui::Point(Size.X-54, Size.Y-18), ui::Point(16, 16), "\xDA"); // TODO All arguments
simulationOptionButton->SetActionCallback(new SimulationOptionAction(this));
AddComponent(simulationOptionButton);
class DisplayModeAction : public ui::ButtonAction class DisplayModeAction : public ui::ButtonAction
{ {
@ -129,10 +154,24 @@ GameView::GameView():
v->c->SetPaused(sender->GetToggleState()); // TODO call proper function v->c->SetPaused(sender->GetToggleState()); // TODO call proper function
} }
}; };
displayModeButton = new ui::Button(ui::Point(Size.X-34, Size.Y-18), ui::Point(16, 16), "\xDA"); // TODO All arguments displayModeButton = new ui::Button(ui::Point(Size.X-36, Size.Y-18), ui::Point(16, 16), "\xDA"); // TODO All arguments
displayModeButton->SetTogglable(true);
displayModeButton->SetActionCallback(new DisplayModeAction(this)); displayModeButton->SetActionCallback(new DisplayModeAction(this));
AddComponent(displayModeButton); AddComponent(displayModeButton);
class PauseAction : public ui::ButtonAction
{
GameView * v;
public:
PauseAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender)
{
v->c->SetPaused(sender->GetToggleState());
}
};
pauseButton = new ui::Button(ui::Point(Size.X-18, Size.Y-18), ui::Point(16, 16), "\x90"); //Pause
pauseButton->SetTogglable(true);
pauseButton->SetActionCallback(new PauseAction(this));
AddComponent(pauseButton);
} }
void GameView::NotifyRendererChanged(GameModel * sender) void GameView::NotifyRendererChanged(GameModel * sender)

View File

@ -20,15 +20,17 @@ private:
GameController * c; GameController * c;
Renderer * ren; Renderer * ren;
//UI Elements //UI Elements
ui::Button * pauseButton;
ui::Button * searchButton; ui::Button * searchButton;
ui::Button * reloadButton; ui::Button * reloadButton;
ui::Button * saveSimulationButton; ui::Button * saveSimulationButton;
ui::Button * downVoteButton; ui::Button * downVoteButton;
ui::Button * upVoteButton; ui::Button * upVoteButton;
ui::Button * tagSimulationButton; ui::Button * tagSimulationButton;
ui::Button * clearSimButton;
ui::Button * loginButton;
ui::Button * simulationOptionButton;
ui::Button * displayModeButton; ui::Button * displayModeButton;
ui::Button * pauseButton;
public: public:
GameView(); GameView();
void AttachController(GameController * _c){ c = _c; } void AttachController(GameController * _c){ c = _c; }