DP-VoidBox/VoidBox/Windows/ConfigWindow.cs

59 lines
1.1 KiB
C#
Raw Normal View History

2024-03-02 01:31:18 +01:00
using Dalamud.Interface.Windowing;
using ImGuiNET;
using System;
using System.Numerics;
namespace VoidBox.Windows;
public class ConfigWindow : Window, IDisposable
{
private bool _configIsEnabled;
public ConfigWindow() : base(
"VoidBox",
ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar |
ImGuiWindowFlags.NoScrollWithMouse)
{
Size = new Vector2(430, 184);
SizeCondition = ImGuiCond.Always;
UpdateFromConfig();
}
public void Dispose() {
}
public void UpdateFromConfig()
{
var config = Service.Config;
_configIsEnabled = config.IsEnabled;
}
public void UpdateToConfig()
{
var config = Service.Config;
config.IsEnabled = _configIsEnabled;
config.Save();
}
public override void Draw()
{
var save = false;
ImGui.Checkbox("Enabled", ref _configIsEnabled);
if (ImGui.Button("Save and apply"))
{
save = true;
}
if (save)
{
UpdateToConfig();
}
}
}