TUCKER: Add CursorStyle and CursorState enums

This commit is contained in:
Adrian Frühwirth 2018-03-02 17:26:12 +01:00
parent 487baf6f8e
commit dce8a98a18
6 changed files with 76 additions and 60 deletions

View file

@ -3021,11 +3021,11 @@ void TuckerEngine::execData3PreUpdate_locationNum70() {
_updateLocation70StringLen = 0; _updateLocation70StringLen = 0;
_forceRedrawPanelItems = true; _forceRedrawPanelItems = true;
_panelState = 1; _panelState = 1;
setCursorType(2); setCursorState(kCursorStateDisabledHidden);
} }
_forceRedrawPanelItems = true; _forceRedrawPanelItems = true;
_panelState = 1; _panelState = 1;
setCursorType(2); setCursorState(kCursorStateDisabledHidden);
int pos = getPositionForLine(22, _infoBarBuf); int pos = getPositionForLine(22, _infoBarBuf);
const int yPos = (_flagsTable[143] == 0) ? 90 : 72; const int yPos = (_flagsTable[143] == 0) ? 90 : 72;
drawStringAlt(88, yPos, color, &_infoBarBuf[pos]); drawStringAlt(88, yPos, color, &_infoBarBuf[pos]);

View file

@ -693,7 +693,7 @@ void TuckerEngine::loadData4() {
d->_standX = t.getNextInteger(); d->_standX = t.getNextInteger();
d->_standY = t.getNextInteger(); d->_standY = t.getNextInteger();
d->_textNum = t.getNextInteger(); d->_textNum = t.getNextInteger();
d->_cursorNum = t.getNextInteger(); d->_cursorStyle = (CursorStyle)t.getNextInteger();
d->_locationNum = t.getNextInteger(); d->_locationNum = t.getNextInteger();
if (d->_locationNum > 0) { if (d->_locationNum > 0) {
d->_toX = t.getNextInteger(); d->_toX = t.getNextInteger();
@ -983,7 +983,7 @@ void TuckerEngine::loadActionsTable() {
} }
_forceRedrawPanelItems = true; _forceRedrawPanelItems = true;
_panelState = 1; _panelState = 1;
setCursorType(2); setCursorState(kCursorStateDisabledHidden);
_tableInstructionsPtr = _csDataBuf + t._pos + 1; _tableInstructionsPtr = _csDataBuf + t._pos + 1;
_csDataLoaded = true; _csDataLoaded = true;
_csDataHandled = true; _csDataHandled = true;
@ -1032,7 +1032,7 @@ void TuckerEngine::loadActionsTable() {
_nextAction = _nextTableToLoadTable[_nextTableToLoadIndex]; _nextAction = _nextTableToLoadTable[_nextTableToLoadIndex];
_csDataLoaded = false; _csDataLoaded = false;
_conversationOptionsCount = 0; _conversationOptionsCount = 0;
setCursorType(2); setCursorState(kCursorStateDisabledHidden);
} }
break; break;
} }
@ -1045,7 +1045,7 @@ void TuckerEngine::loadActionsTable() {
_csDataLoaded = false; _csDataLoaded = false;
_forceRedrawPanelItems = true; _forceRedrawPanelItems = true;
_panelState = 0; _panelState = 0;
setCursorType(0); setCursorState(kCursorStateNormal);
_csDataHandled = false; _csDataHandled = false;
_actionVerbLocked = false; _actionVerbLocked = false;
_mouseClick = 1; _mouseClick = 1;

View file

@ -119,11 +119,11 @@ Common::Error TuckerEngine::saveGameState(int num, const Common::String &descrip
bool TuckerEngine::canLoadGameStateCurrently() { bool TuckerEngine::canLoadGameStateCurrently() {
return !_player && _cursorType < 2; return !_player && _cursorState != kCursorStateDisabledHidden;
} }
bool TuckerEngine::canSaveGameStateCurrently() { bool TuckerEngine::canSaveGameStateCurrently() {
return !_player && _cursorType < 2; return !_player && _cursorState != kCursorStateDisabledHidden;
} }
bool TuckerEngine::existsSavegame() { bool TuckerEngine::existsSavegame() {

View file

@ -414,11 +414,11 @@ void TuckerEngine::handleMapSequence() {
if (_nextLocationNum == 9 && _noPositionChangeAfterMap) { if (_nextLocationNum == 9 && _noPositionChangeAfterMap) {
_backgroundSpriteCurrentAnimation = 2; _backgroundSpriteCurrentAnimation = 2;
_backgroundSpriteCurrentFrame = 0; _backgroundSpriteCurrentFrame = 0;
setCursorType(2); setCursorState(kCursorStateDisabledHidden);
} else if (_nextLocationNum == 66 && _noPositionChangeAfterMap) { } else if (_nextLocationNum == 66 && _noPositionChangeAfterMap) {
_backgroundSpriteCurrentAnimation = 1; _backgroundSpriteCurrentAnimation = 1;
_backgroundSpriteCurrentFrame = 0; _backgroundSpriteCurrentFrame = 0;
setCursorType(2); setCursorState(kCursorStateDisabledHidden);
} }
_noPositionChangeAfterMap = false; _noPositionChangeAfterMap = false;
_xPosCurrent = xPos; _xPosCurrent = xPos;

View file

@ -207,8 +207,8 @@ void TuckerEngine::resetVariables() {
_leftMouseButtonPressed = _rightMouseButtonPressed = false; _leftMouseButtonPressed = _rightMouseButtonPressed = false;
_lastKeyPressed = 0; _lastKeyPressed = 0;
memset(_inputKeys, 0, sizeof(_inputKeys)); memset(_inputKeys, 0, sizeof(_inputKeys));
_cursorNum = 0; _cursorStyle = kCursorNormal;
_cursorType = 0; _cursorState = kCursorStateNormal;
_updateCursorFlag = false; _updateCursorFlag = false;
_panelNum = 1; _panelNum = 1;
@ -377,8 +377,8 @@ void TuckerEngine::mainLoop() {
loadBudSpr(); loadBudSpr();
loadCursor(); loadCursor();
setCursorNum(_cursorNum); setCursorStyle(_cursorStyle);
setCursorType(_cursorType); setCursorState(_cursorState);
_flagsTable[219] = 1; _flagsTable[219] = 1;
_flagsTable[105] = 1; _flagsTable[105] = 1;
@ -422,7 +422,7 @@ void TuckerEngine::mainLoop() {
setupNewLocation(); setupNewLocation();
} }
updateCharPosition(); updateCharPosition();
if (_cursorType == 0) { if (_cursorState == kCursorStateNormal) {
updateCursor(); updateCursor();
} else if (_panelState == 2) { } else if (_panelState == 2) {
handleMouseOnPanel(); handleMouseOnPanel();
@ -713,16 +713,16 @@ void TuckerEngine::updateCursorPos(int x, int y) {
_mousePosY = y; _mousePosY = y;
} }
void TuckerEngine::setCursorNum(int num) { void TuckerEngine::setCursorStyle(CursorStyle style) {
_cursorNum = num; _cursorStyle = style;
static const int cursorW = 16; static const int cursorW = 16;
static const int cursorH = 16; static const int cursorH = 16;
CursorMan.replaceCursor(_cursorGfxBuf + _cursorNum * 256, cursorW, cursorH, 1, 1, 0); CursorMan.replaceCursor(_cursorGfxBuf + _cursorStyle * 256, cursorW, cursorH, 1, 1, 0);
} }
void TuckerEngine::setCursorType(int type) { void TuckerEngine::setCursorState(CursorState state) {
_cursorType = type; _cursorState = state;
CursorMan.showMouse(_cursorType < 2); CursorMan.showMouse(_cursorState != kCursorStateDisabledHidden);
} }
void TuckerEngine::showCursor(bool visible) { void TuckerEngine::showCursor(bool visible) {
@ -792,7 +792,7 @@ void TuckerEngine::copyLocBitmap(const char *filename, int offset, bool isMask)
} }
void TuckerEngine::updateMouseState() { void TuckerEngine::updateMouseState() {
if (_cursorType < 2) { if (_cursorState != kCursorStateDisabledHidden) {
_leftMouseButtonPressed = (_mouseButtonsMask & 1) != 0; _leftMouseButtonPressed = (_mouseButtonsMask & 1) != 0;
if (_leftMouseButtonPressed) { if (_leftMouseButtonPressed) {
_mouseIdleCounter = 0; _mouseIdleCounter = 0;
@ -809,9 +809,9 @@ void TuckerEngine::updateMouseState() {
_gameHintsStringNum = 0; _gameHintsStringNum = 0;
} }
} }
if (_cursorType == 1) { if (_cursorState == kCursorStateDialog) {
if (_panelState == 1) { if (_panelState == 1) {
setCursorNum(1); setCursorStyle(kCursorTalk);
} }
if (_mousePosY < 140) { if (_mousePosY < 140) {
_mousePosY = 140; _mousePosY = 140;
@ -820,7 +820,7 @@ void TuckerEngine::updateMouseState() {
} }
void TuckerEngine::updateCharPositionHelper() { void TuckerEngine::updateCharPositionHelper() {
setCursorType(2); setCursorState(kCursorStateDisabledHidden );
_charSpeechSoundCounter = kDefaultCharSpeechSoundCounter; _charSpeechSoundCounter = kDefaultCharSpeechSoundCounter;
_currentActionVerb = 0; _currentActionVerb = 0;
startSpeechSound(_speechSoundNum, _speechVolume); startSpeechSound(_speechSoundNum, _speechVolume);
@ -1033,7 +1033,7 @@ void TuckerEngine::setBlackPalette() {
} }
void TuckerEngine::updateCursor() { void TuckerEngine::updateCursor() {
setCursorNum(0); setCursorStyle(kCursorNormal);
if (_backgroundSpriteCurrentAnimation == -1 && !_panelLockedFlag && _selectedObject._locationObjectLocationNum > 0) { if (_backgroundSpriteCurrentAnimation == -1 && !_panelLockedFlag && _selectedObject._locationObjectLocationNum > 0) {
_selectedObject._locationObjectLocationNum = 0; _selectedObject._locationObjectLocationNum = 0;
} }
@ -1396,7 +1396,7 @@ void TuckerEngine::saveOrLoad() {
} }
_forceRedrawPanelItems = true; _forceRedrawPanelItems = true;
_panelState = 0; _panelState = 0;
setCursorType(0); setCursorState(kCursorStateNormal);
return; return;
} }
} }
@ -1425,7 +1425,7 @@ void TuckerEngine::handleMouseOnPanel() {
} else if (_mousePosX < 218) { } else if (_mousePosX < 218) {
_forceRedrawPanelItems = true; _forceRedrawPanelItems = true;
_panelState = 0; _panelState = 0;
setCursorType(0); setCursorState(kCursorStateNormal);
} else { } else {
_quitGame = true; _quitGame = true;
} }
@ -2119,7 +2119,7 @@ void TuckerEngine::updateCharacterAnimation() {
_characterAnimationIndex = -1; _characterAnimationIndex = -1;
_backgroundSpriteCurrentAnimation = -1; _backgroundSpriteCurrentAnimation = -1;
if (_nextAction == 0) { if (_nextAction == 0) {
setCursorType(0); setCursorState(kCursorStateNormal);
} }
} else { } else {
_backgroundSpriteCurrentFrame = _characterAnimationsTable[_characterAnimationIndex]; _backgroundSpriteCurrentFrame = _characterAnimationsTable[_characterAnimationIndex];
@ -2143,7 +2143,7 @@ void TuckerEngine::updateCharacterAnimation() {
_backgroundSpriteCurrentFrame = 0; _backgroundSpriteCurrentFrame = 0;
_changeBackgroundSprite = false; _changeBackgroundSprite = false;
if (_nextAction == 0) { if (_nextAction == 0) {
setCursorType(0); setCursorState(kCursorStateNormal);
} }
} }
} }
@ -2162,7 +2162,7 @@ void TuckerEngine::updateCharacterAnimation() {
_backgroundSpriteCurrentAnimation = -1; _backgroundSpriteCurrentAnimation = -1;
_backgroundSpriteCurrentFrame = 0; _backgroundSpriteCurrentFrame = 0;
if (_nextAction == 0 && _panelState == 0) { if (_nextAction == 0 && _panelState == 0) {
setCursorType(0); setCursorState(kCursorStateNormal);
} }
} }
} }
@ -2181,7 +2181,7 @@ void TuckerEngine::updateCharacterAnimation() {
_actionPosY = _yPosCurrent - 64; _actionPosY = _yPosCurrent - 64;
_actionTextColor = 1; _actionTextColor = 1;
_actionCharacterNum = 99; _actionCharacterNum = 99;
setCursorType(2); setCursorState(kCursorStateDisabledHidden);
_charSpeechSoundCounter = kDefaultCharSpeechSoundCounter; _charSpeechSoundCounter = kDefaultCharSpeechSoundCounter;
} }
} }
@ -2392,7 +2392,7 @@ void TuckerEngine::handleMap() {
} }
} }
if (!_panelLockedFlag && (_backgroundSpriteCurrentAnimation == -1 || _locationNum == 25) && _locationMaskType == 3) { if (!_panelLockedFlag && (_backgroundSpriteCurrentAnimation == -1 || _locationNum == 25) && _locationMaskType == 3) {
setCursorType(0); setCursorState(kCursorStateNormal);
if (_locationMaskCounter == 1) { if (_locationMaskCounter == 1) {
_characterFacingDirection = 0; _characterFacingDirection = 0;
_locationMaskType = 0; _locationMaskType = 0;
@ -2403,7 +2403,7 @@ void TuckerEngine::handleMap() {
if (_locationNum == 25 || _backgroundSpriteCurrentAnimation != 4) { if (_locationNum == 25 || _backgroundSpriteCurrentAnimation != 4) {
if (_locationMaskType == 0) { if (_locationMaskType == 0) {
_locationMaskType = 1; _locationMaskType = 1;
setCursorType(2); setCursorState(kCursorStateDisabledHidden);
if (_selectedObject._locationObjectToWalkX2 > 800) { if (_selectedObject._locationObjectToWalkX2 > 800) {
_backgroundSpriteCurrentAnimation = _selectedObject._locationObjectToWalkX2 - 900; _backgroundSpriteCurrentAnimation = _selectedObject._locationObjectToWalkX2 - 900;
if (_selectedObject._locationObjectToWalkY2 > 499) { if (_selectedObject._locationObjectToWalkY2 > 499) {
@ -2431,7 +2431,7 @@ void TuckerEngine::handleMap() {
} }
_locationMaskType = 2; _locationMaskType = 2;
_panelState = 0; _panelState = 0;
setCursorType(0); setCursorState(kCursorStateNormal);
if (_selectedObject._locationObjectLocationNum == 99) { if (_selectedObject._locationObjectLocationNum == 99) {
_noPositionChangeAfterMap = true; _noPositionChangeAfterMap = true;
handleMapSequence(); handleMapSequence();
@ -3001,7 +3001,7 @@ void TuckerEngine::updateCharSpeechSound(bool displayText) {
} }
} }
if (_charSpeechSoundCounter == 0 && !_csDataHandled) { if (_charSpeechSoundCounter == 0 && !_csDataHandled) {
setCursorType(0); setCursorState(kCursorStateNormal);
} else if (displayText) { } else if (displayText) {
drawSpeechText(_actionPosX, _actionPosY, _characterSpeechDataPtr, _speechSoundNum, _actionTextColor); drawSpeechText(_actionPosX, _actionPosY, _characterSpeechDataPtr, _speechSoundNum, _actionTextColor);
} }
@ -3364,7 +3364,7 @@ int TuckerEngine::executeTableInstruction() {
_nextTableToLoadTable[i] = readTableInstructionParam(3); _nextTableToLoadTable[i] = readTableInstructionParam(3);
} }
_nextTableToLoadIndex = -1; _nextTableToLoadIndex = -1;
setCursorType(1); setCursorState(kCursorStateDialog);
return 1; return 1;
case kCode_opf: case kCode_opf:
_conversationOptionsCount = 0; _conversationOptionsCount = 0;
@ -3384,7 +3384,7 @@ int TuckerEngine::executeTableInstruction() {
} }
} }
_nextTableToLoadIndex = -1; _nextTableToLoadIndex = -1;
setCursorType(1); setCursorState(kCursorStateDialog);
return 1; return 1;
case kCode_ofg: case kCode_ofg:
i = readTableInstructionParam(3); i = readTableInstructionParam(3);
@ -3512,7 +3512,7 @@ int TuckerEngine::getObjectUnderCursor() {
} }
_selectedObjectType = 0; _selectedObjectType = 0;
_selectedCharacterNum = i; _selectedCharacterNum = i;
setCursorNum(_locationObjectsTable[i]._cursorNum); setCursorStyle(_locationObjectsTable[i]._cursorStyle);
return i; return i;
} }
return -1; return -1;
@ -3669,7 +3669,7 @@ void TuckerEngine::handleMouseClickOnInventoryObject() {
_actionVerbLocked = false; _actionVerbLocked = false;
_forceRedrawPanelItems = true; _forceRedrawPanelItems = true;
_panelState = 2; _panelState = 2;
setCursorType(1); setCursorState(kCursorStateDialog);
} }
break; break;
case 1: case 1:
@ -3681,7 +3681,7 @@ void TuckerEngine::handleMouseClickOnInventoryObject() {
_actionPosY = _yPosCurrent - 64; _actionPosY = _yPosCurrent - 64;
_actionTextColor = 1; _actionTextColor = 1;
_actionCharacterNum = 99; _actionCharacterNum = 99;
setCursorType(2); setCursorState(kCursorStateDisabledHidden);
_charSpeechSoundCounter = kDefaultCharSpeechSoundCounter; _charSpeechSoundCounter = kDefaultCharSpeechSoundCounter;
_currentActionVerb = 0; _currentActionVerb = 0;
_speechSoundNum = 2235; _speechSoundNum = 2235;
@ -3794,7 +3794,7 @@ void TuckerEngine::setActionForInventoryObject() {
_actionPosY = _yPosCurrent - 64; _actionPosY = _yPosCurrent - 64;
_actionTextColor = 1; _actionTextColor = 1;
_actionCharacterNum = 99; _actionCharacterNum = 99;
setCursorType(2); setCursorState(kCursorStateDisabledHidden);
_charSpeechSoundCounter = kDefaultCharSpeechSoundCounter; _charSpeechSoundCounter = kDefaultCharSpeechSoundCounter;
_actionVerbLocked = false; _actionVerbLocked = false;
_actionRequiresTwoObjects = false; _actionRequiresTwoObjects = false;
@ -3860,7 +3860,7 @@ void TuckerEngine::playSpeechForAction(int i) {
_actionPosY = _yPosCurrent - 64; _actionPosY = _yPosCurrent - 64;
_actionTextColor = 1; _actionTextColor = 1;
_actionCharacterNum = 99; _actionCharacterNum = 99;
setCursorType(2); setCursorState(kCursorStateDisabledHidden);
_charSpeechSoundCounter = kDefaultCharSpeechSoundCounter; _charSpeechSoundCounter = kDefaultCharSpeechSoundCounter;
} }
} }

View file

@ -52,6 +52,34 @@ class RewindableAudioStream;
*/ */
namespace Tucker { namespace Tucker {
enum CursorStyle {
kCursorNormal = 0,
kCursorTalk = 1,
kCursorArrowRight = 2,
kCursorArrowUp = 3,
kCursorArrowLeft = 4,
kCursorArrowDown = 5,
kCursorMap = 6
};
enum CursorState {
kCursorStateNormal = 0,
kCursorStateDialog = 1,
kCursorStateDisabledHidden = 2
};
enum Verb {
kVerbWalk = 0,
kVerbLook = 1,
kVerbTalk = 2,
kVerbOpen = 3,
kVerbClose = 4,
kVerbGive = 5,
kVerbTake = 6,
kVerbMove = 7,
kVerbUse = 8
};
struct Action { struct Action {
int _key; int _key;
int _testFlag1Num; int _testFlag1Num;
@ -157,7 +185,7 @@ struct LocationObject {
int _toWalkY2; int _toWalkY2;
int _standX; int _standX;
int _standY; int _standY;
int _cursorNum; CursorStyle _cursorStyle;
}; };
struct LocationSound { struct LocationSound {
@ -194,18 +222,6 @@ enum {
kLastSaveSlot = 99 kLastSaveSlot = 99
}; };
enum Verb {
kVerbWalk = 0,
kVerbLook = 1,
kVerbTalk = 2,
kVerbOpen = 3,
kVerbClose = 4,
kVerbGive = 5,
kVerbTake = 6,
kVerbMove = 7,
kVerbUse = 8
};
enum InputKey { enum InputKey {
kInputKeyPause = 0, kInputKeyPause = 0,
kInputKeyEscape, kInputKeyEscape,
@ -299,8 +315,8 @@ protected:
void waitForTimer(int ticksCount); void waitForTimer(int ticksCount);
void parseEvents(); void parseEvents();
void updateCursorPos(int x, int y); void updateCursorPos(int x, int y);
void setCursorNum(int num); void setCursorStyle(CursorStyle num);
void setCursorType(int type); void setCursorState(CursorState state);
void showCursor(bool visible); void showCursor(bool visible);
void setupNewLocation(); void setupNewLocation();
void copyLocBitmap(const char *filename, int offset, bool isMask); void copyLocBitmap(const char *filename, int offset, bool isMask);
@ -688,8 +704,8 @@ protected:
bool _mouseWheelDown; bool _mouseWheelDown;
int _lastKeyPressed; int _lastKeyPressed;
bool _inputKeys[kInputKeyCount]; bool _inputKeys[kInputKeyCount];
int _cursorNum; CursorStyle _cursorStyle;
int _cursorType; CursorState _cursorState;
bool _updateCursorFlag; bool _updateCursorFlag;
int _panelNum; int _panelNum;