bool PanTrackNode::process(uint32 deltaTimeInMillis) { ScriptManager * scriptManager = _engine->getScriptManager(); ScriptingEffect *fx = scriptManager->getSideFX(_slot); if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) { MusicNodeBASE *mus = (MusicNodeBASE *)fx; int curPos = scriptManager->getStateValue(StateKey_ViewPos); int16 _width = _engine->getRenderManager()->getBkgSize().x; int16 _halfWidth = _width / 2; int16 _quarterWidth = _width / 4; int tmp = 0; if (curPos <= _position) tmp = _position - curPos; else tmp = _position - curPos + _width; int balance = 0; if (tmp > _halfWidth) tmp -= _width; if (tmp > _quarterWidth) { balance = 1; tmp = _halfWidth - tmp; } else if (tmp < -_quarterWidth) { balance = -1; tmp = -_halfWidth - tmp; } // Originally it's value -90...90 but we use -127...127 and therefore 360 replaced by 508 mus->setBalance( (508 * tmp) / _width ); tmp = (360 * tmp) / _width; int deltaVol = balance; // This value sets how fast volume goes off than sound source back of you // By this value we can hack some "bugs" have place in originall game engine like beat sound in ZGI-dc10 int volumeCorrection = 2; if (_engine->getGameId() == GID_GRANDINQUISITOR) { if (scriptManager->getCurrentLocation() == "dc10") volumeCorrection = 5; } if (deltaVol != 0) deltaVol = (mus->getVolume() * volumeCorrection) * (90 - tmp * balance) / 90; if (deltaVol > 255) deltaVol = 255; mus->setDeltaVolume(deltaVol); } return false; }
bool AnimationEffect::process(uint32 deltaTimeInMillis) { ScriptManager *scriptManager = _engine->getScriptManager(); RenderManager *renderManager = _engine->getRenderManager(); RenderTable::RenderState renderState = renderManager->getRenderTable()->getRenderState(); bool isPanorama = (renderState == RenderTable::PANORAMA); int16 velocity = _engine->getMouseVelocity() + _engine->getKeyboardVelocity(); // Do not update animation nodes in panoramic mode while turning, if the user // has set this option if (scriptManager->getStateValue(StateKey_NoTurnAnim) == 1 && isPanorama && velocity) return false; PlayNodes::iterator it = _playList.begin(); if (it != _playList.end()) { playnode *nod = &(*it); if (nod->_curFrame == -1) { // The node is just beginning playback nod->_curFrame = nod->start; _animation->start(); _animation->seekToFrame(nod->start); _animation->setEndFrame(nod->stop); nod->_delay = deltaTimeInMillis; // Force the frame to draw if (nod->slot) scriptManager->setStateValue(nod->slot, 1); } else if (_animation->endOfVideo()) { // The node has reached the end; check if we need to loop nod->loop--; if (nod->loop == 0) { if (nod->slot >= 0) scriptManager->setStateValue(nod->slot, 2); if (nod->_scaled) { nod->_scaled->free(); delete nod->_scaled; } _playList.erase(it); return _disposeAfterUse; } nod->_curFrame = nod->start; _animation->seekToFrame(nod->start); } // Check if we need to draw a frame bool needsUpdate = false; if (_frmDelayOverride == 0) { // If not overridden, use the VideoDecoder's check needsUpdate = _animation->needsUpdate(); } else { // Otherwise, implement our own timing nod->_delay -= deltaTimeInMillis; if (nod->_delay <= 0) { nod->_delay += _frmDelayOverride; needsUpdate = true; } } if (needsUpdate) { const Graphics::Surface *frame = _animation->decodeNextFrame(); if (frame) { uint32 dstw; uint32 dsth; if (isPanorama) { dstw = nod->pos.height(); dsth = nod->pos.width(); } else { dstw = nod->pos.width(); dsth = nod->pos.height(); } // We only scale down the animation to fit its frame, not up, otherwise we // end up with distorted animations - e.g. the armor visor in location cz1e // in Nemesis (one of the armors inside Irondune), or the planet in location // aa10 in Nemesis (Juperon, outside the asylum). We do allow scaling up only // when a simple 2x filter is requested (e.g. the alchemists and cup sequence // in Nemesis) if (frame->w > dstw || frame->h > dsth || (frame->w == dstw / 2 && frame->h == dsth / 2)) { if (nod->_scaled) if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) { nod->_scaled->free(); delete nod->_scaled; nod->_scaled = NULL; } if (!nod->_scaled) { nod->_scaled = new Graphics::Surface; nod->_scaled->create(dstw, dsth, frame->format); } renderManager->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth); frame = nod->_scaled; } if (isPanorama) { Graphics::Surface *transposed = RenderManager::tranposeSurface(frame); renderManager->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask); transposed->free(); delete transposed; } else { renderManager->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask); } } } } return false; }