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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Tue Apr 28 14:25:41 CEST 2009


Revision: 40176
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40176&view=rev
Author:   peres001
Date:     2009-04-28 12:25:41 +0000 (Tue, 28 Apr 2009)

Log Message:
-----------
Added in-game menu for BRA. Load/save is not supported yet.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/graphics.h
    scummvm/trunk/engines/parallaction/gui_br.cpp
    scummvm/trunk/engines/parallaction/input.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_br.cpp
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp
    scummvm/trunk/engines/parallaction/sound.h
    scummvm/trunk/engines/parallaction/sound_br.cpp

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2009-04-28 12:23:52 UTC (rev 40175)
+++ scummvm/trunk/engines/parallaction/graphics.h	2009-04-28 12:25:41 UTC (rev 40176)
@@ -278,7 +278,8 @@
 	kGfxObjTypeAnim = 2,
 	kGfxObjTypeLabel = 3,
 	kGfxObjTypeBalloon = 4,
-	kGfxObjTypeCharacter = 8
+	kGfxObjTypeCharacter = 8,
+	kGfxObjTypeMenu = 16
 };
 
 enum {

Modified: scummvm/trunk/engines/parallaction/gui_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_br.cpp	2009-04-28 12:23:52 UTC (rev 40175)
+++ scummvm/trunk/engines/parallaction/gui_br.cpp	2009-04-28 12:25:41 UTC (rev 40176)
@@ -306,12 +306,6 @@
 	kMenuPart4
 };
 
-
-
-
-
-
-
 void Parallaction_br::startGui(bool showSplash) {
 	_menuHelper = new MenuInputHelper;
 
@@ -329,7 +323,126 @@
 }
 
 
+class IngameMenuInputState_BR : public MenuInputState {
+	Parallaction_br *_vm;
+	GfxObj *_menuObj, *_mscMenuObj, *_sfxMenuObj;
+	int _menuObjId, _mscMenuObjId, _sfxMenuObjId;
 
+	Common::Rect _menuRect;
+	int _cellW, _cellH;
 
+	int _sfxStatus, _mscStatus;
+
+	int frameFromStatus(int status) const {
+		int frame;
+		if (status == 0) {
+			frame = 1;
+		} else
+		if (status == 1) {
+			frame = 0;
+		} else {
+			frame = 2;
+		}
+
+		return frame;
+	}
+
+public:
+	IngameMenuInputState_BR(Parallaction_br *vm, MenuInputHelper *helper) : MenuInputState("ingamemenu", helper), _vm(vm) {
+		Frames *menuFrames = _vm->_disk->loadFrames("request.win");
+		assert(menuFrames);
+		_menuObj = new GfxObj(kGfxObjTypeMenu, menuFrames, "ingamemenu");
+
+		Frames *mscFrames = _vm->_disk->loadFrames("onoff.win");
+		assert(mscFrames);
+		_mscMenuObj = new GfxObj(kGfxObjTypeMenu, mscFrames, "msc");
+
+		Frames *sfxFrames = _vm->_disk->loadFrames("sfx.win");
+		assert(sfxFrames);
+		_sfxMenuObj = new GfxObj(kGfxObjTypeMenu, sfxFrames, "sfx");
+
+		_menuObj->getRect(0, _menuRect);
+		_cellW = _menuRect.width() / 3;
+		_cellH = _menuRect.height() / 2;
+	}
+
+	MenuInputState *run() {
+		if (_vm->_input->getLastButtonEvent() != kMouseLeftUp) {
+			return this;
+		}
+
+		int cell = -1;
+
+		Common::Point p;
+		_vm->_input->getCursorPos(p);
+		if (_menuRect.contains(p)) {
+			cell = (p.x - _menuRect.left) / _cellW + 3 * ((p.y - _menuRect.top) / _cellH);
+		}
+
+		switch (cell) {
+		case 4:	// resume
+		case -1: // invalid cell
+			_vm->_gfx->freeDialogueObjects();
+			return 0;
+
+		case 0:	// toggle music
+			if (_mscStatus != -1) {
+				_vm->enableMusic(!_mscStatus);
+				_mscStatus = _vm->getMusicStatus();
+				_vm->_gfx->setItemFrame(_mscMenuObjId, frameFromStatus(_mscStatus));
+			}
+			return this;
+
+		case 1:	// toggle sfx
+			if (_sfxStatus != -1) {
+				_vm->enableSfx(!_sfxStatus);
+				_sfxStatus = _vm->getSfxStatus();
+				_vm->_gfx->setItemFrame(_sfxMenuObjId, frameFromStatus(_sfxStatus));
+			}
+			return this;
+
+		case 2:	// save
+			warning("Saving is not supported yet!");
+			_vm->_gfx->freeDialogueObjects();
+			break;
+
+		case 3:	// load
+			warning("Loading is not supported yet!");
+			_vm->_gfx->freeDialogueObjects();
+			break;
+
+		case 5:	// quit
+			_vm->quitGame();
+		}
+
+		return 0;
+	}
+
+	void enter() {
+		// TODO: find the right position of the menu object
+		_menuObjId = _vm->_gfx->setItem(_menuObj, 0, 0, 0);
+		_vm->_gfx->setItemFrame(_menuObjId, 0);
+
+		_mscMenuObjId = _vm->_gfx->setItem(_mscMenuObj, 0, 0, 0);
+		_mscStatus = _vm->getMusicStatus();
+		_vm->_gfx->setItemFrame(_mscMenuObjId, frameFromStatus(_mscStatus));
+
+		_sfxMenuObjId = _vm->_gfx->setItem(_sfxMenuObj, 0, 0, 0);
+		_sfxStatus = _vm->getSfxStatus();
+		_vm->_gfx->setItemFrame(_sfxMenuObjId, frameFromStatus(_sfxStatus));
+	}
+};
+
+void Parallaction_br::startIngameMenu() {
+	_menuHelper = new MenuInputHelper;
+
+	new IngameMenuInputState_BR(this, _menuHelper);
+	_menuHelper->setState("ingamemenu");
+
+	_input->_inputMode = Input::kInputModeMenu;
+}
+
+
+
 } // namespace Parallaction
 

