Lots of SzGui work

This commit is contained in:
2026-02-25 00:08:27 -06:00
parent e6749c51c4
commit dad80e30da
20 changed files with 968 additions and 22 deletions

View File

@@ -0,0 +1,76 @@
using System.Numerics;
using ImGuiNET;
namespace SzGui.Windows;
public class SettingsWindow : SzGuiWindowBase
{
private bool _settingsDirty = false;
public SettingsWindow() => WindowName = "App Settings";
protected override void RenderContent()
{
ImGui.SeparatorText("Application Settings");
foreach (var setting in ApplicationSettings.GetAllSettings().ToList())
{
string key = setting.Key;
object val = setting.Value;
bool changed = false;
if (val is bool boolVal)
{
if (ImGui.Checkbox(key, ref boolVal))
{
ApplicationSettings.SetSettingValue(key, boolVal);
changed = true;
}
}
else if (val is float floatVal || val is double)
{
float f = Convert.ToSingle(val);
if (ImGui.DragFloat(key, ref f, 0.01f))
{
ApplicationSettings.SetSettingValue(key, f);
changed = true;
}
}
else if (val is string strVal)
{
if (ImGui.InputText(key, ref strVal, 256))
{
ApplicationSettings.SetSettingValue(key, strVal);
changed = true;
}
}
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip($"Internal Key: {key}");
}
if (changed) _settingsDirty = true;
}
ImGui.Separator();
if (ImGui.Button("Save Changes"))
{
ApplicationSettings.SaveSettings();
_settingsDirty = false;
}
ImGui.SameLine();
if (ImGui.Button("Reload from Disk"))
{
ApplicationSettings.LoadSettings();
}
if (_settingsDirty)
{
ImGui.TextColored(new Vector4(1, 0.5f, 0, 1), "You have unsaved changes!");
}
}
}