[Scummvm-git-logs] scummvm master -> 297cb6be82bee185c5e0b1d63d6fae972fdf6e46

dreammaster dreammaster at scummvm.org
Fri Mar 3 03:07:30 CET 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
297cb6be82 TITANIC: Code for starfield mode setup & photo code


Commit: 297cb6be82bee185c5e0b1d63d6fae972fdf6e46
    https://github.com/scummvm/scummvm/commit/297cb6be82bee185c5e0b1d63d6fae972fdf6e46
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-03-02T21:07:28-05:00

Commit Message:
TITANIC: Code for starfield mode setup & photo code

Changed paths:
    engines/titanic/core/game_object.h
    engines/titanic/game/nav_helmet.cpp
    engines/titanic/star_control/star_control.cpp
    engines/titanic/star_control/star_control_sub8.cpp
    engines/titanic/star_control/star_control_sub8.h
    engines/titanic/star_control/star_field.cpp
    engines/titanic/star_control/star_field.h
    engines/titanic/star_control/star_view.cpp
    engines/titanic/star_control/star_view.h
    engines/titanic/titanic.h


diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index a04860f..3f42a87 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -44,7 +44,7 @@ enum Found { FOUND_NONE = 0, FOUND_GLOBAL = 1, FOUND_ROOM = 2, FOUND_PET = 3, FO
 enum RoomFlagsComparison { RFC_LOCATION = 1, RFC_CLASS_ELEVATOR = 2, RFC_TITANIA = 3 };
 enum StarControlAction {
 	STAR_SHOW = 0, STAR_HIDE, STAR_2, STAR_RESET_POS, STAR_4, STAR_5, STAR_6, STAR_7,
-	STAR_8, STAR_9, STAR_10, STAR_11, STAR_12, STAR_13, STAR_SET_REFERENCE, STAR_FADE_IN,
+	STAR_8, STAR_TOGGLE_MODE, STAR_10, STAR_11, STAR_12, STAR_13, STAR_SET_REFERENCE, STAR_FADE_IN,
 	STAR_FADE_OUT, STAR_17, STAR_18, STAR_19
 };
 
diff --git a/engines/titanic/game/nav_helmet.cpp b/engines/titanic/game/nav_helmet.cpp
index aaaa17d..37d96a2 100644
--- a/engines/titanic/game/nav_helmet.cpp
+++ b/engines/titanic/game/nav_helmet.cpp
@@ -106,7 +106,7 @@ bool CNavHelmet::PETHelmetOnOffMsg(CPETHelmetOnOffMsg *msg) {
 
 bool CNavHelmet::PETPhotoOnOffMsg(CPETPhotoOnOffMsg *msg) {
 	if (_flag)
-		starFn(STAR_9);
+		starFn(STAR_TOGGLE_MODE);
 
 	return true;
 }
diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp
index dcde81e..66bb9fe 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 ff5ca35..f53c6f0 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 ab05316..0c0cdcf 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 3cc859b..24b30bf 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 24b22a9..dc82a88 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 32003b6..405e8d6 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 a39d058..ee78ca7 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();
 
diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h
index 43f3fa0..fdc9402 100644
--- a/engines/titanic/titanic.h
+++ b/engines/titanic/titanic.h
@@ -164,6 +164,11 @@ public:
 	uint getRandomNumber(uint max) { return _randomSource.getRandomNumber(max); }
 
 	/**
+	 * Returns a random floating point number between 0.0 to 65535.0
+	 */
+	double getRandomFloat() { return getRandomNumber(0xffffffff) * 0.000015259022; }
+
+	/**
 	 * Support method that generates a savegame name
 	 * @param slot		Slot number
 	 */





More information about the Scummvm-git-logs mailing list