OrangeGuidanceTomestone/client/Ui/MainWindow.cs

78 lines
1.8 KiB
C#
Raw Normal View History

2022-09-04 07:40:34 +00:00
using System.Numerics;
2022-09-04 05:03:59 +00:00
using ImGuiNET;
using OrangeGuidanceTomestone.Ui.MainWindowTabs;
namespace OrangeGuidanceTomestone.Ui;
internal class MainWindow {
private Plugin Plugin { get; }
private List<ITab> Tabs { get; }
internal bool Visible;
2022-09-05 08:21:45 +00:00
internal uint ExtraMessages;
2022-09-04 05:03:59 +00:00
internal MainWindow(Plugin plugin) {
this.Plugin = plugin;
this.Tabs = new List<ITab> {
new Write(this.Plugin),
new MessageList(this.Plugin),
2022-09-05 08:02:34 +00:00
new Settings(this.Plugin),
2022-09-04 05:03:59 +00:00
};
}
internal void Draw() {
if (!this.Visible) {
return;
}
2022-09-06 07:59:39 +00:00
ImGui.SetNextWindowSize(new Vector2(475, 350), ImGuiCond.FirstUseEver);
2023-09-29 00:53:50 +00:00
if (!ImGui.Begin(Plugin.Name, ref this.Visible)) {
2022-09-04 05:03:59 +00:00
ImGui.End();
return;
}
2022-09-05 23:23:55 +00:00
if (this.Plugin.Config.ApiKey == string.Empty) {
this.DrawApiKey();
} else {
this.DrawTabs();
}
2022-09-04 05:03:59 +00:00
2022-09-05 23:23:55 +00:00
ImGui.End();
}
2022-09-04 05:03:59 +00:00
2022-09-05 23:23:55 +00:00
private void DrawTabs() {
if (!ImGui.BeginTabBar("##ogt-main-tabs")) {
return;
}
foreach (var tab in this.Tabs) {
if (!ImGui.BeginTabItem(tab.Name)) {
continue;
2022-09-04 05:03:59 +00:00
}
2022-09-07 05:35:58 +00:00
if (ImGui.BeginChild("##tab-content")) {
tab.Draw();
}
ImGui.EndChild();
2022-09-05 23:23:55 +00:00
ImGui.EndTabItem();
2022-09-04 05:03:59 +00:00
}
2022-09-05 23:23:55 +00:00
ImGui.EndTabBar();
}
private void DrawApiKey() {
ImGui.PushTextWrapPos();
2023-09-29 00:53:50 +00:00
ImGui.TextUnformatted($"Somehow, {Plugin.Name} wasn't able to register you an account automatically.");
2022-09-05 23:23:55 +00:00
ImGui.TextUnformatted("Click the button below to try again.");
ImGui.PopTextWrapPos();
if (ImGui.Button("Register")) {
this.Plugin.GetApiKey();
}
2022-09-04 05:03:59 +00:00
}
}