[Scummvm-cvs-logs] scummvm master -> 5f2687fdb3a1f5543b4214db0170317c039e60ac

dreammaster dreammaster at scummvm.org
Sat Jul 26 04:10:59 CEST 2014


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:
5f2687fdb3 MADS: Main menu background is now correctly loading


Commit: 5f2687fdb3a1f5543b4214db0170317c039e60ac
    https://github.com/scummvm/scummvm/commit/5f2687fdb3a1f5543b4214db0170317c039e60ac
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-07-25T22:07:34-04:00

Commit Message:
MADS: Main menu background is now correctly loading

Changed paths:
    engines/mads/dialogs.h
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/dialogs_nebular.h
    engines/mads/nebular/menu_nebular.cpp
    engines/mads/nebular/menu_nebular.h
    engines/mads/scene.cpp



diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index aad29f6..c2d5bba 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -201,7 +201,8 @@ public:
 
 enum DialogId {
 	DIALOG_NONE = 0, DIALOG_GAME_MENU = 1, DIALOG_SAVE = 2, DIALOG_RESTORE = 3,
-	DIALOG_OPTIONS = 4, DIALOG_DIFFICULTY = 5, DIALOG_ERROR = 6
+	DIALOG_OPTIONS = 4, DIALOG_DIFFICULTY = 5, DIALOG_ERROR = 6,
+	DIALOG_MAIN_MENU = 7
 };
 
 class Dialogs {
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 4e237ea..63b16d8 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -33,6 +33,7 @@
 #include "mads/staticres.h"
 #include "mads/nebular/dialogs_nebular.h"
 #include "mads/nebular/game_nebular.h"
+#include "mads/nebular/menu_nebular.h"
 
 namespace MADS {
 
@@ -270,6 +271,12 @@ bool DialogsNebular::commandCheck(const char *idStr, Common::String &valStr,
 
 void DialogsNebular::showDialog() {
 	switch (_pendingDialog) {
+	case DIALOG_MAIN_MENU: {
+		MainMenu *menu = new MainMenu(_vm);
+		menu->show();
+		delete menu;
+		break;
+	}
 	case DIALOG_DIFFICULTY: {
 		DifficultyDialog *dlg = new DifficultyDialog(_vm);
 		dlg->show();
@@ -526,6 +533,7 @@ void PictureDialog::restore() {
 
 FullScreenDialog::FullScreenDialog(MADSEngine *vm) : _vm(vm) {
 	_screenId = 990;
+	_palFlag = true;
 }
 
 FullScreenDialog::~FullScreenDialog() {
@@ -540,12 +548,7 @@ void FullScreenDialog::display() {
 	int currentSceneId = scene._currentSceneId;
 	int priorSceneId = scene._priorSceneId;
 
-	if (_vm->_dialogs->_pendingDialog) {
-		palFlag = true;
-	} else {
-		_vm->_palette->initPalette();
-	}
-	scene.loadScene(_screenId, game._aaName, palFlag);
+	scene.loadScene(_screenId, game._aaName, _palFlag);
 
 	scene._priorSceneId = priorSceneId;
 	scene._currentSceneId = currentSceneId;
@@ -567,11 +570,7 @@ void FullScreenDialog::display() {
 	_vm->_screen.empty();
 	_vm->_screen.hLine(0, 20, MADS_SCREEN_WIDTH, 2);
 	_vm->_screen.hLine(0, 179, MADS_SCREEN_WIDTH, 2);
-
-	_vm->_screen.copyRectToScreen(Common::Rect(0, _vm->_screen._offset.y,
-		MADS_SCREEN_WIDTH, _vm->_screen._offset.y + 1));
-	_vm->_screen.copyRectToScreen(Common::Rect(0, _vm->_screen._offset.y + 157,
-		MADS_SCREEN_WIDTH, _vm->_screen._offset.y + 157));
+	game._scene._spriteSlots.fullRefresh();
 
 	game._fx = _vm->_screenFade == SCREEN_FADE_SMOOTH ? kTransitionFadeIn : kCenterVertTransition;
 	game._trigger = 0;
@@ -582,8 +581,6 @@ void FullScreenDialog::display() {
 	_vm->_palette->setEntry(13, 45, 45, 0);
 	_vm->_palette->setEntry(14, 63, 63, 63);
 	_vm->_palette->setEntry(15, 45, 45, 45);
-
-	_vm->_events->setCursor(CURSOR_ARROW);
 }
 
 /*------------------------------------------------------------------------*/
@@ -641,6 +638,8 @@ void GameDialog::display() {
 
 	_lineIndex = -1;
 	setClickableLines();
+
+	_vm->_events->setCursor(CURSOR_ARROW);
 }
 
 GameDialog::~GameDialog() {
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index f4003a8..fe7e656 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -120,6 +120,11 @@ protected:
 	int _screenId;
 
 	/**
+	 * Flag for palette initialization
+	 */
+	bool _palFlag;
+
+	/**
 	 * Handles displaying the screen background and dialog
 	 */
 	virtual void display();
diff --git a/engines/mads/nebular/menu_nebular.cpp b/engines/mads/nebular/menu_nebular.cpp
index c472726..f6ca990 100644
--- a/engines/mads/nebular/menu_nebular.cpp
+++ b/engines/mads/nebular/menu_nebular.cpp
@@ -37,29 +37,44 @@ namespace Nebular {
 
 MenuView::MenuView(MADSEngine *vm) : FullScreenDialog(vm) {
 	_breakFlag = false;
+	_redrawFlag = true;
+	_palFlag = false;
 }
 
-void MenuView::execute() {
-	Common::Event event;
+void MenuView::show() {
+	Scene &scene = _vm->_game->_scene;	
+	EventsManager &events = *_vm->_events;
+	display();
 
-	// Main event loop to show the view
-	while (!_breakFlag) {
-		// Handle events
-		while (g_system->getEventManager()->pollEvent(event)) {
-			onEvent(event);
-		}
+	events.hideCursor();
+
+	while (!_breakFlag && !_vm->shouldQuit()) {
+		handleEvents();
 
-		if (_vm->_events->checkForNextFrameCounter()) {
-			// Next frame drawn, so allow view to prepare for following one
-			doFrame();
+		if (_redrawFlag) {
+			scene.drawElements(_vm->_game->_fx, _vm->_game->_fx);
+			_redrawFlag = false;
 		}
 
-		// Slight delay
-		g_system->delayMillis(10);
-		_breakFlag = _vm->shouldQuit();
+		_vm->_events->waitForNextFrame();
+		_vm->_game->_fx = kTransitionNone;
+		doFrame();
 	}
 }
 
+void MenuView::display() {
+	_vm->_palette->resetGamePalette(4, 8);
+
+	FullScreenDialog::display();
+}
+
+void MenuView::handleEvents() {
+	Common::Event event;
+
+	while (g_system->getEventManager()->pollEvent(event))
+		onEvent(event);
+}
+
 /*------------------------------------------------------------------------*/
 
 MainMenu::MainMenu(MADSEngine *vm): MenuView(vm) {
@@ -182,23 +197,23 @@ bool MainMenu::onEvent(Common::Event &event) {
 void MainMenu::doFrame() {
 	int itemSize;
 
+	// Delay between animation frames on the menu
 	uint32 currTime = g_system->getMillis();
 	if (currTime < _delayTimeout)
 		return;
 	_delayTimeout = currTime + MADS_MENU_ANIM_DELAY;
 
-	// Rex Nebular handling to cycle through the animated display of the menu items
+	// If we've alerady reached the end of the menuitem animation, exit immediately
 	if (_menuItemIndex == 7)
 		return;
 
-	// If the user has chosen to skip the menu animation, show the menu immediately
+	// If the user has chosen to skip the animation, show the full menu immediately
 	if (_skipFlag && !_vm->_events->isCursorVisible()) {
 		// Clear any pending animation
 //		_savedSurface.copyTo(&_vm->_screen, Common::Point(0, MADS_MENU_Y));
 		
-		// Quickly loop through all the menuitems to display each's final frame
+		// Quickly loop through all the menu items to display each's final frame
 		while (_menuItemIndex < 7) {
-
 			if (_menuItem) {
 				// Draw the final frame of the menuitem
 				MSprite *spr = _menuItem->getFrame(0);
@@ -241,20 +256,7 @@ void MainMenu::doFrame() {
 		// Get the next menuitem resource
 		Common::String spritesName = Resources::formatName(NEBULAR_MENUSCREEN,
 			'A', ++_menuItemIndex, EXT_SS, "");
-
-		/*
-		//sprintf(resName, "RM%dA%d.SS", REX_MENUSCREEN, ++_menuItemIndex);
-		data = _vm->res()->get(resName);
-		_menuItem = new SpriteAsset(_vm, data, data->size(), resName);
-		_vm->res()->toss(resName);
-		*/
-		// Slot it into available palette space
-		/*
-		RGBList *palData = _menuItem->getRgbList();
-		_vm->_palette->addRange(palData);
-		_menuItem->translate(palData, true);
-		_itemPalData.push_back(palData);
-		*/
+		_menuItem = new SpriteAsset(_vm, spritesName, 0);
 		_frameIndex = _menuItem->getCount() - 1;
 
 		// If the final resource is now loaded, which contains the highlighted versions of 
diff --git a/engines/mads/nebular/menu_nebular.h b/engines/mads/nebular/menu_nebular.h
index 4cd6f37..e960da4 100644
--- a/engines/mads/nebular/menu_nebular.h
+++ b/engines/mads/nebular/menu_nebular.h
@@ -37,19 +37,23 @@ namespace Nebular {
 enum MADSGameAction { START_GAME, RESUME_GAME, SHOW_INTRO, CREDITS, QUOTES, EXIT };
 
 class MenuView: public FullScreenDialog {
+private:
+	void handleEvents();
 protected:
-	MADSEngine *_vm;
 	bool _breakFlag;
+	bool _redrawFlag;
 
 	virtual void doFrame() = 0;
 
 	virtual bool onEvent(Common::Event &event) = 0;
+
+	virtual void display();
 public:
 	MenuView(MADSEngine *vm);
 
 	virtual ~MenuView() {}
 
-	void execute();
+	virtual void show();
 };
 
 class MainMenu: public MenuView {
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 639f297..1f95749 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -196,21 +196,24 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 }
 
 void Scene::loadHotspots() {
-	File f(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH"));
-	MadsPack madsPack(&f);
-	bool isV2 = (_vm->getGameID() != GType_RexNebular);
+	_hotspots.clear();
 
-	Common::SeekableReadStream *stream = madsPack.getItemStream(0);
-	int count = stream->readUint16LE();
-	delete stream;
+	Common::File f;
+	if (f.open(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH"))) {
+		MadsPack madsPack(&f);
+		bool isV2 = (_vm->getGameID() != GType_RexNebular);
 
-	stream = madsPack.getItemStream(1);
-	_hotspots.clear();
-	for (int i = 0; i < count; ++i)
-		_hotspots.push_back(Hotspot(*stream, isV2));
+		Common::SeekableReadStream *stream = madsPack.getItemStream(0);
+		int count = stream->readUint16LE();
+		delete stream;
 
-	delete stream;
-	f.close();
+		stream = madsPack.getItemStream(1);
+		for (int i = 0; i < count; ++i)
+			_hotspots.push_back(Hotspot(*stream, isV2));
+
+		delete stream;
+		f.close();
+	}
 }
 
 void Scene::loadVocab() {






More information about the Scummvm-git-logs mailing list