diff options
author | David Fioramonti | 2017-08-18 04:54:27 -0700 |
---|---|---|
committer | David Fioramonti | 2017-08-18 04:54:27 -0700 |
commit | 524855d173699a6b56dd932a70e2d9a1e4068d8c (patch) | |
tree | 49d6bca633f55f45508cba0363f3ee15bab09a86 /engines/titanic | |
parent | 38c02017f5a9da17d3c06dbcc1acf23b80c1cac4 (diff) | |
download | scummvm-rg350-524855d173699a6b56dd932a70e2d9a1e4068d8c.tar.gz scummvm-rg350-524855d173699a6b56dd932a70e2d9a1e4068d8c.tar.bz2 scummvm-rg350-524855d173699a6b56dd932a70e2d9a1e4068d8c.zip |
TITANIC: Change variable for tracking stars marked into enum
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/star_control/star_camera.cpp | 55 | ||||
-rw-r--r-- | engines/titanic/star_control/star_camera.h | 11 |
2 files changed, 40 insertions, 26 deletions
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp index 9c1c598ede..76302d2266 100644 --- a/engines/titanic/star_control/star_camera.cpp +++ b/engines/titanic/star_control/star_camera.cpp @@ -33,12 +33,12 @@ FMatrix *CStarCamera::_priorOrientation; FMatrix *CStarCamera::_newOrientation; CStarCamera::CStarCamera(const CNavigationInfo *data) : - _matrixRow(-1), _mover(nullptr), _isMoved(false) { + _star_lock_state(ZERO_LOCKED), _mover(nullptr), _isMoved(false) { setupHandler(data); } CStarCamera::CStarCamera(CViewport *src) : - _matrixRow(-1), _mover(nullptr), _isMoved(false), _viewport(src) { + _star_lock_state(ZERO_LOCKED), _mover(nullptr), _isMoved(false), _viewport(src) { } void CStarCamera::init() { @@ -226,15 +226,16 @@ void CStarCamera::setViewportAngle(const FPoint &angles) { if (isLocked()) return; - - if (_matrixRow == -1) { - // No locked markers + switch(_star_lock_state) { + case ZERO_LOCKED: { FPose subX(X_AXIS, angles._y); FPose subY(Y_AXIS, -angles._x); // needs to be negative or looking left will cause the view to go right FPose sub(subX, subY); proc22(sub); - } else if (_matrixRow == 0) { - // 1 marker is locked in + } + break; + + case ONE_LOCKED: { FVector row1 = _matrix._row1; FPose poseX(X_AXIS, angles._y); FPose poseY(Y_AXIS, -angles._x); // needs to be negative or looking left will cause the view to go right @@ -275,8 +276,10 @@ void CStarCamera::setViewportAngle(const FPoint &angles) { m1.set(tempV4, tempV5, tempV6); _viewport.setOrientation(m1); _viewport.setPosition(tempV1); - } else if (_matrixRow == 1) { - // 2 markers locked in + } + break; + + case TWO_LOCKED: { FVector tempV2; DAffine m1, m2, sub; DVector mrow1, mrow2, mrow3; @@ -342,32 +345,38 @@ void CStarCamera::setViewportAngle(const FPoint &angles) { m3.set(mrow1, mrow2, mrow3); _viewport.setOrientation(m3); _viewport.setPosition(tempV16); - } + } + break; + + //TODO: should three stars locked do anything in this function? Error? + case THREE_LOCKED: + break; + } } bool CStarCamera::adDAffineRow(const FVector v) { - if (_matrixRow >= 2) + if (_star_lock_state == THREE_LOCKED) return false; CNavigationInfo data; _mover->copyTo(&data); deleteHandler(); - - FVector &row = _matrix[++_matrixRow]; + FVector &row = _matrix[(int)_star_lock_state]; + _star_lock_state = StarLockState( (int)_star_lock_state + 1); row = v; setupHandler(&data); return true; } bool CStarCamera::removeMatrixRow() { - if (_matrixRow == -1) + if (_star_lock_state == ZERO_LOCKED) return false; CNavigationInfo data; _mover->copyTo(&data); deleteHandler(); - --_matrixRow; + _star_lock_state = StarLockState( (int)_star_lock_state - 1); setupHandler(&data); return true; } @@ -387,14 +396,14 @@ void CStarCamera::save(SimpleFile *file, int indent) { bool CStarCamera::setupHandler(const CNavigationInfo *src) { CCameraMover *mover = nullptr; - switch (_matrixRow) { - case -1: + switch (_star_lock_state) { + case ZERO_LOCKED: mover = new CUnmarkedCameraMover(src); break; - case 0: - case 1: - case 2: + case ONE_LOCKED: + case TWO_LOCKED: + case THREE_LOCKED: mover = new CMarkedCameraMover(src); break; @@ -419,7 +428,7 @@ void CStarCamera::deleteHandler() { } void CStarCamera::lockMarker1(FVector v1, FVector v2, FVector v3) { - if (_matrixRow != -1) + if (_star_lock_state != ZERO_LOCKED) return; FVector tempV; @@ -454,7 +463,7 @@ void CStarCamera::lockMarker1(FVector v1, FVector v2, FVector v3) { } void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) { - if (_matrixRow != 0) + if (_star_lock_state != ONE_LOCKED) return; DAffine m2(X_AXIS, _matrix._row1); @@ -545,7 +554,7 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) { } void CStarCamera::lockMarker3(CViewport *viewport, const FVector &v) { - if (_matrixRow != 1) + if (_star_lock_state != TWO_LOCKED) return; FMatrix newOr = viewport->getOrientation(); diff --git a/engines/titanic/star_control/star_camera.h b/engines/titanic/star_control/star_camera.h index fa46eb38b1..3cdea2aa85 100644 --- a/engines/titanic/star_control/star_camera.h +++ b/engines/titanic/star_control/star_camera.h @@ -33,6 +33,8 @@ namespace Titanic { +enum StarLockState { ZERO_LOCKED=0, ONE_LOCKED=1, TWO_LOCKED=2, THREE_LOCKED=3 }; + /** * Implements a reference point from which the starmap can be viewed */ @@ -41,7 +43,7 @@ private: static FMatrix *_priorOrientation; static FMatrix *_newOrientation; private: - int _matrixRow; + StarLockState _star_lock_state; FMatrix _matrix; CCameraMover *_mover; CViewport _viewport; @@ -107,7 +109,7 @@ public: virtual void increaseForwardSpeed(); /** - * Decreases movement speed in backward direction + * Increases movement speed in backward direction */ virtual void increaseBackwardSpeed(); @@ -155,7 +157,10 @@ public: */ virtual void setViewportAngle(const FPoint &angles); - virtual int getMatrixRow() const { return _matrixRow; } + /** + * How many stars are currently locked onto + */ + virtual StarLockState getStarLockState() const { return _star_lock_state; } /** * Adds the row for a locked in marker |