3 Copyright (C) 2019 rubenwardy
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "irrlichttypes_extrabloated.h"
36 std::unordered_map<Property, std::string> properties;
39 static Property GetPropertyByName(const std::string &name) {
40 if (name == "textcolor") {
42 } else if (name == "bgcolor") {
49 std::string get(Property prop, std::string def) const {
50 auto it = properties.find(prop);
51 if (it == properties.end()) {
58 void set(Property prop, std::string value) {
59 properties[prop] = std::move(value);
62 video::SColor getColor(Property prop, video::SColor def) const {
63 auto it = properties.find(prop);
64 if (it == properties.end()) {
68 parseColorString(it->second, def, false, 0xFF);
72 video::SColor getColor(Property prop) const {
73 auto it = properties.find(prop);
74 FATAL_ERROR_IF(it == properties.end(), "Unexpected missing property");
77 parseColorString(it->second, color, false, 0xFF);
81 bool hasProperty(Property prop) const {
82 return properties.find(prop) != properties.end();
85 StyleSpec &operator|=(const StyleSpec &other) {
86 for (size_t i = 1; i < NUM_PROPERTIES; i++) {
87 auto prop = (Property)i;
88 if (other.hasProperty(prop)) {
89 properties[prop] = other.get(prop, "");
96 StyleSpec operator|(const StyleSpec &other) const {
97 StyleSpec newspec = *this;