Add option to limit the amount of shown log lines

This commit is contained in:
Harold Iedema
2024-04-18 16:13:46 +02:00
parent 04b1063972
commit e0793a51da
7 changed files with 80 additions and 29 deletions
+2
View File
@@ -39,6 +39,7 @@ internal class Configuration : IPluginConfiguration
public bool SortAutoTranslate; public bool SortAutoTranslate;
public bool CollapseDuplicateMessages; public bool CollapseDuplicateMessages;
public bool PlaySounds = true; public bool PlaySounds = true;
public int MaxLinesToRender = 10_000;
public bool FontsEnabled = true; public bool FontsEnabled = true;
public ExtraGlyphRanges ExtraGlyphRanges = 0; public ExtraGlyphRanges ExtraGlyphRanges = 0;
@@ -83,6 +84,7 @@ internal class Configuration : IPluginConfiguration
SortAutoTranslate = other.SortAutoTranslate; SortAutoTranslate = other.SortAutoTranslate;
CollapseDuplicateMessages = other.CollapseDuplicateMessages; CollapseDuplicateMessages = other.CollapseDuplicateMessages;
PlaySounds = other.PlaySounds; PlaySounds = other.PlaySounds;
MaxLinesToRender = other.MaxLinesToRender;
FontsEnabled = other.FontsEnabled; FontsEnabled = other.FontsEnabled;
ExtraGlyphRanges = other.ExtraGlyphRanges; ExtraGlyphRanges = other.ExtraGlyphRanges;
FontSize = other.FontSize; FontSize = other.FontSize;
+18
View File
@@ -2093,6 +2093,24 @@ namespace ChatTwo.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Limits the amount of log lines to show in the chat window. This may slightly improve performance..
/// </summary>
internal static string Options_MaxLinesToShow_Description {
get {
return ResourceManager.GetString("Options_MaxLinesToShow_Description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Maximum amount of log lines to display in the chat window.
/// </summary>
internal static string Options_MaxLinesToShow_Name {
get {
return ResourceManager.GetString("Options_MaxLinesToShow_Name", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Miscellaneous. /// Looks up a localized string similar to Miscellaneous.
/// </summary> /// </summary>
+6
View File
@@ -841,4 +841,10 @@
<data name="Options_CollapseDuplicateMessages_Description"> <data name="Options_CollapseDuplicateMessages_Description">
<value>Vervang opeenvolgende dubbele berichten door een teller die is toegevoegd aan het eerste exemplaar van het bericht.</value> <value>Vervang opeenvolgende dubbele berichten door een teller die is toegevoegd aan het eerste exemplaar van het bericht.</value>
</data> </data>
<data name="Options_MaxLinesToShow_Name" xml:space="preserve">
<value>Maximum aantal regels om te tonen in het chat venster</value>
</data>
<data name="Options_MaxLinesToShow_Description" xml:space="preserve">
<value>Limiteer het maximum aantal regels die worden getoont in het chatvester.</value>
</data>
</root> </root>
+6
View File
@@ -994,4 +994,10 @@
<data name="Options_PlaySounds_Description" xml:space="preserve"> <data name="Options_PlaySounds_Description" xml:space="preserve">
<value>Play sounds on interaction.</value> <value>Play sounds on interaction.</value>
</data> </data>
<data name="Options_MaxLinesToShow_Name" xml:space="preserve">
<value>Maximum amount of log lines to display in the chat window</value>
</data>
<data name="Options_MaxLinesToShow_Description" xml:space="preserve">
<value>Limits the amount of log lines to show in the chat window. This may slightly improve performance.</value>
</data>
</root> </root>
+5 -1
View File
@@ -874,7 +874,11 @@ public sealed class ChatLogWindow : Window, IUiComponent
var lastTimestamp = string.Empty; var lastTimestamp = string.Empty;
int? lastMessageHash = null; int? lastMessageHash = null;
var sameCount = 0; var sameCount = 0;
for (var i = 0; i < tab.Messages.Count; i++)
int maxLines = Plugin.Config.MaxLinesToRender;
int startLine = tab.Messages.Count > maxLines ? tab.Messages.Count - maxLines : 0;
for (int i = startLine; i < tab.Messages.Count; i++)
{ {
var message = tab.Messages[i]; var message = tab.Messages[i];
+6
View File
@@ -87,6 +87,12 @@ internal sealed class Display : ISettingsTab {
ImGuiUtil.DragFloatVertical(Language.Options_WindowOpacity_Name, ref Mutable.WindowAlpha, .25f, 0f, 100f, $"{Mutable.WindowAlpha:N2}%%", ImGuiSliderFlags.AlwaysClamp); ImGuiUtil.DragFloatVertical(Language.Options_WindowOpacity_Name, ref Mutable.WindowAlpha, .25f, 0f, 100f, $"{Mutable.WindowAlpha:N2}%%", ImGuiSliderFlags.AlwaysClamp);
ImGui.Spacing(); ImGui.Spacing();
if (ImGuiUtil.InputIntVertical(Language.Options_MaxLinesToShow_Name, Language.Options_MaxLinesToShow_Description, ref Mutable.MaxLinesToRender)) {
Mutable.MaxLinesToRender = Math.Clamp(Mutable.MaxLinesToRender, 1, 10_000);
}
ImGui.Spacing();
ImGuiUtil.OptionCheckbox(ref Mutable.CanMove, Language.Options_CanMove_Name); ImGuiUtil.OptionCheckbox(ref Mutable.CanMove, Language.Options_CanMove_Name);
ImGui.Spacing(); ImGui.Spacing();
+9
View File
@@ -234,6 +234,15 @@ internal static class ImGuiUtil {
return r; return r;
} }
internal static bool InputIntVertical(string label, string description, ref int value, int step = 1, int stepFast = 100, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) {
ImGui.TextUnformatted(label);
ImGui.SetNextItemWidth(-1);
var r = ImGui.InputInt($"##{label}", ref value, step, stepFast, flags);
HelpText(description);
return r;
}
internal static bool CtrlShiftButton(string label, string tooltip = "") internal static bool CtrlShiftButton(string label, string tooltip = "")
{ {
var io = ImGui.GetIO(); var io = ImGui.GetIO();