From decc3bfd227d2956ba4a0ec80e1fcedd0631b042 Mon Sep 17 00:00:00 2001 From: Anna Date: Sat, 15 Jan 2022 00:24:47 -0500 Subject: [PATCH] feat: add option to make modern more compact --- ChatTwo/Configuration.cs | 1 + ChatTwo/Ui/ChatLog.cs | 9 ++++++++- ChatTwo/Ui/Settings.cs | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index 261a8ad..7371056 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -10,6 +10,7 @@ internal class Configuration : IPluginConfiguration { public bool HideChat = true; public bool NativeItemTooltips = true; public bool PrettierTimestamps = true; + public bool MoreCompactPretty; public bool SidebarTabView; public float FontSize = 17f; public Dictionary ChatColours = new(); diff --git a/ChatTwo/Ui/ChatLog.cs b/ChatTwo/Ui/ChatLog.cs index 47466e2..dd96062 100755 --- a/ChatTwo/Ui/ChatLog.cs +++ b/ChatTwo/Ui/ChatLog.cs @@ -174,6 +174,13 @@ internal sealed class ChatLog : IUiComponent { ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero); var table = tab.DisplayTimestamp && this.Ui.Plugin.Config.PrettierTimestamps; + if (this.Ui.Plugin.Config.MoreCompactPretty) { + var padding = ImGui.GetStyle().CellPadding; + padding.Y = 0; + + ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, padding); + } + if (table) { if (!ImGui.BeginTable("timestamp-table", 2, ImGuiTableFlags.PreciseWidths)) { goto EndChild; @@ -227,7 +234,7 @@ internal sealed class ChatLog : IUiComponent { // } } finally { tab.MessagesMutex.ReleaseMutex(); - ImGui.PopStyleVar(); + ImGui.PopStyleVar(this.Ui.Plugin.Config.MoreCompactPretty ? 2 : 1); } // PluginLog.Log($"numDrawn: {numDrawn}"); diff --git a/ChatTwo/Ui/Settings.cs b/ChatTwo/Ui/Settings.cs index 00a461a..d226bbd 100755 --- a/ChatTwo/Ui/Settings.cs +++ b/ChatTwo/Ui/Settings.cs @@ -14,6 +14,7 @@ internal sealed class Settings : IUiComponent { private bool _nativeItemTooltips; private bool _sidebarTabView; private bool _prettierTimestamps; + private bool _moreCompactPretty; private float _fontSize; private Dictionary _chatColours = new(); private List _tabs = new(); @@ -39,6 +40,7 @@ internal sealed class Settings : IUiComponent { this._nativeItemTooltips = config.NativeItemTooltips; this._sidebarTabView = config.SidebarTabView; this._prettierTimestamps = config.PrettierTimestamps; + this._moreCompactPretty = config.MoreCompactPretty; this._fontSize = config.FontSize; this._chatColours = config.ChatColours.ToDictionary(entry => entry.Key, entry => entry.Value); this._tabs = config.Tabs.Select(tab => tab.Clone()).ToList(); @@ -68,6 +70,11 @@ internal sealed class Settings : IUiComponent { ImGui.Checkbox("Show native item tooltips", ref this._nativeItemTooltips); ImGui.Checkbox("Show tabs in a sidebar", ref this._sidebarTabView); ImGui.Checkbox("Use modern timestamp layout", ref this._prettierTimestamps); + + if (this._prettierTimestamps) { + ImGui.Checkbox("More compact modern layout", ref this._moreCompactPretty); + } + ImGui.DragFloat("Font size", ref this._fontSize, .0125f, 12f, 36f, "%.1f"); if (ImGui.TreeNodeEx("Chat colours")) { @@ -210,6 +217,7 @@ internal sealed class Settings : IUiComponent { config.NativeItemTooltips = this._nativeItemTooltips; config.SidebarTabView = this._sidebarTabView; config.PrettierTimestamps = this._prettierTimestamps; + config.MoreCompactPretty = this._moreCompactPretty; config.FontSize = this._fontSize; config.ChatColours = this._chatColours; config.Tabs = this._tabs;