- Fix imgui asserts on table

This commit is contained in:
Infi
2025-09-19 22:49:51 +02:00
parent efdf69f782
commit 9b3e3f79e3
3 changed files with 29 additions and 34 deletions
+2 -2
View File
@@ -1259,8 +1259,8 @@ public sealed class ChatLogWindow : Window
if (!tabTable.Success) if (!tabTable.Success)
return; return;
ImGui.TableSetupColumn("tabs", ImGuiTableColumnFlags.None, 1); ImGui.TableSetupColumn("tabs", ImGuiTableColumnFlags.WidthStretch, 1);
ImGui.TableSetupColumn("chat", ImGuiTableColumnFlags.None, 4); ImGui.TableSetupColumn("chat", ImGuiTableColumnFlags.WidthStretch, 4);
ImGui.TableNextColumn(); ImGui.TableNextColumn();
+18 -23
View File
@@ -257,33 +257,33 @@ public class SeStringDebugger : Window
var style = ImGui.GetStyle(); var style = ImGui.GetStyle();
ImGui.Text($"{name}:"); ImGui.Text($"{name}:");
ImGui.Indent(style.IndentSpacing); using var indent = ImRaii.PushIndent(style.IndentSpacing);
if (!ImGui.BeginTable($"##chat3-{name}", 2, 0)) using (var table = ImRaii.Table($"##chat2-{name}", 2))
{ {
ImGui.EndTable(); if (!table.Success)
ImGui.Unindent(style.IndentSpacing);
return; return;
}
ImGui.TableSetupColumn($"##chat3-{name}-key", 0, 0.4f); ImGui.TableSetupColumn($"##chat2-{name}-key", ImGuiTableColumnFlags.WidthStretch, 0.4f);
ImGui.TableSetupColumn($"##chat3-{name}-value"); ImGui.TableSetupColumn($"##chat2-{name}-value");
for (var i = 0; i < metadata.Count; i++) for (var i = 0; i < metadata.Count; i++)
{ {
using var id = ImRaii.PushId(i);
var (key, value) = metadata.ElementAt(i); var (key, value) = metadata.ElementAt(i);
ImGui.PushID(i);
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text(key); ImGui.Text(key);
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGuiTextVisibleWhitespace(value); ImGuiTextVisibleWhitespace(value);
ImGui.PopID();
} }
ImGui.EndTable(); }
ImGui.Unindent(style.IndentSpacing);
ImGui.NewLine(); ImGui.NewLine();
} }
// ImGuiTextVisibleWhitespace replaces leading and trailing whitespace with // ImGuiTextVisibleWhitespace replaces leading and trailing whitespace with
// visible characters. The extra characters are rendered with a muted font. // visible characters. The extra characters are rendered with a muted font.
private static void ImGuiTextVisibleWhitespace(string? original, bool wrap = true) private static void ImGuiTextVisibleWhitespace(string? original)
{ {
if (string.IsNullOrEmpty(original)) if (string.IsNullOrEmpty(original))
{ {
@@ -298,33 +298,28 @@ public class SeStringDebugger : Window
using var pushedStyle = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0)); using var pushedStyle = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
void WriteText(string wText)
{
if (wrap)
ImGui.TextWrapped(wText);
else
ImGui.TextUnformatted(wText);
}
while (start < end && char.IsWhiteSpace(text[start])) while (start < end && char.IsWhiteSpace(text[start]))
start++; start++;
if (start > 0) if (start > 0)
{ {
using var pushedColor = ImRaii.PushColor(ImGuiCol.Text, new Vector4(1, 1, 1, 0.5f)); using var pushedColor = ImRaii.PushColor(ImGuiCol.Text, new Vector4(1, 1, 1, 0.5f));
WriteText(new string('_', start)); ImGui.TextWrapped(new string('_', start));
ImGui.SameLine(); ImGui.SameLine();
} }
while (end > start && char.IsWhiteSpace(text[end - 1])) while (end > start && char.IsWhiteSpace(text[end - 1]))
end--; end--;
WriteText(text[start..end]); ImGui.TextWrapped(text[start..end]);
if (end < text.Length) if (end < text.Length)
{ {
ImGui.SameLine(); ImGui.SameLine();
using var pushedColor = ImRaii.PushColor(ImGuiCol.Text, new Vector4(1, 1, 1, 0.5f)); using var pushedColor = ImRaii.PushColor(ImGuiCol.Text, new Vector4(1, 1, 1, 0.5f));
WriteText(new string('_', text.Length - end)); ImGui.TextWrapped(new string('_', text.Length - end));
} }
} }
} }
+1 -1
View File
@@ -62,7 +62,7 @@ internal sealed class Emote : ISettingsTab
if (table) if (table)
{ {
ImGui.TableSetupColumn(Language.Options_Emote_EmoteTable); ImGui.TableSetupColumn(Language.Options_Emote_EmoteTable);
ImGui.TableSetupColumn("##Del", 0, 0.07f); ImGui.TableSetupColumn("##Del", ImGuiTableColumnFlags.WidthStretch, 0.07f);
ImGui.TableHeadersRow(); ImGui.TableHeadersRow();