aboutsummaryrefslogtreecommitdiffstats
path: root/SamplePlugin/Windows
diff options
context:
space:
mode:
authorPinapelz <donaldshan1@outlook.com>2024-09-14 13:48:51 -0700
committerGitHub <noreply@github.com>2024-09-14 13:48:51 -0700
commit610015a68d7ad9580c7ac9dc427ccace650a9b9e (patch)
treedb3e449a3fd039b4935359eafb1f3ee9f61f5df7 /SamplePlugin/Windows
Initial commit
Diffstat (limited to 'SamplePlugin/Windows')
-rw-r--r--SamplePlugin/Windows/ConfigWindow.cs59
-rw-r--r--SamplePlugin/Windows/MainWindow.cs58
2 files changed, 117 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();
+ }
+ }
+}
diff --git a/SamplePlugin/Windows/MainWindow.cs b/SamplePlugin/Windows/MainWindow.cs
new file mode 100644
index 0000000..9ac6a4d
--- /dev/null
+++ b/SamplePlugin/Windows/MainWindow.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Numerics;
+using Dalamud.Interface.Internal;
+using Dalamud.Interface.Utility;
+using Dalamud.Interface.Windowing;
+using Dalamud.Plugin.Services;
+using ImGuiNET;
+
+namespace SamplePlugin.Windows;
+
+public class MainWindow : Window, IDisposable
+{
+ private string GoatImagePath;
+ private Plugin Plugin;
+
+ // We give this window a hidden ID using ##
+ // So that the user will see "My Amazing Window" as window title,
+ // but for ImGui the ID is "My Amazing Window##With a hidden ID"
+ public MainWindow(Plugin plugin, string goatImagePath)
+ : base("My Amazing Window##With a hidden ID", ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)
+ {
+ SizeConstraints = new WindowSizeConstraints
+ {
+ MinimumSize = new Vector2(375, 330),
+ MaximumSize = new Vector2(float.MaxValue, float.MaxValue)
+ };
+
+ GoatImagePath = goatImagePath;
+ Plugin = plugin;
+ }
+
+ public void Dispose() { }
+
+ public override void Draw()
+ {
+ ImGui.Text($"The random config bool is {Plugin.Configuration.SomePropertyToBeSavedAndWithADefault}");
+
+ if (ImGui.Button("Show Settings"))
+ {
+ Plugin.ToggleConfigUI();
+ }
+
+ ImGui.Spacing();
+
+ ImGui.Text("Have a goat:");
+ var goatImage = Plugin.TextureProvider.GetFromFile(GoatImagePath).GetWrapOrDefault();
+ if (goatImage != null)
+ {
+ ImGuiHelpers.ScaledIndent(55f);
+ ImGui.Image(goatImage.ImGuiHandle, new Vector2(goatImage.Width, goatImage.Height));
+ ImGuiHelpers.ScaledIndent(-55f);
+ }
+ else
+ {
+ ImGui.Text("Image not found.");
+ }
+ }
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage