ScummVM API documentation
riven_stack.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 #ifndef RIVEN_STACK_H
23 #define RIVEN_STACK_H
24 
25 #include "common/keyboard.h"
26 #include "common/hash-str.h"
27 #include "common/ptr.h"
28 #include "common/rect.h"
29 #include "common/str-array.h"
30 
31 #include "mohawk/riven_actions.h"
32 #include "mohawk/riven_graphics.h"
33 
34 namespace Mohawk {
35 
36 class MohawkEngine_Riven;
37 
38 // NAME Resource ID's
39 enum RivenNameResource {
40  kCardNames = 1,
41  kHotspotNames = 2,
42  kExternalCommandNames = 3,
43  kVariableNames = 4,
44  kStackNames = 5
45 };
46 
51 public:
52  RivenNameList();
53  RivenNameList(MohawkEngine_Riven *vm, uint16 id);
54  ~RivenNameList();
55 
57  Common::String getName(uint16 nameID) const;
58 
64  int16 getNameId(const Common::String &name) const;
65 
72  void registerName(uint16 nameId, const Common::String &name);
73 
74 private:
75  void loadResource(MohawkEngine_Riven *vm, uint16 id);
76 
77  Common::StringArray _names;
78  Common::Array<uint16> _index;
79 };
80 
89 class RivenStack {
90 public:
91  RivenStack(MohawkEngine_Riven *vm, uint16 id);
92  virtual ~RivenStack();
93 
96 
98  uint16 getId() const;
99 
101  Common::String getName(RivenNameResource nameResource, uint16 nameId) const;
102 
108  int16 getIdFromName(RivenNameResource nameResource, const Common::String &name) const;
109 
111  void registerName(RivenNameResource nameResource, uint16 nameId, const Common::String &name);
112 
114  uint16 getCardStackId(uint32 globalId) const;
115 
117  uint32 getCurrentCardGlobalId() const;
118 
120  uint32 getCardGlobalId(uint16 cardId) const;
121 
123  void runCommand(uint16 commandNameId, const Common::Array<uint16> &args);
124 
126  void dump() const;
127 
129  virtual void installCardTimer();
130 
132  void removeTimer();
133 
135  void onMouseDown(const Common::Point &mouse);
136 
138  void onMouseUp(const Common::Point &mouse);
139 
141  void onMouseMove(const Common::Point &mouse);
142 
148  void queueMouseCursorRefresh();
149 
151  void onFrame();
152 
154  bool mouseIsDown() const;
155 
157  Common::Point getMousePosition() const;
158 
160  Common::Point getMouseDragStartPosition() const;
161 
163  void mouseForceUp();
164 
166  void onAction(RivenAction keyAction);
167 
169  RivenAction getAction() const;
170 
172  void resetAction();
173 
174  // Common external commands
175  void xflies(const ArgumentArray &args); // Start the "flies" effect
176 
177  // Miscellaneous
178  uint16 getComboDigit(uint32 correctCombo, uint32 digit);
179  void runDemoBoundaryDialog();
180  void runEndGame(uint16 videoCode, uint32 delay, uint32 videoFrameCountOverride);
181  void runCredits(uint16 video, uint32 delay, uint32 videoFrameCountOverride);
182 
183  void pageTurn(RivenTransition transition);
184  bool keepTurningPages();
185  void waitForPageTurnSound();
186 
187 protected:
189 
190  MohawkEngine_Riven *_vm;
191 
193  void registerCommand(const Common::String &name, ExternalCommand *command);
194 
196  void installTimer(TimerProc *proc, uint32 time);
197 
198 private:
200 
201 #define REGISTER_COMMAND(cls, method) \
202  registerCommand( \
203  #method, new Common::Functor1Mem<const Common::Array<uint16> &, void, cls>(this, &cls::method) \
204  )
205 
206 #define TIMER(cls, method) \
207  new Common::Functor0Mem<void, cls>(this, &cls::method)
208 
209  void loadResourceNames();
210  void loadCardIdMap();
211  void setCurrentStackVariable();
212  void checkTimer();
213 
214  uint16 _id;
215 
216  // Stack resource names
217  RivenNameList _varNames;
218  RivenNameList _externalCommandNames;
219  RivenNameList _hotspotNames;
220  RivenNameList _cardNames;
221  RivenNameList _stackNames;
222 
223  Common::Array<uint32> _cardIdMap;
224 
225  CommandsMap _commands;
226 
227  RivenAction _action;
228 
229  bool _mouseIsDown;
230  Common::Point _mousePosition;
231  Common::Point _mouseDragStartPosition;
232  bool _shouldRefreshMouseCursor;
233 
234  // Timer
235  Common::SharedPtr<TimerProc> _timerProc;
236  uint32 _timerTime;
237 };
238 
239 namespace RivenStacks {
241  const char *getName(uint16 stackId);
242 
244  uint16 getId(const char *stackName);
245 }
246 
247 } // End of namespace Mohawk
248 
249 #endif
Definition: str.h:59
Definition: riven_stack.h:50
int16 getNameId(const Common::String &name) const
RivenAction
Definition: riven_actions.h:28
void registerName(uint16 nameId, const Common::String &name)
Definition: riven.h:91
Definition: riven_stack.h:89
Definition: hashmap.h:85
Definition: rect.h:45
Common::String getName(uint16 nameID) const
Definition: func.h:437
Definition: ptr.h:159
Definition: hash-str.h:49
Definition: hash-str.h:45
Definition: bitmap.h:32