ScummVM API documentation
puzzle.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 // ITE puzzle scene
23 
24 #ifndef SAGA_PUZZLE_H
25 #define SAGA_PUZZLE_H
26 
27 namespace Saga {
28 
29 
30 #define PUZZLE_SOUNDS 3622
31 #define PUZZLE_TOOL_SOUNDS (PUZZLE_SOUNDS + 0)
32 #define PUZZLE_HINT_SOUNDS (PUZZLE_SOUNDS + 45)
33 #define PUZZLE_SOLICIT_SOUNDS (PUZZLE_SOUNDS + 57)
34 #define PUZZLE_WHINE_SOUNDS (PUZZLE_SOUNDS + 72)
35 #define PUZZLE_SAKKA_SOUNDS (PUZZLE_SOUNDS + 87)
36 
37 class Puzzle {
38 private:
39  enum kRQStates {
40  kRQNoHint = 0,
41  kRQHintRequested = 1,
42  kRQHintRequestedStage2 = 2,
43  kRQSakkaDenies = 3,
44  kRQSkipEverything = 4,
45  kRQSpeaking = 5
46  };
47 
48  SagaEngine *_vm;
49 
50  bool _solved;
51  bool _active;
52  bool _newPuzzle;
53  bool _sliding;
54 
55  kRQStates _hintRqState;
56  kRQStates _hintNextRqState;
57  int _hintGiver;
58  int _hintSpeaker;
59  int _hintOffer;
60  int _hintCount;
61  int _helpCount;
62 
63  int _puzzlePiece;
64  int _piecePriority[PUZZLE_PIECES];
65 
66  int _lang;
67 
68 public:
69  Puzzle(SagaEngine *vm);
70 
71  void execute();
72  void exitPuzzle();
73 
74  bool isSolved() { return _solved; }
75  bool isActive() { return _active; }
76 
77  void handleReply(int reply);
78  void handleClick(Point mousePt);
79 
80  void movePiece(Point mousePt);
81 
82 private:
83  void initPieceInfo(int i, int16 curX, int16 curY, byte offX, byte offY, int16 trgX,
84  int16 trgY, uint8 flag, uint8 count, Point point0, Point point1,
85  Point point2, Point point3, Point point4, Point point5);
86 
87  static void hintTimerCallback(void *refCon);
88 
89  void solicitHint();
90 
91  void initPieces();
92  void showPieces();
93  void slidePiece(int x1, int y1, int x2, int y2);
94  void dropPiece(Point mousePt);
95  void alterPiecePriority();
96  void drawCurrentPiece();
97 
98  void giveHint();
99  void clearHint();
100 
101 private:
102  struct PieceInfo {
103  int16 curX;
104  int16 curY;
105  byte offX;
106  byte offY;
107  int16 trgX;
108  int16 trgY;
109  uint8 flag;
110  uint8 count;
111  Point point[6];
112  };
113 
114  PieceInfo _pieceInfo[PUZZLE_PIECES];
115  int _slidePointX, _slidePointY;
116  Rect _hintBox;
117 };
118 
119 } // End of namespace Saga
120 
121 #endif
Definition: saga.h:497
Definition: rect.h:144
Definition: actor.h:34
Definition: puzzle.h:37
Definition: rect.h:45