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