[Scummvm-git-logs] scummvm master -> 6e46535c92fdfcc3a69b1dbec3f46dc5f818b6bf

dreammaster dreammaster at scummvm.org
Wed May 31 01:23:38 CEST 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:
6e46535c92 TITANIC: Rename CPhotoCrosshairs to CStarCrosshairs


Commit: 6e46535c92fdfcc3a69b1dbec3f46dc5f818b6bf
    https://github.com/scummvm/scummvm/commit/6e46535c92fdfcc3a69b1dbec3f46dc5f818b6bf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-05-30T19:22:27-04:00

Commit Message:
TITANIC: Rename CPhotoCrosshairs to CStarCrosshairs

The crosshairs are used in the main starfield as well, so they
shouldn't have a Photo specific name

Changed paths:
  A engines/titanic/star_control/star_crosshairs.cpp
  A engines/titanic/star_control/star_crosshairs.h
  R engines/titanic/star_control/photo_crosshairs.cpp
  R engines/titanic/star_control/photo_crosshairs.h
    engines/titanic/module.mk
    engines/titanic/star_control/star_field.cpp
    engines/titanic/star_control/star_field.h


diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index dc6b9b7..1e85874 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -443,7 +443,6 @@ MODULE_OBJS := \
 	star_control/fvector.o \
 	star_control/matrix_transform.o \
 	star_control/orientation_changer.o \
-	star_control/photo_crosshairs.o \
 	star_control/star_camera.o \
 	star_control/star_closeup.o \
 	star_control/star_control_sub2.o \
@@ -452,6 +451,7 @@ MODULE_OBJS := \
 	star_control/star_control_sub23.o \
 	star_control/star_control_sub24.o \
 	star_control/star_control_sub27.o \
+	star_control/star_crosshairs.o \
 	star_control/star_field.o \
 	star_control/star_markers.o \
 	star_control/star_points1.o \
