[Scummvm-git-logs] scummvm master -> 454e8af18d31b1ee4965850fdadb4bd638829b63

bluegr noreply at scummvm.org
Tue Apr 29 00:32:46 UTC 2025


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
584cd0d250 EFH: Split save and load action handling into separate functions
454e8af18d EFH: Add an initial simplistic keymapper for saving and loading


Commit: 584cd0d250f19db791017a86e1b0583ec72bdaed
    https://github.com/scummvm/scummvm/commit/584cd0d250f19db791017a86e1b0583ec72bdaed
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-04-29T03:30:08+03:00

Commit Message:
EFH: Split save and load action handling into separate functions

Changed paths:
    engines/efh/efh.cpp
    engines/efh/efh.h


diff --git a/engines/efh/efh.cpp b/engines/efh/efh.cpp
index 39811efb1ed..266ca7200f1 100644
--- a/engines/efh/efh.cpp
+++ b/engines/efh/efh.cpp
@@ -164,47 +164,12 @@ Common::Error EfhEngine::run() {
 				_redrawNeededFl = true;
 			}
 			break;
-		case Common::KEYCODE_F5: { // Original is using CTRL-S, which is mapped to F5 in utils
-			for (uint counter = 0; counter < 2; ++counter) {
-				clearBottomTextZone(0);
-				displayCenteredString("Are You Sure You Want To Save?", 24, 296, 160);
-				if (counter == 0)
-					displayFctFullScreen();
-			}
-			Common::KeyCode input = waitForKey();
-			if (input == Common::KEYCODE_y) {
-				displayMenuAnswerString("-> Yes <-", 24, 296, 169);
-				getInput(2);
-				saveGameDialog();
-			} else {
-				displayMenuAnswerString("-> No!!! <-", 24, 296, 169);
-				getInput(2);
-			}
-			clearBottomTextZone_2(0);
-			displayLowStatusScreen(true);
-
-			}
+		case Common::KEYCODE_F5: // Original is using CTRL-S, which is mapped to F5 in utils
+			handleActionSave();
+			break;
+		case Common::KEYCODE_F7: // Original is using CTRL-L, which is mapped to F7 in utils
+			handleActionLoad();
 			break;
-		case Common::KEYCODE_F7: { // Original is using CTRL-L, which is mapped to F7 in utils
-			for (uint counter = 0; counter < 2; ++counter) {
-				clearBottomTextZone(0);
-				displayCenteredString("Are You Sure You Want To Load?", 24, 296, 160);
-				if (counter == 0)
-					displayFctFullScreen();
-			}
-			Common::KeyCode input = waitForKey();
-			if (input == Common::KEYCODE_y) {
-				displayMenuAnswerString("-> Yes <-", 24, 296, 169);
-				getInput(2);
-				loadGameDialog();
-			} else {
-				displayMenuAnswerString("-> No!!! <-", 24, 296, 169);
-				getInput(2);
-			}
-			clearBottomTextZone_2(0);
-			displayLowStatusScreen(true);
-
-		} break;
 
 		// debug cases to test sound
 		case Common::KEYCODE_4:
@@ -294,6 +259,46 @@ Common::Error EfhEngine::run() {
 	return Common::kNoError;
 }
 
