1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Implemented terrain transition animation

This commit is contained in:
Ivan Savenko
2023-03-01 19:25:51 +02:00
parent 58aa5c0427
commit 165f6a0944
8 changed files with 74 additions and 32 deletions

View File

@@ -99,7 +99,7 @@ void MapViewController::update(uint32_t timeDelta)
// - teleporting ( 250 ms)
static const double fadeOutDuration = 500;
static const double fadeInDuration = 500;
//static const double heroTeleportDuration = 250;
static const double heroTeleportDuration = 250;
//FIXME: remove code duplication?
@@ -140,13 +140,14 @@ void MapViewController::update(uint32_t timeDelta)
}
}
//if(teleportContext)
//{
// teleportContext->progress += timeDelta / heroTeleportDuration;
// moveFocusToSelection();
// if(teleportContext->progress >= 1.0)
// teleportContext.reset();
//}
if(teleportContext)
{
teleportContext->progress += timeDelta / heroTeleportDuration;
if(teleportContext->progress >= 1.0)
{
activateAdventureContext(teleportContext->animationTime);
}
}
if(fadingOutContext)
{
@@ -316,9 +317,8 @@ void MapViewController::onBeforeHeroTeleported(const CGHeroInstance * obj, const
if(isEventVisible(obj, from, dest))
{
// TODO: generate view with old state
setViewCenter(obj->getSightCenter());
removeObject(obj);
view->createTransitionSnapshot(context);
}
}
@@ -326,16 +326,16 @@ void MapViewController::onAfterHeroTeleported(const CGHeroInstance * obj, const
{
assert(!hasOngoingAnimations());
removeObject(obj);
addObject(obj);
if(isEventVisible(obj, from, dest))
{
// TODO: animation
teleportContext = std::make_shared<MapRendererAdventureTransitionContext>(*state);
teleportContext->animationTime = adventureContext->animationTime;
adventureContext = teleportContext;
context = teleportContext;
setViewCenter(obj->getSightCenter());
addObject(obj);
}
else
{
removeObject(obj);
addObject(obj);
}
}
@@ -395,6 +395,9 @@ bool MapViewController::hasOngoingAnimations()
if(fadingInContext)
return true;
if (teleportContext)
return true;
return false;
}
@@ -458,6 +461,7 @@ void MapViewController::resetContext()
movementContext.reset();
fadingOutContext.reset();
fadingInContext.reset();
teleportContext.reset();
worldViewContext.reset();
spellViewContext.reset();
puzzleMapContext.reset();