MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / load_theme

Method load_theme

src/GUIHolder.cpp:82–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82bool GUIHolder::load_theme(const std::filesystem::path& configPath, const std::string& themeName) {
83 std::filesystem::path themeDir = configPath / "themes";
84 bool successfullyLoaded = false;
85 if(std::filesystem::exists(themeDir) && std::filesystem::is_directory(themeDir)) {
86 std::ifstream f(themeDir / (themeName + ".json"));
87 if(f.is_open()) {
88 using json = nlohmann::json;
89 try {
90 json j;
91 f >> j;
92 auto theme(std::make_shared<GUIStuff::Theme>());
93 j.get_to(*theme);
94 gui.io.theme = theme;
95 successfullyLoaded = true;
96 } catch(...) {}
97 f.close();
98 }
99 }
100 if(!successfullyLoaded)
101 load_default_theme();
102 return successfullyLoaded;
103}
104
105void GUIHolder::update() {
106 gui.io.deltaTime = main.deltaTime;

Callers 3

load_configMethod · 0.80
reload_theme_listMethod · 0.80

Calls 2

get_toMethod · 0.80
closeMethod · 0.65

Tested by

no test coverage detected