fix a crash DRT didnt notice 👀
This commit is contained in:
parent
fcf4f80b34
commit
3b2cef2636
@ -7,11 +7,11 @@ using FDK;
|
|||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using SampleFramework;
|
using SampleFramework;
|
||||||
|
|
||||||
namespace OpenTaiko;
|
namespace OpenTaiko;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FOR DEBUGGING! This class is intended for developers only!
|
FOR DEBUGGING! This class is intended for developers only!
|
||||||
*/
|
*/
|
||||||
public static class ImGuiDebugWindow {
|
public static class ImGuiDebugWindow {
|
||||||
private static bool showImGuiDemoWindow = false;
|
private static bool showImGuiDemoWindow = false;
|
||||||
private static Assembly assemblyinfo = Assembly.GetExecutingAssembly();
|
private static Assembly assemblyinfo = Assembly.GetExecutingAssembly();
|
||||||
@ -25,8 +25,8 @@ public static class ImGuiDebugWindow {
|
|||||||
private static readonly string[] sortNames = ["Memory Usage (Highest->Lowest)", "Memory Usage (Lowest->Highest)", "Pointer ID"];
|
private static readonly string[] sortNames = ["Memory Usage (Highest->Lowest)", "Memory Usage (Lowest->Highest)", "Pointer ID"];
|
||||||
private static string reloadTexPath = "";
|
private static string reloadTexPath = "";
|
||||||
public static void Draw() {
|
public static void Draw() {
|
||||||
if (SampleFramework.Game.ImGuiController == null) return;
|
if (SampleFramework.Game.ImGuiController == null) return;
|
||||||
|
|
||||||
#region Fetch allocated memory
|
#region Fetch allocated memory
|
||||||
if (SoundManager.PlayTimer.SystemTimeMs - memoryReadTimer > 5000) {
|
if (SoundManager.PlayTimer.SystemTimeMs - memoryReadTimer > 5000) {
|
||||||
memoryReadTimer = SoundManager.PlayTimer.SystemTimeMs;
|
memoryReadTimer = SoundManager.PlayTimer.SystemTimeMs;
|
||||||
@ -35,39 +35,39 @@ public static class ImGuiDebugWindow {
|
|||||||
pagedmemory = process.PagedMemorySize64;
|
pagedmemory = process.PagedMemorySize64;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
ImGui.SetNextWindowPos(new System.Numerics.Vector2(0, 0), ImGuiCond.FirstUseEver);
|
ImGui.SetNextWindowPos(new System.Numerics.Vector2(0, 0), ImGuiCond.FirstUseEver);
|
||||||
ImGui.SetNextWindowSize(new System.Numerics.Vector2(400,300), ImGuiCond.FirstUseEver);
|
ImGui.SetNextWindowSize(new System.Numerics.Vector2(400, 300), ImGuiCond.FirstUseEver);
|
||||||
if (ImGui.Begin("Debug Window (Toggle Visbility with F11)###DEBUG")) {
|
if (ImGui.Begin("Debug Window (Toggle Visbility with F11)###DEBUG")) {
|
||||||
|
|
||||||
#region Debug Info
|
#region Debug Info
|
||||||
ImGui.Checkbox("Show ImGui Demo Window", ref showImGuiDemoWindow);
|
ImGui.Checkbox("Show ImGui Demo Window", ref showImGuiDemoWindow);
|
||||||
if (showImGuiDemoWindow) { ImGui.ShowDemoWindow(); }
|
if (showImGuiDemoWindow) { ImGui.ShowDemoWindow(); }
|
||||||
|
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
ImGui.Text($"Game Version: {OpenTaiko.VERSION}");
|
ImGui.Text($"Game Version: {OpenTaiko.VERSION}");
|
||||||
ImGui.Text($"Allocated Memory: {pagedmemory} bytes ({String.Format("{0:0.###}",(float)pagedmemory / (1024 * 1024 * 1024))}GB)");
|
ImGui.Text($"Allocated Memory: {pagedmemory} bytes ({String.Format("{0:0.###}", (float)pagedmemory / (1024 * 1024 * 1024))}GB)");
|
||||||
ImGui.Text($"FPS: {(OpenTaiko.FPS != null ? OpenTaiko.FPS.NowFPS : "???")}");
|
ImGui.Text($"FPS: {(OpenTaiko.FPS != null ? OpenTaiko.FPS.NowFPS : "???")}");
|
||||||
ImGui.Text("Current Stage: " + OpenTaiko.r現在のステージ.eStageID.ToString() + " (StageID " + ((int)OpenTaiko.r現在のステージ.eStageID).ToString() + ")");
|
ImGui.Text("Current Stage: " + OpenTaiko.r現在のステージ.eStageID.ToString() + " (StageID " + ((int)OpenTaiko.r現在のステージ.eStageID).ToString() + ")");
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
ImGui.BeginTabBar("Tabs");
|
ImGui.BeginTabBar("Tabs");
|
||||||
|
|
||||||
#region Tabs
|
#region Tabs
|
||||||
System();
|
System();
|
||||||
Inputs();
|
Inputs();
|
||||||
Profile();
|
Profile();
|
||||||
Stage();
|
Stage();
|
||||||
Textures();
|
Textures();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
ImGui.EndTabBar();
|
ImGui.EndTabBar();
|
||||||
|
|
||||||
ImGui.End();
|
ImGui.End();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#region Tabs
|
#region Tabs
|
||||||
private static void System() {
|
private static void System() {
|
||||||
if (ImGui.BeginTabItem("System")) {
|
if (ImGui.BeginTabItem("System")) {
|
||||||
@ -135,12 +135,12 @@ public static class ImGuiDebugWindow {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case InputDeviceType.MidiIn:
|
case InputDeviceType.MidiIn:
|
||||||
var midiin = (CInputMIDI)device;
|
var midiin = (CInputMIDI)device;
|
||||||
//for (int i = 0; i < midiin.InputEvents.Count; i++) {
|
//for (int i = 0; i < midiin.InputEvents.Count; i++) {
|
||||||
// if (midiin.InputEvents[i].Pressed) { ImGui.Text(midiin.InputEvents[i].nKey + " Pressed!"); }
|
// if (midiin.InputEvents[i].Pressed) { ImGui.Text(midiin.InputEvents[i].nKey + " Pressed!"); }
|
||||||
// if (midiin.KeyPressing(i)) { ImGui.Text("Pressing!"); }
|
// if (midiin.KeyPressing(i)) { ImGui.Text("Pressing!"); }
|
||||||
// if (midiin.InputEvents[i].Released) { ImGui.Text(midiin.InputEvents[i].nKey + " Released!"); }
|
// if (midiin.InputEvents[i].Released) { ImGui.Text(midiin.InputEvents[i].nKey + " Released!"); }
|
||||||
//}
|
//}
|
||||||
ImGui.TextColored(new Vector4(1, 0, 0, 1), "MIDI input polling is currently disabled.");
|
ImGui.TextColored(new Vector4(1, 0, 0, 1), "MIDI input polling is currently disabled.");
|
||||||
break;
|
break;
|
||||||
case InputDeviceType.Unknown:
|
case InputDeviceType.Unknown:
|
||||||
@ -161,7 +161,7 @@ public static class ImGuiDebugWindow {
|
|||||||
ImGui.BeginDisabled(OpenTaiko.r現在のステージ.eStageID == CStage.EStage.Game);
|
ImGui.BeginDisabled(OpenTaiko.r現在のステージ.eStageID == CStage.EStage.Game);
|
||||||
int count = OpenTaiko.ConfigIni.nPlayerCount;
|
int count = OpenTaiko.ConfigIni.nPlayerCount;
|
||||||
if (ImGui.InputInt("Player Count", ref count))
|
if (ImGui.InputInt("Player Count", ref count))
|
||||||
OpenTaiko.ConfigIni.nPlayerCount = Math.Clamp(count, 1, 5); // funny things can happen when the player count is set to 0
|
OpenTaiko.ConfigIni.nPlayerCount = Math.Clamp(count, 1, 5); // funny things can happen when the player count is set to 0
|
||||||
ImGui.EndDisabled();
|
ImGui.EndDisabled();
|
||||||
|
|
||||||
for (int i = 0; i < OpenTaiko.ConfigIni.nPlayerCount; i++) {
|
for (int i = 0; i < OpenTaiko.ConfigIni.nPlayerCount; i++) {
|
||||||
@ -179,7 +179,7 @@ public static class ImGuiDebugWindow {
|
|||||||
OpenTaiko.NamePlate.tNamePlateRefreshTitles(save);
|
OpenTaiko.NamePlate.tNamePlateRefreshTitles(save);
|
||||||
}
|
}
|
||||||
|
|
||||||
string preview = OpenTaiko.SaveFileInstances[save].data.TitleId == 0 ? "初心者" : OpenTaiko.Databases.DBNameplateUnlockables.data[OpenTaiko.SaveFileInstances[save].data.TitleId].nameplateInfo.cld.GetString("");
|
string preview = OpenTaiko.SaveFileInstances[save].data.TitleId == -1 ? "初心者" : OpenTaiko.Databases.DBNameplateUnlockables.data[OpenTaiko.SaveFileInstances[save].data.TitleId].nameplateInfo.cld.GetString("");
|
||||||
|
|
||||||
if (ImGui.BeginCombo("Nameplate", preview)) {
|
if (ImGui.BeginCombo("Nameplate", preview)) {
|
||||||
foreach (long id in OpenTaiko.Databases.DBNameplateUnlockables.data.Keys) {
|
foreach (long id in OpenTaiko.Databases.DBNameplateUnlockables.data.Keys) {
|
||||||
@ -285,7 +285,7 @@ public static class ImGuiDebugWindow {
|
|||||||
break;
|
break;
|
||||||
case CStage.EStage.Game:
|
case CStage.EStage.Game:
|
||||||
for (int i = 0; i < OpenTaiko.ConfigIni.nPlayerCount; i++) {
|
for (int i = 0; i < OpenTaiko.ConfigIni.nPlayerCount; i++) {
|
||||||
if (ImGui.TreeNodeEx($"Player {i+1}###GAME_CHART_{i}", ImGuiTreeNodeFlags.Framed)) {
|
if (ImGui.TreeNodeEx($"Player {i + 1}###GAME_CHART_{i}", ImGuiTreeNodeFlags.Framed)) {
|
||||||
|
|
||||||
Difficulty game_difficulty = OpenTaiko.DifficultyNumberToEnum(OpenTaiko.stageSongSelect.nChoosenSongDifficulty[i]);
|
Difficulty game_difficulty = OpenTaiko.DifficultyNumberToEnum(OpenTaiko.stageSongSelect.nChoosenSongDifficulty[i]);
|
||||||
var dtx = OpenTaiko.GetDTX(i);
|
var dtx = OpenTaiko.GetDTX(i);
|
||||||
@ -331,9 +331,9 @@ public static class ImGuiDebugWindow {
|
|||||||
|
|
||||||
ImGui.Text("Note Count: ");
|
ImGui.Text("Note Count: ");
|
||||||
ImGui.Indent();
|
ImGui.Indent();
|
||||||
ImGui.Text("Normal: " + dtx.nノーツ数_Branch[0] +
|
ImGui.Text("Normal: " + dtx.nノーツ数_Branch[0] +
|
||||||
" / Expert: " + dtx.nノーツ数_Branch[1] +
|
" / Expert: " + dtx.nノーツ数_Branch[1] +
|
||||||
" / Master: " + dtx.nノーツ数_Branch[2]);
|
" / Master: " + dtx.nノーツ数_Branch[2]);
|
||||||
ImGui.Unindent();
|
ImGui.Unindent();
|
||||||
|
|
||||||
ImGui.TreePop();
|
ImGui.TreePop();
|
||||||
@ -369,15 +369,15 @@ public static class ImGuiDebugWindow {
|
|||||||
else
|
else
|
||||||
ImGui.TextDisabled("To prevent crash during enumeration,\nyou can not view the texture list during StartUp stage.");
|
ImGui.TextDisabled("To prevent crash during enumeration,\nyou can not view the texture list during StartUp stage.");
|
||||||
|
|
||||||
currentStageMemoryUsage = 0;
|
currentStageMemoryUsage = 0;
|
||||||
|
|
||||||
#region Script.lua Memory Usage
|
#region Script.lua Memory Usage
|
||||||
int index = 0;
|
int index = 0;
|
||||||
foreach (CLuaScript luascript in CLuaScript.listScripts)
|
foreach (CLuaScript luascript in CLuaScript.listScripts)
|
||||||
currentStageMemoryUsage += CTextureListPopup(luascript.listDisposables.OfType<CTexture>(),
|
currentStageMemoryUsage += CTextureListPopup(luascript.listDisposables.OfType<CTexture>(),
|
||||||
$"Module #{index}", $"MODULE{index++}_TEXTURES");
|
$"Module #{index}", $"MODULE{index++}_TEXTURES");
|
||||||
|
|
||||||
switch (OpenTaiko.r現在のステージ.eStageID) {
|
switch (OpenTaiko.r現在のステージ.eStageID) {
|
||||||
#region Game
|
#region Game
|
||||||
case CStage.EStage.Game:
|
case CStage.EStage.Game:
|
||||||
|
|
||||||
@ -388,8 +388,8 @@ public static class ImGuiDebugWindow {
|
|||||||
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actMob.MobScript,
|
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actMob.MobScript,
|
||||||
"Mob", "TEXTURE_LUA_MOB");
|
"Mob", "TEXTURE_LUA_MOB");
|
||||||
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actBalloon.KusudamaScript,
|
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actBalloon.KusudamaScript,
|
||||||
"Kusudama", "TEXTURE_LUA_KUSUDAMA");
|
"Kusudama", "TEXTURE_LUA_KUSUDAMA");
|
||||||
|
|
||||||
#region Endings
|
#region Endings
|
||||||
switch ((Difficulty)OpenTaiko.stageSongSelect.nChoosenSongDifficulty[0]) {
|
switch ((Difficulty)OpenTaiko.stageSongSelect.nChoosenSongDifficulty[0]) {
|
||||||
case Difficulty.Tower:
|
case Difficulty.Tower:
|
||||||
@ -428,8 +428,7 @@ public static class ImGuiDebugWindow {
|
|||||||
"AI Full Combo", "TEXTURE_LUA_AIFC");
|
"AI Full Combo", "TEXTURE_LUA_AIFC");
|
||||||
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.AIWin_PerfectScript,
|
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.AIWin_PerfectScript,
|
||||||
"AI Perfect Combo", "TEXTURE_LUA_AIPFC");
|
"AI Perfect Combo", "TEXTURE_LUA_AIPFC");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.FailedScript,
|
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.FailedScript,
|
||||||
"Clear Failed", "TEXTURE_LUA_GAMEFAILED");
|
"Clear Failed", "TEXTURE_LUA_GAMEFAILED");
|
||||||
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.ClearScript,
|
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.ClearScript,
|
||||||
@ -440,30 +439,30 @@ public static class ImGuiDebugWindow {
|
|||||||
"Perfect Combo", "TEXTURE_LUA_GAMEPFC");
|
"Perfect Combo", "TEXTURE_LUA_GAMEPFC");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Text("Script.lua Tex Memory Usage: " + GetMemAllocationInMegabytes(currentStageMemoryUsage) + "MB");
|
ImGui.Text("Script.lua Tex Memory Usage: " + GetMemAllocationInMegabytes(currentStageMemoryUsage) + "MB");
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
ImGui.EndTabItem();
|
ImGui.EndTabItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ImGui Items
|
#region ImGui Items
|
||||||
private static void CTexturePopup(CTexture texture, string label) {
|
private static void CTexturePopup(CTexture texture, string label) {
|
||||||
if (ImGui.TreeNodeEx(label, ImGuiTreeNodeFlags.Framed)) {
|
if (ImGui.TreeNodeEx(label, ImGuiTreeNodeFlags.Framed)) {
|
||||||
|
|
||||||
ImGui.BeginDisabled();
|
ImGui.BeginDisabled();
|
||||||
ImGui.InputText("Path", ref reloadTexPath, 2048);
|
ImGui.InputText("Path", ref reloadTexPath, 2048);
|
||||||
if (ImGui.Button("Reload via. Path (To-do)")) {
|
if (ImGui.Button("Reload via. Path (To-do)")) {
|
||||||
// To-do
|
// To-do
|
||||||
}
|
}
|
||||||
ImGui.EndDisabled();
|
ImGui.EndDisabled();
|
||||||
|
|
||||||
@ -474,9 +473,8 @@ public static class ImGuiDebugWindow {
|
|||||||
if (DrawCTextureForImGui(texture, 800, 800)) {
|
if (DrawCTextureForImGui(texture, 800, 800)) {
|
||||||
ImGui.Text("Pointer: " + texture.Pointer);
|
ImGui.Text("Pointer: " + texture.Pointer);
|
||||||
ImGui.Text("Size: x" + texture.szTextureSize.Width + ",y" + texture.szTextureSize.Height);
|
ImGui.Text("Size: x" + texture.szTextureSize.Width + ",y" + texture.szTextureSize.Height);
|
||||||
ImGui.Text("Memory allocated: " + String.Format("{0:0.###}",GetTextureMemAllocationInMegabytes(texture)) + "MB");
|
ImGui.Text("Memory allocated: " + String.Format("{0:0.###}", GetTextureMemAllocationInMegabytes(texture)) + "MB");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ImGui.TextDisabled("Texture is not loaded.");
|
ImGui.TextDisabled("Texture is not loaded.");
|
||||||
}
|
}
|
||||||
ImGui.EndTooltip();
|
ImGui.EndTooltip();
|
||||||
@ -503,7 +501,7 @@ public static class ImGuiDebugWindow {
|
|||||||
if (texture == null) return false;
|
if (texture == null) return false;
|
||||||
return DrawCTextureForImGui(texture,
|
return DrawCTextureForImGui(texture,
|
||||||
new Vector2(texture.szTextureSize.Width, texture.szTextureSize.Height),
|
new Vector2(texture.szTextureSize.Width, texture.szTextureSize.Height),
|
||||||
new Vector2(0,0), new Vector2(1,1));
|
new Vector2(0, 0), new Vector2(1, 1));
|
||||||
}
|
}
|
||||||
private static bool DrawCTextureForImGui(CTexture texture, int max_width, int max_height) {
|
private static bool DrawCTextureForImGui(CTexture texture, int max_width, int max_height) {
|
||||||
if (texture == null) return false;
|
if (texture == null) return false;
|
||||||
@ -519,7 +517,7 @@ public static class ImGuiDebugWindow {
|
|||||||
new Vector2(rect.Width, rect.Height),
|
new Vector2(rect.Width, rect.Height),
|
||||||
new Vector2((float)rect.X / texture.szTextureSize.Width, (float)rect.Y / texture.szTextureSize.Height),
|
new Vector2((float)rect.X / texture.szTextureSize.Width, (float)rect.Y / texture.szTextureSize.Height),
|
||||||
new Vector2((float)rect.Right / texture.szTextureSize.Width, (float)rect.Bottom / texture.szTextureSize.Height));
|
new Vector2((float)rect.Right / texture.szTextureSize.Width, (float)rect.Bottom / texture.szTextureSize.Height));
|
||||||
}
|
}
|
||||||
/// <param name="image_size">Must be in pixels</param>
|
/// <param name="image_size">Must be in pixels</param>
|
||||||
/// <param name="pos">Value is typically between 0.0f and 1.0f</param>
|
/// <param name="pos">Value is typically between 0.0f and 1.0f</param>
|
||||||
/// <param name="size">Value is typically between 0.0f and 1.0f</param>
|
/// <param name="size">Value is typically between 0.0f and 1.0f</param>
|
||||||
@ -527,9 +525,9 @@ public static class ImGuiDebugWindow {
|
|||||||
if (texture == null) return false;
|
if (texture == null) return false;
|
||||||
ImGui.Image((nint)texture.Pointer, image_size, pos, size);
|
ImGui.Image((nint)texture.Pointer, image_size, pos, size);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Helpers
|
#region Helpers
|
||||||
private static float GetMemAllocationInMegabytes(int bytes) { return (float)bytes / (1024 * 1024); }
|
private static float GetMemAllocationInMegabytes(int bytes) { return (float)bytes / (1024 * 1024); }
|
||||||
private static float GetTextureMemAllocationInMegabytes(CTexture texture) {
|
private static float GetTextureMemAllocationInMegabytes(CTexture texture) {
|
||||||
@ -547,7 +545,7 @@ public static class ImGuiDebugWindow {
|
|||||||
}
|
}
|
||||||
private static int GetTotalMemoryUsageFromCTextureList(ScriptBG script) {
|
private static int GetTotalMemoryUsageFromCTextureList(ScriptBG script) {
|
||||||
return script != null ? GetTotalMemoryUsageFromCTextureList(script.Textures.Values) : 0;
|
return script != null ? GetTotalMemoryUsageFromCTextureList(script.Textures.Values) : 0;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user