[Scummvm-cvs-logs] SF.net SVN: scummvm: [28714] scummvm/trunk/engines/lure

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Sat Aug 25 08:08:03 CEST 2007


Revision: 28714
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28714&view=rev
Author:   dreammaster
Date:     2007-08-24 23:08:02 -0700 (Fri, 24 Aug 2007)

Log Message:
-----------
Completed the restart/restore dialog screen and functionality

Modified Paths:
--------------
    scummvm/trunk/engines/lure/game.cpp
    scummvm/trunk/engines/lure/game.h
    scummvm/trunk/engines/lure/res.cpp
    scummvm/trunk/engines/lure/res.h
    scummvm/trunk/engines/lure/res_struct.cpp
    scummvm/trunk/engines/lure/res_struct.h
    scummvm/trunk/engines/lure/room.cpp
    scummvm/trunk/engines/lure/surface.cpp

Modified: scummvm/trunk/engines/lure/game.cpp
===================================================================
--- scummvm/trunk/engines/lure/game.cpp	2007-08-25 06:06:18 UTC (rev 28713)
+++ scummvm/trunk/engines/lure/game.cpp	2007-08-25 06:08:02 UTC (rev 28714)
@@ -46,7 +46,7 @@
 	int_game = this;
 	_debugger = new Debugger();
 	_slowSpeedFlag = true;
-	_preloadFlag = true;
+	_preloadFlag = false;
 	_soundFlag = true;
 }
 
@@ -130,23 +130,30 @@
 	uint32 timerVal2 = system.getMillis();
 
 	screen.empty();
-	//_screen.resetPalette();
 	screen.setPaletteEmpty();
 
+	// Flag for starting game
+	setState(GS_RESTART);       
+
 	while (!events.quitFlag) {
-		setState(0);
-		Script::execute(STARTUP_SCRIPT);
+		
+		if ((_state & GS_RESTART) != 0) {
+			res.reset();
 
-		int bootParam = ConfMan.getInt("boot_param");
-		handleBootParam(bootParam);
+			setState(0);
+			Script::execute(STARTUP_SCRIPT);
 
+			int bootParam = ConfMan.getInt("boot_param");
+			handleBootParam(bootParam);
+if (bootParam == 1) _state = GS_RESTORE_RESTART; //******DEBUG******
+		}
+
 		// Set the player direction
-		res.getActiveHotspot(PLAYER_ID)->setDirection(UP);
+//		res.getActiveHotspot(PLAYER_ID)->setDirection(UP);
 
 		room.update();
 		mouse.setCursorNum(CURSOR_ARROW);
 		mouse.cursorOn();
-if (bootParam == 1) _state = GS_RESTORE_RESTART; //******DEBUG******
 
 		// Main game loop
 		while (!events.quitFlag && ((_state & GS_RESTART) == 0)) {
@@ -188,48 +195,46 @@
 							SaveRestoreDialog::show(false);
 							break;
 
-						default:
-							handled = false;
-					}
-					if (handled)
-						continue;
+						case Common::KEYCODE_F9:
+							doRestart();
+							break;
 
-					// Handle any remaining standard keys
-					switch (events.event().kbd.keycode) {
-					case Common::KEYCODE_ESCAPE:
-						events.quitFlag = true;
-						break;
+						case Common::KEYCODE_KP_PLUS:
+							while (++roomNum <= 51) 
+								if (res.getRoom(roomNum) != NULL) break; 
+							if (roomNum == 52) roomNum = 1;
 
-					case '+':
-						while (++roomNum <= 51) 
-							if (res.getRoom(roomNum) != NULL) break; 
-						if (roomNum == 52) roomNum = 1;
+							room.leaveRoom();
+							room.setRoomNumber(roomNum);
+							break;
 
-						room.leaveRoom();
-						room.setRoomNumber(roomNum);
-						break;
+						case Common::KEYCODE_KP_MINUS:
+							if (roomNum == 1) roomNum = 55;
+							while (res.getRoom(--roomNum) == NULL) ;
 
-					case '-':
-						if (roomNum == 1) roomNum = 55;
-						while (res.getRoom(--roomNum) == NULL) ;
+							room.leaveRoom();
+							room.setRoomNumber(roomNum);
+							break;
 
-						room.leaveRoom();
-						room.setRoomNumber(roomNum);
-						break;
+						case Common::KEYCODE_KP_MULTIPLY:
+							res.getActiveHotspot(PLAYER_ID)->setRoomNumber(
+								room.roomNumber());
+							break;
 
-					case '*':
-						res.getActiveHotspot(PLAYER_ID)->setRoomNumber(
-							room.roomNumber());
-						break;
+						case Common::KEYCODE_KP_DIVIDE:
+						case Common::KEYCODE_SLASH:
+							room.setShowInfo(!room.showInfo());
+							break;
 
-					case Common::KEYCODE_KP_DIVIDE:
-					case Common::KEYCODE_SLASH:
-						room.setShowInfo(!room.showInfo());
-						break;
+						case Common::KEYCODE_ESCAPE:
+							doQuit();
+							break;
 
-					default:
-						break;
+						default:
+							handled = false;
 					}
+					if (handled)
+						continue;
 				}
 
 				if ((events.type() == Common::EVENT_LBUTTONDOWN) ||
@@ -260,7 +265,6 @@
 		}
 
 		room.leaveRoom();
