File indexing completed on 2024-04-21 04:04:01
0001 /* 0002 KShisen - A japanese game similar to Mahjongg 0003 SPDX-FileCopyrightText: 1997 Mario Weilguni <mweilguni@sime.com> 0004 SPDX-FileCopyrightText: 2002-2004 Dave Corrie <kde@davecorrie.com> 0005 SPDX-FileCopyrightText: 2009, 2016 Frederik Schwarzer <schwarzer@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #ifndef KSHISEN_APP_H 0011 #define KSHISEN_APP_H 0012 0013 // KF 0014 #include <KXmlGuiWindow> 0015 0016 // Qt 0017 class QLabel; 0018 0019 // KShisen 0020 namespace KShisen 0021 { 0022 class Board; 0023 } 0024 0025 namespace KShisen 0026 { 0027 /** 0028 * @brief Class holding the application and its functions 0029 */ 0030 class App : public KXmlGuiWindow 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 explicit App(QWidget * parent = nullptr); 0036 0037 private Q_SLOTS: 0038 void slotEndOfGame(); 0039 0040 /** Updates actions, to enable and disable them where needed. 0041 * According to the current state of the game (game over, pause ...) some 0042 * actions might better be disabled. This is the place to do so. 0043 */ 0044 void updateItems(); 0045 /// Updated the time display in the status bar 0046 void updateTimeDisplay(); 0047 /// Updates the tiles removed display in the status bar 0048 void updateTileDisplay(); 0049 /// Updates the cheat status display in the status bar 0050 void updateCheatDisplay(); 0051 /// Shows the settings dialog 0052 void showSettingsDialog(); // const? 0053 0054 void notifyTilesDoNotMatch(); 0055 void notifyInvalidMove(); 0056 void notifySelectATile(); 0057 void notifySelectAMatchingTile(); 0058 void notifySelectAMove(); 0059 0060 /** Sets some flags for a new game. 0061 * This should be called from Board::newGame(). 0062 */ 0063 void newGame(); 0064 0065 /** Restarts the current game. 0066 * Currently this is done by undoing all moves done by the user as yet and 0067 * resetting the move history and the timer. 0068 * This might change over time. However, just make sure, the user gets his 0069 * currently played game as if it was started by the New Game action. 0070 */ 0071 void restartGame(); 0072 // void isSolvable(); // currently not used 0073 /// Toggles the pause mode 0074 void togglePause(); 0075 0076 /** Controls the pause mode. 0077 * If the game is paused, do not show the board and disable actions like undo 0078 * and such. 0079 */ 0080 void setPauseEnabled(bool enabled); 0081 0082 /** Undoes one move. 0083 * The Undo action should set the cheat flag, so the user cannot end up in 0084 * the highscore dialog by making bad decisions. :) 0085 */ 0086 void undo(); 0087 /// Redoes an undone move 0088 void redo(); 0089 0090 /** Shows a hint and sets cheat flag. 0091 * The Hint action should set the cheat flag, so the user cannot end up in 0092 * the high score dialog by having been told what to do. :) 0093 */ 0094 void hint(); 0095 /// Calls KShortcutsDialog without arguments 0096 void keyBindings(); 0097 /// Shows the high score table 0098 void showHighScores(); // const? 0099 0100 Q_SIGNALS: 0101 /** Invokes the creation of a new game. 0102 * This signal is connected to the newGame() slot of the Board, which 0103 * then does its job and sends a signal back to this class so the rest 0104 * of the work can be done here. 0105 * @see newGame() 0106 * @see Board::newGame() 0107 */ 0108 void invokeNewGame(); 0109 0110 private: 0111 /// Calculates the scores 0112 static int score(int x, int y, int seconds, bool gravity); 0113 0114 /** Sets up the status bar areas. 0115 * There are four areas in the status bar: 0116 * - game tip 0117 * - timer 0118 * - tile count 0119 * - cheat mode 0120 */ 0121 void setupStatusBar(); 0122 /// Sets up the needed actions and adds them to the action collection 0123 void setupActions(); 0124 /// Sets the cheat mode 0125 void setCheatModeEnabled(bool enabled); 0126 0127 private: 0128 QLabel * m_gameTipLabel{nullptr}; ///< Status bar area for game tips 0129 QLabel * m_gameTimerLabel{nullptr}; ///< Status bar area for the timer 0130 QLabel * m_gameTilesLabel{nullptr}; ///< Status bar area for the tile counter 0131 QLabel * m_gameCheatLabel{nullptr}; ///< Status bar area for the cheat mode 0132 Board * m_board{nullptr}; ///< Holds the game board 0133 }; 0134 } // namespace KShisen 0135 0136 #endif // KSHISEN_APP_H 0137 0138 // vim: expandtab:tabstop=4:shiftwidth=4 0139 // kate: space-indent on; indent-width 4