Skip to content

Commit

Permalink
MOHAWK: Riven: Make sure to update the cursor when entering a card
Browse files Browse the repository at this point in the history
  • Loading branch information
bgK committed Aug 5, 2017
1 parent e5869ec commit 51a342b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion engines/mohawk/riven.cpp
Expand Up @@ -412,7 +412,7 @@ void MohawkEngine_Riven::changeToCard(uint16 dest) {
_card->enter(true);

// Now we need to redraw the cursor if necessary and handle mouse over scripts
_stack->onMouseMove(_stack->getMousePosition());
_stack->queueMouseCursorRefresh();

// Finally, install any hardcoded timer
_stack->installCardTimer();
Expand Down
10 changes: 10 additions & 0 deletions engines/mohawk/riven_stack.cpp
Expand Up @@ -40,6 +40,7 @@ RivenStack::RivenStack(MohawkEngine_Riven *vm, uint16 id) :
_vm(vm),
_id(id),
_mouseIsDown(false),
_shouldRefreshMouseCursor(false),
_keyPressed(Common::KEYCODE_INVALID) {
removeTimer();

Expand Down Expand Up @@ -275,6 +276,10 @@ void RivenStack::mouseForceUp() {
_mouseIsDown = false;
}

void RivenStack::queueMouseCursorRefresh() {
_shouldRefreshMouseCursor = true;
}

void RivenStack::onFrame() {
if (!_vm->getCard() || _vm->_scriptMan->hasQueuedScripts()) {
return;
Expand All @@ -284,6 +289,11 @@ void RivenStack::onFrame() {

_vm->_gfx->updateEffects();

if (_shouldRefreshMouseCursor) {
_vm->getCard()->onMouseMove(getMousePosition());
_shouldRefreshMouseCursor = false;
}

RivenScriptPtr script(new RivenScript());
if (_mouseIsDown) {
script += _vm->getCard()->onMouseDragUpdate();
Expand Down
8 changes: 8 additions & 0 deletions engines/mohawk/riven_stack.h
Expand Up @@ -129,6 +129,13 @@ class RivenStack {
/** Handle a mouse move event */
void onMouseMove(const Common::Point &mouse);

/**
* The mouse cursor needs to be refreshed on the next interactive frame
*
* Even if the mouse didn't move.
*/
void queueMouseCursorRefresh();

/** Frame update handler */
void onFrame();

Expand Down Expand Up @@ -208,6 +215,7 @@ class RivenStack {
bool _mouseIsDown;
Common::Point _mousePosition;
Common::Point _mouseDragStartPosition;
bool _shouldRefreshMouseCursor;

// Timer
Common::SharedPtr<TimerProc> _timerProc;
Expand Down

0 comments on commit 51a342b

Please sign in to comment.