84 if (name ==
"textcolor") {
86 }
else if (name ==
"bgcolor") {
88 }
else if (name ==
"bgcolor_hovered") {
90 }
else if (name ==
"bgcolor_pressed") {
92 }
else if (name ==
"noclip") {
94 }
else if (name ==
"border") {
96 }
else if (name ==
"bgimg") {
98 }
else if (name ==
"bgimg_hovered") {
100 }
else if (name ==
"bgimg_middle") {
102 }
else if (name ==
"bgimg_pressed") {
104 }
else if (name ==
"fgimg") {
106 }
else if (name ==
"fgimg_hovered") {
108 }
else if (name ==
"fgimg_middle") {
110 }
else if (name ==
"fgimg_pressed") {
112 }
else if (name ==
"alpha") {
114 }
else if (name ==
"content_offset") {
116 }
else if (name ==
"padding") {
118 }
else if (name ==
"font") {
120 }
else if (name ==
"font_size") {
122 }
else if (name ==
"colors") {
124 }
else if (name ==
"bordercolors") {
126 }
else if (name ==
"borderwidths") {
128 }
else if (name ==
"sound") {
130 }
else if (name ==
"spacing") {
132 }
else if (name ==
"size") {
142 return val.empty() ? def : val;
154 if (name ==
"default") {
156 }
else if (name ==
"focused") {
158 }
else if (name ==
"hovered") {
160 }
else if (name ==
"pressed") {
188 if ((state & i) != 0) {
189 temp = temp | styles[i];
218 std::array<video::SColor, 4> def)
const
224 std::vector<std::string> strs;
228 for (
size_t i = 0; i <= 3; i++) {
243 std::vector<std::string> strs;
247 for (
size_t i = 0; i <= 3; i++)
248 def[i] =
stoi(strs[i]);
259 irr::core::rect<s32> rect;
271 irr::core::rect<s32> rect;
299 return v2s32(vec.X, vec.Y);
309 return v2s32(vec.X, vec.Y);
319 if (font.empty() && size.empty())
322 std::vector<std::string> modes =
split(font,
',');
324 for (
size_t i = 0; i < modes.size(); i++) {
325 if (modes[i] ==
"normal")
327 else if (modes[i] ==
"mono")
329 else if (modes[i] ==
"bold")
331 else if (modes[i] ==
"italic")
338 if (size[0] ==
'*') {
339 std::string new_size = size.substr(1);
341 }
else if (size[0] ==
'+' || size[0] ==
'-') {
344 calc_size =
stoi(size);
347 spec.
size = (unsigned)std::min(std::max(calc_size, 1), 999);
354 video::ITexture *def)
const
361 video::ITexture *texture = tsrc->
getTexture(val);
371 video::ITexture *texture = tsrc->
getTexture(val);
398 set(prop, other.
get(prop,
""));
413 bool parseArray(
const std::string &value, std::vector<std::string> &arr)
const
415 std::vector<std::string> strs =
split(value,
',');
417 if (strs.size() == 1) {
418 arr = {strs[0], strs[0], strs[0], strs[0]};
419 }
else if (strs.size() == 2) {
420 arr = {strs[0], strs[1], strs[0], strs[1]};
421 }
else if (strs.size() == 4) {
425 <<
" arguments): \"" << value <<
"\"" << std::endl;
431 bool parseRect(
const std::string &value, irr::core::rect<s32> *parsed_rect)
const
433 irr::core::rect<s32> rect;
434 std::vector<std::string> v_rect =
split(value,
',');
436 if (v_rect.size() == 1) {
437 s32 x =
stoi(v_rect[0]);
438 rect.UpperLeftCorner = irr::core::vector2di(x, x);
439 rect.LowerRightCorner = irr::core::vector2di(-x, -x);
440 }
else if (v_rect.size() == 2) {
441 s32 x =
stoi(v_rect[0]);
442 s32 y =
stoi(v_rect[1]);
443 rect.UpperLeftCorner = irr::core::vector2di(x, y);
444 rect.LowerRightCorner = irr::core::vector2di(-x, -y);
446 }
else if (v_rect.size() == 4) {
447 rect.UpperLeftCorner = irr::core::vector2di(
449 rect.LowerRightCorner = irr::core::vector2di(
452 warningstream <<
"Invalid rectangle string format: \"" << value
453 <<
"\"" << std::endl;
465 std::vector<std::string> v_vector =
split(value,
',');
467 if (v_vector.size() == 1) {
468 f32 x =
stof(v_vector[0]);
471 }
else if (v_vector.size() == 2) {
472 vec.X =
stof(v_vector[0]);
473 vec.Y =
stof(v_vector[1]);
475 warningstream <<
"Invalid 2d vector string format: \"" << value
476 <<
"\"" << std::endl;
unsigned int getFontSize(FontMode mode)
get font size for a specific mode
Definition: fontengine.cpp:163
irr::gui::IGUIFont * getFont(FontSpec spec)
Definition: fontengine.cpp:91
Definition: texturesource.h:34
virtual video::ITexture * getTexture(const std::string &name, u32 *id=nullptr)=0
Definition: StyleSpec.h:32
gui::IGUIFont * getFont() const
Definition: StyleSpec.h:312
static State getStateByName(const std::string &name)
Parses a name and returns the corresponding state enum.
Definition: StyleSpec.h:152
video::SColor getColor(Property prop) const
Definition: StyleSpec.h:207
std::array< bool, NUM_PROPERTIES > property_set
Definition: StyleSpec.h:77
bool getBool(Property prop, bool def) const
Definition: StyleSpec.h:376
State
Definition: StyleSpec.h:67
@ STATE_HOVERED
Definition: StyleSpec.h:70
@ STATE_INVALID
Definition: StyleSpec.h:73
@ STATE_FOCUSED
Definition: StyleSpec.h:69
@ STATE_DEFAULT
Definition: StyleSpec.h:68
@ STATE_PRESSED
Definition: StyleSpec.h:71
@ NUM_STATES
Definition: StyleSpec.h:72
bool parseVector2f(const std::string &value, v2f32 *parsed_vec) const
Definition: StyleSpec.h:462
State getState() const
Gets the state that this style is intended for.
Definition: StyleSpec.h:168
std::string get(Property prop, std::string def) const
Definition: StyleSpec.h:139
v2s32 getVector2i(Property prop) const
Definition: StyleSpec.h:302
Property
Definition: StyleSpec.h:35
@ FONT_SIZE
Definition: StyleSpec.h:54
@ BGCOLOR_PRESSED
Definition: StyleSpec.h:39
@ SOUND
Definition: StyleSpec.h:58
@ BORDERCOLORS
Definition: StyleSpec.h:56
@ BGIMG_PRESSED
Definition: StyleSpec.h:45
@ ALPHA
Definition: StyleSpec.h:50
@ BGCOLOR_HOVERED
Definition: StyleSpec.h:38
@ SPACING
Definition: StyleSpec.h:59
@ BGIMG_MIDDLE
Definition: StyleSpec.h:44
@ NOCLIP
Definition: StyleSpec.h:40
@ SIZE
Definition: StyleSpec.h:60
@ PADDING
Definition: StyleSpec.h:52
@ NUM_PROPERTIES
Definition: StyleSpec.h:61
@ COLORS
Definition: StyleSpec.h:55
@ FONT
Definition: StyleSpec.h:53
@ BORDER
Definition: StyleSpec.h:41
@ FGIMG_PRESSED
Definition: StyleSpec.h:49
@ NONE
Definition: StyleSpec.h:62
@ TEXTCOLOR
Definition: StyleSpec.h:36
@ BGCOLOR
Definition: StyleSpec.h:37
@ BGIMG
Definition: StyleSpec.h:42
@ BGIMG_HOVERED
Definition: StyleSpec.h:43
@ FGIMG
Definition: StyleSpec.h:46
@ BORDERWIDTHS
Definition: StyleSpec.h:57
@ FGIMG_MIDDLE
Definition: StyleSpec.h:48
@ CONTENT_OFFSET
Definition: StyleSpec.h:51
@ FGIMG_HOVERED
Definition: StyleSpec.h:47
v2s32 getVector2i(Property prop, v2s32 def) const
Definition: StyleSpec.h:289
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:183
std::array< video::SColor, 4 > getColorArray(Property prop, std::array< video::SColor, 4 > def) const
Definition: StyleSpec.h:217
static Property GetPropertyByName(const std::string &name)
Definition: StyleSpec.h:82
irr::core::rect< s32 > getRect(Property prop) const
Definition: StyleSpec.h:266
bool isNotDefault(Property prop) const
Definition: StyleSpec.h:386
StyleSpec operator|(const StyleSpec &other) const
Definition: StyleSpec.h:405
void addState(State state)
Set the given state on this style.
Definition: StyleSpec.h:174
bool parseArray(const std::string &value, std::vector< std::string > &arr) const
Definition: StyleSpec.h:413
video::ITexture * getTexture(Property prop, ISimpleTextureSource *tsrc) const
Definition: StyleSpec.h:366
irr::core::rect< s32 > getRect(Property prop, irr::core::rect< s32 > def) const
Definition: StyleSpec.h:253
video::SColor getColor(Property prop, video::SColor def) const
Definition: StyleSpec.h:196
State state_map
Definition: StyleSpec.h:79
StyleSpec & operator|=(const StyleSpec &other)
Definition: StyleSpec.h:393
void set(Property prop, const std::string &value)
Definition: StyleSpec.h:145
video::ITexture * getTexture(Property prop, ISimpleTextureSource *tsrc, video::ITexture *def) const
Definition: StyleSpec.h:353
bool parseRect(const std::string &value, irr::core::rect< s32 > *parsed_rect) const
Definition: StyleSpec.h:431
std::array< s32, 4 > getIntArray(Property prop, std::array< s32, 4 > def) const
Definition: StyleSpec.h:237
bool hasProperty(Property prop) const
Definition: StyleSpec.h:391
std::array< std::string, NUM_PROPERTIES > properties
Definition: StyleSpec.h:78
v2f32 getVector2f(Property prop, v2f32 def) const
Definition: StyleSpec.h:276
#define FATAL_ERROR_IF(expr, msg)
Definition: debug.h:51
FontEngine * g_fontengine
reference to access font engine, has to be initialized by main
Definition: fontengine.cpp:31
@ FM_Standard
Definition: fontengine.h:34
@ FM_Mono
Definition: fontengine.h:35
#define FONT_SIZE_UNSPECIFIED
Definition: fontengine.h:31
core::vector2d< f32 > v2f32
Definition: irr_v2d.h:30
core::vector2d< s32 > v2s32
Definition: irr_v2d.h:28
thread_local LogStream warningstream
bool parseColorString(const std::string &value, video::SColor &color, bool quiet, unsigned char default_alpha)
Definition: string.cpp:582
#define stoi
Definition: string.h:423
#define stof
Definition: string.h:424
std::vector< std::basic_string< T > > split(const std::basic_string< T > &s, T delim)
Definition: string.h:603
bool is_yes(std::string_view str)
Returns whether str should be regarded as (bool) true.
Definition: string.h:373
Definition: fontengine.h:41
bool italic
Definition: fontengine.h:56
bool bold
Definition: fontengine.h:55
unsigned int size
Definition: fontengine.h:53
FontMode mode
Definition: fontengine.h:54