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>
+34 -28
View File
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
@@ -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();