[Scummvm-cvs-logs] SF.net SVN: scummvm: [28106] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun Jul 15 18:04:34 CEST 2007


Revision: 28106
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28106&view=rev
Author:   peres001
Date:     2007-07-15 09:04:34 -0700 (Sun, 15 Jul 2007)

Log Message:
-----------
Refactored selectCharacter so that menu code doesn't need auxiliary buffer kBit2 anymore.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/menu.cpp
    scummvm/trunk/engines/parallaction/menu.h

Modified: scummvm/trunk/engines/parallaction/menu.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/menu.cpp	2007-07-15 15:27:42 UTC (rev 28105)
+++ scummvm/trunk/engines/parallaction/menu.cpp	2007-07-15 16:04:34 UTC (rev 28106)
@@ -87,14 +87,15 @@
 #define SLOT_Y			64
 #define SLOT_WIDTH		(BLOCK_WIDTH+2)
 
+#define PASSWORD_LEN	6
 
-static uint16 _amigaDinoKey[] = { 5, 3, 6, 2, 2, 7 };
-static uint16 _amigaDonnaKey[] = { 0, 3, 6, 2, 2, 6 };
-static uint16 _amigaDoughKey[] = { 1, 3 ,7, 2, 4, 6 };
+static uint16 _amigaDinoKey[PASSWORD_LEN] = { 5, 3, 6, 2, 2, 7 };
+static uint16 _amigaDonnaKey[PASSWORD_LEN] = { 0, 3, 6, 2, 2, 6 };
+static uint16 _amigaDoughKey[PASSWORD_LEN] = { 1, 3 ,7, 2, 4, 6 };
 
-static uint16 _pcDinoKey[] = { 5, 3, 6, 1, 4, 7 };
-static uint16 _pcDonnaKey[] = { 0, 2, 8, 5, 5, 1 };
-static uint16 _pcDoughKey[] = { 1, 7 ,7, 2, 2, 6 };
+static uint16 _pcDinoKey[PASSWORD_LEN] = { 5, 3, 6, 1, 4, 7 };
+static uint16 _pcDonnaKey[PASSWORD_LEN] = { 0, 2, 8, 5, 5, 1 };
+static uint16 _pcDoughKey[PASSWORD_LEN] = { 1, 7 ,7, 2, 2, 6 };
 
 
 Menu::Menu(Parallaction *vm) {
@@ -163,16 +164,17 @@
 	_vm->_gfx->displayCenteredString(100, v14[2]);
 	_vm->_gfx->displayCenteredString(120, v14[3]);
 
+	_vm->showCursor(false);
+
 	_vm->_gfx->updateScreen();
-	_vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack);
 
 	_mouseButtons = kMouseNone;
-
-	for (; _mouseButtons != kMouseLeftUp; ) {
+	do {
 		_vm->updateInput();
-		if (_mouseButtons == kMouseRightUp) break;
-	}
+	} while (_mouseButtons != kMouseLeftUp && _mouseButtons != kMouseRightUp);
 
+	_vm->showCursor(true);
+
 	if (_mouseButtons != kMouseRightUp) {
 		strcpy(_vm->_location._name, "fogne");
 		return;    // show intro
@@ -307,6 +309,30 @@
 }
 
 
+int Menu::getSelectedBlock(const Common::Point &p, Common::Rect &r) {
+
+	for (uint16 _si = 0; _si < 9; _si++) {
+
+		Common::Rect q(
+			_si * BLOCK_X_OFFSET + BLOCK_SELECTION_X,
+			BLOCK_SELECTION_Y - _si * BLOCK_Y_OFFSET,
+			(_si + 1) * BLOCK_X_OFFSET + BLOCK_SELECTION_X,
+			BLOCK_SELECTION_Y + BLOCK_HEIGHT - _si * BLOCK_Y_OFFSET
+		);
+
+		if (q.contains(p)) {
+			r.setWidth(BLOCK_WIDTH);
+			r.setHeight(BLOCK_HEIGHT);
+			r.moveTo(_si * BLOCK_X_OFFSET + BLOCK_X, BLOCK_Y - _si * BLOCK_Y_OFFSET);
+			return _si;
+		}
+
+	}
+
+	return -1;
+}
+
+
 //
 //	character selection and protection
 //
@@ -314,11 +340,8 @@
 	debugC(1, kDebugMenu, "Menu::selectCharacter()");
 
 	uint16 _di = 0;
-	bool askPassword = true;
 
-	uint16 _donna_points = 0;
-	uint16 _dino_points = 0;
-	uint16 _dough_points = 0;
+	uint16 _donna_points, _dino_points, _dough_points;
 
 	StaticCnv v14;
 
@@ -334,51 +357,34 @@
 	_vm->_disk->selectArchive((_vm->getFeatures() & GF_LANG_MULT) ? "disk1" : "disk0");
 
 	_vm->_disk->loadSlide("password");	// loads background into kBitBack buffer
