ScummVM API documentation
qd_interface_element.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_INTERFACE_ELEMENT_H
23#define QDENGINE_QDCORE_QD_INTERFACE_ELEMENT_H
24
25#include "common/keyboard.h"
26
27#include "qdengine/system/sound/snd_sound.h"
28#include "qdengine/system/input/mouse_input.h"
29#include "qdengine/system/graphics/gr_screen_region.h"
30#include "qdengine/qdcore/qd_animation.h"
31#include "qdengine/qdcore/qd_interface_object_base.h"
32#include "qdengine/qdcore/qd_sound_handle.h"
33
34
35namespace QDEngine {
36
37//class qdInterfaceScreen;
38class qdInterfaceElementState;
39
42public:
45 virtual ~qdInterfaceElement() = 0;
46
47 qdInterfaceElement &operator = (const qdInterfaceElement &el);
48
51 OPTION_NONE = 0,
62 };
63
78 };
79
88 };
89
95 virtual element_type get_element_type() const = 0;
96
99 return _option_ID;
100 }
103 _option_ID = id;
104 }
106 bool linked_to_option() const {
107 return (_option_ID != OPTION_NONE);
108 }
110 virtual int option_value() const {
111 return -1;
112 }
114 virtual bool set_option_value(int value) {
115 return false;
116 }
117
119 virtual const Vect2i r() const {
120 return _r + g_engine->screen_offset();
121 }
123 void set_r(const Vect2i &v) {
124 _r = v;
125 }
126
128 virtual int size_x() const {
129 return _animation.size_x();
130 }
132 virtual int size_y() const {
133 return _animation.size_y();
134 }
135
136 virtual grScreenRegion screen_region() const;
137 const grScreenRegion &last_screen_region() const {
138 return _last_screen_region;
139 }
140
142 void set_screen_depth(int v) {
143 _screen_depth = v;
144 }
146 int screen_depth() const {
147 return _screen_depth;
148 }
149
151 bool save_script(Common::WriteStream &fh, int indent = 0) const;
152
154 bool load_script(const xml::tag *p);
155
157 virtual bool redraw() const;
158 virtual bool need_redraw() const;
159 virtual bool post_redraw();
160
162 virtual bool mouse_handler(int x, int y, mouseDispatcher::mouseEvent ev) = 0;
164 virtual bool keyboard_handler(Common::KeyCode vkey) = 0;
166 virtual bool char_input_handler(int vkey) {
167 return false;
168 }
169
170 virtual void hover_clear() { }
171
173
176 virtual bool init(bool is_game_active = true) = 0;
177
179 virtual bool quant(float dt);
180
181 const qdAnimation &animation() const {
182 return _animation;
183 }
184
186 bool set_animation(const qdAnimation *anm, int anm_flags = 0);
189
191 qdResource *add_resource(const Common::Path &file_name, const qdInterfaceElementState *res_owner);
193 bool remove_resource(const Common::Path &file_name, const qdInterfaceElementState *res_owner);
194
196 virtual bool hit_test(int x, int y) const;
197
200
202 void hide() {
203 _is_visible = false;
204 }
206 void show() {
207 _is_visible = true;
208 }
210 bool is_visible() const {
211 return _is_visible;
212 }
213
215 bool is_locked() const {
216 return _is_locked;
217 }
219 void set_lock(bool state) {
220 _is_locked = state;
221 }
222
223protected:
224
226 virtual bool save_script_body(Common::WriteStream &fh, int indent = 0) const = 0;
227
229 virtual bool load_script_body(const xml::tag *p) = 0;
230
231 void clear_screen_region() {
232 _last_screen_region = grScreenRegion_EMPTY;
233 }
234
235private:
236
238 option_ID_t _option_ID;
240 Common::String _option_data;
241
243 Vect2i _r;
244
246 int _screen_depth;
247
249 qdAnimation _animation;
250
252 qdSoundHandle _sound_handle;
253
255 bool _is_visible;
256
258 bool _is_locked;
259
260 grScreenRegion _last_screen_region;
261 const qdAnimationFrame *_last_animation_frame;
262};
263
264} // namespace QDEngine
265
266#endif // QDENGINE_QDCORE_QD_INTERFACE_ELEMENT_H
Definition: path.h:52
Definition: str.h:59
Definition: stream.h:77
Definition: xmath.h:268
Прямоугольная область на экране.
Definition: gr_screen_region.h:31
mouseEvent
События.
Definition: mouse_input.h:41
Кадр анимации.
Definition: qd_animation_frame.h:31
Анимация.
Definition: qd_animation.h:57
Базовый класс для элементов GUI.
Definition: qd_interface_element.h:41
qdResource * add_resource(const Common::Path &file_name, const qdInterfaceElementState *res_owner)
Добавляет ресурс file_name с владельцем owner.
virtual int size_x() const
Возвращает размер элемента по горизонтали в пикселах.
Definition: qd_interface_element.h:128
bool linked_to_option() const
Возвращает true, если с элементом связана настройка игры.
Definition: qd_interface_element.h:106
virtual bool load_script_body(const xml::tag *p)=0
Загрузка данных из скрипта.
void set_screen_depth(int v)
Устанавливает экранную глубину элемента.
Definition: qd_interface_element.h:142
bool save_script(Common::WriteStream &fh, int indent=0) const
Запись данных в скрипт.
virtual const Vect2i r() const
Возвращает экранные координаты центра элемента.
Definition: qd_interface_element.h:119
state_status_t state_status(const qdInterfaceElementState *p) const
Возвращает статус состояния.
virtual bool redraw() const
Отрисовка элемента.
void set_lock(bool state)
Блокировка/разблокировка элемента.
Definition: qd_interface_element.h:219
static qdInterfaceElement * create_element(element_type tp)
Создание элемента интерфейса заданного типа.
int screen_depth() const
Возвращает экранную глубину эелмента.
Definition: qd_interface_element.h:146
virtual bool mouse_handler(int x, int y, mouseDispatcher::mouseEvent ev)=0
Обработчик событий мыши.
option_ID_t
Идентификаторы настроек игры.
Definition: qd_interface_element.h:50
@ OPTION_SOUND_VOLUME
громкость звука, [0, 255]
Definition: qd_interface_element.h:55
@ OPTION_MUSIC_VOLUME
громкость музыки, [0, 255]
Definition: qd_interface_element.h:59
@ OPTION_ACTIVE_PERSONAGE
определенный персонаж персонаж активен/неактивен, 1/0
Definition: qd_interface_element.h:61
@ OPTION_SOUND
звук вкл/выкл, 1/0
Definition: qd_interface_element.h:53
@ OPTION_MUSIC
музыка вкл/выкл, 1/0
Definition: qd_interface_element.h:57
void show()
Показывает элемент.
Definition: qd_interface_element.h:206
bool remove_resource(const Common::Path &file_name, const qdInterfaceElementState *res_owner)
Удаляет ресурс file_name с владельцем owner.
virtual bool set_option_value(int value)
Устанавливает значение настройки игры, связанной с элементом.
Definition: qd_interface_element.h:114
bool set_state(const qdInterfaceElementState *p)
Включает состояние элемента.
virtual bool keyboard_handler(Common::KeyCode vkey)=0
Обработчик ввода с клавиатуры.
element_type
Типы элементов интерфейса.
Definition: qd_interface_element.h:65
@ EL_SAVE
сэйв
Definition: qd_interface_element.h:73
@ EL_BACKGROUND
фон
Definition: qd_interface_element.h:67
@ EL_BUTTON
кнопка
Definition: qd_interface_element.h:69
@ EL_TEXT_WINDOW
окно с текстами
Definition: qd_interface_element.h:75
@ EL_SLIDER
слайдер
Definition: qd_interface_element.h:71
@ EL_COUNTER
счётчик
Definition: qd_interface_element.h:77
virtual bool save_script_body(Common::WriteStream &fh, int indent=0) const =0
Запись данных в скрипт.
bool load_script(const xml::tag *p)
Загрузка данных из скрипта.
void set_option_ID(option_ID_t id)
Устанавливает идентификатор настройки игры, связанной с элементом.
Definition: qd_interface_element.h:102
void set_r(const Vect2i &v)
Устанавливает экранные координаты центра элемента.
Definition: qd_interface_element.h:123
bool is_visible() const
Возвращает true, если элемент не спрятан.
Definition: qd_interface_element.h:210
virtual bool hit_test(int x, int y) const
Возвращает true, если точка с экранными координатами (x,у) попадает в элемент.
virtual int option_value() const
Возвращает значение настройки игры, связанной с элементом.
Definition: qd_interface_element.h:110
bool set_animation(const qdAnimation *anm, int anm_flags=0)
Устанавливает анимацию для элемента.
virtual element_type get_element_type() const =0
Возвращает тип элемента.
void hide()
Прячет элемент.
Definition: qd_interface_element.h:202
virtual int size_y() const
Возвращает размер элемента по вертикали в пикселах.
Definition: qd_interface_element.h:132
state_status_t
Статус состояния.
Definition: qd_interface_element.h:81
@ STATE_DONE
работа состояния закончилась
Definition: qd_interface_element.h:87
@ STATE_INACTIVE
состояние неактивно
Definition: qd_interface_element.h:83
@ STATE_ACTIVE
состояние активно
Definition: qd_interface_element.h:85
virtual bool quant(float dt)
Обсчет логики, параметр - время в секундах.
virtual bool char_input_handler(int vkey)
Обработчик ввода символов с клавиатуры.
Definition: qd_interface_element.h:166
bool is_locked() const
Возвращает true, если элемент заблокирован.
Definition: qd_interface_element.h:215
virtual bool init(bool is_game_active=true)=0
Инициализация элемента.
option_ID_t option_ID() const
Возвращает идентификатор настройки игры, связанной с элементом.
Definition: qd_interface_element.h:98
static void destroy_element(qdInterfaceElement *p)
Уничтожение элемента интерфейса.
Состояние элемента интерфейса.
Definition: qd_interface_element_state.h:156
Базовый класс для всех интерфейсных объектов.
Definition: qd_interface_object_base.h:32
Definition: qd_resource.h:34
Класс для управления звуками.
Definition: qd_sound_handle.h:31
XML тег.
Definition: xml_tag.h:33
Базовый класс для игровых ресурсов.
Definition: console.h:28