[Scummvm-cvs-logs] scummvm master -> 661542b8c62a618f5d4b8265c8f9fb4d7e58a3a7

bluegr bluegr at gmail.com
Mon Apr 6 02:13:13 CEST 2015


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:
661542b8c6 MADS: Implement copy protection screen for Rex


Commit: 661542b8c62a618f5d4b8265c8f9fb4d7e58a3a7
    https://github.com/scummvm/scummvm/commit/661542b8c62a618f5d4b8265c8f9fb4d7e58a3a7
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-04-06T03:12:15+03:00

Commit Message:
MADS: Implement copy protection screen for Rex

Changed paths:
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/dialogs_nebular.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 4ba5366..9388aa2 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -417,7 +417,7 @@ TextDialog(vm, FONT_INTERFACE, Common::Point(-1, -1), 32) {
 		_hogEntry._pageNum, _hogEntry._lineNum, _hogEntry._wordNum);
 	wordWrap(line);
 
-	wordWrap("and type it on the line below (we',27h,'ve even given you");
+	wordWrap("and type it on the line below (we've even given you");
 	wordWrap("first letter as a hint).  As soon as you do that, we can get");
 	wordWrap("right into this really COOL adventure game!\n");
 	wordWrap("\n");
@@ -428,17 +428,47 @@ TextDialog(vm, FONT_INTERFACE, Common::Point(-1, -1), 32) {
 
 void CopyProtectionDialog::show() {
 	draw();
-	_vm->_events->showCursor();
 
-	// TODO: Replace with text input
-	while (!_vm->shouldQuit() && !_vm->_events->isKeyPressed() &&
-		!_vm->_events->_mouseClicked) {
-		_vm->_events->delay(1);
+	Common::KeyState curKey;
+	Common::Rect inputArea(110, 165, 210, 175);
+	MSurface *origInput = new MSurface(inputArea.width(), inputArea.height());
+	_vm->_screen.frameRect(inputArea, TEXTDIALOG_BLACK);
+	_vm->_screen.copyTo(origInput, inputArea, Common::Point(0, 0));
+	_font->setColors(TEXTDIALOG_FE, TEXTDIALOG_FE, TEXTDIALOG_FE, TEXTDIALOG_FE);
+	_vm->_screen.copyRectToScreen(inputArea);
+	_vm->_screen.updateScreen();
+
+	while (!_vm->shouldQuit()) {
+		while (!_vm->_events->isKeyPressed()) {
+			_vm->_events->delay(1);
+		}
+
+		curKey = _vm->_events->getKey();
+		
+		if (curKey.keycode == Common::KEYCODE_RETURN || curKey.keycode == Common::KEYCODE_KP_ENTER)
+			break;
+		else if (curKey.keycode == Common::KEYCODE_BACKSPACE)
+			_textInput.deleteLastChar();
+		else if (_textInput.size() < 14)
+			_textInput += curKey.ascii;
+
+		_vm->_events->_pendingKeys.clear();
+
+		_vm->_screen.copyFrom(origInput, Common::Rect(0, 0, inputArea.width(), inputArea.height()), Common::Point(inputArea.left, inputArea.top));
+		_font->writeString(&_vm->_screen, _textInput,
+			Common::Point(inputArea.left + 2, inputArea.top + 1), 1);
+		_vm->_screen.copyRectToScreen(inputArea);
+		_vm->_screen.updateScreen();
 	}
 
-	_vm->_events->_pendingKeys.clear();
+	delete origInput;
 }
 
+bool CopyProtectionDialog::isCorrectAnswer() {
+	return _hogEntry._word == _textInput;
+}
+
+
 bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) {
 	File f;
 	f.open("*HOGANUS.DAT");
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index 5dbe4da..0f086f6 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -69,6 +69,7 @@ struct HOGANUS {
 class CopyProtectionDialog : public TextDialog {
 private:
 	HOGANUS _hogEntry;
+	Common::String _textInput;
 
 	/**
 	 * Get a random copy protection entry from the HOGANUS resource
@@ -84,6 +85,8 @@ public:
 	 * Show the dialog
 	 */
 	virtual void show();
+
+	bool isCorrectAnswer();
 };
 
 class PictureDialog : public TextDialog {
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index cde998e..ec7c667 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -45,19 +45,25 @@ GameNebular::GameNebular(MADSEngine *vm)
 }
 
 ProtectionResult GameNebular::checkCopyProtection() {
-	/*
-	// DEBUG: Flag copy protection failure
-	_globals[kCopyProtectFailed] = -1;
+	//if (!ConfMan.getBool("copy_protection"))
+	//	return PROTECTION_SUCCEED;
 
-	if (!ConfMan.getBool("copy_protection"))
-	return true;
+	CopyProtectionDialog *dlg;
+	bool correctAnswer;
 
-	* DEBUG: Disabled for now
-	CopyProtectionDialog *dlg = new CopyProtectionDialog(_vm, false);
+	dlg = new CopyProtectionDialog(_vm, false);
 	dlg->show();
+	correctAnswer = dlg->isCorrectAnswer();
 	delete dlg;
-	*/
-	return PROTECTION_SUCCEED;
+
+	if (!correctAnswer) {
+		dlg = new CopyProtectionDialog(_vm, true);
+		dlg->show();
+		correctAnswer = dlg->isCorrectAnswer();
+		delete dlg;
+	}
+
+	return correctAnswer ? PROTECTION_SUCCEED : PROTECTION_FAIL;
 }
 
 void GameNebular::startGame() {
@@ -91,26 +97,6 @@ void GameNebular::startGame() {
 		checkShowDialog();
 		_winStatus = 0;
 
-		/*
-		// Check copy protection
-		ProtectionResult protectionResult = checkCopyProtection();
-		switch (protectionResult) {
-		case PROTECTION_FAIL:
-		// Copy protection failed
-		_scene._nextSceneId = 804;
-		initializeGlobals();
-		_globals[kCopyProtectFailed] = true;
-		return;
-		case PROTECTION_ESCAPE:
-		// User escaped out of copy protection dialog
-		_vm->quitGame();
-		return;
-		default:
-		// Copy protection check succeeded
-		break;
-		}
-		*/
-
 		_sectionNumber = 1;
 		initSection(_sectionNumber);
 		_vm->_events->setCursor(CURSOR_ARROW);
@@ -128,6 +114,24 @@ void GameNebular::startGame() {
 	_scene._nextSceneId = 101;
 
 	initializeGlobals();
+
+	// Check copy protection
+	ProtectionResult protectionResult = checkCopyProtection();
+
+	switch (protectionResult) {
+	case PROTECTION_FAIL:
+		// Copy protection failed
+		_scene._nextSceneId = 804;
+		_globals[kCopyProtectFailed] = true;
+		return;
+	case PROTECTION_ESCAPE:
+		// User escaped out of copy protection dialog
+		_vm->quitGame();
+		return;
+	default:
+		// Copy protection check succeeded
+		break;
+	}
 }
 
 void GameNebular::initializeGlobals() {
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 8ce559b..5f8417c 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -957,7 +957,7 @@ void Scene804::step() {
 				_globals[kInSpace] = false;
 				_globals[kBeamIsUp] = true;
 
-				assert(!_globals[kCopyProtectFailed]);
+				//assert(!_globals[kCopyProtectFailed]);
 				_game._winStatus = 4;
 				return;
 			}






More information about the Scummvm-git-logs mailing list