+	_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);	//
 
-	_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);	//
-	_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBit2);		//
 	_vm->_gfx->setPalette(_vm->_gfx->_palette);
 
-	while (askPassword == true) {
+	while (true) {
 
-		askPassword = false;
 		_di = 0;
 
 		_vm->_gfx->displayString(60, 30, introMsg1[_language], 1);			// displays message
-		_vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack);
 
 		_donna_points = 0;
 		_dino_points = 0;
 		_dough_points = 0;
 
-		while (_di < 6) {
+		while (_di < PASSWORD_LEN) {
 
 			_mouseButtons = kMouseNone;
 			do {
 				_vm->updateInput();
-				_vm->_gfx->swapBuffers();
-				_vm->waitTime(1);
+				g_system->delayMillis(30);
+				_vm->_gfx->updateScreen();
 			} while (_mouseButtons != kMouseLeftUp);	// waits for left click
 
-			for (uint16 _si = 0; _si < 9; _si++) {
-
-				Common::Rect r(
-					_si * BLOCK_X_OFFSET + BLOCK_SELECTION_X,
-					BLOCK_SELECTION_Y - _si * BLOCK_Y_OFFSET,
-					(_si + 1) * BLOCK_X_OFFSET + BLOCK_SELECTION_X,
-					BLOCK_SELECTION_Y + BLOCK_HEIGHT - _si * BLOCK_Y_OFFSET
-				);
-
-				if (!r.contains(_vm->_mousePos)) continue;
-
-				r.setWidth(BLOCK_WIDTH);
-				r.setHeight(BLOCK_HEIGHT);
-				r.moveTo(_si * BLOCK_X_OFFSET + BLOCK_X, BLOCK_Y - _si * BLOCK_Y_OFFSET);
+			Common::Rect r;
+			int _si = getSelectedBlock(_vm->_mousePos, r);
+			if (_si != -1) {
 				_vm->_gfx->grabRect(v14._data0, r, Gfx::kBitFront, BLOCK_WIDTH);
-
-				_vm->_gfx->flatBlitCnv(&v14, _di * SLOT_WIDTH + SLOT_X, SLOT_Y, Gfx::kBitBack);
 				_vm->_gfx->flatBlitCnv(&v14, _di * SLOT_WIDTH + SLOT_X, SLOT_Y, Gfx::kBitFront);
-
 //				beep();
 
 				if (_vm->getPlatform() == Common::kPlatformAmiga && (_vm->getFeatures() & GF_LANG_MULT)) {
@@ -399,31 +405,29 @@
 
 				_di++;
 			}
+		}
 
-			askPassword = (_dino_points < 6 && _donna_points < 6 && _dough_points < 6);
+		if (_dino_points == PASSWORD_LEN || _donna_points == PASSWORD_LEN || _dough_points == PASSWORD_LEN) {
+			break;
 		}
 
-		if (askPassword == false) break;
-
-		_vm->_gfx->copyScreen(Gfx::kBit2, Gfx::kBitFront);
+		_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
 		_vm->_gfx->displayString(60, 30, introMsg2[_language], 1);
 		_vm->_gfx->updateScreen();
 
 		g_system->delayMillis(2000);
 
-		_vm->_gfx->copyScreen(Gfx::kBit2, Gfx::kBitFront);
-		_vm->_gfx->updateScreen();
+		_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
 	}
 
-
-	if (_dino_points > _donna_points && _dino_points > _dough_points) {
+	if (_dino_points == PASSWORD_LEN) {
 		sprintf(_vm->_location._name, "test.%s", _dinoName);
-	} else {
-		if (_donna_points > _dino_points && _donna_points > _dough_points) {
-			sprintf(_vm->_location._name, "test.%s", _donnaName);
-		} else {
-			sprintf(_vm->_location._name, "test.%s", _doughName);
-		}
+	} else
+	if (_donna_points == PASSWORD_LEN) {
+		sprintf(_vm->_location._name, "test.%s", _donnaName);
+	} else
+	if (_dough_points == PASSWORD_LEN) {
+		sprintf(_vm->_location._name, "test.%s", _doughName);
 	}
 
 	_vm->_gfx->setBlackPalette();

Modified: scummvm/trunk/engines/parallaction/menu.h
===================================================================
--- scummvm/trunk/engines/parallaction/menu.h	2007-07-15 15:27:42 UTC (rev 28105)
+++ scummvm/trunk/engines/parallaction/menu.h	2007-07-15 16:04:34 UTC (rev 28106)
@@ -48,6 +48,7 @@
 	void		newGame();
 	uint16		chooseLanguage();
 	uint16		selectGame();
+	int			getSelectedBlock(const Common::Point &p, Common::Rect& r);
 
 public:
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list