ULTIMA4: Shift mouse button -> interact to GameController

This commit is contained in:
Paul Gilbert 2020-05-02 18:16:47 -07:00
parent 09b715379b
commit bfe395bbcf
5 changed files with 37 additions and 11 deletions

View File

@ -42,6 +42,11 @@ bool Controller::notifyKeyPressed(int key) {
return processed;
}
bool Controller::notifyMousePress(const Common::Point &mousePos) {
return mousePressed(mousePos);
}
int Controller::getTimerInterval() {
return _timerInterval;
}

View File

@ -50,6 +50,12 @@ public:
*/
bool notifyKeyPressed(int key);
/**
* The event manager will call this method to notify that
* the left button was clicked
*/
bool notifyMousePress(const Common::Point &mousePos);
int getTimerInterval();
/**
@ -72,6 +78,13 @@ public:
return false;
}
/**
* Mouse button was pressed
*/
virtual bool mousePressed(const Common::Point &mousePos) {
return false;
}
/**
* Handles keybinder actions
*/

View File

@ -343,11 +343,15 @@ void GameController::keybinder(KeybindingAction action) {
MetaEngine::executeAction(action);
}
bool GameController::keyPressed(int key) {
// Manually redraw the text prompt
g_screen->screenPrompt();
bool GameController::mousePressed(const Common::Point &mousePos) {
const MouseArea *area = eventHandler->mouseAreaForPoint(mousePos.x, mousePos.y);
return KeyHandler::defaultHandler(key, nullptr);
if (area) {
keybinder(KEYBIND_INTERACT);
return true;
}
return false;
}
void GameController::initMoons() {

View File

@ -122,10 +122,9 @@ public:
void keybinder(KeybindingAction action) override;
/**
* The main key handler for the game. Interpretes each key as a
* command - 'a' for attack, 't' for talk, etc.
* Mouse button was pressed
*/
bool keyPressed(int key) override;
bool mousePressed(const Common::Point &mousePos) override;
/**
* This function is called every quarter second.

View File

@ -271,10 +271,15 @@ void EventHandler::handleMouseButtonDownEvent(const Common::Event &event, Contro
return;
if (event.type == Common::EVENT_LBUTTONDOWN) {
const MouseArea *area = eventHandler->mouseAreaForPoint(event.mouse.x, event.mouse.y);
if (!area)
return;
controller->keybinder(KEYBIND_INTERACT);
// handle the keypress
bool processed = controller->notifyMousePress(event.mouse);
if (processed) {
if (updateScreen)
(*updateScreen)();
g_screen->update();
}
} else if (event.type == Common::EVENT_RBUTTONDOWN) {
_isRightButtonDown = true;
handleMouseMotionEvent(event);