#include <HangmanGame.h>

Public Member Functions | |
| HangmanGame (WContainerWidget *parent) | |
Private Member Functions | |
| void | doLogin () |
| void | play (std::wstring user, Dictionary dictionary) |
| void | showGame () |
| void | showHighScores () |
Private Attributes | |
| WStackedWidget * | MainStack |
| LoginWidget * | Login |
| HangmanWidget * | Game |
| HighScoresWidget * | Scores |
| WText * | BackToGameText |
| WText * | ScoresText |
Definition at line 25 of file HangmanGame.h.
| HangmanGame::HangmanGame | ( | WContainerWidget * | parent ) |
Definition at line 18 of file HangmanGame.C.
: WTable(parent) { resize(WLength(100, WLength::Percentage), WLength::Auto); WText *title = new WText(L"A Witty game: Hangman", elementAt(0,0)); title->decorationStyle().font().setSize(WFont::XXLarge); // Center the title horizontally. elementAt(0, 0)->setContentAlignment(AlignTop | AlignCenter); // Element (1,1) holds a stack of widgets with the main content. // This is where we switch between Login, Game, and Highscores widgets. MainStack = new WStackedWidget(elementAt(1, 0)); MainStack->setPadding(20); MainStack->addWidget(Login = new LoginWidget()); Login->loginSuccessful.connect(this, &HangmanGame::play); // Element (2,0) contains navigation buttons. Instead of WButton, // we use WText. WText inherits from WInteractWidget, and thus exposes // the click event. BackToGameText = new WText(L" Gaming Grounds ", elementAt(2, 0)); BackToGameText->decorationStyle().setCursor(PointingHandCursor); BackToGameText->clicked().connect(this, &HangmanGame::showGame); ScoresText = new WText(L" Highscores ", elementAt(2, 0)); ScoresText->decorationStyle().setCursor(PointingHandCursor); ScoresText->clicked().connect(this, &HangmanGame::showHighScores); // Center the buttons horizontally. elementAt(2, 0)->setContentAlignment(AlignTop | AlignCenter); doLogin(); }
| void HangmanGame::doLogin | ( | ) | [private] |
Definition at line 53 of file HangmanGame.C.
{
MainStack->setCurrentWidget(Login);
BackToGameText->hide();
ScoresText->hide();
}
| void HangmanGame::play | ( | std::wstring | user, |
| Dictionary | dictionary | ||
| ) | [private] |
Definition at line 60 of file HangmanGame.C.
{
// Add a widget by passing MainStack as the parent, ...
Game = new HangmanWidget(user, dict, MainStack);
// ... or using addWidget
MainStack->addWidget(Scores = new HighScoresWidget(user));
BackToGameText->show();
ScoresText->show();
showGame();
}
| void HangmanGame::showGame | ( | ) | [private] |
Definition at line 81 of file HangmanGame.C.
{
MainStack->setCurrentWidget(Game);
BackToGameText->decorationStyle().font().setWeight(WFont::Bold);
ScoresText->decorationStyle().font().setWeight(WFont::NormalWeight);
}
| void HangmanGame::showHighScores | ( | ) | [private] |
Definition at line 73 of file HangmanGame.C.
{
MainStack->setCurrentWidget(Scores);
Scores->update();
BackToGameText->decorationStyle().font().setWeight(WFont::NormalWeight);
ScoresText->decorationStyle().font().setWeight(WFont::Bold);
}
WText* HangmanGame::BackToGameText [private] |
Definition at line 35 of file HangmanGame.h.
HangmanWidget* HangmanGame::Game [private] |
Definition at line 33 of file HangmanGame.h.
LoginWidget* HangmanGame::Login [private] |
Definition at line 32 of file HangmanGame.h.
WStackedWidget* HangmanGame::MainStack [private] |
Definition at line 31 of file HangmanGame.h.
HighScoresWidget* HangmanGame::Scores [private] |
Definition at line 34 of file HangmanGame.h.
WText* HangmanGame::ScoresText [private] |
Definition at line 36 of file HangmanGame.h.
1.7.2