mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 20:24:16 +01:00
Convert PluginStatWindow to ImRaii (#2268)
Currently the Hooks tab asserts because of a missing ImGui.EndTabItem. Instead of just adding that, I took the opportunity to convert everything to use ImRaii instead.
This commit is contained in:
parent
85b77226e9
commit
09f519ce6f
1 changed files with 219 additions and 216 deletions
|
|
@ -8,6 +8,7 @@ using Dalamud.Hooking.Internal;
|
|||
using Dalamud.Interface.Components;
|
||||
using Dalamud.Interface.ImGuiNotification;
|
||||
using Dalamud.Interface.ImGuiNotification.Internal;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Plugin.Internal;
|
||||
using Dalamud.Plugin.Internal.Types;
|
||||
|
|
@ -44,10 +45,13 @@ internal class PluginStatWindow : Window
|
|||
{
|
||||
var pluginManager = Service<PluginManager>.Get();
|
||||
|
||||
if (!ImGui.BeginTabBar("Stat Tabs"))
|
||||
using var tabBar = ImRaii.TabBar("Stat Tabs");
|
||||
if (!tabBar)
|
||||
return;
|
||||
|
||||
if (ImGui.BeginTabItem("Draw times"))
|
||||
using (var tabItem = ImRaii.TabItem("Draw times"))
|
||||
{
|
||||
if (tabItem)
|
||||
{
|
||||
var doStats = UiBuilder.DoStats;
|
||||
|
||||
|
|
@ -88,7 +92,7 @@ internal class PluginStatWindow : Window
|
|||
ref this.drawSearchText,
|
||||
500);
|
||||
|
||||
if (ImGui.BeginTable(
|
||||
using var table = ImRaii.Table(
|
||||
"##PluginStatsDrawTimes",
|
||||
4,
|
||||
ImGuiTableFlags.RowBg
|
||||
|
|
@ -97,7 +101,9 @@ internal class PluginStatWindow : Window
|
|||
| ImGuiTableFlags.Resizable
|
||||
| ImGuiTableFlags.ScrollY
|
||||
| ImGuiTableFlags.Reorderable
|
||||
| ImGuiTableFlags.Hideable))
|
||||
| ImGuiTableFlags.Hideable);
|
||||
|
||||
if (table)
|
||||
{
|
||||
ImGui.TableSetupScrollFreeze(0, 1);
|
||||
ImGui.TableSetupColumn("Plugin");
|
||||
|
|
@ -148,15 +154,14 @@ internal class PluginStatWindow : Window
|
|||
: "-");
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui.BeginTabItem("Framework times"))
|
||||
using (var tabItem = ImRaii.TabItem("Framework times"))
|
||||
{
|
||||
if (tabItem)
|
||||
{
|
||||
var doStats = Framework.StatsEnabled;
|
||||
|
||||
|
|
@ -189,7 +194,7 @@ internal class PluginStatWindow : Window
|
|||
ref this.frameworkSearchText,
|
||||
500);
|
||||
|
||||
if (ImGui.BeginTable(
|
||||
using var table = ImRaii.Table(
|
||||
"##PluginStatsFrameworkTimes",
|
||||
4,
|
||||
ImGuiTableFlags.RowBg
|
||||
|
|
@ -198,7 +203,8 @@ internal class PluginStatWindow : Window
|
|||
| ImGuiTableFlags.Resizable
|
||||
| ImGuiTableFlags.ScrollY
|
||||
| ImGuiTableFlags.Reorderable
|
||||
| ImGuiTableFlags.Hideable))
|
||||
| ImGuiTableFlags.Hideable);
|
||||
if (table)
|
||||
{
|
||||
ImGui.TableSetupScrollFreeze(0, 1);
|
||||
ImGui.TableSetupColumn("Method", ImGuiTableColumnFlags.None, 250);
|
||||
|
|
@ -250,15 +256,14 @@ internal class PluginStatWindow : Window
|
|||
ImGui.TableNextColumn();
|
||||
ImGui.Text($"{handlerHistory.Value.Average():F4}ms");
|
||||
}
|
||||
|
||||
ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui.BeginTabItem("Hooks"))
|
||||
using (var tabItem = ImRaii.TabItem("Hooks"))
|
||||
{
|
||||
if (tabItem)
|
||||
{
|
||||
ImGui.Checkbox("Show Dalamud Hooks", ref this.showDalamudHooks);
|
||||
|
||||
|
|
@ -268,7 +273,7 @@ internal class PluginStatWindow : Window
|
|||
ref this.hookSearchText,
|
||||
500);
|
||||
|
||||
if (ImGui.BeginTable(
|
||||
using var table = ImRaii.Table(
|
||||
"##PluginStatsHooks",
|
||||
4,
|
||||
ImGuiTableFlags.RowBg
|
||||
|
|
@ -276,7 +281,8 @@ internal class PluginStatWindow : Window
|
|||
| ImGuiTableFlags.Resizable
|
||||
| ImGuiTableFlags.ScrollY
|
||||
| ImGuiTableFlags.Reorderable
|
||||
| ImGuiTableFlags.Hideable))
|
||||
| ImGuiTableFlags.Hideable);
|
||||
if (table)
|
||||
{
|
||||
ImGui.TableSetupScrollFreeze(0, 1);
|
||||
ImGui.TableSetupColumn("Detour Method", ImGuiTableColumnFlags.None, 250);
|
||||
|
|
@ -345,11 +351,8 @@ internal class PluginStatWindow : Window
|
|||
Log.Error(ex, "Error drawing hooks in plugin stats");
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndTabBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue