mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-14 12:44: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.Components;
|
||||||
using Dalamud.Interface.ImGuiNotification;
|
using Dalamud.Interface.ImGuiNotification;
|
||||||
using Dalamud.Interface.ImGuiNotification.Internal;
|
using Dalamud.Interface.ImGuiNotification.Internal;
|
||||||
|
using Dalamud.Interface.Utility.Raii;
|
||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
using Dalamud.Plugin.Internal;
|
using Dalamud.Plugin.Internal;
|
||||||
using Dalamud.Plugin.Internal.Types;
|
using Dalamud.Plugin.Internal.Types;
|
||||||
|
|
@ -44,10 +45,13 @@ internal class PluginStatWindow : Window
|
||||||
{
|
{
|
||||||
var pluginManager = Service<PluginManager>.Get();
|
var pluginManager = Service<PluginManager>.Get();
|
||||||
|
|
||||||
if (!ImGui.BeginTabBar("Stat Tabs"))
|
using var tabBar = ImRaii.TabBar("Stat Tabs");
|
||||||
|
if (!tabBar)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ImGui.BeginTabItem("Draw times"))
|
using (var tabItem = ImRaii.TabItem("Draw times"))
|
||||||
|
{
|
||||||
|
if (tabItem)
|
||||||
{
|
{
|
||||||
var doStats = UiBuilder.DoStats;
|
var doStats = UiBuilder.DoStats;
|
||||||
|
|
||||||
|
|
@ -88,7 +92,7 @@ internal class PluginStatWindow : Window
|
||||||
ref this.drawSearchText,
|
ref this.drawSearchText,
|
||||||
500);
|
500);
|
||||||
|
|
||||||
if (ImGui.BeginTable(
|
using var table = ImRaii.Table(
|
||||||
"##PluginStatsDrawTimes",
|
"##PluginStatsDrawTimes",
|
||||||
4,
|
4,
|
||||||
ImGuiTableFlags.RowBg
|
ImGuiTableFlags.RowBg
|
||||||
|
|
@ -97,7 +101,9 @@ internal class PluginStatWindow : Window
|
||||||
| ImGuiTableFlags.Resizable
|
| ImGuiTableFlags.Resizable
|
||||||
| ImGuiTableFlags.ScrollY
|
| ImGuiTableFlags.ScrollY
|
||||||
| ImGuiTableFlags.Reorderable
|
| ImGuiTableFlags.Reorderable
|
||||||
| ImGuiTableFlags.Hideable))
|
| ImGuiTableFlags.Hideable);
|
||||||
|
|
||||||
|
if (table)
|
||||||
{
|
{
|
||||||
ImGui.TableSetupScrollFreeze(0, 1);
|
ImGui.TableSetupScrollFreeze(0, 1);
|
||||||
ImGui.TableSetupColumn("Plugin");
|
ImGui.TableSetupColumn("Plugin");
|
||||||
|
|
@ -148,15 +154,14 @@ internal class PluginStatWindow : Window
|
||||||
: "-");
|
: "-");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ImGui.EndTable();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndTabItem();
|
using (var tabItem = ImRaii.TabItem("Framework times"))
|
||||||
}
|
{
|
||||||
|
if (tabItem)
|
||||||
if (ImGui.BeginTabItem("Framework times"))
|
|
||||||
{
|
{
|
||||||
var doStats = Framework.StatsEnabled;
|
var doStats = Framework.StatsEnabled;
|
||||||
|
|
||||||
|
|
@ -189,7 +194,7 @@ internal class PluginStatWindow : Window
|
||||||
ref this.frameworkSearchText,
|
ref this.frameworkSearchText,
|
||||||
500);
|
500);
|
||||||
|
|
||||||
if (ImGui.BeginTable(
|
using var table = ImRaii.Table(
|
||||||
"##PluginStatsFrameworkTimes",
|
"##PluginStatsFrameworkTimes",
|
||||||
4,
|
4,
|
||||||
ImGuiTableFlags.RowBg
|
ImGuiTableFlags.RowBg
|
||||||
|
|
@ -198,7 +203,8 @@ internal class PluginStatWindow : Window
|
||||||
| ImGuiTableFlags.Resizable
|
| ImGuiTableFlags.Resizable
|
||||||
| ImGuiTableFlags.ScrollY
|
| ImGuiTableFlags.ScrollY
|
||||||
| ImGuiTableFlags.Reorderable
|
| ImGuiTableFlags.Reorderable
|
||||||
| ImGuiTableFlags.Hideable))
|
| ImGuiTableFlags.Hideable);
|
||||||
|
if (table)
|
||||||
{
|
{
|
||||||
ImGui.TableSetupScrollFreeze(0, 1);
|
ImGui.TableSetupScrollFreeze(0, 1);
|
||||||
ImGui.TableSetupColumn("Method", ImGuiTableColumnFlags.None, 250);
|
ImGui.TableSetupColumn("Method", ImGuiTableColumnFlags.None, 250);
|
||||||
|
|
@ -250,15 +256,14 @@ internal class PluginStatWindow : Window
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text($"{handlerHistory.Value.Average():F4}ms");
|
ImGui.Text($"{handlerHistory.Value.Average():F4}ms");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ImGui.EndTable();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndTabItem();
|
using (var tabItem = ImRaii.TabItem("Hooks"))
|
||||||
}
|
{
|
||||||
|
if (tabItem)
|
||||||
if (ImGui.BeginTabItem("Hooks"))
|
|
||||||
{
|
{
|
||||||
ImGui.Checkbox("Show Dalamud Hooks", ref this.showDalamudHooks);
|
ImGui.Checkbox("Show Dalamud Hooks", ref this.showDalamudHooks);
|
||||||
|
|
||||||
|
|
@ -268,7 +273,7 @@ internal class PluginStatWindow : Window
|
||||||
ref this.hookSearchText,
|
ref this.hookSearchText,
|
||||||
500);
|
500);
|
||||||
|
|
||||||
if (ImGui.BeginTable(
|
using var table = ImRaii.Table(
|
||||||
"##PluginStatsHooks",
|
"##PluginStatsHooks",
|
||||||
4,
|
4,
|
||||||
ImGuiTableFlags.RowBg
|
ImGuiTableFlags.RowBg
|
||||||
|
|
@ -276,7 +281,8 @@ internal class PluginStatWindow : Window
|
||||||
| ImGuiTableFlags.Resizable
|
| ImGuiTableFlags.Resizable
|
||||||
| ImGuiTableFlags.ScrollY
|
| ImGuiTableFlags.ScrollY
|
||||||
| ImGuiTableFlags.Reorderable
|
| ImGuiTableFlags.Reorderable
|
||||||
| ImGuiTableFlags.Hideable))
|
| ImGuiTableFlags.Hideable);
|
||||||
|
if (table)
|
||||||
{
|
{
|
||||||
ImGui.TableSetupScrollFreeze(0, 1);
|
ImGui.TableSetupScrollFreeze(0, 1);
|
||||||
ImGui.TableSetupColumn("Detour Method", ImGuiTableColumnFlags.None, 250);
|
ImGui.TableSetupColumn("Detour Method", ImGuiTableColumnFlags.None, 250);
|
||||||
|
|
@ -345,11 +351,8 @@ internal class PluginStatWindow : Window
|
||||||
Log.Error(ex, "Error drawing hooks in plugin stats");
|
Log.Error(ex, "Error drawing hooks in plugin stats");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndTable();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ImGui.EndTabBar();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue