TWINE: cleanup and more keymapper actions connected

This commit is contained in:
Martin Gerhardy 2020-10-24 13:31:56 +02:00 committed by Eugene Sandulenko
parent 235ba116fc
commit a1e43850d1
8 changed files with 16 additions and 50 deletions

View File

@ -25,6 +25,7 @@
#include "twine/collision.h"
#include "twine/gamestate.h"
#include "twine/grid.h"
#include "twine/input.h"
#include "twine/interface.h"
#include "twine/movements.h"
#include "twine/redraw.h"
@ -861,9 +862,9 @@ void Extra::processExtras() {
// if hero touch extra
if (_engine->_collision->checkExtraCollisionWithActors(extra, -1) == 0) {
// FIXME: add constant for sample index
_engine->_sound->playSample(97, 0x1000, 1, extra->x, extra->y, extra->z, -1);
_engine->_sound->playSample(97, 4096, 1, extra->x, extra->y, extra->z);
if (extra->info1 > 1 && !(_engine->loopPressedKey & 2)) {
if (extra->info1 > 1 && !_engine->_input->isActionActive(TwinEActionType::MoveBackward)) {
_engine->_renderer->projectPositionOnScreen(extra->x - _engine->_grid->cameraX, extra->y - _engine->_grid->cameraY, extra->z - _engine->_grid->cameraZ);
_engine->_redraw->addOverlay(koNumber, extra->info1, _engine->_renderer->projPosX, _engine->_renderer->projPosY, 158, koNormal, 2);
}

View File

@ -167,8 +167,6 @@ public:
int16 internalKeyCode = 0;
int16 currentKey = 0;
int16 key = 0;
int32 heroPressedKey = 0;
int32 heroPressedKey2 = 0;
int16 leftMouse = 0;
int16 rightMouse = 0;

View File

@ -447,7 +447,6 @@ int32 Menu::processMenu(int16 *menuSettings) {
_engine->_screens->loadMenuImage(false);
do {
_engine->readKeys();
_engine->_input->key = _engine->_input->pressedKey;
if (_engine->_input->toggleActionIfActive(TwinEActionType::UIDown)) {
currentButton++;
@ -972,7 +971,6 @@ void Menu::drawInventoryItems() {
}
void Menu::processInventoryMenu() {
int32 di = 1;
int32 tmpAlphaLight = _engine->_scene->alphaLight;
int32 tmpBetaLight = _engine->_scene->betaLight;
@ -1000,25 +998,9 @@ void Menu::processInventoryMenu() {
_engine->readKeys();
int32 prevSelectedItem = inventorySelectedItem;
if (!di) {
_engine->_input->key = _engine->_input->pressedKey;
_engine->loopPressedKey = _engine->_input->skippedKey;
_engine->loopCurrentKey = _engine->_input->internalKeyCode;
if (_engine->_input->key != 0 || _engine->_input->skippedKey != 0) {
di = 1;
}
} else {
_engine->loopCurrentKey = 0;
_engine->_input->key = 0;
_engine->loopPressedKey = 0;
if (!_engine->_input->pressedKey && !_engine->_input->skippedKey) {
di = 0;
}
}
if (_engine->loopCurrentKey == 1 || _engine->loopPressedKey & 0x20)
if (_engine->_input->toggleAbortAction() || _engine->_input->isActionActive(TwinEActionType::ExecuteBehaviourAction)) {
break;
}
if (_engine->_input->toggleActionIfActive(TwinEActionType::UIDown)) {
inventorySelectedItem++;
@ -1107,7 +1089,7 @@ void Menu::processInventoryMenu() {
_engine->_text->initTextBank(_engine->_text->currentTextBank + 3);
while (_engine->_input->internalKeyCode != 0 && _engine->_input->skippedKey != 0) {
while (!_engine->_input->toggleAbortAction()) {
_engine->readKeys();
_engine->_system->delayMillis(1);
_engine->flip(); // TODO: needed?

View File

@ -93,10 +93,8 @@ void MenuOptions::newGame() {
}
void MenuOptions::showCredits() {
int32 tmpShadowMode;
canShowCredits = 1;
tmpShadowMode = _engine->cfgfile.ShadowMode;
int32 tmpShadowMode = _engine->cfgfile.ShadowMode;
_engine->cfgfile.ShadowMode = 0;
_engine->_gameState->initEngineVars();
_engine->_scene->currentSceneIdx = 119;
@ -229,21 +227,6 @@ void MenuOptions::newGameMenu() {
if (_engine->gameEngineLoop()) {
showCredits();
}
_engine->_screens->copyScreen(_engine->frontVideoBuffer, _engine->workVideoBuffer);
// TODO: recheck this
do {
_engine->readKeys();
do {
_engine->readKeys();
if (_engine->shouldQuit()) {
break;
}
} while (_engine->_input->skippedKey != 0);
if (_engine->shouldQuit()) {
break;
}
} while (_engine->_input->internalKeyCode != 0);
}
}

View File

@ -279,7 +279,7 @@ void Movements::processActorMovements(int32 actorIdx) {
moveActor(actor->angle, actor->angle + tempAngle, actor->speed, &actor->move);
_engine->_input->heroPressedKey = _engine->_input->key;
heroPressedKey = _engine->_input->key;
} else {
if (!actor->staticFlags.bIsSpriteActor) {
if (actor->controlMode != kManual) {
@ -386,7 +386,7 @@ void Movements::processActorMovements(int32 actorIdx) {
heroMoved = 0; // don't break animation
}
if (_engine->_input->key != _engine->_input->heroPressedKey || _engine->loopPressedKey != _engine->_input->heroPressedKey2) {
if (_engine->_input->key != heroPressedKey || _engine->loopPressedKey != heroPressedKey2) {
if (heroMoved) {
_engine->_animations->initAnim(kStanding, 0, 255, actorIdx);
}
@ -436,8 +436,8 @@ void Movements::processActorMovements(int32 actorIdx) {
moveActor(actor->angle, actor->angle + tempAngle, actor->speed, &actor->move);
_engine->_input->heroPressedKey = _engine->_input->key;
_engine->_input->heroPressedKey2 = _engine->loopPressedKey;
heroPressedKey = _engine->_input->key;
heroPressedKey2 = _engine->loopPressedKey;
break;
case kFollow: {

View File

@ -45,6 +45,10 @@ class TwinEEngine;
class Movements {
private:
TwinEEngine *_engine;
int32 heroPressedKey = 0;
int32 heroPressedKey2 = 0;
public:
Movements(TwinEEngine *engine);
/** Hero moved */

View File

@ -339,9 +339,8 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
previousLoopPressedKey = loopPressedKey;
_input->key = _input->pressedKey;
loopPressedKey = _input->skippedKey;
loopCurrentKey = _input->internalKeyCode;
_debug->processDebug(loopCurrentKey);
_debug->processDebug(_input->internalKeyCode);
if (_menuOptions->canShowCredits != 0) {
// TODO: if current music playing != 8, than play_track(8);

View File

@ -228,7 +228,6 @@ public:
int32 loopPressedKey = 0;
int32 previousLoopPressedKey = 0;
int32 loopCurrentKey = 0;
int32 loopInventoryItem = 0;
int32 loopActorStep = 0;