Skip to content

Commit dc22638

Browse files
committed
ImDebugger UI update
1 parent 6fe537d commit dc22638

File tree

4 files changed

+70
-32
lines changed

4 files changed

+70
-32
lines changed

UI/ImDebugger/ImDebugger.cpp

+59-32
Original file line numberDiff line numberDiff line change
@@ -957,14 +957,14 @@ void DrawMediaDecodersView(ImConfig &cfg, ImControl &control) {
957957
return;
958958
}
959959

960-
if (ImGui::CollapsingHeader("sceMpeg")) {
961-
const std::map<u32, MpegContext *> &ctxs = __MpegGetContexts();
960+
const std::map<u32, MpegContext *> &mpegCtxs = __MpegGetContexts();
961+
if (ImGui::CollapsingHeaderWithCount("sceMpeg", mpegCtxs.size())) {
962962
if (ImGui::BeginTable("mpegs", 2, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) {
963963
ImGui::TableSetupColumn("Addr", ImGuiTableColumnFlags_WidthFixed);
964964
ImGui::TableSetupColumn("VFrames", ImGuiTableColumnFlags_WidthFixed);
965965

966966
ImGui::TableHeadersRow();
967-
for (auto iter : ctxs) {
967+
for (auto iter : mpegCtxs) {
968968
ImGui::TableNextRow();
969969
ImGui::TableNextColumn();
970970
ImGui::PushID(iter.first);
@@ -987,8 +987,8 @@ void DrawMediaDecodersView(ImConfig &cfg, ImControl &control) {
987987
ImGui::EndTable();
988988
}
989989

990-
auto iter = ctxs.find(cfg.selectedMpegCtx);
991-
if (iter != ctxs.end()) {
990+
auto iter = mpegCtxs.find(cfg.selectedMpegCtx);
991+
if (iter != mpegCtxs.end()) {
992992
const MpegContext *ctx = iter->second;
993993
char temp[16];
994994
snprintf(temp, sizeof(temp), "sceMpeg context at %08x", iter->first);
@@ -1003,7 +1003,17 @@ void DrawMediaDecodersView(ImConfig &cfg, ImControl &control) {
10031003
}
10041004
}
10051005

1006-
if (ImGui::CollapsingHeader("sceAtrac", ImGuiTreeNodeFlags_DefaultOpen)) {
1006+
// Count the active atrac contexts so we can display it.
1007+
const int maxAtracContexts = __AtracMaxContexts();
1008+
int atracCount = 0;
1009+
for (int i = 0; i < maxAtracContexts; i++) {
1010+
u32 type;
1011+
if (__AtracGetCtx(i, &type)) {
1012+
atracCount++;
1013+
}
1014+
}
1015+
1016+
if (ImGui::CollapsingHeaderWithCount("sceAtrac", atracCount, ImGuiTreeNodeFlags_DefaultOpen)) {
10071017
ImGui::Checkbox("Force FFMPEG", &g_Config.bForceFfmpegForAudioDec);
10081018
if (ImGui::BeginTable("atracs", 8, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) {
10091019
ImGui::TableSetupColumn("Index", ImGuiTableColumnFlags_WidthFixed);
@@ -1016,8 +1026,7 @@ void DrawMediaDecodersView(ImConfig &cfg, ImControl &control) {
10161026
ImGui::TableSetupColumn("Impl", ImGuiTableColumnFlags_WidthFixed);
10171027

10181028
ImGui::TableHeadersRow();
1019-
const int maxContexts = __AtracMaxContexts();
1020-
for (int i = 0; i < maxContexts; i++) {
1029+
for (int i = 0; i < maxAtracContexts; i++) {
10211030
u32 codecType = 0;
10221031

10231032
ImGui::TableNextRow();
@@ -1164,7 +1173,48 @@ void DrawMediaDecodersView(ImConfig &cfg, ImControl &control) {
11641173
}
11651174
}
11661175

1167-
if (ImGui::CollapsingHeader("sceAudiocodec", ImGuiTreeNodeFlags_DefaultOpen)) {
1176+
if (ImGui::CollapsingHeaderWithCount("sceMp3", (int)mp3Map.size(), ImGuiTreeNodeFlags_DefaultOpen)) {
1177+
if (ImGui::BeginTable("mp3", 3, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) {
1178+
ImGui::TableSetupColumn("Handle", ImGuiTableColumnFlags_WidthFixed);
1179+
ImGui::TableSetupColumn("Channels", ImGuiTableColumnFlags_WidthFixed);
1180+
ImGui::TableSetupColumn("ReadPos", ImGuiTableColumnFlags_WidthFixed);
1181+
1182+
for (auto &iter : mp3Map) {
1183+
ImGui::TableNextRow();
1184+
ImGui::TableNextColumn();
1185+
ImGui::PushID(iter.first);
1186+
ImGui::SetNextItemAllowOverlap();
1187+
char temp[16];
1188+
snprintf(temp, sizeof(temp), "%d", iter.first);
1189+
if (ImGui::Selectable(temp, iter.first == cfg.selectedMp3Ctx, ImGuiSelectableFlags_SpanAllColumns)) {
1190+
cfg.selectedMp3Ctx = iter.first;
1191+
}
1192+
if (!iter.second) {
1193+
continue;
1194+
}
1195+
ImGui::TableNextColumn();
1196+
ImGui::Text("%d", iter.second->Channels);
1197+
ImGui::TableNextColumn();
1198+
ImGui::Text("%d", (int)iter.second->ReadPos());
1199+
ImGui::PopID();
1200+
}
1201+
ImGui::EndTable();
1202+
}
1203+
1204+
auto iter = mp3Map.find(cfg.selectedMp3Ctx);
1205+
if (iter != mp3Map.end() && ImGui::CollapsingHeader("MP3 %d", iter->first)) {
1206+
ImGui::Text("MP3 Context %d", iter->first);
1207+
if (iter->second) {
1208+
AuCtx *ctx = iter->second;
1209+
ImGui::Text("%d Hz, %d channels", ctx->SamplingRate, ctx->Channels);
1210+
ImGui::Text("AUBuf: %08x AUSize: %08x", ctx->AuBuf, ctx->AuBufSize);
1211+
ImGui::Text("PCMBuf: %08x PCMSize: %08x", ctx->PCMBuf, ctx->PCMBufSize);
1212+
ImGui::Text("Pos: %d (%d -> %d)", ctx->ReadPos(), ctx->startPos, ctx->endPos);
1213+
}
1214+
}
1215+
}
1216+
1217+
if (ImGui::CollapsingHeaderWithCount("sceAudiocodec", (int)g_audioDecoderContexts.size(), ImGuiTreeNodeFlags_DefaultOpen)) {
11681218
if (ImGui::BeginTable("codecs", 2, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) {
11691219
ImGui::TableSetupColumn("CtxAddr", ImGuiTableColumnFlags_WidthFixed);
11701220
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_WidthFixed);
@@ -1186,29 +1236,6 @@ void DrawMediaDecodersView(ImConfig &cfg, ImControl &control) {
11861236
}
11871237
}
11881238

1189-
if (ImGui::CollapsingHeader("sceMp3", ImGuiTreeNodeFlags_DefaultOpen)) {
1190-
if (ImGui::BeginTable("mp3", 3, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) {
1191-
ImGui::TableSetupColumn("Handle", ImGuiTableColumnFlags_WidthFixed);
1192-
ImGui::TableSetupColumn("Channels", ImGuiTableColumnFlags_WidthFixed);
1193-
ImGui::TableSetupColumn("StartPos", ImGuiTableColumnFlags_WidthFixed);
1194-
// TODO: more..
1195-
1196-
for (auto &iter : mp3Map) {
1197-
ImGui::TableNextRow();
1198-
ImGui::TableNextColumn();
1199-
ImGui::Text("%d", iter.first);
1200-
if (!iter.second) {
1201-
continue;
1202-
}
1203-
ImGui::TableNextColumn();
1204-
ImGui::Text("%d", iter.second->Channels);
1205-
ImGui::TableNextColumn();
1206-
ImGui::Text("%d", (int)iter.second->startPos);
1207-
}
1208-
ImGui::EndTable();
1209-
}
1210-
}
1211-
12121239
ImGui::End();
12131240
}
12141241

UI/ImDebugger/ImDebugger.h

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ struct ImConfig {
9999
int selectedBreakpoint = -1;
100100
int selectedMemCheck = -1;
101101
int selectedAtracCtx = 0;
102+
int selectedMp3Ctx = 0;
102103
int selectedMemoryBlock = 0;
103104
u32 selectedMpegCtx = 0;
104105

ext/imgui/imgui_extras.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Just some string_view and related wrappers.
22

3+
#include <cstdio>
4+
#include <cstdlib>
35
#include <string_view>
46
#include "ext/imgui/imgui.h"
57

@@ -53,4 +55,10 @@ bool RepeatButtonShift(const char* label, float repeatRate) {
5355
return clicked;
5456
}
5557

58+
bool CollapsingHeaderWithCount(const char *title, int count, ImGuiTreeNodeFlags flags) {
59+
char temp[256];
60+
snprintf(temp, sizeof(temp), "%s (%d)##%s", title, count, title);
61+
return ImGui::CollapsingHeader(temp, flags);
62+
}
63+
5664
} // namespace ImGui

ext/imgui/imgui_extras.h

+2
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ inline void TextUnformatted(std::string_view str) {
1212
bool RepeatButton(const char *title);
1313
bool RepeatButtonShift(const char* label, float repeatRate = 0.05f);
1414

15+
bool CollapsingHeaderWithCount(const char *title, int count, ImGuiTreeNodeFlags flags = 0);
16+
1517
} // namespace ImGui

0 commit comments

Comments
 (0)