diff options
author | Nicola Mettifogo | 2009-04-28 12:25:41 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2009-04-28 12:25:41 +0000 |
commit | 9108871833313f88b2f10aa5c5998fa3fb23e008 (patch) | |
tree | c31d2c3bf6911d61c4631eaf6c878b132a0a9230 /engines | |
parent | 19bd929a5d84aa057da397a882ed2208fd9776e3 (diff) | |
download | scummvm-rg350-9108871833313f88b2f10aa5c5998fa3fb23e008.tar.gz scummvm-rg350-9108871833313f88b2f10aa5c5998fa3fb23e008.tar.bz2 scummvm-rg350-9108871833313f88b2f10aa5c5998fa3fb23e008.zip |
Added in-game menu for BRA. Load/save is not supported yet.
svn-id: r40176
Diffstat (limited to 'engines')
-rw-r--r-- | engines/parallaction/graphics.h | 3 | ||||
-rw-r--r-- | engines/parallaction/gui_br.cpp | 125 | ||||
-rw-r--r-- | engines/parallaction/input.cpp | 16 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 12 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 12 | ||||
-rw-r--r-- | engines/parallaction/parallaction_br.cpp | 45 | ||||
-rw-r--r-- | engines/parallaction/parallaction_ns.cpp | 22 | ||||
-rw-r--r-- | engines/parallaction/sound.h | 9 | ||||
-rw-r--r-- | engines/parallaction/sound_br.cpp | 44 |
9 files changed, 267 insertions, 21 deletions
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index e7e7c7fb41..228b0add39 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -278,7 +278,8 @@ enum { kGfxObjTypeAnim = 2, kGfxObjTypeLabel = 3, kGfxObjTypeBalloon = 4, - kGfxObjTypeCharacter = 8 + kGfxObjTypeCharacter = 8, + kGfxObjTypeMenu = 16 }; enum { diff --git a/engines/parallaction/gui_br.cpp b/engines/parallaction/gui_br.cpp index 955c7bd262..760a5b0d04 100644 --- a/engines/parallaction/gui_br.cpp +++ b/engines/parallaction/gui_br.cpp @@ -306,12 +306,6 @@ const MainMenuInputState_BR::MenuOptions MainMenuInputState_BR::_optionsPC[NUM_M kMenuPart4 }; - - - - - - void Parallaction_br::startGui(bool showSplash) { _menuHelper = new MenuInputHelper; @@ -329,6 +323,125 @@ void Parallaction_br::startGui(bool showSplash) { } +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 diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp index 92f3f026d1..d1e2765539 100644 --- a/engines/parallaction/input.cpp +++ b/engines/parallaction/input.cpp @@ -202,11 +202,21 @@ int Input::updateGameInput() { 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(); } diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index d9673f9002..7aee966aa6 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -266,21 +266,13 @@ void Parallaction::showLocationComment(const Common::String &text, bool end) { _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(); diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 4e799a048e..b5ba60a089 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -81,7 +81,8 @@ enum EngineFlags { enum { kEvNone = 0, kEvSaveGame = 2000, - kEvLoadGame = 4000 + kEvLoadGame = 4000, + kEvIngameMenu = 8000 }; enum ParallactionGameType { @@ -375,6 +376,7 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ private: 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*); diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp index 6e2ab963c2..562eb06266 100644 --- a/engines/parallaction/parallaction_br.cpp +++ b/engines/parallaction/parallaction_br.cpp @@ -126,6 +126,26 @@ void Parallaction_br::callFunction(uint index, void* parm) { (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 @@ void Parallaction_br::restoreOrSaveZoneFlags(ZonePtr z, bool restore) { } } +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 diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index d229da0d08..9604b26026 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -248,6 +248,28 @@ void Parallaction_ns::callFunction(uint index, void* parm) { (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(); diff --git a/engines/parallaction/sound.h b/engines/parallaction/sound.h index bef90a866b..f0ecea67bb 100644 --- a/engines/parallaction/sound.h +++ b/engines/parallaction/sound.h @@ -189,6 +189,9 @@ protected: 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 @@ public: 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 { diff --git a/engines/parallaction/sound_br.cpp b/engines/parallaction/sound_br.cpp index a9b734f69b..df089ceb16 100644 --- a/engines/parallaction/sound_br.cpp +++ b/engines/parallaction/sound_br.cpp @@ -419,6 +419,10 @@ void DosSoundMan_br::loadChannelData(const char *filename, Channel *ch) { 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 @@ void DosSoundMan_br::playMusic() { return; } + if (!_musicEnabled) { + return; + } + Common::SeekableReadStream *s = _vm->_disk->loadMusic(_musicFile.c_str()); assert(s); _midiPlayer->play(s); @@ -486,6 +494,10 @@ void AmigaSoundMan_br::playSfx(const char *filename, uint channel, bool looping, 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::playSfx(const char *filename, uint channel, bool looping, 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(Parallaction_br *vm) : _vm(vm) { } SoundMan_br::~SoundMan_br() { + stopAllSfx(); +} + +void SoundMan_br::stopAllSfx() { stopSfx(0); stopSfx(1); stopSfx(2); @@ -562,6 +582,7 @@ SoundMan_br::~SoundMan_br() { } void SoundMan_br::setMusicFile(const char *name) { + stopMusic(); _musicFile = name; } @@ -617,5 +638,28 @@ void SoundMan_br::execute(int command, const char *parm) { } } +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 |