-		screen.paletteFadeOut();
 
 		// If Skorl catches player, show the catching animation
 		if ((_state & GS_CAUGHT) != 0) {
@@ -270,7 +274,7 @@
 			mouse.cursorOff();
 			Sound.addSound(0x33);
 			anim->show();
-			mouse.cursorOn();
+			delete anim;
 		}
 
 		// If the Restart/Restore dialog is needed, show it
@@ -278,12 +282,9 @@
 			// Show the Restore/Restart dialog 
 			bool restartFlag = RestartRestoreDialog::show();
 
-			setState(0);
-				
-			if (restartFlag) {
-				res.reloadData();
-				Script::execute(STARTUP_SCRIPT);
-			}
+			if (restartFlag)
+				setState(GS_RESTART);
+
 		} else if ((_state & GS_RESTART) == 0)
 			// Exiting game
 			events.quitFlag = true;
@@ -299,6 +300,7 @@
 		break;
 
 	case MENUITEM_RESTART_GAME: 
+		doQuit();
 		break;
 
 	case MENUITEM_SAVE_GAME:
@@ -863,31 +865,13 @@
 }
 
 void Game::doQuit() {
-	Mouse &mouse = Mouse::getReference();
-	Events &events = Events::getReference();
-	Screen &screen = Screen::getReference();
+	if (getYN()) 
+		Events::getReference().quitFlag = true;
+}
 
-	mouse.cursorOff();
-	Surface *s = Surface::newDialog(190, "Are you sure (y/n)?");
-	s->centerOnScreen();
-	delete s;
-
-	Common::KeyCode key = Common::KEYCODE_INVALID;
-	do {
-		if (events.pollEvent()) {
-			if (events.event().type == Common::EVENT_KEYDOWN) {
-				key = events.event().kbd.keycode;
-			}
-		}
-	} while ((key != Common::KEYCODE_ESCAPE) &&
-	         (key != Common::KEYCODE_y) &&
-	         (key != Common::KEYCODE_n));
-
-	events.quitFlag = (key == Common::KEYCODE_n);
-	if (!events.quitFlag) {
-		screen.update();
-		mouse.cursorOn();
-	}
+void Game::doRestart() {
+	if (getYN())
+		setState(GS_RESTART);
 }
 
 void Game::doTextSpeed() {
@@ -948,7 +932,53 @@
 
 		room.setRoomNumber(2);
 		break;
+
+	default:
+		room.setRoomNumber(value);
+		break;
 	}
 }
 
+bool Game::getYN() {
+	Mouse &mouse = Mouse::getReference();
+	Events &events = Events::getReference();
+	Screen &screen = Screen::getReference();
+
+	mouse.cursorOff();
+	Surface *s = Surface::newDialog(190, "Are you sure (y/n)?");
+	s->centerOnScreen();
+	delete s;
+
+	bool breakFlag = false;
+	bool result = false; 
+
+	do {
+		if (events.pollEvent()) {
+			if (events.event().type == Common::EVENT_KEYDOWN) {
+				Common::KeyCode key = events.event().kbd.keycode;
+				if ((key == Common::KEYCODE_y) || (key == Common::KEYCODE_n) ||
+					(key == Common::KEYCODE_ESCAPE)) {
+					breakFlag = true;
+					result = key == Common::KEYCODE_y;
+				}
+			}
+			if (events.event().type == Common::EVENT_LBUTTONUP) {
+				breakFlag = true;
+				result = true;
+			}
+			if (events.event().type == Common::EVENT_RBUTTONUP) {
+				breakFlag = true;
+				result = false;
+			}
+		}
+
+		g_system->delayMillis(10);
+	} while (!events.quitFlag && !breakFlag);
+
+	screen.update();
+	mouse.cursorOn();
+
+	return result;
+}
+
 } // end of namespace Lure

