[Scummvm-git-logs] scummvm branch-2-8 -> dc13270cd4b73b2c3b68083a0e23f366ce59c069

mgerhardy noreply at scummvm.org
Tue Jan 2 13:02:40 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:
dc13270cd4 TWINE: allow to toggle the zoom mode by keybinding


Commit: dc13270cd4b73b2c3b68083a0e23f366ce59c069
    https://github.com/scummvm/scummvm/commit/dc13270cd4b73b2c3b68083a0e23f366ce59c069
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-01-02T14:02:21+01:00

Commit Message:
TWINE: allow to toggle the zoom mode by keybinding

this is bound to F5 in the original game - but F5 is our own dialog

there is currently no binding set at all. See https://bugs.scummvm.org/ticket/14795

Changed paths:
    engines/twine/debugger/console.cpp
    engines/twine/holomap.cpp
    engines/twine/input.h
    engines/twine/menu/menu.cpp
    engines/twine/metaengine.cpp
    engines/twine/renderer/redraw.cpp
    engines/twine/renderer/redraw.h
    engines/twine/scene/gamestate.cpp
    engines/twine/scene/scene.cpp
    engines/twine/script/script_life.cpp
    engines/twine/text.cpp
    engines/twine/twine.cpp
    engines/twine/twine.h


diff --git a/engines/twine/debugger/console.cpp b/engines/twine/debugger/console.cpp
index d298cc7a67c..296aafe237a 100644
--- a/engines/twine/debugger/console.cpp
+++ b/engines/twine/debugger/console.cpp
@@ -132,7 +132,7 @@ bool TwinEConsole::doToggleClipRendering(int argc, const char **argv) {
 }
 
 bool TwinEConsole::doToggleSceneryView(int argc, const char **argv) {
-	TOGGLE_DEBUG(_engine->_redraw->_inSceneryView, "scenery view\n")
+	TOGGLE_DEBUG(_engine->_redraw->_flagMCGA, "scenery view\n")
 	return true;
 }
 
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 48e834920f3..bbe3d3cc60b 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -332,7 +332,6 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
 		return;
 	}
 
-	_engine->exitSceneryView();
 	_engine->_interface->unsetClip();
 	_engine->_screens->clearScreen();
 
