From e219b3e1fe83c2d75b8a1e851d9ec22212d3a518 Mon Sep 17 00:00:00 2001 From: Infi Date: Fri, 1 May 2026 20:14:13 +0200 Subject: [PATCH] - Improve DBViewer behaviour and UI (cherry picked from commit cb41787f5525aa73175ad06299d0a799ebf731e2) --- ChatTwo/Resources/Language.Designer.cs | 100 ++++++++++++++++++++++++ ChatTwo/Resources/Language.ca.resx | 34 ++++++++ ChatTwo/Resources/Language.de.resx | 34 ++++++++ ChatTwo/Resources/Language.es.resx | 34 ++++++++ ChatTwo/Resources/Language.fr.resx | 34 ++++++++ ChatTwo/Resources/Language.it.resx | 34 ++++++++ ChatTwo/Resources/Language.ja.resx | 34 ++++++++ ChatTwo/Resources/Language.ko.resx | 34 ++++++++ ChatTwo/Resources/Language.nl.resx | 34 ++++++++ ChatTwo/Resources/Language.pt-BR.resx | 34 ++++++++ ChatTwo/Resources/Language.resx | 34 ++++++++ ChatTwo/Resources/Language.ro.resx | 34 ++++++++ ChatTwo/Resources/Language.ru.resx | 34 ++++++++ ChatTwo/Resources/Language.sv.resx | 34 ++++++++ ChatTwo/Resources/Language.zh-Hans.resx | 34 ++++++++ ChatTwo/Resources/Language.zh-Hant.resx | 34 ++++++++ ChatTwo/Ui/DbViewer.cs | 36 ++++++--- ChatTwo/Util/DatePicker.cs | 3 + ChatTwo/Util/ImGuiUtil.cs | 15 +++- 19 files changed, 652 insertions(+), 12 deletions(-) diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs index 1085545..4601203 100755 --- a/ChatTwo/Resources/Language.Designer.cs +++ b/ChatTwo/Resources/Language.Designer.cs @@ -131,6 +131,15 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Loading logs .... + /// + internal static string ChatExport_Initial { + get { + return ResourceManager.GetString("ChatExport_Initial", resourceCulture); + } + } + /// /// Looks up a localized string similar to Input is disabled for this tab. /// @@ -1454,6 +1463,34 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Database migration has failed, a new database will be created. + ///Your old database can still be recovered, please contact the plugin author for help.. + /// + internal static string Database_Migration_Error_Desc { + get { + return ResourceManager.GetString("Database_Migration_Error_Desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Chat2 Database Migration Error. + /// + internal static string Database_Migration_Error_Title { + get { + return ResourceManager.GetString("Database_Migration_Error_Title", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Open date picker. + /// + internal static string DatePicker_Tooltip { + get { + return ResourceManager.GetString("DatePicker_Tooltip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Fri. /// @@ -1643,6 +1680,15 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Reset date selection.. + /// + internal static string DbViewer_Date_Reset_Tooltip { + get { + return ResourceManager.GetString("DbViewer_Date_Reset_Tooltip", resourceCulture); + } + } + /// /// Looks up a localized string similar to FromTo:. /// @@ -1733,6 +1779,24 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Export the message history to a json file.. + /// + internal static string Export_Json_Tooltip { + get { + return ResourceManager.GetString("Export_Json_Tooltip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Export the message history to a text file.. + /// + internal static string Export_Txt_Tooltip { + get { + return ResourceManager.GetString("Export_Txt_Tooltip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Chinese (full). /// @@ -1796,6 +1860,24 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Pick a folder location for export.. + /// + internal static string Folder_Export_Location_Tooltip { + get { + return ResourceManager.GetString("Folder_Export_Location_Tooltip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Pick an export location. + /// + internal static string Folder_Selection_Header { + get { + return ResourceManager.GetString("Folder_Selection_Header", resourceCulture); + } + } + /// /// Looks up a localized string similar to Source. /// @@ -3713,6 +3795,24 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Previous page. + /// + internal static string Page_ArrowLeft_Tooltip { + get { + return ResourceManager.GetString("Page_ArrowLeft_Tooltip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Next page. + /// + internal static string Page_ArrowRight_Tooltip { + get { + return ResourceManager.GetString("Page_ArrowRight_Tooltip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Unable to find ID for this message, please try another one.. /// diff --git a/ChatTwo/Resources/Language.ca.resx b/ChatTwo/Resources/Language.ca.resx index 4d74af5..b5d95b1 100644 --- a/ChatTwo/Resources/Language.ca.resx +++ b/ChatTwo/Resources/Language.ca.resx @@ -1432,4 +1432,38 @@ Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Resources/Language.de.resx b/ChatTwo/Resources/Language.de.resx index 59c241e..29cae9a 100644 --- a/ChatTwo/Resources/Language.de.resx +++ b/ChatTwo/Resources/Language.de.resx @@ -1435,4 +1435,38 @@ Nachdem du 'Aktiviert' angeklickt und auf 'Start' gedrückt hast, wird die einge Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Resources/Language.es.resx b/ChatTwo/Resources/Language.es.resx index 285cddd..078e6cb 100644 --- a/ChatTwo/Resources/Language.es.resx +++ b/ChatTwo/Resources/Language.es.resx @@ -1432,4 +1432,38 @@ Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Resources/Language.fr.resx b/ChatTwo/Resources/Language.fr.resx index aa1ae4b..2c78d87 100644 --- a/ChatTwo/Resources/Language.fr.resx +++ b/ChatTwo/Resources/Language.fr.resx @@ -1432,4 +1432,38 @@ Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Resources/Language.it.resx b/ChatTwo/Resources/Language.it.resx index 922b966..dd1f9d4 100644 --- a/ChatTwo/Resources/Language.it.resx +++ b/ChatTwo/Resources/Language.it.resx @@ -1432,4 +1432,38 @@ Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Resources/Language.ja.resx b/ChatTwo/Resources/Language.ja.resx index 96225f7..b9e43c5 100644 --- a/ChatTwo/Resources/Language.ja.resx +++ b/ChatTwo/Resources/Language.ja.resx @@ -1432,4 +1432,38 @@ Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Resources/Language.ko.resx b/ChatTwo/Resources/Language.ko.resx index b8aa844..55b2a95 100644 --- a/ChatTwo/Resources/Language.ko.resx +++ b/ChatTwo/Resources/Language.ko.resx @@ -1432,4 +1432,38 @@ Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Resources/Language.nl.resx b/ChatTwo/Resources/Language.nl.resx index fb8f793..959638f 100644 --- a/ChatTwo/Resources/Language.nl.resx +++ b/ChatTwo/Resources/Language.nl.resx @@ -1432,4 +1432,38 @@ Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Resources/Language.pt-BR.resx b/ChatTwo/Resources/Language.pt-BR.resx index 1f4aca1..33a21e4 100644 --- a/ChatTwo/Resources/Language.pt-BR.resx +++ b/ChatTwo/Resources/Language.pt-BR.resx @@ -1432,4 +1432,38 @@ Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx index 01989ca..c3a3f19 100644 --- a/ChatTwo/Resources/Language.resx +++ b/ChatTwo/Resources/Language.resx @@ -1432,4 +1432,38 @@ Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Resources/Language.ro.resx b/ChatTwo/Resources/Language.ro.resx index 7ad9b42..8246b58 100644 --- a/ChatTwo/Resources/Language.ro.resx +++ b/ChatTwo/Resources/Language.ro.resx @@ -1432,4 +1432,38 @@ Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Resources/Language.ru.resx b/ChatTwo/Resources/Language.ru.resx index 20d6180..eac47ed 100644 --- a/ChatTwo/Resources/Language.ru.resx +++ b/ChatTwo/Resources/Language.ru.resx @@ -1432,4 +1432,38 @@ Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Resources/Language.sv.resx b/ChatTwo/Resources/Language.sv.resx index c6bff07..c0742de 100644 --- a/ChatTwo/Resources/Language.sv.resx +++ b/ChatTwo/Resources/Language.sv.resx @@ -1432,4 +1432,38 @@ Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Resources/Language.zh-Hans.resx b/ChatTwo/Resources/Language.zh-Hans.resx index d304ba0..1ccc180 100644 --- a/ChatTwo/Resources/Language.zh-Hans.resx +++ b/ChatTwo/Resources/Language.zh-Hans.resx @@ -1432,4 +1432,38 @@ Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Resources/Language.zh-Hant.resx b/ChatTwo/Resources/Language.zh-Hant.resx index c2c20fb..be9c6ab 100644 --- a/ChatTwo/Resources/Language.zh-Hant.resx +++ b/ChatTwo/Resources/Language.zh-Hant.resx @@ -1433,4 +1433,38 @@ Select all + + Chat2 Database Migration Error + + + Database migration has failed, a new database will be created. +Your old database can still be recovered, please contact the plugin author for help. + + + Reset date selection. + + + Pick a folder location for export. + + + Pick an export location + + + Export the message history to a text file. + + + Export the message history to a json file. + + + Previous page + + + Next page + + + Open date picker + + + Loading logs ... + diff --git a/ChatTwo/Ui/DbViewer.cs b/ChatTwo/Ui/DbViewer.cs index b9ed676..4a9296d 100644 --- a/ChatTwo/Ui/DbViewer.cs +++ b/ChatTwo/Ui/DbViewer.cs @@ -56,6 +56,8 @@ public class DbViewer : Window private string InputPath = string.Empty; private IActiveNotification Notification = null!; + private bool NeedsScrollReset; + public DbViewer(Plugin plugin) : base("DBViewer###chat2-dbviewer") { Plugin = plugin; @@ -104,11 +106,17 @@ public class DbViewer : Window var spacing = 3.0f * ImGuiHelpers.GlobalScale; DateWidget.DatePickerWithInput("##FromDate", 1, ref MinDateString, ref AfterDate, DateFormat); DateWidget.DatePickerWithInput("##ToDate", 2, ref MaxDateString, ref BeforeDate, DateFormat, true); + ImGui.SameLine(0, spacing); + if (ImGuiUtil.IconButton(FontAwesomeIcon.Recycle)) DateReset(); - ImGuiUtil.DrawArrows(ref CurrentPage, 1, totalPages, spacing); + + if (ImGui.IsItemHovered()) + ImGui.SetTooltip(Language.DbViewer_Date_Reset_Tooltip); + ImGui.SameLine(0, spacing); + ChannelSelection(); var skipText = Language.DbViewer_CharacterOption; @@ -128,12 +136,12 @@ public class DbViewer : Window ImGui.OpenPopup("InputPathDialog"); if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) - ImGui.SetTooltip("Pick a folder location for export."); + ImGui.SetTooltip(Language.Folder_Export_Location_Tooltip); using (var innerPopup = ImRaii.Popup("InputPathDialog")) { if (innerPopup.Success) - Plugin.FileDialogManager.OpenFolderDialog("Pick an export location", (b, s) => { if (b) InputPath = s; }, null, true); + Plugin.FileDialogManager.OpenFolderDialog(Language.Folder_Selection_Header, (b, s) => { if (b) InputPath = s; }, null, true); } ImGui.SameLine(0, spacing); @@ -145,7 +153,7 @@ public class DbViewer : Window new Notification { Title = "Chat2 Text Export", - Content = "Loading logs ...", + Content = Language.ChatExport_Initial, Type = NotificationType.Info, Minimized = false, UserDismissable = false, @@ -157,7 +165,7 @@ public class DbViewer : Window } if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) - ImGui.SetTooltip("Export the message history to a text file."); + ImGui.SetTooltip(Language.Export_Txt_Tooltip); ImGui.SameLine(0, spacing); using (ImRaii.Disabled(InputPath.Length == 0 || IsExporting)) @@ -168,7 +176,7 @@ public class DbViewer : Window new Notification { Title = "Chat2 Json Export", - Content = "Loading logs ...", + Content = Language.ChatExport_Initial, Type = NotificationType.Info, Minimized = false, UserDismissable = false, @@ -180,13 +188,15 @@ public class DbViewer : Window } if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) - ImGui.SetTooltip("Export the message history to a json file."); + ImGui.SetTooltip(Language.Export_Json_Tooltip); var width = 350 * ImGuiHelpers.GlobalScale; var loadingIndicator = IsProcessing && ProcessingStart < Environment.TickCount64; ImGui.AlignTextToFramePadding(); ImGui.TextUnformatted(string.Format(Language.DbViewer_Page, CurrentPage, totalPages, Count, loadingIndicator ? Language.DbViewer_LoadingIndicator : "")); + ImGuiUtil.DrawArrows(ref CurrentPage, 1, totalPages, spacing, tooltipLeft: Language.Page_ArrowLeft_Tooltip, tooltipRight: Language.Page_ArrowRight_Tooltip); + ImGui.SameLine(ImGui.GetContentRegionMax().X - width); ImGui.SetNextItemWidth(width); if (ImGui.InputTextWithHint("##searchbar", Language.DbViewer_SearcHint, ref SimpleSearchTerm, 30)) @@ -222,6 +232,7 @@ public class DbViewer : Window Messages = rangeMessageEnumerator.ToArray(); Filtered = Filter(Messages); + NeedsScrollReset = true; } catch (Exception ex) { @@ -246,6 +257,12 @@ public class DbViewer : Window if (!child.Success) return; + if (NeedsScrollReset) + { + NeedsScrollReset = false; + ImGui.SetScrollY(0.0f); + } + using var table = ImRaii.Table("##messageHistory", 4, ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg | ImGuiTableFlags.Resizable); if (!table.Success) return; @@ -281,6 +298,7 @@ public class DbViewer : Window private void ChannelSelection() { const string addTabPopup = "add-channel-popup"; + var spacing = 3.0f * ImGuiHelpers.GlobalScale; if (ImGui.Button("Channels")) ImGui.OpenPopup(addTabPopup); @@ -306,7 +324,7 @@ public class DbViewer : Window if (ImGui.IsItemHovered()) ImGui.SetTooltip("Select all"); - ImGui.SameLine(); + ImGui.SameLine(0, spacing); if (ImGuiComponents.IconButton(FontAwesomeIcon.Times)) { @@ -317,7 +335,7 @@ public class DbViewer : Window if (ImGui.IsItemHovered()) ImGui.SetTooltip("Unselect all"); - ImGui.SameLine(); + ImGui.SameLine(0, spacing); using var headerNode = ImRaii.TreeNode(header); if (!headerNode.Success) diff --git a/ChatTwo/Util/DatePicker.cs b/ChatTwo/Util/DatePicker.cs index 47d9442..58fb068 100644 --- a/ChatTwo/Util/DatePicker.cs +++ b/ChatTwo/Util/DatePicker.cs @@ -65,6 +65,9 @@ public static class DateWidget ImGui.SameLine(0, 3.0f * ImGuiHelpers.GlobalScale); ImGuiUtil.IconButton(FontAwesomeIcon.Calendar, id.ToString()); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip(Language.DatePicker_Tooltip); + if (DatePicker(label, ref date, closeWhenMouseLeavesIt)) dateString = date.ToString(format); } diff --git a/ChatTwo/Util/ImGuiUtil.cs b/ChatTwo/Util/ImGuiUtil.cs index 5712ba6..75b17fb 100755 --- a/ChatTwo/Util/ImGuiUtil.cs +++ b/ChatTwo/Util/ImGuiUtil.cs @@ -391,7 +391,7 @@ internal static class ImGuiUtil } } - public static void DrawArrows(ref int selected, int min, int max, float spacing, int id = 0) + public static void DrawArrows(ref int selected, int min, int max, float spacing, int id = 0, string? tooltipLeft = null, string? tooltipRight = null) { // Prevents changing values from triggering EndDisable var isMin = selected == min; @@ -404,12 +404,19 @@ internal static class ImGuiUtil selected--; } + if (tooltipLeft != null && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) + ImGui.SetTooltip(tooltipLeft); + ImGui.SameLine(0, spacing); + using (ImRaii.Disabled(isMax)) { if (IconButton(FontAwesomeIcon.ArrowRight, id+1.ToString())) selected++; } + + if (tooltipRight != null && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) + ImGui.SetTooltip(tooltipRight); } public static void WrappedTextWithColor(Vector4 color, string text) @@ -544,6 +551,8 @@ internal static class ImGuiUtil public static void ChannelSelector(string headerText, Dictionary chatCodes) { + var spacing = 3.0f * ImGuiHelpers.GlobalScale; + using var channelNode = ImRaii.TreeNode(headerText); if (!channelNode.Success) return; @@ -561,7 +570,7 @@ internal static class ImGuiUtil if (ImGui.IsItemHovered()) ImGui.SetTooltip(Language.ChannelSelector_Select); - ImGui.SameLine(); + ImGui.SameLine(0, spacing); if (ImGuiComponents.IconButton(FontAwesomeIcon.Times)) { @@ -572,7 +581,7 @@ internal static class ImGuiUtil if (ImGui.IsItemHovered()) ImGui.SetTooltip(Language.ChannelSelector_Unselect); - ImGui.SameLine(); + ImGui.SameLine(0, spacing); using var headerNode = ImRaii.TreeNode(header); if (!headerNode.Success)