Modified: scummvm/trunk/engines/parallaction/input.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/input.cpp	2009-04-28 12:23:52 UTC (rev 40175)
+++ scummvm/trunk/engines/parallaction/input.cpp	2009-04-28 12:25:41 UTC (rev 40176)
@@ -202,11 +202,21 @@
 		return event;
 	}
 
-	if (_hasKeyPressEvent && (_vm->getFeatures() & GF_DEMO) == 0) {
-		if (_keyPressed.keycode == Common::KEYCODE_l) event = kEvLoadGame;
-		if (_keyPressed.keycode == Common::KEYCODE_s) event = kEvSaveGame;
+	if (_vm->getGameType() == GType_Nippon) {
+		if (_hasKeyPressEvent && (_vm->getFeatures() & GF_DEMO) == 0) {
+			if (_keyPressed.keycode == Common::KEYCODE_l) event = kEvLoadGame;
+			if (_keyPressed.keycode == Common::KEYCODE_s) event = kEvSaveGame;
+		}
+	} else
+	if (_vm->getGameType() == GType_BRA) {
+		if (_hasKeyPressEvent && (_vm->getFeatures() & GF_DEMO) == 0) {
+			if (_keyPressed.keycode == Common::KEYCODE_F5) event = kEvIngameMenu;
+		}
+	} else {
+		error("unsupported gametype in updateGameInput");
 	}
 
+
 	if (event == kEvNone) {
 		translateGameInput();
 	}

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2009-04-28 12:23:52 UTC (rev 40175)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2009-04-28 12:25:41 UTC (rev 40176)
@@ -266,21 +266,13 @@
 	_balloonMan->setLocationBalloon(text.c_str(), end);
 }
 
