-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgesturecontroller.h
86 lines (70 loc) · 1.91 KB
/
gesturecontroller.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
#ifndef GESTURECONTROLLER_H
#define GESTURECONTROLLER_H
// File must include
#include <QVector>
#include "abstractrule.h"
// Forward declaration
class QPointF;
class AbstractRule;
class AbstractGameBoardInfo;
class CoreController;
class EffectPainter;
/**
* @brief A class of a controller which controls the gesture and let the core
* controller to do things.
*/
class GestureController
{
public:
/**
* @brief State of the gesture.
*/
enum GestureState {NoGesture, ChooseGesture, LocateGesture};
/**
* @brief Constructor with the rule, the infomation of the gameboard, the
* core controller, the effect painter.
*/
GestureController(AbstractRule *theRule,
AbstractGameBoardInfo *theGameBoardInfo,
CoreController *theController,
EffectPainter *theEffectPainter);
/**
* @brief Press.
*
* maintain: gestureState,gestureIndexes
*/
void dealPressed(const QPointF& pos);
/**
* @brief Move.
*
* If haven't confirm which gesture it is, append _gesture_indexes.
* If the gesture is confirmed, set the new positions of each balls
* influenced.
*/
void dealMoved(const QPointF& pos);
/**
* @brief Release.
*
* Put balls influenced to correct position exam whether it can be put there.
* If can then do something, if not then rollback.
*/
void dealReleased(const QPointF& pos);
private:
// Rule of the game
AbstractRule *rule;
// Infomation of the gameboard
AbstractGameBoardInfo *gameboardInfo;
// Core controller which controls the balls
CoreController *controller;
// The effective painter
EffectPainter *effectPainter;
// The gesture allowed
AbstractRule::Gesture gesture;
// State of the gesture
GestureState gestureState;
// Indexes of the gesture
QVector <int> gestureIndexes;
// Test the gesture
void testGesture(const QPointF& pos);
};
#endif // GESTURECONTROLLER_H