forked from Caraxi/RemindMe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRemindMeConfig.cs
215 lines (172 loc) · 8.19 KB
/
RemindMeConfig.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
using Dalamud.Configuration;
using Dalamud.Plugin;
using ImGuiNET;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Reflection;
using Lumina.Excel.GeneratedSheets;
using Newtonsoft.Json;
using RemindMe.Config;
namespace RemindMe
{
public partial class RemindMeConfig : IPluginConfiguration {
public uint InstallNoticeDismissed = 0;
[NonSerialized] private float debugFraction = 0;
[NonSerialized]
private RemindMe plugin;
public int Version { get; set; } = 2;
[JsonProperty(ItemTypeNameHandling = TypeNameHandling.None)]
public Dictionary<Guid, Config.MonitorDisplay> MonitorDisplays = new Dictionary<Guid, MonitorDisplay>();
[JsonIgnore]
public List<GeneralReminder> GeneralReminders = new List<GeneralReminder>();
private bool showGlobalCooldowns;
public long PollingRate = 100;
private const int GlobalCooldownGroup = 58;
// General Reminder Configs
public int FoodReminderMinimum = 600;
public int LeveReminderThreshold = 96;
[JsonIgnore] private List<StatusMonitor> visibleStatusMonitor = new();
public RemindMeConfig() { }
public void Init(RemindMe plugin)
{
this.plugin = plugin;
foreach (var t in Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(GeneralReminder)))) {
GeneralReminders.Add((GeneralReminder) Activator.CreateInstance(t));
}
if (Version == 1) {
// Update to Version 2
// Remove Status Monitors with ClassJob of 0
Version = 2;
if (MonitorDisplays.Count > 0) {
foreach (var a in MonitorDisplays.Values) {
a.StatusMonitors.RemoveAll(a => a.ClassJob == 0);
}
}
Save();
}
}
public void Save()
{
Service.PluginInterface.SavePluginConfig(this);
}
public bool DrawConfigUI() {
visibleStatusMonitor.Clear();
bool drawConfig = true;
ImGui.SetNextWindowSizeConstraints(new Vector2(400, 400), new Vector2(1200, 1200));
if (!ImGui.Begin($"{plugin.Name} - Configuration###cooldownMonitorSetup", ref drawConfig)) {
ImGui.End();
return drawConfig;
}
if (InstallNoticeDismissed != 1) {
ImGui.TextWrapped($"Thank you for installing {plugin.Name}.\nI am currently working on completely rewriting the plugin but please don't hesitate to bring up any issues you have with the current version. Things seem to be relatively stable, but some things may still pop up.");
if (ImGui.SmallButton("Dismiss")) {
InstallNoticeDismissed = 1;
Save();
}
ImGui.Separator();
}
ImGui.BeginTabBar("###remindMeConfigTabs");
if (ImGui.BeginTabItem("Displays")) {
DrawDisplaysTab();
ImGui.EndTabItem();
}
if (MonitorDisplays.Values.Count(d => d.Enabled) > 0) {
if (ImGui.BeginTabItem("Actions")) {
DrawActionsTab();
ImGui.EndTabItem();
}
if (ImGui.BeginTabItem("Status Effects")) {
DrawStatusEffectsTab();
ImGui.EndTabItem();
}
if (ImGui.BeginTabItem("Raid Effects")) {
DrawRaidEffectsTab();
ImGui.EndTabItem();
}
if (ImGui.BeginTabItem("Reminders")) {
DrawRemindersTab();
ImGui.EndTabItem();
}
}
#if DEBUG
if (ImGui.BeginTabItem("Debug")) {
DrawDebugTab();
ImGui.EndTabItem();
}
#endif
ImGui.EndTabBar();
ImGui.End();
return drawConfig;
}
private void StatusMonitorConfigDisplay(StatusMonitor statusMonitor, Status status = null, string forcedName = null, string note = null, bool removeOnly = false) {
status ??= Service.Data.GetExcelSheet<Status>().GetRow(statusMonitor.Status);
if (status == null) return;
if (!visibleStatusMonitor.Contains(statusMonitor)) visibleStatusMonitor.Add(statusMonitor);
var statusIcon = plugin.IconManager.GetIconTexture(status.Icon);
if (statusIcon != null) {
ImGui.Image(statusIcon.ImGuiHandle, new Vector2(18, 24));
} else {
ImGui.Dummy(new Vector2(18, 24));
}
if (ImGui.IsItemHovered()) {
ImGui.SetTooltip(status.Description);
}
if (statusMonitor.StatusList != null && statusMonitor.SingleIcon == false) {
foreach (var s in statusMonitor.StatusList) {
ImGui.SameLine();
ImGui.SetCursorPosX(ImGui.GetCursorPosX() - 10);
var extraStatus = Service.Data.GetExcelSheet<Status>().GetRow(s);
if (extraStatus == null) continue;
var extraStatusIcon = plugin.IconManager.GetIconTexture(extraStatus.Icon);
if (extraStatusIcon == null) continue;
ImGui.Image(extraStatusIcon.ImGuiHandle, new Vector2(18, 24));
if (ImGui.IsItemHovered()) {
ImGui.SetTooltip(extraStatus.Description);
}
}
}
ImGui.SameLine();
ImGui.Text(forcedName ?? status.Name);
if (!string.IsNullOrEmpty(note)) {
ImGui.SameLine();
ImGui.Text($"({note})");
}
var typeText = "";
if (statusMonitor.SelfOnly) typeText += "SELF";
if (statusMonitor.AlwaysAvailable && statusMonitor.SelfOnly) typeText += ",";
if (statusMonitor.AlwaysAvailable) typeText += "PERMA";
if (!string.IsNullOrEmpty(typeText)) {
var typeTextSize = ImGui.CalcTextSize($"[{typeText}]");
ImGui.SameLine();
ImGui.SetCursorPosX(ImGui.GetColumnWidth() - typeTextSize.X);
ImGui.TextDisabled($"[{typeText}]");
}
ImGui.NextColumn();
foreach (var s in MonitorDisplays.Values.Where(d => d.Enabled)) {
var enabled = s.StatusMonitors.Contains(statusMonitor);
if (removeOnly && !enabled) {
ImGui.NextColumn();
continue;
}
if (ImGui.Checkbox($"###statusToggle{s.Guid}_{status.RowId}_{visibleStatusMonitor.Count}", ref enabled)) {
if (enabled && !removeOnly) {
s.StatusMonitors.Add(statusMonitor);
} else {
s.StatusMonitors.Remove(statusMonitor);
}
Save();
}
ImGui.NextColumn();
}
ImGui.Separator();
}
private void StatusMonitorConfigDisplay(uint statusId, float maxDuration, string note = null, bool raid = false, bool selfOnly = false, uint[] statusList = null, string forcedName = null, ushort limitedZone = 0, bool stacking = false, bool alwaysAvailable = false, byte minLevel = byte.MinValue, byte maxLevel = byte.MaxValue, bool singleIcon = false) {
var status = Service.Data.GetExcelSheet<Status>().GetRow(statusId);
if (status == null) return;
var statusMonitor = new StatusMonitor {Status = status.RowId, ClassJob = Service.ClientState.LocalPlayer.ClassJob.Id, MaxDuration = maxDuration, SelfOnly = selfOnly, StatusList = statusList, IsRaid = raid, LimitedZone = limitedZone, Stacking = stacking, AlwaysAvailable = alwaysAvailable, MinLevel = minLevel, MaxLevel = maxLevel, SingleIcon = singleIcon};
StatusMonitorConfigDisplay(statusMonitor, status, forcedName, note);
}
}
}