diff options
Diffstat (limited to 'engines/wintermute/base')
-rw-r--r-- | engines/wintermute/base/base_engine.cpp | 3 | ||||
-rw-r--r-- | engines/wintermute/base/base_engine.h | 9 | ||||
-rw-r--r-- | engines/wintermute/base/base_game.cpp | 5 | ||||
-rw-r--r-- | engines/wintermute/base/base_game.h | 2 | ||||
-rw-r--r-- | engines/wintermute/base/base_game_settings.cpp | 5 | ||||
-rw-r--r-- | engines/wintermute/base/base_game_settings.h | 1 | ||||
-rw-r--r-- | engines/wintermute/base/base_keyboard_state.cpp | 48 | ||||
-rw-r--r-- | engines/wintermute/base/base_sprite.cpp | 15 | ||||
-rw-r--r-- | engines/wintermute/base/base_string_table.cpp | 9 | ||||
-rw-r--r-- | engines/wintermute/base/base_string_table.h | 1 | ||||
-rw-r--r-- | engines/wintermute/base/sound/base_sound.cpp | 18 | ||||
-rw-r--r-- | engines/wintermute/base/sound/base_sound_buffer.cpp | 29 | ||||
-rw-r--r-- | engines/wintermute/base/sound/base_sound_buffer.h | 15 | ||||
-rw-r--r-- | engines/wintermute/base/sound/base_sound_manager.cpp | 8 |
14 files changed, 135 insertions, 33 deletions
diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index 7c2e9c8468..2166a3e070 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -61,10 +61,11 @@ BaseEngine::~BaseEngine() { delete _classReg; } -void BaseEngine::createInstance(const Common::String &targetName, const Common::String &gameId, Common::Language lang) { +void BaseEngine::createInstance(const Common::String &targetName, const Common::String &gameId, Common::Language lang, WMETargetExecutable targetExecutable) { instance()._targetName = targetName; instance()._gameId = gameId; instance()._language = lang; + instance()._targetExecutable = targetExecutable; instance().init(); } diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index dd82cf9c29..0f4a6b0775 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -34,6 +34,8 @@ #include "common/random.h" #include "common/language.h" +#include "engines/wintermute/game_description.h" + namespace Wintermute { class BaseFileManager; @@ -53,10 +55,12 @@ class BaseEngine : public Common::Singleton<Wintermute::BaseEngine> { Common::RandomSource *_rnd; SystemClassRegistry *_classReg; Common::Language _language; + WMETargetExecutable _targetExecutable; public: BaseEngine(); ~BaseEngine(); - static void createInstance(const Common::String &targetName, const Common::String &gameId, Common::Language lang); + static void createInstance(const Common::String &targetName, const Common::String &gameId, Common::Language lang, WMETargetExecutable targetExecutable = LATEST_VERSION); + void setGameRef(BaseGame *gameRef) { _gameRef = gameRef; } Common::RandomSource *getRandomSource() { return _rnd; } @@ -73,6 +77,9 @@ public: const char *getGameTargetName() const { return _targetName.c_str(); } Common::String getGameId() const { return _gameId; } Common::Language getLanguage() const { return _language; } + WMETargetExecutable getTargetExecutable() const { + return _targetExecutable; + } }; } // End of namespace Wintermute diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 8df39c825a..668053bb3a 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -3896,6 +3896,11 @@ void BaseGame::expandStringByStringTable(char **str) const { _settings->expandStringByStringTable(str); } +////////////////////////////////////////////////////////////////////////// +void BaseGame::expandStringByStringTable(Common::String &str) const { + _settings->expandStringByStringTable(str); +} + char *BaseGame::getKeyFromStringTable(const char *str) const { return _settings->getKeyFromStringTable(str); } diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index cdbbff6c93..e535cc9618 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -123,6 +123,7 @@ public: inline BaseObject *getMainObject() { return _mainObject; } inline BaseFont *getSystemFont() { return _systemFont; } + inline BaseFont *getVideoFont() { return _videoFont; } bool initInput(); bool initLoop(); @@ -140,6 +141,7 @@ public: // String Table void expandStringByStringTable(char **str) const; + void expandStringByStringTable(Common::String &str) const; char *getKeyFromStringTable(const char *str) const; void LOG(bool res, const char *fmt, ...); diff --git a/engines/wintermute/base/base_game_settings.cpp b/engines/wintermute/base/base_game_settings.cpp index 61c5894be3..996bada997 100644 --- a/engines/wintermute/base/base_game_settings.cpp +++ b/engines/wintermute/base/base_game_settings.cpp @@ -215,6 +215,11 @@ void BaseGameSettings::expandStringByStringTable(char **str) const { _stringTable->expand(str); } +////////////////////////////////////////////////////////////////////////// +void BaseGameSettings::expandStringByStringTable(Common::String &str) const { + _stringTable->expand(str); +} + char *BaseGameSettings::getKeyFromStringTable(const char *str) const { return _stringTable->getKey(str); } diff --git a/engines/wintermute/base/base_game_settings.h b/engines/wintermute/base/base_game_settings.h index 2059cb075e..15afb06450 100644 --- a/engines/wintermute/base/base_game_settings.h +++ b/engines/wintermute/base/base_game_settings.h @@ -46,6 +46,7 @@ public: bool loadSettings(const char *filename); bool loadStringTable(const char *filename, bool clearOld); void expandStringByStringTable(char **str) const; + void expandStringByStringTable(Common::String &str) const; char *getKeyFromStringTable(const char *str) const; bool persist(BasePersistenceManager *persistMgr); diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 61087c5836..0babc07586 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -278,10 +278,24 @@ uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) { enum VKeyCodes { kVkEscape = 27, kVkSpace = 32, + kVkHome = 36, kVkLeft = 37, kVkUp = 38, kVkRight = 39, - kVkDown = 40 + kVkDown = 40, + + kVkF1 = 112, + kVkF2 = 113, + kVkF3 = 114, + kVkF4 = 115, + kVkF5 = 116, + kVkF6 = 117, + kVkF7 = 118, + kVkF8 = 119, + kVkF9 = 120, + kVkF10 = 121, + kVkF11 = 122, + kVkF12 = 123 }; ////////////////////////////////////////////////////////////////////////// @@ -290,22 +304,42 @@ Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { switch (vkey) { case kVkEscape: return Common::KEYCODE_ESCAPE; - break; case kVkSpace: return Common::KEYCODE_SPACE; - break; + case kVkHome: + return Common::KEYCODE_HOME; case kVkLeft: return Common::KEYCODE_LEFT; - break; case kVkRight: return Common::KEYCODE_RIGHT; - break; case kVkUp: return Common::KEYCODE_UP; - break; case kVkDown: return Common::KEYCODE_DOWN; - break; + case kVkF1: + return Common::KEYCODE_F1; + case kVkF2: + return Common::KEYCODE_F2; + case kVkF3: + return Common::KEYCODE_F3; + case kVkF4: + return Common::KEYCODE_F4; + case kVkF5: + return Common::KEYCODE_F5; + case kVkF6: + return Common::KEYCODE_F6; + case kVkF7: + return Common::KEYCODE_F7; + case kVkF8: + return Common::KEYCODE_F8; + case kVkF9: + return Common::KEYCODE_F9; + case kVkF10: + return Common::KEYCODE_F10; + case kVkF11: + return Common::KEYCODE_F11; + case kVkF12: + return Common::KEYCODE_F12; default: warning("Unknown VKEY: %d", vkey); return (Common::KeyCode)vkey; diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 04060bff32..09e138a1fd 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -41,6 +41,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/game_description.h" namespace Wintermute { @@ -347,9 +348,17 @@ void BaseSprite::reset() { } else { _currentFrame = -1; } - - killAllSounds(); - + if (BaseEngine::instance().getTargetExecutable() >= WME_1_8_6) { + /* + * This was added in WME 1.8.6 + * + * 5MA and possibly other games ship with pre-1.8.6 WME, and + * depends (e.g.: menu sounds, etc) on this not being triggered. + * + * See bug #6647 + */ + killAllSounds(); + } _lastFrameTime = 0; _finished = false; _moveX = _moveY = 0; diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 89407a7b0e..4c750ebc93 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -147,6 +147,15 @@ void BaseStringTable::expand(char **str) const { } } +////////////////////////////////////////////////////////////////////////// +void BaseStringTable::expand(Common::String &str) const { + char *tmp = new char[str.size()+1]; + strcpy(tmp, str.c_str()); + expand(&tmp); + str = tmp; + delete[] tmp; +} + ////////////////////////////////////////////////////////////////////////// const char *BaseStringTable::expandStatic(const char *string) const { diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index cdcf11917d..cfa3eeb226 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -41,6 +41,7 @@ class BaseStringTable : public BaseClass { public: bool loadFile(const char *filename, bool deleteAll = true); void expand(char **str) const; + void expand(Common::String &str) const; const char *expandStatic(const char *string) const; bool addString(const char *key, const char *val, bool reportDuplicities = true); BaseStringTable(BaseGame *inGame); diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index fa452cc0d6..b5b12d55f9 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -89,7 +89,7 @@ bool BaseSound::setSoundSimple() { _sound->setLooping(_soundLooping); _sound->setPrivateVolume(_soundPrivateVolume); _sound->setLoopStart(_soundLoopStart); - _sound->_freezePaused = _soundFreezePaused; + _sound->setFreezePaused(_soundFreezePaused); if (_soundPlaying) { return _sound->resume(); } else { @@ -130,7 +130,7 @@ bool BaseSound::pause(bool freezePaused) { if (_sound) { _soundPaused = true; if (freezePaused) { - _sound->_freezePaused = true; + _sound->setFreezePaused(true); } return _sound->pause(); } else { @@ -150,13 +150,13 @@ bool BaseSound::resume() { bool BaseSound::persist(BasePersistenceManager *persistMgr) { if (persistMgr->getIsSaving() && _sound) { _soundPlaying = _sound->isPlaying(); - _soundLooping = _sound->_looping; - _soundPrivateVolume = _sound->_privateVolume; + _soundLooping = _sound->isLooping(); + _soundPrivateVolume = _sound->getPrivateVolume(); if (_soundPlaying) { _soundPosition = _sound->getPosition(); } - _soundLoopStart = _sound->_loopStart; - _soundFreezePaused = _sound->_freezePaused; + _soundLoopStart = _sound->getLoopStart(); + _soundFreezePaused = _sound->isFreezePaused(); } if (persistMgr->getIsSaving()) { @@ -232,7 +232,7 @@ bool BaseSound::setPrivateVolume(int volume) { if (!_sound) { return STATUS_FAILED; } else { - _sound->_privateVolume = volume; + _sound->setPrivateVolume(volume); return STATUS_OK; } } @@ -241,7 +241,7 @@ int BaseSound::getVolumePercent() { if (!_sound) { return 0; } else { - return _sound->_privateVolume * 100 / 255; + return _sound->getPrivateVolume() * 100 / 255; } } @@ -249,7 +249,7 @@ int BaseSound::getVolume() { if (!_sound) { return 0; } else { - return _sound->_privateVolume; + return _sound->getPrivateVolume(); } } diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 7ec68ea752..5fdac12cef 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -143,8 +143,13 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) { _stream->seek(startSample); _handle = new Audio::SoundHandle; if (_looping) { - Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); - g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, _pan, DisposeAfterUse::YES); + if (_loopStart != 0) { + Audio::AudioStream *loopStream = new Audio::SubLoopingAudioStream(_stream, 0, Audio::Timestamp(_loopStart, _stream->getRate()), _stream->getLength(), DisposeAfterUse::NO); + g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, _pan, DisposeAfterUse::YES); + } else { + Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); + g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, _pan, DisposeAfterUse::YES); + } } else { g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, _pan, DisposeAfterUse::NO); } @@ -296,4 +301,24 @@ bool BaseSoundBuffer::applyFX(TSFXType type, float param1, float param2, float p return STATUS_OK; } +int32 BaseSoundBuffer::getPrivateVolume() const { + return _privateVolume; +} + +bool BaseSoundBuffer::isLooping() const { + return _looping; +} + +bool BaseSoundBuffer::isFreezePaused() const { + return _freezePaused; +} + +void BaseSoundBuffer::setFreezePaused(bool freezePaused) { + _freezePaused = freezePaused; +} + +Audio::Mixer::SoundType BaseSoundBuffer::getType() const { + return _type; +} + } // End of namespace Wintermute diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h index 94bc8dc6ad..b3f3046674 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -71,23 +71,26 @@ public: void updateVolume(); void setType(Audio::Mixer::SoundType Type); + Audio::Mixer::SoundType getType() const; bool loadFromFile(const Common::String &filename, bool forceReload = false); void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); bool applyFX(TSFXType type, float param1, float param2, float param3, float param4); - + int32 getPrivateVolume() const; + void setFreezePaused(bool freezePaused); + bool isFreezePaused() const; + bool isLooping() const; //HSTREAM _stream; //HSYNC _sync; + +private: + Audio::Mixer::SoundType _type; Audio::SeekableAudioStream *_stream; Audio::SoundHandle *_handle; - bool _freezePaused; - uint32 _loopStart; - Audio::Mixer::SoundType _type; bool _looping; - int32 _privateVolume; -private: + uint32 _loopStart; uint32 _startPos; Common::String _filename; bool _streamed; diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 41cfe5ea62..f1e0c3b1f9 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -254,9 +254,9 @@ byte BaseSoundMgr::getMasterVolume() { bool BaseSoundMgr::pauseAll(bool includingMusic) { for (uint32 i = 0; i < _sounds.size(); i++) { - if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { + if (_sounds[i]->isPlaying() && (_sounds[i]->getType() != Audio::Mixer::kMusicSoundType || includingMusic)) { _sounds[i]->pause(); - _sounds[i]->_freezePaused = true; + _sounds[i]->setFreezePaused(true); } } @@ -268,9 +268,9 @@ bool BaseSoundMgr::pauseAll(bool includingMusic) { bool BaseSoundMgr::resumeAll() { for (uint32 i = 0; i < _sounds.size(); i++) { - if (_sounds[i]->_freezePaused) { + if (_sounds[i]->isFreezePaused()) { _sounds[i]->resume(); - _sounds[i]->_freezePaused = false; + _sounds[i]->setFreezePaused(false); } } |