BURIED: Replace magic numbers with enum

This commit is contained in:
Eugene Sandulenko 2021-03-25 14:07:50 +01:00
parent 99b947979d
commit f07685729c
3 changed files with 30 additions and 22 deletions

View File

@ -149,17 +149,17 @@ void NavArrowWindow::onLButtonDown(const Common::Point &point, uint flags) {
// If we only clicked on the forward arrow, then take care of it here
if (!rightButton.contains(point) && !downButton.contains(point)) {
if (_arrowStatus[4] == BUTTON_ENABLED)
((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(4);
((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(kDirectionForward);
} else {
if (rightButton.contains(point)) {
Graphics::Surface *centerArrow = _vm->_gfx->getBitmap(_arrowBitmaps[4][_arrowStatus[4]]);
if (_vm->_gfx->checkPointAgainstMaskedBitmap(centerArrow, 39, 49, point, 255, 255, 255)) {
if (_arrowStatus[4] == BUTTON_ENABLED)
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(4);
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(kDirectionForward);
} else {
if (_arrowStatus[2] == BUTTON_ENABLED)
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(2);
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(kDirectionRight);
}
centerArrow->free();
@ -171,10 +171,10 @@ void NavArrowWindow::onLButtonDown(const Common::Point &point, uint flags) {
if (_vm->_gfx->checkPointAgainstMaskedBitmap(centerArrow, 39, 49, point, 255, 255, 255)) {
if (_arrowStatus[4] == BUTTON_ENABLED)
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(4);
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(kDirectionForward);
} else {
if (_arrowStatus[3] == BUTTON_ENABLED)
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(3);
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(kDirectionDown);
}
centerArrow->free();
@ -183,16 +183,16 @@ void NavArrowWindow::onLButtonDown(const Common::Point &point, uint flags) {
}
} else {
if (upButton.contains(point) && _arrowStatus[0] == BUTTON_ENABLED)
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(0);
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(kDirectionUp);
if (leftButton.contains(point) && _arrowStatus[1] == BUTTON_ENABLED)
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(1);
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(kDirectionLeft);
if (rightButton.contains(point) && _arrowStatus[2] == BUTTON_ENABLED)
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(2);
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(kDirectionRight);
if (downButton.contains(point) && _arrowStatus[3] == BUTTON_ENABLED)
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(3);
retVal = ((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(kDirectionDown);
}
if (retVal) {
@ -206,26 +206,26 @@ void NavArrowWindow::onKeyUp(const Common::KeyState &key, uint flags) {
case Common::KEYCODE_KP4:
case Common::KEYCODE_LEFT:
if (_arrowStatus[1] == BUTTON_ENABLED)
((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(1);
((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(kDirectionLeft);
break;
case Common::KEYCODE_KP6:
case Common::KEYCODE_RIGHT:
if (_arrowStatus[2] == BUTTON_ENABLED)
((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(2);
((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(kDirectionRight);
break;
case Common::KEYCODE_KP2:
case Common::KEYCODE_DOWN:
if (_arrowStatus[3] == BUTTON_ENABLED)
((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(3);
((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(kDirectionDown);
break;
case Common::KEYCODE_KP8:
case Common::KEYCODE_UP:
if (_arrowStatus[0] == BUTTON_ENABLED)
((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(0);
((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(kDirectionUp);
break;
case Common::KEYCODE_KP5:
if (_arrowStatus[4] == BUTTON_ENABLED)
((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(4);
((GameUIWindow *)_parent)->_sceneViewWindow->moveInDirection(kDirectionForward);
break;
default:
break;

View File

@ -486,7 +486,7 @@ bool SceneViewWindow::jumpToSceneRestore(const Location &newLocation) {
return true;
}
bool SceneViewWindow::moveInDirection(int direction) {
bool SceneViewWindow::moveInDirection(Direction direction) {
if (!_currentScene)
return false;
@ -495,19 +495,19 @@ bool SceneViewWindow::moveInDirection(int direction) {
DestinationScene destinationData;
switch (direction) {
case 0: // Up
case kDirectionUp: // Up
destinationData = _currentScene->_staticData.destUp;
break;
case 1: // Left
case kDirectionLeft: // Left
destinationData = _currentScene->_staticData.destLeft;
break;
case 2: // Right
case kDirectionRight: // Right
destinationData = _currentScene->_staticData.destRight;
break;
case 3: // Down
case kDirectionDown: // Down
destinationData = _currentScene->_staticData.destDown;
break;
case 4: // Forward
case kDirectionForward: // Forward
destinationData = _currentScene->_staticData.destForward;
break;
}

View File

@ -44,6 +44,14 @@ class AVIFrames;
class SceneBase;
class VideoWindow;
enum Direction {
kDirectionUp = 0,
kDirectionLeft = 1,
kDirectionRight = 2,
kDirectionDown = 3,
kDirectionForward = 4
};
class SceneViewWindow : public Window {
public:
SceneViewWindow(BuriedEngine *vm, Window *parent);
@ -64,7 +72,7 @@ public:
bool jumpToScene(const Location &newLocation);
bool jumpToSceneRestore(const Location &newLocation);
bool moveInDirection(int direction);
bool moveInDirection(Direction direction);
bool moveToDestination(const DestinationScene &destinationData);
bool timeSuitJump(int destination);
@ -140,7 +148,7 @@ public:
void onMouseMove(const Common::Point &point, uint flags);
void onKeyUp(const Common::KeyState &key, uint flags);
bool isScenePresent() { return _currentScene != 0; }
int draggingItem(int itemID, const Common::Point &pointLocation, int itemFlags);
int droppedItem(int itemID, const Common::Point &pointLocation, int itemFlags);