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