ScummVM API documentation
qd_interface_dispatcher.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
23#ifndef QDENGINE_QDCORE_QD_INTERFACE_DISPATCHER_H
24#define QDENGINE_QDCORE_QD_INTERFACE_DISPATCHER_H
25
26#include "common/keyboard.h"
27
28#include "qdengine/qdcore/qd_resource_container.h"
29#include "qdengine/qdcore/qd_interface_object_base.h"
30#include "qdengine/qdcore/qd_object_list_container.h"
31
32
33namespace QDEngine {
34
35class qdInterfaceScreen;
36class qdInterfaceElementState;
37
39public:
42
45 MODAL_SCREEN_SAVE_OVERWRITE,
46 MODAL_SCREEN_SAVE_NAME_EDIT,
47 MODAL_SCREEN_OTHER
48 };
49
51 bool redraw(int dx = 0, int dy = 0) const;
52 bool pre_redraw();
53 bool post_redraw();
54
56 bool quant(float dt);
57
61 bool rename_screen(qdInterfaceScreen *scr, const char *name);
65 qdInterfaceScreen *get_screen(const char *screen_name);
68
71 const screen_list_t &screen_list() const {
72 return _screens.get_list();
73 }
74
76
79 bool select_screen(const char *screen_name, bool lock_resources = false);
82
84 bool select_ingame_screen(bool inventory_state = false);
85
88
89 qdInterfaceScreen *selected_screen() const {
90 return _cur_screen;
91 }
92
94 bool is_screen_active(const qdInterfaceScreen *p) const {
95 return (_cur_screen == p);
96 }
97
103 qdResource *get_resource(const Common::Path &file_name) const {
104 return _resources.get_resource(file_name);
105 }
106
110 bool keyboard_handler(Common::KeyCode vkey);
111 bool char_input_handler(int vkey);
112
114 bool save_script(Common::WriteStream &fh, int indent = 0) const;
116 bool load_script(const xml::tag *p);
117
119 void set_main_menu_screen(const char *name);
121 const char *main_menu_screen_name() const {
122 return _main_menu_screen_name.c_str();
123 }
125 bool has_main_menu() const {
126 return !_main_menu_screen_name.empty();
127 }
128
130 void set_ingame_screen(const char *name, bool inventory_state = false);
132 const char *ingame_screen_name(bool inventory_state = false) const {
133 return _ingame_screen_names[inventory_state].c_str();
134 }
136 bool has_ingame_screen(bool inventory_state = false) const {
137 return !_ingame_screen_names[inventory_state].empty();
138 }
139
141 const char *save_prompt_screen_name() const {
142 return _save_prompt_screen_name.c_str();
143 }
144 void set_save_prompt_screen_name(const char *str) {
145 if (str) _save_prompt_screen_name = str;
146 else _save_prompt_screen_name = "";
147 }
148 bool has_save_prompt_screen() const {
149 return !_save_prompt_screen_name.empty();
150 }
151
152 const char *save_title_screen_name() const {
153 return _save_title_screen_name.c_str();
154 }
155 void set_save_title_screen_name(const char *name) {
156 _save_title_screen_name = name;
157 }
158 bool has_save_title_screen() const {
159 return !_save_title_screen_name.empty();
160 }
161
163 bool need_save_screenshot() const {
164 return _need_save_screenshot;
165 }
166 void toggle_save_screenshot(bool state) {
167 _need_save_screenshot = state;
168 }
170 bool need_show_save_time() const {
171 return _need_show_save_time;
172 }
173 void toggle_show_save_time(bool state) {
174 _need_show_save_time = state;
175 }
176 bool need_show_save_title() const {
177 return _need_show_save_title;
178 }
179 void toggle_show_save_title(bool state) {
180 _need_show_save_title = state;
181 }
183 int save_font_type() const {
184 return _save_font_type;
185 }
186 void set_save_font_type(int type) {
187 _save_font_type = type;
188 }
190 int save_font_color() const {
191 return _save_font_color;
192 }
193 void set_save_font_color(int clr) {
194 _save_font_color = clr;
195 }
196
198 bool need_scene_redraw() const {
199 return _need_scene_redraw;
200 }
202 void set_scene_redraw(bool state) {
203 _need_scene_redraw = state;
204 }
205
206 static void set_dispatcher(qdInterfaceDispatcher *p) {
207 _dispatcher = p;
208 }
209 static qdInterfaceDispatcher *get_dispatcher() {
210 return _dispatcher;
211 }
212
213 void activate() {
214 _is_active = true;
215 }
216 void deactivate() {
217 _is_active = false;
218 }
219 bool is_active() const {
220 return _is_active;
221 }
222
223 bool is_mouse_hover() const {
224 return _is_mouse_hover;
225 }
226 void toggle_mouse_hover() {
227 _is_mouse_hover = true;
228 }
229 bool is_autohide_enabled() const {
230 return !_autohide_disable;
231 }
232 void disable_autohide() {
233 _autohide_disable = true;
234 }
235
236 ModalScreenMode modalScreenMode() const {
237 return _modalScreenMode;
238 }
239 void setModalScreenMode(ModalScreenMode mode) {
240 _modalScreenMode = mode;
241 }
242
243 bool set_save_title(const char *title);
244 const char *get_save_title() const;
245
250 bool handle_event(int event_code, const char *event_data, qdInterfaceObjectBase *sender = NULL);
251
252 void toggle_end_game_mode(bool state) {
253 _end_game_mode = state;
254 }
255
257 void set_next_screen(const char *screen_name) {
258 _next_screen = screen_name;
259 }
260
261 static int option_value(int option_id, const char *option_data = NULL);
262 static bool set_option_value(int option_id, int value, const char *oprtion_data = NULL);
263
264#ifdef __QD_DEBUG_ENABLE__
265 bool get_resources_info(qdResourceInfoContainer &infos) const;
266#endif
267
268private:
269
271 qdInterfaceScreen *_cur_screen;
272
274 qdInterfaceScreen *_background_screen;
276 bool _background_screen_lock;
277
278 ModalScreenMode _modalScreenMode;
279
281 Common::String _main_menu_screen_name;
282
284
287 Common::String _ingame_screen_names[2];
288
290 Common::String _save_title_screen_name;
291 Common::String _save_title;
292
294 Common::String _save_prompt_screen_name;
295
297 bool _need_save_screenshot;
299 bool _need_show_save_time;
301 bool _need_show_save_title;
303 int _save_font_type;
305 int _save_font_color;
306
309
310 typedef qdResourceContainer<qdInterfaceElementState> resource_container_t;
312 resource_container_t _resources;
313
315 bool _is_active;
316
318 bool _is_mouse_hover;
320 bool _autohide_disable;
321
323 bool _need_full_redraw;
324
326 bool _need_scene_redraw;
327
330 bool _end_game_mode;
331
333 const char *_next_screen;
334
336 static qdInterfaceDispatcher *_dispatcher;
337};
338
339} // namespace QDEngine
340
341#endif // QDENGINE_QDCORE_QD_INTERFACE_DISPATCHER_H
Definition: path.h:52
Definition: str.h:59
Definition: stream.h:77
mouseEvent
События.
Definition: mouse_input.h:41
Definition: qd_interface_dispatcher.h:38
qdInterfaceScreen * get_screen(const char *screen_name)
Поиск экрана по имени.
bool remove_screen(qdInterfaceScreen *scr)
Удаление экрана из списка.
qdResource * add_resource(const Common::Path &file_name, const qdInterfaceElementState *owner)
Добавляет ресурс file_name с владельцем owner.
bool handle_event(int event_code, const char *event_data, qdInterfaceObjectBase *sender=NULL)
const screen_list_t & screen_list() const
Возвращает список экранов.
Definition: qd_interface_dispatcher.h:71
bool select_ingame_screen(bool inventory_state=false)
Включает внутриигровой интерфейс.
bool need_show_save_time() const
Нужно ли выводить дату и время при отображении сэйва
Definition: qd_interface_dispatcher.h:170
ModalScreenMode
для чего вызван модальный экран
Definition: qd_interface_dispatcher.h:44
const char * ingame_screen_name(bool inventory_state=false) const
Возвращает имя внутриигрового экрана.
Definition: qd_interface_dispatcher.h:132
bool is_screen_active(const qdInterfaceScreen *p) const
Возвращает true, если экран p в данный момент активен.
Definition: qd_interface_dispatcher.h:94
bool add_screen(qdInterfaceScreen *scr)
Добавление экрана.
bool is_screen_in_list(const qdInterfaceScreen *scr)
Возвращает true, если экран есть в списке.
bool select_background_screen(qdInterfaceScreen *p)
Установка фонового экрана.
const char * main_menu_screen_name() const
Возвращает имя экрана с главным меню игры.
Definition: qd_interface_dispatcher.h:121
bool quant(float dt)
Обсчет логики, параметр - время в секундах.
bool redraw(int dx=0, int dy=0) const
Отрисовка интерфейса.
void set_main_menu_screen(const char *name)
Установка имени экрана с главным меню игры.
bool rename_screen(qdInterfaceScreen *scr, const char *name)
Изменение имени экрана.
bool save_script(Common::WriteStream &fh, int indent=0) const
Запись данных в скрипт.
bool select_screen(const char *screen_name, bool lock_resources=false)
Установка активного экрана.
bool has_main_menu() const
Возвращает true, если установлено имя экрана с главным меню игры.
Definition: qd_interface_dispatcher.h:125
const char * save_prompt_screen_name() const
Имя модального экрана подсказки: перезаписывать сэйв или нет.
Definition: qd_interface_dispatcher.h:141
bool need_save_screenshot() const
Нужно ли выводить скриншот к сохраненке
Definition: qd_interface_dispatcher.h:163
void update_personage_buttons()
Включает кнопки, связанные с персонажем p, выключает кнопки остальных персонажей.
bool remove_resource(const Common::Path &file_name, const qdInterfaceElementState *owner)
Удаляет ресурс file_name с владельцем owner.
qdResource * get_resource(const Common::Path &file_name) const
Возвращает указатель на ресурс file_name.
Definition: qd_interface_dispatcher.h:103
void set_next_screen(const char *screen_name)
Устанавливает следующий экран.
Definition: qd_interface_dispatcher.h:257
bool mouse_handler(int x, int y, mouseDispatcher::mouseEvent ev)
Обработчик событий мыши.
int save_font_color() const
Цвет, которым выводится текст сэйва (в частности дата и время)
Definition: qd_interface_dispatcher.h:190
void set_scene_redraw(bool state)
Устанавливает, надо ли если интерфейсу отрисовываться поверх сцены.
Definition: qd_interface_dispatcher.h:202
bool has_ingame_screen(bool inventory_state=false) const
Возвращает true, если установлено имя внутриигрового экрана.
Definition: qd_interface_dispatcher.h:136
int save_font_type() const
Тип шрифт, которым выводится текст сэйва (в частности дата и время)
Definition: qd_interface_dispatcher.h:183
bool load_script(const xml::tag *p)
Загрузка данных из скрипта.
bool need_scene_redraw() const
Возвращает true, если интерфейс отрисовывается поверх сцены.
Definition: qd_interface_dispatcher.h:198
bool keyboard_handler(Common::KeyCode vkey)
Обработчик ввода с клавиатуры.
void set_ingame_screen(const char *name, bool inventory_state=false)
Установка имени внутриигрового экрана.
Состояние элемента интерфейса.
Definition: qd_interface_element_state.h:156
Базовый класс для всех интерфейсных объектов.
Definition: qd_interface_object_base.h:32
qdInterfaceObjectBase * owner() const
Возвращает указатель на владельца объекта.
Definition: qd_interface_object_base.h:43
Интерфейсный экран.
Definition: qd_interface_screen.h:44
const char * name() const
Возвращает имя объекта.
Definition: qd_named_object_base.h:40
Definition: qd_object_list_container.h:32
qdResource * get_resource(const Common::Path &file_name) const
Возвращает указатель на ресурс, соответствующий файлу с именем file_name.
Definition: qd_resource_container.h:156
Definition: qd_resource.h:34
XML тег.
Definition: xml_tag.h:33
Definition: list.h:39
Базовый класс для игровых ресурсов.
Definition: console.h:28