Globetrotter/Globetrotter/PluginUi.cs

77 lines
2.3 KiB
C#
Raw Permalink Normal View History

2021-03-19 20:06:45 +00:00
using ImGuiNET;
2021-04-16 12:01:48 +00:00
using System.Numerics;
2021-03-19 20:06:45 +00:00
namespace Globetrotter {
internal class PluginUi {
2023-09-29 01:02:45 +00:00
private Plugin Plugin { get; }
2021-03-19 20:06:45 +00:00
private bool _displaySettings;
private bool DisplaySettings {
get => this._displaySettings;
set => this._displaySettings = value;
}
2023-09-29 01:02:45 +00:00
public PluginUi(Plugin plugin) {
2021-08-23 01:48:54 +00:00
this.Plugin = plugin;
2021-03-19 20:06:45 +00:00
}
2021-08-24 18:40:46 +00:00
public void OpenSettings() {
2021-03-19 20:06:45 +00:00
this.DisplaySettings = true;
}
public void Draw() {
if (!this.DisplaySettings) {
return;
}
2021-04-16 12:01:48 +00:00
ImGui.SetNextWindowSize(new Vector2(350, 250), ImGuiCond.FirstUseEver);
2021-03-19 20:06:45 +00:00
if (!ImGui.Begin("Globetrotter settings", ref this._displaySettings)) {
2021-04-16 12:01:48 +00:00
ImGui.End();
2021-03-19 20:06:45 +00:00
return;
}
ImGui.TextUnformatted("Use /tmap to open your current treasure map.");
ImGui.Separator();
2021-08-23 01:48:54 +00:00
var showOnDecipher = this.Plugin.Config.ShowOnDecipher;
2021-04-16 12:01:48 +00:00
if (HelpCheckbox("Show on decipher", "Open the map with a flag set after deciphering a map.", ref showOnDecipher)) {
2021-08-23 01:48:54 +00:00
this.Plugin.Config.ShowOnDecipher = showOnDecipher;
this.Plugin.Config.Save();
2021-03-19 20:06:45 +00:00
}
2021-04-16 12:01:48 +00:00
ImGui.Separator();
2021-08-23 01:48:54 +00:00
var showOnOpen = this.Plugin.Config.ShowOnOpen;
2021-04-16 12:01:48 +00:00
if (HelpCheckbox("Show on open", "Open the map with a flag set instead of the normal treasure map window.", ref showOnOpen)) {
2021-08-23 01:48:54 +00:00
this.Plugin.Config.ShowOnOpen = showOnOpen;
this.Plugin.Config.Save();
2021-03-19 20:06:45 +00:00
}
2021-04-16 12:01:48 +00:00
ImGui.Separator();
2021-08-23 01:48:54 +00:00
var showOnHover = this.Plugin.Config.ShowOnHover;
2021-04-16 12:01:48 +00:00
if (HelpCheckbox("Show on hover", "Open the map with a flag set when hovering over a deciphered map.", ref showOnHover)) {
2021-08-23 01:48:54 +00:00
this.Plugin.Config.ShowOnHover = showOnHover;
this.Plugin.Config.Save();
2021-04-16 12:01:48 +00:00
}
2021-03-19 20:06:45 +00:00
ImGui.End();
}
2021-04-16 12:01:48 +00:00
private static bool HelpCheckbox(string label, string help, ref bool isChecked) {
var ret = ImGui.Checkbox(label, ref isChecked);
ImGui.TreePush();
ImGui.PushTextWrapPos();
ImGui.TextUnformatted(help);
ImGui.PopTextWrapPos();
ImGui.TreePop();
return ret;
}
2021-03-19 20:06:45 +00:00
}
}