diff options
author | johndoe123 | 2014-12-01 18:08:41 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2018-07-20 06:43:33 +0000 |
commit | ace0d042ec9d31956bdbb2c2f2e116a8e9860983 (patch) | |
tree | c1347330637ab927cbb3b8d7c517adf9f527aeba | |
parent | e4ce8ad4c9e9c5156270bb4c1c6f4952a011b70f (diff) | |
download | scummvm-rg350-ace0d042ec9d31956bdbb2c2f2e116a8e9860983.tar.gz scummvm-rg350-ace0d042ec9d31956bdbb2c2f2e116a8e9860983.tar.bz2 scummvm-rg350-ace0d042ec9d31956bdbb2c2f2e116a8e9860983.zip |
ILLUSIONS: Refactoring the resource system (not done yet)
-rw-r--r-- | engines/illusions/actorresource.cpp | 9 | ||||
-rw-r--r-- | engines/illusions/actorresource.h | 5 | ||||
-rw-r--r-- | engines/illusions/backgroundresource.cpp | 93 | ||||
-rw-r--r-- | engines/illusions/backgroundresource.h | 13 | ||||
-rw-r--r-- | engines/illusions/fontresource.cpp | 4 | ||||
-rw-r--r-- | engines/illusions/fontresource.h | 1 | ||||
-rw-r--r-- | engines/illusions/illusions.cpp | 4 | ||||
-rw-r--r-- | engines/illusions/illusions.h | 6 | ||||
-rw-r--r-- | engines/illusions/illusions_bbdou.cpp | 12 | ||||
-rw-r--r-- | engines/illusions/illusions_duckman.cpp | 17 | ||||
-rw-r--r-- | engines/illusions/midiresource.cpp | 3 | ||||
-rw-r--r-- | engines/illusions/midiresource.h | 1 | ||||
-rw-r--r-- | engines/illusions/resourcesystem.cpp | 6 | ||||
-rw-r--r-- | engines/illusions/resourcesystem.h | 3 | ||||
-rw-r--r-- | engines/illusions/scriptresource.cpp | 4 | ||||
-rw-r--r-- | engines/illusions/scriptresource.h | 1 | ||||
-rw-r--r-- | engines/illusions/soundresource.cpp | 42 | ||||
-rw-r--r-- | engines/illusions/soundresource.h | 12 | ||||
-rw-r--r-- | engines/illusions/talkresource.cpp | 22 | ||||
-rw-r--r-- | engines/illusions/talkresource.h | 11 |
20 files changed, 128 insertions, 141 deletions
diff --git a/engines/illusions/actorresource.cpp b/engines/illusions/actorresource.cpp index 43cb314709..3cca9171ae 100644 --- a/engines/illusions/actorresource.cpp +++ b/engines/illusions/actorresource.cpp @@ -29,11 +29,7 @@ namespace Illusions { // ActorResourceLoader void ActorResourceLoader::load(Resource *resource) { - resource->_instance = _vm->_actorItems->createActorInstance(resource); -} - -void ActorResourceLoader::unload(Resource *resource) { - // TODO Remove method + resource->_instance = _vm->_actorInstances->createActorInstance(resource); } void ActorResourceLoader::buildFilename(Resource *resource) { @@ -197,7 +193,7 @@ void ActorInstance::load(Resource *resource) { void ActorInstance::unload() { if (_pauseCtr <= 0) unregisterResources(); - _vm->_actorItems->removeActorInstance(this); + _vm->_actorInstances->removeActorInstance(this); delete _actorResource; } @@ -266,7 +262,6 @@ ActorInstance *ActorInstanceList::createActorInstance(Resource *resource) { void ActorInstanceList::removeActorInstance(ActorInstance *actorInstance) { _items.remove(actorInstance); - debug("removeActorInstance() AFTER _items.size(): %d", _items.size()); } void ActorInstanceList::pauseByTag(uint32 tag) { diff --git a/engines/illusions/actorresource.h b/engines/illusions/actorresource.h index cc8feebd44..2ccb9efd58 100644 --- a/engines/illusions/actorresource.h +++ b/engines/illusions/actorresource.h @@ -36,7 +36,6 @@ public: ActorResourceLoader(IllusionsEngine *vm) : _vm(vm) {} virtual ~ActorResourceLoader() {} virtual void load(Resource *resource); - virtual void unload(Resource *resource); virtual void buildFilename(Resource *resource); virtual bool isFlag(int flag); protected: @@ -99,8 +98,8 @@ public: ActorInstance(IllusionsEngine *vm); virtual void load(Resource *resource); virtual void unload(); - void pause(); - void unpause(); + virtual void pause(); + virtual void unpause(); public: IllusionsEngine *_vm; uint32 _tag; diff --git a/engines/illusions/backgroundresource.cpp b/engines/illusions/backgroundresource.cpp index 34a42c72c0..e8059bc4b6 100644 --- a/engines/illusions/backgroundresource.cpp +++ b/engines/illusions/backgroundresource.cpp @@ -37,10 +37,6 @@ void BackgroundResourceLoader::load(Resource *resource) { resource->_instance = _vm->_backgroundInstances->createBackgroundInstance(resource); } -void BackgroundResourceLoader::unload(Resource *resource) { - // TODO Remove method -} - void BackgroundResourceLoader::buildFilename(Resource *resource) { resource->_filename = Common::String::format("%08X.bg", resource->_resId); } @@ -415,6 +411,46 @@ void BackgroundInstance::unload() { _vm->setDefaultTextCoords(); } +void BackgroundInstance::pause() { + ++_pauseCtr; + if (_pauseCtr <= 1) { + unregisterResources(); + _vm->setDefaultTextCoords(); + _vm->_camera->getActiveState(_savedCameraState); + _savedPalette = new byte[1024]; + _vm->_screen->getPalette(_savedPalette); + freeSurface(); + } +} + +void BackgroundInstance::unpause() { + --_pauseCtr; + if (_pauseCtr <= 0) { + registerResources(); + initSurface(); + _vm->_screen->setPalette(_savedPalette, 1, 256); + delete[] _savedPalette; + _savedPalette = 0; + // TODO _vm->_screen->_fadeClear(); + _vm->_camera->setActiveState(_savedCameraState); + _vm->_backgroundInstances->refreshPan(); + } +} + +void BackgroundInstance::registerResources() { + for (uint i = 0; i < _bgRes->_regionSequencesCount; ++i) { + Sequence *sequence = &_bgRes->_regionSequences[i]; + _vm->_dict->addSequence(sequence->_sequenceId, sequence); + } +} + +void BackgroundInstance::unregisterResources() { + for (uint i = 0; i < _bgRes->_regionSequencesCount; ++i) { + Sequence *sequence = &_bgRes->_regionSequences[i]; + _vm->_dict->removeSequence(sequence->_sequenceId); + } +} + void BackgroundInstance::initSurface() { for (uint i = 0; i < kMaxBackgroundItemSurfaces; ++i) _surfaces[i] = 0; @@ -446,20 +482,6 @@ void BackgroundInstance::drawTiles(Graphics::Surface *surface, TileMap &tileMap, } } -void BackgroundInstance::registerResources() { - for (uint i = 0; i < _bgRes->_regionSequencesCount; ++i) { - Sequence *sequence = &_bgRes->_regionSequences[i]; - _vm->_dict->addSequence(sequence->_sequenceId, sequence); - } -} - -void BackgroundInstance::unregisterResources() { - for (uint i = 0; i < _bgRes->_regionSequencesCount; ++i) { - Sequence *sequence = &_bgRes->_regionSequences[i]; - _vm->_dict->removeSequence(sequence->_sequenceId); - } -} - void BackgroundInstance::drawTiles8(Graphics::Surface *surface, TileMap &tileMap, byte *tilePixels) { const int kTileWidth = 32; const int kTileHeight = 8; @@ -511,32 +533,6 @@ void BackgroundInstance::drawTiles16(Graphics::Surface *surface, TileMap &tileMa } } -void BackgroundInstance::pause() { - ++_pauseCtr; - if (_pauseCtr <= 1) { - unregisterResources(); - _vm->setDefaultTextCoords(); - _vm->_camera->getActiveState(_savedCameraState); - _savedPalette = new byte[1024]; - _vm->_screen->getPalette(_savedPalette); - freeSurface(); - } -} - -void BackgroundInstance::unpause() { - --_pauseCtr; - if (_pauseCtr <= 0) { - registerResources(); - initSurface(); - _vm->_screen->setPalette(_savedPalette, 1, 256); - delete[] _savedPalette; - _savedPalette = 0; - // TODO _vm->_screen->_fadeClear(); - _vm->_camera->setActiveState(_savedCameraState); - _vm->_backgroundInstances->refreshPan(); - } -} - // BackgroundInstanceList BackgroundInstanceList::BackgroundInstanceList(IllusionsEngine *vm) @@ -555,7 +551,6 @@ BackgroundInstance *BackgroundInstanceList::createBackgroundInstance(Resource *r void BackgroundInstanceList::removeBackgroundInstance(BackgroundInstance *backgroundInstance) { _items.remove(backgroundInstance); - debug("removeActorInstance() AFTER _items.size(): %d", _items.size()); } void BackgroundInstanceList::pauseByTag(uint32 tag) { @@ -570,7 +565,7 @@ void BackgroundInstanceList::unpauseByTag(uint32 tag) { (*it)->unpause(); } -BackgroundInstance *BackgroundInstanceList::findActiveBackground() { +BackgroundInstance *BackgroundInstanceList::findActiveBackgroundInstance() { for (ItemsIterator it = _items.begin(); it != _items.end(); ++it) if ((*it)->_pauseCtr == 0) return (*it); @@ -585,20 +580,20 @@ BackgroundInstance *BackgroundInstanceList::findBackgroundByResource(BackgroundR } BackgroundResource *BackgroundInstanceList::getActiveBgResource() { - BackgroundInstance *background = findActiveBackground(); + BackgroundInstance *background = findActiveBackgroundInstance(); if (background) return background->_bgRes; return 0; } WidthHeight BackgroundInstanceList::getMasterBgDimensions() { - BackgroundInstance *backgroundInstance = findActiveBackground(); + BackgroundInstance *backgroundInstance = findActiveBackgroundInstance(); int16 index = backgroundInstance->_bgRes->findMasterBgIndex(); return backgroundInstance->_bgRes->_bgInfos[index - 1]._surfInfo._dimensions; } void BackgroundInstanceList::refreshPan() { - BackgroundInstance *backgroundInstance = findActiveBackground(); + BackgroundInstance *backgroundInstance = findActiveBackgroundInstance(); if (backgroundInstance) { WidthHeight dimensions = getMasterBgDimensions(); _vm->_camera->refreshPan(backgroundInstance, dimensions); diff --git a/engines/illusions/backgroundresource.h b/engines/illusions/backgroundresource.h index 673f69f069..9438501916 100644 --- a/engines/illusions/backgroundresource.h +++ b/engines/illusions/backgroundresource.h @@ -47,7 +47,6 @@ public: BackgroundResourceLoader(IllusionsEngine *vm) : _vm(vm) {} virtual ~BackgroundResourceLoader() {} virtual void load(Resource *resource); - virtual void unload(Resource *resource); virtual void buildFilename(Resource *resource); virtual bool isFlag(int flag); protected: @@ -188,11 +187,8 @@ public: BackgroundInstance(IllusionsEngine *vm); virtual void load(Resource *resource); virtual void unload(); - void initSurface(); - void freeSurface(); - void drawTiles(Graphics::Surface *surface, TileMap &tileMap, byte *tilePixels); - void pause(); - void unpause(); + virtual void pause(); + virtual void unpause(); public: IllusionsEngine *_vm; uint32 _tag; @@ -204,6 +200,9 @@ public: byte *_savedPalette; void registerResources(); void unregisterResources(); + void initSurface(); + void freeSurface(); + void drawTiles(Graphics::Surface *surface, TileMap &tileMap, byte *tilePixels); void drawTiles8(Graphics::Surface *surface, TileMap &tileMap, byte *tilePixels); void drawTiles16(Graphics::Surface *surface, TileMap &tileMap, byte *tilePixels); }; @@ -216,7 +215,7 @@ public: void removeBackgroundInstance(BackgroundInstance *backgroundInstance); void pauseByTag(uint32 tag); void unpauseByTag(uint32 tag); - BackgroundInstance *findActiveBackground(); + BackgroundInstance *findActiveBackgroundInstance(); BackgroundInstance *findBackgroundByResource(BackgroundResource *backgroundResource); BackgroundResource *getActiveBgResource(); WidthHeight getMasterBgDimensions(); diff --git a/engines/illusions/fontresource.cpp b/engines/illusions/fontresource.cpp index 4d4caf611d..91007fc89a 100644 --- a/engines/illusions/fontresource.cpp +++ b/engines/illusions/fontresource.cpp @@ -34,10 +34,6 @@ void FontResourceLoader::load(Resource *resource) { resource->_instance = fontInstance; } -void FontResourceLoader::unload(Resource *resource) { - // TODO Remove method -} - void FontResourceLoader::buildFilename(Resource *resource) { resource->_filename = Common::String::format("%08X.fnt", resource->_resId); } diff --git a/engines/illusions/fontresource.h b/engines/illusions/fontresource.h index d658ddc0ce..8ea059fa37 100644 --- a/engines/illusions/fontresource.h +++ b/engines/illusions/fontresource.h @@ -35,7 +35,6 @@ public: FontResourceLoader(IllusionsEngine *vm) : _vm(vm) {} virtual ~FontResourceLoader() {} virtual void load(Resource *resource); - virtual void unload(Resource *resource); virtual void buildFilename(Resource *resource); virtual bool isFlag(int flag); protected: diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp index 771afb7298..95b00279b4 100644 --- a/engines/illusions/illusions.cpp +++ b/engines/illusions/illusions.cpp @@ -148,7 +148,7 @@ int IllusionsEngine::updateGraphics(uint flags) { updateFader(); // TODO Move to BackgroundInstanceList class - BackgroundInstance *backgroundItem = _backgroundInstances->findActiveBackground(); + BackgroundInstance *backgroundItem = _backgroundInstances->findActiveBackgroundInstance(); if (backgroundItem) { BackgroundResource *bgRes = backgroundItem->_bgRes; for (uint i = 0; i < bgRes->_bgInfosCount; ++i) { @@ -326,7 +326,7 @@ void IllusionsEngine::setDefaultTextPosition(Common::Point &position) { } FramesList *IllusionsEngine::findActorSequenceFrames(Sequence *sequence) { - return _actorItems->findSequenceFrames(sequence); + return _actorInstances->findSequenceFrames(sequence); } } // End of namespace Illusions diff --git a/engines/illusions/illusions.h b/engines/illusions/illusions.h index 59de64ceb1..9980698a67 100644 --- a/engines/illusions/illusions.h +++ b/engines/illusions/illusions.h @@ -72,7 +72,7 @@ class ScriptStack; class Sequence; class SoundMan; class SpecialCode; -class TalkItems; +class TalkInstanceList; class ThreadList; class UpdateFunctions; @@ -106,11 +106,11 @@ public: Screen *_screen; ScreenText *_screenText; Input *_input; - ActorInstanceList *_actorItems; + ActorInstanceList *_actorInstances; BackgroundInstanceList *_backgroundInstances; Camera *_camera; Controls *_controls; - TalkItems *_talkItems; + TalkInstanceList *_talkItems; ScriptOpcodes *_scriptOpcodes; SpecialCode *_specialCode; ThreadList *_threads; diff --git a/engines/illusions/illusions_bbdou.cpp b/engines/illusions/illusions_bbdou.cpp index c73d9f4682..b71f4fe203 100644 --- a/engines/illusions/illusions_bbdou.cpp +++ b/engines/illusions/illusions_bbdou.cpp @@ -205,12 +205,12 @@ Common::Error IllusionsEngine_BBDOU::run() { _screen = new Screen(this, 640, 480, 16); _screenText = new ScreenText(this); _input = new Input(); - _actorItems = new ActorInstanceList(this); + _actorInstances = new ActorInstanceList(this); _backgroundInstances = new BackgroundInstanceList(this); _camera = new Camera(this); _controls = new Controls(this); _cursor = new Cursor(this); - _talkItems = new TalkItems(this); + _talkItems = new TalkInstanceList(this); _triggerFunctions = new TriggerFunctions(); _threads = new ThreadList(this); _updateFunctions = new UpdateFunctions(); @@ -261,7 +261,7 @@ Common::Error IllusionsEngine_BBDOU::run() { delete _controls; delete _camera; delete _backgroundInstances; - delete _actorItems; + delete _actorInstances; delete _input; delete _screenText; delete _screen; @@ -371,7 +371,7 @@ Control *IllusionsEngine_BBDOU::getObjectControl(uint32 objectId) { Common::Point IllusionsEngine_BBDOU::getNamedPointPosition(uint32 namedPointId) { Common::Point pt; if (_backgroundInstances->findActiveBackgroundNamedPoint(namedPointId, pt) || - _actorItems->findNamedPoint(namedPointId, pt) || + _actorInstances->findNamedPoint(namedPointId, pt) || _controls->findNamedPoint(namedPointId, pt)) return pt; // TODO @@ -553,7 +553,7 @@ void IllusionsEngine_BBDOU::enterPause(uint32 threadId) { _camera->pushCameraMode(); _threads->suspendThreadsByTag(sceneId, threadId); _controls->pauseControlsByTag(sceneId); - _actorItems->pauseByTag(sceneId); + _actorInstances->pauseByTag(sceneId); _backgroundInstances->pauseByTag(sceneId); _activeScenes.pauseActiveScene(); } @@ -561,7 +561,7 @@ void IllusionsEngine_BBDOU::enterPause(uint32 threadId) { void IllusionsEngine_BBDOU::leavePause(uint32 threadId) { uint32 sceneId = _activeScenes.getCurrentScene(); _backgroundInstances->unpauseByTag(sceneId); - _actorItems->unpauseByTag(sceneId); + _actorInstances->unpauseByTag(sceneId); _controls->unpauseControlsByTag(sceneId); _threads->notifyThreadsByTag(sceneId, threadId); _camera->popCameraMode(); diff --git a/engines/illusions/illusions_duckman.cpp b/engines/illusions/illusions_duckman.cpp index bc5b667a87..f9705b6ef8 100644 --- a/engines/illusions/illusions_duckman.cpp +++ b/engines/illusions/illusions_duckman.cpp @@ -40,7 +40,6 @@ #include "illusions/sound.h" #include "illusions/soundresource.h" #include "illusions/specialcode.h" -//TODO#include "illusions/bbdou/bbdou_specialcode.h" #include "illusions/talkresource.h" #include "illusions/textdrawer.h" #include "illusions/thread.h" @@ -99,11 +98,11 @@ Common::Error IllusionsEngine_Duckman::run() { _screen = new Screen(this, 320, 200, 8); _screenText = new ScreenText(this); _input = new Input(); - _actorItems = new ActorInstanceList(this); + _actorInstances = new ActorInstanceList(this); _backgroundInstances = new BackgroundInstanceList(this); _camera = new Camera(this); _controls = new Controls(this); - _talkItems = new TalkItems(this); + _talkItems = new TalkInstanceList(this); _threads = new ThreadList(this); _updateFunctions = new UpdateFunctions(); _soundMan = new SoundMan(this); @@ -176,7 +175,7 @@ Common::Error IllusionsEngine_Duckman::run() { delete _controls; delete _camera; delete _backgroundInstances; - delete _actorItems; + delete _actorInstances; delete _input; delete _screenText; delete _screen; @@ -291,13 +290,11 @@ void IllusionsEngine_Duckman::setDefaultTextCoords() { } void IllusionsEngine_Duckman::loadSpecialCode(uint32 resId) { -//TODO _specialCode = new BbdouSpecialCode(this); -//TODO _specialCode->init(); + //TODO? } void IllusionsEngine_Duckman::unloadSpecialCode(uint32 resId) { -//TODO delete _specialCode; -//TODO _specialCode = 0; + //TODO? } void IllusionsEngine_Duckman::notifyThreadId(uint32 &threadId) { @@ -726,13 +723,13 @@ bool IllusionsEngine_Duckman::changeScene(uint32 sceneId, uint32 threadId, uint3 void IllusionsEngine_Duckman::enterPause(uint32 sceneId, uint32 threadId) { _threads->suspendThreads(threadId); _controls->pauseControls(); - _actorItems->pauseByTag(sceneId); + _actorInstances->pauseByTag(sceneId); _backgroundInstances->pauseByTag(sceneId); } void IllusionsEngine_Duckman::leavePause(uint32 sceneId, uint32 threadId) { _backgroundInstances->unpauseByTag(sceneId); - _actorItems->unpauseByTag(sceneId); + _actorInstances->unpauseByTag(sceneId); _controls->unpauseControls(); _threads->notifyThreads(threadId); } diff --git a/engines/illusions/midiresource.cpp b/engines/illusions/midiresource.cpp index b6e181e2c7..fc088ab020 100644 --- a/engines/illusions/midiresource.cpp +++ b/engines/illusions/midiresource.cpp @@ -34,9 +34,6 @@ void MidiGroupResourceLoader::load(Resource *resource) { } -void MidiGroupResourceLoader::unload(Resource *resource) { -} - void MidiGroupResourceLoader::buildFilename(Resource *resource) { resource->_filename = Common::String::format("%08X.fnt", resource->_resId); } diff --git a/engines/illusions/midiresource.h b/engines/illusions/midiresource.h index 54ad8765be..9032e99396 100644 --- a/engines/illusions/midiresource.h +++ b/engines/illusions/midiresource.h @@ -35,7 +35,6 @@ public: MidiGroupResourceLoader(IllusionsEngine *vm) : _vm(vm) {} virtual ~MidiGroupResourceLoader() {} virtual void load(Resource *resource); - virtual void unload(Resource *resource); virtual void buildFilename(Resource *resource); virtual bool isFlag(int flag); protected: diff --git a/engines/illusions/resourcesystem.cpp b/engines/illusions/resourcesystem.cpp index bb6048bed2..9e81f1f9df 100644 --- a/engines/illusions/resourcesystem.cpp +++ b/engines/illusions/resourcesystem.cpp @@ -36,6 +36,12 @@ void ResourceInstance::load(Resource *resource) { void ResourceInstance::unload() { } +void ResourceInstance::pause() { +} + +void ResourceInstance::unpause() { +} + ResourceInstance::~ResourceInstance() { } diff --git a/engines/illusions/resourcesystem.h b/engines/illusions/resourcesystem.h index 37e843efa5..edf1cdd08c 100644 --- a/engines/illusions/resourcesystem.h +++ b/engines/illusions/resourcesystem.h @@ -43,6 +43,8 @@ class ResourceInstance { public: virtual void load(Resource *resource); virtual void unload(); + virtual void pause(); + virtual void unpause(); virtual ~ResourceInstance(); }; @@ -77,7 +79,6 @@ class BaseResourceLoader { public: virtual ~BaseResourceLoader() {} virtual void load(Resource *resource) = 0; - virtual void unload(Resource *resource) = 0; virtual void buildFilename(Resource *resource) = 0; virtual bool isFlag(int flag) = 0; }; diff --git a/engines/illusions/scriptresource.cpp b/engines/illusions/scriptresource.cpp index 28e56da36f..775ca73b28 100644 --- a/engines/illusions/scriptresource.cpp +++ b/engines/illusions/scriptresource.cpp @@ -33,10 +33,6 @@ void ScriptResourceLoader::load(Resource *resource) { resource->_instance = scriptInstance; } -void ScriptResourceLoader::unload(Resource *resource) { - // TODO Remove method -} - void ScriptResourceLoader::buildFilename(Resource *resource) { resource->_filename = Common::String::format("%08X.scr", resource->_resId); } diff --git a/engines/illusions/scriptresource.h b/engines/illusions/scriptresource.h index c168294c44..c2119b03c8 100644 --- a/engines/illusions/scriptresource.h +++ b/engines/illusions/scriptresource.h @@ -34,7 +34,6 @@ public: ScriptResourceLoader(IllusionsEngine *vm) : _vm(vm) {} virtual ~ScriptResourceLoader() {} virtual void load(Resource *resource); - virtual void unload(Resource *resource); virtual void buildFilename(Resource *resource); virtual bool isFlag(int flag); protected: diff --git a/engines/illusions/soundresource.cpp b/engines/illusions/soundresource.cpp index 1f14e2ce9d..efc16dfa69 100644 --- a/engines/illusions/soundresource.cpp +++ b/engines/illusions/soundresource.cpp @@ -29,25 +29,9 @@ namespace Illusions { // SoundGroupResourceLoader void SoundGroupResourceLoader::load(Resource *resource) { -#if 0 // ### TODO - debug("SoundGroupResourceLoader::load() Loading sound group %08X...", resource->_resId); - SoundGroupResource *soundGroupResource = new SoundGroupResource(); - soundGroupResource->load(resource->_data, resource->_dataSize); - resource->_refId = soundGroupResource; - - for (uint i = 0; i < soundGroupResource->_soundEffectsCount; ++i) { - SoundEffect *soundEffect = &soundGroupResource->_soundEffects[i]; - _vm->_soundMan->loadSound(soundEffect->_soundEffectId, resource->_resId, soundEffect->_looping); - } -#endif -} - -void SoundGroupResourceLoader::unload(Resource *resource) { -#if 0 // ### TODO - debug("SoundGroupResourceLoader::unload() Unloading sound group %08X...", resource->_resId); - _vm->_soundMan->unloadSounds(resource->_resId); - delete (SoundGroupResource*)resource->_refId; -#endif + SoundGroupInstance *soundGroupInstance = new SoundGroupInstance(_vm); + soundGroupInstance->load(resource); + resource->_instance = soundGroupInstance; } void SoundGroupResourceLoader::buildFilename(Resource *resource) { @@ -98,4 +82,24 @@ void SoundGroupResource::load(byte *data, uint32 dataSize) { } +// SoundGroupInstance + +SoundGroupInstance::SoundGroupInstance(IllusionsEngine *vm) + : _vm(vm) { +} + +void SoundGroupInstance::load(Resource *resource) { + _soundGroupResource = new SoundGroupResource(); + _soundGroupResource->load(resource->_data, resource->_dataSize); + for (uint i = 0; i < _soundGroupResource->_soundEffectsCount; ++i) { + SoundEffect *soundEffect = &_soundGroupResource->_soundEffects[i]; + _vm->_soundMan->loadSound(soundEffect->_soundEffectId, resource->_resId, soundEffect->_looping); + } + _resId = resource->_resId; +} + +void SoundGroupInstance::unload() { + _vm->_soundMan->unloadSounds(_resId); +} + } // End of namespace Illusions diff --git a/engines/illusions/soundresource.h b/engines/illusions/soundresource.h index 09b88179ab..638e8df810 100644 --- a/engines/illusions/soundresource.h +++ b/engines/illusions/soundresource.h @@ -35,7 +35,6 @@ public: SoundGroupResourceLoader(IllusionsEngine *vm) : _vm(vm) {} virtual ~SoundGroupResourceLoader() {} virtual void load(Resource *resource); - virtual void unload(Resource *resource); virtual void buildFilename(Resource *resource); virtual bool isFlag(int flag); protected: @@ -61,6 +60,17 @@ public: SoundEffect *_soundEffects; }; +class SoundGroupInstance : public ResourceInstance { +public: + SoundGroupInstance(IllusionsEngine *vm); + virtual void load(Resource *resource); + virtual void unload(); +public: + IllusionsEngine *_vm; + SoundGroupResource *_soundGroupResource; + uint32 _resId; +}; + } // End of namespace Illusions #endif // ILLUSIONS_SOUNDRESOURCE_H diff --git a/engines/illusions/talkresource.cpp b/engines/illusions/talkresource.cpp index e9d54331e5..17672bae2a 100644 --- a/engines/illusions/talkresource.cpp +++ b/engines/illusions/talkresource.cpp @@ -32,10 +32,6 @@ void TalkResourceLoader::load(Resource *resource) { resource->_instance = _vm->_talkItems->createTalkInstance(resource); } -void TalkResourceLoader::unload(Resource *resource) { - // TODO Remove method -} - void TalkResourceLoader::buildFilename(Resource *resource) { resource->_filename = Common::String::format("%08X.tlk", resource->_resId); } @@ -129,47 +125,47 @@ void TalkInstance::unregisterResources() { } } -// TalkItems +// TalkInstanceList -TalkItems::TalkItems(IllusionsEngine *vm) +TalkInstanceList::TalkInstanceList(IllusionsEngine *vm) : _vm(vm) { } -TalkItems::~TalkItems() { +TalkInstanceList::~TalkInstanceList() { } -TalkInstance *TalkItems::createTalkInstance(Resource *resource) { +TalkInstance *TalkInstanceList::createTalkInstance(Resource *resource) { TalkInstance *talkInstance = new TalkInstance(_vm); talkInstance->load(resource); _items.push_back(talkInstance); return talkInstance; } -void TalkItems::removeTalkInstance(TalkInstance *talkInstance) { +void TalkInstanceList::removeTalkInstance(TalkInstance *talkInstance) { _items.remove(talkInstance); } -TalkInstance *TalkItems::findTalkItem(uint32 talkId) { +TalkInstance *TalkInstanceList::findTalkItem(uint32 talkId) { for (ItemsIterator it = _items.begin(); it != _items.end(); ++it) if ((*it)->_talkId == talkId) return (*it); return 0; } -TalkInstance *TalkItems::findTalkItemByTag(uint32 tag) { +TalkInstance *TalkInstanceList::findTalkItemByTag(uint32 tag) { for (ItemsIterator it = _items.begin(); it != _items.end(); ++it) if ((*it)->_tag == tag) return (*it); return 0; } -void TalkItems::pauseByTag(uint32 tag) { +void TalkInstanceList::pauseByTag(uint32 tag) { TalkInstance *talkInstance = findTalkItemByTag(tag); if (talkInstance) talkInstance->pause(); } -void TalkItems::unpauseByTag(uint32 tag) { +void TalkInstanceList::unpauseByTag(uint32 tag) { TalkInstance *talkInstance = findTalkItemByTag(tag); if (talkInstance) talkInstance->unpause(); diff --git a/engines/illusions/talkresource.h b/engines/illusions/talkresource.h index 7f86a36bcc..5e3797e592 100644 --- a/engines/illusions/talkresource.h +++ b/engines/illusions/talkresource.h @@ -35,7 +35,6 @@ public: TalkResourceLoader(IllusionsEngine *vm) : _vm(vm) {} virtual ~TalkResourceLoader() {} virtual void load(Resource *resource); - virtual void unload(Resource *resource); virtual void buildFilename(Resource *resource); virtual bool isFlag(int flag); protected: @@ -66,8 +65,8 @@ public: TalkInstance(IllusionsEngine *vm); virtual void load(Resource *resource); virtual void unload(); - void pause(); - void unpause(); + virtual void pause(); + virtual void unpause(); public: IllusionsEngine *_vm; uint32 _talkId; @@ -78,10 +77,10 @@ public: void unregisterResources(); }; -class TalkItems { +class TalkInstanceList { public: - TalkItems(IllusionsEngine *vm); - ~TalkItems(); + TalkInstanceList(IllusionsEngine *vm); + ~TalkInstanceList(); TalkInstance *createTalkInstance(Resource *resource); void removeTalkInstance(TalkInstance *talkInstance); TalkInstance *findTalkItem(uint32 talkId); |