WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
AppSettings.cpp
Go to the documentation of this file.
1#ifdef _WIN32
2#include <windows.h>
3#endif
4
5#include "AppSettings.h"
6#include "ThemeManager.h"
7#include "IniFile.h"
8#include "Logger.h"
9#include "imgui.h"
10
12{
13 const core::IniFile config(configPath);
14
15 gamePath = config.getString("Settings/Path");
16 enableDbCache = config.getBool("Settings/EnableDbCache", false);
17 showConsole = config.getBool("Settings/ShowConsole", false);
18 drawGrid = config.getBool("Viewport/DrawGrid", true);
19 bgColor.x = static_cast<float>(config.getDouble("Viewport/BgR", 71.0 / 255.0));
20 bgColor.y = static_cast<float>(config.getDouble("Viewport/BgG", 95.0 / 255.0));
21 bgColor.z = static_cast<float>(config.getDouble("Viewport/BgB", 121.0 / 255.0));
22
23 ThemeManager::currentThemeRef() = config.getInt("Settings/Theme",
24 static_cast<int>(ThemeManager::UE5));
28
29 currentFont = config.getInt("Settings/Font", 0);
30 fontSize = static_cast<float>(config.getDouble("Settings/FontSize", 18.0));
31 if (fontSize < 10.0f) fontSize = 10.0f;
32 if (fontSize > 40.0f) fontSize = 40.0f;
33
34 LOG_INFO << "Settings loaded. Game path:" << gamePath;
35}
36
38{
40 config.setValue("Settings/Path", gamePath);
41 config.setValue("Settings/EnableDbCache", enableDbCache);
42 config.setValue("Settings/ShowConsole", showConsole);
43 config.setValue("Viewport/DrawGrid", drawGrid);
44 config.setValue("Viewport/BgR", static_cast<double>(bgColor.x));
45 config.setValue("Viewport/BgG", static_cast<double>(bgColor.y));
46 config.setValue("Viewport/BgB", static_cast<double>(bgColor.z));
47 config.setValue("Settings/Theme", ThemeManager::currentThemeRef());
48 config.setValue("Settings/Font", currentFont);
49 config.setValue("Settings/FontSize", static_cast<double>(fontSize));
50 config.sync();
51
52 ImGui::SaveIniSettingsToDisk(imguiIniPath);
53 LOG_INFO << "Settings and UI layout saved.";
54}
#define LOG_INFO
Definition Logger.h:10
Simple INI file reader/writer with section/key support.
Definition IniFile.h:15
bool getBool(const std::string &key, bool defaultValue=false) const
Definition IniFile.h:58
int getInt(const std::string &key, int defaultValue=0) const
Definition IniFile.h:40
void setValue(const std::string &key, int value)
Definition IniFile.h:83
std::string getString(const std::string &key, const std::string &defaultValue="") const
Definition IniFile.h:27
double getDouble(const std::string &key, double defaultValue=0.0) const
Definition IniFile.h:49
void sync() const
Definition IniFile.h:119
constexpr int themeCount() noexcept
Number of available themes.
int & currentThemeRef() noexcept
Writable reference so ImGui::Combo can bind directly.
static constexpr const char * configPath
Definition AppSettings.h:25
bool enableDbCache
Definition AppSettings.h:13
std::string gamePath
Definition AppSettings.h:10
glm::vec3 bgColor
Definition AppSettings.h:18
bool showConsole
Definition AppSettings.h:14
float fontSize
Definition AppSettings.h:22
static constexpr const char * imguiIniPath
Definition AppSettings.h:26
void save() const
Persist to Config.ini and save the ImGui layout to disk.
void load()
Load from Config.ini (also restores the current ThemeManager theme).