[Scummvm-git-logs] scummvm master -> 05480e11c90580ebdbe3095689ee47fac67794fe
mgerhardy
noreply at scummvm.org
Mon Oct 7 08:05:49 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:
05480e11c9 TWINE: basic layout from director engine for imgui debug tools
Commit: 05480e11c90580ebdbe3095689ee47fac67794fe
https://github.com/scummvm/scummvm/commit/05480e11c90580ebdbe3095689ee47fac67794fe
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-10-07T10:05:28+02:00
Commit Message:
TWINE: basic layout from director engine for imgui debug tools
Changed paths:
A engines/twine/debugger/debugtools.cpp
A engines/twine/debugger/debugtools.h
A engines/twine/debugger/dt-internal.h
engines/twine/debugger/console.cpp
engines/twine/debugger/console.h
engines/twine/debugger/debug.cpp
engines/twine/debugger/debug.h
engines/twine/debugger/debug_grid.cpp
engines/twine/debugger/debug_grid.h
engines/twine/debugger/debug_scene.cpp
engines/twine/debugger/debug_scene.h
engines/twine/detection.cpp
engines/twine/holomap_v1.h
engines/twine/input.cpp
engines/twine/input.h
engines/twine/metaengine.cpp
engines/twine/module.mk
engines/twine/renderer/redraw.cpp
engines/twine/shared.h
engines/twine/twine.cpp
diff --git a/engines/twine/debugger/console.cpp b/engines/twine/debugger/console.cpp
index 4553c9ac29c..5146bbecb6d 100644
--- a/engines/twine/debugger/console.cpp
+++ b/engines/twine/debugger/console.cpp
@@ -60,7 +60,6 @@ TwinEConsole::TwinEConsole(TwinEEngine *engine) : _engine(engine), GUI::Debugger
registerCmd("toggle_actors", WRAP_METHOD(TwinEConsole, doToggleActorRendering));
registerCmd("toggle_clips", WRAP_METHOD(TwinEConsole, doToggleClipRendering));
registerCmd("toggle_freecamera", WRAP_METHOD(TwinEConsole, doToggleFreeCamera));
- registerCmd("toggle_scenechanges", WRAP_METHOD(TwinEConsole, doToggleSceneChanges));
registerCmd("toggle_scenerendering", WRAP_METHOD(TwinEConsole, doToggleSceneRendering));
registerCmd("set_track_obj", WRAP_METHOD(TwinEConsole, doSetTrackObject));
registerCmd("scene_actor", WRAP_METHOD(TwinEConsole, doSkipSceneActorsBut));
@@ -168,11 +167,6 @@ bool TwinEConsole::doToggleFreeCamera(int argc, const char **argv) {
return true;
}
-bool TwinEConsole::doToggleSceneChanges(int argc, const char **argv) {
- TOGGLE_DEBUG(_engine->_debugGrid->_canChangeScenes, "scene switching via keybinding\n")
- return true;
-}
-
bool TwinEConsole::doSetTrackObject(int argc, const char **argv) {
if (argc <= 2) {
debugPrintf("Expected to get a the scene actor number and the track\n");
diff --git a/engines/twine/debugger/console.h b/engines/twine/debugger/console.h
index ba17d3b26c0..af1ade8d7a8 100644
--- a/engines/twine/debugger/console.h
+++ b/engines/twine/debugger/console.h
@@ -60,7 +60,6 @@ private:
bool doToggleGodMode(int argc, const char **argv);
bool doToggleEnhancements(int argc, const char **argv);
bool doToggleFreeCamera(int argc, const char **argv);
- bool doToggleSceneChanges(int argc, const char **argv);
bool doToggleSceneRendering(int argc, const char **argv);
bool doSetTrackObject(int argc, const char **argv);
bool doChangeChapter(int argc, const char **argv);
diff --git a/engines/twine/debugger/debug.cpp b/engines/twine/debugger/debug.cpp
index 06269387c44..21f927c2ef1 100644
--- a/engines/twine/debugger/debug.cpp
+++ b/engines/twine/debugger/debug.cpp
@@ -20,455 +20,12 @@
*/
#include "twine/debugger/debug.h"
-
-#include "common/system.h"
#include "twine/debugger/debug_grid.h"
-#include "twine/debugger/debug_scene.h"
-#include "twine/menu/interface.h"
-#include "twine/menu/menu.h"
-#include "twine/renderer/redraw.h"
-#include "twine/renderer/screens.h"
-#include "twine/scene/scene.h"
-#include "twine/scene/grid.h"
-#include "twine/text.h"
#include "twine/twine.h"
namespace TwinE {
-void Debug::debugFillButton(int32 x, int32 y, int32 width, int32 height, int8 color) {
- const Common::Rect rect(x, y, x + width, y + height);
- _engine->_interface->box(rect, color);
-}
-
-void Debug::debugDrawButton(const Common::Rect &rect, const char *text, int32 textLeft, int32 textTop, int32 isActive, int8 color) {
- debugFillButton(rect.left + 1, rect.top + 1, rect.right - rect.left - 1, rect.bottom - rect.top - 1, color);
- _engine->_menu->drawRectBorders(rect);
- _engine->drawText(textLeft, textTop, text, 0);
- _engine->copyBlockPhys(rect);
-}
-
-void Debug::debugDrawWindowButtons(int32 w) {
- DebugWindowStruct &window = _debugWindows[w];
- for (int32 b = 0; b < window.numButtons; b++) {
- DebugButtonStruct &btn = window.debugButtons[b];
- const char *text = btn.text;
- const int32 textLeft = btn.textLeft;
- const int32 textTop = btn.textTop;
- const int32 isActive = btn.isActive;
- int8 color = btn.color;
- if (isActive > 0) {
- color = btn.activeColor;
- }
-
- debugDrawButton(btn.rect, text, textLeft, textTop, isActive, color);
- }
-}
-
-void Debug::debugDrawWindow(int32 w) {
- DebugWindowStruct &window = _debugWindows[w];
- const Common::Rect &rect = window.rect;
- const int32 alpha = window.alpha;
-
- _engine->_interface->shadeBox(rect, alpha);
- _engine->_menu->drawRectBorders(rect);
-
- if (window.numLines > 0) {
- for (int32 l = 0; l < window.numLines; l++) {
- _engine->drawText(rect.left + 10, rect.top + l * 20 + 5, window.text[l], 0);
- }
- }
-
- debugDrawWindowButtons(w);
-}
-
-int32 Debug::debugTypeUseMenu(int32 type) {
- for (int32 w = 0; w < _numDebugWindows; w++) {
- DebugWindowStruct &window = _debugWindows[w];
- if (window.isActive <= 0) {
- continue;
- }
- for (int32 b = 0; b < window.numButtons; b++) {
- DebugButtonStruct &btn = window.debugButtons[b];
- if (btn.type != type) {
- continue;
- }
- const int submenu = btn.submenu;
- if (submenu > 0) {
- _debugWindows[submenu].isActive = !_debugWindows[submenu].isActive;
- }
- return submenu;
- }
- }
- return 0;
-}
-
-void Debug::debugResetButtonsState() {
- for (int32 w = 0; w < _numDebugWindows; w++) {
- DebugWindowStruct &window = _debugWindows[w];
- if (window.isActive <= 0) {
- continue;
- }
- for (int32 b = 0; b < window.numButtons; b++) {
- DebugButtonStruct &btn = window.debugButtons[b];
- if (btn.type > -1) {
- continue;
- }
- btn.isActive = 0;
- }
- }
-}
-
-void Debug::debugRefreshButtons(int32 type) {
- for (int32 w = 0; w < _numDebugWindows; w++) {
- DebugWindowStruct &window = _debugWindows[w];
- if (window.isActive <= 0) {
- continue;
- }
- for (int32 b = 0; b < window.numButtons; b++) {
- DebugButtonStruct &btn = window.debugButtons[b];
- if (btn.type != type) {
- continue;
- }
- const char *text = btn.text;
- const int32 textLeft = btn.textLeft;
- const int32 textTop = btn.textTop;
- int8 color = btn.color;
- const int32 isActive = btn.isActive = !btn.isActive;
-
- if (isActive > 0) {
- color = btn.activeColor;
- }
-
- debugDrawButton(btn.rect, text, textLeft, textTop, isActive, color);
-
- if (btn.submenu && isActive > 0) {
- debugDrawWindow(btn.submenu);
- }
- }
- }
-}
-
-void Debug::debugDrawWindows() {
- for (int32 w = 0; w < _numDebugWindows; w++) {
- DebugWindowStruct &window = _debugWindows[w];
- if (window.isActive > 0) {
- debugDrawWindow(w);
- }
- }
-}
-
-void Debug::debugResetButton(int32 type) {
- for (int32 w = 0; w < _numDebugWindows; w++) {
- DebugWindowStruct &window = _debugWindows[w];
- if (window.isActive <= 0) {
- continue;
- }
- for (int32 b = 0; b < window.numButtons; b++) {
- DebugButtonStruct &btn = window.debugButtons[b];
- if (btn.type != type) {
- continue;
- }
- const int submenu = btn.submenu;
- btn.isActive = 0;
- if (submenu > 0) {
- _debugWindows[submenu].debugButtons[b].isActive = !_debugWindows[submenu].debugButtons[b].isActive;
- }
- break;
- }
- }
-}
-
-void Debug::debugRedrawScreen() {
- _engine->_redraw->redrawEngineActions(true);
- _engine->saveFrontBuffer();
- debugDrawWindows();
-}
-
-int32 Debug::debugGetActionsState(int32 type) {
- int32 state = 0;
-
- switch (type) {
- case FREE_CAMERA:
- state = _engine->_debugGrid->_useFreeCamera ? 1 : 0;
- break;
- case CHANGE_SCENE:
- state = _engine->_debugGrid->_canChangeScenes ? 1 : 0;
- break;
- case SHOW_ZONES:
- state = _engine->_debugScene->_showingZones ? 1 : 0;
- break;
- case SHOW_ZONE_CUBE:
- case SHOW_ZONE_CAMERA:
- case SHOW_ZONE_SCENARIC:
- case SHOW_ZONE_CELLINGGRID:
- case SHOW_ZONE_OBJECT:
- case SHOW_ZONE_TEXT:
- case SHOW_ZONE_LADDER:
- state = _engine->_debugScene->_typeZones;
- break;
- default:
- break;
- }
- return state;
-}
-
-void Debug::debugSetActions(int32 type) {
- switch (type) {
- case FREE_CAMERA:
- _engine->_debugGrid->_useFreeCamera = !_engine->_debugGrid->_useFreeCamera;
- break;
-
- case CHANGE_SCENE:
- _engine->_debugGrid->_canChangeScenes = !_engine->_debugGrid->_canChangeScenes;
- break;
-
- case SHOW_ZONES:
- _engine->_debugScene->_showingZones = !_engine->_debugScene->_showingZones;
- debugResetButton(-1);
- debugResetButton(-2);
- debugRedrawScreen();
- break;
- case SHOW_ZONE_CUBE:
- if (_engine->_debugScene->_showingZones) {
- if (_engine->_debugScene->_typeZones & 0x01)
- _engine->_debugScene->_typeZones &= ~0x01;
- else
- _engine->_debugScene->_typeZones |= 0x01;
- debugRedrawScreen();
- }
- break;
- case SHOW_ZONE_CAMERA:
- if (_engine->_debugScene->_showingZones) {
- if (_engine->_debugScene->_typeZones & 0x02)
- _engine->_debugScene->_typeZones &= ~0x02;
- else
- _engine->_debugScene->_typeZones |= 0x02;
- debugRedrawScreen();
- }
- break;
- case SHOW_ZONE_SCENARIC:
- if (_engine->_debugScene->_showingZones) {
- if (_engine->_debugScene->_typeZones & 0x04)
- _engine->_debugScene->_typeZones &= ~0x04;
- else
- _engine->_debugScene->_typeZones |= 0x04;
- debugRedrawScreen();
- }
- break;
- case SHOW_ZONE_CELLINGGRID:
- if (_engine->_debugScene->_showingZones) {
- if (_engine->_debugScene->_typeZones & 0x08)
- _engine->_debugScene->_typeZones &= ~0x08;
- else
- _engine->_debugScene->_typeZones |= 0x08;
- debugRedrawScreen();
- debugRedrawScreen();
- }
- break;
- case SHOW_ZONE_OBJECT:
- if (_engine->_debugScene->_showingZones) {
- if (_engine->_debugScene->_typeZones & 0x10)
- _engine->_debugScene->_typeZones &= ~0x10;
- else
- _engine->_debugScene->_typeZones |= 0x10;
- debugRedrawScreen();
- debugRedrawScreen();
- }
- break;
- case SHOW_ZONE_TEXT:
- if (_engine->_debugScene->_showingZones) {
- if (_engine->_debugScene->_typeZones & 0x20)
- _engine->_debugScene->_typeZones &= ~0x20;
- else
- _engine->_debugScene->_typeZones |= 0x20;
- debugRedrawScreen();
- }
- break;
- case SHOW_ZONE_LADDER:
- if (_engine->_debugScene->_showingZones) {
- if (_engine->_debugScene->_typeZones & 0x40)
- _engine->_debugScene->_typeZones &= ~0x40;
- else
- _engine->_debugScene->_typeZones |= 0x40;
- debugRedrawScreen();
- }
- break;
-
- case -1:
- debugResetButton(-2);
- debugRedrawScreen();
- break;
- case -2:
- debugResetButton(-1);
- debugRedrawScreen();
- break;
- default:
- break;
- }
-}
-
-void Debug::debugAddButton(int32 window, const Common::Rect &rect, const char *text, int32 textLeft, int32 textTop, int32 isActive, int32 color, int32 activeColor, int32 submenu, int32 type) {
- const int32 button = _debugWindows[window].numButtons;
- DebugButtonStruct &btn = _debugWindows[window].debugButtons[button];
- btn.rect = rect;
- btn.text = text;
- btn.textLeft = textLeft;
- btn.textTop = textTop;
- btn.isActive = debugGetActionsState(type);
- btn.color = color;
- btn.activeColor = activeColor;
- btn.submenu = submenu;
- btn.type = type;
- _debugWindows[window].numButtons++;
-}
-
-void Debug::debugAddWindowText(int32 window, const char *text) {
- int32 line = _debugWindows[window].numLines;
- _debugWindows[window].text[line] = text;
- _debugWindows[window].numLines++;
-}
-
-void Debug::debugAddWindow(const Common::Rect &rect, int32 alpha, int32 isActive) {
- _debugWindows[_numDebugWindows].rect = rect;
- _debugWindows[_numDebugWindows].alpha = alpha;
- _debugWindows[_numDebugWindows].numButtons = 0;
- _debugWindows[_numDebugWindows].isActive = isActive;
- _numDebugWindows++;
-}
-
-void Debug::debugLeftMenu() {
- // left menu window
- debugAddWindow(Common::Rect(5, 60, 200, 474), 4, 1);
- debugAddButton(0, Common::Rect(5, 55, 160, 75), "Use free camera", 30, 60, 0, 87, 119, NO_MENU, FREE_CAMERA);
- debugAddButton(0, Common::Rect(161, 55, 200, 75), "info", 171, 60, 0, 87, 119, FREE_CAMERA_INFO_MENU, -1);
- debugAddButton(0, Common::Rect(5, 76, 160, 96), "Change scenes", 30, 81, 0, 87, 119, NO_MENU, CHANGE_SCENE);
- debugAddButton(0, Common::Rect(161, 76, 200, 96), "info", 171, 81, 0, 87, 119, CHANGE_SCENE_INFO_MENU, -2);
- debugAddButton(0, Common::Rect(5, 97, 200, 117), "Show celling grids", 30, 102, 0, 87, 119, NO_MENU, 3);
- debugAddButton(0, Common::Rect(5, 118, 200, 138), "Show zones", 30, 123, 0, 87, 119, ZONES_MENU, SHOW_ZONES);
-
- // add submenu windows
- // - free camera window
- debugAddWindow(Common::Rect(205, 55, 634, 160), 4, 0);
- debugAddWindowText(FREE_CAMERA_INFO_MENU, "When enable, use the following keys to browse through the scenes:");
- debugAddWindowText(FREE_CAMERA_INFO_MENU, " - S to go North");
- debugAddWindowText(FREE_CAMERA_INFO_MENU, " - X to go South");
- debugAddWindowText(FREE_CAMERA_INFO_MENU, " - Z to go West");
- debugAddWindowText(FREE_CAMERA_INFO_MENU, " - C to go East");
-
- // - change scene window
- debugAddWindow(Common::Rect(205, 55, 634, 137), 4, 0);
- debugAddWindowText(CHANGE_SCENE_INFO_MENU, "When enable, use the following keys to change to another scene:");
- debugAddWindowText(CHANGE_SCENE_INFO_MENU, " - R to go Next Scene");
- debugAddWindowText(CHANGE_SCENE_INFO_MENU, " - F to go Previous Scene");
-
- // - zones window
- debugAddWindow(Common::Rect(205, 55, 634, 97), 4, 0);
- debugAddWindowText(ZONES_MENU, "You can enable or disable each zone type:");
- debugAddButton(ZONES_MENU, Common::Rect(205, 118, 350, 138), "Cube Zones", 215, 123, 1, 87, 119, 0, SHOW_ZONE_CUBE);
- debugAddButton(ZONES_MENU, Common::Rect(205, 139, 350, 159), "Camera Zones", 215, 144, 2, 87, 119, 0, SHOW_ZONE_CAMERA);
- debugAddButton(ZONES_MENU, Common::Rect(205, 160, 350, 180), "Scenaric Zones", 215, 165, 3, 87, 119, 0, SHOW_ZONE_SCENARIC);
- debugAddButton(ZONES_MENU, Common::Rect(205, 181, 350, 201), "Celling Grid Zones", 215, 186, 4, 87, 119, 0, SHOW_ZONE_CELLINGGRID);
- debugAddButton(ZONES_MENU, Common::Rect(205, 202, 350, 222), "Object Zones", 215, 207, 5, 87, 119, 0, SHOW_ZONE_OBJECT);
- debugAddButton(ZONES_MENU, Common::Rect(205, 223, 350, 243), "Text Zones", 215, 228, 6, 87, 119, 0, SHOW_ZONE_TEXT);
- debugAddButton(ZONES_MENU, Common::Rect(205, 244, 350, 264), "Ladder Zones", 215, 249, 7, 87, 119, 0, SHOW_ZONE_LADDER);
-}
-
-int32 Debug::debugProcessButton(int32 x, int32 y) {
- for (int32 i = 0; i < _numDebugWindows; i++) {
- for (int32 j = 0; j < _debugWindows[i].numButtons; j++) {
- const Common::Rect &rect = _debugWindows[i].debugButtons[j].rect;
- if (rect.contains(x, y)) {
- return _debugWindows[i].debugButtons[j].type;
- }
- }
- }
-
- return 0;
-}
-
-void Debug::debugPlasmaWindow(const char *text, int32 color) {
- _engine->_menu->processPlasmaEffect(Common::Rect(0, 0, PLASMA_WIDTH, PLASMA_HEIGHT), color);
- const int32 textSize = _engine->_text->sizeFont(text);
- _engine->_text->drawText((_engine->width() / 2) - (textSize / 2), 10, text);
- const Common::Rect rect(5, 5, _engine->width() - 5, 50);
- _engine->_menu->drawRectBorders(rect);
- _engine->copyBlockPhys(rect);
-}
-
-void Debug::debugProcessWindow() {
- if (!_engine->_input->toggleActionIfActive(TwinEActionType::DebugMenu)) {
- return;
- }
- const char *text = "Game Debug Window";
- int32 colorIdx = 4;
- int32 count = 0;
-
- ScopedCursor cursor(_engine);
- _engine->saveFrontBuffer();
-
- debugResetButtonsState();
- if (_numDebugWindows == 0) {
- debugLeftMenu();
- }
- debugDrawWindows();
-
- for (;;) {
- FrameMarker frame(_engine, 25);
- _engine->readKeys();
- if (_engine->shouldQuit()) {
- break;
- }
- const Common::Point &point = _engine->_input->getMousePositions();
-
- if (_engine->_input->toggleActionIfActive(TwinEActionType::DebugMenuActivate)) {
- int type = 0;
- if ((type = debugProcessButton(point.x, point.y)) != NO_ACTION) { // process menu item
- if (debugTypeUseMenu(type)) {
- _engine->restoreFrontBuffer();
- _engine->copyBlockPhys(205, 55, 634, 474);
- }
-
- debugRefreshButtons(type);
- debugSetActions(type);
- }
- }
-
- // draw window plasma effect
- if (count == 256) {
- colorIdx++;
- count = 0;
- }
- int32 color = colorIdx * 16;
- if (color >= 240) {
- color = 64;
- colorIdx = 4;
- }
- debugPlasmaWindow(text, color);
-
- if (_engine->_input->toggleActionIfActive(TwinEActionType::DebugMenu)) {
- break;
- }
-
- count++;
- }
- _engine->_redraw->_firstTime = true;
-}
-
void Debug::processDebug() {
- if (!_engine->_cfgfile.Debug) {
- return;
- }
-
- Input *input = _engine->_input;
- if (input->isActionActive(TwinEActionType::DebugPlaceActorAtCenterOfScreen)) {
- ActorStruct *actor = _engine->_scene->getActor(OWN_ACTOR_SCENE_INDEX);
- actor->_posObj = _engine->_grid->_worldCube;
- actor->_posObj.y += 1000;
- }
-
- debugProcessWindow();
-
- _engine->_debugGrid->changeGrid();
_engine->_debugGrid->changeGridCamera();
_engine->_debugGrid->applyCellingGrid();
}
diff --git a/engines/twine/debugger/debug.h b/engines/twine/debugger/debug.h
index 18219d3e6cc..82828b51a98 100644
--- a/engines/twine/debugger/debug.h
+++ b/engines/twine/debugger/debug.h
@@ -27,78 +27,12 @@
namespace TwinE {
-enum ButtonType {
- NO_ACTION,
- FREE_CAMERA,
- CHANGE_SCENE,
- SHOW_CELLING_GRID,
- SHOW_ZONES,
- SHOW_ZONE_CUBE,
- SHOW_ZONE_CAMERA,
- SHOW_ZONE_SCENARIC,
- SHOW_ZONE_CELLINGGRID,
- SHOW_ZONE_OBJECT,
- SHOW_ZONE_TEXT,
- SHOW_ZONE_LADDER
-};
-
-enum WindowType {
- NO_MENU,
- FREE_CAMERA_INFO_MENU,
- CHANGE_SCENE_INFO_MENU,
- ZONES_MENU
-};
-
-struct DebugButtonStruct {
- Common::Rect rect { 0, 0, 0, 0 };
- const char *text = "";
- int32 textLeft = 0;
- int32 textTop = 0;
- int32 isActive = 0;
- int32 color = 0;
- int32 activeColor = 0;
- int32 submenu = 0;
- int32 type = 0;
-};
-
-struct DebugWindowStruct {
- Common::Rect rect { 0, 0, 0, 0 };
- int32 alpha = 0;
- int32 isActive = 0;
- int32 numLines = 0;
- const char *text[20] {0};
- int32 numButtons = 0;
- DebugButtonStruct debugButtons[50];
-};
-
class TwinEEngine;
class Debug {
private:
TwinEEngine *_engine;
- DebugWindowStruct _debugWindows[10];
- int32 _numDebugWindows = 0;
- void debugFillButton(int32 x, int32 y, int32 width, int32 height, int8 color);
- void debugDrawButton(const Common::Rect &rect, const char *text, int32 textLeft, int32 textTop, int32 isActive, int8 color);
- void debugDrawWindowButtons(int32 w);
- void debugDrawWindow(int32 w);
- int32 debugTypeUseMenu(int32 type);
- void debugResetButtonsState();
- void debugRefreshButtons(int32 type);
- void debugDrawWindows();
- void debugResetButton(int32 type);
- void debugRedrawScreen();
- int32 debugGetActionsState(int32 type);
- void debugSetActions(int32 type);
- void debugAddButton(int32 window, const Common::Rect &rect, const char *text, int32 textLeft, int32 textTop, int32 isActive, int32 color, int32 activeColor, int32 submenu, int32 type);
- void debugAddWindowText(int32 window, const char *text);
- void debugAddWindow(const Common::Rect &rect, int32 alpha, int32 isActive);
- void debugLeftMenu();
- int32 debugProcessButton(int32 x, int32 y);
- void debugPlasmaWindow(const char *text, int32 color);
- void debugProcessWindow();
-
public:
Debug(TwinEEngine *engine) : _engine(engine) {}
void processDebug();
diff --git a/engines/twine/debugger/debug_grid.cpp b/engines/twine/debugger/debug_grid.cpp
index 58390c5c6ef..c0a382c2729 100644
--- a/engines/twine/debugger/debug_grid.cpp
+++ b/engines/twine/debugger/debug_grid.cpp
@@ -30,7 +30,6 @@
namespace TwinE {
DebugGrid::DebugGrid(TwinEEngine *engine) : _engine(engine) {
- _canChangeScenes = _engine->_cfgfile.Debug;
}
void DebugGrid::changeGridCamera() {
@@ -57,32 +56,6 @@ void DebugGrid::changeGridCamera() {
}
}
-void DebugGrid::changeGrid() {
- if (!_canChangeScenes) {
- return;
- }
- Scene *scene = _engine->_scene;
- Redraw *redraw = _engine->_redraw;
- Input *input = _engine->_input;
- if (input->toggleActionIfActive(TwinEActionType::NextRoom)) {
- scene->_currentSceneIdx++;
- if (scene->_currentSceneIdx >= LBA1SceneId::SceneIdMax) {
- scene->_currentSceneIdx = LBA1SceneId::Citadel_Island_Prison;
- }
- scene->_needChangeScene = scene->_currentSceneIdx;
- redraw->_firstTime = true;
- }
-
- if (input->toggleActionIfActive(TwinEActionType::PreviousRoom)) {
- scene->_currentSceneIdx--;
- if (scene->_currentSceneIdx < LBA1SceneId::Citadel_Island_Prison) {
- scene->_currentSceneIdx = LBA1SceneId::SceneIdMax - 1;
- }
- scene->_needChangeScene = scene->_currentSceneIdx;
- redraw->_firstTime = true;
- }
-}
-
void DebugGrid::applyCellingGrid() {
Grid *grid = _engine->_grid;
Input *input = _engine->_input;
diff --git a/engines/twine/debugger/debug_grid.h b/engines/twine/debugger/debug_grid.h
index ca594dcaecb..44bf6e4fe3b 100644
--- a/engines/twine/debugger/debug_grid.h
+++ b/engines/twine/debugger/debug_grid.h
@@ -36,13 +36,10 @@ public:
DebugGrid(TwinEEngine *engine);
bool _useFreeCamera = false;
- bool _canChangeScenes = false;
bool _disableGridRendering = false;
/** Change scenario camera positions */
void changeGridCamera();
- /** Change grid index */
- void changeGrid();
/** Apply and change disappear celling grid */
void applyCellingGrid();
};
diff --git a/engines/twine/debugger/debug_scene.cpp b/engines/twine/debugger/debug_scene.cpp
index 92957245f26..9ff6d9ed103 100644
--- a/engines/twine/debugger/debug_scene.cpp
+++ b/engines/twine/debugger/debug_scene.cpp
@@ -45,26 +45,7 @@ void DebugScene::projectBoundingBoxPoints(IVec3 *pPoint3d, IVec3 *pPoint3dProjec
}
bool DebugScene::checkZoneType(ZoneType type) const {
- switch (type) {
- case ZoneType::kCube:
- return (_typeZones & 0x01) != 0;
- case ZoneType::kCamera:
- return (_typeZones & 0x02) != 0;
- case ZoneType::kSceneric:
- return (_typeZones & 0x04) != 0;
- case ZoneType::kGrid:
- return (_typeZones & 0x08) != 0;
- case ZoneType::kObject:
- return (_typeZones & 0x10) != 0;
- case ZoneType::kText:
- return (_typeZones & 0x20) != 0;
- case ZoneType::kLadder:
- return (_typeZones & 0x40) != 0;
- default:
- return true;
- }
-
- return false;
+ return (_typeZones & (1u << (uint32)type)) != 0u;
}
DebugScene::ScenePositionsProjected DebugScene::calculateBoxPositions(const IVec3 &mins, const IVec3 &maxs) {
@@ -157,7 +138,6 @@ bool DebugScene::displayActors() {
_engine->_interface->box(filledRect, COLOR_WHITE);
_engine->_menu->drawRectBorders(filledRect);
_engine->drawText(positions.frontTopRightPoint2D.x, positions.frontTopRightPoint2D.y, Common::String::format("Actor: %i", a), true, true, boxwidth);
- _engine->drawText(positions.frontTopRightPoint2D.x, positions.frontTopRightPoint2D.y + lineHeight, Common::String::format("pos: %i:%i:%i", pos.x, pos.y, pos.z), true, true, boxwidth);
const int16 rleft = positions.frontTopLeftPoint2D.x;
const int16 rtop = positions.backTopLeftPoint2D.y;
const int16 rright = positions.backTopRightPoint2D.x;
diff --git a/engines/twine/debugger/debug_scene.h b/engines/twine/debugger/debug_scene.h
index 1f1d881051b..aef310ebec2 100644
--- a/engines/twine/debugger/debug_scene.h
+++ b/engines/twine/debugger/debug_scene.h
@@ -75,7 +75,7 @@ public:
bool _showingTracks = false;
bool _showingClips = false;
bool _godMode = false;
- int32 _typeZones = 127; // all zones on as default
+ uint32 _typeZones = 127; // all zones on as default
int16 _onlyLoadActor = -1;
void renderDebugView();
diff --git a/engines/twine/debugger/debugtools.cpp b/engines/twine/debugger/debugtools.cpp
new file mode 100644
index 00000000000..ec6e7fb11e3
--- /dev/null
+++ b/engines/twine/debugger/debugtools.cpp
@@ -0,0 +1,278 @@
+/* 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/IconsMaterialSymbols.h"
+
+#include "backends/imgui/imgui.h"
+#include "backends/imgui/imgui_internal.h"
+#include "common/util.h"
+#include "twine/debugger/debug_grid.h"
+#include "twine/debugger/debug_scene.h"
+#include "twine/debugger/debugtools.h"
+#include "twine/debugger/dt-internal.h"
+#include "twine/holomap.h"
+#include "twine/renderer/redraw.h"
+#include "twine/scene/actor.h"
+#include "twine/scene/gamestate.h"
+#include "twine/scene/grid.h"
+#include "twine/scene/scene.h"
+
+#include "twine/shared.h"
+#include "twine/twine.h"
+
+namespace TwinE {
+
+#define GAME_STATE_TITLE "Game State"
+#define MAIN_WINDOW_TITLE "Debug window"
+#define HOLOMAP_FLAGS_TITLE "Holomap flags"
+#define GAME_FLAGS_TITLE "Game flags"
+#define ACTOR_DETAILS_TITLE "Actor"
+
+void onImGuiInit() {
+ ImGuiIO &io = ImGui::GetIO();
+ io.Fonts->AddFontDefault();
+
+ ImFontConfig icons_config;
+ icons_config.MergeMode = true;
+ icons_config.PixelSnapH = false;
+ icons_config.OversampleH = 3;
+ icons_config.OversampleV = 3;
+ icons_config.GlyphOffset = {0, 4};
+
+ static const ImWchar icons_ranges[] = {ICON_MIN_MS, ICON_MAX_MS, 0};
+ ImGui::addTTFFontFromArchive("MaterialSymbolsSharp.ttf", 16.f, &icons_config, icons_ranges);
+
+ _tinyFont = ImGui::addTTFFontFromArchive("FreeSans.ttf", 10.0f, nullptr, nullptr);
+}
+
+static void mainWindow(int ¤tActor, TwinEEngine *engine) {
+ if (ImGui::Begin(MAIN_WINDOW_TITLE)) {
+ Scene *scene = engine->_scene;
+ GameState *gameState = engine->_gameState;
+ ImGui::Text("Scene: %i", scene->_currentSceneIdx);
+ ImGui::Text("Scene name: %s", gameState->_sceneName);
+
+ if (ImGui::Checkbox("Bounding boxes", &engine->_debugScene->_showingActors)) {
+ engine->_redraw->_firstTime = true;
+ }
+ if (ImGui::Checkbox("Clipping", &engine->_debugScene->_showingClips)) {
+ engine->_redraw->_firstTime = true;
+ }
+ if (ImGui::Checkbox("Zones", &engine->_debugScene->_showingZones)) {
+ engine->_redraw->_firstTime = true;
+ }
+
+ if (engine->_debugScene->_showingZones) {
+ if (ImGui::CollapsingHeader("Zones")) {
+ static const struct ZonesDesc {
+ const char *name;
+ ZoneType type;
+ const char *desc;
+ } d[] = {
+ {"Cube", ZoneType::kCube, "Change to another scene"},
+ {"Camera", ZoneType::kCamera, "Binds camera view"},
+ {"Sceneric", ZoneType::kSceneric, "For use in Life Script"},
+ {"Grid", ZoneType::kGrid, "Set disappearing Grid fragment"},
+ {"Object", ZoneType::kObject, "Give bonus"},
+ {"Text", ZoneType::kText, "Displays text message"},
+ {"Ladder", ZoneType::kLadder, "Hero can climb on it"},
+ {"Escalator", ZoneType::kEscalator, nullptr},
+ {"Hit", ZoneType::kHit, nullptr},
+ {"Rail", ZoneType::kRail, nullptr}};
+
+ for (int i = 0; i < ARRAYSIZE(d); ++i) {
+ ImGui::CheckboxFlags(d[i].name, &engine->_debugScene->_typeZones, (1u << (uint32)d[i].type));
+ if (d[i].desc) {
+ ImGui::SetTooltip(d[i].desc);
+ }
+ }
+ }
+ }
+
+ if (ImGui::BeginCombo("Scene", gameState->_sceneName)) {
+ for (int i = 0; i < engine->numHoloPos(); ++i) {
+ Common::String name = Common::String::format("[%03d] %s", i, engine->_holomap->getLocationName(i));
+ if (ImGui::Selectable(name.c_str(), i == engine->_scene->_currentSceneIdx)) {
+ scene->_currentSceneIdx = i;
+ scene->_needChangeScene = scene->_currentSceneIdx;
+ engine->_redraw->_firstTime = true;
+ }
+ }
+ ImGui::EndCombo();
+ }
+
+ if (currentActor < 0 || currentActor > engine->_scene->_nbObjets) {
+ currentActor = 0;
+ }
+ Common::String currentActorLabel = Common::String::format("Actor %i", currentActor);
+ if (ImGui::BeginCombo("Actor", currentActorLabel.c_str())) {
+ for (int i = 0; i < engine->_scene->_nbObjets; ++i) {
+ Common::String label = Common::String::format("Actor %i", i);
+ const bool selected = i == currentActor;
+ if (ImGui::Selectable(label.c_str(), selected)) {
+ currentActor = i;
+ }
+ }
+ ImGui::EndCombo();
+ }
+ }
+ ImGui::End();
+}
+
+static void gameState(TwinEEngine *engine) {
+ if (ImGui::Begin(GAME_STATE_TITLE)) {
+ int keys = engine->_gameState->_inventoryNumKeys;
+ if (ImGui::InputInt("Keys", &keys)) {
+ engine->_gameState->setKeys(keys);
+ }
+ int kashes = engine->_gameState->_goldPieces;
+ if (ImGui::InputInt("Cash", &kashes)) {
+ engine->_gameState->setKashes(kashes);
+ }
+ int zlitos = engine->_gameState->_zlitosPieces;
+ if (ImGui::InputInt("Zlitos", &zlitos)) {
+ engine->_gameState->setZlitos(zlitos);
+ }
+ int magicPoints = engine->_gameState->_magicPoint;
+ if (ImGui::InputInt("Magic points", &magicPoints)) {
+ engine->_gameState->setMagicPoints(magicPoints);
+ }
+ int magicLevel = engine->_gameState->_magicLevelIdx;
+ if (ImGui::InputInt("Magic level", &magicLevel)) {
+ engine->_gameState->_magicLevelIdx = CLIP<int16>(magicLevel, 0, 4);
+ }
+ int leafs = engine->_gameState->_inventoryNumLeafs;
+ if (ImGui::InputInt("Leafs", &leafs)) {
+ engine->_gameState->setLeafs(leafs);
+ }
+ int leafBoxes = engine->_gameState->_inventoryNumLeafsBox;
+ if (ImGui::InputInt("Leaf boxes", &leafBoxes)) {
+ engine->_gameState->setLeafBoxes(leafBoxes);
+ }
+ int gas = engine->_gameState->_inventoryNumGas;
+ if (ImGui::InputInt("Gas", &gas)) {
+ engine->_gameState->setGas(gas);
+ }
+ }
+ ImGui::End();
+}
+
+static void holomapFlags(TwinEEngine *engine) {
+ if (ImGui::Begin(HOLOMAP_FLAGS_TITLE)) {
+ if (ImGui::BeginTable("###holomapflags", 8)) {
+ for (int i = 0; i < engine->numHoloPos(); ++i) {
+ ImGui::TableNextColumn();
+ ImGui::Text("[%03d] = %d", i, engine->_gameState->_holomapFlags[i]);
+ }
+ ImGui::EndTable();
+ }
+ }
+ ImGui::End();
+}
+
+static void gameFlags(TwinEEngine *engine) {
+ if (ImGui::Begin(GAME_FLAGS_TITLE)) {
+ ImGui::Text("Chapter %i", engine->_gameState->getChapter());
+ if (ImGui::BeginTable("###gameflags", 8)) {
+ for (int i = 0; i < NUM_GAME_FLAGS; ++i) {
+ ImGui::TableNextColumn();
+ ImGui::Text("[%03d] = %d", i, engine->_gameState->hasGameFlag(i));
+ }
+ ImGui::EndTable();
+ }
+ }
+ ImGui::End();
+}
+
+static void actorDetails(int actorIdx, TwinEEngine *engine) {
+ if (ActorStruct *actor = engine->_scene->getActor(actorIdx)) {
+ if (ImGui::Begin(ACTOR_DETAILS_TITLE)) {
+ ImGui::Text("Idx %i", actor->_actorIdx);
+ ImGui::Text("Pos %i %i %i", actor->_posObj.x, actor->_posObj.y, actor->_posObj.z);
+ ImGui::Text("Followed %i", actor->_followedActor);
+ ImGui::Text("Rotation %i", actor->_beta);
+ ImGui::Text("Speed %i", actor->_speed);
+ ImGui::Text("Control mode %i", actor->_controlMode);
+ ImGui::Text("Delay %i", actor->_delayInMillis);
+ ImGui::Text("Crop %i %i %i %i", actor->_cropLeft, actor->_cropTop, actor->_cropRight, actor->_cropBottom);
+ ImGui::Text("Strength %i", actor->_strengthOfHit);
+ ImGui::Text("Hit by %i", actor->_hitBy);
+ ImGui::Text("Bonus %i", actor->_bonusParameter);
+ ImGui::Text("Life %i", actor->_lifePoint);
+ ImGui::Text("Brick shape %i", actor->brickShape());
+ ImGui::Text("Brick causes damage %i", actor->brickCausesDamage());
+ ImGui::Text("Collision %i", actor->_objCol);
+ ImGui::Text("Body %i", actor->_body);
+ ImGui::Text("Gen body %i", actor->_genBody);
+ ImGui::Text("Save gen body %i", actor->_saveGenBody);
+ ImGui::Text("Gen anim %i", actor->_genAnim);
+ ImGui::Text("Next gen anim %i", actor->_nextGenAnim);
+ ImGui::Text("Ptr anim action %i", actor->_ptrAnimAction);
+ ImGui::Text("Sprite %i", actor->_sprite);
+ ImGui::Text("A3DS %i %i %i", actor->A3DS.Num, actor->A3DS.Deb, actor->A3DS.Fin);
+ ImGui::Text("Hit by %i", actor->_hitBy);
+ }
+ ImGui::End();
+ }
+}
+
+void onImGuiRender() {
+ if (!debugChannelSet(-1, kDebugImGui)) {
+ ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange | ImGuiConfigFlags_NoMouse;
+ return;
+ }
+ static int currentActor = 0;
+
+ ImGuiIO &io = ImGui::GetIO();
+ io.ConfigFlags &= ~(ImGuiConfigFlags_NoMouseCursorChange | ImGuiConfigFlags_NoMouse);
+
+ ImGui::DockSpaceOverViewport(0, ImGui::GetMainViewport(), ImGuiDockNodeFlags_PassthruCentralNode);
+ TwinEEngine *engine = (TwinEEngine *)g_engine;
+
+ if (ImGui::BeginMainMenuBar()) {
+ if (ImGui::BeginMenu("Debugger")) {
+ ImGui::Checkbox("Free camera", &engine->_debugGrid->_useFreeCamera);
+ ImGui::Checkbox("God mode", &engine->_debugScene->_godMode);
+
+ if (ImGui::MenuItem("Center actor")) {
+ ActorStruct *actor = engine->_scene->getActor(OWN_ACTOR_SCENE_INDEX);
+ actor->_posObj = engine->_grid->_worldCube;
+ actor->_posObj.y += 1000;
+ }
+ ImGui::EndMenu();
+ }
+ ImGui::EndMainMenuBar();
+ }
+
+ mainWindow(currentActor, engine);
+ gameState(engine);
+
+ // TODO: combine them
+ holomapFlags(engine);
+ gameFlags(engine);
+
+ actorDetails(currentActor, engine);
+}
+
+void onImGuiCleanup() {
+}
+
+} // namespace TwinE
diff --git a/engines/twine/debugger/debugtools.h b/engines/twine/debugger/debugtools.h
new file mode 100644
index 00000000000..933a657d404
--- /dev/null
+++ b/engines/twine/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 TWINE_DEBUGGER_DEBUGTOOLS_H
+#define TWINE_DEBUGGER_DEBUGTOOLS_H
+
+namespace TwinE {
+void onImGuiInit();
+void onImGuiRender();
+void onImGuiCleanup();
+} // namespace TwinE
+
+#endif
diff --git a/engines/twine/debugger/dt-internal.h b/engines/twine/debugger/dt-internal.h
new file mode 100644
index 00000000000..7d29b02e421
--- /dev/null
+++ b/engines/twine/debugger/dt-internal.h
@@ -0,0 +1,38 @@
+/* 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 TWINE_DEBUGGER_DT_INTERNAL_H
+#define TWINE_DEBUGGER_DT_INTERNAL_H
+
+#define IMGUI_DEFINE_MATH_OPERATORS
+
+#include "graphics/surface.h"
+
+#include "backends/imgui/imgui.h"
+#include "backends/imgui/imgui_fonts.h"
+
+namespace TwinE {
+
+ImFont *_tinyFont = nullptr;
+
+} // namespace TwinE
+
+#endif
diff --git a/engines/twine/detection.cpp b/engines/twine/detection.cpp
index 3d4ad4f4bc5..6f955933caf 100644
--- a/engines/twine/detection.cpp
+++ b/engines/twine/detection.cpp
@@ -35,8 +35,9 @@ static const PlainGameDescriptor twineGames[] = {
};
static const DebugChannelDef debugFlagList[] = {
- {TwinE::kDebugScripts, "Scripts", "Scripts debugging"},
- {TwinE::kDebugTime, "Time", "Time debugging"},
+ {TwinE::kDebugScripts, "scripts", "Scripts debugging"},
+ {TwinE::kDebugTime, "time", "Time debugging"},
+ {TwinE::kDebugImGui, "imgui", "UI for debugging"},
DEBUG_CHANNEL_END
};
diff --git a/engines/twine/holomap_v1.h b/engines/twine/holomap_v1.h
index e3d8b896239..c128ae9a506 100644
--- a/engines/twine/holomap_v1.h
+++ b/engines/twine/holomap_v1.h
@@ -66,7 +66,7 @@ private:
// float _distanceModifier = 1.0f;
int32 _numHoloPos = 0;
- Location _listHoloPos[MAX_HOLO_POS_2];
+ Location _listHoloPos[MAX_HOLO_POS];
int32 _holomapPaletteIndex = 0;
uint8 _paletteHolomap[NUMOFCOLORS * 3]{0};
diff --git a/engines/twine/input.cpp b/engines/twine/input.cpp
index 15d28ea928a..a5851e18a3a 100644
--- a/engines/twine/input.cpp
+++ b/engines/twine/input.cpp
@@ -130,11 +130,6 @@ void Input::processCustomEngineEventStart(const Common::Event &event) {
case TwinEActionType::DebugGridCameraPressDown:
case TwinEActionType::DebugGridCameraPressLeft:
case TwinEActionType::DebugGridCameraPressRight:
- case TwinEActionType::DebugPlaceActorAtCenterOfScreen:
- case TwinEActionType::DebugMenu:
- case TwinEActionType::DebugMenuActivate:
- case TwinEActionType::NextRoom:
- case TwinEActionType::PreviousRoom:
case TwinEActionType::ApplyCellingGrid:
case TwinEActionType::IncreaseCellingGridIndex:
case TwinEActionType::DecreaseCellingGridIndex:
diff --git a/engines/twine/input.h b/engines/twine/input.h
index 3d7a536b8d3..1059040451b 100644
--- a/engines/twine/input.h
+++ b/engines/twine/input.h
@@ -39,8 +39,6 @@ extern const char *holomapKeyMapId;
enum TwinEActionType {
Pause,
- NextRoom,
- PreviousRoom,
ApplyCellingGrid,
IncreaseCellingGridIndex,
DecreaseCellingGridIndex,
@@ -48,9 +46,6 @@ enum TwinEActionType {
DebugGridCameraPressDown,
DebugGridCameraPressLeft,
DebugGridCameraPressRight,
- DebugPlaceActorAtCenterOfScreen,
- DebugMenu,
- DebugMenuActivate,
QuickBehaviourNormal,
QuickBehaviourAthletic,
QuickBehaviourAggressive,
diff --git a/engines/twine/metaengine.cpp b/engines/twine/metaengine.cpp
index e56b17c1309..d939e9013e3 100644
--- a/engines/twine/metaengine.cpp
+++ b/engines/twine/metaengine.cpp
@@ -222,16 +222,6 @@ Common::KeymapArray TwinEMetaEngine::initKeymaps(const char *target) const {
act->addDefaultInputMapping("p");
gameKeyMap->addAction(act);
- act = new Action("NEXTROOM", _("Debug Next Room"));
- act->setCustomEngineActionEvent(TwinEActionType::NextRoom);
- act->addDefaultInputMapping("r");
- gameKeyMap->addAction(act);
-
- act = new Action("PREVIOUSROOM", _("Debug Previous Room"));
- act->setCustomEngineActionEvent(TwinEActionType::PreviousRoom);
- act->addDefaultInputMapping("f");
- gameKeyMap->addAction(act);
-
act = new Action("APPLYCELLINGGRID", _("Debug Apply Celling Grid"));
act->setCustomEngineActionEvent(TwinEActionType::ApplyCellingGrid);
act->addDefaultInputMapping("t");
@@ -268,21 +258,6 @@ Common::KeymapArray TwinEMetaEngine::initKeymaps(const char *target) const {
act->addDefaultInputMapping("c");
gameKeyMap->addAction(act);
- act = new Action("DEBUGPLACEACTORATCENTEROFSCREEN", _("Place actor at center of screen"));
- act->setCustomEngineActionEvent(TwinEActionType::DebugPlaceActorAtCenterOfScreen);
- act->addDefaultInputMapping("v");
- gameKeyMap->addAction(act);
-
- act = new Action("DEBUGMENU", _("Debug Menu"));
- act->setCustomEngineActionEvent(TwinEActionType::DebugMenu);
- act->addDefaultInputMapping("MOUSE_RIGHT");
- gameKeyMap->addAction(act);
-
- act = new Action("DEBUGMENUEXEC", _("Debug Menu Execute"));
- act->setCustomEngineActionEvent(TwinEActionType::DebugMenuActivate);
- act->addDefaultInputMapping("MOUSE_LEFT");
- gameKeyMap->addAction(act);
-
act = new Action("CHANGETONORMALBEHAVIOUR", _("Normal Behaviour"));
act->setCustomEngineActionEvent(TwinEActionType::ChangeBehaviourNormal);
act->addDefaultInputMapping("1");
diff --git a/engines/twine/module.mk b/engines/twine/module.mk
index 0518d107fef..ed6b84d0ef7 100644
--- a/engines/twine/module.mk
+++ b/engines/twine/module.mk
@@ -61,6 +61,11 @@ MODULE_OBJS := \
text.o \
twine.o
+ifdef USE_IMGUI
+MODULE_OBJS += \
+ debugger/debugtools.o
+endif
+
# This module can be built as a plugin
ifeq ($(ENABLE_TWINE), DYNAMIC_PLUGIN)
PLUGIN := 1
diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 2f6fd7e44bd..b34a945ad5e 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -909,9 +909,7 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // AffScene
correctZLevels(drawList, drawListPos);
processDrawList(drawList, drawListPos, bgRedraw);
- if (_engine->_cfgfile.Debug) {
- _engine->_debugScene->renderDebugView();
- }
+ _engine->_debugScene->renderDebugView();
renderOverlays();
renderText();
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index 38508542da8..204c4fd5d91 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -794,7 +794,8 @@ inline constexpr T bits(T value, uint8 offset, uint8 bits) {
enum kDebugLevels {
kDebugScripts = 1 << 0,
- kDebugTime = 1 << 1
+ kDebugTime = 1 << 1,
+ kDebugImGui = 1 << 2
};
}
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 8aed3bdcb27..c1e0112ba99 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -76,7 +76,9 @@
#include "twine/shared.h"
#include "twine/slideshow.h"
#include "twine/text.h"
-
+#ifdef USE_IMGUI
+#include "twine/debugger/debugtools.h"
+#endif
namespace TwinE {
ScopedEngineFreeze::ScopedEngineFreeze(TwinEEngine *engine, bool pause) : _engine(engine) {
@@ -340,6 +342,15 @@ Common::Error TwinEEngine::run() {
}
}
+#ifdef USE_IMGUI
+ ImGuiCallbacks callbacks;
+ bool drawImGui = debugChannelSet(-1, kDebugImGui);
+ callbacks.init = TwinE::onImGuiInit;
+ callbacks.render = drawImGui ? TwinE::onImGuiRender : nullptr;
+ callbacks.cleanup = TwinE::onImGuiCleanup;
+ _system->setImGuiCallbacks(callbacks);
+#endif
+
bool quitGame = false;
while (!quitGame && !shouldQuit()) {
readKeys();
@@ -381,6 +392,14 @@ Common::Error TwinEEngine::run() {
#endif
break;
}
+#ifdef USE_IMGUI
+ // For performance reasons, disable the renderer callback if the ImGui debug flag isn't set
+ if (debugChannelSet(-1, kDebugImGui) != drawImGui) {
+ drawImGui = !drawImGui;
+ callbacks.render = drawImGui ? TwinE::onImGuiRender : nullptr;
+ _system->setImGuiCallbacks(callbacks);
+ }
+#endif
}
ConfMan.setBool("combatauto", _actor->_combatAuto);
More information about the Scummvm-git-logs
mailing list