49 lines
1.2 KiB
C#
49 lines
1.2 KiB
C#
using ImGuiNET;
|
|
|
|
namespace MegaMappingway;
|
|
|
|
internal class PluginUi : IDisposable {
|
|
private Plugin Plugin { get; }
|
|
|
|
private bool _visible;
|
|
|
|
internal PluginUi(Plugin plugin) {
|
|
this.Plugin = plugin;
|
|
|
|
this.Plugin.Interface.UiBuilder.Draw += this.Draw;
|
|
this.Plugin.Interface.UiBuilder.OpenConfigUi += this.OpenConfig;
|
|
}
|
|
|
|
public void Dispose() {
|
|
this.Plugin.Interface.UiBuilder.OpenConfigUi -= this.OpenConfig;
|
|
this.Plugin.Interface.UiBuilder.Draw -= this.Draw;
|
|
}
|
|
|
|
private void OpenConfig() {
|
|
this._visible = true;
|
|
}
|
|
|
|
private void Draw() {
|
|
if (!this._visible) {
|
|
return;
|
|
}
|
|
|
|
using var end = new OnDispose(ImGui.End);
|
|
if (!ImGui.Begin("Player Map settings", ref this._visible, ImGuiWindowFlags.AlwaysAutoResize)) {
|
|
return;
|
|
}
|
|
|
|
var anyChanged = false;
|
|
|
|
var freq = this.Plugin.Config.UpdateFrequency;
|
|
if (ImGui.DragInt("Upload frequency (secs)", ref freq, 0.05f, 1, 60)) {
|
|
anyChanged = true;
|
|
this.Plugin.Config.UpdateFrequency = freq;
|
|
}
|
|
|
|
if (anyChanged) {
|
|
this.Plugin.SaveConfig();
|
|
}
|
|
}
|
|
}
|