[Scummvm-git-logs] scummvm master -> b51421229bb96e15181d62f6706601967fe571c4

dreammaster dreammaster at scummvm.org
Sat Mar 11 04:15: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:
b51421229b TITANIC: Implementing star reference classes


Commit: b51421229bb96e15181d62f6706601967fe571c4
    https://github.com/scummvm/scummvm/commit/b51421229bb96e15181d62f6706601967fe571c4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-03-10T22:15:20-05:00

Commit Message:
TITANIC: Implementing star reference classes

Changed paths:
  A engines/titanic/star_control/star_ref.cpp
  A engines/titanic/star_control/star_ref.h
    engines/titanic/module.mk
    engines/titanic/star_control/base_star.cpp
    engines/titanic/star_control/base_star.h
    engines/titanic/star_control/star_control_sub2.cpp
    engines/titanic/star_control/star_control_sub2.h
    engines/titanic/star_control/star_control_sub8.cpp
    engines/titanic/star_control/star_control_sub8.h
    engines/titanic/star_control/star_field.cpp


diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index aaa2a99..325263d 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -457,6 +457,7 @@ MODULE_OBJS := \
 	star_control/star_field.o \
 	star_control/star_points1.o \
 	star_control/star_points2.o \
+	star_control/star_ref.o \
 	star_control/star_view.o \
 	star_control/surface_area.o \
 	star_control/surface_fader_base.o \
diff --git a/engines/titanic/star_control/base_star.cpp b/engines/titanic/star_control/base_star.cpp
index 552ef17..bce8d7c 100644
--- a/engines/titanic/star_control/base_star.cpp
+++ b/engines/titanic/star_control/base_star.cpp
@@ -22,6 +22,7 @@
 
 #include "titanic/star_control/base_star.h"
 #include "titanic/star_control/star_control_sub12.h"
+#include "titanic/star_control/star_ref.h"
 #include "titanic/titanic.h"
 
 namespace Titanic {
@@ -200,8 +201,9 @@ void CBaseStar::draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar
 	// TODO
 }
 
-void CBaseStar::baseFn1(int v1, int v2, int v3, int v4) {
-	// TODO
+void CBaseStar::baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
+		const Common::Point &pt) {
+	CStarRef1 ref(this, pt);
 }
 
 int CBaseStar::baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) {
diff --git a/engines/titanic/star_control/base_star.h b/engines/titanic/star_control/base_star.h
index c348b1f..1335980 100644
--- a/engines/titanic/star_control/base_star.h
+++ b/engines/titanic/star_control/base_star.h
@@ -53,6 +53,13 @@ struct CBaseStarEntry {
 	bool operator==(const CBaseStarEntry &s) const;
 };
 
+struct CStarPosition {
+	Common::Point _position;
+	int _index1;
+	int _index2;
+	CStarPosition() : _index1(0), _index2(0) {}
+};
+
 class CBaseStar {
 private:
 	void draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5);
@@ -82,9 +89,6 @@ protected:
 	 * Reset the data for an entry
 	 */
 	void resetEntry(CBaseStarEntry &entry);
-
-	void baseFn1(int v1, int v2, int v3, int v4);
-	int baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12);
 public:
 	CBaseStar();
 	virtual ~CBaseStar() {}
@@ -100,7 +104,7 @@ public:
 	 * Selects a star
 	 */
 	virtual bool selectStar(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
-		int flags, const Common::Point &pt) { return false; }
+		const Common::Point &pt, int flags = 0) { return false; }
 
 	/**
 	 * Adds a new star, or removes one if already present at the given co-ordinates
@@ -132,6 +136,11 @@ public:
 	 * Get a pointer to a data entry
 	 */
 	const CBaseStarEntry *getDataPtr(int index) const;
+
+	void baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
+		const Common::Point &pt);
+
+	int baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12);
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub2.cpp b/engines/titanic/star_control/star_control_sub2.cpp
index cf7190f..16830c2 100644
--- a/engines/titanic/star_control/star_control_sub2.cpp
+++ b/engines/titanic/star_control/star_control_sub2.cpp
@@ -31,7 +31,7 @@ bool CStarControlSub2::loadYale(int v1) {
 }
 
 bool CStarControlSub2::selectStar(CSurfaceArea *surfaceArea,
-		CStarControlSub12 *sub12, int flags, const Common::Point &pt) {
+		CStarControlSub12 *sub12, const Common::Point &pt, int flags) {
 	// TODO
 	return true;
 }
diff --git a/engines/titanic/star_control/star_control_sub2.h b/engines/titanic/star_control/star_control_sub2.h
index 9de2da4..d4d343c 100644
--- a/engines/titanic/star_control/star_control_sub2.h
+++ b/engines/titanic/star_control/star_control_sub2.h
@@ -37,7 +37,7 @@ public:
 	 * Selects a star
 	 */
 	virtual bool selectStar(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
-		int flags, const Common::Point &pt);
+		const Common::Point &pt, int flags = 0);
 
 	virtual bool loadStar();
 
