[Scummvm-cvs-logs] scummvm master -> 2a4a290d31f7efbd7f35b94930c545ebd14d236d

m-kiewitz m_kiewitz at users.sourceforge.net
Mon Feb 1 19:08:56 CET 2016


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:
2a4a290d31 AGI: change how menus are triggered on Non-PC


Commit: 2a4a290d31f7efbd7f35b94930c545ebd14d236d
    https://github.com/scummvm/scummvm/commit/2a4a290d31f7efbd7f35b94930c545ebd14d236d
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2016-02-01T19:08:22+01:00

Commit Message:
AGI: change how menus are triggered on Non-PC

Changed paths:
    engines/agi/agi.h
    engines/agi/cycle.cpp
    engines/agi/detection.cpp
    engines/agi/keyboard.cpp
    engines/agi/op_cmd.cpp



diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 7d604c7..48df0ae 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -343,7 +343,7 @@ enum {
 	VM_FLAG_LOGIC_ZERO_FIRST_TIME,
 	VM_FLAG_RESTORE_JUST_RAN,
 	VM_FLAG_STATUS_SELECTS_ITEMS,
-	VM_FLAG_MENUS_WORK,
+	VM_FLAG_MENUS_ACCESSIBLE,
 	VM_FLAG_OUTPUT_MODE,		// 15
 	VM_FLAG_AUTO_RESTART
 };
@@ -437,8 +437,6 @@ struct AgiGame {
 
 	InputMode inputMode;			/**< keyboard input mode */
 
-	uint16 specialMenuTriggerKey;	/**< key to trigger menu for platforms except PC */
-
 	int16 curLogicNr;				/**< current logic number */
 	Common::Array<ScriptPos> execStack;
 
@@ -938,8 +936,6 @@ public:
 	int doPollKeyboard();
 	void cleanKeyboard();
 
-	int16 getSpecialMenuControllerSlot();
-
 	bool handleMouseClicks(uint16 &key);
 	bool handleController(uint16 key);
 
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index dd31fee..1747452 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -195,10 +195,6 @@ int AgiEngine::mainCycle(bool onlyCheckForEvents) {
 		pollTimer();
 	}
 
-	if (_menu->delayedExecuteActive()) {
-		_menu->execute();
-	}
-
 	key = doPollKeyboard();
 
 	// In AGI Mouse emulation mode we must update the mouse-related
@@ -308,6 +304,10 @@ int AgiEngine::mainCycle(bool onlyCheckForEvents) {
 		}
 	}
 
