mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Separated timer updates from rendering in adventure map and town screen
This commit is contained in:
parent
3ecdff2a21
commit
fa496628f2
@ -55,6 +55,8 @@ BasicMapView::BasicMapView(const Point & offset, const Point & dimensions)
|
||||
pos += offset;
|
||||
pos.w = dimensions.x;
|
||||
pos.h = dimensions.y;
|
||||
|
||||
addUsedEvents(TIME);
|
||||
}
|
||||
|
||||
void BasicMapView::render(Canvas & target, bool fullUpdate)
|
||||
@ -64,21 +66,22 @@ void BasicMapView::render(Canvas & target, bool fullUpdate)
|
||||
tilesCache->render(controller->getContext(), targetClipped, fullUpdate);
|
||||
}
|
||||
|
||||
void BasicMapView::tick(uint32_t msPassed)
|
||||
{
|
||||
controller->tick(msPassed);
|
||||
}
|
||||
|
||||
void BasicMapView::show(SDL_Surface * to)
|
||||
{
|
||||
controller->updateBefore(GH.getFrameDeltaMilliseconds());
|
||||
|
||||
Canvas target(to);
|
||||
CSDL_Ext::CClipRectGuard guard(to, pos);
|
||||
render(target, false);
|
||||
|
||||
controller->updateAfter(GH.getFrameDeltaMilliseconds());
|
||||
controller->afterRender();
|
||||
}
|
||||
|
||||
void BasicMapView::showAll(SDL_Surface * to)
|
||||
{
|
||||
controller->updateBefore(0);
|
||||
|
||||
Canvas target(to);
|
||||
CSDL_Ext::CClipRectGuard guard(to, pos);
|
||||
render(target, true);
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
BasicMapView(const Point & offset, const Point & dimensions);
|
||||
~BasicMapView() override;
|
||||
|
||||
void tick(uint32_t msPassed) override;
|
||||
void show(SDL_Surface * to) override;
|
||||
void showAll(SDL_Surface * to) override;
|
||||
};
|
||||
|
@ -89,7 +89,7 @@ std::shared_ptr<IMapRendererContext> MapViewController::getContext() const
|
||||
return context;
|
||||
}
|
||||
|
||||
void MapViewController::updateBefore(uint32_t timeDelta)
|
||||
void MapViewController::tick(uint32_t timeDelta)
|
||||
{
|
||||
// confirmed to match H3 for
|
||||
// - hero embarking on boat (500 ms)
|
||||
@ -158,7 +158,7 @@ void MapViewController::updateBefore(uint32_t timeDelta)
|
||||
}
|
||||
}
|
||||
|
||||
void MapViewController::updateAfter(uint32_t timeDelta)
|
||||
void MapViewController::afterRender()
|
||||
{
|
||||
if(movementContext)
|
||||
{
|
||||
|
@ -83,8 +83,8 @@ public:
|
||||
void setViewCenter(const int3 & position);
|
||||
void setViewCenter(const Point & position, int level);
|
||||
void setTileSize(const Point & tileSize);
|
||||
void updateBefore(uint32_t timeDelta);
|
||||
void updateAfter(uint32_t timeDelta);
|
||||
void tick(uint32_t timePassed);
|
||||
void afterRender();
|
||||
|
||||
void activateAdventureContext(uint32_t animationTime);
|
||||
void activateAdventureContext();
|
||||
|
@ -320,6 +320,8 @@ CShowableAnim::CShowableAnim(int x, int y, std::string name, ui8 Flags, ui32 fra
|
||||
pos.h = anim->getImage(0, group)->height();
|
||||
pos.x+= x;
|
||||
pos.y+= y;
|
||||
|
||||
addUsedEvents(TIME);
|
||||
}
|
||||
|
||||
CShowableAnim::~CShowableAnim()
|
||||
@ -391,11 +393,14 @@ void CShowableAnim::show(SDL_Surface * to)
|
||||
if ( flags & BASE )// && frame != first) // FIXME: results in graphical glytch in Fortress, upgraded hydra's dwelling
|
||||
blitImage(first, group, to);
|
||||
blitImage(frame, group, to);
|
||||
}
|
||||
|
||||
void CShowableAnim::tick(uint32_t msPassed)
|
||||
{
|
||||
if ((flags & PLAY_ONCE) && frame + 1 == last)
|
||||
return;
|
||||
|
||||
frameTimePassed += GH.getFrameDeltaMilliseconds();
|
||||
frameTimePassed += msPassed;
|
||||
|
||||
if(frameTimePassed >= frameTimeTotal)
|
||||
{
|
||||
|
@ -190,6 +190,7 @@ public:
|
||||
//show current frame and increase counter
|
||||
void show(SDL_Surface * to) override;
|
||||
void showAll(SDL_Surface * to) override;
|
||||
void tick(uint32_t msPassed) override;
|
||||
};
|
||||
|
||||
/// Creature-dependend animations like attacking, moving,...
|
||||
|
@ -68,7 +68,7 @@ CBuildingRect::CBuildingRect(CCastleBuildings * Par, const CGTownInstance * Town
|
||||
area(nullptr),
|
||||
stateTimeCounter(BUILD_ANIMATION_FINISHED_TIMEPOINT)
|
||||
{
|
||||
addUsedEvents(LCLICK | RCLICK | HOVER);
|
||||
addUsedEvents(LCLICK | RCLICK | HOVER | TIME);
|
||||
pos.x += str->pos.x;
|
||||
pos.y += str->pos.y;
|
||||
|
||||
@ -203,9 +203,12 @@ void CBuildingRect::show(SDL_Surface * to)
|
||||
|
||||
border->draw(to, pos.x, pos.y);
|
||||
}
|
||||
}
|
||||
|
||||
if(stateTimeCounter < BUILD_ANIMATION_FINISHED_TIMEPOINT)
|
||||
stateTimeCounter += GH.getFrameDeltaMilliseconds();
|
||||
void CBuildingRect::tick(uint32_t msPassed)
|
||||
{
|
||||
CShowableAnim::tick(msPassed);
|
||||
stateTimeCounter += msPassed;
|
||||
}
|
||||
|
||||
void CBuildingRect::showAll(SDL_Surface * to)
|
||||
|
@ -69,6 +69,7 @@ public:
|
||||
void clickLeft(tribool down, bool previousState) override;
|
||||
void clickRight(tribool down, bool previousState) override;
|
||||
void mouseMoved (const Point & cursorPosition) override;
|
||||
void tick(uint32_t msPassed) override;
|
||||
void show(SDL_Surface * to) override;
|
||||
void showAll(SDL_Surface * to) override;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user