blob: 0a0af987e3ad8a945ae905f0e6073ce4b01cc180 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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();
}
}
}
|