116 lines
3.6 KiB
C#
Executable File
116 lines
3.6 KiB
C#
Executable File
using System;
|
|
using ImGuiNET;
|
|
using XivCommon.Functions;
|
|
|
|
namespace TextBoxStyler {
|
|
public class PluginUi : IDisposable {
|
|
private const string DefaultLabel = "<default>";
|
|
|
|
private Plugin Plugin { get; }
|
|
|
|
private bool _drawUi;
|
|
|
|
private bool DrawUi {
|
|
get => this._drawUi;
|
|
set => this._drawUi = value;
|
|
}
|
|
|
|
internal PluginUi(Plugin plugin) {
|
|
this.Plugin = plugin;
|
|
|
|
this.Plugin.Interface.UiBuilder.OnBuildUi += this.Draw;
|
|
this.Plugin.Interface.UiBuilder.OnOpenConfigUi += this.ToggleConfig;
|
|
}
|
|
|
|
public void Dispose() {
|
|
this.Plugin.Interface.UiBuilder.OnOpenConfigUi -= this.ToggleConfig;
|
|
this.Plugin.Interface.UiBuilder.OnBuildUi -= this.Draw;
|
|
}
|
|
|
|
internal void ToggleConfig(object? sender = null, EventArgs? e = null) {
|
|
this.DrawUi = !this.DrawUi;
|
|
}
|
|
|
|
private void Draw() {
|
|
if (!this.DrawUi) {
|
|
return;
|
|
}
|
|
|
|
if (!ImGui.Begin($"{this.Plugin.Name} settings", ref this._drawUi)) {
|
|
ImGui.End();
|
|
return;
|
|
}
|
|
|
|
if (ImGui.BeginTabBar("textboxstyle-tabs")) {
|
|
if (ImGui.BeginTabItem("Talk")) {
|
|
this.DrawTalkSettings();
|
|
ImGui.EndTabItem();
|
|
}
|
|
|
|
if (ImGui.BeginTabItem("Battle talk")) {
|
|
this.DrawBattleTalkSettings();
|
|
ImGui.EndTabItem();
|
|
}
|
|
|
|
ImGui.EndTabBar();
|
|
}
|
|
|
|
ImGui.End();
|
|
}
|
|
|
|
private void DrawTalkSettings() {
|
|
ImGui.TextUnformatted("Choose a setting below to change the style of all text boxes.");
|
|
|
|
var placeholder = this.Plugin.Config.Style?.Name() ?? DefaultLabel;
|
|
if (ImGui.BeginCombo("Text box style", placeholder)) {
|
|
if (ImGui.Selectable(DefaultLabel)) {
|
|
this.Plugin.Config.Style = null;
|
|
this.Plugin.Config.Save();
|
|
}
|
|
|
|
foreach (var style in (TalkStyle[]) Enum.GetValues(typeof(TalkStyle))) {
|
|
if (!ImGui.Selectable(style.Name())) {
|
|
continue;
|
|
}
|
|
|
|
this.Plugin.Config.Style = style;
|
|
this.Plugin.Config.Save();
|
|
}
|
|
|
|
ImGui.EndCombo();
|
|
}
|
|
|
|
var affectCutscenes = this.Plugin.Config.AffectCutscenes;
|
|
if (ImGui.Checkbox("Affect cutscenes", ref affectCutscenes)) {
|
|
this.Plugin.Config.AffectCutscenes = affectCutscenes;
|
|
this.Plugin.Config.Save();
|
|
}
|
|
}
|
|
|
|
private void DrawBattleTalkSettings() {
|
|
ImGui.TextUnformatted("Choose a setting below to change the style of all battle talk text boxes.");
|
|
|
|
var placeholder = this.Plugin.Config.BattleTalkStyle?.Name() ?? DefaultLabel;
|
|
if (!ImGui.BeginCombo("Battle talk style", placeholder)) {
|
|
return;
|
|
}
|
|
|
|
if (ImGui.Selectable(DefaultLabel)) {
|
|
this.Plugin.Config.BattleTalkStyle = null;
|
|
this.Plugin.Config.Save();
|
|
}
|
|
|
|
foreach (var style in (BattleTalkStyle[]) Enum.GetValues(typeof(BattleTalkStyle))) {
|
|
if (!ImGui.Selectable(style.Name())) {
|
|
continue;
|
|
}
|
|
|
|
this.Plugin.Config.BattleTalkStyle = style;
|
|
this.Plugin.Config.Save();
|
|
}
|
|
|
|
ImGui.EndCombo();
|
|
}
|
|
}
|
|
}
|