TITANIC: Cleanup & fixes for starfield viewpoint box

This commit is contained in:
Paul Gilbert 2017-05-30 20:01:49 -04:00
parent 6e46535c92
commit 56474edca0
12 changed files with 53 additions and 47 deletions

View File

@ -291,7 +291,7 @@ void CStarCloseup::draw(const FPose &pose, const FVector &vector, const FVector
}
if (val2 <= 0) {
surfaceArea->setMode(SA_NONE);
surfaceArea->setMode(SA_SOLID);
surfaceArea->_pixel = MKTAG_BE(entryP->_pixel1, entryP->_pixel2,
entryP->_pixel3, 0);
surfaceArea->setColorFromPixel();
@ -314,7 +314,7 @@ void CStarCloseup::draw(const FPose &pose, const FVector &vector, const FVector
}
}
} else {
surfaceArea->setMode(SA_NONE);
surfaceArea->setMode(SA_SOLID);
surfaceArea->_pixel = entryP->_pixel1;
surfaceArea->setColorFromPixel();
@ -396,7 +396,7 @@ void CStarCloseup::draw(const FPose &pose, const FVector &vector, const FVector
}
if (val2 <= 0) {
surfaceArea->setMode(SA_NONE);
surfaceArea->setMode(SA_SOLID);
surfaceArea->_pixel = pixel1;
surfaceArea->setColorFromPixel();
@ -418,7 +418,7 @@ void CStarCloseup::draw(const FPose &pose, const FVector &vector, const FVector
}
}
} else {
surfaceArea->setMode(SA_NONE);
surfaceArea->setMode(SA_SOLID);
surfaceArea->_pixel = pixel2;
surfaceArea->setColorFromPixel();

View File

@ -215,7 +215,7 @@ void CStarControl::doAction(StarControlAction action) {
break;
case STAR_11:
_view.toggleCrosshairs();
_view.toggleBox();
break;
case STAR_12:

View File

@ -161,7 +161,7 @@ void CStarCrosshairs::draw(CSurfaceArea *surfaceArea) {
uint savedPixel = surfaceArea->_pixel;
surfaceArea->_pixel = 0xff;
surfaceArea->setColorFromPixel();
SurfaceAreaMode savedMode = surfaceArea->setMode(SA_NONE);
SurfaceAreaMode savedMode = surfaceArea->setMode(SA_SOLID);
for (int idx = 0; idx < _entryIndex; ++idx) {
const CStarPosition &src = _entries[idx];

View File

@ -28,7 +28,7 @@
namespace Titanic {
CStarField::CStarField() : _points1On(false), _points2On(false), _mode(MODE_STARFIELD),
_showCrosshairs(true), _val5(0), _isSolved(false) {
_showBox(true), _val5(0), _isSolved(false) {
}
void CStarField::load(SimpleFile *file) {
@ -37,7 +37,7 @@ void CStarField::load(SimpleFile *file) {
_points1On = file->readNumber();
_points2On = file->readNumber();
_mode = (StarMode)file->readNumber();
_showCrosshairs = file->readNumber();
_showBox = file->readNumber();
_isSolved = file->readNumber();
}
@ -47,7 +47,7 @@ void CStarField::save(SimpleFile *file, int indent) {
file->writeNumberLine(_points1On, indent);
file->writeNumberLine(_points2On, indent);
file->writeNumberLine(_mode, indent);
file->writeNumberLine(_showCrosshairs, indent);
file->writeNumberLine(_showBox, indent);
file->writeNumberLine(_isSolved, indent);
}
@ -66,7 +66,7 @@ bool CStarField::initDocument() {
void CStarField::render(CVideoSurface *surface, CStarCamera *camera) {
CSurfaceArea surfaceArea(surface);
draw(&surfaceArea, camera, &_starCloseup);
if (_showCrosshairs)
if (_showBox)
drawBox(&surfaceArea);
_markers.draw(&surfaceArea, camera, nullptr);
@ -112,13 +112,13 @@ void CStarField::setMode(StarMode mode) {
_mode = mode;
}
void CStarField::toggleCrosshairs() {
_showCrosshairs = !_showCrosshairs;
void CStarField::toggleBox() {
_showBox = !_showBox;
}
bool CStarField::setCrosshairs(bool isVisible) {
bool oldVal = _showCrosshairs;
_showCrosshairs = isVisible;
bool CStarField::setBoxVisible(bool isVisible) {
bool oldVal = _showBox;
_showBox = isVisible;
return oldVal;
}

View File

@ -42,7 +42,7 @@ private:
bool _points1On;
bool _points2On;
StarMode _mode;
bool _showCrosshairs;
bool _showBox;
int _val5;
bool _isSolved;
private:
@ -90,14 +90,14 @@ public:
void setMode(StarMode mode);
/**
* Toggles whether the crosshairs box is visible
* Toggles whether the big box is visible
*/
void toggleCrosshairs();
void toggleBox();
/**
* Sets whether the crosshairs box is visible
* Sets whether the big box is visible
*/
bool setCrosshairs(bool isVisible);
bool setBoxVisible(bool isVisible);
/**
* Returns the index for the number of star matches

View File

@ -34,7 +34,7 @@ void CStarMarkers::draw(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarClo
FPoint center((double)surfaceArea->_width * 0.5,
surfaceArea->_height * 0.5);
FVector newV;
int x1, x2, x3, y1, y2, y3;
double x1, x2, x3, y1, y2, y3;
uint savedPixel = surfaceArea->_pixel;
surfaceArea->_pixel = 0xffff;
@ -54,14 +54,14 @@ void CStarMarkers::draw(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarClo
x2 = center._x + vTemp._x;
y1 = center._y + vTemp._y;
y2 = y1 - -4.0;
y2 = y1 + 4.0;
x1 = x2 - 4.0;
x3 = x2 - -4.0;
x3 = x2 + 4.0;
y3 = y1 - 4.0;
surfaceArea->drawLine(Common::Point(x1, y1), Common::Point(x2, y2));
surfaceArea->drawLine(Common::Point(x2, y2), Common::Point(x3, y1));
surfaceArea->drawLine(Common::Point(x3, y1), Common::Point(x2, y3));
surfaceArea->drawLine(Common::Point(x2, y3), Common::Point(x1, y1));
surfaceArea->drawLine(FPoint(x1, y1), FPoint(x2, y2));
surfaceArea->drawLine(FPoint(x2, y2), FPoint(x3, y1));
surfaceArea->drawLine(FPoint(x3, y1), FPoint(x2, y3));
surfaceArea->drawLine(FPoint(x2, y3), FPoint(x1, y1));
}
}

View File

@ -72,7 +72,7 @@ void CStarPoints1::draw(CSurfaceArea *surface, CStarCamera *camera) {
surface->_pixel = 0xff0000;
uint oldPixel = surface->_pixel;
surface->setColorFromPixel();
SurfaceAreaMode oldMode = surface->setMode(SA_NONE);
SurfaceAreaMode oldMode = surface->setMode(SA_SOLID);
vector1._z = vTemp._x * pose._row1._z + vTemp._y * pose._row2._z + vTemp._z * pose._row3._z + pose._vector._z;
vector1._x = vTemp._x * pose._row1._x + vTemp._y * pose._row2._x + vTemp._z * pose._row3._x + pose._vector._x;

View File

@ -76,7 +76,7 @@ void CStarPoints2::draw(CSurfaceArea *surface, CStarCamera *camera) {
surface->_pixel = 0xffff00;
uint oldPixel = surface->_pixel;
surface->setColorFromPixel();
SurfaceAreaMode oldMode = surface->setMode(SA_NONE);
SurfaceAreaMode oldMode = surface->setMode(SA_SOLID);
for (uint rootCtr = 0; rootCtr < _data.size(); ++rootCtr) {
const RootEntry &re = _data[rootCtr];

View File

@ -344,9 +344,9 @@ void CStarView::fn11() {
_starField->fn9();
}
void CStarView::toggleCrosshairs() {
void CStarView::toggleBox() {
if (_starField)
_starField->toggleCrosshairs();
_starField->toggleBox();
}
void CStarView::fn13() {
@ -425,7 +425,7 @@ void CStarView::fn18(CStarCamera *camera) {
if (_photoSurface) {
int oldVal = _starField->get54();
bool oldCrosshairs = _starField->setCrosshairs(false);
bool oldCrosshairs = _starField->setBoxVisible(false);
// Render the starfield for the photograph view
_photoSurface->clear();
@ -433,7 +433,7 @@ void CStarView::fn18(CStarCamera *camera) {
_starField->render(_photoSurface, camera);
// Render any previously set crosshairs
_starField->setCrosshairs(oldCrosshairs);
_starField->setBoxVisible(oldCrosshairs);
_starField->set54(oldVal);
_starField->fn6(_photoSurface, camera);
_photoSurface->unlock();

View File

@ -146,9 +146,9 @@ public:
void fn11();
/**
* Toggles whether the crosshairs box is visible
* Toggles whether the viewpoint box is visible in the starfield
*/
void toggleCrosshairs();
void toggleBox();
void fn13();
void fn14();

View File

@ -31,7 +31,7 @@ CSurfaceArea::CSurfaceArea(CVideoSurface *surface) {
_pitch = surface->getPitch();
_field0 = 0;
_colorMask = _color = 0;
_mode = SA_NONE;
_mode = SA_SOLID;
_surface = nullptr;
// Original supported other pixel depths
@ -49,7 +49,7 @@ void CSurfaceArea::initialize() {
_field27 = _field26 = _field25 = 0;
_field24 = 0;
_rgb = _field2C = 0;
_mode = SA_NONE;
_mode = SA_SOLID;
}
void CSurfaceArea::setColor(uint rgb) {
@ -184,25 +184,31 @@ double CSurfaceArea::drawLine(const FRect &rect) {
switch (_bpp) {
case 0:
s.format = Graphics::PixelFormat::createFormatCLUT8();
if (_mode != SA_NONE)
if (_mode != SA_SOLID) {
Graphics::drawLine(rr.left, rr.top, rr.right, rr.bottom, 0, plotPoint<byte>, this);
return r.top;
return r.top;
}
break;
case 1:
case 2:
s.format = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
if (_mode != SA_NONE)
if (_mode != SA_SOLID) {
Graphics::drawLine(rr.left, rr.top, rr.right, rr.bottom, 0, plotPoint<uint16>, this);
return r.top;
return r.top;
}
break;
case 4:
s.format = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
if (_mode != SA_NONE)
if (_mode != SA_SOLID) {
Graphics::drawLine(rr.left, rr.top, rr.right, rr.bottom, 0, plotPoint<uint32>, this);
return r.top;
return r.top;
}
break;
default:
error("Unknown bpp");
}
s.drawLine(rr.left, rr.top, rr.right, rr.bottom, _color);
s.drawLine(rr.left, rr.top, rr.right, rr.bottom, _rgb);
return r.top;
}

View File

@ -31,7 +31,7 @@
namespace Titanic {
enum SurfaceAreaMode {
SA_NONE = 0, SA_MODE1 = 1, SA_MODE2 = 2, SA_XOR = 3, SA_MODE4 = 4
SA_SOLID = 0, SA_MODE1 = 1, SA_MODE2 = 2, SA_XOR = 3, SA_MODE4 = 4
};
class CSurfaceArea {
@ -96,8 +96,8 @@ public:
/**
* Draws a line on the surface
*/
double drawLine(const Common::Point &pt1, const Common::Point &pt2) {
return drawLine(FRect(pt1.x, pt1.y, pt2.x, pt2.y));
double drawLine(const FPoint &pt1, const FPoint &pt2) {
return drawLine(FRect(pt1._x, pt1._y, pt2._x, pt2._y));
}
};