ScummVM API documentation
qd_minigame_interface.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 QDENGINE_QDCORE_QD_MINIGAME_INTERFACE_H
23 #define QDENGINE_QDCORE_QD_MINIGAME_INTERFACE_H
24 
25 namespace Common {
26 class ReadStream;
27 class WriteStream;
28 }
29 
30 namespace QDEngine {
31 
32 class qdEngineInterface;
33 
35 
76 class qdMinigameSceneInterface;
77 
79 public:
81  typedef qdMiniGameInterface *(*interface_open_proc)(const char *game_name);
83  typedef bool (*interface_close_proc)(qdMiniGameInterface *p);
84 
85  virtual ~qdMiniGameInterface() { };
86 
88  virtual bool init(const qdEngineInterface *engine_interface) = 0;
89 
91  virtual bool quant(float dt) = 0;
92 
94  virtual bool finit() = 0;
95 
97  virtual bool new_game(const qdEngineInterface *engine_interface) {
98  return true;
99  }
101  virtual int save_game(const qdEngineInterface *engine_interface, const qdMinigameSceneInterface *scene_interface, char *buffer, int buffer_size) {
102  return 0;
103  }
105  virtual int load_game(const qdEngineInterface *engine_interface, const qdMinigameSceneInterface *scene_interface, const char *buffer, int buffer_size) {
106  return 0;
107  }
108 
109  // maski, 20060129, no version yet
110  // version 100, 20060414, qdMinigameCounterInterface added, version added, no other changes
111  // version 101, 20060607
112  // version 102, 20060629
113  // version 103, 20060715
114  // version 104, never released
115  // version 105, 20061026, b945e65
116  // version 106, 20070214
117  // version 107, 20070404 09:13
118  // version 108, 20070404 10:12
119  // version 109, 20070416
120  // version 110, 20070419
121  // version 111, 20070420
122  // version 112, 20070507
123  enum { INTERFACE_VERSION = 112 };
124  virtual int version() const {
125  return INTERFACE_VERSION;
126  }
127 };
128 
129 template<class T>
130 class mgVect2 {
131 public:
132  explicit mgVect2(T value = (T)0) : x(value), y(value) { }
133  mgVect2(T xx, T yy) : x(xx), y(yy) { }
134 
135  mgVect2 &operator += (const mgVect2 &v) {
136  x += v.x;
137  y += v.y;
138  return *this;
139  }
140  mgVect2 &operator -= (const mgVect2 &v) {
141  x -= v.x;
142  y -= v.y;
143  return *this;
144  }
145  mgVect2 &operator *= (T v) {
146  x *= v;
147  y *= v;
148  return *this;
149  }
150  mgVect2 &operator /= (T v) {
151  x /= v;
152  y /= v;
153  return *this;
154  }
155 
156  mgVect2 operator + (const mgVect2 &v) {
157  return mgVect2(*this) += v;
158  }
159  mgVect2 operator - (const mgVect2 &v) {
160  return mgVect2(*this) -= v;
161  }
162  mgVect2 operator / (T v) {
163  return mgVect2(*this) /= v;
164  }
165  mgVect2 operator * (T v) {
166  return mgVect2(*this) *= v;
167  }
168 
169  T x;
170  T y;
171 };
172 
173 template<class T>
174 class mgVect3 {
175 public:
176  explicit mgVect3(T value = (T)0) : x(value), y(value), z(value) { }
177  mgVect3(T xx, T yy, T zz) : x(xx), y(yy), z(zz) { }
178 
179  mgVect3 &operator += (const mgVect3 &v) {
180  x += v.x;
181  y += v.y;
182  z += v.z;
183  return *this;
184  }
185  mgVect3 &operator -= (const mgVect3 &v) {
186  x -= v.x;
187  y -= v.y;
188  z -= v.z;
189  return *this;
190  }
191  mgVect3 &operator *= (T v) {
192  x *= v;
193  y *= v;
194  z *= v;
195  return *this;
196  }
197  mgVect3 &operator /= (T v) {
198  x /= v;
199  y /= v;
200  z /= v;
201  return *this;
202  }
203 
204  mgVect3 operator + (const mgVect3 &v) {
205  return mgVect3(*this) += v;
206  }
207  mgVect3 operator - (const mgVect3 &v) {
208  return mgVect3(*this) -= v;
209  }
210  mgVect3 operator / (T v) {
211  return mgVect3(*this) /= v;
212  }
213  mgVect3 operator * (T v) {
214  return mgVect3(*this) *= v;
215  }
216 
217  void write(Common::WriteStream &out) const;
218  void read(Common::ReadStream &out);
219 
220  T x;
221  T y;
222  T z;
223 };
224 
225 typedef mgVect3<float> mgVect3f;
226 typedef mgVect2<float> mgVect2f;
227 typedef mgVect2<int> mgVect2i;
228 
231 public:
232  virtual ~qdMinigameObjectInterface() { };
233 
235  virtual const char *name() const = 0;
236 
238  virtual bool has_state(const char *state_name) const = 0;
241  virtual const char *current_state_name() const = 0;
243  virtual bool is_state_active(const char *state_name) const = 0;
245  virtual bool is_state_waiting_activation(const char *state_name) const = 0;
247  virtual int current_state_index() const = 0;
249  virtual bool set_state(const char *state_name) = 0;
251  virtual bool set_state(int state_index) = 0;
253 
257  virtual int state_index(const char *state_name) const = 0;
258 
260  virtual mgVect3f R() const = 0;
262  virtual void set_R(const mgVect3f &r) = 0;
263 
265  virtual bool hit_test(const mgVect2i &pos) const = 0;
266 
268  virtual mgVect2i screen_R() const = 0;
270  virtual bool update_screen_R() = 0;
272  virtual mgVect2i screen_size() const = 0;
273 
277  virtual void set_screen_rotation(float angle, float speed) = 0;
279  virtual float screen_rotation() const = 0;
281  virtual void set_screen_scale(const mgVect2f &scale, const mgVect2f &speed) = 0;
283  virtual mgVect2f screen_scale() const = 0;
284 
286  virtual int shadow_color() const = 0;
288  virtual int shadow_alpha() const = 0;
290  virtual bool set_shadow(int shadow_color, int shadow_alpha) = 0;
291 
293  virtual bool is_visible() const = 0;
294 
296  virtual mgVect3f bound() const = 0;
297 
299 
304  virtual bool move(const mgVect3f &target_position, bool disable_target_change = false) = 0;
305 
309  virtual float direction_angle() const = 0;
311  virtual bool set_direction_angle(float direction) = 0;
312 };
313 
316 public:
317  virtual ~qdMinigameSceneInterface() { }
318 
320  virtual const char *name() const = 0;
321 
323  virtual qdMinigameObjectInterface *object_interface(const char *object_name) = 0;
325  virtual qdMinigameObjectInterface *personage_interface(const char *personage_name) = 0;
327  virtual bool activate_personage(const char *personage_name) = 0;
328 
330  virtual mgVect3f screen2world_coords(const mgVect2i &screen_pos, float screen_depth = 0) const = 0;
332  virtual mgVect2i world2screen_coords(const mgVect3f &world_pos) const = 0;
334  virtual float screen_depth(const mgVect3f &pos) const = 0;
336  virtual mgVect3f screen2grid_coords(const mgVect2i &screen_pos) const = 0;
337 
339  virtual qdMinigameObjectInterface *mouse_object_interface() const = 0;
341  virtual qdMinigameObjectInterface *mouse_click_object_interface() const = 0;
343  virtual qdMinigameObjectInterface *mouse_right_click_object_interface() const = 0;
345  virtual qdMinigameObjectInterface *mouse_hover_object_interface() const = 0;
346 
347  virtual const char *minigame_parameter(const char *parameter_name) const = 0;
348 
349  virtual void release_object_interface(qdMinigameObjectInterface *p) const = 0;
350 };
351 
354 public:
355  virtual ~qdMinigameCounterInterface() { }
356 
358  virtual int value() const = 0;
360  virtual void set_value(int value) = 0;
362  virtual void add_value(int value_delta) = 0;
363 };
364 
366 public:
367  virtual ~qdEngineInterface() { }
368 
372  MOUSE_EV_LEFT_DOWN = 0,
384  MOUSE_EV_MOUSE_MOVE
385  };
386 
387  virtual qdMinigameSceneInterface *current_scene_interface() const = 0;
388  virtual void release_scene_interface(qdMinigameSceneInterface *p) const = 0;
389 
390  virtual qdMinigameCounterInterface *counter_interface(const char *counter_name) const = 0;
391  virtual void release_counter_interface(qdMinigameCounterInterface *p) const = 0;
392 
394  virtual mgVect2i screen_size() const = 0;
395 
397  virtual bool is_key_pressed(int vkey) const = 0;
398 
400  virtual bool is_mouse_event_active(qdMinigameMouseEvent event_id) const = 0;
401 
403  virtual mgVect2i mouse_cursor_position() const = 0;
404 
407  virtual bool add_hall_of_fame_entry(int score) const = 0;
408 
411  virtual bool set_interface_text(const char *screen_name, const char *control_name, const char *text) const = 0;
412 
414  virtual void rnd_init(int seed) const = 0;
416  virtual uint32 rnd(uint32 m) const = 0;
418  virtual float frnd(float x) const = 0;
420  virtual float fabs_rnd(float x) const = 0;
421 };
422 
423 } // namespace QDEngine
424 
425 #endif // QDENGINE_QDCORE_QD_MINIGAME_INTERFACE_H
Definition: stream.h:77
qdMinigameMouseEvent
Идентификаторы событий для работы с мышью.
Definition: qd_minigame_interface.h:370
Отжатие левой кнопки.
Definition: qd_minigame_interface.h:380
virtual bool new_game(const qdEngineInterface *engine_interface)
Инициализация миниигры, вызывается при старте и перезапуске игры.
Definition: qd_minigame_interface.h:97
Definition: qd_minigame_interface.h:78
Definition: qd_minigame_interface.h:174
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: qd_minigame_interface.h:365
Definition: qd_minigame_interface.h:130
Базовый класс для игровых ресурсов.
Definition: console.h:28
Definition: algorithm.h:29
virtual int load_game(const qdEngineInterface *engine_interface, const qdMinigameSceneInterface *scene_interface, const char *buffer, int buffer_size)
Загрузка данных, вызывается при загрузке сцены, на которую повешена миниигра.
Definition: qd_minigame_interface.h:105
Нажатие правой кнопки.
Definition: qd_minigame_interface.h:374
Двойное нажатие правой кнопки.
Definition: qd_minigame_interface.h:378
DBCSString operator+(const DBCSString &x, const DBCSString &y)
Интерфейс к динамическому объекту.
Definition: qd_minigame_interface.h:230
Интерфейс к счётчику.
Definition: qd_minigame_interface.h:353
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Интерфейс к сцене.
Definition: qd_minigame_interface.h:315
Definition: stream.h:385
Двойное нажатие левой кнопки.
Definition: qd_minigame_interface.h:376
virtual int save_game(const qdEngineInterface *engine_interface, const qdMinigameSceneInterface *scene_interface, char *buffer, int buffer_size)
Сохранение данных, вызывается при сохранении сцены, на которую повешена миниигра. ...
Definition: qd_minigame_interface.h:101
Отжатие правой кнопки.
Definition: qd_minigame_interface.h:382