diff options
author | Paul Gilbert | 2014-09-16 21:18:35 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-09-16 21:18:35 -0400 |
commit | 455eb540c4cb30314468f605512e84ca2d5bf294 (patch) | |
tree | 98b7c3db791c067202f59c4941bd98be72d90351 /engines/mads/nebular | |
parent | 2b9a5ca2b3e4e07f391c4aa0c4ee5223d52b6903 (diff) | |
download | scummvm-rg350-455eb540c4cb30314468f605512e84ca2d5bf294.tar.gz scummvm-rg350-455eb540c4cb30314468f605512e84ca2d5bf294.tar.bz2 scummvm-rg350-455eb540c4cb30314468f605512e84ca2d5bf294.zip |
MADS: Beginnings of resource loading in AnimView
Diffstat (limited to 'engines/mads/nebular')
-rw-r--r-- | engines/mads/nebular/menu_nebular.cpp | 122 | ||||
-rw-r--r-- | engines/mads/nebular/menu_nebular.h | 33 |
2 files changed, 122 insertions, 33 deletions
diff --git a/engines/mads/nebular/menu_nebular.cpp b/engines/mads/nebular/menu_nebular.cpp index f0a0a995b0..979c14f3e1 100644 --- a/engines/mads/nebular/menu_nebular.cpp +++ b/engines/mads/nebular/menu_nebular.cpp @@ -799,10 +799,18 @@ AnimationView::AnimationView(MADSEngine *vm) : MenuView(vm) { _showWhiteBars = true; _resetPalette = false; _resyncMode = NEVER; + _v1 = 0; + _v2 = -1; + _resourceIndex = -1; + _currentAnimation = nullptr; load(); } +AnimationView::~AnimationView() { + delete _currentAnimation; +} + void AnimationView::load() { Common::String resName(_resourceName); if (!resName.hasSuffix(".")) @@ -814,6 +822,17 @@ void AnimationView::load() { processLines(); } +void AnimationView::display() { + _vm->_palette->initPalette(); + Common::fill(&_vm->_palette->_cyclingPalette[0], &_vm->_palette->_cyclingPalette[PALETTE_SIZE], 0); + + _vm->_palette->resetGamePalette(1, 8); + _vm->_game->_scene._spriteSlots.reset(); + _vm->_game->_scene._paletteCycles.clear(); + + MenuView::display(); +} + bool AnimationView::onEvent(Common::Event &event) { // Wait for the Escape key or a mouse press if (((event.type == Common::EVENT_KEYDOWN) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) || @@ -826,36 +845,45 @@ bool AnimationView::onEvent(Common::Event &event) { } void AnimationView::doFrame() { - // Only update state if wait period has expired - if (_previousUpdate > 0) { - if (g_system->getMillis() - _previousUpdate < 3000) { - return; - } else { - // time for an update - _previousUpdate = g_system->getMillis(); - } - } else { - _previousUpdate = g_system->getMillis(); - return; +// Scene &scene = _vm->_game->_scene; + + // TODO: Or when current animation is finished + if (_resourceIndex == -1) { + if (++_resourceIndex == (int)_resources.size()) + scriptDone(); + else + loadNextResource(); } - /* - char bgFile[10]; - strncpy(bgFile, _currentFile, 5); - bgFile[0] = bgFile[2]; - bgFile[1] = bgFile[3]; - bgFile[2] = bgFile[4]; - bgFile[3] = '\0'; - bgNumber = atoi(bgFile); - sprintf(bgFile, "rm%i.art", bgNumber); - - // Not all scenes have a background. If there is one, refresh it - if (Common::File::exists(bgFile)) { - _vm->_palette->resetGamePalette(4, 8); - SceneInfo *sceneInfo = SceneInfo::init(_vm); - sceneInfo->load(bgNumber, 0, Common::String(), 0, scene._depthSurface, - scene._backgroundSurface); +} + +void AnimationView::loadNextResource() { + Scene &scene = _vm->_game->_scene; + ResourceEntry &resEntry = _resources[_resourceIndex]; + + if (resEntry._bgFlag) + _vm->_palette->resetGamePalette(1, 8); + + delete _currentAnimation; + _currentAnimation = Animation::init(_vm, &scene); + _currentAnimation->load(scene._userInterface, scene._depthSurface, + resEntry._resourceName, 0, nullptr, scene._sceneInfo); + + // If a sound driver has been specified, then load the correct one + if (!_currentAnimation->_header._soundName.empty()) { + const char *chP = strchr(_currentAnimation->_header._soundName.c_str(), '.'); + assert(chP); + + int driverNum = atoi(chP + 1); + _vm->_sound->init(driverNum); + } + + // Set the enabled state for this animation + _vm->_sound->setEnabled(resEntry._soundFlag); + + // Check for background loading + if (resEntry._bgFlag) { + } - */ } void AnimationView::scriptDone() { @@ -893,7 +921,7 @@ void AnimationView::processLines() { resName += c; } - _resources.push_back(ResourceEntry(resName, _sfx)); + _resources.push_back(ResourceEntry(resName, _sfx, false, false)); _sfx = 0; } @@ -977,6 +1005,42 @@ int AnimationView::getParameter() { return result; } +void AnimationView::checkResource(const Common::String &resourceName) { + //bool hasSuffix = false; + +} + +int AnimationView::scanResourceIndex(const Common::String &resourceName) { + int foundIndex = -1; + + if (_v1) { + const char *chP = strchr(resourceName.c_str(), '\\'); + if (!chP) { + chP = strchr(resourceName.c_str(), '*'); + } + + Common::String resName = chP ? Common::String(chP + 1) : resourceName; + + if (_v2 != 3) { + assert(_resIndex.size() == 0); + } + + // Scan for the resource name + for (uint resIndex = 0; resIndex < _resIndex.size(); ++resIndex) { + ResIndexEntry &resEntry = _resIndex[resIndex]; + if (resEntry._resourceName.compareToIgnoreCase(resourceName)) { + foundIndex = resIndex; + break; + } + } + } + + if (foundIndex >= 0) { + // TODO + } + return -1; +} + } // End of namespace Nebular diff --git a/engines/mads/nebular/menu_nebular.h b/engines/mads/nebular/menu_nebular.h index 7abe3c8892..3959244600 100644 --- a/engines/mads/nebular/menu_nebular.h +++ b/engines/mads/nebular/menu_nebular.h @@ -230,15 +230,27 @@ enum ResyncMode { NEVER, ALWAYS, BEGINNING }; struct ResourceEntry { Common::String _resourceName; - int _sfx; + int _fx; + bool _soundFlag; + bool _bgFlag; ResourceEntry() {} - ResourceEntry(const Common::String &resName, int sfx) { + ResourceEntry(const Common::String &resName, int fx, bool soundFlag, bool bgFlag) { _resourceName = resName; - _sfx = sfx; + _fx = fx; + _soundFlag = soundFlag; + _bgFlag = bgFlag; } }; +struct ResIndexEntry { + int _id; + int _v; + Common::String _resourceName; + + ResIndexEntry() {} +}; + /** * Animation cutscene view */ @@ -255,7 +267,16 @@ private: ResyncMode _resyncMode; int _sfx; Common::Array<ResourceEntry> _resources; + Common::Array<ResIndexEntry> _resIndex; + int _v1; + int _v2; + int _resourceIndex; + Animation *_currentAnimation; private: + void checkResource(const Common::String &resourceName); + + int scanResourceIndex(const Common::String &resourceName); + void load(); void processLines(); @@ -265,7 +286,11 @@ private: int getParameter(); void scriptDone(); + + void loadNextResource(); protected: + virtual void display(); + virtual void doFrame(); virtual bool onEvent(Common::Event &event); @@ -277,7 +302,7 @@ public: AnimationView(MADSEngine *vm); - virtual ~AnimationView() {} + virtual ~AnimationView(); }; } // End of namespace Nebular |