23#ifndef QDENGINE_QDCORE_QD_GAME_DISPATCHER_H
24#define QDENGINE_QDCORE_QD_GAME_DISPATCHER_H
26#include "qdengine/parser/xml_fwd.h"
27#include "qdengine/system/input/mouse_input.h"
28#include "qdengine/system/graphics/gr_screen_region.h"
29#include "qdengine/qdcore/qd_camera_mode.h"
30#include "qdengine/qdcore/qd_object_list_container.h"
31#include "qdengine/qdcore/qd_game_dispatcher_base.h"
32#include "qdengine/qdcore/qd_resource_dispatcher.h"
33#include "qdengine/qdcore/qd_screen_text_dispatcher.h"
34#include "qdengine/qdcore/qd_interface_dispatcher.h"
35#include "qdengine/qdcore/qd_inventory.h"
36#include "qdengine/qdcore/qd_font_info.h"
37#include "qdengine/qdcore/qd_file_owner.h"
38#include "qdengine/qdcore/util/WinVideo.h"
55 OBJECT_CLICK_FLAG = 0x04,
56 DIALOG_CLICK_FLAG = 0x08,
57 FULLSCREEN_REDRAW_FLAG = 0x10,
58 SKIP_REDRAW_FLAG = 0x20,
59 MAIN_MENU_FLAG = 0x40,
60 INTRO_MODE_FLAG = 0x80,
61 CLICK_FAILED_FLAG = 0x100,
62 OBJECT_CLICK_FAILED_FLAG = 0x200,
63 CLICK_WAS_FAILED_FLAG = 0x400,
64 OBJECT_CLICK_WAS_FAILED_FLAG = 0x800,
65 LOAD_GAME_FLAG = 0x1000,
66 SAVE_GAME_FLAG = 0x2000,
67 FADE_IN_FLAG = 0x4000,
68 FADE_OUT_FLAG = 0x8000,
69 NEXT_FRAME_FLAG = 0x10000
76 return QD_NAMED_OBJECT_DISPATCHER;
82 qdGameObjectMouse
const *mouse_object()
const {
85 bool drop_mouse_object();
89 int resource_compression()
const {
90 return _resource_compression;
92 void set_resource_compression(
int compression) {
93 _resource_compression = compression;
96 void request_file_package(
const qdFileOwner &file_owner)
const;
98 void startup_check()
const;
100 qdLoadingProgressFnc set_scene_loading_progress_callback(qdLoadingProgressFnc p,
void *dp = 0) {
101 qdLoadingProgressFnc old_fnc = _scene_loading_progress_fnc;
102 _scene_loading_progress_fnc = p;
103 _scene_loading_progress_data = dp;
108 qdLoadingProgressFnc get_scene_loading_progress_callback() {
109 return _scene_loading_progress_fnc;
112 void *get_scene_loading_progress_data() {
113 return _scene_loading_progress_data;
116 void set_time(
int tm) {
119 int get_time()
const {
123 bool start_intro_videos();
126 void quant(
float dt);
134 bool keyboard_handler(Common::KeyCode vkey,
bool event);
136 bool add_game_end(qdGameEnd *p);
137 bool rename_game_end(qdGameEnd *p,
const char *
name);
138 bool remove_game_end(qdGameEnd *p);
139 qdGameEnd *get_game_end(
const char *
name);
140 bool is_game_end_in_list(
const char *
name);
141 bool is_game_end_in_list(qdGameEnd *p);
143 bool add_counter(qdCounter *p);
144 bool rename_counter(qdCounter *p,
const char *
name);
145 bool remove_counter(qdCounter *p);
146 qdCounter *get_counter(
const char *
name);
147 bool is_counter_in_list(
const char *
name);
148 bool is_counter_in_list(qdCounter *p);
150 bool add_minigame(qdMiniGame *p);
151 bool rename_minigame(qdMiniGame *p,
const char *
name);
152 bool remove_minigame(
const char *
name);
153 bool remove_minigame(qdMiniGame *p);
154 qdMiniGame *get_minigame(
const char *
name);
155 bool is_minigame_in_list(
const char *
name);
156 bool is_minigame_in_list(qdMiniGame *p);
158 void set_mouse_click_state(
const qdGameObjectState *p) {
159 _mouse_click_state = p;
162 bool add_inventory(qdInventory *p) {
163 if (_inventories.add_object(p)) {
169 bool remove_inventory(
const char *
name) {
170 return _inventories.remove_object(
name);
172 bool remove_inventory(qdInventory *p) {
173 return _inventories.remove_object(p);
175 qdInventory *get_inventory(
const char *
name) {
176 return _inventories.get_object(
name);
178 bool is_inventory_in_list(
const char *
name) {
179 return _inventories.is_in_list(
name);
181 bool is_inventory_in_list(qdInventory *p) {
182 return _inventories.is_in_list(p);
184 bool rename_inventory(qdInventory *p,
const char *
name);
186 const qdInventoryCellType *add_inventory_cell_type(
const qdInventoryCellType &tp) {
188 assert(find_inventory_cell_type(tp.type()) == _inventory_cell_types.
end());
191 return &_inventory_cell_types.
back();
193 bool remove_inventory_cell_type(
int type) {
194 typedef qdInventoryCellTypeVector::iterator i_t;
195 i_t res = find_inventory_cell_type(type);
196 if (res != _inventory_cell_types.
end()) {
197 _inventory_cell_types.
erase(res);
202 const qdInventoryCellType *get_inventory_cell_type(
int type)
const {
203 typedef qdInventoryCellTypeVector::const_iterator ci_t;
204 ci_t res = find_inventory_cell_type(type);
205 if (res != _inventory_cell_types.
end())
209 int get_unique_inventory_cell_type()
const {
210 if (_inventory_cell_types.
empty())
return 0;
211 return _inventory_cell_types.
back().type() + 1;
213 bool set_inventory_cell_type(
const qdInventoryCellType &tp) {
214 typedef qdInventoryCellTypeVector::iterator i_t;
215 i_t res = find_inventory_cell_type(tp.type());
216 if (res != _inventory_cell_types.
end()) {
222 const qdInventoryCellTypeVector &inventory_cell_types()
const {
223 return _inventory_cell_types;
226 qdInventoryCellTypeVector ¬_const_inventory_cell_types() {
227 return _inventory_cell_types;
241 const qdFontInfo *get_font_info(
int type)
const;
242 int get_unique_font_info_type()
const;
245 return _fonts.get_list();
248 int default_font()
const {
249 return _default_font;
251 void set_default_font(
int font) {
252 _default_font = font;
255 bool toggle_inventory(
bool state);
256 bool toggle_inventory() {
257 if (!_cur_inventory)
return toggle_inventory(
true);
258 else return toggle_inventory(
false);
260 bool put_to_inventory(qdGameObjectAnimated *p);
261 bool remove_from_inventory(qdGameObjectAnimated *p);
262 bool is_in_inventory(
const qdGameObjectAnimated *p)
const;
263 bool is_on_mouse(
const qdGameObjectAnimated *p)
const;
265 const qdInventory *cur_inventory()
const {
266 return _cur_inventory;
269 bool add_video(qdVideo *p, qdVideo
const *before = NULL);
270 bool remove_video(
const char *
name);
271 bool remove_video(qdVideo *p);
272 qdVideo *get_video(
const char *
name);
273 bool is_video_in_list(
const char *
name);
274 bool is_video_in_list(qdVideo *p);
275 bool rename_video(qdVideo *p,
const char *
name);
277 bool add_trigger_chain(qdTriggerChain *p);
278 bool remove_trigger_chain(
const char *
name);
279 bool remove_trigger_chain(qdTriggerChain *p);
280 qdTriggerChain *get_trigger_chain(
const char *
name);
281 bool is_trigger_chain_in_list(
const char *
name);
282 bool is_trigger_chain_in_list(qdTriggerChain *p);
283 bool rename_trigger_chain(qdTriggerChain *p,
const char *
name);
285 bool add_scene(qdGameScene *p);
286 bool rename_scene(qdGameScene *p,
const char *
name);
287 bool remove_scene(qdGameScene *p);
288 qdGameScene *get_scene(
const char *
name);
289 bool is_scene_in_list(
const char *
name);
290 bool is_scene_in_list(
const qdGameScene *p);
292 bool add_global_object(qdGameObject *p);
293 bool rename_global_object(qdGameObject *p,
const char *
name);
294 bool remove_global_object(
const char *
name);
295 bool remove_global_object(qdGameObject *p);
296 qdGameObject *get_global_object(
const char *
name);
297 bool is_global_object_in_list(
const char *
name);
298 bool is_global_object_in_list(qdGameObject *p);
300 bool merge_global_objects(qdGameObject *obj = NULL);
301 bool split_global_objects(qdGameObject *obj = NULL);
302 bool update_walk_state(
const char *object_name, qdGameObjectState *p);
303 qdGameObjectState *get_walk_state(
const char *object_name);
306 bool play_video(
const char *vid_name);
307 bool play_video(qdVideo *p);
311 bool is_video_finished();
312 bool is_video_playing() {
313 if (!_cur_video)
return false;
317 void continueVideo();
318 bool is_video_playing(qdVideo *p) {
319 return (_cur_video == p);
322 bool play_music_track(
const qdMusicTrack *p,
bool interface_mode =
false);
323 const qdMusicTrack *current_music()
const {
324 return _cur_music_track;
328 bool select_scene(
const char *s_name);
329 bool select_scene(qdGameScene *sp,
bool resources_flag =
true);
340 int load_resources();
341 void free_resources();
342 int get_resources_size();
344 void load_script(
const char *fname);
345 void load_script(
const xml::tag *p);
347 bool save_script(
const char *fname)
const;
354 bool save_game(
int slot_id)
const;
359 bool init_triggers();
360 bool reset_triggers();
363 return _videos.get_list();
366 return _trigger_chains.get_list();
368 const qdGameObjectList &global_object_list()
const {
369 return _global_objects.get_list();
371 const qdInventoryList &inventory_list()
const {
372 return _inventories.get_list();
374 const qdMiniGameList &minigame_list()
const {
375 return _minigames.get_list();
377 const qdGameEndList &game_end_list()
const {
378 return _game_ends.get_list();
380 const qdGameSceneList &scene_list()
const {
381 return _scenes.get_list();
383 const qdCounterList &counter_list()
const {
384 return _counters.get_list();
387 qdGameScene *get_active_scene()
const {
391 qdSound *get_sound(
const char *
name);
392 qdAnimation *get_animation(
const char *
name);
393 qdAnimationSet *get_animation_set(
const char *
name);
394 qdGameObject *get_object(
const char *
name);
395 qdGameObjectMoving *get_active_personage();
396 qdNamedObject *get_named_object(
const qdNamedObjectReference *ref);
398 qdScaleInfo *get_scale_info(
const char *p);
400 bool check_condition(qdCondition *cnd);
408 bool is_gameplay_paused() {
409 return _is_gameplay_paused;
412 void pause_gameplay(
bool pause) { _is_gameplay_paused = pause; }
416 qdScreenTextDispatcher &screen_texts_dispatcher() {
417 return _screen_texts;
420 bool toggle_main_menu() {
421 return toggle_main_menu(!_interface_dispatcher.is_active());
423 bool toggle_main_menu(
bool state,
const char *screen_name = NULL);
424 bool has_main_menu()
const {
427 bool is_main_menu_exit_enabled()
const;
429 void set_game_end(
const qdGameEnd *p) {
432 bool end_game(
const qdGameEnd *p);
434 bool add_redraw_region(
const grScreenRegion ®);
454 void toggle_full_redraw() {
457 bool need_full_redraw()
const {
461 static void set_dispatcher(qdGameDispatcher *p);
462 static qdGameDispatcher *get_dispatcher() {
468 return _startup_scene.c_str();
476 _startup_scene =
name;
478 _startup_scene.
clear();
482 return !_startup_scene.empty();
487 void set_game_title(
const char *p) {
490 const char *game_title()
const {
491 return _game_title.c_str();
494 void set_texts_database(
const Common::Path &file_name) {
495 _texts_database = file_name;
498 return _texts_database;
501 void set_cd_key(
const char *key) {
504 const char *cd_key()
const {
505 return _cd_key.c_str();
508 bool add_dialog_state(qdGameObjectState *p);
510 const Vect2f &mouse_cursor_pos()
const {
511 return _mouse_cursor_pos;
514 bool is_autosave_slot(
int save_slot) {
515 return save_slot == _autosave_slot;
518 void set_auto_save(
int save_slot) {
520 _autosave_slot = save_slot;
522 void set_auto_load(
int save_slot) {
524 _autosave_slot = save_slot;
527 static grFont *create_font(
int font_idx);
528 static void free_font(grFont *fnt);
533 const grFont *find_font(
int type)
const;
535 bool set_fade(
bool fade_in,
float duration);
537 bool write_resource_stats(
const char *file_name)
const;
539 int hall_of_fame_size()
const {
540 return _hall_of_fame_size;
542 void set_hall_of_fame_size(
int size) {
543 _hall_of_fame_size = size;
546 const char *hall_of_fame_player_name(
int place)
const;
547 void set_hall_of_fame_player_name(
int place,
const char *
name);
549 int hall_of_fame_player_score(
int place)
const;
551 bool is_hall_of_fame_updated(
int place)
const;
553 bool has_hall_of_fame()
const {
554 return _hall_of_fame_size != 0;
556 bool load_hall_of_fame();
557 bool save_hall_of_fame()
const;
558 bool add_hall_of_fame_entry(
int score);
565 bool _is_gameplay_paused =
false;
567 bool _enable_file_packages;
569 int _resource_compression;
572 int _hall_of_fame_size;
573 struct HallOfFameEntry {
586 HallOfFame _hall_of_fame;
588 qdInterfaceDispatcher _interface_dispatcher;
590 winVideo _video_player;
592 qdObjectListContainer<qdVideo> _videos;
594 qdObjectListContainer<qdGameObject> _global_objects;
595 qdObjectListContainer<qdTriggerChain> _trigger_chains;
596 qdObjectListContainer<qdInventory> _inventories;
597 qdObjectListContainer<qdGameEnd> _game_ends;
598 qdObjectListContainer<qdGameScene> _scenes;
599 qdObjectListContainer<qdCounter> _counters;
601 qdGameScene *_cur_scene;
606 const qdGameEnd *_game_end;
608 qdObjectListContainer<qdMiniGame> _minigames;
610 qdInventory *_cur_inventory;
611 qdInventoryCellTypeVector _inventory_cell_types;
613 qdObjectListContainer<qdFontInfo> _fonts;
618 qdGameObjectMouse *_mouse_obj;
619 qdGameObjectAnimated *_mouse_click_obj;
620 const qdGameObjectState *_mouse_click_state;
621 qdAnimation *_mouse_animation;
622 Vect2f _mouse_cursor_pos;
625 dialog_states_container_t _dialog_states;
626 dialog_states_container_t _dialog_states_last;
628 qdScreenTextDispatcher _screen_texts;
640 void *_scene_loading_progress_data;
641 qdLoadingProgressFnc _scene_loading_progress_fnc;
643 qdGameScene *_next_scene;
645 bool _interface_music_mode;
646 const qdMusicTrack *_cur_music_track;
647 const qdMusicTrack *_cur_interface_music_track;
650 float _fade_duration;
652 qdCameraMode _default_camera_mode;
654 static qdGameDispatcher *_dispatcher;
656 bool init_inventories();
658 qdInventoryCellTypeVector::iterator find_inventory_cell_type(
int type) {
660 _inventory_cell_types.end(), type);
663 qdInventoryCellTypeVector::const_iterator find_inventory_cell_type(
int type)
const {
664 return Common::find(_inventory_cell_types.begin(), _inventory_cell_types.end(), type);
667 void redraw(
const grScreenRegion ®);
668 void redraw_scene(
bool draw_interface =
true);
671 bool update_ingame_interface();
674 bool update_hall_of_fame_names();
677qdGameDispatcher *qd_get_game_dispatcher();
iterator end()
Definition: array.h:380
iterator erase(iterator pos)
Definition: array.h:329
T & back()
Definition: array.h:230
void push_back(const T &element)
Definition: array.h:181
bool empty() const
Definition: array.h:352
mouseEvent
События.
Definition: mouse_input.h:41
Definition: qd_file_owner.h:27
Шрифт
Definition: qd_font_info.h:36
Definition: qd_game_dispatcher_base.h:79
Definition: qd_game_dispatcher.h:43
bool activate_trigger_links(const qdNamedObject *p)
Делает активными все линки, идущие от объекта в триггерах.
int named_object_type() const
Возвращает тип объекта.
Definition: qd_game_dispatcher.h:75
@ TEXT_SET_DIALOGS
Фразы диалогов, отображаемые в данный момент на экране
Definition: qd_game_dispatcher.h:48
void set_startup_scene(const char *name)
Устанавливает имя стартовой сцены игры.
Definition: qd_game_dispatcher.h:474
void toggle_restart()
Ставит флаг, что надо перезапустить игру.
Definition: qd_game_dispatcher.h:446
bool deactivate_scene_triggers(const qdGameScene *p)
Делает неактивными все триггера сцены.
const char * startup_scene() const
Возвращает имя стартовой сцены игры.
Definition: qd_game_dispatcher.h:467
bool need_exit() const
Возвращает true, если надо выйти из игры.
Definition: qd_game_dispatcher.h:441
bool init()
Инициализация данных, вызывается один раз сразу после загрузки скрипта.
qdFontInfo * find_font_info(int type)
Поиск шрифтов
bool load_save(Common::SeekableReadStream *fh)
Загрузка данных из сэйва.
bool save_save(Common::WriteStream *stream) const
Запись данных в сэйв.
bool has_startup_scene() const
Возвращает true, если задана стартовая сцена игры.
Definition: qd_game_dispatcher.h:481
void toggle_exit()
Ставит флаг, что надо выйти из игры.
Definition: qd_game_dispatcher.h:437
bool add_font_info(qdFontInfo *fi)
Операции со шрифтами
bool need_restart() const
Возвращает true, если надо перезапустить игру.
Definition: qd_game_dispatcher.h:450
Mouse.
Definition: qd_game_object_mouse.h:34
Сцена.
Definition: qd_game_scene.h:47
bool has_main_menu() const
Возвращает true, если установлено имя экрана с главным меню игры.
Definition: qd_interface_dispatcher.h:125
const char * name() const
Возвращает имя объекта.
Definition: qd_named_object_base.h:40
Поименованный объект.
Definition: qd_named_object.h:70
void set_owner(qdNamedObject *p)
Устанавливает владельца объекта.
Definition: qd_named_object.h:86
bool check_flag(int fl) const
Возвращает true, если установлен флаг fl.
Definition: qd_named_object.h:99
void set_flag(int fl)
Устанавливает флаг.
Definition: qd_named_object.h:91
Диспетчер ресурсов.
Definition: qd_resource_dispatcher.h:32
XML тег.
Definition: xml_tag.h:33
In find(In first, In last, const T &v)
Definition: algorithm.h:225
Базовый класс для игровых ресурсов.
Definition: console.h:28