ScummVM API documentation
qd_game_dispatcher_base.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_DISPATCHER_BASE_H
23#define QDENGINE_QDCORE_QD_GAME_DISPATCHER_BASE_H
24
25#include "qdengine/qdcore/qd_conditional_object.h"
26#include "qdengine/qdcore/qd_object_map_container.h"
27#include "qdengine/qdcore/qd_scale_info.h"
28
29#include "qdengine/qd_fwd.h"
30#include "qdengine/parser/xml_fwd.h"
31
32#ifdef __QD_DEBUG_ENABLE__
33#include "qdengine/qdcore/qd_resource.h"
34#endif
35
36namespace QDEngine {
37
38typedef void (*qdLoadingProgressFnc)(int percents_loaded, void *data);
39
41 uint32 _total_size;
42 uint32 _loaded_size;
43 void *_data;
44 qdLoadingProgressFnc _progress_fnc;
45
46public:
47
48 qdLoadingProgressFnc set_callback_fnc(qdLoadingProgressFnc p, void *dp) {
49 qdLoadingProgressFnc old_fnc = _progress_fnc;
50 _progress_fnc = p;
51 _data = dp;
52
53 return old_fnc;
54 }
55
56 void set_total_size(int sz) {
57 _total_size = sz;
58 _loaded_size = 0;
59 }
60 int total_size() const {
61 return _total_size;
62 }
63
64 void show_progress(int sz) {
65 if (!_total_size || !_progress_fnc) return;
66 _loaded_size += sz;
67 uint32 percents = round(float(_loaded_size) / float(_total_size) * 100.0f);
68 (*_progress_fnc)(percents, _data);
69 }
70
72 _progress_fnc = 0;
73 _total_size = _loaded_size = 0;
74 _data = 0;
75 }
77};
78
80public:
83
84 void set_resources_size(int sz) {
85 _loading_progress.set_total_size(sz);
86 }
87
88 qdLoadingProgressFnc set_loading_progress_callback(qdLoadingProgressFnc p, void *dp = 0) {
89 return _loading_progress.set_callback_fnc(p, dp);
90 }
91
92 void show_loading_progress(int sz = 0);
93
94 bool add_sound(qdSound *p);
95 bool remove_sound(const char *name);
96 bool remove_sound(qdSound *p);
97 virtual qdSound *get_sound(const char *name);
98 bool is_sound_in_list(const char *name);
99 bool is_sound_in_list(qdSound *p);
100
101 bool add_animation(qdAnimation *p);
102 bool remove_animation(const char *name);
103 bool remove_animation(qdAnimation *p);
104 virtual qdAnimation *get_animation(const char *name);
105 bool is_animation_in_list(const char *name);
106 bool is_animation_in_list(qdAnimation *p);
107
108 bool add_animation_set(qdAnimationSet *p);
109 bool remove_animation_set(const char *name);
110 bool remove_animation_set(qdAnimationSet *p);
111 virtual qdAnimationSet *get_animation_set(const char *name);
112 bool is_animation_set_in_list(const char *name);
113 bool is_animation_set_in_list(qdAnimationSet *p);
114
115 const qdSoundList &sound_list() const {
116 return _sounds.get_list();
117 }
118 const qdAnimationList &animation_list() const {
119 return _animations.get_list();
120 }
121 const qdAnimationSetList &animation_set_list() const {
122 return _animation_sets.get_list();
123 }
124
125 virtual void load_script_body(const xml::tag *p);
126 virtual bool save_script_body(Common::WriteStream &fh, int indent = 0) const;
127
128 virtual int load_resources();
129 void free_resources();
130
131 virtual void quant(float dt) { };
132
133 void add_scale_info(qdScaleInfo *p) {
134 _scale_infos.push_back(*p);
135 }
136 bool get_object_scale(const char *p, float &sc);
137 bool set_object_scale(const char *p, float sc);
138
139 virtual qdScaleInfo *get_scale_info(const char *p);
140
141 virtual int get_resources_size();
142
145 }
146
147#ifdef __QD_DEBUG_ENABLE__
148 virtual bool get_resources_info(qdResourceInfoContainer &infos) const;
149#endif
150
151private:
152
156
157 typedef Std::vector<qdScaleInfo> scale_info_container_t;
158 scale_info_container_t _scale_infos;
159
160 qdLoadingProgressInfo _loading_progress;
161};
162
163} // namespace QDEngine
164
165#endif // QDENGINE_QDCORE_QD_GAME_DISPATCHER_BASE_H
void push_back(const T &element)
Definition: array.h:181
Definition: stream.h:77
Анимация.
Definition: qd_animation.h:57
Definition: qd_animation_set.h:34
Объект с условиями.
Definition: qd_conditional_object.h:37
trigger_start_mode
Варианты старта триггера.
Definition: qd_conditional_object.h:122
@ TRIGGER_START_FAILED
запуск не удался
Definition: qd_conditional_object.h:124
Definition: qd_game_dispatcher_base.h:79
qdConditionalObject::trigger_start_mode trigger_start()
Активация триггера.
Definition: qd_game_dispatcher_base.h:143
Definition: qd_game_dispatcher_base.h:40
const char * name() const
Возвращает имя объекта.
Definition: qd_named_object_base.h:40
Definition: qd_object_map_container.h:33
Definition: qd_scale_info.h:31
Звук.
Definition: qd_sound.h:35
XML тег.
Definition: xml_tag.h:33
Definition: list.h:39
Базовый класс для игровых ресурсов.
Definition: console.h:28