Skip to content

Commit

Permalink
TITANIC: Rename CStarControlSub8 to CPhotoCrosshairs
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed May 28, 2017
1 parent 99ce2f6 commit 6587cac
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion engines/titanic/module.mk
Expand Up @@ -443,11 +443,11 @@ 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 \
star_control/star_control_sub7.o \
star_control/star_control_sub8.o \
star_control/star_control_sub21.o \
star_control/star_control_sub22.o \
star_control/star_control_sub23.o \
Expand Down
Expand Up @@ -20,18 +20,18 @@
*
*/

#include "titanic/star_control/star_control_sub8.h"
#include "titanic/star_control/photo_crosshairs.h"
#include "titanic/star_control/star_control_sub7.h"
#include "titanic/star_control/star_camera.h"
#include "titanic/star_control/star_field.h"
#include "titanic/star_control/star_ref.h"

namespace Titanic {

CStarControlSub8::CStarControlSub8() : _field8(-1), _entryIndex(-1) {
CPhotoCrosshairs::CPhotoCrosshairs() : _field8(-1), _entryIndex(-1) {
}

void CStarControlSub8::selectStar(int index, CVideoSurface *surface,
void CPhotoCrosshairs::selectStar(int index, CVideoSurface *surface,
CStarField *starField, CStarControlSub7 *sub7) {
if (_entryIndex >= 0) {
if (_entryIndex == _field8) {
Expand Down Expand Up @@ -93,7 +93,7 @@ void CStarControlSub8::selectStar(int index, CVideoSurface *surface,
}
}

bool CStarControlSub8::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarCamera *camera) {
bool CPhotoCrosshairs::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarCamera *camera) {
int count = starField->baseFn2(surfaceArea, camera);

if (count > 0) {
Expand All @@ -107,7 +107,7 @@ bool CStarControlSub8::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CSt
}
}

void CStarControlSub8::fn2(CVideoSurface *surface, CStarField *starField, CStarControlSub7 *sub7) {
void CPhotoCrosshairs::fn2(CVideoSurface *surface, CStarField *starField, CStarControlSub7 *sub7) {
if (_field8 <= -1) {
if (_entryIndex > -1) {
fn5(_entryIndex, surface, starField, sub7);
Expand All @@ -122,17 +122,17 @@ void CStarControlSub8::fn2(CVideoSurface *surface, CStarField *starField, CStarC
}
}

void CStarControlSub8::fn3() {
void CPhotoCrosshairs::fn3() {
if (_field8 < 3)
++_field8;
}

FPoint CStarControlSub8::getPosition() const {
FPoint CPhotoCrosshairs::getPosition() const {
return (_entryIndex >= 0 && _entryIndex <= 2) ?
FPoint(_entries[_entryIndex]) : FPoint();
}

void CStarControlSub8::draw(CSurfaceArea *surfaceArea) {
void CPhotoCrosshairs::draw(CSurfaceArea *surfaceArea) {
if (!_positions.empty()) {
uint savedPixel = surfaceArea->_pixel;
surfaceArea->_pixel = 0xff;
Expand All @@ -155,7 +155,7 @@ void CStarControlSub8::draw(CSurfaceArea *surfaceArea) {
}
}

void CStarControlSub8::allocate(int count) {
void CPhotoCrosshairs::allocate(int count) {
if (!_positions.empty()) {
if ((int)_positions.size() == count)
return;
Expand All @@ -166,12 +166,12 @@ void CStarControlSub8::allocate(int count) {
_positions.resize(count);
}

void CStarControlSub8::clear() {
void CPhotoCrosshairs::clear() {
_positions.clear();
_field8 = _entryIndex = -1;
}

int CStarControlSub8::indexOf(const Common::Point &pt) const {
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) {
Expand All @@ -182,14 +182,14 @@ int CStarControlSub8::indexOf(const Common::Point &pt) const {
return -1;
}

void CStarControlSub8::fn4(int index, CSurfaceArea *surfaceArea) {
void CPhotoCrosshairs::fn4(int index, CSurfaceArea *surfaceArea) {
if (index >= 0 && index < (int)_positions.size()) {
const CStarPosition &pt = _positions[index];
fn7(pt, surfaceArea);
}
}

void CStarControlSub8::fn5(int index, CVideoSurface *surface, CStarField *starField, CStarControlSub7 *sub7) {
void CPhotoCrosshairs::fn5(int index, CVideoSurface *surface, CStarField *starField, CStarControlSub7 *sub7) {
surface->lock();
CSurfaceArea surfaceArea(surface);
fn7(_positions[index + 1], &surfaceArea);
Expand All @@ -199,12 +199,12 @@ void CStarControlSub8::fn5(int index, CVideoSurface *surface, CStarField *starFi
sub7->addStar(starP);
}

void CStarControlSub8::fn6(CSurfaceArea *surfaceArea) {
void CPhotoCrosshairs::fn6(CSurfaceArea *surfaceArea) {
const CStarPosition &pt = _positions[_entryIndex];
fn7(pt, surfaceArea);
}

void CStarControlSub8::fn7(const FPoint &pt, CSurfaceArea *surfaceArea) {
void CPhotoCrosshairs::fn7(const FPoint &pt, CSurfaceArea *surfaceArea) {
uint savedPixel = surfaceArea->_pixel;
surfaceArea->_pixel = 255;
surfaceArea->setColorFromPixel();
Expand Down
Expand Up @@ -20,8 +20,8 @@
*
*/

#ifndef TITANIC_STAR_CONTROL_SUB8_H
#define TITANIC_STAR_CONTROL_SUB8_H
#ifndef TITANIC_PHOTO_CROSSHAIRS_H
#define TITANIC_PHOTO_CROSSHAIRS_H

#include "common/array.h"
#include "common/rect.h"
Expand All @@ -37,7 +37,7 @@ class CStarField;
class CStarControlSub7;
class CStarCamera;

class CStarControlSub8 {
class CPhotoCrosshairs {
private:
Common::Array<CStarPosition> _positions;
int _entryIndex;
Expand All @@ -56,8 +56,8 @@ class CStarControlSub8 {
int _field8;
int _fieldC;
public:
CStarControlSub8();
~CStarControlSub8() { clear(); }
CPhotoCrosshairs();
~CPhotoCrosshairs() { clear(); }

/**
* Load the data for the class from file
Expand Down Expand Up @@ -91,4 +91,4 @@ class CStarControlSub8 {

} // End of namespace Titanic

#endif /* TITANIC_STAR_CONTROL_SUB8_H */
#endif /* TITANIC_PHOTO_CROSSHAIRS_H */
26 changes: 13 additions & 13 deletions engines/titanic/star_control/star_field.cpp
Expand Up @@ -33,7 +33,7 @@ CStarField::CStarField() : _points1On(false), _points2On(false), _mode(MODE_STAR

void CStarField::load(SimpleFile *file) {
_sub7.load(file);
_sub8.load(file);
_crosshairs.load(file);
_points1On = file->readNumber();
_points2On = file->readNumber();
_mode = (StarMode)file->readNumber();
Expand All @@ -43,7 +43,7 @@ void CStarField::load(SimpleFile *file) {

void CStarField::save(SimpleFile *file, int indent) {
_sub7.save(file, indent);
_sub8.save(file, indent);
_crosshairs.save(file, indent);
file->writeNumberLine(_points1On, indent);
file->writeNumberLine(_points2On, indent);
file->writeNumberLine(_mode, indent);
Expand All @@ -70,7 +70,7 @@ void CStarField::render(CVideoSurface *surface, CStarCamera *camera) {
drawCrosshairs(&surfaceArea);

_sub7.draw(&surfaceArea, camera, nullptr);
_sub8.draw(&surfaceArea);
_crosshairs.draw(&surfaceArea);

if (_points2On)
_points2.draw(&surfaceArea, camera);
Expand Down Expand Up @@ -123,15 +123,15 @@ bool CStarField::setCrosshairs(bool isVisible) {
}

int CStarField::get88() const {
return _sub8._field8;
return _crosshairs._field8;
}

int CStarField::get5() const {
return _val5;
}

void CStarField::setSolved() {
_isSolved = _sub8._field8 == 2;
_isSolved = _crosshairs._field8 == 2;
}

bool CStarField::isSolved() const {
Expand Down Expand Up @@ -183,10 +183,10 @@ void CStarField::fn4(CSurfaceArea *surfaceArea, CStarCamera *camera) {

double CStarField::fn5(CSurfaceArea *surfaceArea, CStarCamera *camera,
FVector &v1, FVector &v2, FVector &v3) {
if (_sub8._fieldC < 0)
if (_crosshairs._fieldC < 0)
return -1.0;

const CBaseStarEntry *dataP = _sub7.getDataPtr(_sub8._fieldC);
const CBaseStarEntry *dataP = _sub7.getDataPtr(_crosshairs._fieldC);
v2 = dataP->_position;
FVector tv = camera->proc29(2, v2);

Expand All @@ -197,7 +197,7 @@ double CStarField::fn5(CSurfaceArea *surfaceArea, CStarCamera *camera,

v1 = FVector(tv._x + surfaceArea->_centroid._x,
tv._y + surfaceArea->_centroid._y, tv._z);
FPoint pt = _sub8.getPosition();
FPoint pt = _crosshairs.getPosition();
v3 = FVector(pt._x, pt._y, 1.0);

double incr = (v1._x - pt._x) * (v1._x - pt._x);
Expand All @@ -212,16 +212,16 @@ double CStarField::fn5(CSurfaceArea *surfaceArea, CStarCamera *camera,

void CStarField::fn6(CVideoSurface *surface, CStarCamera *camera) {
CSurfaceArea surfaceArea(surface);
_sub8.fn1(this, &surfaceArea, camera);
_crosshairs.fn1(this, &surfaceArea, camera);
}

void CStarField::fn7() {
_sub8.fn3();
_crosshairs.fn3();
setSolved();
}

void CStarField::fn8(CVideoSurface *surface) {
_sub8.fn2(surface, this, &_sub7);
_crosshairs.fn2(surface, this, &_sub7);
setSolved();
}

Expand All @@ -231,9 +231,9 @@ bool CStarField::mouseButtonDown(CVideoSurface *surface, CStarCamera *camera,
CSurfaceArea surfaceArea(surface);
return selectStar(&surfaceArea, camera, pt);
} else {
int starNum = _sub8.indexOf(pt);
int starNum = _crosshairs.indexOf(pt);
if (starNum >= 0) {
_sub8.selectStar(starNum, surface, this, &_sub7);
_crosshairs.selectStar(starNum, surface, this, &_sub7);
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions engines/titanic/star_control/star_field.h
Expand Up @@ -26,7 +26,7 @@
#include "titanic/star_control/star_control_sub2.h"
#include "titanic/star_control/star_closeup.h"
#include "titanic/star_control/star_control_sub7.h"
#include "titanic/star_control/star_control_sub8.h"
#include "titanic/star_control/photo_crosshairs.h"
#include "titanic/star_control/star_points1.h"
#include "titanic/star_control/star_points2.h"

Expand All @@ -35,7 +35,7 @@ namespace Titanic {
class CStarField : public CStarControlSub2 {
private:
CStarControlSub7 _sub7;
CStarControlSub8 _sub8;
CPhotoCrosshairs _crosshairs;
CStarPoints1 _points1;
CStarPoints2 _points2;
CStarCloseup _starCloseup;
Expand Down
2 changes: 2 additions & 0 deletions engines/titanic/star_control/star_view.cpp
Expand Up @@ -426,10 +426,12 @@ void CStarView::fn18(CStarCamera *camera) {
int oldVal = _starField->get54();
bool oldCrosshairs = _starField->setCrosshairs(false);

// Render the starfield for the photograph view
_photoSurface->clear();
_photoSurface->lock();
_starField->render(_photoSurface, camera);

// Render any previously set crosshairs
_starField->setCrosshairs(oldCrosshairs);
_starField->set54(oldVal);
_starField->fn6(_photoSurface, camera);
Expand Down

0 comments on commit 6587cac

Please sign in to comment.