-
 void Parallaction::runGameFrame(int event) {
 	if (_input->_inputMode != Input::kInputModeGame) {
 		return;
 	}
 
-	if (event != kEvNone) {
-		_input->stopHovering();
-		if (event == kEvSaveGame) {
-			_saveLoad->saveGame();
-		} else
-		if (event == kEvLoadGame) {
-			_saveLoad->loadGame();
-		}
-		_input->setArrowCursor();
+	if (!processGameEvent(event)) {
+		return;
 	}
 
 	_gfx->beginFrame();

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2009-04-28 12:23:52 UTC (rev 40175)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2009-04-28 12:25:41 UTC (rev 40176)
@@ -81,7 +81,8 @@
 enum {
 	kEvNone			= 0,
 	kEvSaveGame		= 2000,
-	kEvLoadGame		= 4000
+	kEvLoadGame		= 4000,
+	kEvIngameMenu   = 8000
 };
 
 enum ParallactionGameType {
@@ -375,6 +376,7 @@
 	virtual void updateWalkers() = 0;
 	virtual void scheduleWalk(int16 x, int16 y, bool fromUser) = 0;
 	virtual DialogueManager *createDialogueManager(ZonePtr z) = 0;
+	virtual bool processGameEvent(int event) = 0;
 };
 
 
@@ -405,6 +407,7 @@
 	virtual void updateWalkers();
 	virtual void scheduleWalk(int16 x, int16 y, bool fromUser);
 	virtual DialogueManager *createDialogueManager(ZonePtr z);
+	virtual bool processGameEvent(int event);
 
 	void	changeBackground(const char *background, const char *mask = 0, const char *path = 0);
 
@@ -507,6 +510,7 @@
 	virtual void updateWalkers();
 	virtual void scheduleWalk(int16 x, int16 y, bool fromUser);
 	virtual DialogueManager *createDialogueManager(ZonePtr z);
+	virtual bool processGameEvent(int event);
 
 	void setupSubtitles(char *s, char *s2, int y);
 	void clearSubtitles();
@@ -521,6 +525,11 @@
 
 	void	setFollower(const Common::String &name);
 
+	int		getSfxStatus();
+	int		getMusicStatus();
+	void	enableSfx(bool enable);
+	void	enableMusic(bool enable);
+
 	const char **_audioCommandsNamesRes;
 	static const char *_partNames[];
 	int			_part;
@@ -553,6 +562,7 @@
 	void	freeLocation(bool removeAll);
 	void	loadProgram(AnimationPtr a, const char *filename);
 	void	startGui(bool showSplash);
+	void 	startIngameMenu();
 	void	freeCharacter();
 
 	typedef void (Parallaction_br::*Callable)(void*);

Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp	2009-04-28 12:23:52 UTC (rev 40175)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp	2009-04-28 12:25:41 UTC (rev 40176)
@@ -126,6 +126,26 @@
 	(this->*_callables[index])(parm);
 }
 
+bool Parallaction_br::processGameEvent(int event) {
+	if (event == kEvNone) {
+		return true;
+	}
+
+	bool c = true;
+	_input->stopHovering();
+
+	switch(event) {
+	case kEvIngameMenu:
+		startIngameMenu();
+		c = false;
+		break;
+	}
+
+	_input->setArrowCursor();
+
+	return c;
+}
+
 Common::Error Parallaction_br::go() {
 
 	bool splash = true;
@@ -547,5 +567,30 @@
 	}
 }
 
+int Parallaction_br::getSfxStatus() {
+	if (!_soundManI) {
+		return -1;
+	}
+	return _soundManI->isSfxEnabled() ? 1 : 0;
+}
 
+int Parallaction_br::getMusicStatus() {
+	if (!_soundManI) {
+		return -1;
+	}
+	return _soundManI->isMusicEnabled() ? 1 : 0;
+}
+
+void Parallaction_br::enableSfx(bool enable) {
+	if (_soundManI) {
+		_soundManI->enableSfx(enable);
+	}
+}
+
+void Parallaction_br::enableMusic(bool enable) {
+	if (_soundManI) {
+		_soundManI->enableMusic(enable);
+	}
+}
+
 } // namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2009-04-28 12:23:52 UTC (rev 40175)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2009-04-28 12:25:41 UTC (rev 40176)
@@ -248,7 +248,29 @@
 	(this->*_callables[index])(parm);
 }
 
