#include <HangmanGame.h>
Public Member Functions | |
HangmanGame (WContainerWidget *parent) | |
Private Slots | |
void | play (std::wstring user, Dictionary dictionary) |
void | showGame () |
void | showHighScores () |
Private Member Functions | |
void | doLogin () |
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.
00018 : 00019 WTable(parent) 00020 { 00021 resize(WLength(100, WLength::Percentage), WLength()); 00022 00023 WText *title = new WText(L"A Witty game: Hangman", elementAt(0,0)); 00024 title->decorationStyle().font().setSize(WFont::XXLarge); 00025 00026 // Center the title horizontally. 00027 elementAt(0, 0)->setContentAlignment(AlignTop | AlignCenter); 00028 00029 // Element (1,1) holds a stack of widgets with the main content. 00030 // This is where we switch between Login, Game, and Highscores widgets. 00031 MainStack = new WStackedWidget(elementAt(1, 0)); 00032 MainStack->setPadding(20); 00033 00034 MainStack->addWidget(Login = new LoginWidget()); 00035 Login->loginSuccessful.connect(SLOT(this, HangmanGame::play)); 00036 00037 // Element (2,0) contains navigation buttons. Instead of WButton, 00038 // we use WText. WText inherits from WInteractWidget, and thus exposes 00039 // the click event. 00040 BackToGameText = new WText(L" Gaming Grounds ", elementAt(2, 0)); 00041 BackToGameText->decorationStyle().setCursor(WCssDecorationStyle::Pointer); 00042 BackToGameText->clicked.connect(SLOT(this, HangmanGame::showGame)); 00043 00044 ScoresText = new WText(L" Highscores ", elementAt(2, 0)); 00045 ScoresText->decorationStyle().setCursor(WCssDecorationStyle::Pointer); 00046 ScoresText->clicked.connect(SLOT(this, HangmanGame::showHighScores)); 00047 // Center the buttons horizontally. 00048 elementAt(2, 0)->setContentAlignment(AlignTop | AlignCenter); 00049 00050 doLogin(); 00051 }
void HangmanGame::play | ( | std::wstring | user, | |
Dictionary | dictionary | |||
) | [private, slot] |
Definition at line 60 of file HangmanGame.C.
00061 { 00062 // Add a widget by passing MainStack as the parent, ... 00063 Game = new HangmanWidget(user, dict, MainStack); 00064 // ... or using addWidget 00065 MainStack->addWidget(Scores = new HighScoresWidget(user)); 00066 00067 BackToGameText->show(); 00068 ScoresText->show(); 00069 00070 showGame(); 00071 }
void HangmanGame::showGame | ( | ) | [private, slot] |
Definition at line 81 of file HangmanGame.C.
00082 { 00083 MainStack->setCurrentWidget(Game); 00084 BackToGameText->decorationStyle().font().setWeight(WFont::Bold); 00085 ScoresText->decorationStyle().font().setWeight(WFont::NormalWeight); 00086 }
void HangmanGame::showHighScores | ( | ) | [private, slot] |
Definition at line 73 of file HangmanGame.C.
00074 { 00075 MainStack->setCurrentWidget(Scores); 00076 Scores->update(); 00077 BackToGameText->decorationStyle().font().setWeight(WFont::NormalWeight); 00078 ScoresText->decorationStyle().font().setWeight(WFont::Bold); 00079 }
void HangmanGame::doLogin | ( | ) | [private] |
Definition at line 53 of file HangmanGame.C.
00054 { 00055 MainStack->setCurrentWidget(Login); 00056 BackToGameText->hide(); 00057 ScoresText->hide(); 00058 }
WStackedWidget* HangmanGame::MainStack [private] |
Definition at line 36 of file HangmanGame.h.
LoginWidget* HangmanGame::Login [private] |
Definition at line 37 of file HangmanGame.h.
HangmanWidget* HangmanGame::Game [private] |
Definition at line 38 of file HangmanGame.h.
HighScoresWidget* HangmanGame::Scores [private] |
Definition at line 39 of file HangmanGame.h.
WText* HangmanGame::BackToGameText [private] |
Definition at line 40 of file HangmanGame.h.
WText* HangmanGame::ScoresText [private] |
Definition at line 41 of file HangmanGame.h.