ScummVM API documentation
qd_interface_text_window.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_TEXT_WINDOW_H
23#define QDENGINE_QDCORE_QD_INTERFACE_TEXT_WINDOW_H
24
25#include "qdengine/qdcore/qd_interface_element.h"
26#include "qdengine/qdcore/qd_interface_element_state.h"
27#include "qdengine/system/graphics/UI_TextParser.h"
28
29
30namespace QDEngine {
31
32class qdScreenTextSet;
33class qdInterfaceSlider;
34
37public:
41
42 enum WindowType {
43 WINDOW_DIALOGS,
44 WINDOW_EDIT,
45 WINDOW_TEXT
46 };
47
48 enum TextVAlign {
49 VALIGN_TOP,
50 VALIGN_CENTER,
51 VALIGN_BOTTOM
52 };
53
54 enum InfoType {
55 INFO_NONE,
56 INFO_PLAYER_NAME,
57 INFO_PLAYER_SCORE
58 };
59
60 qdInterfaceTextWindow &operator = (const qdInterfaceTextWindow &wnd);
61
64 }
65
69 bool keyboard_handler(Common::KeyCode vkey);
70 bool char_input_handler(int input);
71
72 void hover_clear();
73
75
78 bool init(bool is_game_active = true);
79
80 bool quant(float dt);
81
82 const Common::Path border_background_file() const {
83 return _border_background.animation_file();
84 }
85 void set_border_background_file(const Common::Path &file_name) {
86 _border_background.set_animation_file(file_name);
87 }
88
89 uint32 background_color() const {
90 return _background_color;
91 }
92 void set_background_color(uint32 color) {
93 _background_color = color;
94 }
95
96 int background_alpha() const {
97 return _background_alpha;
98 }
99 void set_background_alpha(int alpha) {
100 _background_alpha = alpha;
101 }
102
103 bool has_background_color() const {
104 return _has_background_color;
105 }
106 void toggle_background_color(bool state) {
107 _has_background_color = state;
108 }
109
111 virtual const Vect2i r() const {
112 return qdInterfaceElement::r() - g_engine->screen_offset();
113 }
114
116 bool redraw() const;
117 bool need_redraw() const;
118
119 grScreenRegion screen_region() const;
120
122 int size_x() const;
124 int size_y() const;
125
126 const Vect2i &text_size() const {
127 return _text_size;
128 }
129 void set_text_size(const Vect2i &sz) {
130 _text_size = sz;
131 }
132
133 const char *slider_name() const {
134 return _slider_name.c_str();
135 }
136 void set_slider_name(const char *name) {
137 _slider_name = name;
138 }
139
141 bool hit_test(int x, int y) const;
142
143 WindowType windowType() const {
144 return _windowType;
145 }
146 void setWindowType(WindowType type) {
147 _windowType = type;
148 }
149
150 InfoType infoType() const {
151 return _infoType;
152 }
153 void setInfoType(InfoType type) {
154 _infoType = type;
155 }
156
157 int playerID() const {
158 return _playerID;
159 }
160 void setPlayerID(int id) {
161 _playerID = id;
162 }
163
164 const char *input_string() const {
165 return _inputString.c_str();
166 }
167 void set_input_string(const char *str);
168 bool edit_start();
169 bool edit_done(bool cancel = false);
170
171 TextVAlign text_valign() const {
172 return _textVAlign;
173 }
174 void set_text_valign(TextVAlign align) {
175 _textVAlign = align;
176 }
177
178 int inputStringLimit() const {
179 return _inputStringLimit;
180 }
181 void setInputStringLimit(int length) {
182 _inputStringLimit = length;
183 }
184
185 const qdScreenTextFormat &textFormat() const {
186 return _textFormat;
187 }
188 void setTextFormat(const qdScreenTextFormat &format) {
189 _textFormat = format;
190 }
191
192protected:
193
195 bool save_script_body(Common::WriteStream &fh, int indent = 0) const;
198
199private:
200
201 WindowType _windowType;
202
203 InfoType _infoType;
204 int _playerID;
205
207 Vect2i _text_size;
208
209 TextVAlign _textVAlign;
210
212 float _scrolling_speed;
213
214 float _scrolling_position;
215 int _text_set_position;
216
217 qdInterfaceElementState _border_background;
218 uint32 _background_color;
219 bool _has_background_color;
220 int _background_alpha;
221
222 int _text_set_id;
223 qdScreenTextSet *_text_set;
224
225 Common::String _slider_name;
226 qdInterfaceSlider *_slider;
227
228 Common::String _inputString;
229 Common::String _inputStringBackup;
230 qdScreenTextFormat _textFormat;
231 int _inputStringLimit;
232 bool _isEditing;
233 int _caretPose;
234
235 UI_TextParser _parser;
236
237 static bool _caretVisible;
238 static float _caretTimer;
239
240 void update_text_position();
241 void set_scrolling(int y_delta);
242
243 void text_redraw() const;
244 bool edit_input(Common::KeyCode vkey);
245};
246
247} // namespace QDEngine
248
249#endif // QDENGINE_QDCORE_QD_INTERFACE_TEXT_WINDOW_H
Definition: path.h:52
Definition: str.h:59
Definition: stream.h:77
Definition: UI_TextParser.h:55
Definition: xmath.h:268
Прямоугольная область на экране.
Definition: gr_screen_region.h:31
mouseEvent
События.
Definition: mouse_input.h:41
Базовый класс для элементов GUI.
Definition: qd_interface_element.h:41
virtual const Vect2i r() const
Возвращает экранные координаты центра элемента.
Definition: qd_interface_element.h:119
element_type
Типы элементов интерфейса.
Definition: qd_interface_element.h:65
@ EL_TEXT_WINDOW
окно с текстами
Definition: qd_interface_element.h:75
Состояние элемента интерфейса.
Definition: qd_interface_element_state.h:156
const Common::Path animation_file(state_mode_t anm_id=DEFAULT_MODE) const
Возвращает имя файла для анимации.
Definition: qd_interface_element_state.h:203
void set_animation_file(const Common::Path &name, state_mode_t anm_id=DEFAULT_MODE)
Устанавливает имя файла для анимации.
Интерфейсный элемент - слайдер.
Definition: qd_interface_slider.h:39
Интерфейсный элемент - окно для текстов.
Definition: qd_interface_text_window.h:36
bool redraw() const
Отрисовка окна.
bool load_script_body(const xml::tag *p)
Загрузка данных из скрипта.
bool hit_test(int x, int y) const
Возвращает true, если точка с экранными координатами (x,у) попадает в элемент.
bool mouse_handler(int x, int y, mouseDispatcher::mouseEvent ev)
Обработчик событий мыши.
bool init(bool is_game_active=true)
Инициализация элемента.
bool keyboard_handler(Common::KeyCode vkey)
Обработчик ввода с клавиатуры.
bool char_input_handler(int input)
Обработчик ввода символов с клавиатуры.
bool quant(float dt)
Обсчет логики, параметр - время в секундах.
int size_y() const
Возвращает размер окна вместе с рамкой по вертикали в пикселах.
qdInterfaceElement::element_type get_element_type() const
Возвращает тип элемента.
Definition: qd_interface_text_window.h:62
virtual const Vect2i r() const
Возвращает экранные координаты центра окна.
Definition: qd_interface_text_window.h:111
int size_x() const
Возвращает размер окна вместе с рамкой по горизонтали в пикселах.
bool save_script_body(Common::WriteStream &fh, int indent=0) const
Запись данных в скрипт.
const char * name() const
Возвращает имя объекта.
Definition: qd_named_object_base.h:40
Обозначает отсутствие шрифта
Definition: qd_screen_text.h:39
Набор экранных текстов.
Definition: qd_screen_text_set.h:32
XML тег.
Definition: xml_tag.h:33
Базовый класс для игровых ресурсов.
Definition: console.h:28