[Scummvm-git-logs] scummvm master -> 900b86ff7f2e5d18577ec467ac1edf484ac1aa56
dreammaster
paulfgilbert at gmail.com
Tue Apr 21 03:24:00 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3b6b0bfb9a ULTIMA4: Disable commands that aren't available in dungeons
be1d255d0c ULTIMA4: Added interact to keymapper
900b86ff7f ULTIMA4: Switch mouse area button handlers to use keymapper actions
Commit: 3b6b0bfb9a2e20e1a29a08995650dd72e83bb812
https://github.com/scummvm/scummvm/commit/3b6b0bfb9a2e20e1a29a08995650dd72e83bb812
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-20T20:18:52-07:00
Commit Message:
ULTIMA4: Disable commands that aren't available in dungeons
Changed paths:
engines/ultima/ultima4/controllers/game_controller.cpp
engines/ultima/ultima4/core/debugger.cpp
diff --git a/engines/ultima/ultima4/controllers/game_controller.cpp b/engines/ultima/ultima4/controllers/game_controller.cpp
index 13a9b95a86..916164bfd1 100644
--- a/engines/ultima/ultima4/controllers/game_controller.cpp
+++ b/engines/ultima/ultima4/controllers/game_controller.cpp
@@ -414,9 +414,6 @@ bool GameController::keyPressed(int key) {
if (key == U4_ENTER) key = 's';
}
- if ((g_context->_location->_context & CTX_DUNGEON) && strchr("abefjlotxy", key))
- g_screen->screenMessage("%cNot here!%c\n", FG_GREY, FG_WHITE);
-
if (valid && endTurn) {
if (eventHandler->getController() == g_game)
g_context->_location->_turnCompleter->finishTurn();
diff --git a/engines/ultima/ultima4/core/debugger.cpp b/engines/ultima/ultima4/core/debugger.cpp
index 4228f0bbc0..eb4cda5fbf 100644
--- a/engines/ultima/ultima4/core/debugger.cpp
+++ b/engines/ultima/ultima4/core/debugger.cpp
@@ -148,6 +148,24 @@ void Debugger::printN(const char *fmt, ...) {
}
bool Debugger::handleCommand(int argc, const char **argv, bool &keepRunning) {
+ static const char *DUNGEON_DISALLOWED[] = {
+ "attack", "board", "enter", "fire", "jimmy", "locate",
+ "open", "talk", "exit", "yell", nullptr
+ };
+
+ if (g_context && (g_context->_location->_context & CTX_DUNGEON)) {
+ Common::String method = argv[0];
+
+ for (const char *const *mth = DUNGEON_DISALLOWED; *mth; ++mth) {
+ if (method.equalsIgnoreCase(*mth)) {
+ print("%cNot here!%c", FG_GREY, FG_WHITE);
+ g_game->finishTurn();
+ keepRunning = false;
+ return true;
+ }
+ }
+ }
+
bool result = Shared::Debugger::handleCommand(argc, argv, keepRunning);
if (result) {
Commit: be1d255d0cf1ed8fbbde1209f6032b5bbceea8fb
https://github.com/scummvm/scummvm/commit/be1d255d0cf1ed8fbbde1209f6032b5bbceea8fb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-20T20:18:53-07:00
Commit Message:
ULTIMA4: Added interact to keymapper
Changed paths:
engines/ultima/ultima4/controllers/game_controller.cpp
engines/ultima/ultima4/core/debugger.cpp
engines/ultima/ultima4/core/debugger.h
engines/ultima/ultima4/meta_engine.cpp
engines/ultima/ultima4/meta_engine.h
diff --git a/engines/ultima/ultima4/controllers/game_controller.cpp b/engines/ultima/ultima4/controllers/game_controller.cpp
index 916164bfd1..8c53cde832 100644
--- a/engines/ultima/ultima4/controllers/game_controller.cpp
+++ b/engines/ultima/ultima4/controllers/game_controller.cpp
@@ -340,89 +340,10 @@ void GameController::keybinder(KeybindingAction action) {
}
bool GameController::keyPressed(int key) {
- bool valid = true;
- int endTurn = 1;
- Object *obj;
- MapTile *tile;
-
- /* Translate context-sensitive action key into a useful command */
- if (key == U4_ENTER && settings._enhancements && settings._enhancementsOptions._smartEnterKey) {
- /* Attempt to guess based on the character's surroundings etc, what
- action they want */
-
- /* Do they want to board something? */
- if (g_context->_transportContext == TRANSPORT_FOOT) {
- obj = g_context->_location->_map->objectAt(g_context->_location->_coords);
- if (obj && (obj->getTile().getTileType()->isShip() ||
- obj->getTile().getTileType()->isHorse() ||
- obj->getTile().getTileType()->isBalloon()))
- key = 'b';
- }
- /* Klimb/Descend Balloon */
- else if (g_context->_transportContext == TRANSPORT_BALLOON) {
- if (g_context->_party->isFlying())
- key = 'd';
- else {
-#ifdef IOS
- U4IOS::IOSSuperButtonHelper superHelper;
- key = ReadChoiceController::get("xk \033\n");
-#else
- key = 'k';
-#endif
- }
- }
- /* X-it transport */
- else key = 'x';
-
- /* Klimb? */
- if ((g_context->_location->_map->portalAt(g_context->_location->_coords, ACTION_KLIMB) != nullptr))
- key = 'k';
- /* Descend? */
- else if ((g_context->_location->_map->portalAt(g_context->_location->_coords, ACTION_DESCEND) != nullptr))
- key = 'd';
-
- if (g_context->_location->_context == CTX_DUNGEON) {
- Dungeon *dungeon = static_cast<Dungeon *>(g_context->_location->_map);
- bool up = dungeon->ladderUpAt(g_context->_location->_coords);
- bool down = dungeon->ladderDownAt(g_context->_location->_coords);
- if (up && down) {
-#ifdef IOS
- U4IOS::IOSClimbHelper climbHelper;
- key = ReadChoiceController::get("kd \033\n");
-#else
- key = 'k'; // This is consistent with the previous code. Ideally, I would have a UI here as well.
-#endif
- } else if (up) {
- key = 'k';
- } else {
- key = 'd';
- }
- }
-
- /* Enter? */
- if (g_context->_location->_map->portalAt(g_context->_location->_coords, ACTION_ENTER) != nullptr)
- key = 'e';
-
- /* Get Chest? */
- if (!g_context->_party->isFlying()) {
- tile = g_context->_location->_map->tileAt(g_context->_location->_coords, WITH_GROUND_OBJECTS);
-
- if (tile->getTileType()->isChest()) key = 'g';
- }
-
- /* None of these? Default to search */
- if (key == U4_ENTER) key = 's';
- }
-
- if (valid && endTurn) {
- if (eventHandler->getController() == g_game)
- g_context->_location->_turnCompleter->finishTurn();
- } else if (!endTurn) {
- /* if our turn did not end, then manually redraw the text prompt */
- g_screen->screenPrompt();
- }
+ // Manually redraw the text prompt
+ g_screen->screenPrompt();
- return valid || KeyHandler::defaultHandler(key, nullptr);
+ return KeyHandler::defaultHandler(key, nullptr);
}
void GameController::initMoons() {
diff --git a/engines/ultima/ultima4/core/debugger.cpp b/engines/ultima/ultima4/core/debugger.cpp
index eb4cda5fbf..6e456e9a51 100644
--- a/engines/ultima/ultima4/core/debugger.cpp
+++ b/engines/ultima/ultima4/core/debugger.cpp
@@ -64,6 +64,7 @@ Debugger::Debugger() : Shared::Debugger() {
registerCmd("get", WRAP_METHOD(Debugger, cmdGet));
registerCmd("hole", WRAP_METHOD(Debugger, cmdHoleUp));
registerCmd("ignite", WRAP_METHOD(Debugger, cmdIgnite));
+ registerCmd("interact", WRAP_METHOD(Debugger, cmdInteract));
registerCmd("jimmy", WRAP_METHOD(Debugger, cmdJimmy));
registerCmd("locate", WRAP_METHOD(Debugger, cmdLocate));
registerCmd("mix", WRAP_METHOD(Debugger, cmdMixReagents));
@@ -637,6 +638,77 @@ bool Debugger::cmdIgnite(int argc, const char **argv) {
return isDebuggerActive();
}
+bool Debugger::cmdInteract(int argc, const char **argv) {
+ if (!settings._enhancements || !settings._enhancementsOptions._smartEnterKey)
+ return isDebuggerActive();
+
+ // Attempt to guess based on the character's surroundings
+
+ if (g_context->_transportContext == TRANSPORT_FOOT) {
+ // When on foot, check for boarding
+ Object *obj = g_context->_location->_map->objectAt(g_context->_location->_coords);
+ if (obj && (obj->getTile().getTileType()->isShip() ||
+ obj->getTile().getTileType()->isHorse() ||
+ obj->getTile().getTileType()->isBalloon()))
+ return cmdBoard(argc, argv);
+ } else if (g_context->_transportContext == TRANSPORT_BALLOON) {
+ // Climb/Descend Balloon
+ if (g_context->_party->isFlying()) {
+ return cmdDescend(argc, argv);
+ } else {
+#ifdef IOS
+ U4IOS::IOSSuperButtonHelper superHelper;
+ key = ReadChoiceController::get("xk \033\n");
+#else
+ return cmdClimb(argc, argv);
+#endif
+ }
+ } else {
+ // For all other transports, exit the transport
+ return cmdExit(argc, argv);
+ }
+
+ if ((g_context->_location->_map->portalAt(g_context->_location->_coords, ACTION_KLIMB) != nullptr))
+ // Climb
+ return cmdClimb(argc, argv);
+ else if ((g_context->_location->_map->portalAt(g_context->_location->_coords, ACTION_DESCEND) != nullptr))
+ // Descend
+ return cmdDescend(argc, argv);
+
+ if (g_context->_location->_context == CTX_DUNGEON) {
+ Dungeon *dungeon = static_cast<Dungeon *>(g_context->_location->_map);
+ bool up = dungeon->ladderUpAt(g_context->_location->_coords);
+ bool down = dungeon->ladderDownAt(g_context->_location->_coords);
+ if (up && down) {
+#ifdef IOS
+ U4IOS::IOSClimbHelper climbHelper;
+ key = ReadChoiceController::get("kd \033\n");
+#else
+ return cmdClimb(argc, argv);
+#endif
+ } else if (up) {
+ return cmdClimb(argc, argv);
+ } else {
+ return cmdDescend(argc, argv);
+ }
+ }
+
+ if (g_context->_location->_map->portalAt(g_context->_location->_coords, ACTION_ENTER) != nullptr)
+ // Enter?
+ return cmdEnter(argc, argv);
+
+ if (!g_context->_party->isFlying()) {
+ // Get Chest?
+ MapTile *tile = g_context->_location->_map->tileAt(g_context->_location->_coords, WITH_GROUND_OBJECTS);
+
+ if (tile->getTileType()->isChest())
+ return cmdGet(argc, argv);
+ }
+
+ // Otherwise default to search
+ return cmdSearch(argc, argv);
+}
+
bool Debugger::cmdJimmy(int argc, const char **argv) {
printN("Jimmy: ");
Direction dir = gameGetDirection();
diff --git a/engines/ultima/ultima4/core/debugger.h b/engines/ultima/ultima4/core/debugger.h
index 3bc7ec6c21..8c818ce01a 100644
--- a/engines/ultima/ultima4/core/debugger.h
+++ b/engines/ultima/ultima4/core/debugger.h
@@ -138,6 +138,11 @@ private:
*/
bool cmdIgnite(int argc, const char **argv);
+ /**
+ * Generic interaction
+ */
+ bool cmdInteract(int argc, const char **argv);
+
/**
* Jimmy lock
*/
diff --git a/engines/ultima/ultima4/meta_engine.cpp b/engines/ultima/ultima4/meta_engine.cpp
index 27052f52b5..423872cc80 100644
--- a/engines/ultima/ultima4/meta_engine.cpp
+++ b/engines/ultima/ultima4/meta_engine.cpp
@@ -39,6 +39,7 @@ struct KeybindingRecord {
};
static const KeybindingRecord KEYS[] = {
+ { KEYBIND_INTERACT, "INTERACT", "Interact", "interact", "RETURN", nullptr },
{ KEYBIND_UP, "UP", "Up", "move up", "UP", nullptr },
{ KEYBIND_DOWN, "DOWN", "Down", "move down", "DOWN", nullptr },
{ KEYBIND_LEFT, "LEFT", "Left", "move left", "LEFT", nullptr },
diff --git a/engines/ultima/ultima4/meta_engine.h b/engines/ultima/ultima4/meta_engine.h
index 512a7b5092..f493691337 100644
--- a/engines/ultima/ultima4/meta_engine.h
+++ b/engines/ultima/ultima4/meta_engine.h
@@ -38,7 +38,7 @@ enum KeybindingAction {
KEYBIND_QUIT_SAVE, KEYBIND_SPEED_UP, KEYBIND_SPEED_DOWN,
KEYBIND_SPEED_NORMAL, KEYBIND_READY_WEAPON, KEYBIND_SEARCH,
KEYBIND_STATS, KEYBIND_TALK, KEYBIND_TOGGLE_MUSIC, KEYBIND_USE,
- KEYBIND_WEAR, KEYBIND_YELL,
+ KEYBIND_WEAR, KEYBIND_YELL, KEYBIND_INTERACT,
KEYBIND_PARTY0, KEYBIND_PARTY1, KEYBIND_PARTY2, KEYBIND_PARTY3,
KEYBIND_PARTY4, KEYBIND_PARTY5, KEYBIND_PARTY6, KEYBIND_PARTY7,
Commit: 900b86ff7f2e5d18577ec467ac1edf484ac1aa56
https://github.com/scummvm/scummvm/commit/900b86ff7f2e5d18577ec467ac1edf484ac1aa56
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-20T20:18:53-07:00
Commit Message:
ULTIMA4: Switch mouse area button handlers to use keymapper actions
Changed paths:
engines/ultima/ultima4/controllers/game_controller.cpp
engines/ultima/ultima4/events/event.cpp
engines/ultima/ultima4/events/event.h
diff --git a/engines/ultima/ultima4/controllers/game_controller.cpp b/engines/ultima/ultima4/controllers/game_controller.cpp
index 8c53cde832..a6ee13bebf 100644
--- a/engines/ultima/ultima4/controllers/game_controller.cpp
+++ b/engines/ultima/ultima4/controllers/game_controller.cpp
@@ -48,11 +48,11 @@ using namespace std;
GameController *g_game = nullptr;
static const MouseArea MOUSE_AREAS[] = {
- { 3, { { 8, 8 }, { 8, 184 }, { 96, 96 } }, MC_WEST, { U4_ENTER, 0, U4_LEFT } },
- { 3, { { 8, 8 }, { 184, 8 }, { 96, 96 } }, MC_NORTH, { U4_ENTER, 0, U4_UP } },
- { 3, { { 184, 8 }, { 184, 184 }, { 96, 96 } }, MC_EAST, { U4_ENTER, 0, U4_RIGHT } },
- { 3, { { 8, 184 }, { 184, 184 }, { 96, 96 } }, MC_SOUTH, { U4_ENTER, 0, U4_DOWN } },
- { 0, { { 0, 0 }, { 0, 0 }, { 0, 0 } }, MC_NORTH, { 0, 0, 0 } }
+ { 3, { { 8, 8 }, { 8, 184 }, { 96, 96 } }, MC_WEST, { KEYBIND_INTERACT, KEYBIND_NONE, KEYBIND_LEFT } },
+ { 3, { { 8, 8 }, { 184, 8 }, { 96, 96 } }, MC_NORTH, { KEYBIND_INTERACT, KEYBIND_NONE, KEYBIND_UP } },
+ { 3, { { 184, 8 }, { 184, 184 }, { 96, 96 } }, MC_EAST, { KEYBIND_INTERACT, KEYBIND_NONE, KEYBIND_RIGHT } },
+ { 3, { { 8, 184 }, { 184, 184 }, { 96, 96 } }, MC_SOUTH, { KEYBIND_INTERACT, KEYBIND_NONE, KEYBIND_DOWN } },
+ { 0, { { 0, 0 }, { 0, 0 }, { 0, 0 } }, MC_NORTH, { KEYBIND_NONE, KEYBIND_NONE, KEYBIND_NONE } }
};
GameController::GameController() : _mapArea(BORDER_WIDTH, BORDER_HEIGHT, VIEWPORT_W, VIEWPORT_H), _paused(false), _pausedTimer(0) {
diff --git a/engines/ultima/ultima4/events/event.cpp b/engines/ultima/ultima4/events/event.cpp
index de6e1a5d40..d4d7d03f74 100644
--- a/engines/ultima/ultima4/events/event.cpp
+++ b/engines/ultima/ultima4/events/event.cpp
@@ -80,14 +80,15 @@ void EventHandler::setControllerDone(bool done) {
if (done)
controllerStopped_helper();
#endif
-} /**< Sets the controller exit flag for the event handler */
+}
-bool EventHandler::getControllerDone() {
- return _controllerDone; /**< Returns the current value of the global exit flag */
+bool EventHandler::getControllerDone() {
+ return _controllerDone;
}
void EventHandler::end() {
- _ended = true; /**< End all event processing */
+ // End all event processing
+ _ended = true;
}
TimedEventMgr *EventHandler::getTimer() {
@@ -261,9 +262,10 @@ void EventHandler::handleMouseButtonDownEvent(const Common::Event &event, Contro
return;
const MouseArea *area = eventHandler->mouseAreaForPoint(event.mouse.x, event.mouse.y);
- if (!area || area->_command[button] == 0)
+ if (!area || area->_command[button] == KEYBIND_NONE)
return;
- controller->keyPressed(area->_command[button]);
+ controller->keybinder((KeybindingAction)area->_command[button]);
+
if (updateScreen)
(*updateScreen)();
g_screen->update();
@@ -299,7 +301,7 @@ void EventHandler::handleKeyDownEvent(const Common::Event &event, Controller *co
debug(1, "key event: sym = %d, mod = %d; translated = %d",
event.kbd.keycode, event.kbd.flags, key);
- /* handle the keypress */
+ // handle the keypress
processed = controller->notifyKeyPressed(key);
if (processed) {
diff --git a/engines/ultima/ultima4/events/event.h b/engines/ultima/ultima4/events/event.h
index 51f601b4ed..405180c894 100644
--- a/engines/ultima/ultima4/events/event.h
+++ b/engines/ultima/ultima4/events/event.h
@@ -116,6 +116,10 @@ public:
static void wait_cycles(uint cycles);
static void setControllerDone(bool exit = true);
+
+ /**
+ * Returns the current value of the global exit flag
+ */
static bool getControllerDone();
static void end();
More information about the Scummvm-git-logs
mailing list