aboutsummaryrefslogtreecommitdiffstats
path: root/SamplePlugin/Windows/ConfigWindow.cs
diff options
context:
space:
mode:
authorPinapelz <donaldshan1@outlook.com>2024-08-26 00:57:05 -0700
committerGitHub <noreply@github.com>2024-08-26 00:57:05 -0700
commitb8c43fbe717d794284c6c4578c9c00ae8e26d711 (patch)
treedb3e449a3fd039b4935359eafb1f3ee9f61f5df7 /SamplePlugin/Windows/ConfigWindow.cs
Initial commit
Diffstat (limited to 'SamplePlugin/Windows/ConfigWindow.cs')
-rw-r--r--SamplePlugin/Windows/ConfigWindow.cs59
1 files changed, 59 insertions, 0 deletions
diff --git a/SamplePlugin/Windows/ConfigWindow.cs b/SamplePlugin/Windows/ConfigWindow.cs
new file mode 100644
index 0000000..0a0af98
--- /dev/null
+++ b/SamplePlugin/Windows/ConfigWindow.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Numerics;
+using Dalamud.Interface.Windowing;
+using ImGuiNET;
+
+namespace SamplePlugin.Windows;
+
+public class ConfigWindow : Window, IDisposable
+{
+ private Configuration Configuration;
+
+ // We give this window a constant ID using ###
+ // This allows for labels being dynamic, like "{FPS Counter}fps###XYZ counter window",
+ // and the window ID will always be "###XYZ counter window" for ImGui
+ public ConfigWindow(Plugin plugin) : base("A Wonderful Configuration Window###With a constant ID")
+ {
+ Flags = ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar |
+ ImGuiWindowFlags.NoScrollWithMouse;
+
+ Size = new Vector2(232, 90);
+ SizeCondition = ImGuiCond.Always;
+
+ Configuration = plugin.Configuration;
+ }
+
+ public void Dispose() { }
+
+ public override void PreDraw()
+ {
+ // Flags must be added or removed before Draw() is being called, or they won't apply
+ if (Configuration.IsConfigWindowMovable)
+ {
+ Flags &= ~ImGuiWindowFlags.NoMove;
+ }
+ else
+ {
+ Flags |= ImGuiWindowFlags.NoMove;
+ }
+ }
+
+ public override void Draw()
+ {
+ // can't ref a property, so use a local copy
+ var configValue = Configuration.SomePropertyToBeSavedAndWithADefault;
+ if (ImGui.Checkbox("Random Config Bool", ref configValue))
+ {
+ Configuration.SomePropertyToBeSavedAndWithADefault = configValue;
+ // can save immediately on change, if you don't want to provide a "Save and Close" button
+ Configuration.Save();
+ }
+
+ var movable = Configuration.IsConfigWindowMovable;
+ if (ImGui.Checkbox("Movable Config Window", ref movable))
+ {
+ Configuration.IsConfigWindowMovable = movable;
+ Configuration.Save();
+ }
+ }
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage