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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Thu Nov 1 15:47:33 CET 2007


Revision: 29355
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29355&view=rev
Author:   peres001
Date:     2007-11-01 07:47:33 -0700 (Thu, 01 Nov 2007)

Log Message:
-----------
More refactoring for gui code.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/callables_ns.cpp
    scummvm/trunk/engines/parallaction/gui_ns.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp
    scummvm/trunk/engines/parallaction/saveload.cpp

Modified: scummvm/trunk/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables_ns.cpp	2007-11-01 14:08:55 UTC (rev 29354)
+++ scummvm/trunk/engines/parallaction/callables_ns.cpp	2007-11-01 14:47:33 UTC (rev 29355)
@@ -434,7 +434,8 @@
 		_gfx->updateScreen();
 		waitUntilLeftClick();
 
-		guiSelectCharacter();
+		selectCharacterForNewLocation();
+		_engineFlags |= kEngineChangeLocation;
 	}
 
 	// this code saves main character animation from being removed from the following code
@@ -547,7 +548,8 @@
 		waitUntilLeftClick();
 
 		_engineFlags &= ~kEngineBlockInput;
-		guiSelectCharacter();
+		selectCharacterForNewLocation();
+		_engineFlags |= kEngineChangeLocation;
 	} else {
 		waitUntilLeftClick();
 	}

Modified: scummvm/trunk/engines/parallaction/gui_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_ns.cpp	2007-11-01 14:08:55 UTC (rev 29354)
+++ scummvm/trunk/engines/parallaction/gui_ns.cpp	2007-11-01 14:47:33 UTC (rev 29355)
@@ -100,11 +100,24 @@
 	{ 0, 2, 8, 5, 5, 1 }		// donna
 };
 
+static const char *_charStartLocation[] = {
+	"test.dough",
+	"test.dino",
+	"test.donna"
+};
+
 enum {
 	NEW_GAME,
 	LOAD_GAME
 };
 
+enum {
+	START_DEMO,
+	START_INTRO,
+	GAME_LOADED,
+	SELECT_CHARACTER
+};
+
 void Parallaction_ns::guiStart() {
 
 	_disk->selectArchive((getFeatures() & GF_LANG_MULT) ? "disk1" : "disk0");
@@ -116,18 +129,49 @@
 	_language = guiChooseLanguage();
 	_disk->setLanguage(_language);
 
+	int event;
+
 	if (getFeatures() & GF_DEMO) {
+		event = START_DEMO;
+	} else {
+		if (guiSelectGame() == NEW_GAME) {
+			event = guiNewGame();
+		} else {
+			event = loadGame() ? GAME_LOADED : START_INTRO;
+		}
+	}
+
+	switch (event) {
+	case START_DEMO:
 		strcpy(_location._name, "fognedemo.dough");
+		break;
+
+	case START_INTRO:
+		strcpy(_location._name, "fogne.dough");
+		break;
+
+	case GAME_LOADED:
+		// nothing to do here
 		return;
-	}
 
-	if (guiSelectGame() == NEW_GAME) {
-		guiNewGame();
+	case SELECT_CHARACTER:
+		selectCharacterForNewLocation();
+		break;
+
 	}
 
 	return;
 }
 
+void Parallaction_ns::selectCharacterForNewLocation() {
+	int character = guiSelectCharacter();
+	if (character == -1)
+		error("invalid character selected from menu screen");
+
+	strcpy(_location._name, _charStartLocation[character]);
+}
+
+
 void Parallaction_ns::guiSplash() {
 
 	showSlide("intro");
@@ -140,7 +184,7 @@
 
 }
 
-void Parallaction_ns::guiNewGame() {
+int Parallaction_ns::guiNewGame() {
 
 	const char **v14 = introMsg3;
 
@@ -167,13 +211,10 @@
 	showCursor(true);
 
 	if (_mouseButtons != kMouseRightUp) {
-		strcpy(_location._name, "fogne.dough");
-		return;    // show intro
+		return START_INTRO;
 	}
 
-	guiSelectCharacter();
-
-	return; // start game
+	return SELECT_CHARACTER;
 }
 
 uint16 Parallaction_ns::guiChooseLanguage() {
@@ -226,8 +267,8 @@
 			}
 		}
 
+		_gfx->updateScreen();
 		g_system->delayMillis(30);
-		_gfx->updateScreen();
 
 	} while (true);
 
@@ -266,23 +307,11 @@
 
 		}
 
+		_gfx->updateScreen();
 		g_system->delayMillis(30);
-		_gfx->updateScreen();
 	}
 
-	if (_si == 0) return NEW_GAME; // new game
-
-	// load game
-
-	// TODO: allow the user to change her mind in this screen, that is
-	// don't force her to start at the intro when she closes her load
-	// game window without picking a savegame.
-	// The 2 strcpy's below act as workaround to prevent crashes for
-	// time being.
-	strcpy(_location._name, "fogne.dough");
-	loadGame();
-
-	return LOAD_GAME;  // load game
+	return _si ? LOAD_GAME : NEW_GAME;
 }
 
 
@@ -313,7 +342,7 @@
 //
 //	character selection and protection
 //