@@ -510,12 +509,9 @@ void Holomap::drawListPos(int calpha, int cbeta, int cgamma, bool pos) {
 }
 
 void Holomap::holoMap() {
-	ScopedEngineFreeze freeze(_engine);
-
 	const int32 alphaLightTmp = _engine->_scene->_alphaLight;
 	const int32 betaLightTmp = _engine->_scene->_betaLight;
 
-	_engine->exitSceneryView();
 	_engine->_gameState->init3DGame();
 
 	_engine->_screens->fadeToBlack(_engine->_screens->_paletteRGBA);
diff --git a/engines/twine/input.h b/engines/twine/input.h
index 285ef80affe..bd088ca43e7 100644
--- a/engines/twine/input.h
+++ b/engines/twine/input.h
@@ -73,6 +73,7 @@ enum TwinEActionType {
 	OpenHolomap,
 	InventoryMenu,
 	SpecialAction,
+	SceneryZoom,
 	Escape,
 
 	UIEnter,
diff --git a/engines/twine/menu/menu.cpp b/engines/twine/menu/menu.cpp
index 82d92e3b554..03b9c271cba 100644
--- a/engines/twine/menu/menu.cpp
+++ b/engines/twine/menu/menu.cpp
@@ -1166,7 +1166,7 @@ void Menu::drawBehaviourMenu(int32 left, int32 top, int32 angle) {
 }
 
 void Menu::processBehaviourMenu(bool behaviourMenu) {
-	_engine->exitSceneryView();
+	_engine->extInitSvga();
 	if (_engine->_actor->_heroBehaviour == HeroBehaviourType::kProtoPack) {
 		_engine->_sound->stopSamples();
 		_engine->_actor->setBehaviour(HeroBehaviourType::kNormal);
diff --git a/engines/twine/metaengine.cpp b/engines/twine/metaengine.cpp
index a987274f14c..bfcdc77590a 100644
--- a/engines/twine/metaengine.cpp
+++ b/engines/twine/metaengine.cpp
@@ -429,6 +429,10 @@ Common::KeymapArray TwinEMetaEngine::initKeymaps(const char *target) const {
 		act->addDefaultInputMapping("JOY_LEFT_SHOULDER");
 		gameKeyMap->addAction(act);
 
+		act = new Action("SCENERYZOOM", _("Scenery Zoom"));
+		act->setCustomEngineActionEvent(TwinEActionType::SceneryZoom);
+		gameKeyMap->addAction(act);
+
 		act = new Action("ESCAPE", _("Escape"));
 		act->setCustomEngineActionEvent(TwinEActionType::Escape);
 		act->addDefaultInputMapping("ESCAPE");
diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 189df4ce6ee..b5cfb049c5a 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -269,7 +269,7 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool flagflip) {
 				drawList[drawListPos].offset = 1;
 				drawListPos++;
 			}
-			if (_inSceneryView && a == _engine->_scene->_currentlyFollowedActor) {
+			if (_flagMCGA && a == _engine->_scene->_currentlyFollowedActor) {
 				_sceneryViewX = projPos.x;
 				_sceneryViewY = projPos.y;
 			}
@@ -872,7 +872,7 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // AffScene
 		_engine->_screens->_fadePalette = false;
 	}
 
-	if (_inSceneryView) {
+	if (_flagMCGA) {
 		zoomScreenScale();
 	}
 }
diff --git a/engines/twine/renderer/redraw.h b/engines/twine/renderer/redraw.h
index e9726ae0eb7..5e6caf011c5 100644
--- a/engines/twine/renderer/redraw.h
+++ b/engines/twine/renderer/redraw.h
@@ -136,7 +136,7 @@ private:
 public:
 	Redraw(TwinEEngine *engine);
 
-	bool _inSceneryView = false; // FlagMCGA
+	bool _flagMCGA = false;
 
 	/** Request background redraw */
 	bool _firstTime = false;
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index a2c824b7416..26f4800d731 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -324,7 +324,7 @@ void GameState::doFoundObj(InventoryItems item) {
 	ScopedEngineFreeze freeze(_engine);
 	_engine->_grid->centerOnActor(_engine->_scene->_sceneHero);
 
-	_engine->exitSceneryView();
+	_engine->extInitSvga();
 	// Hide hero in scene
 	_engine->_scene->_sceneHero->_staticFlags.bIsHidden = 1;
 	_engine->_redraw->redrawEngineActions(true);
@@ -498,7 +498,7 @@ void GameState::processGameChoices(TextId choiceIdx) {
 void GameState::processGameoverAnimation() {
 	const int32 tmpLbaTime = _engine->timerRef;
 
-	_engine->exitSceneryView();
+	_engine->testRestoreModeSVGA(false);
 	// workaround to fix hero redraw after drowning
 	_engine->_scene->_sceneHero->_staticFlags.bIsHidden = 1;
 	_engine->_redraw->redrawEngineActions(true);
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index b1246b6d269..e7640045211 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -551,6 +551,7 @@ void Scene::changeScene() {
 	}
 
 	if (_holomapTrajectory != -1) {
+		_engine->testRestoreModeSVGA(false);
 		_engine->_holomap->drawHolomapTrajectory(_holomapTrajectory);
 		_holomapTrajectory = -1;
 	}
@@ -772,7 +773,7 @@ void Scene::checkZoneSce(int32 actorIdx) {
 			case ZoneType::kText:
 				if (IS_HERO(actorIdx) && _engine->_movements->shouldExecuteAction()) {
 					ScopedEngineFreeze scopedFreeze(_engine);
-					_engine->exitSceneryView();
+					_engine->testRestoreModeSVGA(true);
 					_engine->_text->setFontCrossColor(zone->infoData.DisplayText.textColor);
 					_talkingActor = actorIdx;
 					_engine->_text->drawTextProgressive((TextId)zone->num);
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index 2e79d6fa839..beb8c18ef1b 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -910,6 +910,7 @@ int32 ScriptLife::lMESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::MESSAGE(%i)", (int)textIdx);
 
 	ScopedEngineFreeze scopedFreeze(engine);
+	engine->testRestoreModeSVGA(true);
 	if (engine->_text->_showDialogueBubble) {
 		engine->_redraw->drawBubble(ctx.actorIdx);
 	}
@@ -1197,6 +1198,7 @@ int32 ScriptLife::lMESSAGE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::MESSAGE_OBJ(%i, %i)", (int)otherActorIdx, (int)textIdx);
 
 	ScopedEngineFreeze scopedFreeze(engine);
+	engine->testRestoreModeSVGA(true);
 	if (engine->_text->_showDialogueBubble) {
 		engine->_redraw->drawBubble(otherActorIdx);
 	}
@@ -1227,6 +1229,8 @@ int32 ScriptLife::lFOUND_OBJECT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const InventoryItems item = (InventoryItems)ctx.stream.readByte();
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::FOUND_OBJECT(%i)", (int)item);
 
+	ScopedEngineFreeze scopedFreeze(engine);
+	engine->testRestoreModeSVGA(true);
 	engine->_gameState->doFoundObj(item);
 	engine->_redraw->redrawEngineActions(true);
 
@@ -1400,14 +1404,14 @@ int32 ScriptLife::lZOOM(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int zoomScreen = ctx.stream.readByte();
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::ZOOM(%i)", zoomScreen);
 
-	if (zoomScreen && !engine->_redraw->_inSceneryView && engine->_cfgfile.SceZoom) {
+	if (zoomScreen && !engine->_redraw->_flagMCGA && engine->_cfgfile.SceZoom) {
 		engine->_screens->fadeToBlack(engine->_screens->_mainPaletteRGBA);
-		engine->initSceneryView();
+		engine->extInitMcga();
 		engine->_screens->setBackPal();
 		engine->_screens->_fadePalette = true;
-	} else if (!zoomScreen && engine->_redraw->_inSceneryView) {
+	} else if (!zoomScreen && engine->_redraw->_flagMCGA) {
 		engine->_screens->fadeToBlack(engine->_screens->_mainPaletteRGBA);
-		engine->exitSceneryView();
+		engine->extInitSvga();
 		engine->_screens->setBackPal();
 		engine->_screens->_fadePalette = true;
 		engine->_redraw->_firstTime = true;
@@ -1573,6 +1577,7 @@ int32 ScriptLife::lASK_CHOICE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::ASK_CHOICE(%i)", (int)choiceIdx);
 
 	ScopedEngineFreeze scopedFreeze(engine);
+	engine->testRestoreModeSVGA(true);
 	if (engine->_text->_showDialogueBubble) {
 		engine->_redraw->drawBubble(ctx.actorIdx);
 	}
@@ -1593,6 +1598,7 @@ int32 ScriptLife::lBIG_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::BIG_MESSAGE(%i)", (int)textIdx);
 
 	ScopedEngineFreeze scopedFreeze(engine);
+	engine->testRestoreModeSVGA(true);
 	engine->_text->bigWinDial();
 	if (engine->_text->_showDialogueBubble) {
 		engine->_redraw->drawBubble(ctx.actorIdx);
@@ -1855,7 +1861,7 @@ int32 ScriptLife::lASK_CHOICE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::ASK_CHOICE_OBJ(%i, %i)", (int)otherActorIdx, (int)choiceIdx);
 
 	ScopedEngineFreeze freeze(engine);
-	engine->exitSceneryView();
+	engine->testRestoreModeSVGA(true);
 	if (engine->_text->_showDialogueBubble) {
 		engine->_redraw->drawBubble(otherActorIdx);
 	}
@@ -1894,6 +1900,7 @@ int32 ScriptLife::lSET_NORMAL_PAL(TwinEEngine *engine, LifeScriptContext &ctx) {
 int32 ScriptLife::lMESSAGE_SENDELL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::MESSAGE_SENDELL()");
 	ScopedEngineFreeze scoped(engine);
+	engine->testRestoreModeSVGA(true);
 	engine->_screens->fadeToBlack(engine->_screens->_paletteRGBA);
 	engine->_screens->loadImage(TwineImage(Resources::HQR_RESS_FILE, 25, 26));
 	engine->_text->bigWinDial();
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 8d7a151fe48..d0f9df4e5ac 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -752,7 +752,7 @@ bool Text::displayText(TextId index, bool showText, bool playVox, bool loop) {
 }
 
 bool Text::drawTextProgressive(TextId index, bool playVox, bool loop) { // Dial
-	_engine->exitSceneryView();
+	_engine->extInitSvga();
 	_engine->_interface->memoClip();
 	_engine->_interface->unsetClip();
 	_engine->saveFrontBuffer();
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index a565a87b01c..079389b093c 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -606,12 +606,21 @@ void TwinEEngine::playIntro() {
 	}
 }
 
-void TwinEEngine::initSceneryView() {
-	_redraw->_inSceneryView = true;
+void TwinEEngine::extInitMcga() {
+	_redraw->_flagMCGA = true;
 }
 
-void TwinEEngine::exitSceneryView() {
-	_redraw->_inSceneryView = false;
+void TwinEEngine::extInitSvga() {
+	_redraw->_flagMCGA = false;
+}
+
+void TwinEEngine::testRestoreModeSVGA(bool redraw) {
+	if (_redraw->_flagMCGA) {
+		extInitSvga();
+		if (redraw) {
+			_redraw->redrawEngineActions(redraw);
+		}
+	}
 }
 
 void TwinEEngine::initAll() {
@@ -625,7 +634,7 @@ void TwinEEngine::initAll() {
 
 	_resources->initResources();
 
-	exitSceneryView();
+	extInitSvga();
 
 	_screens->clearScreen();
 
@@ -700,7 +709,7 @@ void TwinEEngine::processBonusList() {
 
 void TwinEEngine::processInventoryAction() {
 	ScopedEngineFreeze scoped(this);
-	exitSceneryView();
+	extInitSvga();
 	_menu->processInventoryMenu();
 
 	switch (_loopInventoryItem) {
@@ -801,7 +810,7 @@ int32 TwinEEngine::toSeconds(int x) const {
 
 void TwinEEngine::processOptionsMenu() {
 	ScopedEngineFreeze scoped(this);
-	exitSceneryView();
+	extInitSvga();
 	_sound->pauseSamples();
 	_menu->inGameOptionsMenu();
 	_scene->playSceneMusic();
@@ -848,7 +857,7 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
 		// Process give up menu - Press ESC
 		if (_input->toggleAbortAction() && _scene->_sceneHero->_lifePoint > 0 && _scene->_sceneHero->_body != -1 && !_scene->_sceneHero->_staticFlags.bIsHidden) {
 			ScopedEngineFreeze scopedFreeze(this);
-			exitSceneryView();
+			extInitSvga();
 			const int giveUp = _menu->giveupMenu();
 			if (giveUp == kQuitEngine) {
 				return false;
@@ -899,6 +908,7 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
 				_actor->_heroBehaviour = HeroBehaviourType::kDiscrete;
 			}
 			ScopedEngineFreeze scopedFreeze(this);
+			testRestoreModeSVGA(true);
 			_menu->processBehaviourMenu(behaviourMenu);
 			_redraw->redrawEngineActions(true);
 		}
@@ -926,6 +936,8 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
 
 		// Draw holomap
 		if (_input->toggleActionIfActive(TwinEActionType::OpenHolomap) && _gameState->hasItem(InventoryItems::kiHolomap) && !_gameState->inventoryDisabled()) {
+			ScopedEngineFreeze freeze(this);
+			testRestoreModeSVGA(true);
 			_holomap->holoMap();
 			_screens->_fadePalette = true;
 			_redraw->redrawEngineActions(true);
@@ -936,7 +948,7 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
 			ScopedEngineFreeze scopedFreeze(this, true);
 			const char *PauseString = "Pause";
 			_text->setFontColor(COLOR_WHITE);
-			if (_redraw->_inSceneryView) {
+			if (_redraw->_flagMCGA) {
 				_text->drawText(_redraw->_sceneryViewX + 5, _redraw->_sceneryViewY, PauseString);
 				_redraw->zoomScreenScale();
 			} else {
@@ -954,6 +966,15 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
 			} while (!_input->toggleActionIfActive(TwinEActionType::Pause));
 			_redraw->redrawEngineActions(true);
 		}
+
+		if (_input->toggleActionIfActive(TwinEActionType::SceneryZoom)) {
+			_redraw->_flagMCGA ^= true;
+			if (_redraw->_flagMCGA) {
+				extInitMcga();
+			} else {
+				extInitSvga();
+			}
+		}
 	}
 
 	_stepFalling = _loopMovePtr.getRealValueFromTime(timerRef);
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 2eb4778f374..39cf33f5277 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -301,7 +301,7 @@ public:
 	ConfigFile _cfgfile;
 
 	int32 _frameCounter = 0;
-	SceneLoopState _sceneLoopState = SceneLoopState::ReturnToMenu;
+	SceneLoopState _sceneLoopState = SceneLoopState::ReturnToMenu; // FlagTheEnd
 	int32 timerRef = 0;
 
 	int32 _loopInventoryItem = 0;
@@ -329,8 +329,9 @@ public:
 	Common::Rect centerOnScreen(int32 w, int32 h) const;
 	Common::Rect centerOnScreenX(int32 w, int32 y, int32 h) const;
 
-	void initSceneryView();
-	void exitSceneryView();
+	void extInitMcga();
+	void extInitSvga();
+	void testRestoreModeSVGA(bool redraw);
 
 	void queueMovie(const char *filename);
 




More information about the Scummvm-git-logs mailing list