+void EfhEngine::handleActionSave() {
+	for (uint counter = 0; counter < 2; ++counter) {
+		clearBottomTextZone(0);
+		displayCenteredString("Are You Sure You Want To Save?", 24, 296, 160);
+		if (counter == 0)
+			displayFctFullScreen();
+	}
+	Common::KeyCode input = waitForKey();
+	if (input == Common::KEYCODE_y) {
+		displayMenuAnswerString("-> Yes <-", 24, 296, 169);
+		getInput(2);
+		saveGameDialog();
+	} else {
+		displayMenuAnswerString("-> No!!! <-", 24, 296, 169);
+		getInput(2);
+	}
+	clearBottomTextZone_2(0);
+	displayLowStatusScreen(true);
+}
+
+void EfhEngine::handleActionLoad() {
+	for (uint counter = 0; counter < 2; ++counter) {
+		clearBottomTextZone(0);
+		displayCenteredString("Are You Sure You Want To Load?", 24, 296, 160);
+		if (counter == 0)
+			displayFctFullScreen();
+	}
+	Common::KeyCode input = waitForKey();
+	if (input == Common::KEYCODE_y) {
+		displayMenuAnswerString("-> Yes <-", 24, 296, 169);
+		getInput(2);
+		loadGameDialog();
+	} else {
+		displayMenuAnswerString("-> No!!! <-", 24, 296, 169);
+		getInput(2);
+	}
+	clearBottomTextZone_2(0);
+	displayLowStatusScreen(true);
+}
+
 void EfhEngine::initialize() {
 	_rnd = new Common::RandomSource("Hell");
 	_rnd->setSeed(g_system->getMillis());   // Kick random number generator
diff --git a/engines/efh/efh.h b/engines/efh/efh.h
index 73743785303..b7c13ae2d3d 100644
--- a/engines/efh/efh.h
+++ b/engines/efh/efh.h
@@ -519,6 +519,10 @@ private:
 	uint32 ROR(uint32 val, uint8 shiftVal);
 	Common::String getArticle(int pronoun);
 
+	// Actions
+	void handleActionSave();
+	void handleActionLoad();
+
 	uint8 _videoMode;
 	uint8 _bufferCharBM[128];
 	int8 *_vgaLineBuffer[200];


Commit: 454e8af18d31b1ee4965850fdadb4bd638829b63
    https://github.com/scummvm/scummvm/commit/454e8af18d31b1ee4965850fdadb4bd638829b63
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-04-29T03:30:09+03:00

Commit Message:
EFH: Add an initial simplistic keymapper for saving and loading

This engine relies a lot on event key codes internally, so this
implementation can be used as a base to allow us to start adding
actions to the keymapper without breaking existing event handling logic

Changed paths:
    engines/efh/efh.cpp
    engines/efh/efh.h
    engines/efh/metaengine.cpp
    engines/efh/utils.cpp


diff --git a/engines/efh/efh.cpp b/engines/efh/efh.cpp
index 266ca7200f1..faf142a5ba8 100644
--- a/engines/efh/efh.cpp
+++ b/engines/efh/efh.cpp
@@ -96,6 +96,19 @@ Common::Error EfhEngine::run() {
 		Common::Event event;
 		Common::KeyCode retVal = getLastCharAfterAnimCount(4);
 
+		switch (_customAction) {
+		case kActionSave:
+			handleActionSave();
+			break;
+		case kActionLoad:
+			handleActionLoad();
+			break;
+		default:
+			break;
+		}
+
+		_customAction = kActionNone;
+
 		switch (retVal) {
 		case Common::KEYCODE_DOWN:
 		case Common::KEYCODE_KP2:
@@ -164,12 +177,6 @@ Common::Error EfhEngine::run() {
 				_redrawNeededFl = true;
 			}
 			break;
-		case Common::KEYCODE_F5: // Original is using CTRL-S, which is mapped to F5 in utils
-			handleActionSave();
-			break;
-		case Common::KEYCODE_F7: // Original is using CTRL-L, which is mapped to F7 in utils
-			handleActionLoad();
-			break;
 
 		// debug cases to test sound
 		case Common::KEYCODE_4:
diff --git a/engines/efh/efh.h b/engines/efh/efh.h
index b7c13ae2d3d..0860617ec97 100644
--- a/engines/efh/efh.h
+++ b/engines/efh/efh.h
@@ -257,6 +257,13 @@ struct TeamMonster {
 	void init();
 };
 
+enum EFHAction {
+	kActionNone,
+	kActionExit,
+	kActionSave,
+	kActionLoad
+};
+
 class EfhEngine : public Engine {
 public:
 	EfhEngine(OSystem *syst, const ADGameDescription *gd);
@@ -294,6 +301,7 @@ private:
 	Common::Platform _platform;
 	int _loadSaveSlot;
 	bool _saveAuthorized;
+	Common::CustomEventType _customAction = kActionNone;
 
 	void initialize();
 	void playIntro();
diff --git a/engines/efh/metaengine.cpp b/engines/efh/metaengine.cpp
index e240a199481..ae3cb367040 100644
--- a/engines/efh/metaengine.cpp
+++ b/engines/efh/metaengine.cpp
@@ -20,9 +20,13 @@
  */
 
 #include "engines/advancedDetector.h"
+#include "backends/keymapper/action.h"
+#include "backends/keymapper/keymapper.h"
+#include "backends/keymapper/standard-actions.h"
 #include "common/system.h"
 #include "common/savefile.h"
 #include "common/textconsole.h"
+#include "common/translation.h"
 #include "graphics/thumbnail.h"
 #include "graphics/surface.h"
 
@@ -70,6 +74,7 @@ public:
 	SaveStateList listSaves(const char *target) const override;
 	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
 	bool removeSaveState(const char *target, int slot) const override;
+	Common::KeymapArray initKeymaps(const char *target) const override;
 };
 
 Common::Error EfhMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const {
@@ -192,6 +197,40 @@ bool EfhMetaEngine::removeSaveState(const char *target, int slot) const {
 	return g_system->getSavefileManager()->removeSavefile(fileName);
 }
 
+Common::KeymapArray EfhMetaEngine::initKeymaps(const char *target) const {
+	using namespace Common;
+
+	Keymap *keymap = new Keymap(Keymap::kKeymapTypeGame, "efh", _("Game keymappings"));
+
+	Action *act;
+
+	act = new Action(kStandardActionLeftClick, _("Left click"));
+	act->setLeftClickEvent();
+	act->addDefaultInputMapping("MOUSE_LEFT");
+	act->addDefaultInputMapping("JOY_A");
+	keymap->addAction(act);
+
+	act = new Action(kStandardActionRightClick, _("Right click"));
+	act->setRightClickEvent();
+	act->addDefaultInputMapping("MOUSE_RIGHT");
+	act->addDefaultInputMapping("JOY_B");
+	keymap->addAction(act);
+
+	act = new Action(kStandardActionSave, _("Save game"));
+	act->setCustomEngineActionEvent(kActionSave);
+	act->addDefaultInputMapping("F5");
+	act->addDefaultInputMapping("JOY_LEFT_SHOULDER");
+	keymap->addAction(act);
+
+	act = new Action(kStandardActionLoad, _("Load game"));
+	act->setCustomEngineActionEvent(kActionLoad);
+	act->addDefaultInputMapping("F7");
+	act->addDefaultInputMapping("JOY_RIGHT_SHOULDER");
+	keymap->addAction(act);
+
+	return Keymap::arrayOf(keymap);
+}
+
 } // End of namespace Efh
 
 #if PLUGIN_ENABLED_DYNAMIC(EFH)
diff --git a/engines/efh/utils.cpp b/engines/efh/utils.cpp
index cb7a71f83a9..9b1eb3586d3 100644
--- a/engines/efh/utils.cpp
+++ b/engines/efh/utils.cpp
@@ -200,12 +200,6 @@ Common::KeyCode EfhEngine::getKeyCode(const Common::Event &event) {
 		retVal = Common::KEYCODE_INVALID;
 	else  if (event.kbd.flags & Common::KBD_CTRL) {
 		switch (retVal) {
-		case Common::KEYCODE_l:
-			retVal = Common::KEYCODE_F7;
-			break;
-		case Common::KEYCODE_s:
-			retVal = Common::KEYCODE_F5;
-			break;
 		case Common::KEYCODE_x:
 		case Common::KEYCODE_q:
 			_shouldQuit = true;
@@ -262,12 +256,15 @@ Common::KeyCode EfhEngine::handleAndMapInput(bool animFl) {
 	Common::KeyCode retVal = Common::KEYCODE_INVALID;
 
 	uint32 lastMs = _system->getMillis();
-	while (retVal == Common::KEYCODE_INVALID && !shouldQuitGame()) {
+	while (retVal == Common::KEYCODE_INVALID && _customAction == kActionNone && !shouldQuitGame()) {
 		_system->getEventManager()->pollEvent(event);
 
 		if (event.type == Common::EVENT_KEYUP)
 			retVal = getKeyCode(event);
 
+		if (event.type == Common::EVENT_CUSTOM_ENGINE_ACTION_START)
+			_customAction = event.customType;
+
 		if (animFl) {
 			_system->delayMillis(20);
 			uint32 newMs = _system->getMillis();




More information about the Scummvm-git-logs mailing list