CommandReference/SamplePlugin/Windows/ConfigWindow.cs

41 lines
1.2 KiB
C#

using System;
using System.Numerics;
using Dalamud.Interface.Windowing;
using ImGuiNET;
namespace SamplePlugin.Windows;
public class ConfigWindow : Window, IDisposable
{
private Configuration Configuration;
public ConfigWindow(Plugin plugin)
: base(
"A Wonderful Configuration Window",
ImGuiWindowFlags.NoResize
| ImGuiWindowFlags.NoCollapse
| ImGuiWindowFlags.NoScrollbar
| ImGuiWindowFlags.NoScrollWithMouse
)
{
this.Size = new Vector2(232, 75);
this.SizeCondition = ImGuiCond.Always;
this.Configuration = plugin.configuration;
}
public void Dispose() { }
public override void Draw()
{
// can't ref a property, so use a local copy
var configValue = this.Configuration.SomePropertyToBeSavedAndWithADefault;
if (ImGui.Checkbox("Random Config Bool", ref configValue))
{
this.Configuration.SomePropertyToBeSavedAndWithADefault = configValue;
// can save immediately on change, if you don't want to provide a "Save and Close" button
this.Configuration.Save();
}
}
}