1
0
mirror of synced 2024-11-23 23:21:06 +01:00

More stuff and also imgui (#717)

* Add names to input devices

* Deprecate unused textures

* ImGui debugging - track Script.lua textures

* ImGui debugging - track Module textures

* ImGui debugging - track Kusudama textures

* actually let's not put that in a tree

* Remove unused input methods for now

* Update ImGuiDebugWindow.cs

* Update OpenTaiko/src/Common/ImGuiDebugWindow.cs

Co-authored-by: Wei-Cheng Yeh (IID) <iid@ccns.ncku.edu.tw>

* Further simplify lyric sandwich

---------

Co-authored-by: Wei-Cheng Yeh (IID) <iid@ccns.ncku.edu.tw>
This commit is contained in:
DragonRatTiger / リュウコ 2024-10-23 10:10:43 -05:00 committed by GitHub
parent e64462809b
commit e87212ea60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 198 additions and 104 deletions

View File

@ -4,10 +4,14 @@ namespace FDK {
public class CInputGamepad : IInputDevice, IDisposable {
// Constructor
private IGamepad Gamepad { get; set; }
public CInputGamepad(IGamepad gamepad) {
this.Gamepad = gamepad;
this.CurrentType = InputDeviceType.Gamepad;
this.GUID = gamepad.Index.ToString();
this.ID = gamepad.Index;
this.Name = gamepad.Name;
this.InputEvents = new List<STInputEvent>(32);
@ -36,6 +40,10 @@ namespace FDK {
get;
private set;
}
public string Name {
get;
private set;
}
public List<STInputEvent> InputEvents {
get;
private set;

View File

@ -4,20 +4,19 @@ namespace FDK {
public class CInputJoystick : IInputDevice, IDisposable {
// Constructor
private IJoystick Joystick { get; set; }
public IJoystick Joystick { get; private set; }
public CInputJoystick(IJoystick joystick) {
Joystick = joystick;
this.Joystick = joystick;
this.CurrentType = InputDeviceType.Joystick;
this.GUID = joystick.Index.ToString();
this.ID = joystick.Index;
this.Name = joystick.Name;
this.InputEvents = new List<STInputEvent>(32);
joystick.ButtonDown += Joystick_ButtonDown;
joystick.ButtonUp += Joystick_ButtonUp;
joystick.AxisMoved += Joystick_AxisMoved;
joystick.HatMoved += Joystick_HatMoved;
}
@ -41,6 +40,10 @@ namespace FDK {
get;
private set;
}
public string Name {
get;
private set;
}
public List<STInputEvent> InputEvents {
get;
private set;
@ -145,14 +148,6 @@ namespace FDK {
ButtonStates[(int)button.Name].Item1 = false;
}
}
private void Joystick_AxisMoved(IJoystick joystick, Axis axis) {
}
private void Joystick_HatMoved(IJoystick joystick, Hat hat) {
}
//-----------------
#endregion
}

View File

@ -8,6 +8,7 @@ namespace FDK {
this.CurrentType = InputDeviceType.Keyboard;
this.GUID = "";
this.ID = 0;
this.Name = keyboards.Count > 0 ? keyboards[0].Name : "";
foreach (var keyboard in keyboards) {
keyboard.KeyDown += KeyDown;
@ -28,6 +29,7 @@ namespace FDK {
public InputDeviceType CurrentType { get; private set; }
public string GUID { get; private set; }
public int ID { get; private set; }
public string Name { get; private set; }
public List<STInputEvent> InputEvents { get; private set; }
public string strDeviceName { get; set; }

View File

@ -14,6 +14,7 @@
this.CurrentType = InputDeviceType.MidiIn;
this.GUID = "";
this.ID = (int)nID;
this.Name = "";
this.strDeviceName = ""; // CInput管理で初期化する
}
@ -59,6 +60,7 @@
public InputDeviceType CurrentType { get; private set; }
public string GUID { get; private set; }
public int ID { get; private set; }
public string Name { get; private set; }
public List<STInputEvent> InputEvents { get; private set; }
public string strDeviceName { get; set; }

View File

@ -80,7 +80,7 @@ namespace FDK {
Trace.TraceInformation("Found {0} Input Device{1}", InputDevices.Count, InputDevices.Count != 1 ? "s:" : ":");
for (int i = 0; i < InputDevices.Count; i++) {
try {
Trace.TraceInformation("Input Device #" + i + " (" + InputDevices[i].CurrentType.ToString() + ")");
Trace.TraceInformation("Input Device #" + i + " (" + InputDevices[i].CurrentType.ToString() + " - " + InputDevices[i].Name + ")");
} catch { }
}

View File

@ -15,13 +15,7 @@ namespace FDK {
this.CurrentType = InputDeviceType.Mouse;
this.GUID = "";
this.ID = 0;
try {
Trace.TraceInformation(mouse.Name + " を生成しました。"); // なぜか0x00のゴミが出るので削除
this.strDeviceName = mouse.Name;
} catch {
Trace.TraceWarning("Mouse デバイスの生成に失敗しました。");
throw;
}
this.Name = mouse.Name;
mouse.Click += Mouse_Click;
mouse.DoubleClick += Mouse_DoubleClick;
@ -40,8 +34,8 @@ namespace FDK {
public InputDeviceType CurrentType { get; private set; }
public string GUID { get; private set; }
public int ID { get; private set; }
public string Name { get; private set; }
public List<STInputEvent> InputEvents { get; private set; }
public string strDeviceName { get; set; }
public void Polling(bool useBufferInput) {
InputEvents.Clear();

View File

@ -11,6 +11,9 @@
int ID {
get;
}
string Name {
get;
}
List<STInputEvent> InputEvents {
get;
}

View File

@ -18,6 +18,7 @@ namespace OpenTaiko {
private static long memoryReadTimer = 0;
private static long pagedmemory = 0;
private static int textureMemoryUsage = 0;
private static int currentStageMemoryUsage = 0;
private static int sortType = -1;
private static readonly string[] sortNames = ["Memory Usage (Highest->Lowest)", "Memory Usage (Lowest->Highest)", "Pointer ID"];
@ -98,7 +99,7 @@ namespace OpenTaiko {
ImGui.Text("Unknown: " + OpenTaiko.InputManager.InputDevices.Count(device => device.CurrentType == InputDeviceType.Unknown));
foreach (IInputDevice device in OpenTaiko.InputManager.InputDevices) {
if (ImGui.TreeNodeEx(device.CurrentType.ToString() + " (ID " + device.ID + ")")) {
if (ImGui.TreeNodeEx(device.CurrentType.ToString() + " (ID " + device.ID + " / Name: " + device.Name + ")")) {
switch (device.CurrentType) {
case InputDeviceType.Keyboard:
var keyboard = (CInputKeyboard)device;
@ -313,7 +314,6 @@ namespace OpenTaiko {
ImGui.Text("Subtitle: " + dtx.SUBTITLE.GetString(""));
ImGui.Text("Charter: " + dtx.MAKER);
// BPM
ImGui.Text("BPM: " + dtx.BASEBPM + (dtx.listBPM.Count > 1 ? (" (Min: " + dtx.MinBPM + " / Max: " + dtx.MaxBPM + ")") : ""));
if (dtx.listBPM.Count > 1) {
if (ImGui.TreeNodeEx($"BPM List ({dtx.listBPM.Count})###GAME_BPM_LIST_{i}")) {
@ -324,6 +324,8 @@ namespace OpenTaiko {
}
}
ImGui.Text("Lyrics: " + (dtx.usingLyricsFile ? dtx.listLyric2.Count : dtx.listLyric.Count));
ImGui.NewLine();
ImGui.Text("Note Count: ");
@ -346,12 +348,7 @@ namespace OpenTaiko {
}
private static void Textures() {
if (ImGui.BeginTabItem("Textures")) {
ImGui.Text("Total Texture Count: " + OpenTaiko.Tx.listTexture.Count);
ImGui.Text("Total Memory Usage: " + textureMemoryUsage + "bytes (" + GetMemAllocationInMegabytes(textureMemoryUsage) + "MB)");
if (ImGui.Button("Refresh") || textureMemoryUsage == 0) {
textureMemoryUsage = OpenTaiko.Tx.listTexture.Where(tex => tex != null).Sum(tex => tex.szTextureSize.Width * tex.szTextureSize.Height * 4);
}
if (ImGui.BeginCombo("Change Sort", sortType != -1 ? sortNames[sortType] : "(Default)")) {
if (ImGui.BeginCombo("Change listTexture Sort###TEXTURE_TOTAL_SORT", sortType != -1 ? sortNames[sortType] : "(Default)")) {
if (ImGui.Selectable(sortNames[0], sortType == 0)) {
OpenTaiko.Tx.listTexture.Sort((tex1, tex2) => (tex2 != null ? tex2.szTextureSize.Width * tex2.szTextureSize.Height : -1).CompareTo(tex1 != null ? tex1.szTextureSize.Width * tex1.szTextureSize.Height : -1));
sortType = 0;
@ -366,17 +363,93 @@ namespace OpenTaiko {
}
ImGui.EndCombo();
}
if (ImGui.TreeNodeEx("Show All Textures###TEXTURE_SHOWALL")) {
int index = 0;
if (OpenTaiko.r現在のステージ.eStageID == CStage.EStage.StartUp)
ImGui.TextDisabled("To prevent crash during enumeration,\nyou can not view the texture list during StartUp stage.");
if (OpenTaiko.r現在のステージ.eStageID != CStage.EStage.StartUp)
CTextureListPopup(OpenTaiko.Tx.listTexture, "Show listTexture", "TEXTURE_ALL");
else
foreach (CTexture tex in OpenTaiko.Tx.listTexture) {
CTexturePopup(tex, $"#{index} (Pointer: {(tex != null ? tex.Pointer : "null")})###TEXTURE_SHOW_POPUP_{index++}");
ImGui.TextDisabled("To prevent crash during enumeration,\nyou can not view the texture list during StartUp stage.");
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) {
#region Game
case CStage.EStage.Game:
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actBackground.UpScript,
"Up Background", "TEXTURE_LUA_UPBG");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actBackground.DownScript,
"Down Background", "TEXTURE_LUA_DOWNBG");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actMob.MobScript,
"Mob", "TEXTURE_LUA_MOB");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actBalloon.KusudamaScript,
"Kusudama", "TEXTURE_LUA_KUSUDAMA");
#region Endings
switch ((Difficulty)OpenTaiko.stageSongSelect.nChoosenSongDifficulty[0]) {
case Difficulty.Tower:
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.Tower_DropoutScript,
"Tower Dropout", "TEXTURE_LUA_TOWERDROPOUT");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.Tower_TopReached_PassScript,
"Tower Cleared", "TEXTURE_LUA_TOWERCLEAR");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.Tower_TopReached_FullComboScript,
"Tower Full Combo", "TEXTURE_LUA_TOWERFC");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.Tower_TopReached_PerfectScript,
"Tower Perfect Combo", "TEXTURE_LUA_TOWERPFC");
break;
case Difficulty.Dan:
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.Dan_FailScript,
"Dan Clear Failed", "TEXTURE_LUA_DANFAILED");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.Dan_Red_PassScript,
"Dan Red Clear", "TEXTURE_LUA_DANCLEAR");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.Dan_Red_FullComboScript,
"Dan Red Full Combo", "TEXTURE_LUA_DANFC");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.Dan_Red_PerfectScript,
"Dan Red Perfect", "TEXTURE_LUA_DANPFC");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.Dan_Red_PassScript,
"Dan Gold Clear", "TEXTURE_LUA_DANGOLDCLEAR");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.Dan_Red_FullComboScript,
"Dan Gold Full Combo", "TEXTURE_LUA_DANGOLDFC");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.Dan_Red_PerfectScript,
"Dan Gold Perfect", "TEXTURE_LUA_DANGOLDPFC");
break;
default:
if (OpenTaiko.ConfigIni.bAIBattleMode) {
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.AILoseScript,
"AI Clear Failed", "TEXTURE_LUA_AIFAILED");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.AIWinScript,
"AI Cleared", "TEXTURE_LUA_AICLEAR");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.AIWin_FullComboScript,
"AI Full Combo", "TEXTURE_LUA_AIFC");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.AIWin_PerfectScript,
"AI Perfect Combo", "TEXTURE_LUA_AIPFC");
}
ImGui.TreePop();
else {
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.FailedScript,
"Clear Failed", "TEXTURE_LUA_GAMEFAILED");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.ClearScript,
"Cleared", "TEXTURE_LUA_GAMECLEAR");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.FullComboScript,
"Full Combo", "TEXTURE_LUA_GAMEFC");
currentStageMemoryUsage += CTextureListPopup(OpenTaiko.stage演奏ドラム画面.actEnd.PerfectComboScript,
"Perfect Combo", "TEXTURE_LUA_GAMEPFC");
}
break;
}
#endregion
#endregion
break;
}
ImGui.Text("Script.lua Tex Memory Usage: " + GetMemAllocationInMegabytes(currentStageMemoryUsage) + "MB");
#endregion
ImGui.EndTabItem();
}
}
@ -409,6 +482,22 @@ namespace OpenTaiko {
}
}
}
private static int CTextureListPopup(IEnumerable<CTexture> textureList, string label, string id) {
if (textureList == null) return 0;
int memoryCount = GetTotalMemoryUsageFromCTextureList(textureList);
if (ImGui.TreeNodeEx($"{label} Textures: ({textureList.Count()} / {String.Format("{0:0.###}", GetMemAllocationInMegabytes(memoryCount))}MB)###{id}")) {
int index = 0;
foreach (CTexture tex in textureList) {
CTexturePopup(tex, $"Texture #{index} (Pointer: {(tex != null ? tex.Pointer : "null")})###{id}_{index++}");
}
ImGui.TreePop();
}
return memoryCount;
}
private static int CTextureListPopup(ScriptBG script, string label, string id) {
return script != null ? CTextureListPopup(script.Textures.Values, label, id) : 0;
}
private static bool DrawCTextureForImGui(CTexture texture) {
if (texture == null) return false;
return DrawCTextureForImGui(texture,
@ -446,12 +535,18 @@ namespace OpenTaiko {
return (float)GetTextureMemAllocation(texture) / (1024 * 1024);
}
private static int GetTextureMemAllocation(CTexture texture) {
if (texture == null) return 0;
return texture.szTextureSize.Width * texture.szTextureSize.Height * 4;
return texture != null ? (texture.szTextureSize.Width * texture.szTextureSize.Height * 4) : 0;
}
private static Vector4 ColorToVector4(Color color) {
return new Vector4((float)color.R / 255, (float)color.G / 255, (float)color.B / 255, (float)color.A / 255);
}
private static int GetTotalMemoryUsageFromCTextureList(IEnumerable<CTexture> textureList) {
return textureList.Where(tex => tex != null).Sum(GetTextureMemAllocation);
}
private static int GetTotalMemoryUsageFromCTextureList(ScriptBG script) {
return script != null ? GetTotalMemoryUsageFromCTextureList(script.Textures.Values) : 0;
}
#endregion
}

View File

@ -7,7 +7,7 @@ using NLua;
namespace OpenTaiko {
class CLuaScript : IDisposable {
private static List<CLuaScript> listScripts = new List<CLuaScript>();
public static List<CLuaScript> listScripts { get; private set; } = new List<CLuaScript>();
public static void tReloadLanguage(string lang) {
foreach (var item in listScripts) {
item.ReloadLanguage(lang);
@ -32,7 +32,7 @@ namespace OpenTaiko {
private CLuaInfo luaInfo;
private CLuaFps luaFPS = new CLuaFps();
private List<IDisposable> listDisposables = new List<IDisposable>();
public List<IDisposable> listDisposables { get; private set; } = new List<IDisposable>();
protected bool Available {
get {

View File

@ -602,7 +602,6 @@ namespace OpenTaiko {
Gauge_Dan[5] = TxC(GAME + GAUGE + @$"1P_Dan_Right.png");
Gauge_Soul = TxC(GAME + GAUGE + @$"Soul.png");
Gauge_Flash = TxC(GAME + GAUGE + @$"Flash.png");
Gauge_Soul_Fire = TxC(GAME + GAUGE + @$"Fire.png");
Gauge_Soul_Explosion = new CTexture[2];
Gauge_Soul_Explosion[0] = TxC(GAME + GAUGE + @$"1P_Explosion.png");
@ -875,7 +874,6 @@ namespace OpenTaiko {
#endregion
#region 6_
Result_FadeIn = TxC(RESULT + @$"FadeIn.png");
Result_Gauge[0] = TxC(RESULT + @$"Gauge.png");
Result_Gauge_Base[0] = TxC(RESULT + @$"Gauge_Base.png");
@ -2529,7 +2527,6 @@ namespace OpenTaiko {
Gauge_Killzone,
Gauge_Soul_Explosion;
public CTexture Gauge_Soul,
Gauge_Flash,
Gauge_Soul_Fire;
public CTexture[] Gauge_Dan;
public CTexture[] Gauge_Dan_Rainbow;
@ -2672,8 +2669,7 @@ namespace OpenTaiko {
#endregion
#region 6_
public CTexture Result_FadeIn,
Result_Header,
public CTexture Result_Header,
Result_Number,
Result_Panel,
Result_Panel_2P,

View File

@ -182,7 +182,7 @@ namespace OpenTaiko {
return base.Draw();
}
private KusudamaScript KusudamaScript;
public KusudamaScript KusudamaScript { get; private set; }
private CCounter ct風船終了;

View File

@ -742,29 +742,29 @@ namespace OpenTaiko {
#region[ private ]
//-----------------
private EndAnimeScript FailedScript;
private EndAnimeScript ClearScript;
private EndAnimeScript FullComboScript;
private EndAnimeScript PerfectComboScript;
public EndAnimeScript FailedScript { get; private set; }
public EndAnimeScript ClearScript { get; private set; }
public EndAnimeScript FullComboScript { get; private set; }
public EndAnimeScript PerfectComboScript { get; private set; }
private EndAnimeScript AILoseScript;
private EndAnimeScript AIWinScript;
private EndAnimeScript AIWin_FullComboScript;
private EndAnimeScript AIWin_PerfectScript;
public EndAnimeScript AILoseScript { get; private set; }
public EndAnimeScript AIWinScript { get; private set; }
public EndAnimeScript AIWin_FullComboScript { get; private set; }
public EndAnimeScript AIWin_PerfectScript { get; private set; }
private EndAnimeScript Tower_DropoutScript;
private EndAnimeScript Tower_TopReached_PassScript;
private EndAnimeScript Tower_TopReached_FullComboScript;
private EndAnimeScript Tower_TopReached_PerfectScript;
public EndAnimeScript Tower_DropoutScript { get; private set; }
public EndAnimeScript Tower_TopReached_PassScript { get; private set; }
public EndAnimeScript Tower_TopReached_FullComboScript { get; private set; }
public EndAnimeScript Tower_TopReached_PerfectScript { get; private set; }
private EndAnimeScript Dan_FailScript;
private EndAnimeScript Dan_Red_PassScript;
private EndAnimeScript Dan_Red_FullComboScript;
private EndAnimeScript Dan_Red_PerfectScript;
public EndAnimeScript Dan_FailScript { get; private set; }
public EndAnimeScript Dan_Red_PassScript { get; private set; }
public EndAnimeScript Dan_Red_FullComboScript { get; private set; }
public EndAnimeScript Dan_Red_PerfectScript { get; private set; }
private EndAnimeScript Dan_Gold_PassScript;
private EndAnimeScript Dan_Gold_FullComboScript;
private EndAnimeScript Dan_Gold_PerfectScript;
public EndAnimeScript Dan_Gold_PassScript { get; private set; }
public EndAnimeScript Dan_Gold_FullComboScript { get; private set; }
public EndAnimeScript Dan_Gold_PerfectScript { get; private set; }
@ -804,8 +804,8 @@ namespace OpenTaiko {
CSound soundAIWinFullCombo;
CSound soundAIWinPerfectCombo;
EndMode[] Mode;
enum EndMode {
public EndMode[] Mode { get; private set; }
public enum EndMode {
StageFailed,
StageCleared,
StageFullCombo,

View File

@ -240,8 +240,6 @@ namespace OpenTaiko {
}
if (OpenTaiko.Tx.Gauge_Line[0] != null) {
#region [Rainbow]
if (this.db現在のゲージ値[0] >= 100.0) {
@ -276,6 +274,7 @@ namespace OpenTaiko {
#endregion
if (OpenTaiko.Tx.Gauge_Line[0] != null) {
OpenTaiko.Tx.Gauge_Line[0].vcScaleRatio.X = scale;
OpenTaiko.Tx.Gauge_Line[0].vcScaleRatio.Y = scale;

View File

@ -78,7 +78,7 @@ namespace OpenTaiko {
}
#region[ private ]
//-----------------
private ScriptBG MobScript;
public ScriptBG MobScript { get; private set; }
//-----------------
#endregion
}