Initial commit
This commit is contained in:
14 files changed
+1260
No files matched your search
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface.Windowing;
|
||||
|
||||
namespace SamplePlugin.Windows;
|
||||
|
||||
public class ConfigWindow : Window, IDisposable
|
||||
{
|
||||
private readonly Configuration configuration;
|
||||
|
||||
// We give this window a constant ID using ###.
|
||||
// This allows for labels to be 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user