forked from markjsosnowski/BlueMageHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PluginUI.cs
84 lines (75 loc) · 2.86 KB
/
PluginUI.cs
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using ImGuiNET;
using System;
using System.Diagnostics;
using System.Numerics;
namespace BlueMageHelper
{
// It is good to have this be disposable in general, in case you ever need it
// to do any cleanup
class PluginUI : IDisposable
{
private Configuration configuration;
// this extra bool exists for ImGui, since you can't ref a property
private bool visible = false;
public bool Visible
{
get { return this.visible; }
set { this.visible = value; }
}
private bool settingsVisible = false;
public bool SettingsVisible
{
get { return this.settingsVisible; }
set { this.settingsVisible = value; }
}
// passing in the image here just for simplicity
public PluginUI(Configuration configuration)
{
this.configuration = configuration;
}
public void Dispose()
{
}
public void Draw()
{
// This is our only draw handler attached to UIBuilder, so it needs to be
// able to draw any windows we might have open.
// Each method checks its own visibility/state to ensure it only draws when
// it actually makes sense.
// There are other ways to do this, but it is generally best to keep the number of
// draw delegates as low as possible.
DrawSettingsWindow();
}
public void DrawSettingsWindow()
{
if (!SettingsVisible)
{
return;
}
ImGui.SetNextWindowSize(new Vector2(290, 90), ImGuiCond.Always);
if (ImGui.Begin("Blue Mage Helper Configuration", ref this.settingsVisible,
ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse))
{
// can't ref a property, so use a local copy
var configValue = this.configuration.show_hint_even_if_unlocked;
if (ImGui.Checkbox("Show hint even if a spell is already unlocked.", ref configValue))
{
this.configuration.show_hint_even_if_unlocked = configValue;
// can save immediately on change, if you don't want to provide a "Save and Close" button
this.configuration.Save();
}
ImGui.Text("Did this plugin help?");
ImGui.SameLine();
if (ImGui.Button("Consider Donating"))
{
System.Diagnostics.Process.Start(new ProcessStartInfo
{
FileName = "https://ko-fi.com/isolraine",
UseShellExecute = true
});
}
}
ImGui.End();
}
}
}