File indexing completed on 2025-03-09 05:12:53
0001 /* kmahjongg, the classic mahjongg game for KDE project 0002 * 0003 * Copyright (C) 1997 Mathias Mueller <in5y158@public.uni-hamburg.de> 0004 * Copyright (C) 2006-2007 Mauricio Piacentini <mauricio@tabuleiro.com> 0005 * 0006 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU 0007 * General Public License as published by the Free Software Foundation; either version 2 of the 0008 * License, or (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 0011 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU General Public License along with this program; if 0015 * not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0016 * 02110-1301, USA. */ 0017 0018 #ifndef KMAHJONGG_H 0019 #define KMAHJONGG_H 0020 0021 // KF 0022 #include <KXmlGuiWindow> 0023 0024 class KToggleAction; 0025 class QLabel; 0026 class KGameClock; 0027 class Editor; 0028 class GameView; 0029 class GameScene; 0030 class GameData; 0031 class KMahjonggLayout; 0032 0033 /** 0034 * @author Mathias */ 0035 class KMahjongg : public KXmlGuiWindow 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 explicit KMahjongg(QWidget * parent = nullptr); 0041 ~KMahjongg() override; 0042 0043 public Q_SLOTS: 0044 void startNewGame(int num = -1); 0045 0046 /** 0047 * Load the settings... */ 0048 void loadSettings(); 0049 0050 void showStatusText(const QString & msg, long board); 0051 0052 void showItemNumber(int maximum, int current, int left); 0053 0054 void gameOver(unsigned short numRemoved, unsigned short cheats); 0055 0056 /** 0057 * Connected to GameView::demoOrMoveListAnimationOver(bool) signal. */ 0058 void demoOrMoveListAnimationOver(bool demoGameLost); 0059 0060 protected: 0061 void setupKAction(); 0062 void setupStatusBar(); 0063 void changeEvent(QEvent * event) override; 0064 void closeEvent(QCloseEvent * event) override; 0065 0066 private Q_SLOTS: 0067 void showSettings(); 0068 void startNewNumeric(); 0069 void saveGame(); 0070 void loadGame(); 0071 void restartGame(); 0072 void undo(); 0073 void redo(); 0074 void pause(); 0075 void demoMode(); 0076 void displayTime(const QString & timestring); 0077 void showHighscores(); 0078 void slotBoardEditor(); 0079 void noMovesAvailable(); 0080 void toggleFullscreen(bool fullscreen); 0081 0082 private: 0083 enum class GameState { Gameplay, 0084 Demo, 0085 Paused, 0086 Finished, 0087 Stuck }; 0088 GameState m_gameState; 0089 0090 void updateState(GameState state); 0091 void updateUndoAndRedoStates(); 0092 void loadLayout(); 0093 void saveSettings(); 0094 0095 bool m_bLastRandomSetting; 0096 0097 GameView * m_gameView; 0098 GameData * m_gameData; 0099 GameScene * m_gameScene; 0100 0101 KMahjonggLayout * m_boardLayout; 0102 0103 Editor * m_boardEditor; 0104 0105 QLabel * m_gameNumLabel; 0106 QLabel * m_tilesLeftLabel; 0107 QLabel * m_statusLabel; 0108 QLabel * m_gameTimerLabel; 0109 0110 QAction * m_undoAction; 0111 QAction * m_redoAction; 0112 0113 KGameClock * m_gameTimer; 0114 0115 KToggleAction * m_pauseAction; 0116 KToggleAction * m_fullscreenAction; 0117 KToggleAction * m_demoAction; 0118 0119 static const QString gameMagic; 0120 static const int gameDataVersion; 0121 }; 0122 0123 #endif