[Scummvm-git-logs] scummvm master -> c41efeac49066071d700b597e621187a251401dc
bluegr
noreply at scummvm.org
Wed Aug 28 16:16:42 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:
c41efeac49 STARK: Add keymapper support
Commit: c41efeac49066071d700b597e621187a251401dc
https://github.com/scummvm/scummvm/commit/c41efeac49066071d700b597e621187a251401dc
Author: NabeelShabbir (i210443 at nu.edu.pk)
Date: 2024-08-28T19:16:39+03:00
Commit Message:
STARK: Add keymapper support
Changed paths:
engines/stark/metaengine.cpp
engines/stark/services/userinterface.cpp
engines/stark/services/userinterface.h
engines/stark/stark.cpp
engines/stark/stark.h
engines/stark/ui/dialogbox.cpp
engines/stark/ui/dialogbox.h
diff --git a/engines/stark/metaengine.cpp b/engines/stark/metaengine.cpp
index 9504e811b7a..a6077170dc4 100644
--- a/engines/stark/metaengine.cpp
+++ b/engines/stark/metaengine.cpp
@@ -24,6 +24,10 @@
#include "engines/stark/stark.h"
#include "engines/stark/services/stateprovider.h"
+#include "backends/keymapper/action.h"
+#include "backends/keymapper/keymapper.h"
+#include "backends/keymapper/standard-actions.h"
+
#include "common/savefile.h"
#include "common/system.h"
#include "common/translation.h"
@@ -74,6 +78,8 @@ public:
return "stark";
}
+ Common::KeymapArray initKeymaps(const char *target) const override;
+
const ADExtraGuiOptionsMap *getAdvancedExtraGuiOptions() const override {
return optionsList;
}
@@ -171,6 +177,175 @@ public:
}
};
+Common::KeymapArray StarkMetaEngine::initKeymaps(const char *target) const {
+ using namespace Common;
+ using namespace Stark;
+
+ Keymap *engineKeyMap = new Keymap(Keymap::kKeymapTypeGame, "stark-default", _("Default keymapppings"));
+ Keymap *gameKeyMap = new Keymap(Keymap::kKeymapTypeGame, "game-shortcuts", _("Game keymappings"));
+
+ Action *act;
+
+ act = new Action(kStandardActionLeftClick, _("Left click"));
+ act->setLeftClickEvent();
+ act->addDefaultInputMapping("MOUSE_LEFT");
+ act->addDefaultInputMapping("JOY_A");
+ engineKeyMap->addAction(act);
+
+ act = new Action(kStandardActionRightClick, _("Right click"));
+ act->setRightClickEvent();
+ act->addDefaultInputMapping("MOUSE_RIGHT");
+ act->addDefaultInputMapping("JOY_B");
+ engineKeyMap->addAction(act);
+
+ // I18N: Opens in-game Diary
+ act = new Action("DIARYMENU", _("Diary menu"));
+ act->setCustomEngineActionEvent(kActionDiaryMenu);
+ act->addDefaultInputMapping("F1");
+ act->addDefaultInputMapping("JOY_X");
+ gameKeyMap->addAction(act);
+
+ act = new Action("SAVEGAME", _("Save game"));
+ act->setCustomEngineActionEvent(kActionSaveGame);
+ act->addDefaultInputMapping("F2");
+ gameKeyMap->addAction(act);
+
+ act = new Action("LOADGAME", _("Load game"));
+ act->setCustomEngineActionEvent(kActionLoadGame);
+ act->addDefaultInputMapping("F3");
+ gameKeyMap->addAction(act);
+
+ // I18N: Opens in-game conversation log
+ act = new Action("CONVOLOG", _("Conversation log"));
+ act->setCustomEngineActionEvent(kActionConversationLog);
+ act->addDefaultInputMapping("F4");
+ gameKeyMap->addAction(act);
+
+ // I18N: Opens in-game Diary
+ act = new Action("APRILSDIARY", _("April's diary (initially disabled)"));
+ act->setCustomEngineActionEvent(kActionAprilsDiary);
+ act->addDefaultInputMapping("F5");
+ gameKeyMap->addAction(act);
+
+ act = new Action("VIDREPLAY", _("Video replay"));
+ act->setCustomEngineActionEvent(kActionVideoReplay);
+ act->addDefaultInputMapping("F6");
+ gameKeyMap->addAction(act);
+
+ act = new Action("GAMESETTINGS", _("Game settings"));
+ act->setCustomEngineActionEvent(kActionGameSettings);
+ act->addDefaultInputMapping("F7");
+ gameKeyMap->addAction(act);
+
+ act = new Action("SAVESCRNSHOT", _("Save screenshot"));
+ act->setCustomEngineActionEvent(kActionSaveScreenshot);
+ act->addDefaultInputMapping("F8");
+ gameKeyMap->addAction(act);
+
+ act = new Action("TOGGLESUBS", _("Toggle subtitles"));
+ act->setCustomEngineActionEvent(kActionToggleSubtitles);
+ act->addDefaultInputMapping("F9");
+ gameKeyMap->addAction(act);
+
+ act = new Action("QUITTOMENU", _("Quit to menu"));
+ act->setCustomEngineActionEvent(kActionQuitToMenu);
+ act->addDefaultInputMapping("F10");
+ gameKeyMap->addAction(act);
+
+ act = new Action("CYCLEBACK", _("Cycle back through inventory cursor items"));
+ act->setCustomEngineActionEvent(kActionCycleForwardInventory);
+ act->addDefaultInputMapping("a");
+ act->addDefaultInputMapping("JOY_LEFT_TRIGGER");
+ gameKeyMap->addAction(act);
+
+ act = new Action("CYCLEFORWARD", _("Cycle forward through inventory cursor items"));
+ act->setCustomEngineActionEvent(kActionCycleBackInventory);
+ act->addDefaultInputMapping("s");
+ act->addDefaultInputMapping("JOY_RIGHT_TRIGGER");
+ gameKeyMap->addAction(act);
+
+ act = new Action("INVENTORY", _("Inventory"));
+ act->setCustomEngineActionEvent(kActionInventory);
+ act->addDefaultInputMapping("i");
+ act->addDefaultInputMapping("JOY_Y");
+ gameKeyMap->addAction(act);
+
+ // I18N: A popup on screen shows shows the exits
+ act = new Action("DISPLAYEXITS", _("Display all exits on current location"));
+ act->setCustomEngineActionEvent(kActionDisplayExits);
+ act->addDefaultInputMapping("x");
+ act->addDefaultInputMapping("JOY_RIGHT_STICK");
+ gameKeyMap->addAction(act);
+
+ act = new Action("EXITGAME", _("Exit game"));
+ act->setCustomEngineActionEvent(kActionExitGame);
+ act->addDefaultInputMapping("A+x");
+ act->addDefaultInputMapping("A+q");
+ gameKeyMap->addAction(act);
+
+ act = new Action("PAUSE", _("Pause game"));
+ act->setCustomEngineActionEvent(kActionPause);
+ act->addDefaultInputMapping("p");
+ act->addDefaultInputMapping("JOY_LEFT_STICK");
+ gameKeyMap->addAction(act);
+
+ act = new Action("SCROLLUPINV", _("Scroll up in inventory"));
+ act->setCustomEngineActionEvent(kActionInventoryScrollUp);
+ act->addDefaultInputMapping("PAGEUP");
+ act->addDefaultInputMapping("UP");
+ act->addDefaultInputMapping("JOY_LEFT_SHOULDER");
+ gameKeyMap->addAction(act);
+
+ act = new Action("SCROLLDOWNINV", _("Scroll down in inventory"));
+ act->setCustomEngineActionEvent(kActionInventoryScrollDown);
+ act->addDefaultInputMapping("PAGEDOWN");
+ act->addDefaultInputMapping("DOWN");
+ act->addDefaultInputMapping("JOY_RIGHT_SHOULDER");
+ gameKeyMap->addAction(act);
+
+ act = new Action("SCROLLUPDILOG", _("Scroll up in your dialogues"));
+ act->setCustomEngineActionEvent(kActionDialogueScrollUp);
+ act->addDefaultInputMapping("PAGEUP");
+ act->addDefaultInputMapping("JOY_LEFT_SHOULDER");
+ gameKeyMap->addAction(act);
+
+ act = new Action("SCROLLDOWNDILOG", _("Scroll down in your dialogues"));
+ act->setCustomEngineActionEvent(kActionDialogueScrollDown);
+ act->addDefaultInputMapping("PAGEDOWN");
+ act->addDefaultInputMapping("JOY_RIGHT_SHOULDER");
+ gameKeyMap->addAction(act);
+
+ act = new Action("SCROLLUPINVPREVDILOG", _("go to next dialogue"));
+ act->setCustomEngineActionEvent(kActionNextDialogue);
+ act->addDefaultInputMapping("DOWN");
+ gameKeyMap->addAction(act);
+
+ act = new Action("SCROLLDOWNINVNEXTDILOG", _("go to previous dialogues"));
+ act->setCustomEngineActionEvent(kActionPrevDialogue);
+ act->addDefaultInputMapping("UP");
+ gameKeyMap->addAction(act);
+
+ act = new Action("SELECTDILOG", _("Select dialogue"));
+ act->setCustomEngineActionEvent(kActionSelectDialogue);
+ act->addDefaultInputMapping("RETURN");
+ act->addDefaultInputMapping("KP_ENTER");
+ act->addDefaultInputMapping("JOY_RIGHT");
+ gameKeyMap->addAction(act);
+
+ act = new Action("SKIP", _("Skip video sequence or dialogue"));
+ act->setCustomEngineActionEvent(kActionSkip);
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_BACK");
+ gameKeyMap->addAction(act);
+
+
+ KeymapArray keymaps(2);
+ keymaps[0] = engineKeyMap;
+ keymaps[1] = gameKeyMap;
+
+ return keymaps;
+}
+
} // End of namespace Stark
#if PLUGIN_ENABLED_DYNAMIC(STARK)
diff --git a/engines/stark/services/userinterface.cpp b/engines/stark/services/userinterface.cpp
index 448f5e2a298..136a0f3811c 100644
--- a/engines/stark/services/userinterface.cpp
+++ b/engines/stark/services/userinterface.cpp
@@ -455,71 +455,65 @@ void UserInterface::doQueuedScreenChange() {
}
}
-void UserInterface::handleKeyPress(const Common::KeyState &keyState) {
+void UserInterface::handleActions(Common::CustomEventType customType) {
if (_modalDialog->isVisible()) {
- _modalDialog->onKeyPress(keyState);
+ _modalDialog->onKeyPress(customType);
return;
}
- // TODO: Delegate keypress handling to the screens
-
- if (keyState.keycode == Common::KEYCODE_ESCAPE) {
+ if (customType == kActionSkip) {
handleEscape();
- } else if ((keyState.keycode == Common::KEYCODE_RETURN
- || keyState.keycode == Common::KEYCODE_KP_ENTER)) {
+ } else if (customType == kActionSelectDialogue) {
if (isInGameScreen()) {
_gameScreen->getDialogPanel()->selectFocusedOption();
}
- } else if (keyState.keycode == Common::KEYCODE_F1) {
+ } else if (customType == kActionDiaryMenu) {
toggleScreen(Screen::kScreenDiaryIndex);
- } else if (keyState.keycode == Common::KEYCODE_F2) {
+ } else if (customType == kActionSaveGame) {
if (isInSaveLoadMenuScreen() || g_engine->canSaveGameStateCurrently()) {
toggleScreen(Screen::kScreenSaveMenu);
}
- } else if (keyState.keycode == Common::KEYCODE_F3) {
+ } else if (customType == kActionLoadGame) {
toggleScreen(Screen::kScreenLoadMenu);
- } else if (keyState.keycode == Common::KEYCODE_F4) {
+ } else if (customType == kActionConversationLog) {
toggleScreen(Screen::kScreenDialog);
- } else if (keyState.keycode == Common::KEYCODE_F5) {
+ } else if (customType == kActionAprilsDiary) {
if (StarkDiary->isEnabled()) {
toggleScreen(Screen::kScreenDiaryPages);
}
- } else if (keyState.keycode == Common::KEYCODE_F6) {
+ } else if (customType == kActionVideoReplay) {
toggleScreen(Screen::kScreenFMVMenu);
- } else if (keyState.keycode == Common::KEYCODE_F7) {
+ } else if (customType == kActionGameSettings) {
toggleScreen(Screen::kScreenSettingsMenu);
- } else if (keyState.keycode == Common::KEYCODE_F8) {
+ } else if (customType == kActionSaveScreenshot) {
g_system->saveScreenshot();
- } else if (keyState.keycode == Common::KEYCODE_F9) {
+ } else if (customType == kActionToggleSubtitles) {
if (isInGameScreen()) {
_shouldToggleSubtitle = !_shouldToggleSubtitle;
}
- } else if (keyState.keycode == Common::KEYCODE_F10) {
+ } else if (customType == kActionQuitToMenu) {
if (isInGameScreen() || isInDiaryIndexScreen()) {
confirm(GameMessage::kQuitGamePrompt, this, &UserInterface::requestQuitToMainMenu);
}
- } else if (keyState.keycode == Common::KEYCODE_a) {
+ } else if (customType == kActionCycleForwardInventory) {
if (isInGameScreen() && isInteractive()) {
cycleInventory(false);
}
- } else if (keyState.keycode == Common::KEYCODE_s) {
+ } else if (customType == kActionCycleBackInventory) {
if (isInGameScreen() && isInteractive()) {
cycleInventory(true);
}
- } else if (keyState.keycode == Common::KEYCODE_i) {
+ } else if (customType == kActionInventory) {
if (isInGameScreen() && isInteractive()) {
inventoryOpen(!isInventoryOpen());
}
- } else if (keyState.keycode == Common::KEYCODE_x
- && !keyState.hasFlags(Common::KBD_ALT)) {
+ } else if (customType == kActionDisplayExits) {
if (isInGameScreen() && isInteractive()) {
_gameScreen->getGameWindow()->toggleExitDisplay();
}
- } else if ((keyState.keycode == Common::KEYCODE_x
- || keyState.keycode == Common::KEYCODE_q)
- && keyState.hasFlags(Common::KBD_ALT)) {
+ } else if (customType == kActionExitGame) {
confirm(GameMessage::kQuitPrompt, this, &UserInterface::notifyShouldExit);
- } else if (keyState.keycode == Common::KEYCODE_p) {
+ } else if (customType == kActionPause) {
if (isInGameScreen()) {
if (g_engine->isPaused()) {
_gamePauseToken.clear();
@@ -528,39 +522,33 @@ void UserInterface::handleKeyPress(const Common::KeyState &keyState) {
debug("The game is paused");
}
}
- } else if (keyState.keycode == Common::KEYCODE_PAGEUP) {
- if (isInGameScreen()) {
- if (isInventoryOpen()) {
- _gameScreen->getInventoryWindow()->scrollUp();
- } else {
- _gameScreen->getDialogPanel()->scrollUp();
- }
- }
- } else if (keyState.keycode == Common::KEYCODE_UP) {
- if (isInGameScreen()) {
- if (isInventoryOpen()) {
+ }
+
+ if (isInGameScreen()) {
+ if (isInventoryOpen()) {
+ if (customType == kActionInventoryScrollUp) {
_gameScreen->getInventoryWindow()->scrollUp();
- } else {
- _gameScreen->getDialogPanel()->focusPrevOption();
- }
- }
- } else if (keyState.keycode == Common::KEYCODE_PAGEDOWN) {
- if (isInGameScreen()) {
- if (isInventoryOpen()) {
+ } else if (customType == kActionInventoryScrollDown) {
_gameScreen->getInventoryWindow()->scrollDown();
- } else {
- _gameScreen->getDialogPanel()->scrollDown();
}
- }
- } else if (keyState.keycode == Common::KEYCODE_DOWN) {
- if (isInGameScreen()) {
- if (isInventoryOpen()) {
- _gameScreen->getInventoryWindow()->scrollDown();
- } else {
+ } else {
+ if (customType == kActionDialogueScrollUp) {
+ _gameScreen->getDialogPanel()->scrollUp();
+ } else if (customType == kActionDialogueScrollDown) {
+ _gameScreen->getDialogPanel()->scrollDown();
+ } else if (customType == kActionNextDialogue) {
_gameScreen->getDialogPanel()->focusNextOption();
+ } else if (customType == kActionPrevDialogue) {
+ _gameScreen->getDialogPanel()->focusPrevOption();
}
}
- } else if (keyState.keycode >= Common::KEYCODE_1 && keyState.keycode <= Common::KEYCODE_9) {
+ }
+}
+
+void UserInterface::handleKeyPress(const Common::KeyState &keyState) {
+
+ // TODO: Delegate keypress handling to the screens
+ if (keyState.keycode >= Common::KEYCODE_1 && keyState.keycode <= Common::KEYCODE_9) {
if (isInGameScreen()) {
uint index = keyState.keycode - Common::KEYCODE_1;
_gameScreen->getDialogPanel()->selectOption(index);
diff --git a/engines/stark/services/userinterface.h b/engines/stark/services/userinterface.h
index ccdd205c9e5..1a2e83f05fc 100644
--- a/engines/stark/services/userinterface.h
+++ b/engines/stark/services/userinterface.h
@@ -193,6 +193,7 @@ public:
void performToggleSubtitle();
/** Perform an action after a keypress */
+ void handleActions(Common::CustomEventType customType);
void handleKeyPress(const Common::KeyState &keyState);
private:
diff --git a/engines/stark/stark.cpp b/engines/stark/stark.cpp
index c1511b1e1d8..c5bbd459c97 100644
--- a/engines/stark/stark.cpp
+++ b/engines/stark/stark.cpp
@@ -185,24 +185,25 @@ void StarkEngine::processEvents() {
if (isPaused()) {
// Only pressing key P to resume the game is allowed when the game is paused
- if (e.type == Common::EVENT_KEYDOWN && e.kbd.keycode == Common::KEYCODE_p) {
+ if (e.type == Common::EVENT_CUSTOM_ENGINE_ACTION_START && e.customType == kActionPause) {
_gamePauseToken.clear();
}
continue;
}
- if (e.type == Common::EVENT_KEYDOWN) {
+ if (e.type == Common::EVENT_KEYDOWN || e.type == Common::EVENT_CUSTOM_ENGINE_ACTION_START) {
if (e.kbdRepeat) {
continue;
}
- if (e.kbd.keycode == Common::KEYCODE_p) {
+ if (e.customType == kActionPause) {
if (StarkUserInterface->isInGameScreen()) {
_gamePauseToken = pauseEngine();
debug("The game is paused");
}
} else {
StarkUserInterface->handleKeyPress(e.kbd);
+ StarkUserInterface->handleActions(e.customType);
}
} else if (e.type == Common::EVENT_LBUTTONUP) {
diff --git a/engines/stark/stark.h b/engines/stark/stark.h
index 887aa4fd2a8..94fdfcbfc6c 100644
--- a/engines/stark/stark.h
+++ b/engines/stark/stark.h
@@ -59,6 +59,35 @@ class Settings;
class GameChapter;
class GameMessage;
+enum STARKAction {
+ kActionNone,
+ kActionDiaryMenu,
+ kActionSaveGame,
+ kActionLoadGame,
+ kActionConversationLog,
+ kActionAprilsDiary,
+ kActionVideoReplay,
+ kActionGameSettings,
+ kActionSaveScreenshot,
+ kActionToggleSubtitles,
+ kActionQuitToMenu,
+ kActionCycleBackInventory,
+ kActionCycleForwardInventory,
+ kActionInventory,
+ kActionDisplayExits,
+ kActionExitGame,
+ kActionPause,
+ kActionInventoryScrollUp,
+ kActionInventoryScrollDown,
+ kActionDialogueScrollUp,
+ kActionDialogueScrollDown,
+ kActionPrevDialogue,
+ kActionNextDialogue,
+ kActionSelectDialogue,
+ kActionSkip
+};
+
+
class StarkEngine : public Engine {
public:
StarkEngine(OSystem *syst, const ADGameDescription *gameDesc);
diff --git a/engines/stark/ui/dialogbox.cpp b/engines/stark/ui/dialogbox.cpp
index 2f922f1fa1b..4feab1b8dac 100644
--- a/engines/stark/ui/dialogbox.cpp
+++ b/engines/stark/ui/dialogbox.cpp
@@ -199,8 +199,8 @@ void DialogBox::onClick(const Common::Point &pos) {
}
}
-void DialogBox::onKeyPress(const Common::KeyState &keyState) {
- if (keyState.keycode == Common::KEYCODE_ESCAPE) {
+void DialogBox::onKeyPress(const Common::CustomEventType customType) {
+ if (customType == kActionSkip) {
close();
}
}
diff --git a/engines/stark/ui/dialogbox.h b/engines/stark/ui/dialogbox.h
index df102e2942c..1a85c296115 100644
--- a/engines/stark/ui/dialogbox.h
+++ b/engines/stark/ui/dialogbox.h
@@ -62,7 +62,7 @@ public:
void onScreenChanged();
/** Called when a keyboard key is pressed and the dialog is active */
- void onKeyPress(const Common::KeyState &keyState);
+ void onKeyPress(const Common::CustomEventType customType);
protected:
void onRender() override;
More information about the Scummvm-git-logs
mailing list