LibD/src/Main/TitleScreen.cpp
Rtch90 5e77a6844e [Fix] Fixed conflicts and a font typo.
Merge branch 'master' of github.com:Allanis/LibD

Conflicts:
	LibDQt/LibDQt.pro
2012-04-19 13:00:34 +01:00

62 lines
1.2 KiB
C++

#include "TitleScreen.h"
#include "../Font/Font.h"
#include "../UI/Button.h"
#include "../Global/Globals.h"
TitleScreen::TitleScreen(void) {
_alive = true;
_result = TitleScreen::QUIT;
_font = new Font();
_font->Load("../Data/Font/Fairydust.ttf", 24);
Button* newGameButton = new Button();
Button* loadGameButton = new Button();
Button* quitButton = new Button();
newGameButton->SetFont(_font);
loadGameButton->SetFont(_font);
quitButton->SetFont(_font);
newGameButton->SetText("New Game");
loadGameButton->SetText("Load Game");
quitButton->SetText("Quit");
_menu.AddButton(newGameButton);
_menu.AddButton(loadGameButton);
_menu.AddButton(quitButton);
_menu.AlignButtons(Menu::ALIGN_VERTICALLY);
}
TitleScreen::~TitleScreen(void) {
if(_font) {
delete _font;
_font = NULL;
}
}
void TitleScreen::Update(float dt) {
_menu.Update();
switch(_menu.GetTriggeredButton()) {
case 0:
_alive = false;
_result = TitleScreen::NEW_GAME;
break;
case 1:
_alive = false;
_result = TitleScreen::LOAD_GAME;
break;
case 2:
_alive = false;
_result = TitleScreen::QUIT;
break;
}
}
void TitleScreen::Render(void) {
_menu.SetXY(32, windowHeight - 128);
_menu.Render();
}