An attempt to fix restoring from cutaway. Still not perfect.

svn-id: r27465
This commit is contained in:
Eugene Sandulenko 2007-06-16 14:06:17 +00:00
parent f4518cd344
commit d9abc85fbd
4 changed files with 41 additions and 14 deletions

View File

@ -243,9 +243,9 @@ void Anim::returnFromCutaway(void) {
}
// Note that clearCutaway() sets _cutawayActive to false.
clearCutaway();
// clearCutaway();
// TODO: Clearing the cutaway via an event is better, but it breaks things up
/*
event.type = kEvTImmediate;
event.code = kCutawayEvent;
event.op = kEventClearCutaway;
@ -256,10 +256,24 @@ void Anim::returnFromCutaway(void) {
q_event = _vm->_events->chain(q_event, &event); // chain with the other events
else
q_event = _vm->_events->queue(&event);
*/
// Restore the scene
_vm->_scene->restoreScene();
event.type = kEvTImmediate;
event.code = kSceneEvent;
event.op = kEventRestore;
event.time = 0;
event.duration = 0;
q_event = _vm->_events->chain(q_event, &event); // chain with the other events
// Restore the animations
event.type = kEvTImmediate;
event.code = kAnimEvent;
event.op = kEventResumeAll;
event.time = 0;
event.duration = 0;
q_event = _vm->_events->chain(q_event, &event); // chain with the other events
// Handle fade up, if we previously faded down
if (_cutAwayFade) {
@ -267,24 +281,15 @@ void Anim::returnFromCutaway(void) {
event.code = kPalEvent;
event.op = kEventBlackToPal;
event.time = 0;
event.duration = kNormalFadeDuration;
event.duration = 3000; //kNormalFadeDuration;
event.data = saved_pal;
q_event = _vm->_events->chain(q_event, &event);
}
// Restore the animations
for (int i = 0; i < MAX_ANIMATIONS; i++) {
if (_animations[i] && _animations[i]->state == ANIM_PLAYING) {
resume(i, 0);
}
}
}
}
void Anim::clearCutaway(void) {
debug(0, "clearCutaway()");
if (_cutawayActive) {
_cutawayActive = false;
@ -851,4 +856,13 @@ void Anim::cutawayInfo() {
}
}
void Anim::resumeAll() {
// Restore the animations
for (int i = 0; i < MAX_ANIMATIONS; i++) {
if (_animations[i] && _animations[i]->state == ANIM_PLAYING) {
resume(i, 0);
}
}
}
} // End of namespace Saga

View File

@ -138,6 +138,7 @@ public:
void stop(uint16 animId);
void finish(uint16 animId);
void resume(uint16 animId, int cycles);
void resumeAll();
int16 getCurrentFrame(uint16 animId);
bool hasCutaway(void) {
return _cutawayActive;

View File

@ -247,10 +247,14 @@ int Events::handleImmediate(Event *event) {
case kScriptEvent:
case kBgEvent:
case kInterfaceEvent:
case kSceneEvent:
case kAnimEvent:
case kCutawayEvent:
handleOneShot(event);
event_done = true;
break;
default:
warning("Unhandled Immediate event type (%d)", event->code & EVENT_MASK);
break;
}
@ -356,6 +360,9 @@ int Events::handleOneShot(Event *event) {
case kEventClearFlag:
_vm->_anim->clearFlag(event->param, event->param2);
break;
case kEventResumeAll:
_vm->_anim->resumeAll();
break;
default:
break;
}
@ -365,6 +372,9 @@ int Events::handleOneShot(Event *event) {
case kEventEnd:
_vm->_scene->nextScene();
return kEvStBreak;
case kEventRestore:
_vm->_scene->restoreScene();
return kEvStBreak;
default:
break;
}

View File

@ -73,11 +73,13 @@ enum EventOps {
kEventFrame = 3,
kEventSetFlag = 4,
kEventClearFlag = 5,
kEventResumeAll = 6,
// MUISC & SOUND events
kEventPlay = 1,
kEventStop = 2,
// SCENE events
kEventEnd = 2,
kEventRestore = 3,
// TEXT events
kEventHide = 2,
kEventRemove = 3,