From 395a0d7c989795b0e1f5115aceb354342ab303ac Mon Sep 17 00:00:00 2001 From: JonKazama-Hellion Date: Sat, 2 May 2026 17:33:51 +0200 Subject: [PATCH] refactor(settings): polish database tab section structure Drop the redundant inner Advanced TreeNode in the Maintenance section, flatten the duplicated indent in the Overview section, and rename the section headings so they reflect their content (Overview shows metadata, Maintenance hosts the shift-gated tooling). --- ChatTwo/Resources/HellionStrings.de.resx | 4 +- ChatTwo/Resources/HellionStrings.resx | 4 +- ChatTwo/Ui/SettingsTabs/Database.cs | 79 +++++++++++------------- 3 files changed, 41 insertions(+), 46 deletions(-) diff --git a/ChatTwo/Resources/HellionStrings.de.resx b/ChatTwo/Resources/HellionStrings.de.resx index c0f0d2b..671dd43 100644 --- a/ChatTwo/Resources/HellionStrings.de.resx +++ b/ChatTwo/Resources/HellionStrings.de.resx @@ -528,9 +528,9 @@ Speicherung - DB-Viewer + Übersicht - Statistiken + Wartung diff --git a/ChatTwo/Resources/HellionStrings.resx b/ChatTwo/Resources/HellionStrings.resx index e83edca..8b19242 100644 --- a/ChatTwo/Resources/HellionStrings.resx +++ b/ChatTwo/Resources/HellionStrings.resx @@ -528,9 +528,9 @@ Storage - DB Viewer + Overview - Statistics + Maintenance diff --git a/ChatTwo/Ui/SettingsTabs/Database.cs b/ChatTwo/Ui/SettingsTabs/Database.cs index acba658..afa75e9 100755 --- a/ChatTwo/Ui/SettingsTabs/Database.cs +++ b/ChatTwo/Ui/SettingsTabs/Database.cs @@ -105,55 +105,51 @@ internal sealed class Database : ISettingsTab using (ImRaii.PushIndent(ImGui.GetStyle().IndentSpacing, false)) { - ImGui.TextUnformatted(Language.Options_Database_Metadata_Heading); - using (ImRaii.PushIndent(ImGui.GetStyle().IndentSpacing, false)) + // Refresh the database size and message count every 5 seconds to avoid + // constant stat calls and spamming the database. + if (DatabaseLastRefreshTicks + 5 * 1000 < Environment.TickCount64) { - // Refresh the database size and message count every 5 seconds to avoid - // constant stat calls and spamming the database. - if (DatabaseLastRefreshTicks + 5 * 1000 < Environment.TickCount64) - { - DatabaseSize = Plugin.MessageManager.Store.DatabaseSize(); - DatabaseLogSize = Plugin.MessageManager.Store.DatabaseLogSize(); - DatabaseMessageCount = Plugin.MessageManager.Store.MessageCount(); - DatabaseLastRefreshTicks = Environment.TickCount64; - } + DatabaseSize = Plugin.MessageManager.Store.DatabaseSize(); + DatabaseLogSize = Plugin.MessageManager.Store.DatabaseLogSize(); + DatabaseMessageCount = Plugin.MessageManager.Store.MessageCount(); + DatabaseLastRefreshTicks = Environment.TickCount64; + } - // Copy the directory path instead of the file path so people can - // paste it into their file explorer. - ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_Path, MessageManager.DatabasePath())); - if (ImGui.IsItemClicked(ImGuiMouseButton.Left)) - { - var path = Path.GetDirectoryName(MessageManager.DatabasePath()); - ImGui.SetClipboardText(path); - WrapperUtil.AddNotification(Language.Options_Database_Metadata_CopyConfigPathNotification, NotificationType.Info); - } + // Copy the directory path instead of the file path so people can + // paste it into their file explorer. + ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_Path, MessageManager.DatabasePath())); + if (ImGui.IsItemClicked(ImGuiMouseButton.Left)) + { + var path = Path.GetDirectoryName(MessageManager.DatabasePath()); + ImGui.SetClipboardText(path); + WrapperUtil.AddNotification(Language.Options_Database_Metadata_CopyConfigPathNotification, NotificationType.Info); + } - if (ImGui.IsItemHovered()) - { - ImGui.SetMouseCursor(ImGuiMouseCursor.Hand); - ImGuiUtil.Tooltip(Language.Options_Database_Metadata_CopyConfigPath); - } + if (ImGui.IsItemHovered()) + { + ImGui.SetMouseCursor(ImGuiMouseCursor.Hand); + ImGuiUtil.Tooltip(Language.Options_Database_Metadata_CopyConfigPath); + } - ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_Size, StringUtil.BytesToString(DatabaseSize))); - if (ImGui.IsItemHovered()) - ImGuiUtil.Tooltip(StringUtil.BytesToString(DatabaseSize)); + ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_Size, StringUtil.BytesToString(DatabaseSize))); + if (ImGui.IsItemHovered()) + ImGuiUtil.Tooltip(StringUtil.BytesToString(DatabaseSize)); - ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_LogSize, StringUtil.BytesToString(DatabaseLogSize))); - if (ImGui.IsItemHovered()) - ImGuiUtil.Tooltip(StringUtil.BytesToString(DatabaseLogSize)); + ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_LogSize, StringUtil.BytesToString(DatabaseLogSize))); + if (ImGui.IsItemHovered()) + ImGuiUtil.Tooltip(StringUtil.BytesToString(DatabaseLogSize)); - ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_MessageCount, DatabaseMessageCount)); + ImGuiUtil.HelpText(string.Format(Language.Options_Database_Metadata_MessageCount, DatabaseMessageCount)); - if (ImGuiUtil.CtrlShiftButton(Language.Options_ClearDatabase_Button, Language.Options_ClearDatabase_Tooltip)) - { - Plugin.Log.Warning("Clearing messages from database"); - Plugin.MessageManager.Store.ClearMessages(); - Plugin.MessageManager.ClearAllTabs(); + if (ImGuiUtil.CtrlShiftButton(Language.Options_ClearDatabase_Button, Language.Options_ClearDatabase_Tooltip)) + { + Plugin.Log.Warning("Clearing messages from database"); + Plugin.MessageManager.Store.ClearMessages(); + Plugin.MessageManager.ClearAllTabs(); - // Refresh on next draw - DatabaseLastRefreshTicks = 0; - WrapperUtil.AddNotification(Language.Options_ClearDatabase_Success, NotificationType.Info); - } + // Refresh on next draw + DatabaseLastRefreshTicks = 0; + WrapperUtil.AddNotification(Language.Options_ClearDatabase_Success, NotificationType.Info); } } } @@ -169,7 +165,6 @@ internal sealed class Database : ISettingsTab using (ImRaii.PushIndent(ImGui.GetStyle().IndentSpacing, false)) { - using var treeNode = ImRaii.TreeNode(Language.Options_Database_Advanced); using var wrap = ImRaii.TextWrapPos(0.0f); ImGuiUtil.WarningText(Language.Options_Database_Advanced_Warning);