MADS: Further animation setup in AnimView

This commit is contained in:
Paul Gilbert 2014-09-18 22:21:15 -04:00
parent 394d4623be
commit a1548e27a0
4 changed files with 46 additions and 5 deletions

View File

@ -390,7 +390,7 @@ void Animation::loadInterface(UserInterface &interfaceSurface, DepthSurface &dep
_scene->_depthStyle = 0;
if (header._bgType <= ANIMBG_FULL_SIZE) {
_vm->_palette->_paletteUsage.setEmpty();
sceneInfo->load(header._roomNumber, flags, header._interfaceFile, 0, depthSurface, interfaceSurface);
sceneInfo->load(header._roomNumber, 0, header._interfaceFile, flags, depthSurface, interfaceSurface);
_scene->_depthStyle = sceneInfo->_depthStyle == 2 ? 1 : 0;
if (palCycles) {
palCycles->clear();

View File

@ -223,6 +223,8 @@ public:
int roomNumber() const { return _header._roomNumber; }
void resetSpriteSetsCount() { _header._spriteSetsCount = 0; } // CHECKME: See if it doesn't leak the memory when the destructor is called
SpriteAsset *getSpriteSet(int idx) { return _spriteSets[idx]; }
};
} // End of namespace MADS

View File

@ -805,12 +805,20 @@ AnimationView::AnimationView(MADSEngine *vm) : MenuView(vm) {
_sfx = 0;
_soundFlag = _bgLoadFlag = true;
_showWhiteBars = true;
_manualFrameNumber = 0;
_manualSpriteSet = nullptr;
_manualStartFrame = _manualEndFrame = 0;
_manualFrame2 = 0;
_hasManual = false;
_animFrameNumber = 0;
_sceneInfo = SceneInfo::init(_vm);
load();
}
AnimationView::~AnimationView() {
delete _currentAnimation;
delete _sceneInfo;
}
void AnimationView::load() {
@ -868,7 +876,8 @@ void AnimationView::loadNextResource() {
delete _currentAnimation;
_currentAnimation = Animation::init(_vm, &scene);
_currentAnimation->load(scene._userInterface, scene._depthSurface,
resEntry._resourceName, 0, nullptr, scene._sceneInfo);
resEntry._resourceName, resEntry._bgFlag ? 0x100 : 0,
nullptr, _sceneInfo);
// If a sound driver has been specified, then load the correct one
if (!_currentAnimation->_header._soundName.empty()) {
@ -879,13 +888,36 @@ void AnimationView::loadNextResource() {
_vm->_sound->init(driverNum);
}
// Set the enabled state for this animation
// Handle any manual setup
if (_currentAnimation->_header._manualFlag) {
_manualFrameNumber = _currentAnimation->_header._spritesIndex;
_manualSpriteSet = _currentAnimation->getSpriteSet(_manualFrameNumber);
_hasManual = true;
}
// Set the sound data for the animation
_vm->_sound->setEnabled(resEntry._soundFlag);
// Check for background loading
if (resEntry._bgFlag) {
Common::String dsrName = _currentAnimation->_header._dsrName;
if (!dsrName.empty())
_vm->_audio->setSoundGroup(dsrName);
// Initial frames scan loop
bool foundFrame = false;
for (int frameCtr = 0; frameCtr < (int)_currentAnimation->_frameEntries.size(); ++frameCtr) {
int spritesIdx = _currentAnimation->_spriteListIndexes[_manualFrameNumber];
AnimFrameEntry &frame = _currentAnimation->_frameEntries[frameCtr];
if (frame._spriteSlot._spritesIndex == spritesIdx) {
_animFrameNumber = frame._frameNumber;
_manualStartFrame = _animFrameNumber;
_manualEndFrame = _manualSpriteSet->getCount() - 1;
_manualFrame2 = _manualStartFrame - 1;
break;
}
}
if (!foundFrame)
_hasManual = false;
}
void AnimationView::scriptDone() {

View File

@ -276,7 +276,14 @@ private:
int _v1;
int _v2;
int _resourceIndex;
SceneInfo *_sceneInfo;
Animation *_currentAnimation;
int _manualFrameNumber;
SpriteAsset *_manualSpriteSet;
int _manualStartFrame, _manualEndFrame;
int _manualFrame2;
bool _hasManual;
int _animFrameNumber;
private:
void checkResource(const Common::String &resourceName);