MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / UpdateGUITheme

Method UpdateGUITheme

LibLemon/src/gui/window.cpp:42–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40 }
41
42 void Window::UpdateGUITheme(const std::string& path){
43 JSONParser jP = JSONParser(path.c_str());
44 auto json = jP.Parse();
45
46 if(json.IsObject()){
47 JSONValue obj;
48 if(json.object->find("gui") != json.object->end() && (obj = json.object->at("gui")).IsObject()) {
49 std::map<Lemon::JSONKey, Lemon::JSONValue>& values = *obj.object;
50
51 if(auto it = values.find("background"); it != values.end()){
52 auto& v = it->second;
53
54 if(v.IsArray() && v.array->size() >= 3){
55 Lemon::colours[Lemon::Colour::Background] = (RGBAColour){v.array->at(0).AsUnsignedNumber<uint8_t>(), v.array->at(1).AsUnsignedNumber<uint8_t>(), v.array->at(2).AsUnsignedNumber<uint8_t>(), 255};
56 } else {} // TODO: Do something when invalid valaue
57 }
58
59 if(auto it = values.find("content"); it != values.end()){
60 auto& v = it->second;
61
62 if(v.IsArray() && v.array->size() >= 3){
63 Lemon::colours[Lemon::Colour::ContentBackground] = (RGBAColour){v.array->at(0).AsUnsignedNumber<uint8_t>(), v.array->at(1).AsUnsignedNumber<uint8_t>(), v.array->at(2).AsUnsignedNumber<uint8_t>(), 255};
64 } else {} // TODO: Do something when invalid valaue
65 }
66
67 if(auto it = values.find("text"); it != values.end()){
68 auto& v = it->second;
69
70 if(v.IsArray() && v.array->size() >= 3){
71 Lemon::colours[Lemon::Colour::Text] = (RGBAColour){v.array->at(0).AsUnsignedNumber<uint8_t>(), v.array->at(1).AsUnsignedNumber<uint8_t>(), v.array->at(2).AsUnsignedNumber<uint8_t>(), 255};
72 } else {} // TODO: Do something when invalid valaue
73 }
74
75 if(auto it = values.find("textAlternate"); it != values.end()){
76 auto& v = it->second;
77
78 if(v.IsArray() && v.array->size() >= 3){
79 Lemon::colours[Lemon::Colour::TextAlternate] = (RGBAColour){v.array->at(0).AsUnsignedNumber<uint8_t>(), v.array->at(1).AsUnsignedNumber<uint8_t>(), v.array->at(2).AsUnsignedNumber<uint8_t>(), 255};
80 } else {} // TODO: Do something when invalid valaue
81 }
82
83 if(auto it = values.find("highlight"); it != values.end()){
84 auto& v = it->second;
85
86 if(v.IsArray() && v.array->size() >= 3){
87 Lemon::colours[Lemon::Colour::Foreground] = (RGBAColour){v.array->at(0).AsUnsignedNumber<uint8_t>(), v.array->at(1).AsUnsignedNumber<uint8_t>(), v.array->at(2).AsUnsignedNumber<uint8_t>(), 255};
88 } else {} // TODO: Do something when invalid valaue
89 }
90
91 if(auto it = values.find("contentShadow"); it != values.end()){
92 auto& v = it->second;
93
94 if(v.IsArray() && v.array->size() >= 3){
95 Lemon::colours[Lemon::Colour::ContentShadow] = (RGBAColour){v.array->at(0).AsUnsignedNumber<uint8_t>(), v.array->at(1).AsUnsignedNumber<uint8_t>(), v.array->at(2).AsUnsignedNumber<uint8_t>(), 255};
96 } else {} // TODO: Do something when invalid valaue
97 }
98 }
99 } else {

Callers

nothing calls this directly

Calls 6

JSONParserClass · 0.85
IsObjectMethod · 0.80
IsArrayMethod · 0.80
sizeMethod · 0.80
ParseMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected