feat: add option to make modern more compact

This commit is contained in:
Anna 2022-01-15 00:24:47 -05:00
parent 35330b4038
commit 47aee321a4
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
3 changed files with 17 additions and 1 deletions

View File

@ -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<ChatType, uint> ChatColours = new();

View File

@ -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}");

View File

@ -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<ChatType, uint> _chatColours = new();
private List<Tab> _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;