@@ -34,11 +34,12 @@ void SettingsWindow::Draw()
34
34
35
35
if (ImGui::BeginTabItem (" projectM" ))
36
36
{
37
- if (ImGui::BeginTable (" projectM" , 3 , tableFlags))
37
+ if (ImGui::BeginTable (" projectM" , 4 , tableFlags))
38
38
{
39
39
ImGui::TableSetupColumn (" ##desc" , ImGuiTableColumnFlags_WidthFixed, .0f );
40
40
ImGui::TableSetupColumn (" ##setting" , ImGuiTableColumnFlags_WidthStretch, .0f );
41
41
ImGui::TableSetupColumn (" ##reset" , ImGuiTableColumnFlags_WidthFixed, 100 .0f );
42
+ ImGui::TableSetupColumn (" ##override" , ImGuiTableColumnFlags_WidthFixed, .0f );
42
43
43
44
ImGui::TableNextRow ();
44
45
LabelWithTooltip (" Preset Path" , " Path to search for preset files if no playlist is loaded." );
@@ -146,20 +147,13 @@ void SettingsWindow::PathSetting(const std::string& property)
146
147
{
147
148
ImGui::TableSetColumnIndex (1 );
148
149
149
- auto path = Poco::Util::Application::instance (). config (). getString (property, " " );
150
+ auto path = _gui. UserConfiguration ()-> getString (property, " " );
150
151
char pathBuffer[2048 ]{};
151
152
strncpy (pathBuffer, path.c_str (), std::min<size_t >(2047 , path.size ()));
152
153
153
- bool isOverridden{false };
154
- if (_gui.CommandLineConfiguration ()->has (property))
155
- {
156
- isOverridden = true ;
157
- ImGui::BeginDisabled ();
158
- }
159
-
160
154
if (ImGui::InputText (std::string (" ##path_" + property).c_str (), &pathBuffer[0 ], IM_ARRAYSIZE (pathBuffer), ImGuiInputTextFlags_EnterReturnsTrue))
161
155
{
162
- _gui.UIConfiguration ()->setString (property, std::string (pathBuffer));
156
+ _gui.UserConfiguration ()->setString (property, std::string (pathBuffer));
163
157
}
164
158
165
159
ImGui::SameLine ();
@@ -170,140 +164,98 @@ void SettingsWindow::PathSetting(const std::string& property)
170
164
}
171
165
ImGui::PopID ();
172
166
173
- if (isOverridden)
167
+ ResetButton (property);
168
+
169
+ if (_gui.CommandLineConfiguration ()->has (property))
174
170
{
175
- ImGui::EndDisabled ();
176
171
OverriddenSettingMarker ();
177
172
}
178
- else
179
- {
180
- ResetButton (property);
181
- }
182
173
}
183
174
184
175
185
176
void SettingsWindow::BooleanSetting (const std::string& property, bool defaultValue)
186
177
{
187
178
ImGui::TableSetColumnIndex (1 );
188
179
189
- auto value = Poco::Util::Application::instance ().config ().getBool (property, defaultValue);
190
-
191
- bool isOverridden{false };
192
- if (_gui.CommandLineConfiguration ()->has (property))
193
- {
194
- isOverridden = true ;
195
- ImGui::BeginDisabled ();
196
- }
180
+ auto value = _gui.UserConfiguration ()->getBool (property, defaultValue);
197
181
198
182
if (ImGui::Checkbox (std::string (" ##boolean_" + property).c_str (), &value))
199
183
{
200
- _gui.UIConfiguration ()->setBool (property, value);
184
+ _gui.UserConfiguration ()->setBool (property, value);
201
185
}
202
186
203
- if (isOverridden)
187
+ ResetButton (property);
188
+
189
+ if (_gui.CommandLineConfiguration ()->has (property))
204
190
{
205
- ImGui::EndDisabled ();
206
191
OverriddenSettingMarker ();
207
192
}
208
- else
209
- {
210
- ResetButton (property);
211
- }
212
193
}
213
194
214
195
void SettingsWindow::IntegerSetting (const std::string& property, int defaultValue, int min, int max)
215
196
{
216
197
ImGui::TableSetColumnIndex (1 );
217
198
218
- auto value = Poco::Util::Application::instance ().config ().getInt (property, defaultValue);
219
-
220
- bool isOverridden{false };
221
- if (_gui.CommandLineConfiguration ()->has (property))
222
- {
223
- isOverridden = true ;
224
- ImGui::BeginDisabled ();
225
- }
199
+ auto value = _gui.UserConfiguration ()->getInt (property, defaultValue);
226
200
227
201
if (ImGui::SliderInt (std::string (" ##integer_" + property).c_str (), &value, min, max))
228
202
{
229
- _gui.UIConfiguration ()->setInt (property, value);
203
+ _gui.UserConfiguration ()->setInt (property, value);
230
204
}
231
205
232
- if (isOverridden)
206
+ ResetButton (property);
207
+
208
+ if (_gui.CommandLineConfiguration ()->has (property))
233
209
{
234
- ImGui::EndDisabled ();
235
210
OverriddenSettingMarker ();
236
211
}
237
- else
238
- {
239
- ResetButton (property);
240
- }
241
212
}
242
213
243
214
void SettingsWindow::IntegerSettingVec (const std::string& property1, const std::string& property2, int defaultValue1, int defaultValue2, int min, int max)
244
215
{
245
216
ImGui::TableSetColumnIndex (1 );
246
217
247
218
int values[2 ] = {
248
- Poco::Util::Application::instance ().config ().getInt (property1, defaultValue1),
249
- Poco::Util::Application::instance ().config ().getInt (property2, defaultValue2)};
250
-
251
- bool isOverridden{false };
252
- if (_gui.CommandLineConfiguration ()->has (property1) || _gui.CommandLineConfiguration ()->has (property2))
253
- {
254
- isOverridden = true ;
255
- ImGui::BeginDisabled ();
256
- }
219
+ _gui.UserConfiguration ()->getInt (property1, defaultValue1),
220
+ _gui.UserConfiguration ()->getInt (property2, defaultValue2)};
257
221
258
222
if (ImGui::SliderInt2 (std::string (" ##integer_" + property1 + property2).c_str (), values, min, max))
259
223
{
260
- _gui.UIConfiguration ()->setInt (property1, values[0 ]);
261
- _gui.UIConfiguration ()->setInt (property2, values[1 ]);
224
+ _gui.UserConfiguration ()->setInt (property1, values[0 ]);
225
+ _gui.UserConfiguration ()->setInt (property2, values[1 ]);
262
226
}
263
227
264
- if (isOverridden)
228
+ ResetButton (property1, property2);
229
+
230
+ if (_gui.CommandLineConfiguration ()->has (property1) || _gui.CommandLineConfiguration ()->has (property2))
265
231
{
266
- ImGui::EndDisabled ();
267
232
OverriddenSettingMarker ();
268
233
}
269
- else
270
- {
271
- ResetButton (property1, property2);
272
- }
234
+
273
235
}
274
236
275
237
void SettingsWindow::DoubleSetting (const std::string& property, double defaultValue, double min, double max)
276
238
{
277
239
ImGui::TableSetColumnIndex (1 );
278
240
279
- auto value = static_cast <float >(Poco::Util::Application::instance ().config ().getDouble (property, defaultValue));
280
-
281
- bool isOverridden{false };
282
- if (_gui.CommandLineConfiguration ()->has (property))
283
- {
284
- isOverridden = true ;
285
- ImGui::BeginDisabled ();
286
- }
241
+ auto value = static_cast <float >(_gui.UserConfiguration ()->getDouble (property, defaultValue));
287
242
288
243
if (ImGui::SliderFloat (std::string (" ##double_" + property).c_str (), &value, static_cast <float >(min), static_cast <float >(max)))
289
244
{
290
- _gui.UIConfiguration ()->setDouble (property, value);
245
+ _gui.UserConfiguration ()->setDouble (property, value);
291
246
}
292
247
293
- if (isOverridden)
248
+ ResetButton (property);
249
+
250
+ if (_gui.CommandLineConfiguration ()->has (property))
294
251
{
295
- ImGui::EndDisabled ();
296
252
OverriddenSettingMarker ();
297
253
}
298
- else
299
- {
300
- ResetButton (property);
301
- }
302
254
}
303
255
304
256
void SettingsWindow::ResetButton (const std::string& property1, const std::string& property2)
305
257
{
306
- if (!_gui.UIConfiguration ()->has (property1) && (property2.empty () || !_gui.UIConfiguration ()->has (property2)))
258
+ if (!_gui.UserConfiguration ()->has (property1) && (property2.empty () || !_gui.UserConfiguration ()->has (property2)))
307
259
{
308
260
return ;
309
261
}
@@ -313,25 +265,25 @@ void SettingsWindow::ResetButton(const std::string& property1, const std::string
313
265
ImGui::PushID (std::string (property1 + property2 + " _ResetButton" ).c_str ());
314
266
if (ImGui::Button (" Reset" ))
315
267
{
316
- _gui.UIConfiguration ()->remove (property1);
268
+ _gui.UserConfiguration ()->remove (property1);
317
269
if (!property2.empty ())
318
270
{
319
- _gui.UIConfiguration ()->remove (property2);
271
+ _gui.UserConfiguration ()->remove (property2);
320
272
}
321
273
}
322
274
ImGui::PopID ();
323
275
}
324
276
325
277
void SettingsWindow::OverriddenSettingMarker ()
326
278
{
327
- ImGui::TableSetColumnIndex (2 );
279
+ ImGui::TableSetColumnIndex (3 );
328
280
329
- ImGui::TextColored (ImVec4 (1 , 0 , 0 , 1 ), " [Locked ]" );
281
+ ImGui::TextColored (ImVec4 (1 , 0 , 0 , 1 ), " [! ]" );
330
282
if (ImGui::IsItemHovered ())
331
283
{
332
284
ImGui::BeginTooltip ();
333
285
ImGui::TextUnformatted (" Value set via command line argument." );
334
- ImGui::TextUnformatted (" Can only be changed if not overridden." );
286
+ ImGui::TextUnformatted (" It will only be used if not overridden." );
335
287
ImGui::EndTooltip ();
336
288
}
337
289
}
0 commit comments