diff --git a/engines/titanic/star_control/star_control_sub8.cpp b/engines/titanic/star_control/star_control_sub8.cpp
index 50c90d2..e82ae1d 100644
--- a/engines/titanic/star_control/star_control_sub8.cpp
+++ b/engines/titanic/star_control/star_control_sub8.cpp
@@ -24,18 +24,11 @@
 #include "titanic/star_control/star_control_sub7.h"
 #include "titanic/star_control/star_control_sub12.h"
 #include "titanic/star_control/star_field.h"
+#include "titanic/star_control/star_ref.h"
 
 namespace Titanic {
 
-CStarControlSub8::CStarControlSub8() : _field8(-1), _fieldC(-1) {
-#if 0
-	_field4(0), _field8(-1)
-#endif
-}
-
-bool MouseButtonDown(const Common::Point &pt) {
-	// TODO
-	return true;
+CStarControlSub8::CStarControlSub8() : _field8(-1), _entryIndex(-1) {
 }
 
 int CStarControlSub8::findStar(const Common::Point &pt) {
@@ -48,8 +41,21 @@ void CStarControlSub8::selectStar(int index, CVideoSurface *surface,
 	// TODO
 }
 
-void CStarControlSub8::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) {
+bool CStarControlSub8::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) {
+	int count = starField->baseFn2(surfaceArea, sub12);
+
+	if (count > 0) {
+		allocate(count);
+		CStarRef2 starRef(starField, &_positions);
+		starRef.process(surfaceArea, sub12);
+		return true;
+	} else {
+		clear();
+		return false;
+	}
+
 	// TODO
+	return true;
 }
 
 void CStarControlSub8::fn2(CVideoSurface *surface, CStarField *starField, CStarControlSub7 *sub7) {
@@ -62,14 +68,62 @@ void CStarControlSub8::fn3() {
 }
 
 FPoint CStarControlSub8::getPosition() const {
-	return (_fieldC >= 0 && _fieldC <= 2) ? _data[_fieldC]._position : FPoint();
+	return (_entryIndex >= 0 && _entryIndex <= 2) ? 
+		FPoint(_entries[_entryIndex].left, _entries[_entryIndex].top) : FPoint();
 }
 
 void CStarControlSub8::draw(CSurfaceArea *surfaceArea) {
-	// TODO
+	if (!_positions.empty()) {
+		uint oldPixel = surfaceArea->_pixel;
+		surfaceArea->_pixel = 0xFF;
+		surfaceArea->setColorFromPixel();
+		SurfaceAreaMode oldMode = surfaceArea->setMode(SA_NONE);
+
+		// TODO: Loop
+		/*
+		for (int idx = 0; idx < _entryIndex; ++idx) {
+			Common::Rect &r = _entries[idx];
+
+		}
+		*/
+
+		surfaceArea->_pixel = oldPixel;
+		surfaceArea->setMode(oldMode);
+	}
+}
+
+void CStarControlSub8::allocate(int count) {
+	if (!_positions.empty()) {
+		if ((int)_positions.size() == count)
+			return;
+
+		clear();
+	}
+
+	_positions.resize(count);
 }
 
 void CStarControlSub8::clear() {
+	_positions.clear();
+	_field8 = _entryIndex = -1;
+}
+
+int CStarControlSub8::indexOf(const Common::Point &pt) const {
+	Common::Rect r(pt.x - 2, pt.y - 2, pt.x + 2, pt.y + 2);
+
+	for (int idx = 0; idx < (int)_positions.size(); ++idx) {
+		if (r.contains(_positions[idx]._position))
+			return idx;
+	}
+
+	return -1;
+}
+
+void CStarControlSub8::fn4(int index, CSurfaceArea *surfaceArea) {
+	// TODO
+}
+
+void CStarControlSub8::fn5(int index, CVideoSurface *surface, CStarField *starField, CStarControlSub7 *sub7) {
 	// TODO
 }
 
diff --git a/engines/titanic/star_control/star_control_sub8.h b/engines/titanic/star_control/star_control_sub8.h
index f7f8ba4..1c0731f 100644
--- a/engines/titanic/star_control/star_control_sub8.h
+++ b/engines/titanic/star_control/star_control_sub8.h
@@ -23,6 +23,9 @@
 #ifndef TITANIC_STAR_CONTROL_SUB8_H
 #define TITANIC_STAR_CONTROL_SUB8_H
 
+#include "common/array.h"
+#include "common/rect.h"
+#include "titanic/star_control/base_star.h"
 #include "titanic/star_control/surface_area.h"
 #include "titanic/star_control/fpoint.h"
 #include "titanic/support/simple_file.h"
@@ -35,19 +38,20 @@ class CStarControlSub7;
 class CStarControlSub12;
 
 class CStarControlSub8 {
-	struct StructEntry {
-		FPoint _position;
-		int _field8;
-		int _fieldC;
-
-		StructEntry() : _field8(0), _fieldC(0) {}
-	};
 private:
-#if 0
-	int _field0;
-	int _field4;
-#endif
-	StructEntry _data[3];
+	Common::Array<CStarPosition> _positions;
+	int _entryIndex;
+	Common::Rect _entries[3];
+private:
+	/**
+	 * Allocates space in the _rects array
+	 */
+	void allocate(int count);
+
+	/**
+	 * Clears any current data
+	 */
+	void clear();
 public:
 	int _field8;
 	int _fieldC;
@@ -72,12 +76,18 @@ public:
 
 	void draw(CSurfaceArea *surfaceArea);
 
-	void fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarControlSub12 *sub12);
+	bool fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarControlSub12 *sub12);
 	void fn2(CVideoSurface *surface, CStarField *starField, CStarControlSub7 *sub7);
 	void fn3();
+	void fn4(int index, CSurfaceArea *surfaceArea);
+	void fn5(int index, CVideoSurface *surface, CStarField *starField, CStarControlSub7 *sub7);
+
 	FPoint getPosition() const;
 
-	void clear();
+	/**
+	 * Returns the index of an entry in the rects list a given point falls within
+	 */
+	int indexOf(const Common::Point &pt) const;
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_field.cpp b/engines/titanic/star_control/star_field.cpp
index 3a09be3..07c5ff4 100644
--- a/engines/titanic/star_control/star_field.cpp
+++ b/engines/titanic/star_control/star_field.cpp
@@ -230,7 +230,7 @@ bool CStarField::mouseButtonDown(CVideoSurface *surface, CStarControlSub12 *sub1
 		int flags, const Common::Point &pt) {
 	if (_mode == MODE_STARFIELD) {
 		CSurfaceArea surfaceArea(surface);
-		return selectStar(&surfaceArea, sub12, 0, pt);
+		return selectStar(&surfaceArea, sub12, pt);
 	} else {
 		int starNum = _sub8.findStar(pt);
 		if (starNum >= 0) {
diff --git a/engines/titanic/star_control/star_ref.cpp b/engines/titanic/star_control/star_ref.cpp
new file mode 100644
index 0000000..f583d72
--- /dev/null
+++ b/engines/titanic/star_control/star_ref.cpp
@@ -0,0 +1,62 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/star_control/star_ref.h"
+
+namespace Titanic {
+
+void CBaseStarRef::process(CSurfaceArea *surface, CStarControlSub12 *sub12) {
+	// TODO
+}
+
+/*------------------------------------------------------------------------*/
+
+bool CStarRef1::check(const Common::Point &pt, int index) {
+	Common::Rect r(pt.x - 2, pt.y - 2, pt.x + 2, pt.y + 2);
+	if (r.contains(_position)) {
+		_index = index;
+		return false;
+	} else {
+		return true;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+bool CStarRef2::check(const Common::Point &pt, int index) {
+	if (_index >= (int)_positions->size())
+		return false;
+
+	CStarPosition &sp = (*_positions)[index];
+	sp._position = pt;
+	sp._index1 = sp._index2 = index;
+	return true;
+}
+
+/*------------------------------------------------------------------------*/
+
+bool CStarRef3::check(const Common::Point &pt, int index) {
+	++_counter;
+	return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_ref.h b/engines/titanic/star_control/star_ref.h
new file mode 100644
index 0000000..48d8b32
--- /dev/null
+++ b/engines/titanic/star_control/star_ref.h
@@ -0,0 +1,78 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/rect.h"
+#include "titanic/star_control/base_star.h"
+#include "titanic/star_control/star_control_sub12.h"
+#include "titanic/star_control/surface_area.h"
+
+#ifndef TITANIC_STAR_REF_H
+#define TITANIC_STAR_REF_H
+
+namespace Titanic {
+
+class CBaseStarRef {
+protected:
+	CBaseStar *_star;
+public:
+	CBaseStarRef(CBaseStar *star) : _star(star) {}
+	CBaseStarRef() : _star(nullptr) {}
+
+	void process(CSurfaceArea *surface, CStarControlSub12 *sub12);
+
+	virtual bool check(const Common::Point &pt, int index) { return false; }
+};
+
+class CStarRef1 : public CBaseStarRef {
+private:
+	Common::Point _position;
+	int _index;
+public:
+	CStarRef1(CBaseStar *star, const Common::Point &pt) :
+		CBaseStarRef(star), _index(-1) {}
+
+	virtual bool check(const Common::Point &pt, int index);
+};
+
+class CStarRef2 : public CBaseStarRef {
+private:
+	Common::Array<CStarPosition> *_positions;
+	int _index;
+public:
+	CStarRef2(CBaseStar *star, Common::Array<CStarPosition> *positions) :
+		CBaseStarRef(star), _positions(positions), _index(0) {}
+
+	virtual bool check(const Common::Point &pt, int index);
+};
+
+class CStarRef3 : public CBaseStarRef {
+private:
+	int _counter;
+public:
+	CStarRef3(CBaseStar *star) :CBaseStarRef(star), _counter(0) {}
+
+	virtual bool check(const Common::Point &pt, int index);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_STAR_REF_H */





More information about the Scummvm-git-logs mailing list