22#ifndef QDENGINE_QDCORE_QD_SCREEN_TEXT_H
23#define QDENGINE_QDCORE_QD_SCREEN_TEXT_H
25#include "common/stream.h"
27#include "qdengine/parser/xml_fwd.h"
28#include "qdengine/xmath.h"
29#include "qdengine/system/graphics/gr_screen_region.h"
30#include "qdengine/system/graphics/gr_font.h"
34class qdGameObjectState;
36const int QD_FONT_TYPE_NONE = -1;
62 bool operator == (
const qdScreenTextFormat &fmt)
const {
63 return (_color == fmt._color &&
64 _arrangement == fmt._arrangement &&
65 _alignment == fmt._alignment &&
66 _hover_color == fmt._hover_color &&
67 _font_type == fmt.font_type() &&
68 _global_depend == fmt.is_global_depend());
71 bool operator != (
const qdScreenTextFormat &fmt)
const {
72 return !(*
this == fmt);
89 void set_color(
int color) {
96 void set_hover_color(
int color) {
99 int hover_color()
const {
103 static const qdScreenTextFormat &default_format();
104 static const qdScreenTextFormat &global_text_format();
105 static void set_global_text_format(
const qdScreenTextFormat &frmt);
106 static const qdScreenTextFormat &global_topic_format();
107 static void set_global_topic_format(
const qdScreenTextFormat &frmt);
109 void set_font_type(
int tp) {
112 int font_type()
const {
116 bool is_global_depend()
const {
117 return _global_depend;
119 void toggle_global_depend(
bool flag =
true) {
120 _global_depend = flag;
123 bool load_script(
const xml::tag *p);
161 const char *data()
const {
162 return _data.c_str();
180 return _text_format.arrangement();
183 return _text_format.alignment();
186 qdScreenTextFormat text_format()
const {
189 void set_text_format(
const qdScreenTextFormat &fmt) {
193 grScreenRegion screen_region()
const {
194 return grScreenRegion(_pos.x, _pos.y, _size.x, _size.y);
200 uint32 color()
const {
201 return _text_format.color();
203 void set_color(uint32 col) {
204 _text_format.set_color(col);
218 bool hit(
int x,
int y)
const {
219 if (x >= _pos.x && x < _pos.x + _size.x) {
220 if (y >= _pos.y && y < _pos.y + _size.y)
226 void set_hover_mode(
bool state) {
231 bool format_text(
int max_width);
247 qdScreenTextFormat _text_format;
250 mutable qdGameObjectState *_owner;
Состояние динамического объекта - базовый класс.
Definition: qd_game_object_state.h:91
Поименованный объект.
Definition: qd_named_object.h:70
Обозначает отсутствие шрифта
Definition: qd_screen_text.h:39
arrangement_t
Расположение относительно других текстов.
Definition: qd_screen_text.h:42
@ ARRANGE_HORIZONTAL
Выравнивание по горизонтали.
Definition: qd_screen_text.h:44
@ ARRANGE_VERTICAL
Выравнивание по вертикали.
Definition: qd_screen_text.h:46
alignment_t
Выравнивание текста.
Definition: qd_screen_text.h:50
@ ALIGN_CENTER
по центру
Definition: qd_screen_text.h:54
@ ALIGN_RIGHT
по правому краю
Definition: qd_screen_text.h:56
@ ALIGN_LEFT
по левому краю
Definition: qd_screen_text.h:52
Экранный текст.
Definition: qd_screen_text.h:146
void set_owner(qdGameObjectState *p)
Устанавливает владельца текста.
Definition: qd_screen_text.h:212
int size_x() const
Горизонтальный размер текста в пикселах.
Definition: qd_screen_text.h:171
int size_y() const
Вертикальный размер текста в пикселах.
Definition: qd_screen_text.h:175
Vect2i screen_pos()
Экранные координаты центра текста.
Definition: qd_screen_text.h:153
void set_data(const char *p)
Устанавливает текст.
void set_screen_pos(const Vect2i &pos)
Устанавливает экранные координаты центра текста.
Definition: qd_screen_text.h:157
qdGameObjectState * owner() const
Возвращает указатель на владельца текста.
Definition: qd_screen_text.h:208
bool hit(int x, int y) const
Проверка попадания точки в текст, параметры в экранных координатах.
Definition: qd_screen_text.h:218
void redraw(const Vect2i &owner_pos) const
Отрисовка текста.
Базовый класс для игровых ресурсов.
Definition: console.h:28