[Scummvm-git-logs] scummvm master -> 35d1fc8ae2602fbcd8954100a2305613678d7ede
sev-
noreply at scummvm.org
Sat May 18 13:42:45 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
35d1fc8ae2 DIRECTOR: DEBUGGER: Initial code for score viewing
Commit: 35d1fc8ae2602fbcd8954100a2305613678d7ede
https://github.com/scummvm/scummvm/commit/35d1fc8ae2602fbcd8954100a2305613678d7ede
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-05-18T15:42:36+02:00
Commit Message:
DIRECTOR: DEBUGGER: Initial code for score viewing
Changed paths:
engines/director/debugtools.cpp
engines/director/score.cpp
engines/director/score.h
diff --git a/engines/director/debugtools.cpp b/engines/director/debugtools.cpp
index 0867bdcf7ef..c9f9b9e6cba 100644
--- a/engines/director/debugtools.cpp
+++ b/engines/director/debugtools.cpp
@@ -350,6 +350,7 @@ typedef struct ImGuiState {
bool _showChannels = false;
bool _showCast = false;
bool _showFuncList = false;
+ bool _showScore = false;
Common::List<CastMemberID> _scriptCasts;
Common::HashMap<Common::String, bool, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _breakpoints;
Common::HashMap<Common::String, bool, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _variables;
@@ -1461,6 +1462,68 @@ static void showFuncList() {
ImGui::End();
}
+static void showScore() {
+ if (!_state->_showScore)
+ return;
+
+ ImVec2 pos(40, 40);
+ ImGui::SetNextWindowPos(pos, ImGuiCond_FirstUseEver);
+
+ ImVec2 windowSize = ImGui::GetMainViewport()->Size - pos - pos;
+ ImGui::SetNextWindowSize(windowSize, ImGuiCond_FirstUseEver);
+
+ if (ImGui::Begin("Score", &_state->_showScore)) {
+ Score *score = g_director->getCurrentMovie()->getScore();
+ uint numFrames = score->_scoreCache.size();
+
+ if (!numFrames) {
+ ImGui::Text("No frames");
+ ImGui::End();
+
+ return;
+ }
+
+ uint numChannels = score->_scoreCache[0]->_sprites.size();
+ uint tableColumns = MAX(numFrames, 25U); // Set minimal table width to 25
+
+ int currentFrameNum = score->getCurrentFrameNum();
+ ImU32 cell_bg_color = ImGui::GetColorU32(ImVec4(0.7f, 0.7f, 0.0f, 0.65f));
+
+ if (ImGui::BeginTable("Score", tableColumns + 1,
+ ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedSame |
+ ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg)) {
+ ImGuiTableFlags flags = ImGuiTableColumnFlags_WidthFixed;
+
+ ImGui::TableSetupColumn("##", flags);
+ for (uint i = 0; i < tableColumns; i++)
+ ImGui::TableSetupColumn(Common::String::format("%-2d", i + 1).c_str(), flags);
+
+ ImGui::TableHeadersRow();
+ for (int ch = 0; ch < numChannels - 1; ch++) {
+ ImGui::TableNextRow();
+
+ ImGui::TableNextColumn();
+ ImGui::Text("%-3d", ch + 1);
+
+ for (uint f = 0; f < numFrames; f++) {
+ Sprite &sprite = *score->_scoreCache[f]->_sprites[ch + 1];
+
+ if (f == currentFrameNum)
+ ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, cell_bg_color);
+
+ ImGui::TableNextColumn();
+
+ if (sprite._castId.member) {
+ ImGui::Text("%d", sprite._castId.member);
+ }
+ }
+ }
+ ImGui::EndTable();
+ }
+ }
+ ImGui::End();
+}
+
void onImGuiInit() {
ImGuiIO &io = ImGui::GetIO();
io.Fonts->AddFontDefault();
@@ -1498,6 +1561,7 @@ void onImGuiRender() {
ImGui::MenuItem("Channels", NULL, &_state->_showChannels);
ImGui::MenuItem("Cast", NULL, &_state->_showCast);
ImGui::MenuItem("Functions", NULL, &_state->_showFuncList);
+ ImGui::MenuItem("Score", NULL, &_state->_showScore);
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
@@ -1512,6 +1576,7 @@ void onImGuiRender() {
showChannels();
showCast();
showFuncList();
+ showScore();
}
void onImGuiCleanup() {
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index f66199bfab1..cdcda48be17 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -100,6 +100,9 @@ Score::~Score() {
delete _labels;
+ for (auto &it : _scoreCache)
+ delete it;
+
if (_framesStream)
delete _framesStream;
@@ -1595,7 +1598,11 @@ void Score::loadFrames(Common::SeekableReadStreamEndian &stream, uint16 version)
// Calculate number of frames and their positions
// numOfFrames in the header is often incorrect
- for (_numFrames = 1; loadFrame(_numFrames, false); _numFrames++) { }
+ for (_numFrames = 1; loadFrame(_numFrames, false); _numFrames++) {
+ if (debugChannelSet(-1, kDebugImGui)) {
+ _scoreCache.push_back(new Frame(*_currentFrame));
+ }
+ }
debugC(1, kDebugLoading, "Score::loadFrames(): Calculated, total number of frames %d!", _numFrames);
@@ -1603,7 +1610,6 @@ void Score::loadFrames(Common::SeekableReadStreamEndian &stream, uint16 version)
loadFrame(1, true);
-
debugC(1, kDebugLoading, "Score::loadFrames(): Number of frames: %d, framesStreamSize: %d", _numFrames, _framesStreamSize);
}
diff --git a/engines/director/score.h b/engines/director/score.h
index 0e4191fbe71..43db7ede618 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -152,6 +152,8 @@ public:
Common::HashMap<uint16, Common::String> _actions;
Common::HashMap<uint16, bool> _immediateActions;
+ Common::Array<Frame *> _scoreCache;
+
// On demand frames loading
uint32 _version;
Frame *_currentFrame;
More information about the Scummvm-git-logs
mailing list