[Scummvm-git-logs] scummvm master -> 8c2619dfe482d136333cac6c62f79b34523b42e7
bluegr
noreply at scummvm.org
Sun Sep 29 13:40:56 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:
8c2619dfe4 TESTBED: Add an ImGui test
Commit: 8c2619dfe482d136333cac6c62f79b34523b42e7
https://github.com/scummvm/scummvm/commit/8c2619dfe482d136333cac6c62f79b34523b42e7
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-09-29T16:40:53+03:00
Commit Message:
TESTBED: Add an ImGui test
Changed paths:
A engines/testbed/imgui.cpp
A engines/testbed/imgui.h
backends/module.mk
engines/testbed/module.mk
engines/testbed/testbed.cpp
diff --git a/backends/module.mk b/backends/module.mk
index 8cb79e3601e..086f2fb6a34 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -499,6 +499,7 @@ endif
ifdef USE_IMGUI
MODULE_OBJS += \
imgui/imgui.o \
+ imgui/imgui_demo.o \
imgui/imgui_draw.o \
imgui/imgui_fonts.o \
imgui/imgui_tables.o \
diff --git a/engines/testbed/imgui.cpp b/engines/testbed/imgui.cpp
new file mode 100644
index 00000000000..7f8e9e676ef
--- /dev/null
+++ b/engines/testbed/imgui.cpp
@@ -0,0 +1,104 @@
+/* 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 "common/system.h"
+#include "common/events.h"
+#include "engines/engine.h"
+#include "engines/testbed/imgui.h"
+
+#include "backends/imgui/imgui.h"
+#include "backends/imgui/imgui_fonts.h"
+
+namespace Testbed {
+
+static bool p_supported = false;
+static bool p_open = false;
+
+static void onImGuiInit() {
+ p_supported = true;
+}
+
+void onImGuiRender() {
+ if (p_open) {
+ ImGui::GetIO().ConfigFlags &= ~(ImGuiConfigFlags_NoMouseCursorChange | ImGuiConfigFlags_NoMouse);
+
+ ImGui::ShowDemoWindow(&p_open);
+ } else {
+ ImGui::GetIO().ConfigFlags |= (ImGuiConfigFlags_NoMouseCursorChange | ImGuiConfigFlags_NoMouse);
+ }
+}
+
+static void onImGuiCleanup() {
+}
+
+TestExitStatus Imguitests::testImGui() {
+ Testsuite::clearScreen();
+ Common::String info = "ImGui test. You should expect an ImGui dialog to appear on screen.\"";
+ if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
+ Testsuite::logPrintf("Info! Skipping test : testImGui\n");
+ return kTestSkipped;
+ }
+ Common::Point pt(0, 100);
+ Testsuite::writeOnScreen("Testing ImGui", pt);
+
+ p_open = true;
+
+ ImGuiCallbacks callbacks;
+ callbacks.init = onImGuiInit;
+ callbacks.render = onImGuiRender;
+ callbacks.cleanup = onImGuiCleanup;
+ g_system->setImGuiCallbacks(callbacks);
+
+ // Update the screen once so that it has the chance to initialise.
+ g_system->updateScreen();
+
+ if (!p_supported) {
+ Testsuite::logDetailedPrintf("ImGui failed\n");
+ return kTestFailed;
+ }
+
+ Common::EventManager *eventMan = g_system->getEventManager();
+ Common::Event event;
+ while (p_open) {
+ while (eventMan->pollEvent(event)) {
+ // Quit if explicitly requested
+ if (Engine::shouldQuit()) {
+ return kTestPassed;
+ }
+ }
+
+ g_system->updateScreen();
+ }
+
+ Common::String prompt = "Did you see an ImGui dialog?";
+ if (!Testsuite::handleInteractiveInput(prompt, "Yes", "No", kOptionLeft)) {
+ Testsuite::logDetailedPrintf("ImGui failed\n");
+ return kTestFailed;
+ }
+ return kTestPassed;
+}
+
+ImGuiTestSuite::ImGuiTestSuite() {
+ _isTsEnabled = true;
+ addTest("testImGui", &Imguitests::testImGui, true);
+}
+
+} // End of namespace Testbed
diff --git a/engines/testbed/imgui.h b/engines/testbed/imgui.h
new file mode 100644
index 00000000000..ef749f33dfd
--- /dev/null
+++ b/engines/testbed/imgui.h
@@ -0,0 +1,65 @@
+/* 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 TESTBED_IMGUI_H
+#define TESTBED_IMGUI_H
+
+#include "testbed/testsuite.h"
+
+namespace Testbed {
+
+namespace Imguitests {
+
+// Helper functions for ImGui tests
+
+// will contain function declarations for ImGui tests
+// add more here
+
+TestExitStatus testImGui();
+
+} // End of namespace Imguitests
+
+class ImGuiTestSuite : public Testsuite {
+public:
+ /**
+ * The constructor for the XXXTestSuite
+ * For every test to be executed one must:
+ * 1) Create a function that would invoke the test
+ * 2) Add that test to list by executing addTest()
+ *
+ * @see addTest()
+ */
+ ImGuiTestSuite();
+ ~ImGuiTestSuite() override {}
+ const char *getName() const override {
+ return "ImGui";
+ }
+
+ const char *getDescription() const override {
+ return "ImGui Subsystem";
+ }
+
+};
+
+
+} // End of namespace Testbed
+
+#endif // TESTBED_IMGUI_H
diff --git a/engines/testbed/module.mk b/engines/testbed/module.mk
index a3419284775..38fc35e85af 100644
--- a/engines/testbed/module.mk
+++ b/engines/testbed/module.mk
@@ -33,6 +33,11 @@ MODULE_OBJS += \
speech.o
endif
+ifdef USE_IMGUI
+MODULE_OBJS += \
+ imgui.o
+endif
+
MODULE_DIRS += \
engines/testbed
diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp
index 1d6705864c6..d44cf59feea 100644
--- a/engines/testbed/testbed.cpp
+++ b/engines/testbed/testbed.cpp
@@ -50,6 +50,9 @@
#ifdef USE_TTS
#include "testbed/speech.h"
#endif
+#ifdef USE_IMGUI
+#include "testbed/imgui.h"
+#endif
namespace Testbed {
@@ -166,6 +169,11 @@ void TestbedEngine::pushTestsuites(Common::Array<Testsuite *> &testsuiteList) {
// Webserver
ts = new WebserverTestSuite();
testsuiteList.push_back(ts);
+#endif
+#ifdef USE_IMGUI
+ // ImGui
+ ts = new ImGuiTestSuite();
+ testsuiteList.push_back(ts);
#endif
// Video decoder
ts = new VideoDecoderTestSuite();
More information about the Scummvm-git-logs
mailing list