diff --git a/engines/titanic/star_control/photo_crosshairs.cpp b/engines/titanic/star_control/photo_crosshairs.cpp
deleted file mode 100644
index eb6268c..0000000
--- a/engines/titanic/star_control/photo_crosshairs.cpp
+++ /dev/null
@@ -1,249 +0,0 @@
-/* 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/photo_crosshairs.h"
-#include "titanic/star_control/star_markers.h"
-#include "titanic/star_control/star_camera.h"
-#include "titanic/star_control/star_field.h"
-#include "titanic/star_control/star_ref.h"
-
-namespace Titanic {
-
-CPhotoCrosshairs::CPhotoCrosshairs() : _matchIndex(-1), _entryIndex(-1) {
-}
-
-void CPhotoCrosshairs::selectStar(int index, CVideoSurface *surface,
-		CStarField *starField, CStarMarkers *markers) {
-	if (_entryIndex >= 0) {
-		// There are existing selected stars already
-		if (_entryIndex == _matchIndex) {
-			// All the stars selected so far have been matched. Only allow
-			// a selection addition if not all three stars have been found
-			if (!isSolved()) {
-				// Don't allow the most recent match to be re-selected
-				if (_positions[index] != _entries[_entryIndex]) {
-					surface->lock();
-
-					// Draw crosshairs around the selected star
-					CSurfaceArea surfaceArea(surface);
-					drawStar(index, &surfaceArea);
-					surface->unlock();
-
-					// Copy the star into the list of selected ones
-					++_entryIndex;
-					CStarPosition &newP = _entries[_entryIndex];
-					newP = _positions[index];
-
-					// Set up a marker in the main starfield for that same star
-					const CBaseStarEntry *starP = starField->getDataPtr(newP._index1);
-					markers->addStar(starP);
-				}
-			}
-		} else if (_entryIndex == _matchIndex + 1) {
-			// There is a most recently selected star that has not yet been matched.
-			// So we allow the user to reselect it to remove the selection, or shift
-			// the selection to some other star
-			if (_positions[index] == _entries[_entryIndex]) {
-				// Remove the crosshairs for the previously selected star
-				surface->lock();
-				CSurfaceArea surfaceArea(surface);
-				eraseCurrent(&surfaceArea);
-				surface->unlock();
-
-				// Decrement number of selections
-				--_entryIndex;
-
-				// Call the markers addStar method, which will remove the existing marker
-				const CBaseStarEntry *starP = starField->getDataPtr(_positions[index]._index1);
-				markers->addStar(starP);
-			} else {
-				// Erase the prior selection and draw the new one
-				surface->lock();
-				CSurfaceArea surfaceArea(surface);
-				eraseCurrent(&surfaceArea);
-				drawStar(index, &surfaceArea);
-				surface->unlock();
-
-				// Remove the old selection from the starfield markers
-				const CBaseStarEntry *starP;
-				starP = starField->getDataPtr(_entries[_entryIndex]._index1);
-				markers->addStar(starP);
-
-				// Add the new selection to the markers list
-				starP = starField->getDataPtr(_positions[index]._index1);
-				markers->addStar(starP);
-
-				// Copy the newly selected star's details into our selections list
-				CStarPosition &newP = _entries[_entryIndex];
-				newP = _positions[index];
-			}
-		}
-	} else {
-		// Very first star being selected
-		// Draw crosshairs around the selected star
-		surface->lock();
-		CSurfaceArea surfaceArea(surface);
-		drawStar(index, &surfaceArea);
-		surface->unlock();
-
-		// Copy the star into the list of selected ones
-		++_entryIndex;
-		const CStarPosition &srcPos = _positions[index];
-		CStarPosition &destPos = _entries[_entryIndex];
-		destPos = srcPos;
-
-		// Set up a marker in the main starfield for that same star
-		const CBaseStarEntry *starP = starField->getDataPtr(destPos._index1);
-		markers->addStar(starP);
-	}
-}
-
-bool CPhotoCrosshairs::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarCamera *camera) {
-	int count = starField->baseFn2(surfaceArea, camera);
-
-	if (count > 0) {
-		allocate(count);
-		CStarRefArray starRef(starField, &_positions);
-		starRef.process(surfaceArea, camera);
-		return true;
-	} else {
-		clear();
-		return false;
-	}
-}
-
-void CPhotoCrosshairs::fn2(CVideoSurface *surface, CStarField *starField, CStarMarkers *markers) {
-	if (_matchIndex <= -1) {
-		if (_entryIndex > -1) {
-			drawEntry(_entryIndex, surface, starField, markers);
-			--_entryIndex;
-		}
-	} else {
-		--_matchIndex;
-		if (_entryIndex - _matchIndex > 1) {
-			drawEntry(_entryIndex, surface, starField, markers);
-			--_entryIndex;
-		}
-	}
-}
-
-void CPhotoCrosshairs::incMatches() {
-	if (_matchIndex < 3)
-		++_matchIndex;
-}
-
-FPoint CPhotoCrosshairs::getPosition() const {
-	return (_entryIndex >= 0 && _entryIndex <= 2) ? 
-		FPoint(_entries[_entryIndex]) : FPoint();
-}
-
-void CPhotoCrosshairs::draw(CSurfaceArea *surfaceArea) {
-	if (!_positions.empty()) {
-		uint savedPixel = surfaceArea->_pixel;
-		surfaceArea->_pixel = 0xff;
-		surfaceArea->setColorFromPixel();
-		SurfaceAreaMode savedMode = surfaceArea->setMode(SA_NONE);
-
-		for (int idx = 0; idx < _entryIndex; ++idx) {
-			const CStarPosition &src = _entries[idx];
-			double xp = src.x, yp = src.y;
-
-			surfaceArea->drawLine(FRect(xp - 8.0, yp, xp - 4.0, yp));
-			surfaceArea->drawLine(FRect(xp + 4.0, yp, xp + 8.0, yp));
-			surfaceArea->drawLine(FRect(xp, yp - 8.0, xp, yp - 4.0));
-			surfaceArea->drawLine(FRect(xp, yp + 4.0, xp, yp + 8.0));
-		}
-
-		surfaceArea->_pixel = savedPixel;
-		surfaceArea->setColorFromPixel();
-		surfaceArea->setMode(savedMode);
-	}
-}
-
-void CPhotoCrosshairs::allocate(int count) {
-	if (!_positions.empty()) {
-		if ((int)_positions.size() == count)
-			return;
-
-		clear();
-	}
-
-	_positions.resize(count);
-}
-
-void CPhotoCrosshairs::clear() {
-	_positions.clear();
-	_matchIndex = _entryIndex = -1;
-}
-
-int CPhotoCrosshairs::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]))
-			return idx;
-	}
-
-	return -1;
-}
-
-void CPhotoCrosshairs::drawStar(int index, CSurfaceArea *surfaceArea) {
-	if (index >= 0 && index < (int)_positions.size()) {
-		const CStarPosition &pt = _positions[index];
-		drawAt(pt, surfaceArea);
-	}
-}
-
-void CPhotoCrosshairs::drawEntry(int index, CVideoSurface *surface, CStarField *starField, CStarMarkers *markers) {
-	surface->lock();
-	CSurfaceArea surfaceArea(surface);
-	drawAt(_entries[index], &surfaceArea);
-	surface->unlock();
-
-	const CBaseStarEntry *starP = starField->getDataPtr(_entries[index]._index1);
-	markers->addStar(starP);
-}
-
-void CPhotoCrosshairs::eraseCurrent(CSurfaceArea *surfaceArea) {
-	assert(_entryIndex >= 0);
-	const CStarPosition &pt = _entries[_entryIndex];
-	drawAt(pt, surfaceArea);
-}
-
-void CPhotoCrosshairs::drawAt(const FPoint &pt, CSurfaceArea *surfaceArea) {
-	uint savedPixel = surfaceArea->_pixel;
-	surfaceArea->_pixel = 255;
-	surfaceArea->setColorFromPixel();
-	SurfaceAreaMode savedMode = surfaceArea->setMode(SA_XOR);
-
-
-	surfaceArea->drawLine(FRect(pt._x - 8.0, pt._y, pt._x - 4.0, pt._y));
-	surfaceArea->drawLine(FRect(pt._x + 4.0, pt._y, pt._x + 8.0, pt._y));
-	surfaceArea->drawLine(FRect(pt._x, pt._y - 8.0, pt._x, pt._y - 4.0));
-	surfaceArea->drawLine(FRect(pt._x, pt._y + 4.0, pt._x, pt._y + 8.0));
-
-	surfaceArea->_pixel = savedPixel;
-	surfaceArea->setColorFromPixel();
-	surfaceArea->setMode(savedMode);
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/star_control/photo_crosshairs.h b/engines/titanic/star_control/photo_crosshairs.h
deleted file mode 100644
index 9f78a2d..0000000
--- a/engines/titanic/star_control/photo_crosshairs.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* 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.
- *
- */
-
-#ifndef TITANIC_PHOTO_CROSSHAIRS_H
-#define TITANIC_PHOTO_CROSSHAIRS_H
-
-#include "common/array.h"
-#include "common/rect.h"
-#include "titanic/star_control/base_stars.h"
-#include "titanic/star_control/surface_area.h"
-#include "titanic/star_control/fpoint.h"
-#include "titanic/support/simple_file.h"
-#include "titanic/support/video_surface.h"
-
-namespace Titanic {
-
-class CStarField;
-class CStarMarkers;
-class CStarCamera;
-
-class CPhotoCrosshairs {
-private:
-	Common::Array<CStarPosition> _positions;
-	CStarPosition _entries[3];
-private:
-	/**
-	 * Allocates space in the _rects array
-	 */
-	void allocate(int count);
-
-	/**
-	 * Clears any current data
-	 */
-	void clear();
-public:
-	int _matchIndex;
-	int _entryIndex;
-public:
-	CPhotoCrosshairs();
-	~CPhotoCrosshairs() { clear(); }
-
-	/**
-	 * Load the data for the class from file
-	 */
-	void load(SimpleFile *file) {}
-
-	/**
-	 * Save the data for the class to file
-	 */
-	void save(SimpleFile *file, int indent) {}
-
-	/**
-	 * Returns true if there are no crosshairs present
-	 */
-	bool isEmpty() const { return _entryIndex == -1; }
-
-	void selectStar(int starNum, CVideoSurface *surface, CStarField *starField,
-		CStarMarkers *markers);
-
-	void draw(CSurfaceArea *surfaceArea);
-
-	bool fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarCamera *camera);
-	void fn2(CVideoSurface *surface, CStarField *starField, CStarMarkers *markers);
-	
-	/**
-	 * Increments the index for the number of matches
-	 */
-	void incMatches();
-	
-	/**
-	 * Draw the crosshairs for a given star
-	 */
-	void drawStar(int index, CSurfaceArea *surfaceArea);
-
-	/**
-	 * Draws the crosshairs for a specified entry, and adds the star
-	 * to the starfield markers
-	 */
-	void drawEntry(int index, CVideoSurface *surface, CStarField *starField, CStarMarkers *markers);
-
-	/**
-	 * Erase crosshairs for the most recently selected star
-	 */
-	void eraseCurrent(CSurfaceArea *surfaceArea);
-	
-	/**
-	 * Draw crosshairs at the given position
-	 */
-	void drawAt(const FPoint &pt, CSurfaceArea *surfaceArea);
-	
-	/**
-	 * Returns the position of the most recently selected star
-	 */
-	FPoint getPosition() const;
-
-	/**
-	 * Returns the index of an entry in the rects list a given point falls within
-	 */
-	int indexOf(const Common::Point &pt) const;
-
-	/**
-	 * Returns true if the starfield is solved
-	 */
-	bool isSolved() const { return _matchIndex == 2; }
-};
-
-} // End of namespace Titanic
-
-#endif /* TITANIC_PHOTO_CROSSHAIRS_H */
diff --git a/engines/titanic/star_control/star_crosshairs.cpp b/engines/titanic/star_control/star_crosshairs.cpp
new file mode 100644
index 0000000..2f64505
--- /dev/null
+++ b/engines/titanic/star_control/star_crosshairs.cpp
@@ -0,0 +1,249 @@
+/* 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_crosshairs.h"
+#include "titanic/star_control/star_markers.h"
+#include "titanic/star_control/star_camera.h"
+#include "titanic/star_control/star_field.h"
+#include "titanic/star_control/star_ref.h"
+
+namespace Titanic {
+
+CStarCrosshairs::CStarCrosshairs() : _matchIndex(-1), _entryIndex(-1) {
+}
+
+void CStarCrosshairs::selectStar(int index, CVideoSurface *surface,
+		CStarField *starField, CStarMarkers *markers) {
+	if (_entryIndex >= 0) {
+		// There are existing selected stars already
+		if (_entryIndex == _matchIndex) {
+			// All the stars selected so far have been matched. Only allow
+			// a selection addition if not all three stars have been found
+			if (!isSolved()) {
+				// Don't allow the most recent match to be re-selected
+				if (_positions[index] != _entries[_entryIndex]) {
+					surface->lock();
+
+					// Draw crosshairs around the selected star
+					CSurfaceArea surfaceArea(surface);
+					drawStar(index, &surfaceArea);
+					surface->unlock();
+
+					// Copy the star into the list of selected ones
+					++_entryIndex;
+					CStarPosition &newP = _entries[_entryIndex];
+					newP = _positions[index];
+
+					// Set up a marker in the main starfield for that same star
+					const CBaseStarEntry *starP = starField->getDataPtr(newP._index1);
+					markers->addStar(starP);
+				}
+			}
+		} else if (_entryIndex == _matchIndex + 1) {
+			// There is a most recently selected star that has not yet been matched.
+			// So we allow the user to reselect it to remove the selection, or shift
+			// the selection to some other star
+			if (_positions[index] == _entries[_entryIndex]) {
+				// Remove the crosshairs for the previously selected star
+				surface->lock();
+				CSurfaceArea surfaceArea(surface);
+				eraseCurrent(&surfaceArea);
+				surface->unlock();
+
+				// Decrement number of selections
+				--_entryIndex;
+
+				// Call the markers addStar method, which will remove the existing marker
+				const CBaseStarEntry *starP = starField->getDataPtr(_positions[index]._index1);
+				markers->addStar(starP);
+			} else {
+				// Erase the prior selection and draw the new one
+				surface->lock();
+				CSurfaceArea surfaceArea(surface);
+				eraseCurrent(&surfaceArea);
+				drawStar(index, &surfaceArea);
+				surface->unlock();
+
+				// Remove the old selection from the starfield markers
+				const CBaseStarEntry *starP;
+				starP = starField->getDataPtr(_entries[_entryIndex]._index1);
+				markers->addStar(starP);
+
+				// Add the new selection to the markers list
+				starP = starField->getDataPtr(_positions[index]._index1);
+				markers->addStar(starP);
+
+				// Copy the newly selected star's details into our selections list
+				CStarPosition &newP = _entries[_entryIndex];
+				newP = _positions[index];
+			}
+		}
+	} else {
+		// Very first star being selected
+		// Draw crosshairs around the selected star
+		surface->lock();
+		CSurfaceArea surfaceArea(surface);
+		drawStar(index, &surfaceArea);
+		surface->unlock();
+
+		// Copy the star into the list of selected ones
+		++_entryIndex;
+		const CStarPosition &srcPos = _positions[index];
+		CStarPosition &destPos = _entries[_entryIndex];
+		destPos = srcPos;
+
+		// Set up a marker in the main starfield for that same star
+		const CBaseStarEntry *starP = starField->getDataPtr(destPos._index1);
+		markers->addStar(starP);
+	}
+}
+
+bool CStarCrosshairs::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarCamera *camera) {
+	int count = starField->baseFn2(surfaceArea, camera);
+
+	if (count > 0) {
+		allocate(count);
+		CStarRefArray starRef(starField, &_positions);
+		starRef.process(surfaceArea, camera);
+		return true;
+	} else {
+		clear();
+		return false;
+	}
+}
+
+void CStarCrosshairs::fn2(CVideoSurface *surface, CStarField *starField, CStarMarkers *markers) {
+	if (_matchIndex <= -1) {
+		if (_entryIndex > -1) {
+			drawEntry(_entryIndex, surface, starField, markers);
+			--_entryIndex;
+		}
+	} else {
+		--_matchIndex;
+		if (_entryIndex - _matchIndex > 1) {
+			drawEntry(_entryIndex, surface, starField, markers);
+			--_entryIndex;
+		}
+	}
+}
+
+void CStarCrosshairs::incMatches() {
+	if (_matchIndex < 3)
+		++_matchIndex;
+}
+
+FPoint CStarCrosshairs::getPosition() const {
+	return (_entryIndex >= 0 && _entryIndex <= 2) ? 
+		FPoint(_entries[_entryIndex]) : FPoint();
+}
+
+void CStarCrosshairs::draw(CSurfaceArea *surfaceArea) {
+	if (!_positions.empty()) {
+		uint savedPixel = surfaceArea->_pixel;
+		surfaceArea->_pixel = 0xff;
+		surfaceArea->setColorFromPixel();
+		SurfaceAreaMode savedMode = surfaceArea->setMode(SA_NONE);
+
+		for (int idx = 0; idx < _entryIndex; ++idx) {
+			const CStarPosition &src = _entries[idx];
+			double xp = src.x, yp = src.y;
+
+			surfaceArea->drawLine(FRect(xp - 8.0, yp, xp - 4.0, yp));
+			surfaceArea->drawLine(FRect(xp + 4.0, yp, xp + 8.0, yp));
+			surfaceArea->drawLine(FRect(xp, yp - 8.0, xp, yp - 4.0));
+			surfaceArea->drawLine(FRect(xp, yp + 4.0, xp, yp + 8.0));
+		}
+
+		surfaceArea->_pixel = savedPixel;
+		surfaceArea->setColorFromPixel();
+		surfaceArea->setMode(savedMode);
+	}
+}
+
+void CStarCrosshairs::allocate(int count) {
+	if (!_positions.empty()) {
+		if ((int)_positions.size() == count)
+			return;
+
+		clear();
+	}
+
+	_positions.resize(count);
+}
+
+void CStarCrosshairs::clear() {
+	_positions.clear();
+	_matchIndex = _entryIndex = -1;
+}
+
+int CStarCrosshairs::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]))
+			return idx;
+	}
+
+	return -1;
+}
+
+void CStarCrosshairs::drawStar(int index, CSurfaceArea *surfaceArea) {
+	if (index >= 0 && index < (int)_positions.size()) {
+		const CStarPosition &pt = _positions[index];
+		drawAt(pt, surfaceArea);
+	}
+}
+
+void CStarCrosshairs::drawEntry(int index, CVideoSurface *surface, CStarField *starField, CStarMarkers *markers) {
+	surface->lock();
+	CSurfaceArea surfaceArea(surface);
+	drawAt(_entries[index], &surfaceArea);
+	surface->unlock();
+
+	const CBaseStarEntry *starP = starField->getDataPtr(_entries[index]._index1);
+	markers->addStar(starP);
+}
+
+void CStarCrosshairs::eraseCurrent(CSurfaceArea *surfaceArea) {
+	assert(_entryIndex >= 0);
+	const CStarPosition &pt = _entries[_entryIndex];
+	drawAt(pt, surfaceArea);
+}
+
+void CStarCrosshairs::drawAt(const FPoint &pt, CSurfaceArea *surfaceArea) {
+	uint savedPixel = surfaceArea->_pixel;
+	surfaceArea->_pixel = 255;
+	surfaceArea->setColorFromPixel();
+	SurfaceAreaMode savedMode = surfaceArea->setMode(SA_XOR);
+
+
+	surfaceArea->drawLine(FRect(pt._x - 8.0, pt._y, pt._x - 4.0, pt._y));
+	surfaceArea->drawLine(FRect(pt._x + 4.0, pt._y, pt._x + 8.0, pt._y));
+	surfaceArea->drawLine(FRect(pt._x, pt._y - 8.0, pt._x, pt._y - 4.0));
+	surfaceArea->drawLine(FRect(pt._x, pt._y + 4.0, pt._x, pt._y + 8.0));
+
+	surfaceArea->_pixel = savedPixel;
+	surfaceArea->setColorFromPixel();
+	surfaceArea->setMode(savedMode);
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_crosshairs.h b/engines/titanic/star_control/star_crosshairs.h
new file mode 100644
index 0000000..e91e245
--- /dev/null
+++ b/engines/titanic/star_control/star_crosshairs.h
@@ -0,0 +1,128 @@
+/* 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.
+ *
+ */
+
+#ifndef TITANIC_STAR_CROSSHAIRS_H
+#define TITANIC_STAR_CROSSHAIRS_H
+
+#include "common/array.h"
+#include "common/rect.h"
+#include "titanic/star_control/base_stars.h"
+#include "titanic/star_control/surface_area.h"
+#include "titanic/star_control/fpoint.h"
+#include "titanic/support/simple_file.h"
+#include "titanic/support/video_surface.h"
+
+namespace Titanic {
+
+class CStarField;
+class CStarMarkers;
+class CStarCamera;
+
+class CStarCrosshairs {
+private:
+	Common::Array<CStarPosition> _positions;
+	CStarPosition _entries[3];
+private:
+	/**
+	 * Allocates space in the _rects array
+	 */
+	void allocate(int count);
+
+	/**
+	 * Clears any current data
+	 */
+	void clear();
+public:
+	int _matchIndex;
+	int _entryIndex;
+public:
+	CStarCrosshairs();
+	~CStarCrosshairs() { clear(); }
+
+	/**
+	 * Load the data for the class from file
+	 */
+	void load(SimpleFile *file) {}
+
+	/**
+	 * Save the data for the class to file
+	 */
+	void save(SimpleFile *file, int indent) {}
+
+	/**
+	 * Returns true if there are no crosshairs present
+	 */
+	bool isEmpty() const { return _entryIndex == -1; }
+
+	void selectStar(int starNum, CVideoSurface *surface, CStarField *starField,
+		CStarMarkers *markers);
+
+	void draw(CSurfaceArea *surfaceArea);
+
+	bool fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarCamera *camera);
+	void fn2(CVideoSurface *surface, CStarField *starField, CStarMarkers *markers);
+	
+	/**
+	 * Increments the index for the number of matches
+	 */
+	void incMatches();
+	
+	/**
+	 * Draw the crosshairs for a given star
+	 */
+	void drawStar(int index, CSurfaceArea *surfaceArea);
+
+	/**
+	 * Draws the crosshairs for a specified entry, and adds the star
+	 * to the starfield markers
+	 */
+	void drawEntry(int index, CVideoSurface *surface, CStarField *starField, CStarMarkers *markers);
+
+	/**
+	 * Erase crosshairs for the most recently selected star
+	 */
+	void eraseCurrent(CSurfaceArea *surfaceArea);
+	
+	/**
+	 * Draw crosshairs at the given position
+	 */
+	void drawAt(const FPoint &pt, CSurfaceArea *surfaceArea);
+	
+	/**
+	 * Returns the position of the most recently selected star
+	 */
+	FPoint getPosition() const;
+
+	/**
+	 * Returns the index of an entry in the rects list a given point falls within
+	 */
+	int indexOf(const Common::Point &pt) const;
+
+	/**
+	 * Returns true if the starfield is solved
+	 */
+	bool isSolved() const { return _matchIndex == 2; }
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_STAR_CROSSHAIRS_H */
diff --git a/engines/titanic/star_control/star_field.cpp b/engines/titanic/star_control/star_field.cpp
index aad6382..669423b 100644
--- a/engines/titanic/star_control/star_field.cpp
+++ b/engines/titanic/star_control/star_field.cpp
@@ -67,7 +67,7 @@ void CStarField::render(CVideoSurface *surface, CStarCamera *camera) {
 	CSurfaceArea surfaceArea(surface);
 	draw(&surfaceArea, camera, &_starCloseup);
 	if (_showCrosshairs)
-		drawCrosshairs(&surfaceArea);
+		drawBox(&surfaceArea);
 
 	_markers.draw(&surfaceArea, camera, nullptr);
 	_crosshairs.draw(&surfaceArea);
@@ -142,7 +142,7 @@ void CStarField::fn1(CErrorCode *errorCode) {
 	_starCloseup.proc3(errorCode);
 }
 
-void CStarField::drawCrosshairs(CSurfaceArea *surfaceArea) {
+void CStarField::drawBox(CSurfaceArea *surfaceArea) {
 	uint oldPixel = surfaceArea->_pixel;
 	surfaceArea->_pixel = 0x323232;
 	surfaceArea->setColorFromPixel();
diff --git a/engines/titanic/star_control/star_field.h b/engines/titanic/star_control/star_field.h
index a014894..ecac23e 100644
--- a/engines/titanic/star_control/star_field.h
+++ b/engines/titanic/star_control/star_field.h
@@ -26,7 +26,7 @@
 #include "titanic/star_control/star_control_sub2.h"
 #include "titanic/star_control/star_closeup.h"
 #include "titanic/star_control/star_markers.h"
-#include "titanic/star_control/photo_crosshairs.h"
+#include "titanic/star_control/star_crosshairs.h"
 #include "titanic/star_control/star_points1.h"
 #include "titanic/star_control/star_points2.h"
 
@@ -35,7 +35,7 @@ namespace Titanic {
 class CStarField : public CStarControlSub2 {
 private:
 	CStarMarkers _markers;
-	CPhotoCrosshairs _crosshairs;
+	CStarCrosshairs _crosshairs;
 	CStarPoints1 _points1;
 	CStarPoints2 _points2;
 	CStarCloseup _starCloseup;
@@ -47,9 +47,9 @@ private:
 	bool _isSolved;
 private:
 	/**
-	 * Draws the square box crosshairs in the middle of the screen
+	 * Draws the big square box in the middle of the screen
 	 */
-	void drawCrosshairs(CSurfaceArea *surfaceArea);
+	void drawBox(CSurfaceArea *surfaceArea);
 
 	void fn4(CSurfaceArea *surfaceArea, CStarCamera *camera);
 public:





More information about the Scummvm-git-logs mailing list