mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
CShowableAnim is now time-based with timing matching H3
This commit is contained in:
parent
a9fefffc65
commit
3acee297be
@ -690,7 +690,7 @@ CInfoBar::VisibleDateInfo::VisibleDateInfo()
|
|||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
|
|
||||||
animation = std::make_shared<CShowableAnim>(1, 0, getNewDayName(), CShowableAnim::PLAY_ONCE);
|
animation = std::make_shared<CShowableAnim>(1, 0, getNewDayName(), CShowableAnim::PLAY_ONCE, 180);// H3 uses around 175-180 ms per frame
|
||||||
|
|
||||||
std::string labelText;
|
std::string labelText;
|
||||||
if(LOCPLINT->cb->getDate(Date::DAY_OF_WEEK) == 1 && LOCPLINT->cb->getDate(Date::DAY) != 1) // monday of any week but first - show new week info
|
if(LOCPLINT->cb->getDate(Date::DAY_OF_WEEK) == 1 && LOCPLINT->cb->getDate(Date::DAY) != 1) // monday of any week but first - show new week info
|
||||||
@ -731,8 +731,8 @@ CInfoBar::VisibleEnemyTurnInfo::VisibleEnemyTurnInfo(PlayerColor player)
|
|||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
background = std::make_shared<CPicture>("ADSTATNX");
|
background = std::make_shared<CPicture>("ADSTATNX");
|
||||||
banner = std::make_shared<CAnimImage>("CREST58", player.getNum(), 0, 20, 51);
|
banner = std::make_shared<CAnimImage>("CREST58", player.getNum(), 0, 20, 51);
|
||||||
sand = std::make_shared<CShowableAnim>(99, 51, "HOURSAND");
|
sand = std::make_shared<CShowableAnim>(99, 51, "HOURSAND", 0, 100); // H3 uses around 100 ms per frame
|
||||||
glass = std::make_shared<CShowableAnim>(99, 51, "HOURGLAS", CShowableAnim::PLAY_ONCE, 40);
|
glass = std::make_shared<CShowableAnim>(99, 51, "HOURGLAS", CShowableAnim::PLAY_ONCE, 1000); // H3 scales this nicely for AI turn duration, don't have anything like that in vcmi
|
||||||
}
|
}
|
||||||
|
|
||||||
CInfoBar::VisibleGameStatusInfo::VisibleGameStatusInfo()
|
CInfoBar::VisibleGameStatusInfo::VisibleGameStatusInfo()
|
||||||
@ -890,7 +890,7 @@ void CInfoBar::showDate()
|
|||||||
playNewDaySound();
|
playNewDaySound();
|
||||||
state = DATE;
|
state = DATE;
|
||||||
visibleInfo = std::make_shared<VisibleDateInfo>();
|
visibleInfo = std::make_shared<VisibleDateInfo>();
|
||||||
setTimer(3000);
|
setTimer(3000); // confirmed to match H3
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,13 +333,13 @@ void CAnimImage::playerColored(PlayerColor currPlayer)
|
|||||||
anim->getImage(0, group)->playerColored(player);
|
anim->getImage(0, group)->playerColored(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
CShowableAnim::CShowableAnim(int x, int y, std::string name, ui8 Flags, ui32 Delay, size_t Group, uint8_t alpha):
|
CShowableAnim::CShowableAnim(int x, int y, std::string name, ui8 Flags, ui32 frameTime, size_t Group, uint8_t alpha):
|
||||||
anim(std::make_shared<CAnimation>(name)),
|
anim(std::make_shared<CAnimation>(name)),
|
||||||
group(Group),
|
group(Group),
|
||||||
frame(0),
|
frame(0),
|
||||||
first(0),
|
first(0),
|
||||||
frameDelay(Delay),
|
frameTimeTotal(frameTime),
|
||||||
value(0),
|
frameTimePassed(0),
|
||||||
flags(Flags),
|
flags(Flags),
|
||||||
xOffset(0),
|
xOffset(0),
|
||||||
yOffset(0),
|
yOffset(0),
|
||||||
@ -380,7 +380,7 @@ bool CShowableAnim::set(size_t Group, size_t from, size_t to)
|
|||||||
group = Group;
|
group = Group;
|
||||||
frame = first = from;
|
frame = first = from;
|
||||||
last = max;
|
last = max;
|
||||||
value = 0;
|
frameTimePassed = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,13 +397,13 @@ bool CShowableAnim::set(size_t Group)
|
|||||||
group = Group;
|
group = Group;
|
||||||
last = anim->size(Group);
|
last = anim->size(Group);
|
||||||
}
|
}
|
||||||
frame = value = 0;
|
frame = 0;
|
||||||
|
frameTimePassed = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CShowableAnim::reset()
|
void CShowableAnim::reset()
|
||||||
{
|
{
|
||||||
value = 0;
|
|
||||||
frame = first;
|
frame = first;
|
||||||
|
|
||||||
if (callback)
|
if (callback)
|
||||||
@ -427,9 +427,11 @@ void CShowableAnim::show(SDL_Surface * to)
|
|||||||
if ((flags & PLAY_ONCE) && frame + 1 == last)
|
if ((flags & PLAY_ONCE) && frame + 1 == last)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( ++value == frameDelay )
|
frameTimePassed += GH.mainFPSmng->getElapsedMilliseconds();
|
||||||
|
|
||||||
|
if(frameTimePassed >= frameTimeTotal)
|
||||||
{
|
{
|
||||||
value = 0;
|
frameTimePassed -= frameTimeTotal;
|
||||||
if ( ++frame >= last)
|
if ( ++frame >= last)
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
@ -466,7 +468,7 @@ void CShowableAnim::rotate(bool on, bool vertical)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CCreatureAnim::CCreatureAnim(int x, int y, std::string name, ui8 flags, ECreatureAnimType type):
|
CCreatureAnim::CCreatureAnim(int x, int y, std::string name, ui8 flags, ECreatureAnimType type):
|
||||||
CShowableAnim(x,y,name,flags,4,size_t(type))
|
CShowableAnim(x, y, name, flags, 100, size_t(type)) // H3 uses 100 ms per frame, irregardless of battle speed settings
|
||||||
{
|
{
|
||||||
xOffset = 0;
|
xOffset = 0;
|
||||||
yOffset = 0;
|
yOffset = 0;
|
||||||
|
@ -125,9 +125,9 @@ protected:
|
|||||||
|
|
||||||
size_t first, last; //animation range
|
size_t first, last; //animation range
|
||||||
|
|
||||||
//TODO: replace with time delay(needed for battles)
|
/// how long (in milliseconds) should
|
||||||
ui32 frameDelay;//delay in frames of each image
|
ui32 frameTimeTotal;
|
||||||
ui32 value;//how many times current frame was showed
|
ui32 frameTimePassed;
|
||||||
|
|
||||||
ui8 flags;//Flags from EFlags enum
|
ui8 flags;//Flags from EFlags enum
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ public:
|
|||||||
//Set per-surface alpha, 0 = transparent, 255 = opaque
|
//Set per-surface alpha, 0 = transparent, 255 = opaque
|
||||||
void setAlpha(ui32 alphaValue);
|
void setAlpha(ui32 alphaValue);
|
||||||
|
|
||||||
CShowableAnim(int x, int y, std::string name, ui8 flags=0, ui32 Delay=4, size_t Group=0, uint8_t alpha = UINT8_MAX);
|
CShowableAnim(int x, int y, std::string name, ui8 flags, ui32 frameTime, size_t Group=0, uint8_t alpha = UINT8_MAX);
|
||||||
~CShowableAnim();
|
~CShowableAnim();
|
||||||
|
|
||||||
//set animation to group or part of group
|
//set animation to group or part of group
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#include "../../lib/mapObjects/CGTownInstance.h"
|
#include "../../lib/mapObjects/CGTownInstance.h"
|
||||||
|
|
||||||
CBuildingRect::CBuildingRect(CCastleBuildings * Par, const CGTownInstance * Town, const CStructure * Str)
|
CBuildingRect::CBuildingRect(CCastleBuildings * Par, const CGTownInstance * Town, const CStructure * Str)
|
||||||
: CShowableAnim(0, 0, Str->defName, CShowableAnim::BASE),
|
: CShowableAnim(0, 0, Str->defName, CShowableAnim::BASE, BUILDING_FRAME_TIME),
|
||||||
parent(Par),
|
parent(Par),
|
||||||
town(Town),
|
town(Town),
|
||||||
str(Str),
|
str(Str),
|
||||||
|
@ -47,7 +47,9 @@ public:
|
|||||||
BUILDING_APPEAR_TIMEPOINT = 500, //500 msec building appears: 0->100% transparency
|
BUILDING_APPEAR_TIMEPOINT = 500, //500 msec building appears: 0->100% transparency
|
||||||
BUILDING_WHITE_BORDER_TIMEPOINT = 1000, //500 msec border glows from white to yellow
|
BUILDING_WHITE_BORDER_TIMEPOINT = 1000, //500 msec border glows from white to yellow
|
||||||
BUILDING_YELLOW_BORDER_TIMEPOINT = 1500, //500 msec border glows from yellow to normal
|
BUILDING_YELLOW_BORDER_TIMEPOINT = 1500, //500 msec border glows from yellow to normal
|
||||||
BUILD_ANIMATION_FINISHED_TIMEPOINT = 2500 //1000 msec delay, nothing happens
|
BUILD_ANIMATION_FINISHED_TIMEPOINT = 2500, //1000 msec delay, nothing happens
|
||||||
|
|
||||||
|
BUILDING_FRAME_TIME = 150 // confirmed H3 timing: 150 ms for each building animation frame
|
||||||
};
|
};
|
||||||
|
|
||||||
/// returns building associated with this structure
|
/// returns building associated with this structure
|
||||||
|
Loading…
Reference in New Issue
Block a user