forked from Haplo064/WheresWOLdo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WOLdo.cs
137 lines (115 loc) · 4.28 KB
/
WOLdo.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using Dalamud.Plugin;
using ImGuiNET;
using Dalamud.Configuration;
using Num = System.Numerics;
using Lumina.Excel.GeneratedSheets;
using System;
namespace WOLdo
{
public class WOLdo : IDalamudPlugin
{
public string Name => "WOLdo";
private DalamudPluginInterface pi;
public Config Configuration;
public string location = "";
public bool enabled = true;
public Lumina.Excel.ExcelSheet<TerritoryType> terr;
public float scale = 1f;
public ImColor col = new ImColor { Value = new Num.Vector4(1f, 1f, 1f, 1f) };
public bool no_move = false;
public bool config = false;
public void Initialize(DalamudPluginInterface pi)
{
this.pi = pi;
Configuration = pi.GetPluginConfig() as Config ?? new Config();
col = Configuration.Col;
no_move = Configuration.NoMove;
scale = Configuration.Scale;
enabled = Configuration.Enabled;
terr = pi.Data.GetExcelSheet<TerritoryType>();
this.pi.UiBuilder.OnBuildUi += DrawWindow;
this.pi.CommandManager.AddHandler("/woldo", new Dalamud.Game.Command.CommandInfo(Command)
{
HelpMessage = "Where's WOLdo config."
});
}
public void Dispose()
{
this.pi.UiBuilder.OnBuildUi -= DrawWindow;
this.pi.CommandManager.RemoveHandler("/woldo");
terr = null;
}
public void Command(string command, string arguments)
{
config = true;
}
private void DrawWindow()
{
ImGuiWindowFlags window_flags = 0;
window_flags |= ImGuiWindowFlags.NoTitleBar;
window_flags |= ImGuiWindowFlags.NoScrollbar;
window_flags |= ImGuiWindowFlags.NoScrollbar;
if (no_move)
{
window_flags |= ImGuiWindowFlags.NoMove;
window_flags |= ImGuiWindowFlags.NoMouseInputs;
window_flags |= ImGuiWindowFlags.NoNav;
}
window_flags |= ImGuiWindowFlags.AlwaysAutoResize;
window_flags |= ImGuiWindowFlags.NoBackground;
if (config)
{
ImGui.SetNextWindowSize(new Num.Vector2(200, 160), ImGuiCond.FirstUseEver);
ImGui.Begin("Where's WOLdo Config", ref config, ImGuiWindowFlags.AlwaysAutoResize);
ImGui.Checkbox("Enabled", ref enabled);
ImGui.ColorEdit4("Colour", ref col.Value, ImGuiColorEditFlags.NoInputs);
ImGui.InputFloat("Size", ref scale);
ImGui.Checkbox("Locked", ref no_move);
if (ImGui.Button("Save and Close Config"))
{
SaveConfig();
config = false;
}
ImGui.End();
}
location = "";
if (pi.ClientState.LocalPlayer != null)
{
location = "Uhoh";
try
{
location = terr.GetRow(pi.ClientState.TerritoryType).PlaceName.Value.Name;
}
catch (Exception e)
{
location = "Change zone to load";
}
}
if (enabled)
{
ImGui.PushStyleColor(ImGuiCol.Text, col.Value);
ImGui.Begin("WOLdo", ref enabled, window_flags);
ImGui.SetWindowFontScale(scale);
ImGui.Text(location);
ImGui.End();
ImGui.PopStyleColor();
}
}
public void SaveConfig()
{
Configuration.Enabled = enabled;
Configuration.Col = col;
Configuration.Scale = scale;
Configuration.NoMove = no_move;
this.pi.SavePluginConfig(Configuration);
}
}
public class Config : IPluginConfiguration
{
public int Version { get; set; } = 0;
public bool Enabled { get; set; } = true;
public ImColor Col { get; set; } = new ImColor { Value = new Num.Vector4(1f,1f,1f,1f) };
public float Scale { get; set; } = 1f;
public bool NoMove { get; set; } = false;
}
}