[Scummvm-git-logs] scummvm master -> 953ab685b9b57afa5f1d4d08a2609f53677fadd9

dreammaster dreammaster at scummvm.org
Wed May 31 04:49:11 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:
953ab685b9 TITANIC: Fix flickering of marker bulbs in PET Starfield display


Commit: 953ab685b9b57afa5f1d4d08a2609f53677fadd9
    https://github.com/scummvm/scummvm/commit/953ab685b9b57afa5f1d4d08a2609f53677fadd9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-05-30T22:49:01-04:00

Commit Message:
TITANIC: Fix flickering of marker bulbs in PET Starfield display

Changed paths:
    engines/titanic/pet_control/pet_starfield.cpp
    engines/titanic/pet_control/pet_starfield.h


diff --git a/engines/titanic/pet_control/pet_starfield.cpp b/engines/titanic/pet_control/pet_starfield.cpp
index 874fb50..bbe8924 100644
--- a/engines/titanic/pet_control/pet_starfield.cpp
+++ b/engines/titanic/pet_control/pet_starfield.cpp
@@ -27,9 +27,9 @@
 
 namespace Titanic {
 
-CPetStarfield::CPetStarfield() : _field18C(0), _photoOn(true),
+CPetStarfield::CPetStarfield() : _flickerCtr(0), _photoOn(true),
 		_hasReference(false), _rect1(22, 352, 598, 478) {
-	_btnOffsets[0] = _btnOffsets[1] = _btnOffsets[2] = 0;
+	_markerStates[0] = _markerStates[1] = _markerStates[2] = MS_BLANK;
 }
 
 bool CPetStarfield::setup(CPetControl *petControl) {
@@ -72,9 +72,9 @@ void CPetStarfield::draw(CScreenManager *screenManager) {
 	}
 
 	_btnSetDest.draw(screenManager);
-	drawButton(_btnOffsets[0], 0, screenManager);
-	drawButton(_btnOffsets[1], 2, screenManager);
-	drawButton(_btnOffsets[2], 4, screenManager);
+	drawButton(_markerStates[0], 0, screenManager);
+	drawButton(_markerStates[1], 2, screenManager);
+	drawButton(_markerStates[2], 4, screenManager);
 	_text.draw(screenManager);
 }
 
@@ -178,37 +178,38 @@ bool CPetStarfield::setupControl(CPetControl *petControl) {
 	return true;
 }
 
-void CPetStarfield::drawButton(int offset, int index, CScreenManager *screenManager) {
-	if (_field18C < 4 && (offset / 3) == 1)
-		--offset;
-	if (offset == 2)
+void CPetStarfield::drawButton(MarkerState state, int index, CScreenManager *screenManager) {
+	int offset = (int)state;
+	if (_flickerCtr < 4 && state == MS_FLICKERING)
+		offset = 0;
+	if (state == MS_HIGHLIGHTED)
 		offset = 1;
 
 	_leds[index + offset].draw(screenManager);
 }
 
 void CPetStarfield::setButtons(int matchIndex, bool isMarkerClose) {
-	_btnOffsets[0] = 0;
-	_btnOffsets[1] = 0;
-	_btnOffsets[2] = 0;
+	_markerStates[0] = MS_BLANK;
+	_markerStates[1] = MS_BLANK;
+	_markerStates[2] = MS_BLANK;
 
 	if (matchIndex >= 0)
-		_btnOffsets[0] = 2;
+		_markerStates[0] = MS_HIGHLIGHTED;
 	if (matchIndex >= 1)
-		_btnOffsets[1] = 2;
+		_markerStates[1] = MS_HIGHLIGHTED;
 	if (matchIndex >= 2)
-		_btnOffsets[2] = 2;
+		_markerStates[2] = MS_HIGHLIGHTED;
 
 	if (isMarkerClose) {
 		if (matchIndex == -1)
-			_btnOffsets[0] = 1;
+			_markerStates[0] = MS_FLICKERING;
 		if (matchIndex == 0)
-			_btnOffsets[1] = 1;
+			_markerStates[1] = MS_FLICKERING;
 		if (matchIndex == 1)
-			_btnOffsets[2] = 1;
+			_markerStates[2] = MS_FLICKERING;
 	}
 
-	_field18C = (_field18C + 1) % 8;
+	_flickerCtr = (_flickerCtr + 1) % 8;
 }
 
 void CPetStarfield::makePetDirty() {
@@ -230,7 +231,7 @@ bool CPetStarfield::elementMouseButton(int index, CMouseButtonDownMsg *msg, cons
 	if (!rect.contains(msg->_mousePos))
 		return false;
 
-	switch (_btnOffsets[index]) {
+	switch (_markerStates[index]) {
 	case 1:
 		if (_petControl->_remoteTarget) {
 			CPETStarFieldLockMsg lockMsg(1);
@@ -239,7 +240,7 @@ bool CPetStarfield::elementMouseButton(int index, CMouseButtonDownMsg *msg, cons
 		break;
 
 	case 2:
-		if (index < 2 && _btnOffsets[index] >= 2) {
+		if (index < 2 && _markerStates[index] >= 2) {
 			if (_petControl->_remoteTarget) {
 				CPETStarFieldLockMsg lockMsg(1);
 				lockMsg.execute(_petControl->_remoteTarget);
diff --git a/engines/titanic/pet_control/pet_starfield.h b/engines/titanic/pet_control/pet_starfield.h
index 01dddfd..deefae7 100644
--- a/engines/titanic/pet_control/pet_starfield.h
+++ b/engines/titanic/pet_control/pet_starfield.h
@@ -29,16 +29,18 @@
 
 namespace Titanic {
 
+enum MarkerState { MS_BLANK = 0, MS_FLICKERING = 1, MS_HIGHLIGHTED = 2};
+
 class CPetStarfield : public CPetSection {
 private:
 	CPetGfxElement _imgStarfield;
 	CPetGfxElement _imgPhoto;
 	CPetGfxElement _imgStarCtrl;
 	CPetGfxElement _btnSetDest;
-	int _btnOffsets[3];
+	MarkerState _markerStates[3];
 	CPetGfxElement _leds[6];
 	Rect _rect1;
-	int _field18C;
+	int _flickerCtr;
 	CTextControl _text;
 	bool _photoOn;
 	bool _hasReference;
@@ -51,7 +53,7 @@ private:
 	/**
 	 * Draw a button
 	 */
-	void drawButton(int offset, int index, CScreenManager *screenManager);
+	void drawButton(MarkerState state, int index, CScreenManager *screenManager);
 
 	/**
 	 * Mouse down handling for Nav elements





More information about the Scummvm-git-logs mailing list