+bool Parallaction_ns::processGameEvent(int event) {
+	if (event == kEvNone) {
+		return true;
+	}
 
+	bool c = true;
+	_input->stopHovering();
+
+	switch(event) {
+	case kEvSaveGame:
+		_saveLoad->saveGame();
+		break;
+
+	case kEvLoadGame:
+		_saveLoad->loadGame();
+		break;
+	}
+
+	_input->setArrowCursor();
+
+	return c;
+}
+
 Common::Error Parallaction_ns::go() {
 	_saveLoad->renameOldSavefiles();
 

Modified: scummvm/trunk/engines/parallaction/sound.h
===================================================================
--- scummvm/trunk/engines/parallaction/sound.h	2009-04-28 12:23:52 UTC (rev 40175)
+++ scummvm/trunk/engines/parallaction/sound.h	2009-04-28 12:25:41 UTC (rev 40176)
@@ -189,6 +189,9 @@
 	int		_sfxRate;
 	uint	_sfxChannel;
 
+	bool	_musicEnabled;
+	bool	_sfxEnabled;
+
 	virtual void playMusic() = 0;
 	virtual void stopMusic() = 0;
 	virtual void pause(bool p) = 0;
@@ -210,9 +213,15 @@
 
 	virtual void playSfx(const char *filename, uint channel, bool looping, int volume = -1) { }
 	void stopSfx(uint channel);
+	void stopAllSfx();
 
 	virtual void execute(int command, const char *parm);
 	void setMusicFile(const char *parm);
+
+	void enableSfx(bool enable);
+	void enableMusic(bool enable);
+	bool isSfxEnabled() const;
+	bool isMusicEnabled() const;
 };
 
 class DosSoundMan_br : public SoundMan_br {

Modified: scummvm/trunk/engines/parallaction/sound_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/sound_br.cpp	2009-04-28 12:23:52 UTC (rev 40175)
+++ scummvm/trunk/engines/parallaction/sound_br.cpp	2009-04-28 12:25:41 UTC (rev 40176)
@@ -419,6 +419,10 @@
 void DosSoundMan_br::playSfx(const char *filename, uint channel, bool looping, int volume) {
 	stopSfx(channel);
 
+	if (!_sfxEnabled) {
+		return;
+	}
+
 	debugC(1, kDebugAudio, "DosSoundMan_br::playSfx(%s, %u, %i, %i)", filename, channel, looping, volume);
 
 	Channel *ch = &_channels[channel];
@@ -439,6 +443,10 @@
 		return;
 	}
 
+	if (!_musicEnabled) {
+		return;
+	}
+
 	Common::SeekableReadStream *s = _vm->_disk->loadMusic(_musicFile.c_str());
 	assert(s);
 	_midiPlayer->play(s);
@@ -486,6 +494,10 @@
 
 	stopSfx(channel);
 
+	if (!_sfxEnabled) {
+		return;
+	}
+
 	debugC(1, kDebugAudio, "AmigaSoundMan_ns::playSfx(%s, %i)", filename, channel);
 
 	Channel *ch = &_channels[channel];
@@ -512,6 +524,10 @@
 void AmigaSoundMan_br::playMusic() {
 	stopMusic();
 
+	if (!_musicEnabled) {
+		return;
+	}
+
 	debugC(1, kDebugAudio, "AmigaSoundMan_ns::playMusic()");
 
 	Common::SeekableReadStream *stream = _vm->_disk->loadMusic(_musicFile.c_str());
@@ -555,6 +571,10 @@
 }
 
 SoundMan_br::~SoundMan_br() {
+	stopAllSfx();
+}
+
+void SoundMan_br::stopAllSfx() {
 	stopSfx(0);
 	stopSfx(1);
 	stopSfx(2);
@@ -562,6 +582,7 @@
 }
 
 void SoundMan_br::setMusicFile(const char *name) {
+	stopMusic();
 	_musicFile = name;
 }
 
@@ -617,5 +638,28 @@
 	}
 }
 
+void SoundMan_br::enableSfx(bool enable) {
+	if (!enable) {
+		stopAllSfx();
+	}
+	_sfxEnabled = enable;
+}
 
+void SoundMan_br::enableMusic(bool enable) {
+	if (enable) {
+		playMusic();
+	} else {
+		stopMusic();
+	}
+	_musicEnabled = enable;
+}
+
+bool SoundMan_br::isSfxEnabled() const {
+	return _sfxEnabled;
+}
+
+bool SoundMan_br::isMusicEnabled() const {
+	return _musicEnabled;
+}
+
 } // namespace Parallaction


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