ScummVM API documentation
qd_game_scene.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_GAME_SCENE_H
23 #define QDENGINE_QDCORE_QD_GAME_SCENE_H
24 
25 #include "qdengine/parser/xml_fwd.h"
26 #include "qdengine/qdcore/qd_camera.h"
27 #include "qdengine/qdcore/qd_conditional_object.h"
28 #include "qdengine/qdcore/qd_game_dispatcher_base.h"
29 #include "qdengine/qdcore/qd_object_map_container.h"
30 #include "qdengine/qdcore/qd_object_list_container.h"
31 #include "qdengine/qdcore/qd_file_owner.h"
32 #include "qdengine/qdcore/util/fps_counter.h"
33 #include "qdengine/system/input/mouse_input.h"
34 #include "qdengine/system/graphics/gr_screen_region.h"
35 
36 namespace Common {
37 class WriteStream;
38 }
39 
40 namespace QDEngine {
41 
42 class qdMiniGame;
43 
44 typedef Std::vector<qdGameObjectMoving *> personages_container_t;
45 
48 public:
49  qdGameScene();
50  ~qdGameScene();
51 
52  int named_object_type() const {
53  return QD_NAMED_OBJECT_SCENE;
54  }
55 
57  enum {
59  CYCLE_X = 0x01,
61  CYCLE_Y = 0x02,
62 
64  RESET_TRIGGERS_ON_LOAD = 0x04,
65 
67  DISABLE_KEYBOARD_PERSONAGE_SWITCH = 0x08,
68 
70  DISABLE_MAIN_MENU = 0x10
71  };
72 
73  qdNamedObject *mouse_click_object() {
74  return _mouse_click_object;
75  }
76  void set_mouse_click_object(qdNamedObject *p) {
77  _mouse_click_object = p;
78  }
79 
80  qdNamedObject *mouse_right_click_object() {
81  return _mouse_right_click_object;
82  }
83  void set_mouse_right_click_object(qdNamedObject *p) {
84  _mouse_right_click_object = p;
85  }
86 
87  qdNamedObject *mouse_hover_object() {
88  return _mouse_hover_object;
89  }
90  void set_mouse_hover_object(qdNamedObject *p) {
91  _mouse_hover_object = p;
92  }
93 
94  const Vect2f mouse_click_pos() const {
95  return _mouse_click_pos;
96  }
97 
98  bool need_to_redraw_inventory(const char *inventory_name) const;
99 
100  const char *minigame_name() const {
101  return _minigame_name.c_str();
102  }
103  void set_minigame_name(const char *name) {
104  _minigame_name = name;
105  }
106  bool has_minigame() const {
107  return !_minigame_name.empty();
108  }
109 
110  const qdMiniGame *minigame() const {
111  return _minigame;
112  }
113  void start_minigame();
114 
115  bool restart_minigame_on_load() const {
116  return _restart_minigame_on_load;
117  }
118  void toggle_restart_minigame_on_load(bool state) {
119  _restart_minigame_on_load = state;
120  }
121 
122  bool add_object(qdGameObject *p);
123  bool rename_object(qdGameObject *p, const char *name);
124  bool remove_object(const char *name);
125  bool remove_object(qdGameObject *p);
126  qdGameObject *get_object(const char *name);
127  bool is_object_in_list(const char *name);
128  bool is_object_in_list(qdGameObject *p);
129 
130  bool is_active() const;
131 
132  void set_active_personage(qdGameObjectMoving *p);
133  void set_active_object(qdGameObjectAnimated *p);
134  qdGameObjectMoving *get_active_personage() {
135  return _selected_object;
136  }
137  bool change_active_personage(void);
138 
139  bool set_personage_button(qdInterfaceButton *p);
140 
141  bool add_grid_zone(qdGridZone *p);
142  bool rename_grid_zone(qdGridZone *p, const char *name);
143  bool remove_grid_zone(const char *name);
144  bool remove_grid_zone(qdGridZone *p);
145  qdGridZone *get_grid_zone(const char *name);
146  bool is_grid_zone_in_list(const char *name);
147  bool is_grid_zone_in_list(qdGridZone *p);
148 
149  bool is_any_personage_in_zone(const qdGridZone *p) const;
150 
151  bool add_music_track(qdMusicTrack *p);
152  bool rename_music_track(qdMusicTrack *p, const char *name);
153  bool remove_music_track(const char *name);
154  bool remove_music_track(qdMusicTrack *p);
155  qdMusicTrack *get_music_track(const char *name);
156  bool is_music_track_in_list(const char *name) const;
157  bool is_music_track_in_list(qdMusicTrack *p) const;
158 
159  void init_objects_grid();
160  void quant(float dt);
161 
163  bool activate();
165  bool deactivate();
166 
168  bool init();
169 
170  void pre_redraw();
171  void redraw();
172  void post_redraw();
173  void debug_redraw();
174 
175  void add_redraw_region(const grScreenRegion &reg) const;
176 
177  bool mouse_handler(int x, int y, mouseDispatcher::mouseEvent ev);
178 
179  void load_script(const xml::tag *p);
180  bool save_script(Common::WriteStream &fh, int indent = 0) const;
181 
183  bool load_data(Common::SeekableReadStream &fh, int save_version);
185  bool save_data(Common::WriteStream &fh) const;
186 
187  int load_resources();
188  void free_resources();
189 
190  qdCamera *get_camera() {
191  return &_camera;
192  }
193  const qdCamera *get_camera() const {
194  return &_camera;
195  }
196 
197  const qdGameObjectList &object_list() const {
198  return _objects.get_list();
199  }
200  const qdGridZoneList &grid_zone_list() const {
201  return _grid_zones.get_list();
202  }
203  const qdMusicTrackList &music_track_list() const {
204  return _music_tracks.get_list();
205  }
206 
207  bool merge_global_objects(qdGameObject *obj = NULL);
208  bool split_global_objects(qdGameObject *obj = NULL);
209 
210  int get_resources_size();
211 
212  void inc_zone_update_count() {
213  _zone_update_count++;
214  }
215  uint32 zone_update_count() const {
216  return _zone_update_count;
217  }
218 
220 
221  static fpsCounter *fps_counter();
222 
223  int autosave_slot() const {
224  return _autosave_slot;
225  }
226  void set_autosave_slot(int slot) {
227  _autosave_slot = slot;
228  }
229 
230  bool has_interface_screen() const {
231  return !_interface_screen_name.empty();
232  }
233  const char *interface_screen_name() const {
234  return _interface_screen_name.c_str();
235  }
236  void set_interface_screen_name(const char *name) {
237  _interface_screen_name = name;
238  }
239 
240  qdGameObject *get_hitted_obj(int x, int y);
241 
242  bool set_camera_mode(const qdCameraMode &mode, qdGameObjectAnimated *object);
243 
244  personages_container_t *getPersonages() { return &_personages; }
245 
246 #ifdef __QD_DEBUG_ENABLE__
247  bool get_resources_info(qdResourceInfoContainer &infos) const;
248 #endif
249 
250 private:
251 
252  int _autosave_slot;
253 
257 
258  qdCamera _camera;
259 
261  qdGameObjectMoving *_selected_object;
262 
264  qdMiniGame *_minigame;
265 
267  bool _restart_minigame_on_load;
268 
270  personages_container_t _personages;
271 
273  qdNamedObject *_mouse_click_object;
275  qdNamedObject *_mouse_right_click_object;
277  qdNamedObject *_mouse_hover_object;
278 
280  Vect2f _mouse_click_pos;
281 
283  Common::String _minigame_name;
284 
286  Common::String _interface_screen_name;
287 
288  uint32 _zone_update_count;
289 
290  static char _fps_string[255];
291 
292  bool init_visible_objects_list();
293  void update_mouse_cursor();
294 
295  void personages_quant();
296 
298  void follow_pers_init(int follow_cond);
300  bool follow_path_seek(qdGameObjectMoving *pObj, bool lock_target);
301 
303  void follow_implement_update_path();
305  void follow_wakening();
308  void follow_circuit(float dt);
310  void follow_end_moving();
312  void follow_quant(float dt);
313 
314  void collision_quant();
315 
316  void create_minigame_objects();
317 };
318 
319 } // namespace QDEngine
320 
321 #endif // QDENGINE_QDCORE_QD_GAME_SCENE_H
Базовый класс для игровых объектов.
Definition: qd_game_object.h:53
Definition: str.h:59
Definition: stream.h:77
Поименованный объект.
Definition: qd_named_object.h:70
Definition: fps_counter.h:27
int named_object_type() const
Возвращает тип объекта.
Definition: qd_game_scene.h:52
Definition: xmath.h:117
Definition: qd_file_owner.h:27
Зона на сетке сцены.
Definition: qd_grid_zone.h:42
Definition: list.h:39
Мини-игра.
Definition: qd_minigame.h:35
Сцена.
Definition: qd_game_scene.h:47
Definition: qd_object_list_container.h:32
Definition: stream.h:745
Dynamic object.
Definition: qd_game_object_animated.h:37
Definition: qd_music_track.h:43
Интерфейсный элемент - кнопка.
Definition: qd_interface_button.h:33
XML тег.
Definition: xml_tag.h:33
Базовый класс для игровых ресурсов.
Definition: console.h:28
Режим работы камеры.
Definition: qd_camera_mode.h:40
Definition: algorithm.h:29
Персонаж.
Definition: qd_game_object_moving.h:35
trigger_start_mode
Варианты старта триггера.
Definition: qd_conditional_object.h:122
mouseEvent
События.
Definition: mouse_input.h:41
Прямоугольная область на экране.
Definition: gr_screen_region.h:31
Definition: qd_camera.h:122
Definition: qd_object_map_container.h:33
Definition: qd_game_dispatcher_base.h:79