Modified: scummvm/trunk/engines/lure/game.h
===================================================================
--- scummvm/trunk/engines/lure/game.h	2007-08-25 06:06:18 UTC (rev 28713)
+++ scummvm/trunk/engines/lure/game.h	2007-08-25 06:08:02 UTC (rev 28714)
@@ -63,7 +63,7 @@
 	void displayChuteAnimation();
 	void displayBarrelAnimation();
 	void handleBootParam(int value);
-	int restartRestoreScreen();
+	bool getYN();
 public:
 	Game();
 	virtual ~Game();
@@ -81,6 +81,7 @@
 	void doDebugMenu();
 	void doShowCredits();
 	void doQuit();
+	void doRestart();
 	void doTextSpeed();
 	void doSound();
 };

Modified: scummvm/trunk/engines/lure/res.cpp
===================================================================
--- scummvm/trunk/engines/lure/res.cpp	2007-08-25 06:06:18 UTC (rev 28713)
+++ scummvm/trunk/engines/lure/res.cpp	2007-08-25 06:08:02 UTC (rev 28714)
@@ -62,11 +62,16 @@
 	_indexedRoomExitHospots.clear();
 	_pausedList.clear();
 	_stringList.clear();
+	_actionsList.clear();
+	_coordinateList.clear();
+	_talkHeaders.clear();
+	_talkData.clear();
 
+	free(_hotspotScriptData);
 	delete _paletteSubset;
 	delete _scriptData;
 	delete _script2Data;
-	free(_hotspotScriptData);
+	delete _talkDialogData;
 	delete _messagesData;
 	delete _cursors;
 	delete [] _charOffsets;
@@ -77,6 +82,13 @@
 	MovementDataList *list;
 };
 
