-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgametools.h
131 lines (92 loc) · 3.19 KB
/
gametools.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#ifndef GAMETOOLS_H
#define GAMETOOLS_H
#include <QtGui>
class GameScene;
class ToolSet;
struct PlaceInfo;
struct BonusInfo;
struct PlayerInfo;
struct LevelPackInfo;
class GameTool : public QObject
{
friend class ToolSet;
public:
enum ToolAction { ToolOutOfRange, ToolInactive, ToolActive };
enum ToolType { ManualTool, AutoTool, ConstTool };
GameTool(int x, int y, int score);
GameTool(int x, int y, int score, const QString &resource);
virtual ~GameTool();
virtual ToolType type() const { return ManualTool; }
void setBase(ToolSet *set) { myToolset = set; }
void setCurrent();
inline const QPixmap& pixmap() const { return myPixmap; }
inline void setPixmap(const QPixmap &pm) { myPixmap = pm; }
inline BonusInfo* info() const { return bonusInfo; }
inline int score() const { return myScore; }
inline void setScore(int val) { myScore = val; }
inline const QPoint& pos() const { return myPos; }
inline bool inProgress() const { return myProgress; }
inline bool isActive() const { return myActive; }
inline void setActive(bool act = true) { myActive = act; }
virtual QString hint() const;
// internal
virtual void advanceAndPaint(QPainter &p, int currentScore);
void animateActivation();
// defined for manual tools
virtual bool checkItemClick(int /*row*/, int /*col*/) { return false; }
virtual ToolAction checkItemState(int /*row*/, int /*col*/) { return ToolOutOfRange; }
// defined for auto tools
virtual bool checkToolClick() { return false; }
protected:
QPixmap myPixmap;
QPoint myPos;
int myScore;
ToolSet *myToolset;
int myProgress;
bool myActive;
BonusInfo *bonusInfo;
static int stage;
};
class ToolSet
{
public:
ToolSet();
~ToolSet();
inline GameTool* current() { return currentTool; }
inline GameTool* tool(int idx) { return tools.at(idx); }
void activateRandomTool();
//inline GameTool* active() { return tools.at(myActiveToolIndex); }
// int bonusClock() const;
// int bonusScore() const;
// int bonusTimer() const;
// int bonusMag() const;
void readProfile(LevelPackInfo *lpi);
void writeProfile(LevelPackInfo *lpi);
void initGraphics();
void setScore(int score);
void addScore(int score);
void setLongestChain(int value);
//void nextToolActivated();
//int activeToolIndex(int score);
//inline int nextToolIndex() const { return next_tool; }
void updateTools(QPainter &p);
inline int toolRow() const { return myOverRow; }
inline int toolCol() const { return myOverCol; }
bool checkMouseHover(const QPoint &pos);
bool checkMouseActions(const QPoint &pos);
bool checkItemClick(int row, int col);
GameTool::ToolAction checkItemState(int row, int col);
void checkMouseMoved(int row, int col);
void progressCurrent();
protected:
void toolAboutExecute();
void toolExecuted();
void updateScore();
QList<GameTool*> tools;
int toolScore;
GameTool *currentTool;
int myOverRow, myOverCol;
struct ToolSetPrivate *priv;
};
extern ToolSet * toolset;
#endif // GAMETOOLS_H