-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathFPSPluginConfig.cs
More file actions
96 lines (73 loc) · 3.69 KB
/
FPSPluginConfig.cs
File metadata and controls
96 lines (73 loc) · 3.69 KB
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
using Dalamud.Configuration;
using Dalamud.Bindings.ImGui;
using System;
using System.Diagnostics;
using System.Reflection;
namespace FPSPlugin {
public class FPSPluginConfig : IPluginConfiguration {
[NonSerialized] private FPSPlugin plugin = null!;
[NonSerialized] public string TestText = string.Empty;
public int Version { get; set; }
public bool ShowDecimals;
public bool Enable = true;
public bool ShowAverage;
public bool ShowMinimum;
public bool NoLabels;
public bool AlternativeFPSLabel;
public bool DtrTooltip = true;
public bool DtrOpenSettings = true;
public int HistorySnapshotCount = 300;
public void LoadDefaults() {
var defaults = new FPSPluginConfig();
foreach (var f in GetType().GetFields(BindingFlags.Public | BindingFlags.Instance)) {
f.SetValue(this, f.GetValue(defaults));
}
}
public void Init(FPSPlugin plugin) {
this.plugin = plugin;
}
public void Save() {
FPSPlugin.PluginInterface.SavePluginConfig(this);
}
public bool DrawConfigUI() {
var drawConfig = true;
var windowFlags = ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse;
ImGui.Begin($"{plugin.Name} Config##fpsPluginConfigWindow", ref drawConfig, windowFlags);
var changed = false;
changed |= ImGui.Checkbox("Show Display##fpsPluginEnabledSetting", ref Enable);
ImGui.SameLine();
ImGui.TextDisabled("/pfps [show|hide|toggle]");
changed |= ImGui.Checkbox("Enable Tooltip##fpsPluginDtrTooltip", ref DtrTooltip);
changed |= ImGui.Checkbox("Click to open settings##fpsPluginDtrOpenSettings", ref DtrOpenSettings);
changed |= ImGui.Checkbox("Show Decimals##fpsPluginDecimalsSetting", ref ShowDecimals);
changed |= ImGui.Checkbox("Show Average##fpsPluginShowAverageSetting", ref ShowAverage);
changed |= ImGui.Checkbox("Show Minimum##fpsPluginShowMinimumSetting", ref ShowMinimum);
changed |= ImGui.Checkbox("Hide Labels##fpsPluginNoLabelsSetting", ref NoLabels);
if (!NoLabels) changed |= ImGui.Checkbox("Alternative FPS Label##fpsPluginAlternativeFPSLabelSetting", ref AlternativeFPSLabel);
changed |= ImGui.InputInt("Tracking Timespan (Seconds)", ref HistorySnapshotCount, 1, 60);
ImGui.Separator();
if (ImGui.Button("Restore Default##fpsPluginDefaultsButton")) {
LoadDefaults();
changed = true;
}
if (changed) {
if (HistorySnapshotCount < 1) HistorySnapshotCount = 1;
if (HistorySnapshotCount > 10000) HistorySnapshotCount = 10000;
Save();
}
ImGui.SameLine();
ImGui.PushStyleColor(ImGuiCol.Button, 0xFF5E5BFF);
ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xFF5E5BAA);
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xFF5E5BDD);
var c = ImGui.GetCursorPos();
ImGui.SetCursorPosX(ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X - ImGui.CalcTextSize("Support on Ko-fi").X - ImGui.GetStyle().FramePadding.X * 2);
if (ImGui.Button("Support on Ko-fi")) {
Process.Start(new ProcessStartInfo {FileName = "https://ko-fi.com/Caraxi", UseShellExecute = true});
}
ImGui.SetCursorPos(c);
ImGui.PopStyleColor(3);
ImGui.End();
return drawConfig;
}
}
}