-void Parallaction_ns::guiSelectCharacter() {
+int Parallaction_ns::guiSelectCharacter() {
 	debugC(1, kDebugMenu, "Parallaction_ns::guiselectCharacter()");
 
 	Graphics::Surface v14;
@@ -331,7 +360,7 @@
 
 	uint16 (*keys)[PASSWORD_LEN] = (getPlatform() == Common::kPlatformAmiga && (getFeatures() & GF_LANG_MULT)) ? _amigaKeys : _pcKeys;
 	uint16 points[3];
-	bool matched = false;
+	int character = -1;
 	uint16 _di = 0;
 
 	while (true) {
@@ -349,7 +378,6 @@
 			_mouseButtons = kMouseNone;
 			do {
 				updateInput();
-				g_system->delayMillis(30);
 				_gfx->updateScreen();
 			} while (_mouseButtons != kMouseLeftUp);	// waits for left click
 
@@ -366,7 +394,7 @@
 					}
 
 					if (points[i] == PASSWORD_LEN) {
-						matched = true;
+						character = i;
 					}
 				}
 
@@ -374,7 +402,7 @@
 			}
 		}
 
-		if (matched) {
+		if (character != -1) {
 			break;
 		}
 
@@ -387,24 +415,12 @@
 		_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
 	}
 
-	if (points[1] == PASSWORD_LEN) {
-		sprintf(_location._name, "test.%s", _dinoName);
-	} else
-	if (points[2] == PASSWORD_LEN) {
-		sprintf(_location._name, "test.%s", _donnaName);
-	} else
-	if (points[0] == PASSWORD_LEN) {
-		sprintf(_location._name, "test.%s", _doughName);
-	}
-
 	_gfx->setBlackPalette();
 	_gfx->updateScreen();
 
-	_engineFlags |= kEngineChangeLocation;
-
 	v14.free();
 
-	return;
+	return character;
 
 }
 

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2007-11-01 14:08:55 UTC (rev 29354)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2007-11-01 14:47:33 UTC (rev 29355)
@@ -369,8 +369,8 @@
 
 	int init();
 
-	virtual void loadGame() = 0;
-	virtual void saveGame() = 0;
+	virtual bool loadGame() = 0;
+	virtual bool saveGame() = 0;
 
 	uint16 		updateInput();
 
@@ -661,8 +661,8 @@
 	const JobFn 	*_jobsFn;
 	JobOpcode* 	createJobOpcode(uint functionId, Job *job);
 
-	void loadGame();
-	void saveGame();
+	bool loadGame();
+	bool saveGame();
 
 
 private:
@@ -902,10 +902,12 @@
 	DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(move);
 	DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(endscript);
 
+	void		selectCharacterForNewLocation();
+
 	void		guiStart();
-	void		guiSelectCharacter();
+	int			guiSelectCharacter();
 	void 		guiSplash();
-	void		guiNewGame();
+	int			guiNewGame();
 	uint16		guiChooseLanguage();
 	uint16		guiSelectGame();
 	int			guiGetSelectedBlock(const Common::Point &p, Common::Rect& r);

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2007-11-01 14:08:55 UTC (rev 29354)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2007-11-01 14:47:33 UTC (rev 29355)
@@ -259,19 +259,16 @@
 
 int Parallaction_ns::go() {
 
+	_globalTable = _disk->loadTable("global");
+
 	guiStart();
 
 	LocationName locname;
 	locname.bind(_location._name);
 
-	_char.setName(locname.character());
-	strcpy(_location._name, locname.location());
+	changeCharacter(locname.character());
 
-	_globalTable = _disk->loadTable("global");
-
-	_engineFlags &= ~kEngineChangeLocation;
-	changeCharacter(_char.getName());
-
+	strcpy(_location._name, locname.location());
 	strcpy(_saveData1, _location._name);
 	parseLocation(_location._name);
 
@@ -454,5 +451,4 @@
 	return new OpcodeImpl2<Parallaction_ns>(this, _jobsFn[functionId], job);
 }
 
-
 } // namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/saveload.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/saveload.cpp	2007-11-01 14:08:55 UTC (rev 29354)
+++ scummvm/trunk/engines/parallaction/saveload.cpp	2007-11-01 14:47:33 UTC (rev 29355)
@@ -373,11 +373,11 @@
 
 
 
-void Parallaction_ns::loadGame() {
+bool Parallaction_ns::loadGame() {
 
 	int _di = selectSaveFile( 0, "Load file", "Load" );
 	if (_di == -1) {
-		return;
+		return false;
 	}
 
 	doLoadGame(_di);
@@ -387,18 +387,19 @@
 
 	setArrowCursor();
 
-	return;
+	return true;
 }
 
 
-void Parallaction_ns::saveGame() {
+bool Parallaction_ns::saveGame() {
 
-	if (!scumm_stricmp(_location._name, "caveau"))
-		return;
+	if (!scumm_stricmp(_location._name, "caveau")) {
+		return false;
+	}
 
 	int slot = selectSaveFile( 1, "Save file", "Save" );
 	if (slot == -1) {
-		return;
+		return false;
 	}
 
 	doSaveGame(slot, _saveFileName.c_str());
@@ -406,9 +407,7 @@
 	GUI::TimedMessageDialog dialog("Saving game...", 1500);
 	dialog.runModal();
 
-	return;
-
-
+	return true;
 }
 
 


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