-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathPluginUI.cs
62 lines (51 loc) · 2.23 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
using ImGuiNET;
using System;
using Dalamud.Game.Chat;
namespace OopsAllLalafells {
public class PluginUI {
private readonly Plugin plugin;
public PluginUI(Plugin plugin) {
this.plugin = plugin;
}
public void Draw() {
if (!this.plugin.SettingsVisible) {
return;
}
bool settingsVisible = this.plugin.SettingsVisible;
if (ImGui.Begin("Oops, All Lalafells!", ref settingsVisible, ImGuiWindowFlags.AlwaysAutoResize)) {
bool uiSelfChange = this.plugin.config.SelfChange;
Race uiSelfRace= this.plugin.config.SelfRace;
DrawRaceOptions("Self", ref uiSelfChange, ref uiSelfRace);
this.plugin.ToggleSelfRace(uiSelfChange);
this.plugin.UpdateSelfRace(uiSelfRace);
ImGui.Spacing();
bool uiOtherChange = this.plugin.config.OtherChange;
Race uiOtherRace = this.plugin.config.OtherRace;
DrawRaceOptions("Others", ref uiOtherChange, ref uiOtherRace);
this.plugin.ToggleOtherRace(uiOtherChange);
this.plugin.UpdateOtherRace(uiOtherRace);
ImGui.End();
}
this.plugin.SettingsVisible = settingsVisible;
this.plugin.SaveConfig();
}
private static void DrawRaceOptions(string target, ref bool doChange, ref Race selectedRace) {
ImGui.Checkbox("Change " + target, ref doChange);
if (doChange) {
if (ImGui.BeginCombo(target + " Race", selectedRace.GetAttribute<Display>().Value)) {
foreach (Race race in Enum.GetValues(typeof(Race))) {
ImGui.PushID((byte) race);
if (ImGui.Selectable(race.GetAttribute<Display>().Value, race == selectedRace)) {
selectedRace = race;
}
if (race == selectedRace) {
ImGui.SetItemDefaultFocus();
}
ImGui.PopID();
}
ImGui.EndCombo();
}
}
}
}
}