diff options
author | Paul Gilbert | 2017-03-02 21:07:28 -0500 |
---|---|---|
committer | Paul Gilbert | 2017-03-02 21:07:28 -0500 |
commit | 297cb6be82bee185c5e0b1d63d6fae972fdf6e46 (patch) | |
tree | fec8bdc9be12531fce56503c93d91b4a5d3057ba /engines/titanic/star_control | |
parent | 415bd5644494d4a4ef532a2e8e70c0c6f23aab05 (diff) | |
download | scummvm-rg350-297cb6be82bee185c5e0b1d63d6fae972fdf6e46.tar.gz scummvm-rg350-297cb6be82bee185c5e0b1d63d6fae972fdf6e46.tar.bz2 scummvm-rg350-297cb6be82bee185c5e0b1d63d6fae972fdf6e46.zip |
TITANIC: Code for starfield mode setup & photo code
Diffstat (limited to 'engines/titanic/star_control')
-rw-r--r-- | engines/titanic/star_control/star_control.cpp | 15 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub8.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub8.h | 4 | ||||
-rw-r--r-- | engines/titanic/star_control/star_field.cpp | 23 | ||||
-rw-r--r-- | engines/titanic/star_control/star_field.h | 18 | ||||
-rw-r--r-- | engines/titanic/star_control/star_view.cpp | 104 | ||||
-rw-r--r-- | engines/titanic/star_control/star_view.h | 26 |
7 files changed, 165 insertions, 29 deletions
diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp index dcde81e253..66bb9fe833 100644 --- a/engines/titanic/star_control/star_control.cpp +++ b/engines/titanic/star_control/star_control.cpp @@ -110,8 +110,11 @@ bool CStarControl::MouseMoveMsg(CMouseMoveMsg *msg) { } bool CStarControl::KeyCharMsg(CKeyCharMsg *msg) { - if (_visible) - _view.KeyCharMsg(msg->_key); + if (_visible) { + CErrorCode errorCode; + _view.KeyCharMsg(msg->_key, &errorCode); + return errorCode.get(); + } return false; } @@ -138,7 +141,7 @@ void CStarControl::newFrame() { int val1 = _starField.get88(); int val2 = 0; - if (!_starField.get3()) { + if (_starField.getMode() == MODE_STARFIELD) { val2 = _starField.get5(); if ((val1 + 2) == _starField.get7Count()) val2 = 0; @@ -205,8 +208,8 @@ void CStarControl::doAction(StarControlAction action) { _view.fn9(); break; - case STAR_9: - _view.fn10(); + case STAR_TOGGLE_MODE: + _view.toggleMode(); break; case STAR_10: @@ -226,7 +229,7 @@ void CStarControl::doAction(StarControlAction action) { break; case STAR_SET_REFERENCE: { - _view.fn15(); + _view.setHasReference(); CPetControl *pet = getPetControl(); if (pet) pet->starsSetReference(); diff --git a/engines/titanic/star_control/star_control_sub8.cpp b/engines/titanic/star_control/star_control_sub8.cpp index ff5ca354ca..f53c6f0a6c 100644 --- a/engines/titanic/star_control/star_control_sub8.cpp +++ b/engines/titanic/star_control/star_control_sub8.cpp @@ -22,6 +22,7 @@ #include "titanic/star_control/star_control_sub8.h" #include "titanic/star_control/star_control_sub7.h" +#include "titanic/star_control/star_control_sub12.h" #include "titanic/star_control/star_field.h" namespace Titanic { @@ -47,5 +48,8 @@ void CStarControlSub8::selectStar(int index, CVideoSurface *surface, // TODO } +void CStarControlSub8::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) { + // TODO +} } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub8.h b/engines/titanic/star_control/star_control_sub8.h index ab05316075..0c0cdcf37c 100644 --- a/engines/titanic/star_control/star_control_sub8.h +++ b/engines/titanic/star_control/star_control_sub8.h @@ -23,6 +23,7 @@ #ifndef TITANIC_STAR_CONTROL_SUB8_H #define TITANIC_STAR_CONTROL_SUB8_H +#include "titanic/star_control/surface_area.h" #include "titanic/support/simple_file.h" #include "titanic/support/video_surface.h" @@ -30,6 +31,7 @@ namespace Titanic { class CStarField; class CStarControlSub7; +class CStarControlSub12; class CStarControlSub8 { struct StructEntry { @@ -64,6 +66,8 @@ public: void selectStar(int starNum, CVideoSurface *surface, CStarField *starField, CStarControlSub7 *sub7); + + void fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarControlSub12 *sub12); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_field.cpp b/engines/titanic/star_control/star_field.cpp index 3cc859b3f4..24b30bfc9b 100644 --- a/engines/titanic/star_control/star_field.cpp +++ b/engines/titanic/star_control/star_field.cpp @@ -25,8 +25,8 @@ namespace Titanic { -CStarField::CStarField() : _val1(0), _val2(0), _val3(0), _val4(true), - _val5(0), _isSolved(false) { +CStarField::CStarField() : _val1(0), _val2(0), _mode(MODE_STARFIELD), + _val4(true), _val5(0), _isSolved(false) { } void CStarField::load(SimpleFile *file) { @@ -34,7 +34,7 @@ void CStarField::load(SimpleFile *file) { _sub8.load(file); _val1 = file->readNumber(); _val2 = file->readNumber(); - _val3 = file->readNumber(); + _mode = (StarMode)file->readNumber(); _val4 = file->readNumber(); _isSolved = file->readNumber(); } @@ -44,7 +44,7 @@ void CStarField::save(SimpleFile *file, int indent) { _sub8.save(file, indent); file->writeNumberLine(_val1, indent); file->writeNumberLine(_val2, indent); - file->writeNumberLine(_val3, indent); + file->writeNumberLine(_mode, indent); file->writeNumberLine(_val4, indent); file->writeNumberLine(_isSolved, indent); } @@ -93,12 +93,12 @@ void CStarField::set54(int val) { _sub5.set4(val); } -int CStarField::get3() const { - return _val3; +StarMode CStarField::getMode() const { + return _mode; } -void CStarField::set3(int val) { - _val3 = val; +void CStarField::setMode(StarMode mode) { + _mode = mode; } void CStarField::toggle4() { @@ -131,9 +131,14 @@ void CStarField::fn1(CErrorCode *errorCode) { _sub5.proc3(errorCode); } +void CStarField::fn6(CVideoSurface *surface, CStarControlSub12 *sub12) { + CSurfaceArea surfaceArea(surface); + +} + bool CStarField::mouseButtonDown(CVideoSurface *surface, CStarControlSub12 *sub12, int flags, const Common::Point &pt) { - if (!_val3) { + if (_mode == MODE_STARFIELD) { CSurfaceArea surfaceArea(surface); return selectStar(&surfaceArea, sub12, 0, pt); } else { diff --git a/engines/titanic/star_control/star_field.h b/engines/titanic/star_control/star_field.h index 24b22a99ef..dc82a88c43 100644 --- a/engines/titanic/star_control/star_field.h +++ b/engines/titanic/star_control/star_field.h @@ -32,6 +32,8 @@ namespace Titanic { +enum StarMode { MODE_STARFIELD = 0, MODE_PHOTO = 1 }; + class CStarField : public CStarControlSub2 { private: CStarControlSub7 _sub7; @@ -41,7 +43,7 @@ private: CStarControlSub5 _sub5; int _val1; int _val2; - int _val3; + StarMode _mode; bool _val4; int _val5; bool _isSolved; @@ -71,8 +73,17 @@ public: void set2(int val); int get54() const; void set54(int val); - int get3() const; - void set3(int val); + + /** + * Gets the current display mode + */ + StarMode getMode() const; + + /** + * Sets the display mode + */ + void setMode(StarMode mode); + void toggle4(); bool set4(bool val); int get88() const; @@ -93,6 +104,7 @@ public: } void fn1(CErrorCode *errorCode); + void fn6(CVideoSurface *surface, CStarControlSub12 *sub12); /** * Called when the starfield is clicked diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp index 32003b678d..405e8d620f 100644 --- a/engines/titanic/star_control/star_view.cpp +++ b/engines/titanic/star_control/star_view.cpp @@ -25,6 +25,7 @@ #include "titanic/star_control/star_control.h" #include "titanic/star_control/star_field.h" #include "titanic/core/game_object.h" +#include "titanic/titanic.h" namespace Titanic { @@ -67,7 +68,10 @@ void CStarView::setup(CScreenManager *screenManager, CStarField *starField, CSta } void CStarView::reset() { - // TODO + if (!_field118) { + CStarControlSub12 sub12(&_sub13); + fn18(&sub12); + } } void CStarView::draw(CScreenManager *screenManager) { @@ -139,9 +143,22 @@ bool CStarView::MouseMoveMsg(int unused, const Point &pt) { return false; } -CErrorCode CStarView::KeyCharMsg(int key) { - // TODO - return CErrorCode(); +bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) { + CStarControlSub6 sub6; +// int v = _starField ? _starField->get88() : -1; + + switch (key) { + case Common::KEYCODE_TAB: + if (_starField) { + toggleMode(); + return true; + } + break; + + // TODO: More switch cases + } + + return false; } bool CStarView::canSetStarDestination() const { @@ -197,8 +214,10 @@ void CStarView::fn9() { // TODO } -void CStarView::fn10() { - // TODO +void CStarView::toggleMode() { + _showingPhoto = !_showingPhoto; + if (_starField) + _starField->setMode(_showingPhoto ? MODE_PHOTO : MODE_STARFIELD); } void CStarView::fn11() { @@ -217,8 +236,18 @@ void CStarView::fn14() { // TODO } -void CStarView::fn15() { - // TODO +void CStarView::setHasReference() { + FVector v1, v2; + randomizeVectors(&v1, &v2); + + _sub13.setPosition(v1); + _sub13.fn11(v2); + _field218 = 0; + _sub13.fn13(1, 0); + _sub13.fn13(0, 0); + _field118 = 1; + reset(); + _field218 = 1; } void CStarView::fn16() { @@ -229,5 +258,64 @@ void CStarView::fn17() { // TODO } +void CStarView::fn18(CStarControlSub12 *sub12) { + if (_starField) { + if (!_videoSurface2) { + CScreenManager *scrManager = CScreenManager::setCurrent(); + if (scrManager) + resizeSurface(scrManager, 600, 340, &_videoSurface2); + } + + if (_videoSurface2) { + int oldVal = _starField->get54(); + _starField->set4(false); + + _videoSurface2->clear(); + _videoSurface2->lock(); + _starField->render(_videoSurface2, sub12); + _videoSurface2->unlock(); + + _starField->set54(oldVal); + _starField->fn6(_videoSurface2, sub12); + } + } +} + +void CStarView::randomizeVectors(FVector *v1, FVector *v2) { + v1->_x = g_vm->getRandomFloat() * -4096.0 - 3072.0; + v1->_y = g_vm->getRandomFloat() * -4096.0 - 3072.0; + v1->_z = g_vm->getRandomFloat() * -4096.0 - 3072.0; + + double vx = g_vm->getRandomFloat() * 8192.0; + double vy = g_vm->getRandomFloat() * 1024.0; + vx -= v1->_x; + vy -= v1->_y; + + v2->_x = vx; + v2->_y = vy; + v2->_z = -v1->_z; + v2->fn3(); +} + +void CStarView::resizeSurface(CScreenManager *scrManager, int width, int height, + CVideoSurface **surface) { + if (!surface) + // Surface pointer must be provided + return; + if (*surface) { + // If there's an existing surface of the correct size, re-use it + if ((*surface)->getWidth() == width && (*surface)->getHeight() == height) + return; + + // Delete the old surface + delete *surface; + *surface = nullptr; + } + + CVideoSurface *newSurface = scrManager->createSurface(width, height); + if (newSurface) + *surface = newSurface; +} + } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_view.h b/engines/titanic/star_control/star_view.h index a39d058371..ee78ca764a 100644 --- a/engines/titanic/star_control/star_view.h +++ b/engines/titanic/star_control/star_view.h @@ -29,6 +29,7 @@ #include "titanic/star_control/star_control_sub13.h" #include "titanic/star_control/surface_fader.h" #include "titanic/star_control/error_code.h" +#include "titanic/star_control/fvector.h" namespace Titanic { @@ -53,6 +54,15 @@ private: #endif private: void fn1(); + void fn18(CStarControlSub12 *sub12); + + void randomizeVectors(FVector *v1, FVector *v2); + + /** + * Handles resizing the surface + */ + void resizeSurface(CScreenManager *scrManager, int width, int height, + CVideoSurface **surface); public: CStarView(); @@ -91,7 +101,7 @@ public: /** * Handles keyboard messages */ - CErrorCode KeyCharMsg(int key); + bool KeyCharMsg(int key, CErrorCode *errorCode); /** * Returns true if a star destination can be set @@ -117,12 +127,22 @@ public: void fn7(); void fn8(); void fn9(); - void fn10(); + + /** + * Toggles between starfield and photo modes + */ + void toggleMode(); + void fn11(); void fn12(); void fn13(); void fn14(); - void fn15(); + + /** + * Called when the photograph is used on the navigation computer + */ + void setHasReference(); + void fn16(); void fn17(); |