File indexing completed on 2024-04-14 03:59:24
0001 /*************************************************************************** 0002 * KBlocks, a falling blocks game by KDE * 0003 * SPDX-FileCopyrightText: 2010 Zhongjie Cai <squall.leonhart.cai@gmail.com> * 0004 * * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 ***************************************************************************/ 0007 #ifndef KBLOCKSKEYBOARDPLAYER_H 0008 #define KBLOCKSKEYBOARDPLAYER_H 0009 0010 #include <string> 0011 using namespace std; 0012 0013 #include <QAction> 0014 #include <KActionCollection> 0015 #include <KXmlGuiWindow> 0016 #include <KLocalizedString> 0017 0018 #include "GamePlayerInterface.h" 0019 0020 class KBlocksKeyboardPlayer : public QObject, public GamePlayerInterface 0021 { 0022 Q_OBJECT 0023 0024 public: 0025 explicit KBlocksKeyboardPlayer(KXmlGuiWindow *parent, const string &name = "", bool netMode = false); 0026 ~KBlocksKeyboardPlayer() override; 0027 0028 public: 0029 void startGame(SingleGameInterface *p) override; 0030 void stopGame() override; 0031 0032 void pauseGame(bool flag) override; 0033 0034 void think(GamePlayer_ActionList *actionList) override; 0035 0036 string getName() override; 0037 0038 private: 0039 void bindKeys(); 0040 0041 Q_SIGNALS: 0042 void blockMoved(); 0043 void blockDropped(); 0044 0045 private Q_SLOTS: 0046 void moveLeft(); 0047 void moveRight(); 0048 void moveDown(); 0049 void pushDown(); 0050 void rotateCW(); 0051 void rotateCCW(); 0052 0053 protected: 0054 SingleGameInterface *mpGame = nullptr; 0055 bool mPauseFlag; 0056 0057 QAction *rotatecw = nullptr; 0058 QAction *rotateccw = nullptr; 0059 QAction *moveleft = nullptr; 0060 QAction *moveright = nullptr; 0061 QAction *movedown = nullptr; 0062 QAction *pushdown = nullptr; 0063 0064 private: 0065 bool mNetMode; 0066 string mPlayerName; 0067 GamePlayer_ActionList mActionList; 0068 0069 KXmlGuiWindow *mpKeyWindow = nullptr; 0070 KActionCollection *mpKeyShortcuts = nullptr; 0071 }; 0072 0073 #endif 0074