1/***************************************************************************
2* KBlocks, a falling blocks game for KDE *
3* Copyright (C) 2010 Zhongjie Cai <squall.leonhart.cai@gmail.com> *
4* *
5* This program is free software; you can redistribute it and/or modify *
6* it under the terms of the GNU General Public License as published by *
7* the Free Software Foundation; either version 2 of the License, or *
8* (at your option) any later version. *
9***************************************************************************/
10#ifndef KBLOCKSKEYBOARDPLAYER_H
11#define KBLOCKSKEYBOARDPLAYER_H
12
13#include <string>
14using namespace std;
15
16#include <KAction>
17#include <KActionCollection>
18#include <KMainWindow>
19#include <KXmlGuiWindow>
20#include <klocalizedstring.h>
21
22#include "GamePlayerInterface.h"
23
24class KBlocksKeyboardPlayer : public QObject, public GamePlayerInterface
25{
26 Q_OBJECT
27
28 public:
29 explicit KBlocksKeyboardPlayer(KXmlGuiWindow * parent, string name = "", bool netMode = false);
30 ~KBlocksKeyboardPlayer();
31
32 public:
33 void startGame(SingleGameInterface * p);
34 void stopGame();
35
36 void pauseGame(bool flag);
37
38 void think(GamePlayer_ActionList * actionList);
39
40 string getName();
41
42 private:
43 void bindKeys();
44
45 private slots:
46 void moveLeft();
47 void moveRight();
48 void moveDown();
49 void pushDown();
50 void rotateCW();
51 void rotateCCW();
52
53 protected:
54 SingleGameInterface* mpGame;
55 bool mPauseFlag;
56
57 KAction* rotatecw;
58 KAction* rotateccw;
59 KAction* moveleft;
60 KAction* moveright;
61 KAction* movedown;
62 KAction* pushdown;
63
64 private:
65 bool mNetMode;
66 string mPlayerName;
67 GamePlayer_ActionList mActionList;
68
69 KXmlGuiWindow* mpKeyWindow;
70 KActionCollection* mpKeyShortcuts;
71};
72
73#endif
74
75