+	if (_menu->delayedExecuteActive()) {
+		_menu->execute();
+	}
+
 	if (!onlyCheckForEvents) {
 		if (_game.msgBoxTicks > 0)
 			_game.msgBoxTicks--;
@@ -408,23 +408,6 @@ int AgiEngine::playGame() {
 int AgiEngine::runGame() {
 	int ec = errOK;
 
-	// figure out the expected menu trigger for the current platform
-	// need to trigger the menu via mouse and via keyboard for platforms except PC
-	if (!(getFeatures() & GF_ESCPAUSE)) {
-		switch (getPlatform()) {
-		case Common::kPlatformAmiga:
-		case Common::kPlatformApple2GS:
-			_game.specialMenuTriggerKey = AGI_MENU_TRIGGER_APPLE2GS;
-			break;
-		case Common::kPlatformAtariST:
-			_game.specialMenuTriggerKey = AGI_MENU_TRIGGER_ATARIST;
-			break;
-		// Macintosh games seem to use ESC key just like PC versions do
-		default:
-			break;
-		}
-	}
-
 	// Execute the game
 	do {
 		debugC(2, kDebugLevelMain, "game loop");
diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp
index 17e1eef..b541390 100644
--- a/engines/agi/detection.cpp
+++ b/engines/agi/detection.cpp
@@ -571,7 +571,7 @@ namespace Agi {
 
 bool AgiBase::canLoadGameStateCurrently() {
 	if (!(getGameType() == GType_PreAGI)) {
-		if (getFlag(VM_FLAG_MENUS_WORK)) {
+		if (getFlag(VM_FLAG_MENUS_ACCESSIBLE)) {
 			if (!_noSaveLoadAllowed) {
 				if (!cycleInnerLoopIsActive()) {
 					// We can't allow to restore a game, while inner loop is active
@@ -592,7 +592,7 @@ bool AgiBase::canSaveGameStateCurrently() {
 		return true;
 
 	if (!(getGameType() == GType_PreAGI)) {
-		if (getFlag(VM_FLAG_MENUS_WORK)) {
+		if (getFlag(VM_FLAG_MENUS_ACCESSIBLE)) {
 			if (!_noSaveLoadAllowed) {
 				if (!cycleInnerLoopIsActive()) {
 					if (promptIsEnabled()) {
diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp
index 07aec98..5a2e165 100644
--- a/engines/agi/keyboard.cpp
+++ b/engines/agi/keyboard.cpp
@@ -280,37 +280,6 @@ int AgiEngine::doPollKeyboard() {
 	return key;
 }
 
-int16 AgiEngine::getSpecialMenuControllerSlot() {
-	int16 controllerSlotESC = -1;
-	int16 controllerSlotSpecial = -1;
-
-	for (uint16 curMapping = 0; curMapping < MAX_CONTROLLER_KEYMAPPINGS; curMapping++) {
-		if (_game.controllerKeyMapping[curMapping].keycode == _game.specialMenuTriggerKey) {
-			if (controllerSlotSpecial < 0) {
-				controllerSlotSpecial = _game.controllerKeyMapping[curMapping].controllerSlot;
-			}
-		}
-		if (_game.controllerKeyMapping[curMapping].keycode == AGI_MENU_TRIGGER_PC) {
-			if (controllerSlotESC < 0) {
-				controllerSlotESC = _game.controllerKeyMapping[curMapping].controllerSlot;
-			}
-		}
-	}
-	if (controllerSlotSpecial >= 0) {
-		// special menu controller slot found
-		if (controllerSlotSpecial != controllerSlotESC) {
-			// not the same as the ESC slot (is the same in Manhunter AppleIIgs, we need to replace "pause"
-			if (controllerSlotSpecial >= 10) {
-				// slot needs to be at least 10
-				// Atari ST SQ1 maps the special key, but doesn't trigger any menu with it
-				// the controller slot in this case is 8.
-				return controllerSlotSpecial;
-			}
-		}
-	}
-	return -1;
-}
-
 bool AgiEngine::handleMouseClicks(uint16 &key) {
 	// No mouse click? -> exit
 	if (key != AGI_MOUSE_BUTTON_LEFT)
@@ -322,7 +291,7 @@ bool AgiEngine::handleMouseClicks(uint16 &key) {
 	displayLineRect.moveTo(0, statusRow * FONT_DISPLAY_HEIGHT);
 
 	if (displayLineRect.contains(_mouse.pos)) {
-	    if (getFlag(VM_FLAG_MENUS_WORK) && _menu->isAvailable()) {
+	    if (getFlag(VM_FLAG_MENUS_ACCESSIBLE) && _menu->isAvailable()) {
 			warning("click on status line -> menu TODO");
 			// TODO: menu
 			// This should be done in a better way as in simulate ESC key
@@ -406,28 +375,31 @@ bool AgiEngine::handleController(uint16 key) {
 		// Escape pressed, user probably wants to trigger the menu
 		// For PC, just passing ASCII code for ESC will normally trigger a controller
 		//  and the scripts will then trigger the menu
-		// For other platforms, ESC was handled by platforms to trigger "pause game" instead
-		// We need to change ESC to a platform specific code to make it work properly.
-		//
-		// There are exceptions though. Mixed Up Mother Goose on AppleIIgs for example actually sets up
-		//  ESC for pause only. That's why we also check, if the key is actually mapped to a controller.
-		// For this special case, we actually replace the pause function with a menu trigger.
-		// Replacing "pause" all the time wouldn't work out as well, becaue games like KQ1 on Apple IIgs
-		//  actually disable "pause" when ego has been killed, which means we wouldn't be able to access
-		//  the menu anymore in that case.
-		if (_menu->isAvailable()) {
-			// menu is actually available
-			if (_game.specialMenuTriggerKey) {
-				int16 specialMenuControllerSlot = getSpecialMenuControllerSlot();
-
-				if (specialMenuControllerSlot >= 0) {
-					// menu trigger found, trigger it now
-					_game.controllerOccured[specialMenuControllerSlot] = true;
-					return true;
-				}
+		switch (getPlatform()) {
+		case Common::kPlatformAmiga:
+		case Common::kPlatformApple2GS:
+		case Common::kPlatformAtariST:
+			// For these platforms, the button ESC normally triggered "pause"
+			// But users could at the same time trigger the menu by clicking on the status line
+			// We check, if menu is currently available and supposed to be accessible.
+			// If yes, we do a delayed trigger now, otherwise we continue processing the key just like normal.
+			//
+			// This is probably the solution with the highest compatibility.
+			// Several games also look for special keys see AGI_MENU_TRIGGER_*
+			// And then there's also Mixed Up Mother Goose, which actually hooks the ESC key for the regular menu
+			//
+			// We risk in here of course, that we let the user access the menu, when it shouldn't be possible.
+			// I'm not 100% sure if those other interpreters really only check VM_FLAG_MENUS_ACCESSIBLE
+			// Needs further investigation.
+			if (getFlag(VM_FLAG_MENUS_ACCESSIBLE) && _menu->isAvailable()) {
+				// menu is supposed to be accessible and is also available
+				_menu->delayedExecute();
+				return true;
 			}
-			// Otherwise go on and look for the ESC controller
+		default:
+			break;
 		}
+		// Otherwise go on and look for the ESC controller
 	}
 
 
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index c3aec4d..13b3cc3 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -729,7 +729,7 @@ void cmdStopSound(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
 }
 
 void cmdMenuInput(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
-	if (vm->getFlag(VM_FLAG_MENUS_WORK)) {
+	if (vm->getFlag(VM_FLAG_MENUS_ACCESSIBLE)) {
 		vm->_menu->delayedExecute();
 	}
 }
@@ -1679,42 +1679,12 @@ void cmdSetGameID(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
 }
 
 void cmdPause(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
-	bool skipPause = false;
-
-	// We check in here, if a special key was specified to trigger menus.
-	// If that's the case, normally triggering the menu should be handled inside handleController()
-	// For the rare cases, where this approach doesn't work because the trigger is not mapped to a controller,
-	//  we trigger the menu in here.
-	//
-	// for further study read the comments for handleController()
-	//
-	// This is needed for at least Mixed Up Mother Goose for Apple IIgs.
-	if (state->specialMenuTriggerKey) {
-		if (vm->_menu->isAvailable()) {
-			// Pulldown-menu is actually available (was submitted)
-			skipPause = true;
-
-			// Check, if special trigger key is currently NOT mapped.
-			if (vm->getSpecialMenuControllerSlot() < 0) {
-				// menu trigger is not mapped, trigger menu
-				vm->_menu->delayedExecute();
-			} else {
-				// menu trigger is mapped, do not replace "pause"
-				skipPause = false;
-			}
-		} else {
-			warning("menu is not available, doing regular pause game instead");
-		}
-	}
-
-	if (!skipPause) {
-		// Show pause message box
-		vm->inGameTimerPause();
+	// Show pause message box
+	vm->inGameTimerPause();
 
-		state->_vm->_systemUI->pauseDialog();
+	state->_vm->_systemUI->pauseDialog();
 
-		vm->inGameTimerResume();
-	}
+	vm->inGameTimerResume();
 }
 
 void cmdSetMenu(AgiGame *state, AgiEngine *vm, uint8 *parameter) {






More information about the Scummvm-git-logs mailing list