Temp fix for FPS drops with too many messages rendered

- Also replaces TextWrap with an ImRaii using version
This commit is contained in:
Infi
2024-05-13 15:24:51 +02:00
parent b7c6c1da5a
commit 26e993be67
5 changed files with 73 additions and 21 deletions
+30
View File
@@ -417,4 +417,34 @@ internal static class ImGuiUtil
return result != 0 || key == VirtualKey.NO_KEY;
}
private struct EndUnconditionally(Action endAction, bool success) : ImRaii.IEndObject
{
private Action EndAction { get; } = endAction;
public bool Success { get; } = success;
public bool Disposed { get; private set; } = false;
public void Dispose()
{
if (!Disposed)
{
EndAction();
Disposed = true;
}
}
}
public static ImRaii.IEndObject TextWrapPos()
{
ImGui.PushTextWrapPos();
return new EndUnconditionally(ImGui.PopTextWrapPos, true);
}
public static ImRaii.IEndObject TextWrapPos(float wrapLocalPosX)
{
ImGui.PushTextWrapPos(wrapLocalPosX);
return new EndUnconditionally(ImGui.PopTextWrapPos, true);
}
}