diff options
-rw-r--r-- | engines/bladerunner/bladerunner.cpp | 4 | ||||
-rw-r--r-- | engines/bladerunner/debugger.cpp | 858 | ||||
-rw-r--r-- | engines/bladerunner/debugger.h | 61 | ||||
-rw-r--r-- | engines/bladerunner/scene.cpp | 14 | ||||
-rw-r--r-- | engines/bladerunner/screen_effects.cpp | 53 | ||||
-rw-r--r-- | engines/bladerunner/screen_effects.h | 11 | ||||
-rw-r--r-- | engines/bladerunner/script/scene/ug01.cpp | 39 | ||||
-rw-r--r-- | engines/bladerunner/script/script.cpp | 25 | ||||
-rw-r--r-- | engines/bladerunner/script/script.h | 6 | ||||
-rw-r--r-- | engines/bladerunner/ui/spinner.cpp | 2 |
10 files changed, 840 insertions, 233 deletions
diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp index 5c8ecbd7cc..06d6e1c339 100644 --- a/engines/bladerunner/bladerunner.cpp +++ b/engines/bladerunner/bladerunner.cpp @@ -1965,6 +1965,10 @@ bool BladeRunnerEngine::loadGame(Common::SeekableReadStream &stream) { #endif // BLADERUNNER_ORIGINAL_BUGS _audioSpeech->stopSpeech(); _actorDialogueQueue->flush(true, false); +#if BLADERUNNER_ORIGINAL_BUGS +#else + _screenEffects->toggleEntry(-1, false); // clear the skip list +#endif _screenEffects->_entries.clear(); int size = s.readInt(); diff --git a/engines/bladerunner/debugger.cpp b/engines/bladerunner/debugger.cpp index 354e899bd6..af3bdaf13e 100644 --- a/engines/bladerunner/debugger.cpp +++ b/engines/bladerunner/debugger.cpp @@ -74,17 +74,35 @@ Debugger::Debugger(BladeRunnerEngine *vm) : GUI::Debugger() { _isDebuggerOverlay = false; - _viewActorsOnly = false; + _viewActorsToggle = false; + _view3dObjectsToggle = false; + _viewItemsToggle = false; _viewLights = false; _viewFogs = false; - _viewSceneObjects = false; _viewScreenEffects = false; _viewObstacles = false; - _viewRegions = false; + _viewRegionsNormalToggle = false; + _viewRegionsExitsToggle = false; _viewUI = false; - _viewWaypoints = false; + _viewWaypointsNormalToggle = false; + _viewWaypointsFleeToggle = false; + _viewWaypointsCoverToggle = false; _viewWalkboxes = false; _viewZBuffer = false; + + _specificActorsDrawn = false; + _specific3dObjectsDrawn = false; + _specificItemsDrawn = false; + _specificEffectsDrawn = false; + _specificLightsDrawn = false; + _specificFogsDrawn = false; + _specificRegionNormalDrawn = false; + _specificRegionExitsDrawn = false; + _specificWaypointNormalDrawn = false; + _specificWaypointFleeDrawn = false; + _specificWaypointCoverDrawn = false; + _specificWalkboxesDrawn = false; + _playFullVk = false; _showStatsVk = false; _showMazeScore = false; @@ -111,9 +129,16 @@ Debugger::Debugger(BladeRunnerEngine *vm) : GUI::Debugger() { registerCmd("object", WRAP_METHOD(Debugger, cmdObject)); registerCmd("item", WRAP_METHOD(Debugger, cmdItem)); registerCmd("region", WRAP_METHOD(Debugger, cmdRegion)); +#if BLADERUNNER_ORIGINAL_BUGS +#else + registerCmd("effect", WRAP_METHOD(Debugger, cmdEffect)); +#endif // BLADERUNNER_ORIGINAL_BUGS } Debugger::~Debugger() { + if(!_specificDrawnObjectsList.empty()) { + _specificDrawnObjectsList.clear(); + } } bool Debugger::cmdAnimation(int argc, const char **argv) { @@ -147,73 +172,216 @@ bool Debugger::cmdAnimation(int argc, const char **argv) { } bool Debugger::cmdDraw(int argc, const char **argv) { - if (argc != 2) { - debugPrintf("Enables debug rendering of actors, screen effect, fogs, lights, scene objects, obstacles, regions, ui elements, walk boxes, waypoints, zbuffer or disables debug rendering.\n"); - debugPrintf("Usage: %s (act | eff | fog | lit | obj | obstacles | reg | ui | walk | way | zbuf | reset)\n", argv[0]); - return true; + bool invalidSyntax = false; + + if (argc != 2 && argc != 3) { + invalidSyntax = true; + } else { + Common::String arg = argv[1]; + + int specificObjectId = -1; + DebuggerDrawnObject dbgDrawnObj; + dbgDrawnObj.type = debuggerObjTypeUndefined; + + if (argc == 3) { + specificObjectId = atoi(argv[2]); + dbgDrawnObj.objId = specificObjectId; + dbgDrawnObj.sceneId = _vm->_scene->getSceneId(); + dbgDrawnObj.setId = _vm->_scene->getSetId(); + } + + if (arg == "allobj") { + if (_viewActorsToggle && _view3dObjectsToggle && _viewItemsToggle) { + _viewActorsToggle = false; + _view3dObjectsToggle = false; + _viewItemsToggle = false; + } else { + _viewActorsToggle = true; + _view3dObjectsToggle = true; + _viewItemsToggle = true; + } + debugPrintf("Drawing all scene objects (actors, 3d objects, items) = %i\n", _viewActorsToggle && _view3dObjectsToggle && _viewItemsToggle); + } else if (arg == "act") { + if (argc == 2) { + _viewActorsToggle = !_viewActorsToggle; + debugPrintf("Drawing all actors in scene = %s\n", _viewActorsToggle? "true" : "false"); + } else { + dbgDrawnObj.setId = -1; + dbgDrawnObj.sceneId = -1; + dbgDrawnObj.type = debuggerObjTypeActor; + } + } else if (arg == "obj") { + if (argc == 2) { + _view3dObjectsToggle = !_view3dObjectsToggle; + debugPrintf("Drawing all 3d objects in scene = %s\n", _view3dObjectsToggle? "true" : "false"); + } else { + dbgDrawnObj.sceneId = -1; + dbgDrawnObj.type = debuggerObjType3dObject; + } + } else if (arg == "item") { + if (argc == 2) { + _viewItemsToggle = !_viewItemsToggle; + dbgDrawnObj.sceneId = -1; + debugPrintf("Drawing all items in scene = %s\n", _viewItemsToggle? "true" : "false"); + } else { + dbgDrawnObj.type = debuggerObjTypeItem; + } + } else if (arg == "eff") { + if (argc == 2) { + _viewScreenEffects = !_viewScreenEffects; + debugPrintf("Drawing all screen effects = %s\n", _viewScreenEffects? "true" : "false"); + } else { + dbgDrawnObj.type = debuggerObjTypeEffect; + } + } else if (arg == "fog") { + if (argc == 2) { + _viewFogs = !_viewFogs; + debugPrintf("Drawing all fogs = %s\n", _viewFogs? "true" : "false"); + } else { + dbgDrawnObj.type = debuggerObjTypeFog; + } + } else if (arg == "lit") { + if (argc == 2) { + _viewLights = !_viewLights; + debugPrintf("Drawing all lights = %s\n", _viewLights? "true" : "false"); + } else { + dbgDrawnObj.type = debuggerObjTypeLight; + } + } else if (arg == "allreg") { + if (_viewRegionsNormalToggle && _viewRegionsExitsToggle) { + _viewRegionsNormalToggle = false; + _viewRegionsExitsToggle = false; + } else { + _viewRegionsNormalToggle = true; + _viewRegionsExitsToggle = true; + } + debugPrintf("Drawing all scene regions (regular, exits) = %s\n", (_viewRegionsNormalToggle && _viewRegionsExitsToggle)? "true" : "false"); + } else if (arg == "regnorm") { + if (argc == 2) { + _viewRegionsNormalToggle = !_viewRegionsNormalToggle; + debugPrintf("Drawing all normal regions = %s\n", _viewRegionsNormalToggle? "true" : "false"); + } else { + dbgDrawnObj.type = debuggerObjTypeRegionNormal; + } + } else if (arg == "regexit") { + if (argc == 2) { + _viewRegionsExitsToggle = !_viewRegionsExitsToggle; + debugPrintf("Drawing all exit regions = %s\n", _viewRegionsExitsToggle? "true" : "false"); + } else { + dbgDrawnObj.type = debuggerObjTypeRegionExit; + } + } else if (arg == "obstacles") { + _viewObstacles = !_viewObstacles; + debugPrintf("Drawing obstacles = %s\n", _viewObstacles? "true" : "false"); + } else if (arg == "ui") { + _viewUI = !_viewUI; + debugPrintf("Drawing all UI elements = %s\n", _viewUI? "true" : "false"); + } else if (arg == "allway") { + if (_viewWaypointsNormalToggle && _viewWaypointsFleeToggle && _viewWaypointsCoverToggle) { + _viewWaypointsNormalToggle = false; + _viewWaypointsFleeToggle = false; + _viewWaypointsCoverToggle = false; + } else { + _viewWaypointsNormalToggle = true; + _viewWaypointsFleeToggle = true; + _viewWaypointsCoverToggle = true; + } + debugPrintf("Drawing all waypoints (regular, cover, flee) = %s\n", (_viewWaypointsNormalToggle && _viewWaypointsFleeToggle && _viewWaypointsCoverToggle)? "true" : "false"); + } else if (arg == "waynorm") { + if (argc == 2) { + _viewWaypointsNormalToggle = !_viewWaypointsNormalToggle; + debugPrintf("Drawing all normal waypoints = %s\n", _viewWaypointsNormalToggle? "true" : "false"); + } else { + dbgDrawnObj.setId = -1; + dbgDrawnObj.sceneId = -1; + dbgDrawnObj.type = debuggerObjTypeWaypointNorm; + } + } else if (arg == "wayflee") { + if (argc == 2) { + _viewWaypointsFleeToggle = !_viewWaypointsFleeToggle; + debugPrintf("Drawing all flee waypoints = %s\n", _viewWaypointsFleeToggle? "true" : "false"); + } else { + dbgDrawnObj.setId = -1; + dbgDrawnObj.sceneId = -1; + dbgDrawnObj.type = debuggerObjTypeWaypoingFlee; + } + } else if (arg == "waycov") { + if (argc == 2) { + _viewWaypointsCoverToggle = !_viewWaypointsCoverToggle; + debugPrintf("Drawing all cover waypoints = %s\n", _viewWaypointsCoverToggle? "true" : "false"); + } else { + dbgDrawnObj.setId = -1; + dbgDrawnObj.sceneId = -1; + dbgDrawnObj.type = debuggerObjTypeWaypointCover; + } + } else if (arg == "walk") { + if (argc == 2) { + _viewWalkboxes = !_viewWalkboxes; + debugPrintf("Drawing all walk boxes = %s\n", _viewWalkboxes? "true" : "false"); + } else { + dbgDrawnObj.type = debuggerObjTypeWalkbox; + } + } else if (arg == "zbuf") { + _viewZBuffer = !_viewZBuffer; + debugPrintf("Drawing Z buffer = %s\n", _viewZBuffer? "true" : "false"); + } else if (arg == "reset") { + + if(!_specificDrawnObjectsList.empty()) { + _specificDrawnObjectsList.clear(); + } + + _viewActorsToggle = false; + _view3dObjectsToggle = false; + _viewItemsToggle = false; + _viewObstacles = false; + _viewRegionsNormalToggle = false; + _viewRegionsExitsToggle = false; + _viewScreenEffects = false; + _viewFogs = false; + _viewLights = false; + _viewUI = false; + _viewWaypointsNormalToggle = false; + _viewWaypointsFleeToggle = false; + _viewWaypointsCoverToggle = false; + _viewWalkboxes = false; + _viewZBuffer = false; + + debugPrintf("Drawing all scene objects (actors, 3d objects, items) = %s\n", (_viewActorsToggle && _view3dObjectsToggle && _viewItemsToggle)? "true" : "false"); + debugPrintf("Drawing scene actors = %s\n", _viewActorsToggle? "true" : "false"); + debugPrintf("Drawing scene 3d objects = %s\n", _view3dObjectsToggle? "true" : "false"); + debugPrintf("Drawing scene items = %s\n", _viewItemsToggle? "true" : "false"); + debugPrintf("Drawing obstacles = %s\n", _viewObstacles? "true" : "false"); + debugPrintf("Drawing all regions (regular, exits) = %s\n", (_viewRegionsNormalToggle && _viewRegionsExitsToggle)? "true" : "false"); + debugPrintf("Drawing regular regions = %s\n", _viewRegionsNormalToggle? "true" : "false"); + debugPrintf("Drawing exit regions = %s\n", _viewRegionsExitsToggle? "true" : "false"); + debugPrintf("Drawing screen effects = %s\n", _viewScreenEffects? "true" : "false"); + debugPrintf("Drawing fogs = %s\n", _viewFogs? "true" : "false"); + debugPrintf("Drawing lights = %s\n", _viewLights? "true" : "false"); + debugPrintf("Drawing UI elements = %s\n", _viewUI? "true" : "false"); + debugPrintf("Drawing all waypoints (regular, cover, flee) = %s\n", (_viewWaypointsNormalToggle && _viewWaypointsFleeToggle && _viewWaypointsCoverToggle)? "true" : "false"); + debugPrintf("Drawing regular waypoints = %s\n", _viewWaypointsNormalToggle? "true" : "false"); + debugPrintf("Drawing flee waypoints = %s\n", _viewWaypointsFleeToggle? "true" : "false"); + debugPrintf("Drawing cover waypoints = %s\n", _viewWaypointsCoverToggle? "true" : "false"); + debugPrintf("Drawing walkboxes = %s\n", _viewWalkboxes? "true" : "false"); + debugPrintf("Drawing Z buffer = %s\n", _viewZBuffer? "true" : "false"); + } else { + invalidSyntax = true; + } + + if (!invalidSyntax) { + if (dbgDrawnObj.type != debuggerObjTypeUndefined) { + toggleObjectInDbgDrawList(dbgDrawnObj); + } + updateTogglesForDbgDrawListInCurrentSetAndScene(); + } } - Common::String arg = argv[1]; - if (arg == "act") { - _viewSceneObjects = !_viewSceneObjects; - _viewActorsOnly = _viewSceneObjects; - debugPrintf("Drawing actors = %i\n", _viewSceneObjects); - } else if (arg == "eff") { - _viewScreenEffects = !_viewScreenEffects; - debugPrintf("Drawing screen effects = %i\n", _viewScreenEffects); - } else if (arg == "fog") { - _viewFogs = !_viewFogs; - debugPrintf("Drawing fogs = %i\n", _viewFogs); - } else if (arg == "lit") { - _viewLights = !_viewLights; - debugPrintf("Drawing lights = %i\n", _viewLights); - } else if (arg == "reg") { - _viewRegions = !_viewRegions; - debugPrintf("Drawing regions = %i\n", _viewRegions); - }else if (arg == "obj") { - _viewSceneObjects = !_viewSceneObjects; - debugPrintf("Drawing scene objects = %i\n", _viewSceneObjects); - } else if (arg == "obstacles") { - _viewObstacles = !_viewObstacles; - debugPrintf("Drawing obstacles = %i\n", _viewObstacles); - } else if (arg == "ui") { - _viewUI = !_viewUI; - debugPrintf("Drawing UI elements = %i\n", _viewUI); - } else if (arg == "way") { - _viewWaypoints = !_viewWaypoints; - debugPrintf("Drawing waypoints = %i\n", _viewWaypoints); - } else if (arg == "walk") { - _viewWalkboxes = !_viewWalkboxes; - debugPrintf("Drawing walk boxes = %i\n", _viewWalkboxes); - } else if (arg == "zbuf") { - _viewZBuffer = !_viewZBuffer; - debugPrintf("Drawing Z buffer = %i\n", _viewZBuffer); - } else if (arg == "reset") { - _viewActorsOnly = false; - _viewScreenEffects = false; - _viewFogs = false; - _viewLights = false; - _viewObstacles = false; - _viewRegions = false; - _viewSceneObjects = false; - _viewUI = false; - _viewWaypoints = false; - _viewWalkboxes = false; - _viewZBuffer = false; - - debugPrintf("Drawing screen effects = %i\n", _viewScreenEffects); - debugPrintf("Drawing fogs = %i\n", _viewFogs); - debugPrintf("Drawing lights = %i\n", _viewLights); - debugPrintf("Drawing obstacles = %i\n", _viewObstacles); - debugPrintf("Drawing regions = %i\n", _viewRegions); - debugPrintf("Drawing scene objects = %i\n", _viewSceneObjects); - debugPrintf("Drawing UI elements = %i\n", _viewUI); - debugPrintf("Drawing waypoints = %i\n", _viewWaypoints); - debugPrintf("Drawing walkboxes = %i\n", _viewWalkboxes); - debugPrintf("Drawing Z buffer = %i\n", _viewZBuffer); - } - - _isDebuggerOverlay = _viewSceneObjects | _viewScreenEffects | _viewRegions | _viewLights | _viewFogs | _viewWaypoints | _viewWalkboxes; + if (invalidSyntax) { + debugPrintf("Enables debug rendering of actors, screen effect, fogs, lights, scene objects\nobstacles, regions, ui elements, walk boxes, waypoints, zbuffer or disables debug rendering.\n"); + debugPrintf("Usage 1: %s (allobj | obstacles | allreg | ui | allway | zbuf | reset)\n", argv[0]); + debugPrintf("Usage 2a: %s (act | obj | item | regnorm | regexit | waynorm | wayflee | waycov) [<id>]\n", argv[0]); + debugPrintf("Usage 2b: %s (eff | fog | lit | walk) [<id>]\n", argv[0]); + } return true; } @@ -1506,6 +1674,51 @@ bool Debugger::cmdRegion(int argc, const char **argv) { return true; } +#if BLADERUNNER_ORIGINAL_BUGS +#else +bool Debugger::cmdEffect(int argc, const char **argv) { + bool invalidSyntax = false; + + if (argc != 3) { + invalidSyntax = true; + } else { + int effectId = atoi(argv[2]); + Common::String modeName = argv[1]; + modeName.toLowercase(); + + if (modeName == "list") { + if (effectId >= 0 && effectId < (int)_vm->_screenEffects->_entries.size()) { + ScreenEffects::Entry &entry = _vm->_screenEffects->_entries[effectId]; + debugPrintf("%2d. Effect (h: %d, x: %d, y: %d, z: %d\n", effectId, (int)entry.height, (int)entry.x, (int)entry.y, (int)entry.z); + } else { + debugPrintf("There is no such effect in the scene!\n"); + } + } else if (modeName == "skip") { + if (effectId >= 0 && effectId < (int)_vm->_screenEffects->_entries.size()) { + _vm->_screenEffects->toggleEntry(effectId, true); + debugPrintf("Skipped effect %2d\n", effectId); + } else { + debugPrintf("There is no such effect to remove in the scene!\n"); + } + } else if (modeName == "restore") { + if (effectId >= 0 && effectId < (int)_vm->_screenEffects->kMaxEffectsInScene) { + _vm->_screenEffects->toggleEntry(effectId, false); + debugPrintf("Attempting to restored effect %2d\n", effectId); + } + } else { + invalidSyntax = true; + } + } + + if (invalidSyntax) { + debugPrintf("List properties or skip/restore a screen-effect obj in the current scene\n"); + debugPrintf("Usage 1: %s list <id>\n", argv[0]); + debugPrintf("Usage 2: %s (skip | restore) <id>\n", argv[0]); + } + return true; +} +#endif // BLADERUNNER_ORIGINAL_BUGS + /** * Toggle playing a full VK session (full) and showing current test statistics as subtitles * Only available in VK mode @@ -1673,7 +1886,7 @@ bool Debugger::cmdList(int argc, const char **argv) { } } debugPrintf("%d objects were found in scene.\n", count); - } else if (arg == "items") { + } else if (arg == "item") { debugPrintf("Listing scene items: \n"); int count = 0; for (int i = 0; i < _vm->_sceneObjects->_count; i++) { @@ -1737,7 +1950,7 @@ bool Debugger::cmdList(int argc, const char **argv) { char waypointText[40]; Vector3 a = waypoint->position; sprintf(waypointText, "Waypoint %i, Pos(%02.2f,%02.2f,%02.2f)", i, a.x, a.y, a.z); - debugPrintf("%02d. %s\n", count, waypointText); + debugPrintf("%s\n", waypointText); ++count; } @@ -1750,7 +1963,7 @@ bool Debugger::cmdList(int argc, const char **argv) { char coverText[40]; Vector3 a = cover->position; sprintf(coverText, "Cover %i, Pos(%02.2f,%02.2f,%02.2f)", i, a.x, a.y, a.z); - debugPrintf("%02d. %s\n", count, coverText); + debugPrintf("%s\n", coverText); ++count; } @@ -1763,7 +1976,7 @@ bool Debugger::cmdList(int argc, const char **argv) { char fleeText[40]; Vector3 a = flee->position; sprintf(fleeText, "Flee %i, Pos(%02.2f,%02.2f,%02.2f)", i, a.x, a.y, a.z); - debugPrintf("%02d. %s\n", count, fleeText); + debugPrintf("%s\n", fleeText); ++count; } debugPrintf("%d waypoints were found in scene.\n", count); @@ -1773,14 +1986,14 @@ bool Debugger::cmdList(int argc, const char **argv) { for (int i = 0; i < _vm->_scene->_set->_walkboxCount; i++) { Set::Walkbox *walkbox = &_vm->_scene->_set->_walkboxes[i]; - debugPrintf("%02d. Walkbox %s, vertices: %d\n", i, walkbox->name.c_str(), walkbox->vertexCount); + debugPrintf("%2d. Walkbox %s, vertices: %d\n", i, walkbox->name.c_str(), walkbox->vertexCount); } debugPrintf("%d walkboxes were found in scene.\n", _vm->_scene->_set->_walkboxCount); } else if (arg == "fog") { debugPrintf("Listing fogs: \n"); int count = 0; for (Fog *fog = _vm->_scene->_set->_effects->_fogs; fog != nullptr; fog = fog->_next) { - debugPrintf("%02d. Fog %s\n", count, fog->_name.c_str()); + debugPrintf("%2d. Fog %s\n", count, fog->_name.c_str()); ++count; } debugPrintf("%d fogs were found in scene.\n", count); @@ -1789,9 +2002,17 @@ bool Debugger::cmdList(int argc, const char **argv) { // list lights for (int i = 0; i < (int)_vm->_lights->_lights.size(); i++) { Light *light = _vm->_lights->_lights[i]; - debugPrintf("%02d. Light %s\n", i, light->_name.c_str()); + debugPrintf("%2d. Light %s\n", i, light->_name.c_str()); } debugPrintf("%d lights were found in scene.\n", (int)_vm->_lights->_lights.size()); + } else if (arg == "eff") { + debugPrintf("Listing scene effects: \n"); + // list scene effects + for (uint i = 0; i < _vm->_screenEffects->_entries.size(); i++) { + ScreenEffects::Entry &entry = _vm->_screenEffects->_entries[i]; + debugPrintf("%2d. Effect (h: %d, x: %d, y: %d, z: %d\n", i, (int)entry.height, (int)entry.x, (int)entry.y, (int)entry.z); + } + debugPrintf("%d scene effects were found in scene.\n", (int)_vm->_screenEffects->_entries.size()); } else { debugPrintf("Invalid item type was specified.\n"); } @@ -1799,7 +2020,7 @@ bool Debugger::cmdList(int argc, const char **argv) { if (invalidSyntax) { debugPrintf("Enables debug listing of actors, scene objects, items, waypoints, regions, lights, fogs and walk-boxes.\n"); - debugPrintf("Usage 1: %s (act | obj | items | way | reg | lit | fog | walk )\n", argv[0]); + debugPrintf("Usage 1: %s (act | obj | item | way | reg | eff | lit | fog | walk )\n", argv[0]); debugPrintf("Usage 2: %s act <actorId>\n", argv[0]); } return true; @@ -1807,13 +2028,27 @@ bool Debugger::cmdList(int argc, const char **argv) { void Debugger::drawDebuggerOverlay() { - if (_viewSceneObjects) drawSceneObjects(); - if (_viewScreenEffects) drawScreenEffects(); - if (_viewLights) drawLights(); - if (_viewFogs) drawFogs(); - if (_viewRegions) drawRegions(); - if (_viewWaypoints) drawWaypoints(); - if (_viewWalkboxes) drawWalkboxes(); + + updateTogglesForDbgDrawListInCurrentSetAndScene(); + + if (_viewActorsToggle || _specificActorsDrawn + || _view3dObjectsToggle || _specific3dObjectsDrawn + || _viewItemsToggle || _specificItemsDrawn) { + drawSceneObjects(); + } + if (_viewScreenEffects || _specificEffectsDrawn) drawScreenEffects(); + if (_viewLights || _specificLightsDrawn) drawLights(); + if (_viewFogs || _specificFogsDrawn) drawFogs(); + if (_viewRegionsNormalToggle || _specificRegionNormalDrawn + || _viewRegionsExitsToggle || _specificRegionExitsDrawn) { + drawRegions(); + } + if (_viewWaypointsNormalToggle || _specificWaypointNormalDrawn + || _viewWaypointsFleeToggle || _specificWaypointFleeDrawn + || _viewWaypointsCoverToggle || _specificWaypointCoverDrawn) { + drawWaypoints(); + } + if (_viewWalkboxes || _specificWalkboxesDrawn) drawWalkboxes(); } void Debugger::drawBBox(Vector3 start, Vector3 end, View *view, Graphics::Surface *surface, int color) { @@ -1856,34 +2091,43 @@ void Debugger::drawSceneObjects() { Vector3 pos = _vm->_view->calculateScreenPosition(0.5 * (a + b)); int color; - if (_viewActorsOnly && sceneObject->type != kSceneObjectTypeActor) - continue; - switch (sceneObject->type) { case kSceneObjectTypeUnknown: break; case kSceneObjectTypeActor: - color = _vm->_surfaceFront.format.RGBToColor(255, 0, 0); - drawBBox(a, b, _vm->_view, &_vm->_surfaceFront, color); - _vm->_surfaceFront.frameRect(sceneObject->screenRectangle, color); - _vm->_mainFont->drawColor(_vm->_textActorNames->getText(sceneObject->id - kSceneObjectOffsetActors), _vm->_surfaceFront, pos.x, pos.y, color); + if ((_viewActorsToggle && !_specificActorsDrawn) + || findInDbgDrawList(debuggerObjTypeActor, sceneObject->id - kSceneObjectOffsetActors, -1, -1) != -1 + ) { + color = _vm->_surfaceFront.format.RGBToColor(255, 0, 0); + drawBBox(a, b, _vm->_view, &_vm->_surfaceFront, color); + _vm->_surfaceFront.frameRect(sceneObject->screenRectangle, color); + _vm->_mainFont->drawColor(_vm->_textActorNames->getText(sceneObject->id - kSceneObjectOffsetActors), _vm->_surfaceFront, pos.x, pos.y, color); + } break; case kSceneObjectTypeItem: - color = _vm->_surfaceFront.format.RGBToColor(0, 255, 0); - char itemText[40]; - drawBBox(a, b, _vm->_view, &_vm->_surfaceFront, color); - sprintf(itemText, "item %i", sceneObject->id - kSceneObjectOffsetItems); - _vm->_surfaceFront.frameRect(sceneObject->screenRectangle, color); - _vm->_mainFont->drawColor(itemText, _vm->_surfaceFront, pos.x, pos.y, color); + if ((_viewItemsToggle && !_specificItemsDrawn) + || findInDbgDrawList(debuggerObjTypeItem, sceneObject->id - kSceneObjectOffsetItems, _vm->_scene->getSetId(), -1) != -1 + ) { + color = _vm->_surfaceFront.format.RGBToColor(0, 255, 0); + char itemText[40]; + drawBBox(a, b, _vm->_view, &_vm->_surfaceFront, color); + sprintf(itemText, "item %i", sceneObject->id - kSceneObjectOffsetItems); + _vm->_surfaceFront.frameRect(sceneObject->screenRectangle, color); + _vm->_mainFont->drawColor(itemText, _vm->_surfaceFront, pos.x, pos.y, color); + } break; case kSceneObjectTypeObject: - color = _vm->_surfaceFront.format.RGBToColor(127, 127, 127); - if (sceneObject->isClickable) { - color = _vm->_surfaceFront.format.RGBToColor(0, 255, 0); + if ((_view3dObjectsToggle && !_specific3dObjectsDrawn) + || findInDbgDrawList(debuggerObjType3dObject, sceneObject->id - kSceneObjectOffsetObjects, _vm->_scene->getSetId(), -1) != -1 + ) { + color = _vm->_surfaceFront.format.RGBToColor(127, 127, 127); + if (sceneObject->isClickable) { + color = _vm->_surfaceFront.format.RGBToColor(0, 255, 0); + } + drawBBox(a, b, _vm->_view, &_vm->_surfaceFront, color); + _vm->_surfaceFront.frameRect(sceneObject->screenRectangle, color); + _vm->_mainFont->drawColor(_vm->_scene->objectGetName(sceneObject->id - kSceneObjectOffsetObjects), _vm->_surfaceFront, pos.x, pos.y, color); } - drawBBox(a, b, _vm->_view, &_vm->_surfaceFront, color); - _vm->_surfaceFront.frameRect(sceneObject->screenRectangle, color); - _vm->_mainFont->drawColor(_vm->_scene->objectGetName(sceneObject->id - kSceneObjectOffsetObjects), _vm->_surfaceFront, pos.x, pos.y, color); break; } } @@ -1893,142 +2137,184 @@ void Debugger::drawSceneObjects() { void Debugger::drawLights() { // draw lights for (int i = 0; i < (int)_vm->_lights->_lights.size(); i++) { - Light *light = _vm->_lights->_lights[i]; - Matrix4x3 m = light->_matrix; - m = invertMatrix(m); - Vector3 posOrigin = m * Vector3(0.0f, 0.0f, 0.0f); - float t = posOrigin.y; - posOrigin.y = posOrigin.z; - posOrigin.z = -t; + if ((_viewLights && !_specificLightsDrawn) + || findInDbgDrawList(debuggerObjTypeLight, i, _vm->_scene->getSetId(), _vm->_scene->getSceneId()) != -1 + ) { + Light *light = _vm->_lights->_lights[i]; + Matrix4x3 m = light->_matrix; + m = invertMatrix(m); + Vector3 posOrigin = m * Vector3(0.0f, 0.0f, 0.0f); + float t = posOrigin.y; + posOrigin.y = posOrigin.z; + posOrigin.z = -t; - Vector3 posTarget = m * Vector3(0.0f, 0.0f, -100.0f); - t = posTarget.y; - posTarget.y = posTarget.z; - posTarget.z = -t; + Vector3 posTarget = m * Vector3(0.0f, 0.0f, -100.0f); + t = posTarget.y; + posTarget.y = posTarget.z; + posTarget.z = -t; - Vector3 size = Vector3(5.0f, 5.0f, 5.0f); - int color = _vm->_surfaceFront.format.RGBToColor(light->_color.r * 255.0f, light->_color.g * 255.0f, light->_color.b * 255.0f); + Vector3 size = Vector3(5.0f, 5.0f, 5.0f); + int color = _vm->_surfaceFront.format.RGBToColor(light->_color.r * 255.0f, light->_color.g * 255.0f, light->_color.b * 255.0f); - drawBBox(posOrigin - size, posOrigin + size, _vm->_view, &_vm->_surfaceFront, color); + drawBBox(posOrigin - size, posOrigin + size, _vm->_view, &_vm->_surfaceFront, color); - Vector3 posOriginT = _vm->_view->calculateScreenPosition(posOrigin); - Vector3 posTargetT = _vm->_view->calculateScreenPosition(posTarget); + Vector3 posOriginT = _vm->_view->calculateScreenPosition(posOrigin); + Vector3 posTargetT = _vm->_view->calculateScreenPosition(posTarget); - _vm->_surfaceFront.drawLine(posOriginT.x, posOriginT.y, posTargetT.x, posTargetT.y, color); + _vm->_surfaceFront.drawLine(posOriginT.x, posOriginT.y, posTargetT.x, posTargetT.y, color); - _vm->_mainFont->drawColor(light->_name, _vm->_surfaceFront, posOriginT.x, posOriginT.y, color); + _vm->_mainFont->drawColor(light->_name, _vm->_surfaceFront, posOriginT.x, posOriginT.y, color); + } } } void Debugger::drawFogs() { - for (Fog *fog = _vm->_scene->_set->_effects->_fogs; fog != nullptr; fog = fog->_next) { - - // Matrix4x3 m = fog->_matrix; - // m = invertMatrix(m); - Matrix4x3 m = fog->_inverted; + Fog *fog = _vm->_scene->_set->_effects->_fogs; + for (int i = 0; fog != nullptr; ++i) { + if ((_viewFogs && !_specificFogsDrawn) + || findInDbgDrawList(debuggerObjTypeFog, i, _vm->_scene->getSetId(), _vm->_scene->getSceneId()) != -1 + ) { + // Matrix4x3 m = fog->_matrix; + // m = invertMatrix(m); + Matrix4x3 m = fog->_inverted; - Vector3 posOrigin = m * Vector3(0.0f, 0.0f, 0.0f); - float t = posOrigin.y; - posOrigin.y = posOrigin.z; - posOrigin.z = -t; + Vector3 posOrigin = m * Vector3(0.0f, 0.0f, 0.0f); + float t = posOrigin.y; + posOrigin.y = posOrigin.z; + posOrigin.z = -t; - Vector3 posTarget = m * Vector3(0.0f, 0.0f, -100.0f); - t = posTarget.y; - posTarget.y = posTarget.z; - posTarget.z = -t; + Vector3 posTarget = m * Vector3(0.0f, 0.0f, -100.0f); + t = posTarget.y; + posTarget.y = posTarget.z; + posTarget.z = -t; - Vector3 size = Vector3(5.0f, 5.0f, 5.0f); - int color = _vm->_surfaceFront.format.RGBToColor(fog->_fogColor.r * 255.0f, fog->_fogColor.g * 255.0f, fog->_fogColor.b * 255.0f); + Vector3 size = Vector3(5.0f, 5.0f, 5.0f); + int color = _vm->_surfaceFront.format.RGBToColor(fog->_fogColor.r * 255.0f, fog->_fogColor.g * 255.0f, fog->_fogColor.b * 255.0f); - drawBBox(posOrigin - size, posOrigin + size, _vm->_view, &_vm->_surfaceFront, color); + drawBBox(posOrigin - size, posOrigin + size, _vm->_view, &_vm->_surfaceFront, color); - Vector3 posOriginT = _vm->_view->calculateScreenPosition(posOrigin); - Vector3 posTargetT = _vm->_view->calculateScreenPosition(posTarget); + Vector3 posOriginT = _vm->_view->calculateScreenPosition(posOrigin); + Vector3 posTargetT = _vm->_view->calculateScreenPosition(posTarget); - // TODO: draw line only for cone fogs, draw boxes or circles for the other types - _vm->_surfaceFront.drawLine(posOriginT.x, posOriginT.y, posTargetT.x, posTargetT.y, color); + // TODO: draw line only for cone fogs, draw boxes or circles for the other types + _vm->_surfaceFront.drawLine(posOriginT.x, posOriginT.y, posTargetT.x, posTargetT.y, color); - _vm->_mainFont->drawColor(fog->_name, _vm->_surfaceFront, posOriginT.x, posOriginT.y, color); + _vm->_mainFont->drawColor(fog->_name, _vm->_surfaceFront, posOriginT.x, posOriginT.y, color); + } + fog = fog->_next; } } void Debugger::drawRegions() { - //draw regions - for (int i = 0; i < 10; i++) { - Regions::Region *region = &_vm->_scene->_regions->_regions[i]; - if (!region->present) continue; - _vm->_surfaceFront.frameRect(region->rectangle, _vm->_surfaceFront.format.RGBToColor(0, 0, 255)); + if (_viewRegionsNormalToggle || _specificRegionNormalDrawn) { + //draw regions + for (int i = 0; i < 10; i++) { + Regions::Region *region = &_vm->_scene->_regions->_regions[i]; + if (!region->present) continue; + if ((_viewRegionsNormalToggle && !_specificRegionNormalDrawn) + || findInDbgDrawList(debuggerObjTypeRegionNormal, i, _vm->_scene->getSetId(), _vm->_scene->getSceneId()) != -1 + ) { + _vm->_surfaceFront.frameRect(region->rectangle, _vm->_surfaceFront.format.RGBToColor(0, 0, 255)); + } + } } - //draw exits - for (int i = 0; i < 10; i++) { - Regions::Region *region = &_vm->_scene->_exits->_regions[i]; - if (!region->present) continue; - _vm->_surfaceFront.frameRect(region->rectangle, _vm->_surfaceFront.format.RGBToColor(255, 255, 255)); + if (_viewRegionsExitsToggle || _specificRegionExitsDrawn) { + //draw exits + for (int i = 0; i < 10; i++) { + Regions::Region *region = &_vm->_scene->_exits->_regions[i]; + if (!region->present) continue; + if ((_viewRegionsExitsToggle && !_specificRegionExitsDrawn) + || findInDbgDrawList(debuggerObjTypeRegionExit, i, _vm->_scene->getSetId(), _vm->_scene->getSceneId()) != -1 + ) { + _vm->_surfaceFront.frameRect(region->rectangle, _vm->_surfaceFront.format.RGBToColor(255, 255, 255)); + } + } } } void Debugger::drawWaypoints() { - //draw world waypoints - for (int i = 0; i < _vm->_waypoints->_count; i++) { - Waypoints::Waypoint *waypoint = &_vm->_waypoints->_waypoints[i]; - if(waypoint->setId != _vm->_scene->getSetId()) { - continue; + if (_viewWaypointsNormalToggle || _specificWaypointNormalDrawn) { + //draw world waypoints + for (int i = 0; i < _vm->_waypoints->_count; i++) { + Waypoints::Waypoint *waypoint = &_vm->_waypoints->_waypoints[i]; + if(waypoint->setId != _vm->_scene->getSetId()) { + continue; + } + if ((_viewWaypointsNormalToggle && !_specificWaypointNormalDrawn) + || findInDbgDrawList(debuggerObjTypeWaypointNorm, i, -1, -1) != -1 + ) { + Vector3 pos = waypoint->position; + Vector3 size = Vector3(3.0f, 3.0f, 3.0f); + int color = _vm->_surfaceFront.format.RGBToColor(255, 255, 255); + drawBBox(pos - size, pos + size, _vm->_view, &_vm->_surfaceFront, color); + Vector3 spos = _vm->_view->calculateScreenPosition(pos); + char waypointText[40]; + sprintf(waypointText, "waypoint %i", i); + _vm->_mainFont->drawColor(waypointText, _vm->_surfaceFront, spos.x, spos.y, color); + } } - Vector3 pos = waypoint->position; - Vector3 size = Vector3(3.0f, 3.0f, 3.0f); - int color = _vm->_surfaceFront.format.RGBToColor(255, 255, 255); - drawBBox(pos - size, pos + size, _vm->_view, &_vm->_surfaceFront, color); - Vector3 spos = _vm->_view->calculateScreenPosition(pos); - char waypointText[40]; - sprintf(waypointText, "waypoint %i", i); - _vm->_mainFont->drawColor(waypointText, _vm->_surfaceFront, spos.x, spos.y, color); - } - - //draw combat cover waypoints - for (int i = 0; i < (int)_vm->_combat->_coverWaypoints.size(); i++) { - Combat::CoverWaypoint *cover = &_vm->_combat->_coverWaypoints[i]; - if (cover->setId != _vm->_scene->getSetId()) { - continue; + } + + if (_viewWaypointsCoverToggle || _specificWaypointCoverDrawn) { + //draw combat cover waypoints + for (int i = 0; i < (int)_vm->_combat->_coverWaypoints.size(); i++) { + Combat::CoverWaypoint *cover = &_vm->_combat->_coverWaypoints[i]; + if (cover->setId != _vm->_scene->getSetId()) { + continue; + } + if ((_viewWaypointsCoverToggle && !_specificWaypointCoverDrawn) + || findInDbgDrawList(debuggerObjTypeWaypointCover, i, -1, -1) != -1 + ) { + Vector3 pos = cover->position; + Vector3 size = Vector3(3.0f, 3.0f, 3.0f); + int color = _vm->_surfaceFront.format.RGBToColor(255, 0, 255); + drawBBox(pos - size, pos + size, _vm->_view, &_vm->_surfaceFront, color); + Vector3 spos = _vm->_view->calculateScreenPosition(pos); + char coverText[40]; + sprintf(coverText, "cover %i", i); + _vm->_mainFont->drawColor(coverText, _vm->_surfaceFront, spos.x, spos.y, color); + } } - Vector3 pos = cover->position; - Vector3 size = Vector3(3.0f, 3.0f, 3.0f); - int color = _vm->_surfaceFront.format.RGBToColor(255, 0, 255); - drawBBox(pos - size, pos + size, _vm->_view, &_vm->_surfaceFront, color); - Vector3 spos = _vm->_view->calculateScreenPosition(pos); - char coverText[40]; - sprintf(coverText, "cover %i", i); - _vm->_mainFont->drawColor(coverText, _vm->_surfaceFront, spos.x, spos.y, color); - } - - //draw combat flee waypoints - for (int i = 0; i < (int)_vm->_combat->_fleeWaypoints.size(); i++) { - Combat::FleeWaypoint *flee = &_vm->_combat->_fleeWaypoints[i]; - if (flee->setId != _vm->_scene->getSetId()) { - continue; + } + + if (_viewWaypointsFleeToggle || _specificWaypointFleeDrawn) { + //draw combat flee waypoints + for (int i = 0; i < (int)_vm->_combat->_fleeWaypoints.size(); i++) { + Combat::FleeWaypoint *flee = &_vm->_combat->_fleeWaypoints[i]; + if (flee->setId != _vm->_scene->getSetId()) { + continue; + } + if ((_viewWaypointsFleeToggle && !_specificWaypointFleeDrawn) + || findInDbgDrawList(debuggerObjTypeWaypoingFlee, i, -1, -1) != -1 + ) { + Vector3 pos = flee->position; + Vector3 size = Vector3(3.0f, 3.0f, 3.0f); + int color = _vm->_surfaceFront.format.RGBToColor(0, 255, 255); + drawBBox(pos - size, pos + size, _vm->_view, &_vm->_surfaceFront, color); + Vector3 spos = _vm->_view->calculateScreenPosition(pos); + char fleeText[40]; + sprintf(fleeText, "flee %i", i); + _vm->_mainFont->drawColor(fleeText, _vm->_surfaceFront, spos.x, spos.y, color); + } } - Vector3 pos = flee->position; - Vector3 size = Vector3(3.0f, 3.0f, 3.0f); - int color = _vm->_surfaceFront.format.RGBToColor(0, 255, 255); - drawBBox(pos - size, pos + size, _vm->_view, &_vm->_surfaceFront, color); - Vector3 spos = _vm->_view->calculateScreenPosition(pos); - char fleeText[40]; - sprintf(fleeText, "flee %i", i); - _vm->_mainFont->drawColor(fleeText, _vm->_surfaceFront, spos.x, spos.y, color); } } void Debugger::drawWalkboxes() { //draw walkboxes for (int i = 0; i < _vm->_scene->_set->_walkboxCount; i++) { - Set::Walkbox *walkbox = &_vm->_scene->_set->_walkboxes[i]; - - for (int j = 0; j < walkbox->vertexCount; j++) { - Vector3 start = _vm->_view->calculateScreenPosition(walkbox->vertices[j]); - Vector3 end = _vm->_view->calculateScreenPosition(walkbox->vertices[(j + 1) % walkbox->vertexCount]); - _vm->_surfaceFront.drawLine(start.x, start.y, end.x, end.y, _vm->_surfaceFront.format.RGBToColor(255, 255, 0)); - Vector3 pos = _vm->_view->calculateScreenPosition(0.5 * (walkbox->vertices[j] + walkbox->vertices[(j + 1) % walkbox->vertexCount])); - _vm->_mainFont->drawColor(walkbox->name, _vm->_surfaceFront, pos.x, pos.y, _vm->_surfaceFront.format.RGBToColor(255, 255, 0)); + if ((_viewWalkboxes && !_specificWalkboxesDrawn) + || findInDbgDrawList(debuggerObjTypeWalkbox, i, _vm->_scene->getSetId(), _vm->_scene->getSceneId()) != -1 + ) { + Set::Walkbox *walkbox = &_vm->_scene->_set->_walkboxes[i]; + for (int j = 0; j < walkbox->vertexCount; j++) { + Vector3 start = _vm->_view->calculateScreenPosition(walkbox->vertices[j]); + Vector3 end = _vm->_view->calculateScreenPosition(walkbox->vertices[(j + 1) % walkbox->vertexCount]); + _vm->_surfaceFront.drawLine(start.x, start.y, end.x, end.y, _vm->_surfaceFront.format.RGBToColor(255, 255, 0)); + Vector3 pos = _vm->_view->calculateScreenPosition(0.5 * (walkbox->vertices[j] + walkbox->vertices[(j + 1) % walkbox->vertexCount])); + _vm->_mainFont->drawColor(walkbox->name, _vm->_surfaceFront, pos.x, pos.y, _vm->_surfaceFront.format.RGBToColor(255, 255, 0)); + } } } } @@ -2036,23 +2322,161 @@ void Debugger::drawWalkboxes() { void Debugger::drawScreenEffects() { //draw aesc for (uint i = 0; i < _vm->_screenEffects->_entries.size(); i++) { - ScreenEffects::Entry &entry = _vm->_screenEffects->_entries[i]; - int j = 0; - for (int y = 0; y < entry.height; y++) { - for (int x = 0; x < entry.width; x++) { - Common::Rect r((entry.x + x) * 2, (entry.y + y) * 2, (entry.x + x) * 2 + 2, (entry.y + y) * 2 + 2); - - int ec = entry.data[j++]; - const int bladeToScummVmConstant = 256 / 16; - - int color = _vm->_surfaceFront.format.RGBToColor( - CLIP(entry.palette[ec].r * bladeToScummVmConstant, 0, 255), - CLIP(entry.palette[ec].g * bladeToScummVmConstant, 0, 255), - CLIP(entry.palette[ec].b * bladeToScummVmConstant, 0, 255)); - _vm->_surfaceFront.fillRect(r, color); + if ((_viewScreenEffects && !_specificEffectsDrawn) + || findInDbgDrawList(debuggerObjTypeEffect, i, _vm->_scene->getSetId(), _vm->_scene->getSceneId()) != -1 + ) { + ScreenEffects::Entry &entry = _vm->_screenEffects->_entries[i]; + int j = 0; + for (int y = 0; y < entry.height; y++) { + for (int x = 0; x < entry.width; x++) { + Common::Rect r((entry.x + x) * 2, (entry.y + y) * 2, (entry.x + x) * 2 + 2, (entry.y + y) * 2 + 2); + + int ec = entry.data[j++]; + const int bladeToScummVmConstant = 256 / 16; + + int color = _vm->_surfaceFront.format.RGBToColor( + CLIP(entry.palette[ec].r * bladeToScummVmConstant, 0, 255), + CLIP(entry.palette[ec].g * bladeToScummVmConstant, 0, 255), + CLIP(entry.palette[ec].b * bladeToScummVmConstant, 0, 255)); + _vm->_surfaceFront.fillRect(r, color); + } + } + } + } +} + +void Debugger::toggleObjectInDbgDrawList(DebuggerDrawnObject &drObj) { + if (drObj.type == debuggerObjTypeUndefined || drObj.objId < 0) { + return; + } + + // Check if there already exists such object in the list: + // if it exists then do a remove action + // else do a push_back action (provided that size() < kMaxSpecificObjectsDrawnCount) + int foundAt = findInDbgDrawList(drObj.type, drObj.objId, drObj.setId, drObj.sceneId); + + if (foundAt >= 0) { + _specificDrawnObjectsList.remove_at(foundAt); + } else { + if (_specificDrawnObjectsList.size() < kMaxSpecificObjectsDrawnCount) { + // TODO check if there actually is an object of such an ID in the current scene! + _specificDrawnObjectsList.push_back(drObj); + } else { + debugPrintf("The specific drawn objects list is full. Try running a draw reset or explicitly removing objects from it\n"); + } + } +} + +/** +* drObjType can be a valid object type, or debuggerObjTypeUndefined as a wildcard for all object types +* drObjId can be a valid object id or -1 as a wildcard +* drObjSetId can be a valid Set id or -1 as a wildcard +* drObjSceneId can be a valid Scene id or -1 as a wildcard +* return the position in the list, if the specific drawn objects list contains the object of the specified type and id +* and it belongs to the current set and scene, +* or -1 otherwise +*/ +int Debugger::findInDbgDrawList(DebuggerDrawnObjectType drObjType, int drObjId, int drObjSetId, int drObjSceneId) { + if (_specificDrawnObjectsList.empty()) { + return -1; + } + + for (int i = 0; i < (int) _specificDrawnObjectsList.size(); ++i) { + if ((drObjType == debuggerObjTypeUndefined || drObjType == _specificDrawnObjectsList[i].type) + && (drObjId == -1 || drObjId == _specificDrawnObjectsList[i].objId) + && (drObjSetId == -1 || _specificDrawnObjectsList[i].setId == -1 || drObjSetId == _specificDrawnObjectsList[i].setId) + && (drObjSceneId == -1 || _specificDrawnObjectsList[i].sceneId == -1 || drObjSceneId == _specificDrawnObjectsList[i].sceneId) + ){ + // TODO for actors, 3d objects, items and waypoints it's probably preferable to ignore the sceneId (?) + return i; + } + } + return -1; +} + +void Debugger::updateTogglesForDbgDrawListInCurrentSetAndScene() { + _specificActorsDrawn = false; + _specific3dObjectsDrawn = false; + _specificItemsDrawn = false; + _specificEffectsDrawn = false; + _specificLightsDrawn = false; + _specificFogsDrawn = false; + _specificRegionNormalDrawn = false; + _specificRegionExitsDrawn = false; + _specificWaypointNormalDrawn = false; + _specificWaypointFleeDrawn = false; + _specificWaypointCoverDrawn = false; + _specificWalkboxesDrawn = false; + for (int i = 0; i < (int) _specificDrawnObjectsList.size(); ++i) { + if ((_specificDrawnObjectsList[i].sceneId == -1 || _specificDrawnObjectsList[i].sceneId == _vm->_scene->getSceneId() ) + && (_specificDrawnObjectsList[i].setId == -1 || _specificDrawnObjectsList[i].setId == _vm->_scene->getSetId()) + ) { + switch (_specificDrawnObjectsList[i].type) { + case debuggerObjTypeActor: + _specificActorsDrawn = true; + _viewActorsToggle = false; + break; + case debuggerObjType3dObject: + _specific3dObjectsDrawn = true; + _view3dObjectsToggle = false; + break; + case debuggerObjTypeItem: + _specificItemsDrawn = true; + _viewItemsToggle = false; + break; + case debuggerObjTypeRegionNormal: + _specificRegionNormalDrawn = true; + _viewRegionsNormalToggle = false; + break; + case debuggerObjTypeRegionExit: + _specificRegionExitsDrawn = true; + _viewRegionsExitsToggle = false; + break; + case debuggerObjTypeWaypointNorm: + _specificWaypointNormalDrawn = true; + _viewWaypointsNormalToggle = false; + break; + case debuggerObjTypeWaypoingFlee: + _specificWaypointFleeDrawn = true; + _viewWaypointsFleeToggle = false; + break; + case debuggerObjTypeWaypointCover: + _specificWaypointCoverDrawn = true; + _viewWaypointsCoverToggle = false; + break; + case debuggerObjTypeWalkbox: + _specificWalkboxesDrawn = true; + _viewWalkboxes = false; + break; + case debuggerObjTypeEffect: + _specificEffectsDrawn = true; + _viewScreenEffects = false; + break; + case debuggerObjTypeLight: + _specificLightsDrawn = true; + _viewLights = false; + break; + case debuggerObjTypeFog: + _specificFogsDrawn = true; + _viewFogs = false; + break; + default: + break; } } } + _isDebuggerOverlay = _viewActorsToggle || _specificActorsDrawn + || _view3dObjectsToggle || _specific3dObjectsDrawn + || _viewItemsToggle || _specificItemsDrawn + || _viewRegionsNormalToggle || _specificRegionNormalDrawn + || _viewRegionsExitsToggle || _specificRegionExitsDrawn + || _viewScreenEffects || _specificEffectsDrawn + || _viewLights || _specificLightsDrawn + || _viewFogs || _specificFogsDrawn + || _viewWaypointsNormalToggle || _specificWaypointNormalDrawn + || _viewWaypointsFleeToggle || _specificWaypointFleeDrawn + || _viewWaypointsCoverToggle || _specificWaypointCoverDrawn + || _viewWalkboxes || _specificWalkboxesDrawn; } } // End of namespace BladeRunner diff --git a/engines/bladerunner/debugger.h b/engines/bladerunner/debugger.h index 96fa76473d..5368286bfc 100644 --- a/engines/bladerunner/debugger.h +++ b/engines/bladerunner/debugger.h @@ -36,21 +36,50 @@ namespace BladeRunner { class BladeRunnerEngine; class View; +enum DebuggerDrawnObjectType { + debuggerObjTypeUndefined = 99, + debuggerObjTypeActor = 0, + debuggerObjType3dObject = 1, + debuggerObjTypeItem = 2, + debuggerObjTypeRegionNormal = 3, + debuggerObjTypeRegionExit = 4, + debuggerObjTypeWaypointNorm = 5, + debuggerObjTypeWaypoingFlee = 6, + debuggerObjTypeWaypointCover = 7, + debuggerObjTypeWalkbox = 8, + debuggerObjTypeEffect = 9, + debuggerObjTypeLight = 10, + debuggerObjTypeFog = 11 +}; + class Debugger : public GUI::Debugger{ BladeRunnerEngine *_vm; + static const int kMaxSpecificObjectsDrawnCount = 100; + + struct DebuggerDrawnObject { + int sceneId; + int setId; + int objId; + DebuggerDrawnObjectType type; + }; + public: bool _isDebuggerOverlay; - bool _viewActorsOnly; + bool _viewActorsToggle; + bool _view3dObjectsToggle; + bool _viewItemsToggle; bool _viewFogs; bool _viewLights; bool _viewScreenEffects; - bool _viewSceneObjects; bool _viewObstacles; - bool _viewRegions; + bool _viewRegionsNormalToggle; + bool _viewRegionsExitsToggle; bool _viewUI; - bool _viewWaypoints; + bool _viewWaypointsNormalToggle; + bool _viewWaypointsFleeToggle; + bool _viewWaypointsCoverToggle; bool _viewWalkboxes; bool _viewZBuffer; bool _playFullVk; @@ -81,6 +110,10 @@ public: bool cmdObject(int argc, const char **argv); bool cmdItem(int argc, const char **argv); bool cmdRegion(int argc, const char **argv); +#if BLADERUNNER_ORIGINAL_BUGS +#else + bool cmdEffect(int argc, const char **argv); +#endif // BLADERUNNER_ORIGINAL_BUGS bool cmdList(int argc, const char **argv); bool cmdVk(int argc, const char **argv); @@ -88,13 +121,31 @@ public: void drawBBox(Vector3 start, Vector3 end, View *view, Graphics::Surface *surface, int color); void drawSceneObjects(); - void drawActors(); void drawLights(); void drawFogs(); void drawRegions(); void drawWaypoints(); void drawWalkboxes(); void drawScreenEffects(); + +private: + Common::Array<DebuggerDrawnObject> _specificDrawnObjectsList; + bool _specificActorsDrawn; + bool _specific3dObjectsDrawn; + bool _specificItemsDrawn; + bool _specificEffectsDrawn; + bool _specificLightsDrawn; + bool _specificFogsDrawn; + bool _specificRegionNormalDrawn; + bool _specificRegionExitsDrawn; + bool _specificWaypointNormalDrawn; + bool _specificWaypointFleeDrawn; + bool _specificWaypointCoverDrawn; + bool _specificWalkboxesDrawn; + + void toggleObjectInDbgDrawList(DebuggerDrawnObject &drObj); + int findInDbgDrawList(DebuggerDrawnObjectType objType, int objId, int setId, int sceneId); + void updateTogglesForDbgDrawListInCurrentSetAndScene(); }; } // End of namespace BladeRunner diff --git a/engines/bladerunner/scene.cpp b/engines/bladerunner/scene.cpp index dc6a7f798c..7b828edf9f 100644 --- a/engines/bladerunner/scene.cpp +++ b/engines/bladerunner/scene.cpp @@ -91,6 +91,10 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) { } else { _regions->clear(); _exits->clear(); +#if BLADERUNNER_ORIGINAL_BUGS +#else + _vm->_screenEffects->toggleEntry(-1, false); // clear the skip list +#endif _vm->_screenEffects->_entries.clear(); _vm->_overlays->removeAll(); _defaultLoop = 0; @@ -132,7 +136,15 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) { if (isLoadingGame) { resume(true); - if (sceneId == kScenePS10 || sceneId == kScenePS11 || sceneId == kScenePS12 || sceneId == kScenePS13) { // police maze? + if (sceneId == kScenePS10 // police maze + || sceneId == kScenePS11 // police maze + || sceneId == kScenePS12 // police maze + || sceneId == kScenePS13 // police maze +#if BLADERUNNER_ORIGINAL_BUGS +#else + || sceneId == kSceneUG01 // Steam room +#endif // BLADERUNNER_ORIGINAL_BUGS + ) { _vm->_sceneScript->sceneLoaded(); } return true; diff --git a/engines/bladerunner/screen_effects.cpp b/engines/bladerunner/screen_effects.cpp index eae768166d..fbab21908b 100644 --- a/engines/bladerunner/screen_effects.cpp +++ b/engines/bladerunner/screen_effects.cpp @@ -30,12 +30,49 @@ ScreenEffects::ScreenEffects(BladeRunnerEngine *vm, int size) { _vm = vm; _dataSize = size; _data = new uint8[size]; - _entries.reserve(8); + _entries.reserve(kMaxEffectsInScene + 1); } ScreenEffects::~ScreenEffects() { delete[] _data; +#if BLADERUNNER_ORIGINAL_BUGS +#else + if(!_skipEntries.empty()) { + _skipEntries.clear(); + } +#endif // BLADERUNNER_ORIGINAL_BUGS +} + +#if BLADERUNNER_ORIGINAL_BUGS +#else +void ScreenEffects::toggleEntry(int effectId, bool skip) { + if (effectId >= 0 && effectId < kMaxEffectsInScene) { + int foundAt = -1; + for (int i = 0; i < (int)_skipEntries.size(); i++) { + if (_skipEntries[i] == effectId) { + foundAt = i; + break; + } + } + + if (skip && foundAt < 0) { + int newSlot = 0; + // keep the array sorted (from greater values to lower values) + for (int i = 0; i < (int)_skipEntries.size(); i++) { + if (effectId > _skipEntries[i]) { + newSlot = i; + break; + } + } + _skipEntries.insert_at(newSlot, effectId); + } else if (!skip && foundAt >= 0 ){ + _skipEntries.remove_at(foundAt); + } + } else if (effectId == -1 && !skip) { + _skipEntries.clear(); + } } +#endif // BLADERUNNER_ORIGINAL_BUGS void ScreenEffects::readVqa(Common::SeekableReadStream *stream) { uint8 *dataPtr = _data; @@ -47,7 +84,7 @@ void ScreenEffects::readVqa(Common::SeekableReadStream *stream) { return; } - entryCount = MIN(entryCount, 7); + entryCount = MIN(entryCount, kMaxEffectsInScene); _entries.resize(entryCount); for (Common::Array<Entry>::iterator entry = _entries.begin(); entry != _entries.end(); ++entry) { @@ -63,12 +100,12 @@ void ScreenEffects::readVqa(Common::SeekableReadStream *stream) { int pixelCount = entry->width * entry->height; - if (pixelCount > dataSize) { // to big to fit + if (pixelCount > dataSize) { // too big to fit entry->width = 0; entry->height = 0; entry->data = _data; continue; - // there is a issue in the game code, because it's not skipping data of entry in this case + // TODO a bug? there is a issue in the game code, because it's not skipping data of entry in this case } int pos = stream->pos(); @@ -94,6 +131,14 @@ void ScreenEffects::readVqa(Common::SeekableReadStream *stream) { } while (pixelCount > 0); stream->seek(pos + entryDataSize, SEEK_SET); } + +#if BLADERUNNER_ORIGINAL_BUGS +#else + // added code to allow skipping specific effects + for (int i = 0; i < (int)_skipEntries.size(); i++) { + _entries.remove_at(_skipEntries[i]); + } +#endif // BLADERUNNER_ORIGINAL_BUGS } //TODO: diff --git a/engines/bladerunner/screen_effects.h b/engines/bladerunner/screen_effects.h index d16f1cf284..06d8014c58 100644 --- a/engines/bladerunner/screen_effects.h +++ b/engines/bladerunner/screen_effects.h @@ -36,6 +36,8 @@ namespace BladeRunner { class BladeRunnerEngine; class ScreenEffects { + friend class Debugger; + static const int kMaxEffectsInScene = 7; public: struct Entry { Color256 palette[16]; @@ -52,6 +54,10 @@ public: Common::Array<Entry> _entries; uint8 *_data; int _dataSize; +#if BLADERUNNER_ORIGINAL_BUGS +#else + Common::Array<int> _skipEntries; // added member to allow skipping specified effects +#endif // BLADERUNNER_ORIGINAL_BUGS public: ScreenEffects(BladeRunnerEngine *vm, int size); @@ -59,7 +65,10 @@ public: void readVqa(Common::SeekableReadStream *stream); void getColor(Color256 *outColor, uint16 x, uint16 y, uint16 z) const; - +#if BLADERUNNER_ORIGINAL_BUGS +#else + void toggleEntry(int effectId, bool skip); // added method to allow skipping specified effects +#endif // BLADERUNNER_ORIGINAL_BUGS //TODO //bool isAffectingArea(int x, int y, int width, int height, int unk); }; diff --git a/engines/bladerunner/script/scene/ug01.cpp b/engines/bladerunner/script/scene/ug01.cpp index e33e3f2554..365463172a 100644 --- a/engines/bladerunner/script/scene/ug01.cpp +++ b/engines/bladerunner/script/scene/ug01.cpp @@ -24,6 +24,12 @@ namespace BladeRunner { +enum kUG01Loops { + kUG01LoopMainLoop = 0, // 0 - 60 + kUG01LoopSteamDissapating = 2, // 61 - 120 + kUG01LoopMainLoopNoSteam = 3 // 121 - 181 +}; + void SceneScriptUG01::InitializeScene() { if (Game_Flag_Query(kFlagUG10toUG01)) { Setup_Scene_Information(34.47f, -50.13f, -924.11f, 500); @@ -37,7 +43,13 @@ void SceneScriptUG01::InitializeScene() { Scene_Exit_Add_2D_Exit(1, 144, 0, 210, 104, 0); Scene_Exit_Add_2D_Exit(2, 0, 173, 139, 402, 3); +#if BLADERUNNER_ORIGINAL_BUGS Ambient_Sounds_Add_Looping_Sound(kSfxSTMLOOP7, 28, 0, 1); +#else + if (!Game_Flag_Query(kFlagUG01SteamOff)) { + Ambient_Sounds_Add_Looping_Sound(kSfxSTMLOOP7, 28, 0, 1); + } +#endif // BLADERUNNER_ORIGINAL_BUGS Ambient_Sounds_Add_Looping_Sound(kSfxUGBED1, 40, 0, 1); Ambient_Sounds_Add_Looping_Sound(kSfxUGBED2, 40, 0, 1); Ambient_Sounds_Add_Sound(kSfxBBDRIP1, 2, 20, 20, 25, -100, 100, -100, 100, 0, 0); @@ -60,9 +72,9 @@ void SceneScriptUG01::InitializeScene() { Ambient_Sounds_Add_Sound(kSfxBBGRN3, 5, 50, 17, 37, 0, 100, -101, -101, 0, 0); if (Game_Flag_Query(kFlagUG01SteamOff)) { - Scene_Loop_Set_Default(3); + Scene_Loop_Set_Default(kUG01LoopMainLoopNoSteam); } else { - Scene_Loop_Set_Default(0); + Scene_Loop_Set_Default(kUG01LoopMainLoop); } } @@ -71,6 +83,12 @@ void SceneScriptUG01::SceneLoaded() { Unobstacle_Object("BEAM03", true); Unobstacle_Object("BEAM04", true); Clickable_Object("PIPES_FG_LFT"); +#if BLADERUNNER_ORIGINAL_BUGS +#else + if (Game_Flag_Query(kFlagUG01SteamOff)) { + Screen_Effect_Skip(0); + } +#endif // BLADERUNNER_ORIGINAL_BUGS } bool SceneScriptUG01::MouseClick(int x, int y) { @@ -82,9 +100,18 @@ bool SceneScriptUG01::ClickedOn3DObject(const char *objectName, bool a2) { if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -9.0f, -50.13f, -148.0f, 0, true, false, false) && !Game_Flag_Query(kFlagUG01SteamOff) ) { +#if BLADERUNNER_ORIGINAL_BUGS Actor_Says(kActorMcCoy, 8525, 13); - Scene_Loop_Set_Default(3); - Scene_Loop_Start_Special(kSceneLoopModeOnce, 2, true); + Scene_Loop_Set_Default(kUG01LoopMainLoopNoSteam); + Scene_Loop_Start_Special(kSceneLoopModeOnce, kUG01LoopSteamDissapating, true); +#else + Sound_Play(kSfxSQUEAK1, 40, 0, 0, 50); + Screen_Effect_Skip(0); + Scene_Loop_Set_Default(kUG01LoopMainLoopNoSteam); + Scene_Loop_Start_Special(kSceneLoopModeOnce, kUG01LoopSteamDissapating, false); + Sound_Play(kSfxSTEAM6A, 40, 0, 0, 50); + Ambient_Sounds_Remove_Looping_Sound(kSfxSTMLOOP7, 2); +#endif // BLADERUNNER_ORIGINAL_BUGS Game_Flag_Set(kFlagUG01SteamOff); } else { Actor_Says(kActorMcCoy, 8525, 13); @@ -180,6 +207,10 @@ void SceneScriptUG01::PlayerWalkedIn() { void SceneScriptUG01::PlayerWalkedOut() { Ambient_Sounds_Remove_All_Non_Looping_Sounds(true); Ambient_Sounds_Remove_All_Looping_Sounds(1); +#if BLADERUNNER_ORIGINAL_BUGS +#else + Screen_Effect_Restore_All(); +#endif // BLADERUNNER_ORIGINAL_BUGS } void SceneScriptUG01::DialogueQueueFlushed(int a1) { diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp index e6659165d6..c8a5c609bf 100644 --- a/engines/bladerunner/script/script.cpp +++ b/engines/bladerunner/script/script.cpp @@ -43,6 +43,10 @@ #include "bladerunner/set.h" #include "bladerunner/settings.h" #include "bladerunner/set_effects.h" +#if BLADERUNNER_ORIGINAL_BUGS +#else +#include "bladerunner/screen_effects.h" +#endif // BLADERUNNER_ORIGINAL_BUGS #include "bladerunner/scene.h" #include "bladerunner/scene_objects.h" #include "bladerunner/script/police_maze.h" @@ -808,6 +812,27 @@ void ScriptBase::Set_Subtitle_Text_On_Screen(Common::String displayText) { _vm->_subtitles->show(); } +#if BLADERUNNER_ORIGINAL_BUGS +#else +void ScriptBase::Screen_Effect_Skip(int effectInc) { + debugC(kDebugScript, "Screen_Effect_Skip(%d)", effectInc); + _vm->_screenEffects->toggleEntry(effectInc, true); + _vm->_scene->advanceFrame(false); +} + +void ScriptBase::Screen_Effect_Restore(int effectInc) { + debugC(kDebugScript, "Screen_Effect_Restore(%d)", effectInc); + _vm->_screenEffects->toggleEntry(effectInc, false); + _vm->_scene->advanceFrame(false); +} + +void ScriptBase::Screen_Effect_Restore_All() { + debugC(kDebugScript, "Screen_Effect_Restore_All()"); + _vm->_screenEffects->toggleEntry(-1, false); + _vm->_scene->advanceFrame(false); +} +#endif // BLADERUNNER_ORIGINAL_BUGS + int ScriptBase::Animation_Open() { //This is not implemented in game return -1; diff --git a/engines/bladerunner/script/script.h b/engines/bladerunner/script/script.h index aca4507f6e..8adfb1d728 100644 --- a/engines/bladerunner/script/script.h +++ b/engines/bladerunner/script/script.h @@ -129,6 +129,12 @@ protected: void Item_Pickup_Spin_Effect(int animationId, int x, int y); bool Item_Query_Visible(int itemId); void Set_Subtitle_Text_On_Screen(Common::String displayText); +#if BLADERUNNER_ORIGINAL_BUGS +#else + void Screen_Effect_Skip(int effectInc); + void Screen_Effect_Restore(int effectInc); + void Screen_Effect_Restore_All(); +#endif // BLADERUNNER_ORIGINAL_BUGS int Animation_Open(); int Animation_Close(); int Animation_Start(); diff --git a/engines/bladerunner/ui/spinner.cpp b/engines/bladerunner/ui/spinner.cpp index 0054e1b2ef..8480906e49 100644 --- a/engines/bladerunner/ui/spinner.cpp +++ b/engines/bladerunner/ui/spinner.cpp @@ -431,7 +431,7 @@ void Spinner::tickDescription() { } if (!_vm->_mouse->isDisabled()) { - // mouse can mouse when disab;ed so hover callbacks will work, while the cursor is invisible + // mouse can still move when disabled, so hover callbacks will work while the cursor is invisible, // so postpone the speech until mouse is invisible again _vm->_actors[_actorId]->speechPlay(_sentenceId, false); _actorId = -1; |