OrangeGuidanceTomestone/client/Ui/ViewerButton.cs

45 lines
1000 B
C#
Raw Normal View History

2022-09-04 05:03:59 +00:00
using ImGuiNET;
namespace OrangeGuidanceTomestone.Ui;
internal class ViewerButton {
private Plugin Plugin { get; }
internal ViewerButton(Plugin plugin) {
this.Plugin = plugin;
}
internal void Draw() {
if (this.Plugin.Ui.Viewer.Visible) {
return;
}
var nearby = this.Plugin.Messages.Nearby().ToList();
if (nearby.Count == 0) {
return;
}
2022-09-05 09:05:14 +00:00
if (this.Plugin.Config.AutoViewer) {
this.Plugin.Ui.Viewer.Visible = true;
return;
}
2022-09-04 05:03:59 +00:00
ImGui.SetNextWindowBgAlpha(0.5f);
2022-09-04 07:40:34 +00:00
if (!ImGui.Begin("##ogt-viewer-button", ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.AlwaysAutoResize)) {
2022-09-04 05:03:59 +00:00
ImGui.End();
return;
}
var label = "View message";
if (nearby.Count > 1) {
label += "s";
}
if (ImGui.Button(label)) {
this.Plugin.Ui.Viewer.Visible = true;
}
ImGui.End();
}
}