[Scummvm-git-logs] scummvm master -> 51e9ca9372b57da22bb007352f7a7aa84b6797ac
sev-
noreply at scummvm.org
Mon Sep 2 09:47:05 UTC 2024
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5da983d8fa QDENGINE: Add ImGui debug channel
ab66430298 QDENGINE: Add a method to retrieve to the contents of the resource pak
c456141d5a QDENGINE: Add ImGui to the engine
51e9ca9372 QDENGINE: Implement rendering of the file list
Commit: 5da983d8fa7fe0e87d25e9a5dde6a624927f2f14
https://github.com/scummvm/scummvm/commit/5da983d8fa7fe0e87d25e9a5dde6a624927f2f14
Author: kunxl-gg (tiwari.25 at iitj.ac.in)
Date: 2024-09-02T11:47:00+02:00
Commit Message:
QDENGINE: Add ImGui debug channel
Signed-off-by: kunxl-gg <tiwari.25 at iitj.ac.in>
Changed paths:
engines/qdengine/detection.cpp
engines/qdengine/qdengine.h
diff --git a/engines/qdengine/detection.cpp b/engines/qdengine/detection.cpp
index 76a3661574a..376c25f7e7c 100644
--- a/engines/qdengine/detection.cpp
+++ b/engines/qdengine/detection.cpp
@@ -35,6 +35,7 @@
static const DebugChannelDef debugFlagList[] = {
{ QDEngine::kDebugGraphics, "graphics", "Graphics debug level" },
+ { QDEngine::kDebugImGui, "imgui", "Imgui debug output"},
{ QDEngine::kDebugInput, "input", "Enable user input tracing"},
{ QDEngine::kDebugLoad, "load", "Enable load tracing" },
{ QDEngine::kDebugLog, "log", "See log messages"},
diff --git a/engines/qdengine/qdengine.h b/engines/qdengine/qdengine.h
index e4639777b2e..5638e4f82c9 100644
--- a/engines/qdengine/qdengine.h
+++ b/engines/qdengine/qdengine.h
@@ -46,6 +46,7 @@ class qdGameDispatcher;
enum QDEngineDebugChannels {
kDebugGraphics = 1,
+ kDebugImGui,
kDebugInput,
kDebugLoad,
kDebugLog,
Commit: ab66430298bd28cf89db2bd8a53337448be7aaca
https://github.com/scummvm/scummvm/commit/ab66430298bd28cf89db2bd8a53337448be7aaca
Author: kunxl-gg (tiwari.25 at iitj.ac.in)
Date: 2024-09-02T11:47:00+02:00
Commit Message:
QDENGINE: Add a method to retrieve to the contents of the resource pak
Signed-off-by: kunxl-gg <tiwari.25 at iitj.ac.in>
Changed paths:
engines/qdengine/qdcore/qd_file_manager.h
diff --git a/engines/qdengine/qdcore/qd_file_manager.h b/engines/qdengine/qdcore/qd_file_manager.h
index fef7229b66c..9cc00e65b50 100644
--- a/engines/qdengine/qdcore/qd_file_manager.h
+++ b/engines/qdengine/qdcore/qd_file_manager.h
@@ -89,6 +89,10 @@ public:
return _packages[idx].is_open();
}
bool is_package_available(const qdFileOwner &file_owner);
+ Common::Archive *get_package(int idx) {
+ assert(idx >= 0 && idx < _packageCount);
+ return _packages[idx]._container;
+ }
bool scan_drives(const qdFileOwner *file_owner = NULL) { return true; }
bool scan_drives(int cd_id) { return true; }
Commit: c456141d5ab7d8ba25c7cadf58ede2ed07b63984
https://github.com/scummvm/scummvm/commit/c456141d5ab7d8ba25c7cadf58ede2ed07b63984
Author: kunxl-gg (tiwari.25 at iitj.ac.in)
Date: 2024-09-02T11:47:00+02:00
Commit Message:
QDENGINE: Add ImGui to the engine
Signed-off-by: kunxl-gg <tiwari.25 at iitj.ac.in>
Changed paths:
A engines/qdengine/debugger/debugtools.cpp
A engines/qdengine/debugger/debugtools.h
engines/qdengine/module.mk
engines/qdengine/qdengine.cpp
diff --git a/engines/qdengine/debugger/debugtools.cpp b/engines/qdengine/debugger/debugtools.cpp
new file mode 100644
index 00000000000..b6e858c6872
--- /dev/null
+++ b/engines/qdengine/debugger/debugtools.cpp
@@ -0,0 +1,153 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "backends/imgui/imgui.h"
+
+#include "common/archive.h"
+#include "common/compression/unzip.h"
+#include "common/debug.h"
+#include "common/path.h"
+
+#include "qdengine/qdengine.h"
+#include "qdengine/debugger/debugtools.h"
+#include "qdengine/qdcore/qd_file_manager.h"
+
+namespace QDEngine {
+
+typedef struct ImGuiState {
+ bool _showCallStack = false;
+ bool _showVars = false;
+ bool _showScore = false;
+ bool _showArchives = false;
+} ImGuiState;
+
+ImGuiState *_state = nullptr;
+
+static void showCallStack() {
+}
+
+static void showVars() {
+}
+
+void showArchives() {
+ if (!_state->_showArchives)
+ return;
+
+ // Calculate the viewport size
+ ImVec2 viewportSize = ImGui::GetMainViewport()->Size;
+
+ // Calculate the window size
+ ImVec2 windowSize = ImVec2(
+ viewportSize.x * 0.5f,
+ viewportSize.y * 0.5f
+ );
+
+ // Calculate the centered position
+ ImVec2 centeredPosition = ImVec2(
+ (viewportSize.x - windowSize.x) * 0.5f,
+ (viewportSize.y - windowSize.y) * 0.5f
+ );
+
+ // Set the next window position and size
+ ImGui::SetNextWindowPos(centeredPosition, ImGuiCond_FirstUseEver);
+ ImGui::SetNextWindowSize(windowSize, ImGuiCond_FirstUseEver);
+
+ if (ImGui::Begin("Archives", &_state->_showArchives)) {
+ ImGui::BeginChild("ChildL", ImVec2(ImGui::GetContentRegionAvail().x * 0.3f, ImGui::GetContentRegionAvail().y), ImGuiChildFlags_None);
+
+ for (int i = 0; i < 3; i++) {
+ Common::Archive *archive = qdFileManager::instance().get_package(0);
+ Common::ArchiveMemberList members;
+ archive->listMembers(members);
+
+ if (ImGui::TreeNode(Common::String::format("Resource/resource%d.pak", i).c_str())) {
+
+ for (auto &it : members) {
+ if (ImGui::TreeNode(Common::String::format("%s", transCyrillic(it->getFileName().c_str())).c_str())) {
+
+ if (ImGui::Selectable(Common::String::format("%d", i).c_str())) {
+ }
+
+ ImGui::TreePop();
+ }
+ }
+
+ ImGui::TreePop();
+ }
+ }
+
+ ImGui::EndChild();
+ }
+ ImGui::End();
+}
+
+static void showScore() {
+ if (!_state->_showScore)
+ return;
+
+ ImGui::SetNextWindowPos(ImVec2(20, 160), ImGuiCond_FirstUseEver);
+ ImGui::SetNextWindowSize(ImVec2(120, 120), ImGuiCond_FirstUseEver);
+ if (ImGui::Begin("Score", &_state->_showScore)) {
+ ImGui::Text("WIP");
+ }
+ ImGui::End();
+}
+
+void onImGuiInit() {
+ _state = new ImGuiState();
+ memset(_state, 0, sizeof(ImGuiState));
+}
+
+void onImGuiRender() {
+ if (!debugChannelSet(-1, kDebugImGui)) {
+ ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange | ImGuiConfigFlags_NoMouse;
+ return;
+ }
+
+ if (!_state)
+ return;
+
+ ImGui::GetIO().ConfigFlags &= ~(ImGuiConfigFlags_NoMouseCursorChange | ImGuiConfigFlags_NoMouse);
+
+ if (ImGui::BeginMainMenuBar()) {
+ if (ImGui::BeginMenu("View")) {
+ ImGui::SeparatorText("Windows");
+
+ ImGui::MenuItem("CallStack", NULL, &_state->_showCallStack);
+ ImGui::MenuItem("Vars", NULL, &_state->_showVars);
+ ImGui::MenuItem("Score", NULL, &_state->_showScore);
+ ImGui::MenuItem("Archives", NULL, &_state->_showArchives);
+ ImGui::EndMenu();
+ }
+ ImGui::EndMainMenuBar();
+ }
+
+ showVars();
+ showCallStack();
+ showScore();
+ showArchives();
+}
+
+void onImGuiCleanup() {
+ delete _state;
+ _state = nullptr;
+}
+} // namespace QDEngine
diff --git a/engines/qdengine/debugger/debugtools.h b/engines/qdengine/debugger/debugtools.h
new file mode 100644
index 00000000000..32370704ca5
--- /dev/null
+++ b/engines/qdengine/debugger/debugtools.h
@@ -0,0 +1,31 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef QDENGINE_DEBUGTOOLS_H
+#define QDENGINE_DEBUGTOOLS_H
+
+namespace QDEngine {
+void onImGuiInit();
+void onImGuiRender();
+void onImGuiCleanup();
+} // namespace QDEngine
+
+#endif // QDENGINE_DEBUGTOOLS_H
diff --git a/engines/qdengine/module.mk b/engines/qdengine/module.mk
index 957cbf221d3..8ceb8a6bc86 100644
--- a/engines/qdengine/module.mk
+++ b/engines/qdengine/module.mk
@@ -4,6 +4,7 @@ MODULE_OBJS = \
qdengine.o \
console.o \
metaengine.o \
+ debugger/debugtools.o \
parser/qdscr_parser.o \
parser/xml_parser.o \
parser/xml_tag_buffer.o \
diff --git a/engines/qdengine/qdengine.cpp b/engines/qdengine/qdengine.cpp
index ef5b369fa98..405d7b2f168 100644
--- a/engines/qdengine/qdengine.cpp
+++ b/engines/qdengine/qdengine.cpp
@@ -19,6 +19,9 @@
*
*/
+#include "backends/imgui/imgui.h"
+
+#include "common/system.h"
#include "common/scummsys.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
@@ -34,6 +37,8 @@
#include "qdengine/console.h"
#include "qdengine/resource.h"
+#include "qdengine/debugger/debugtools.h"
+
#include "qdengine/parser/qdscr_parser.h"
#include "qdengine/qdcore/qd_file_manager.h"
@@ -209,6 +214,15 @@ Common::Error QDEngineEngine::run() {
bool exit_flag = false;
bool was_inactive = false;
+#ifdef USE_IMGUI
+ ImGuiCallbacks callbacks;
+ bool drawImGui = debugChannelSet(-1, kDebugImGui);
+ callbacks.init = QDEngine::onImGuiInit;
+ callbacks.render = drawImGui ? QDEngine::onImGuiRender : nullptr;
+ callbacks.cleanup = QDEngine::onImGuiCleanup;
+ _system->setImGuiCallbacks(callbacks);
+#endif
+
// Activate the window
grDispatcher::activate(true);
@@ -256,6 +270,15 @@ Common::Error QDEngineEngine::run() {
input::mouse_wndproc(event, mouseDispatcher::instance());
}
+ // For performance reasons, disable the renderer callback if the ImGui debug flag isn't set
+#ifdef USE_IMGUI
+ if (debugChannelSet(-1, kDebugImGui) != drawImGui) {
+ drawImGui = !drawImGui;
+ callbacks.render = drawImGui ? QDEngine::onImGuiRender : nullptr;
+ _system->setImGuiCallbacks(callbacks);
+ }
+#endif
+
if (grDispatcher::instance()->is_mouse_hidden())
grDispatcher::instance()->set_null_mouse_cursor();
else
Commit: 51e9ca9372b57da22bb007352f7a7aa84b6797ac
https://github.com/scummvm/scummvm/commit/51e9ca9372b57da22bb007352f7a7aa84b6797ac
Author: kunxl-gg (tiwari.25 at iitj.ac.in)
Date: 2024-09-02T11:47:00+02:00
Commit Message:
QDENGINE: Implement rendering of the file list
Signed-off-by: kunxl-gg <tiwari.25 at iitj.ac.in>
Changed paths:
engines/qdengine/debugger/debugtools.cpp
engines/qdengine/qdcore/qd_file_manager.h
diff --git a/engines/qdengine/debugger/debugtools.cpp b/engines/qdengine/debugger/debugtools.cpp
index b6e858c6872..5d1152ad9a8 100644
--- a/engines/qdengine/debugger/debugtools.cpp
+++ b/engines/qdengine/debugger/debugtools.cpp
@@ -56,8 +56,8 @@ void showArchives() {
// Calculate the window size
ImVec2 windowSize = ImVec2(
- viewportSize.x * 0.5f,
- viewportSize.y * 0.5f
+ viewportSize.x * 0.7f,
+ viewportSize.y * 0.7f
);
// Calculate the centered position
@@ -73,12 +73,15 @@ void showArchives() {
if (ImGui::Begin("Archives", &_state->_showArchives)) {
ImGui::BeginChild("ChildL", ImVec2(ImGui::GetContentRegionAvail().x * 0.3f, ImGui::GetContentRegionAvail().y), ImGuiChildFlags_None);
+ // Iterate through the 3 resource pak files
for (int i = 0; i < 3; i++) {
- Common::Archive *archive = qdFileManager::instance().get_package(0);
+ Common::Archive *archive = qdFileManager::instance().get_package(i);
Common::ArchiveMemberList members;
- archive->listMembers(members);
- if (ImGui::TreeNode(Common::String::format("Resource/resource%d.pak", i).c_str())) {
+ if (archive)
+ archive->listMembers(members);
+
+ if (archive && ImGui::TreeNode(Common::String::format("Resource/resource%d.pak", i).c_str())) {
for (auto &it : members) {
if (ImGui::TreeNode(Common::String::format("%s", transCyrillic(it->getFileName().c_str())).c_str())) {
@@ -150,4 +153,5 @@ void onImGuiCleanup() {
delete _state;
_state = nullptr;
}
+
} // namespace QDEngine
diff --git a/engines/qdengine/qdcore/qd_file_manager.h b/engines/qdengine/qdcore/qd_file_manager.h
index 9cc00e65b50..04ea90edc0a 100644
--- a/engines/qdengine/qdcore/qd_file_manager.h
+++ b/engines/qdengine/qdcore/qd_file_manager.h
@@ -90,7 +90,6 @@ public:
}
bool is_package_available(const qdFileOwner &file_owner);
Common::Archive *get_package(int idx) {
- assert(idx >= 0 && idx < _packageCount);
return _packages[idx]._container;
}
More information about the Scummvm-git-logs
mailing list