70 if (name ==
"textcolor") {
72 }
else if (name ==
"bgcolor") {
74 }
else if (name ==
"bgcolor_hovered") {
76 }
else if (name ==
"bgcolor_pressed") {
78 }
else if (name ==
"noclip") {
80 }
else if (name ==
"border") {
82 }
else if (name ==
"bgimg") {
84 }
else if (name ==
"bgimg_hovered") {
86 }
else if (name ==
"bgimg_middle") {
88 }
else if (name ==
"bgimg_pressed") {
90 }
else if (name ==
"fgimg") {
92 }
else if (name ==
"fgimg_hovered") {
94 }
else if (name ==
"fgimg_middle") {
96 }
else if (name ==
"fgimg_pressed") {
98 }
else if (name ==
"alpha") {
100 }
else if (name ==
"content_offset") {
102 }
else if (name ==
"padding") {
104 }
else if (name ==
"font") {
106 }
else if (name ==
"font_size") {
108 }
else if (name ==
"colors") {
110 }
else if (name ==
"bordercolors") {
112 }
else if (name ==
"borderwidths") {
114 }
else if (name ==
"sound") {
116 }
else if (name ==
"spacing") {
118 }
else if (name ==
"size") {
128 return val.empty() ? def : val;
140 if (name ==
"default") {
142 }
else if (name ==
"focused") {
144 }
else if (name ==
"hovered") {
146 }
else if (name ==
"pressed") {
174 if ((state & i) != 0) {
175 temp = temp | styles[i];
204 std::array<video::SColor, 4> def)
const
210 std::vector<std::string> strs;
214 for (
size_t i = 0; i <= 3; i++) {
229 std::vector<std::string> strs;
233 for (
size_t i = 0; i <= 3; i++)
234 def[i] =
stoi(strs[i]);
245 irr::core::rect<s32> rect;
257 irr::core::rect<s32> rect;
285 return v2s32(vec.X, vec.Y);
295 return v2s32(vec.X, vec.Y);
305 if (font.empty() && size.empty())
308 std::vector<std::string> modes =
split(font,
',');
310 for (
size_t i = 0; i < modes.size(); i++) {
311 if (modes[i] ==
"normal")
313 else if (modes[i] ==
"mono")
315 else if (modes[i] ==
"bold")
317 else if (modes[i] ==
"italic")
324 if (size[0] ==
'*') {
325 std::string new_size = size.substr(1);
327 }
else if (size[0] ==
'+' || size[0] ==
'-') {
330 calc_size =
stoi(size);
333 spec.
size = (unsigned)std::min(std::max(calc_size, 1), 999);
340 video::ITexture *def)
const
347 video::ITexture *texture = tsrc->
getTexture(val);
357 video::ITexture *texture = tsrc->
getTexture(val);
384 set(prop, other.
get(prop,
""));
399 bool parseArray(
const std::string &value, std::vector<std::string> &arr)
const
401 std::vector<std::string> strs =
split(value,
',');
403 if (strs.size() == 1) {
404 arr = {strs[0], strs[0], strs[0], strs[0]};
405 }
else if (strs.size() == 2) {
406 arr = {strs[0], strs[1], strs[0], strs[1]};
407 }
else if (strs.size() == 4) {
411 <<
" arguments): \"" << value <<
"\"" << std::endl;
417 bool parseRect(
const std::string &value, irr::core::rect<s32> *parsed_rect)
const
419 irr::core::rect<s32> rect;
420 std::vector<std::string> v_rect =
split(value,
',');
422 if (v_rect.size() == 1) {
423 s32 x =
stoi(v_rect[0]);
424 rect.UpperLeftCorner = irr::core::vector2di(x, x);
425 rect.LowerRightCorner = irr::core::vector2di(-x, -x);
426 }
else if (v_rect.size() == 2) {
427 s32 x =
stoi(v_rect[0]);
428 s32 y =
stoi(v_rect[1]);
429 rect.UpperLeftCorner = irr::core::vector2di(x, y);
430 rect.LowerRightCorner = irr::core::vector2di(-x, -y);
432 }
else if (v_rect.size() == 4) {
433 rect.UpperLeftCorner = irr::core::vector2di(
435 rect.LowerRightCorner = irr::core::vector2di(
438 warningstream <<
"Invalid rectangle string format: \"" << value
439 <<
"\"" << std::endl;
451 std::vector<std::string> v_vector =
split(value,
',');
453 if (v_vector.size() == 1) {
454 f32 x =
stof(v_vector[0]);
457 }
else if (v_vector.size() == 2) {
458 vec.X =
stof(v_vector[0]);
459 vec.Y =
stof(v_vector[1]);
461 warningstream <<
"Invalid 2d vector string format: \"" << value
462 <<
"\"" << std::endl;
unsigned int getFontSize(FontMode mode)
get font size for a specific mode
Definition fontengine.cpp:152
irr::gui::IGUIFont * getFont(FontSpec spec)
Definition fontengine.cpp:80
Definition texturesource.h:25
virtual video::ITexture * getTexture(const std::string &name, u32 *id=nullptr)=0
Definition StyleSpec.h:18
gui::IGUIFont * getFont() const
Definition StyleSpec.h:298
static State getStateByName(const std::string &name)
Parses a name and returns the corresponding state enum.
Definition StyleSpec.h:138
video::SColor getColor(Property prop) const
Definition StyleSpec.h:193
std::array< bool, NUM_PROPERTIES > property_set
Definition StyleSpec.h:63
bool getBool(Property prop, bool def) const
Definition StyleSpec.h:362
State
Definition StyleSpec.h:53
@ STATE_HOVERED
Definition StyleSpec.h:56
@ STATE_INVALID
Definition StyleSpec.h:59
@ STATE_FOCUSED
Definition StyleSpec.h:55
@ STATE_DEFAULT
Definition StyleSpec.h:54
@ STATE_PRESSED
Definition StyleSpec.h:57
@ NUM_STATES
Definition StyleSpec.h:58
bool parseVector2f(const std::string &value, v2f32 *parsed_vec) const
Definition StyleSpec.h:448
State getState() const
Gets the state that this style is intended for.
Definition StyleSpec.h:154
std::string get(Property prop, std::string def) const
Definition StyleSpec.h:125
v2s32 getVector2i(Property prop) const
Definition StyleSpec.h:288
Property
Definition StyleSpec.h:21
@ FONT_SIZE
Definition StyleSpec.h:40
@ BGCOLOR_PRESSED
Definition StyleSpec.h:25
@ SOUND
Definition StyleSpec.h:44
@ BORDERCOLORS
Definition StyleSpec.h:42
@ BGIMG_PRESSED
Definition StyleSpec.h:31
@ ALPHA
Definition StyleSpec.h:36
@ BGCOLOR_HOVERED
Definition StyleSpec.h:24
@ SPACING
Definition StyleSpec.h:45
@ BGIMG_MIDDLE
Definition StyleSpec.h:30
@ NOCLIP
Definition StyleSpec.h:26
@ SIZE
Definition StyleSpec.h:46
@ PADDING
Definition StyleSpec.h:38
@ NUM_PROPERTIES
Definition StyleSpec.h:47
@ COLORS
Definition StyleSpec.h:41
@ FONT
Definition StyleSpec.h:39
@ BORDER
Definition StyleSpec.h:27
@ FGIMG_PRESSED
Definition StyleSpec.h:35
@ NONE
Definition StyleSpec.h:48
@ TEXTCOLOR
Definition StyleSpec.h:22
@ BGCOLOR
Definition StyleSpec.h:23
@ BGIMG
Definition StyleSpec.h:28
@ BGIMG_HOVERED
Definition StyleSpec.h:29
@ FGIMG
Definition StyleSpec.h:32
@ BORDERWIDTHS
Definition StyleSpec.h:43
@ FGIMG_MIDDLE
Definition StyleSpec.h:34
@ CONTENT_OFFSET
Definition StyleSpec.h:37
@ FGIMG_HOVERED
Definition StyleSpec.h:33
v2s32 getVector2i(Property prop, v2s32 def) const
Definition StyleSpec.h:275
static StyleSpec getStyleFromStatePropagation(const std::array< StyleSpec, NUM_STATES > &styles, State state)
Using a list of styles mapped to state values, calculate the final.
Definition StyleSpec.h:169
std::array< video::SColor, 4 > getColorArray(Property prop, std::array< video::SColor, 4 > def) const
Definition StyleSpec.h:203
static Property GetPropertyByName(const std::string &name)
Definition StyleSpec.h:68
irr::core::rect< s32 > getRect(Property prop) const
Definition StyleSpec.h:252
bool isNotDefault(Property prop) const
Definition StyleSpec.h:372
StyleSpec operator|(const StyleSpec &other) const
Definition StyleSpec.h:391
void addState(State state)
Set the given state on this style.
Definition StyleSpec.h:160
bool parseArray(const std::string &value, std::vector< std::string > &arr) const
Definition StyleSpec.h:399
video::ITexture * getTexture(Property prop, ISimpleTextureSource *tsrc) const
Definition StyleSpec.h:352
irr::core::rect< s32 > getRect(Property prop, irr::core::rect< s32 > def) const
Definition StyleSpec.h:239
video::SColor getColor(Property prop, video::SColor def) const
Definition StyleSpec.h:182
State state_map
Definition StyleSpec.h:65
StyleSpec & operator|=(const StyleSpec &other)
Definition StyleSpec.h:379
void set(Property prop, const std::string &value)
Definition StyleSpec.h:131
video::ITexture * getTexture(Property prop, ISimpleTextureSource *tsrc, video::ITexture *def) const
Definition StyleSpec.h:339
bool parseRect(const std::string &value, irr::core::rect< s32 > *parsed_rect) const
Definition StyleSpec.h:417
std::array< s32, 4 > getIntArray(Property prop, std::array< s32, 4 > def) const
Definition StyleSpec.h:223
bool hasProperty(Property prop) const
Definition StyleSpec.h:377
std::array< std::string, NUM_PROPERTIES > properties
Definition StyleSpec.h:64
v2f32 getVector2f(Property prop, v2f32 def) const
Definition StyleSpec.h:262
#define FATAL_ERROR_IF(expr, msg)
Definition debug.h:36
FontEngine * g_fontengine
reference to access font engine, has to be initialized by main
Definition fontengine.cpp:19
@ FM_Standard
Definition fontengine.h:23
@ FM_Mono
Definition fontengine.h:24
#define FONT_SIZE_UNSPECIFIED
Definition fontengine.h:20
core::vector2d< f32 > v2f32
Definition irr_v2d.h:15
core::vector2d< s32 > v2s32
Definition irr_v2d.h:13
thread_local LogStream warningstream
bool parseColorString(const std::string &value, video::SColor &color, bool quiet, unsigned char default_alpha)
Definition string.cpp:600
#define stoi
Definition string.h:431
#define stof
Definition string.h:432
std::vector< std::basic_string< T > > split(const std::basic_string< T > &s, T delim)
Definition string.h:611
bool is_yes(std::string_view str)
Returns whether str should be regarded as (bool) true.
Definition string.h:381
Definition fontengine.h:30
bool italic
Definition fontengine.h:45
bool bold
Definition fontengine.h:44
unsigned int size
Definition fontengine.h:42
FontMode mode
Definition fontengine.h:43