1 2 // qnetwalk/mainwindow.h 3 // Copyright (C) 2004-2013, Andi Peredri <andi@ukr.net> 4 5 #ifndef MAINWINDOW_H 6 #define MAINWINDOW_H 7 8 #include <QMainWindow> 9 #include <QList> 10 11 class Cell; 12 class QAction; 13 class QLCDNumber; 14 class Sound; 15 16 17 class MainWindow : public QMainWindow 18 { 19 Q_OBJECT 20 public: 21 MainWindow(); 22 ~MainWindow(); 23 virtual QMenu * createPopupMenu(); 24 protected: 25 virtual void closeEvent(QCloseEvent *); 26 virtual void keyPressEvent(QKeyEvent *); 27 private: 28 enum Skill { Novice, Normal, Expert, Master }; 29 enum BoardSize 30 { 31 NoviceBoardSize = 5, 32 NormalBoardSize = 7, 33 ExpertBoardSize = 9, 34 MasterBoardSize = 9 35 }; 36 enum 37 { 38 NumHighscores = 10, 39 MinimumNumCells = 20 40 }; 41 typedef QList<Cell *> CellList; 42 private slots: 43 void help(); 44 void about(); 45 void newGame(); 46 void keyboard(); 47 void noRotation(); 48 void startRotation(); 49 void finishRotation(); 50 void openHomepage(); 51 void showHighscores(); 52 void triggeredSkill(QAction *); 53 private: 54 Cell * uCell(Cell * cell, bool wrap) const; 55 Cell * dCell(Cell * cell, bool wrap) const; 56 Cell * lCell(Cell * cell, bool wrap) const; 57 Cell * rCell(Cell * cell, bool wrap) const; 58 bool isGameOver(); 59 bool updateConnections(); 60 void setSkill(int s); 61 void addRandomDir(CellList & list); 62 void addHighscore(int score); 63 void dialog(const QString & caption, const QString & text); 64 private: 65 int skill; 66 bool wrapped; 67 Cell * root; 68 Cell * board[MasterBoardSize * MasterBoardSize]; 69 Sound * clickSound; 70 Sound * connectSound; 71 Sound * startSound; 72 Sound * turnSound; 73 Sound * winSound; 74 QString user; 75 QAction * soundAction; 76 QStringList highscores; 77 QLCDNumber * lcd; 78 }; 79 80 #endif 81