mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
vcmi: add reverse effect animation type
To be used later with obstacle removal
This commit is contained in:
parent
c4d5a7a2d6
commit
7543fdf787
@ -871,42 +871,43 @@ uint32_t CastAnimation::getAttackClimaxFrame() const
|
|||||||
return maxFrames / 2;
|
return maxFrames / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectAnimation::EffectAnimation(BattleInterface & owner, std::string animationName, int effects):
|
EffectAnimation::EffectAnimation(BattleInterface & owner, std::string animationName, int effects, bool reversed):
|
||||||
BattleAnimation(owner),
|
BattleAnimation(owner),
|
||||||
animation(std::make_shared<CAnimation>(animationName)),
|
animation(std::make_shared<CAnimation>(animationName)),
|
||||||
effectFlags(effects),
|
effectFlags(effects),
|
||||||
effectFinished(false)
|
effectFinished(false),
|
||||||
|
reversed(reversed)
|
||||||
{
|
{
|
||||||
logAnim->debug("CPointEffectAnimation::init: effect %s", animationName);
|
logAnim->debug("CPointEffectAnimation::init: effect %s", animationName);
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectAnimation::EffectAnimation(BattleInterface & owner, std::string animationName, std::vector<BattleHex> hex, int effects):
|
EffectAnimation::EffectAnimation(BattleInterface & owner, std::string animationName, std::vector<BattleHex> hex, int effects, bool reversed):
|
||||||
EffectAnimation(owner, animationName, effects)
|
EffectAnimation(owner, animationName, effects, reversed)
|
||||||
{
|
{
|
||||||
battlehexes = hex;
|
battlehexes = hex;
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectAnimation::EffectAnimation(BattleInterface & owner, std::string animationName, BattleHex hex, int effects):
|
EffectAnimation::EffectAnimation(BattleInterface & owner, std::string animationName, BattleHex hex, int effects, bool reversed):
|
||||||
EffectAnimation(owner, animationName, effects)
|
EffectAnimation(owner, animationName, effects, reversed)
|
||||||
{
|
{
|
||||||
assert(hex.isValid());
|
assert(hex.isValid());
|
||||||
battlehexes.push_back(hex);
|
battlehexes.push_back(hex);
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectAnimation::EffectAnimation(BattleInterface & owner, std::string animationName, std::vector<Point> pos, int effects):
|
EffectAnimation::EffectAnimation(BattleInterface & owner, std::string animationName, std::vector<Point> pos, int effects, bool reversed):
|
||||||
EffectAnimation(owner, animationName, effects)
|
EffectAnimation(owner, animationName, effects, reversed)
|
||||||
{
|
{
|
||||||
positions = pos;
|
positions = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectAnimation::EffectAnimation(BattleInterface & owner, std::string animationName, Point pos, int effects):
|
EffectAnimation::EffectAnimation(BattleInterface & owner, std::string animationName, Point pos, int effects, bool reversed):
|
||||||
EffectAnimation(owner, animationName, effects)
|
EffectAnimation(owner, animationName, effects, reversed)
|
||||||
{
|
{
|
||||||
positions.push_back(pos);
|
positions.push_back(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectAnimation::EffectAnimation(BattleInterface & owner, std::string animationName, Point pos, BattleHex hex, int effects):
|
EffectAnimation::EffectAnimation(BattleInterface & owner, std::string animationName, Point pos, BattleHex hex, int effects, bool reversed):
|
||||||
EffectAnimation(owner, animationName, effects)
|
EffectAnimation(owner, animationName, effects, reversed)
|
||||||
{
|
{
|
||||||
assert(hex.isValid());
|
assert(hex.isValid());
|
||||||
battlehexes.push_back(hex);
|
battlehexes.push_back(hex);
|
||||||
@ -924,6 +925,13 @@ bool EffectAnimation::init()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < animation->size(size_t(BattleEffect::AnimType::DEFAULT)); ++i)
|
||||||
|
{
|
||||||
|
size_t current = animation->size(size_t(BattleEffect::AnimType::DEFAULT)) - 1 - i;
|
||||||
|
|
||||||
|
animation->duplicateImage(size_t(BattleEffect::AnimType::DEFAULT), current, size_t(BattleEffect::AnimType::REVERSE));
|
||||||
|
}
|
||||||
|
|
||||||
if (screenFill())
|
if (screenFill())
|
||||||
{
|
{
|
||||||
for(int i=0; i * first->width() < owner.fieldController->pos.w ; ++i)
|
for(int i=0; i * first->width() < owner.fieldController->pos.w ; ++i)
|
||||||
@ -935,6 +943,7 @@ bool EffectAnimation::init()
|
|||||||
be.effectID = ID;
|
be.effectID = ID;
|
||||||
be.animation = animation;
|
be.animation = animation;
|
||||||
be.currentFrame = 0;
|
be.currentFrame = 0;
|
||||||
|
be.type = reversed ? BattleEffect::AnimType::REVERSE : BattleEffect::AnimType::DEFAULT;
|
||||||
|
|
||||||
for (size_t i = 0; i < std::max(battlehexes.size(), positions.size()); ++i)
|
for (size_t i = 0; i < std::max(battlehexes.size(), positions.size()); ++i)
|
||||||
{
|
{
|
||||||
|
@ -310,6 +310,7 @@ class EffectAnimation : public BattleAnimation
|
|||||||
{
|
{
|
||||||
std::string soundName;
|
std::string soundName;
|
||||||
bool effectFinished;
|
bool effectFinished;
|
||||||
|
bool reversed;
|
||||||
int effectFlags;
|
int effectFlags;
|
||||||
|
|
||||||
std::shared_ptr<CAnimation> animation;
|
std::shared_ptr<CAnimation> animation;
|
||||||
@ -334,17 +335,17 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Create animation with screen-wide effect
|
/// Create animation with screen-wide effect
|
||||||
EffectAnimation(BattleInterface & owner, std::string animationName, int effects = 0);
|
EffectAnimation(BattleInterface & owner, std::string animationName, int effects = 0, bool reversed = false);
|
||||||
|
|
||||||
/// Create animation positioned at point(s). Note that positions must be are absolute, including battleint position offset
|
/// Create animation positioned at point(s). Note that positions must be are absolute, including battleint position offset
|
||||||
EffectAnimation(BattleInterface & owner, std::string animationName, Point pos , int effects = 0);
|
EffectAnimation(BattleInterface & owner, std::string animationName, Point pos , int effects = 0, bool reversed = false);
|
||||||
EffectAnimation(BattleInterface & owner, std::string animationName, std::vector<Point> pos , int effects = 0);
|
EffectAnimation(BattleInterface & owner, std::string animationName, std::vector<Point> pos , int effects = 0, bool reversed = false);
|
||||||
|
|
||||||
/// Create animation positioned at certain hex(es)
|
/// Create animation positioned at certain hex(es)
|
||||||
EffectAnimation(BattleInterface & owner, std::string animationName, BattleHex hex , int effects = 0);
|
EffectAnimation(BattleInterface & owner, std::string animationName, BattleHex hex , int effects = 0, bool reversed = false);
|
||||||
EffectAnimation(BattleInterface & owner, std::string animationName, std::vector<BattleHex> hex, int effects = 0);
|
EffectAnimation(BattleInterface & owner, std::string animationName, std::vector<BattleHex> hex, int effects = 0, bool reversed = false);
|
||||||
|
|
||||||
EffectAnimation(BattleInterface & owner, std::string animationName, Point pos, BattleHex hex, int effects = 0);
|
EffectAnimation(BattleInterface & owner, std::string animationName, Point pos, BattleHex hex, int effects = 0, bool reversed = false);
|
||||||
~EffectAnimation();
|
~EffectAnimation();
|
||||||
|
|
||||||
bool init() override;
|
bool init() override;
|
||||||
|
@ -122,7 +122,7 @@ void BattleEffectsController::collectRenderableObjects(BattleRenderer & renderer
|
|||||||
int currentFrame = static_cast<int>(floor(elem.currentFrame));
|
int currentFrame = static_cast<int>(floor(elem.currentFrame));
|
||||||
currentFrame %= elem.animation->size();
|
currentFrame %= elem.animation->size();
|
||||||
|
|
||||||
auto img = elem.animation->getImage(currentFrame);
|
auto img = elem.animation->getImage(currentFrame, static_cast<size_t>(elem.type));
|
||||||
|
|
||||||
canvas.draw(img, elem.pos);
|
canvas.draw(img, elem.pos);
|
||||||
});
|
});
|
||||||
|
@ -30,6 +30,13 @@ class EffectAnimation;
|
|||||||
/// Struct for battle effect animation e.g. morale, prayer, armageddon, bless,...
|
/// Struct for battle effect animation e.g. morale, prayer, armageddon, bless,...
|
||||||
struct BattleEffect
|
struct BattleEffect
|
||||||
{
|
{
|
||||||
|
enum class AnimType : ui8
|
||||||
|
{
|
||||||
|
DEFAULT = 0, //If we have such animation
|
||||||
|
REVERSE = 1 //Reverse DEFAULT will be used
|
||||||
|
};
|
||||||
|
|
||||||
|
AnimType type;
|
||||||
Point pos; //position on the screen
|
Point pos; //position on the screen
|
||||||
float currentFrame;
|
float currentFrame;
|
||||||
std::shared_ptr<CAnimation> animation;
|
std::shared_ptr<CAnimation> animation;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user