+void Resources::reset() {
+	freeData();
+
+	_fieldList.reset();
+	reloadData();
+}
+
 void Resources::reloadData() {
 	Disk &d = Disk::getReference();
 	MemoryBlock *mb, *paths;

Modified: scummvm/trunk/engines/lure/res.h
===================================================================
--- scummvm/trunk/engines/lure/res.h	2007-08-25 06:06:18 UTC (rev 28713)
+++ scummvm/trunk/engines/lure/res.h	2007-08-25 06:08:02 UTC (rev 28714)
@@ -88,12 +88,13 @@
 	int _talkStartEntry;
 	uint16 _talkingCharacter;
 
+	void reloadData();
 	void freeData();
 public:
 	Resources();
 	~Resources();
 	static Resources &getReference();
-	void reloadData();
+	void reset();
 
 	byte *getResource(uint16 resId);
 	RoomDataList &roomData() { return _roomData; }

Modified: scummvm/trunk/engines/lure/res_struct.cpp
===================================================================
--- scummvm/trunk/engines/lure/res_struct.cpp	2007-08-25 06:06:18 UTC (rev 28713)
+++ scummvm/trunk/engines/lure/res_struct.cpp	2007-08-25 06:08:02 UTC (rev 28714)
@@ -1206,12 +1206,16 @@
 // Field list and miscellaneous variables
 
 ValueTableData::ValueTableData() {
+	reset();
+}
+
+void ValueTableData::reset() {
 	_numGroats = 0;
 	_playerNewPos.roomNumber = 0;
 	_playerNewPos.position.x = 0;
 	_playerNewPos.position.y = 0;
 	_flags = GAMEFLAG_4 | GAMEFLAG_1;
-	_hdrFlagMask = 1;
+	_hdrFlagMask = 1;    
 
 	for (uint16 index = 0; index < NUM_VALUE_FIELDS; ++index)
 		_fieldList[index] = 0;

Modified: scummvm/trunk/engines/lure/res_struct.h
===================================================================
--- scummvm/trunk/engines/lure/res_struct.h	2007-08-25 06:06:18 UTC (rev 28713)
+++ scummvm/trunk/engines/lure/res_struct.h	2007-08-25 06:08:02 UTC (rev 28714)
@@ -839,6 +839,7 @@
 	bool isKnownField(uint16 fieldIndex);
 public:
 	ValueTableData();
+	void reset();
 	uint16 getField(uint16 fieldIndex);
 	uint16 getField(FieldName fieldName);
 

Modified: scummvm/trunk/engines/lure/room.cpp
===================================================================
--- scummvm/trunk/engines/lure/room.cpp	2007-08-25 06:06:18 UTC (rev 28713)
+++ scummvm/trunk/engines/lure/room.cpp	2007-08-25 06:08:02 UTC (rev 28714)
@@ -492,13 +492,13 @@
 }
 
 void Room::setRoomNumber(uint16 newRoomNumber, bool showOverlay) {
-	Resources &r = Resources::getReference();
+	Resources &res = Resources::getReference();
 	Game &game = Game::getReference();
 	Mouse &mouse = Mouse::getReference();
 
 	mouse.pushCursorNum(CURSOR_DISK);
 
-	_roomData = r.getRoom(newRoomNumber);
+	_roomData = res.getRoom(newRoomNumber);
 	if (!_roomData)
 		error("Tried to change to non-existant room: %d", newRoomNumber);
 	bool leaveFlag = (_layers[0] && (newRoomNumber != _roomNumber) && (_roomNumber != 0));
@@ -512,6 +512,7 @@
 	}
 
 	_screen.empty();
+	_screen.setPaletteEmpty(GAME_COLOURS);
 
 	_numLayers = _roomData->numLayers;
 	if (showOverlay) ++_numLayers;
@@ -521,20 +522,25 @@
 		_layers[layerNum] = new RoomLayer(_roomData->layers[layerNum],
 			layerNum == 0);
 
-	// Load in the game palette and set the non-room specific colours at the top end of the palette
+	// Load in the game palette, which contains at it's top end general GUI element colours
 	Palette mainPalette(GAME_PALETTE_RESOURCE_ID);
-	_screen.setPalette(&mainPalette, MAIN_PALETTE_SIZE, GAME_COLOURS - MAIN_PALETTE_SIZE);
+	_screen.setPalette(&mainPalette, 0, GAME_COLOURS);
 
+	// Generate the palette for the room that will be faded in
+	Palette p(MAIN_PALETTE_SIZE, NULL, RGB64);
+	Palette tempPalette(paletteId);
+	p.copyFrom(&tempPalette);
+	res.insertPaletteSubset(p);
+
 	// Set the new room number
-	r.fieldList().setField(ROOM_NUMBER, newRoomNumber);
+	res.fieldList().setField(ROOM_NUMBER, newRoomNumber);
 
 	if (_roomData->sequenceOffset != 0xffff)
 		Script::execute(_roomData->sequenceOffset);
 
 	loadRoomHotspots();
 
-	if (_roomData->exitTime != 0xffff)
-	{
+	if ((_roomData->exitTime != 0xffff) && (_roomData->exitTime != 0)) {
 		// If time has passed, animation ticks needed before room is displayed
 		int numSeconds = (g_system->getMillis() - _roomData->exitTime) / 1000;
 		if (numSeconds > 300) numSeconds = 300;
@@ -545,14 +551,9 @@
 		game.preloadFlag() = false;
 	}
 
+	game.tick();
 	update();
 	_screen.update();
-
-	// Generate the palette for the room and fade it in
-	Palette p(MAIN_PALETTE_SIZE, NULL, RGB64);
-	Palette tempPalette(paletteId);
-	p.copyFrom(&tempPalette);
-	r.insertPaletteSubset(p);
 	_screen.paletteFadeIn(&p);
 
 	mouse.popCursor();

Modified: scummvm/trunk/engines/lure/surface.cpp
===================================================================
--- scummvm/trunk/engines/lure/surface.cpp	2007-08-25 06:06:18 UTC (rev 28713)
+++ scummvm/trunk/engines/lure/surface.cpp	2007-08-25 06:08:02 UTC (rev 28714)
@@ -632,7 +632,6 @@
 	Screen &screen = Screen::getReference();
 	Mouse &mouse = Mouse::getReference();
 	Events &events = Events::getReference();
-	Room &room = Room::getReference();
 	Resources &res = Resources::getReference();
 	LureEngine &engine = LureEngine::getReference();
 	int selectedLine = -1;
@@ -656,7 +655,6 @@
 		return false;
 	}
 
-	room.update();
 	Surface *s = new Surface(INFO_DIALOG_WIDTH, SR_SAVEGAME_NAMES_Y + 
 		numSaves * FONT_HEIGHT + FONT_HEIGHT + 2);
 
@@ -799,8 +797,7 @@
 };
 
 
