26 ImGui::StyleColorsDark();
29 ImGui::StyleColorsLight();
32 ImGui::StyleColorsClassic();
39 if (ImGui::Combo(label, &style_idx,
"Dark\0Light\0Classic\0"))
42 ini_cfg[
"Appearance"][
"Style"] = std::to_string(style_idx);
57 bool ShowFontSelector(
const char *label,
int &selectedFont, mINI::INIStructure &ini_cfg)
59 ImGuiIO &io = ImGui::GetIO();
60 ImFont *font_current = ImGui::GetFont();
61 if (ImGui::BeginCombo(label,
font_names[selectedFont]))
63 for (
int n = 0; n < io.Fonts->Fonts.Size; n++)
65 ImFont *font = io.Fonts->Fonts[n];
66 ImGui::PushID((
void *)font);
67 if (ImGui::Selectable(
font_names[n], font == font_current))
69 io.FontDefault = font;
75 ini_cfg[
"Appearance"][
"Font"] = std::to_string(selectedFont);
83 ImGuiIO &io = ImGui::GetIO();
84 ImFont *font = io.Fonts->Fonts[font_idx];
85 io.FontDefault = font;
90 std::vector<T>
split2T(std::string &s,
char delimiter)
92 std::vector<T> values;
94 std::istringstream tokenStream(s);
95 while (std::getline(tokenStream, token, delimiter))
97 values.push_back((T)std::stod(token));
104 std::string s = std::to_string(v.x) +
"," + std::to_string(v.y) +
"," + std::to_string(v.z) +
"," + std::to_string(v.w);
110 std::string s = std::to_string(v.x) +
"," + std::to_string(v.y);
116 void check_ini_setting(mINI::INIStructure &ini_cfg, std::string section, std::string key,
char *value)
118 if (ini_cfg.has(section))
120 if (ini_cfg[section].has(key))
122 value = &ini_cfg[section][key][0];
124 ini_cfg[section][key] = std::string(value);
128 void check_ini_setting(mINI::INIStructure &ini_cfg, std::string section, std::string key, std::string value)
130 if (ini_cfg.has(section))
132 if (ini_cfg[section].has(key))
134 value = ini_cfg[section][key];
136 ini_cfg[section][key] = value;
141 template <
typename T>
142 void check_ini_setting(mINI::INIStructure &ini_cfg, std::string section, std::string key, T &value)
144 if (ini_cfg.has(section))
146 if (ini_cfg[section].has(key))
148 value = (T)stod(ini_cfg[section][key]);
150 ini_cfg[section][key] = std::to_string(value);
155 void check_ini_setting(mINI::INIStructure &ini_cfg, std::string section, std::string key, ImVec4 &value)
157 if (ini_cfg.has(section))
159 if (ini_cfg[section].has(key))
161 std::vector<float> val_vec = split2T<float>(ini_cfg[section][key],
',');
162 value = ImVec4(val_vec[0], val_vec[1], val_vec[2], val_vec[3]);
169 void check_ini_setting(mINI::INIStructure &ini_cfg, std::string section, std::string key, ImVec2 &value)
171 if (ini_cfg.has(section))
173 if (ini_cfg[section].has(key))
175 std::vector<float> val_vec = split2T<float>(ini_cfg[section][key],
',');
176 value = ImVec2(val_vec[0], val_vec[1]);
std::string ImVec2string(const ImVec4 &v)
void check_ini_setting(mINI::INIStructure &ini_cfg, std::string section, std::string key, char *value)
bool ShowFontSelector(const char *label, int &selectedFont, mINI::INIStructure &ini_cfg)
bool ShowStyleSelector(const char *label, int &style_idx, mINI::INIStructure &ini_cfg)
void set_font(int font_idx)
std::vector< T > split2T(std::string &s, char delimiter)
void set_style(int style_idx)
const char * font_names[6]