| 80 | } |
| 81 | |
| 82 | bool 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 | |
| 105 | void GUIHolder::update() { |
| 106 | gui.io.deltaTime = main.deltaTime; |
no test coverage detected