-bool RestartRestoreDialog::show()
-{
+bool RestartRestoreDialog::show() {
 	Resources &res = Resources::getReference();
 	Events &events = Events::getReference();
 	Mouse &mouse = Mouse::getReference();
@@ -814,6 +811,7 @@
 	// See if there are any savegames that can be restored
 	String *firstSave = engine.detectSave(1);
 	bool restartFlag = (firstSave == NULL);
+	int highlightedButton = -1;
 
 	if (!restartFlag) {
 		Memory::dealloc(firstSave);
@@ -824,37 +822,93 @@
 			   (btnRecord->Language != UNK_LANG))
 			++btnRecord;
 
-		// Fade in the restart/restore screen
-		Palette p(RESTART_RESOURCE_ID + 1);
+		// Fade out the screen
+		screen.paletteFadeOut(RES_PALETTE_ENTRIES);
+
+		// Get the palette that will be used, and first fade out the prior screen
+		Palette p(RESTART_RESOURCE_ID - 1);
+
+		// Turn on the mouse
+		mouse.cursorOn();
+
+		// Load the restore/restart screen image
 		Surface *s = Surface::getScreen(RESTART_RESOURCE_ID);
+		s->copyTo(&screen.screen(), 0, MENUBAR_Y_SIZE);
+		delete s;
 
 		res.activeHotspots().clear();
 		Hotspot *btnHotspot = new Hotspot();
+
 		// Restart button
 		btnHotspot->setSize(btnRecord->width, btnRecord->height);
 		btnHotspot->setPosition(btnRecord->BtnRestart.x, btnRecord->BtnRestart.y);
 		btnHotspot->setAnimation(0x184B);
-		btnHotspot->copyTo(s);
+		btnHotspot->copyTo(&screen.screen());
+
 		// Restore button
 		btnHotspot->setFrameNumber(1);
 		btnHotspot->setPosition(btnRecord->BtnRestore.x, btnRecord->BtnRestore.y);
-		btnHotspot->copyTo(s);
+		btnHotspot->copyTo(&screen.screen());
 
-		// Copy the surface to the screen
-		screen.setPaletteEmpty();
-		s->copyToScreen(0, 0);
-		delete s;
-
+		screen.update();
 		screen.paletteFadeIn(&p);
 
-		events.waitForPress();
-		screen.paletteFadeOut();
+		// Event loop for making selection
+		while (!events.quitFlag) {
+			// Handle events
+			if (events.pollEvent()) {
+				if ((events.type() == Common::EVENT_LBUTTONDOWN) && (highlightedButton != -1)) {
+					mouse.waitForRelease();
+					break;
+				}
+			}
 
-		//restartFlag = !SaveRestoreDialog::show(false);
+			// Check if the pointer is over either button
+			int currentButton = -1;
+			if ((mouse.y() >= btnRecord->BtnRestart.y) &&
+				(mouse.y() < btnRecord->BtnRestart.y + btnRecord->height)) {
+				// Check whether the Restart or Restore button is highlighted
+				if ((mouse.x() >= btnRecord->BtnRestart.x) &&
+					(mouse.x() < btnRecord->BtnRestart.x + btnRecord->width))
+					currentButton = 0;
+				else if ((mouse.x() >= btnRecord->BtnRestore.x) &&
+					(mouse.x() < btnRecord->BtnRestore.x + btnRecord->width))
+					currentButton = 1;
+			}
+
+			// Take care of highlighting as the selected button changes
+			if (currentButton != highlightedButton) {
+				highlightedButton = currentButton;
+
+				// Restart button
+				btnHotspot->setFrameNumber((highlightedButton == 0) ? 2 : 0);
+				btnHotspot->setPosition(btnRecord->BtnRestart.x, btnRecord->BtnRestart.y);
+				btnHotspot->copyTo(&screen.screen());
+
+				// Restore button
+				btnHotspot->setFrameNumber((highlightedButton == 1) ? 3 : 1);
+				btnHotspot->setPosition(btnRecord->BtnRestore.x, btnRecord->BtnRestore.y);
+				btnHotspot->copyTo(&screen.screen());
+			}
+
+
+			screen.update();
+			g_system->delayMillis(10);
+		}
+
+		restartFlag = highlightedButton == 0;
+		delete btnHotspot;
 	}
 
 	Sound.killSounds();
 
+	if (!restartFlag && !events.quitFlag) {
+		// Need to show Restore game dialog
+		if (!SaveRestoreDialog::show(false))
+			// User cancelled, so fall back on Restart
+			restartFlag = true;
+	}
+
 	return restartFlag;
 }
 


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