- Improve draw performance by adjusting if assumption

This commit is contained in:
Infi
2025-06-22 12:49:05 +02:00
parent f3783e9abf
commit e43167101b
2 changed files with 15 additions and 20 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<Project Sdk="Dalamud.NET.Sdk/12.0.2"> <Project Sdk="Dalamud.NET.Sdk/12.0.2">
<PropertyGroup> <PropertyGroup>
<Version>1.30.4</Version> <Version>1.30.5</Version>
<TargetFramework>net9.0-windows</TargetFramework> <TargetFramework>net9.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
+14 -19
View File
@@ -996,8 +996,7 @@ public sealed class ChatLogWindow : Window
if (!child.Success) if (!child.Success)
return; return;
var useTable = tab.DisplayTimestamp && Plugin.Config.PrettierTimestamps; if (tab.DisplayTimestamp && Plugin.Config.PrettierTimestamps)
if (useTable)
DrawLogTableStyle(tab, handler, switchedTab); DrawLogTableStyle(tab, handler, switchedTab);
else else
DrawLogNormalStyle(tab, handler, switchedTab); DrawLogNormalStyle(tab, handler, switchedTab);
@@ -1006,9 +1005,7 @@ public sealed class ChatLogWindow : Window
private void DrawLogNormalStyle(Tab tab, PayloadHandler handler, bool switchedTab) private void DrawLogNormalStyle(Tab tab, PayloadHandler handler, bool switchedTab)
{ {
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero)) using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero))
{
DrawMessages(tab, handler, false); DrawMessages(tab, handler, false);
}
if (switchedTab || ImGui.GetScrollY() >= ImGui.GetScrollMaxY()) if (switchedTab || ImGui.GetScrollY() >= ImGui.GetScrollMaxY())
ImGui.SetScrollHereY(1f); ImGui.SetScrollHereY(1f);
@@ -1094,7 +1091,7 @@ public sealed class ChatLogWindow : Window
{ {
ImGui.SameLine(); ImGui.SameLine();
DrawChunks( DrawChunks(
new[] { new TextChunk(ChunkSource.None, null, $" ({sameCount + 1}x)") { FallbackColour = ChatType.System, Italic = true, } }, [new TextChunk(ChunkSource.None, null, $" ({sameCount + 1}x)") { FallbackColour = ChatType.System, Italic = true, }],
true, true,
handler, handler,
ImGui.GetContentRegionAvail().X ImGui.GetContentRegionAvail().X
@@ -1145,24 +1142,22 @@ public sealed class ChatLogWindow : Window
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Dummy(new Vector2(10f, height.Value)); ImGui.Dummy(new Vector2(10f, height.Value));
message.IsVisible[tab.Identifier] = ImGui.IsItemVisible();
if (message.IsVisible[tab.Identifier]) var nowVisible = ImGui.IsItemVisible();
{ if (!nowVisible)
if (isTable)
ImGui.TableSetColumnIndex(0);
ImGui.SetCursorPos(beforeDummy);
}
else
{
continue; continue;
}
if (isTable)
ImGui.TableSetColumnIndex(0);
ImGui.SetCursorPos(beforeDummy);
message.IsVisible[tab.Identifier] = nowVisible;
} }
if (tab.DisplayTimestamp) if (tab.DisplayTimestamp)
{ {
var timestamp = message.Date.ToLocalTime().ToString("t", !Plugin.Config.Use24HourClock ? null : CultureInfo.CreateSpecificCulture("es-ES")); var localTime = message.Date.ToLocalTime();
var timestamp = localTime.ToString("t", !Plugin.Config.Use24HourClock ? null : CultureInfo.CreateSpecificCulture("es-ES"));
if (isTable) if (isTable)
{ {
if (!Plugin.Config.HideSameTimestamps || timestamp != lastTimestamp) if (!Plugin.Config.HideSameTimestamps || timestamp != lastTimestamp)
@@ -1175,7 +1170,7 @@ public sealed class ChatLogWindow : Window
// tooltip string for all visible items on every // tooltip string for all visible items on every
// frame. // frame.
if (ImGui.IsItemHovered()) if (ImGui.IsItemHovered())
ImGuiUtil.Tooltip(message.Date.ToLocalTime().ToString("F")); ImGuiUtil.Tooltip(localTime.ToString("F"));
} }
else else
{ {
@@ -1203,7 +1198,7 @@ public sealed class ChatLogWindow : Window
// We need to draw something otherwise the item visibility check below won't work. // We need to draw something otherwise the item visibility check below won't work.
if (message.Content.Count == 0) if (message.Content.Count == 0)
DrawChunks(new[] { new TextChunk(ChunkSource.Content, null, " ") }, true, handler, lineWidth); DrawChunks([new TextChunk(ChunkSource.Content, null, " ")], true, handler, lineWidth);
else else
DrawChunks(message.Content, true, handler, lineWidth); DrawChunks(message.Content, true, handler, lineWidth);