MYST3: Implement dragging using the gamepad
Used in the Xbox version menus
This commit is contained in:
parent
402517fbee
commit
ea3fcdd96f
3 changed files with 57 additions and 32 deletions
|
@ -1886,14 +1886,19 @@ void Script::runScriptWhileDragging(Context &c, const Opcode &cmd) {
|
||||||
|
|
||||||
_vm->_cursor->changeCursor(2);
|
_vm->_cursor->changeCursor(2);
|
||||||
|
|
||||||
bool mousePressed = true;
|
bool dragWithDirectionKeys = _vm->_state->hasVarDragWithDirectionKeys()
|
||||||
|
&& _vm->_state->getDragWithDirectionKeys();
|
||||||
|
|
||||||
|
bool dragging = true;
|
||||||
do {
|
do {
|
||||||
mousePressed = _vm->getEventManager()->getButtonState() & Common::EventManager::LBUTTON;
|
dragging = _vm->getEventManager()->getButtonState() & Common::EventManager::LBUTTON;
|
||||||
_vm->_state->setDragEnded(!mousePressed);
|
dragging |= _vm->_state->hasVarGamePadActionPressed() && _vm->_state->getGamePadActionPressed();
|
||||||
|
_vm->_state->setDragEnded(!dragging);
|
||||||
|
|
||||||
_vm->processInput(true);
|
_vm->processInput(true);
|
||||||
_vm->drawFrame();
|
_vm->drawFrame();
|
||||||
|
|
||||||
|
if (!dragWithDirectionKeys) {
|
||||||
// Distance between the mouse and the lever
|
// Distance between the mouse and the lever
|
||||||
Common::Point mouse = _vm->_cursor->getPosition();
|
Common::Point mouse = _vm->_cursor->getPosition();
|
||||||
int16 distanceX = mouse.x - leverWidth / 2 - _vm->_state->getVar(cmd.args[0]);
|
int16 distanceX = mouse.x - leverWidth / 2 - _vm->_state->getVar(cmd.args[0]);
|
||||||
|
@ -1929,11 +1934,29 @@ void Script::runScriptWhileDragging(Context &c, const Opcode &cmd) {
|
||||||
// Set the lever position to the best position
|
// Set the lever position to the best position
|
||||||
_vm->_state->setDragPositionFound(true);
|
_vm->_state->setDragPositionFound(true);
|
||||||
_vm->_state->setVar(cmd.args[4], bestPosition);
|
_vm->_state->setVar(cmd.args[4], bestPosition);
|
||||||
|
} else {
|
||||||
|
uint16 previousPosition = _vm->_state->getVar(cmd.args[4]);
|
||||||
|
uint16 position = previousPosition;
|
||||||
|
|
||||||
|
if (_vm->_state->getGamePadLeftPressed()) {
|
||||||
|
position--;
|
||||||
|
} else if (_vm->_state->getGamePadRightPressed()) {
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
|
||||||
|
position = CLIP<int16>(position, 0, maxLeverPosition);
|
||||||
|
_vm->_state->setVar(cmd.args[4], position);
|
||||||
|
_vm->_state->setDragLeverPositionChanged(position != previousPosition);
|
||||||
|
}
|
||||||
|
|
||||||
_vm->runScriptsFromNode(script);
|
_vm->runScriptsFromNode(script);
|
||||||
_vm->processInput(true);
|
_vm->processInput(true);
|
||||||
_vm->drawFrame();
|
_vm->drawFrame();
|
||||||
} while (mousePressed);
|
} while (dragging);
|
||||||
|
|
||||||
|
if (dragWithDirectionKeys) {
|
||||||
|
_vm->_state->setDragWithDirectionKeys(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Script::chooseNextNode(Context &c, const Opcode &cmd) {
|
void Script::chooseNextNode(Context &c, const Opcode &cmd) {
|
||||||
|
|
|
@ -373,6 +373,7 @@ GameState::GameState(Myst3Engine *vm):
|
||||||
VAR(1434, GamePadRightPressed, false)
|
VAR(1434, GamePadRightPressed, false)
|
||||||
VAR(1435, GamePadCancelPressed, false)
|
VAR(1435, GamePadCancelPressed, false)
|
||||||
|
|
||||||
|
VAR(1437, DragWithDirectionKeys, false)
|
||||||
VAR(1438, MenuAttractCountDown, false)
|
VAR(1438, MenuAttractCountDown, false)
|
||||||
VAR(1439, ShieldEffectActive, false)
|
VAR(1439, ShieldEffectActive, false)
|
||||||
|
|
||||||
|
|
|
@ -297,6 +297,7 @@ public:
|
||||||
DECLARE_VAR(GamePadRightPressed)
|
DECLARE_VAR(GamePadRightPressed)
|
||||||
DECLARE_VAR(GamePadCancelPressed)
|
DECLARE_VAR(GamePadCancelPressed)
|
||||||
|
|
||||||
|
DECLARE_VAR(DragWithDirectionKeys)
|
||||||
DECLARE_VAR(MenuSavesAvailable)
|
DECLARE_VAR(MenuSavesAvailable)
|
||||||
DECLARE_VAR(MenuSelectedSave)
|
DECLARE_VAR(MenuSelectedSave)
|
||||||
DECLARE_VAR(MenuAttractCountDown)
|
DECLARE_VAR(MenuAttractCountDown)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue