Skip to content
Permalink
Browse files

TITANIC: Implemented CStarView MouseMoveMsg

  • Loading branch information
dreammaster committed Mar 2, 2017
1 parent 4ab3872 commit 49218970131904419777873019fbc8067d1d7a30
@@ -25,13 +25,14 @@

namespace Titanic {

void FPoint::normalize() {
double FPoint::normalize() {
double hyp = sqrt(_x * _x + _y * _y);
assert(hyp != 0.0);

double fraction = 1.0 / hyp;
_x *= fraction;
_y *= fraction;
return hyp;
}

} // End of namespace Titanic
@@ -23,6 +23,8 @@
#ifndef TITANIC_FPOINT_H
#define TITANIC_FPOINT_H

#include "common/rect.h"

namespace Titanic {

/**
@@ -34,6 +36,7 @@ class FPoint {
public:
FPoint() : _x(0), _y(0) {}
FPoint(double x, double y) : _x(x), _y(y) {}
FPoint(const Common::Point &pt) : _x(pt.x), _y(pt.y) {}

bool operator==(const FPoint &p) const { return _x == p._x && _y == p._y; }
bool operator!=(const FPoint &p) const { return _x != p._x || _y != p._y; }
@@ -54,7 +57,7 @@ class FPoint {
* Normalises the X and Y coordinates as fractions relative to the
* value of the hypotenuse formed by a triangle from the origin (0,0)
*/
void normalize();
double normalize();
};

} // End of namespace Titanic
@@ -216,8 +216,8 @@ FVector CStarControlSub12::proc31(int index, const FVector &v) {
return _sub13.fn18(index, v);
}

void CStarControlSub12::proc32(double v1, double v2) {
error("TODO: CStarControlSub12::proc32");
void CStarControlSub12::setViewportPosition(const FPoint &pt) {
// TODO
}

bool CStarControlSub12::setArrayVector(const FVector &v) {
@@ -25,6 +25,7 @@

#include "titanic/support/simple_file.h"
#include "titanic/star_control/fmatrix.h"
#include "titanic/star_control/fpoint.h"
#include "titanic/star_control/star_control_sub13.h"
#include "titanic/star_control/star_control_sub20.h"

@@ -93,7 +94,12 @@ class CStarControlSub12 {
virtual FVector proc29(const FVector &v);
virtual FVector proc30(int index, const FVector &v);
virtual FVector proc31(int index, const FVector &v);
virtual void proc32(double v1, double v2);

/**
* Sets the viewport position within the starfield
*/
virtual void setViewportPosition(const FPoint &pt);

virtual int getCurrentIndex() const { return _currentIndex; }
virtual bool setArrayVector(const FVector &v);
virtual bool proc35();
@@ -24,9 +24,9 @@

namespace Titanic {

bool CStarControlSub2::proc3(int v1) {
bool CStarControlSub2::loadYale(int v1) {
clear();
// TODO
error("Original loadYale not supported");
return true;
}

@@ -31,7 +31,7 @@ class CStarControlSub2: public CBaseStar {
public:
virtual ~CStarControlSub2() {}

virtual bool proc3(int v1);
virtual bool loadYale(int v1);
virtual bool proc4(int v1, int v2, int v3, int v4, int v5);
virtual bool loadStar();
virtual bool proc7(int v1, int v2);
@@ -31,9 +31,8 @@ namespace Titanic {
CStarView::CStarView() : _sub12(nullptr, nullptr), _sub13((void *)nullptr),
_owner(nullptr), _starField(nullptr), _videoSurface(nullptr), _field118(0),
_videoSurface2(nullptr), _homePhotoMask(nullptr),
_field218(0), _field21C(0) {
CStar20Data data = { 0, 0, 0x47C35000, 0, 0x41A00000,
0x3F800000, 0x3F800000, 0x3F800000 };
_field218(0), _showingPhoto(false) {
CStar20Data data = { 0, 0, 100000.0, 0, 20.0, 1.0, 1.0, 1.0 };

_sub12.proc3(&data);
}
@@ -47,7 +46,7 @@ void CStarView::load(SimpleFile *file, int param) {
_sub13.load(file, 0);

_field218 = file->readNumber();
_field21C = file->readNumber();
_showingPhoto = file->readNumber();
}
}

@@ -59,7 +58,7 @@ void CStarView::save(SimpleFile *file, int indent) {
_sub13.save(file, indent);

file->writeNumberLine(_field218, indent);
file->writeNumberLine(_field21C, indent);
file->writeNumberLine(_showingPhoto, indent);
}

void CStarView::setup(CScreenManager *screenManager, CStarField *starField, CStarControl *starControl) {
@@ -76,13 +75,13 @@ void CStarView::draw(CScreenManager *screenManager) {
return;

if (_fader.isActive()) {
CVideoSurface *surface = _field21C ? _videoSurface2 : _videoSurface;
CVideoSurface *surface = _showingPhoto ? _videoSurface2 : _videoSurface;
surface = _fader.fade(screenManager, surface);
screenManager->blitFrom(SURFACE_PRIMARY, surface);
} else {
Point destPos(20, 10);

if (_field21C) {
if (_showingPhoto) {
screenManager->blitFrom(SURFACE_PRIMARY, _videoSurface2, &destPos);

if (!_homePhotoMask && _owner) {
@@ -110,8 +109,28 @@ void CStarView::MouseButtonDownMsg(int unused, const Point &pt) {
// TODO
}

void CStarView::MouseMoveMsg(int unused, const Point &pt) {
// TODO
bool CStarView::MouseMoveMsg(int unused, const Point &pt) {
if (!_showingPhoto && (_fader._index < 0 || _fader._count >= 0)) {
FPoint fpt = pt;
FPoint centerPt(300.0, 170.0);

if (fpt != centerPt) {
double threshold = MIN(centerPt._x, centerPt._y) * 0.5;
FPoint tempPt = fpt - centerPt;

double distance = tempPt.normalize();
if (distance >= threshold) {
distance -= threshold;

FPoint relPt(tempPt._x * -2.0 * distance / threshold,
tempPt._y * -2.0 * distance / threshold);
_sub12.setViewportPosition(relPt);
return true;
}
}
}

return false;
}

CErrorCode CStarView::KeyCharMsg(int key) {
@@ -47,7 +47,7 @@ class CStarView {
CVideoSurface *_videoSurface2;
CGameObject *_homePhotoMask;
int _field218;
int _field21C;
bool _showingPhoto;
#if 0
int _field210;
#endif
@@ -86,7 +86,7 @@ class CStarView {
/**
* Handles mouse move messages
*/
void MouseMoveMsg(int unused, const Point &pt);
bool MouseMoveMsg(int unused, const Point &pt);

/**
* Handles keyboard messages

0 comments on commit 4921897

Please sign in to comment.
You can’t perform that action at this time.