[Scummvm-git-logs] scummvm master -> 4c6d2073e8b2412d6ac8d33102d8638794e1f822

scemino noreply at scummvm.org
Sun Apr 28 20:47:35 UTC 2024


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d592496750 DIRECTOR: Show imgui only when requested
4c6d2073e8 DIRECTOR: IMGUI: Add a main menu


Commit: d59249675081abd23d27e9eef04b44f3371ed2e6
    https://github.com/scummvm/scummvm/commit/d59249675081abd23d27e9eef04b44f3371ed2e6
Author: scemino (scemino74 at gmail.com)
Date: 2024-04-28T22:46:59+02:00

Commit Message:
DIRECTOR: Show imgui only when requested

Changed paths:
    engines/director/debugtools.cpp
    engines/director/detection.cpp
    engines/director/director.h


diff --git a/engines/director/debugtools.cpp b/engines/director/debugtools.cpp
index dd2df33a0ef..f1b6f2e1e7f 100644
--- a/engines/director/debugtools.cpp
+++ b/engines/director/debugtools.cpp
@@ -31,7 +31,13 @@ void onImGuiInit() {
 }
 
 void onImGuiRender() {
-	Director::Lingo* lingo = g_director->getLingo();
+	if (!debugChannelSet(-1, kDebugImGui)) {
+		ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange | ImGuiConfigFlags_NoMouse;
+		return;
+	}
+
+	ImGui::GetIO().ConfigFlags &= ~(ImGuiConfigFlags_NoMouseCursorChange | ImGuiConfigFlags_NoMouse);
+	Director::Lingo *lingo = g_director->getLingo();
 
 	ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);
 	ImGui::SetNextWindowSize(ImVec2(120, 120), ImGuiCond_FirstUseEver);
@@ -51,4 +57,4 @@ void onImGuiRender() {
 
 void onImGuiCleanup() {
 }
-} // namespace Twp
+} // namespace Director
diff --git a/engines/director/detection.cpp b/engines/director/detection.cpp
index 80c1659dfdd..e91a37ac99b 100644
--- a/engines/director/detection.cpp
+++ b/engines/director/detection.cpp
@@ -73,6 +73,7 @@ static const DebugChannelDef debugFlagList[] = {
 	{Director::kDebugText, "text", "Text rendering"},
 	{Director::kDebugXObj, "xobj", "XObjects"},
 	{Director::kDebugLingoThe, "lingothe", "Lingo \"the\" entities"},
+	{Director::kDebugImGui, "imgui", "Show ImGui debug window (if available)"},
 	DEBUG_CHANNEL_END
 };
 
diff --git a/engines/director/director.h b/engines/director/director.h
index 1eaf1c257a2..fc6e1a39f84 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -85,6 +85,7 @@ enum {
 	kDebugConsole,
 	kDebugXObj,
 	kDebugLingoThe,
+	kDebugImGui,
 };
 
 enum {


Commit: 4c6d2073e8b2412d6ac8d33102d8638794e1f822
    https://github.com/scummvm/scummvm/commit/4c6d2073e8b2412d6ac8d33102d8638794e1f822
Author: scemino (scemino74 at gmail.com)
Date: 2024-04-28T22:46:59+02:00

Commit Message:
DIRECTOR: IMGUI: Add a main menu

Changed paths:
    engines/director/debugtools.cpp


diff --git a/engines/director/debugtools.cpp b/engines/director/debugtools.cpp
index f1b6f2e1e7f..fbf02a64b96 100644
--- a/engines/director/debugtools.cpp
+++ b/engines/director/debugtools.cpp
@@ -27,34 +27,88 @@
 
 namespace Director {
 
-void onImGuiInit() {
-}
+typedef struct ImGuiState {
+	bool _showCallStack;
+	bool _showVars;
+	bool _showScore;
+} ImGuiState;
 
-void onImGuiRender() {
-	if (!debugChannelSet(-1, kDebugImGui)) {
-		ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange | ImGuiConfigFlags_NoMouse;
+ImGuiState *_state = nullptr;
+
+static void showCallStack() {
+	if (!_state->_showCallStack)
 		return;
-	}
 
-	ImGui::GetIO().ConfigFlags &= ~(ImGuiConfigFlags_NoMouseCursorChange | ImGuiConfigFlags_NoMouse);
 	Director::Lingo *lingo = g_director->getLingo();
+	ImGui::SetNextWindowPos(ImVec2(20, 160), ImGuiCond_FirstUseEver);
+	ImGui::SetNextWindowSize(ImVec2(120, 120), ImGuiCond_FirstUseEver);
+	if (ImGui::Begin("CallStack", &_state->_showCallStack)) {
+		ImGui::Text("%s", lingo->formatCallStack(lingo->_state->pc).c_str());
+	}
+	ImGui::End();
+}
+
+static void showVars() {
+	if (!_state->_showVars)
+		return;
 
+	Director::Lingo *lingo = g_director->getLingo();
 	ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);
 	ImGui::SetNextWindowSize(ImVec2(120, 120), ImGuiCond_FirstUseEver);
-	ImGui::Begin("Vars");
-	ImGui::Text("%s", lingo->formatAllVars().c_str());
-	ImGui::Separator();
-	ImGuiIO &io = ImGui::GetIO();
-	ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
+	if (ImGui::Begin("Vars", &_state->_showVars)) {
+		ImGui::Text("%s", lingo->formatAllVars().c_str());
+		ImGui::Separator();
+		ImGuiIO &io = ImGui::GetIO();
+		ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
+	}
 	ImGui::End();
+}
+
+static void showScore() {
+	if (!_state->_showScore)
+		return;
 
 	ImGui::SetNextWindowPos(ImVec2(20, 160), ImGuiCond_FirstUseEver);
 	ImGui::SetNextWindowSize(ImVec2(120, 120), ImGuiCond_FirstUseEver);
-	ImGui::Begin("CallStack");
-	ImGui::Text("%s", lingo->formatCallStack(lingo->_state->pc).c_str());
+	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::MenuItem("CallStack", NULL, &_state->_showCallStack);
+			ImGui::MenuItem("Vars", NULL, &_state->_showVars);
+			ImGui::MenuItem("Score", NULL, &_state->_showScore);
+			ImGui::EndMenu();
+		}
+		ImGui::EndMainMenuBar();
+	}
+
+	showVars();
+	showCallStack();
+	showScore();
+}
+
 void onImGuiCleanup() {
+	delete _state;
+	_state = nullptr;
 }
 } // namespace Director




More information about the Scummvm-git-logs mailing list