mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-27 12:22:45 +02:00
Wiped CDefEssential
This commit is contained in:
parent
6cd0dd9843
commit
3bbff27127
@ -29,12 +29,9 @@ static long long pow(long long a, int b)
|
|||||||
|
|
||||||
CDefHandler::CDefHandler()
|
CDefHandler::CDefHandler()
|
||||||
{
|
{
|
||||||
notFreeImgs = false;
|
|
||||||
}
|
}
|
||||||
CDefHandler::~CDefHandler()
|
CDefHandler::~CDefHandler()
|
||||||
{
|
{
|
||||||
if (notFreeImgs)
|
|
||||||
return;
|
|
||||||
for (auto & elem : ourImages)
|
for (auto & elem : ourImages)
|
||||||
{
|
{
|
||||||
if (elem.bitmap)
|
if (elem.bitmap)
|
||||||
@ -44,11 +41,6 @@ CDefHandler::~CDefHandler()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CDefEssential::~CDefEssential()
|
|
||||||
{
|
|
||||||
for(auto & elem : ourImages)
|
|
||||||
SDL_FreeSurface(elem.bitmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDefHandler::openFromMemory(ui8 *table, const std::string & name)
|
void CDefHandler::openFromMemory(ui8 *table, const std::string & name)
|
||||||
{
|
{
|
||||||
@ -350,14 +342,6 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const SDL_Co
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
CDefEssential * CDefHandler::essentialize()
|
|
||||||
{
|
|
||||||
auto ret = new CDefEssential();
|
|
||||||
ret->ourImages = ourImages;
|
|
||||||
notFreeImgs = true;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
CDefHandler * CDefHandler::giveDef(const std::string & defName)
|
CDefHandler * CDefHandler::giveDef(const std::string & defName)
|
||||||
{
|
{
|
||||||
ResourceID resID(std::string("SPRITES/") + defName, EResType::ANIMATION);
|
ResourceID resID(std::string("SPRITES/") + defName, EResType::ANIMATION);
|
||||||
@ -369,12 +353,4 @@ CDefHandler * CDefHandler::giveDef(const std::string & defName)
|
|||||||
nh->openFromMemory(data.get(), defName);
|
nh->openFromMemory(data.get(), defName);
|
||||||
return nh;
|
return nh;
|
||||||
}
|
}
|
||||||
CDefEssential * CDefHandler::giveDefEss(const std::string & defName)
|
|
||||||
{
|
|
||||||
CDefEssential * ret;
|
|
||||||
CDefHandler * temp = giveDef(defName);
|
|
||||||
ret = temp->essentialize();
|
|
||||||
delete temp;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -66,12 +66,6 @@ struct SSpriteDef
|
|||||||
ui32 TopMargin;
|
ui32 TopMargin;
|
||||||
} PACKED_STRUCT;
|
} PACKED_STRUCT;
|
||||||
|
|
||||||
class CDefEssential //DefHandler with images only
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
std::vector<Cimage> ourImages;
|
|
||||||
~CDefEssential();
|
|
||||||
};
|
|
||||||
|
|
||||||
class CDefHandler
|
class CDefHandler
|
||||||
{
|
{
|
||||||
@ -91,13 +85,10 @@ public:
|
|||||||
int width, height; //width and height
|
int width, height; //width and height
|
||||||
std::string defName;
|
std::string defName;
|
||||||
std::vector<Cimage> ourImages;
|
std::vector<Cimage> ourImages;
|
||||||
bool notFreeImgs;
|
|
||||||
|
|
||||||
CDefHandler();
|
CDefHandler();
|
||||||
~CDefHandler();
|
~CDefHandler();
|
||||||
|
|
||||||
CDefEssential * essentialize();
|
|
||||||
|
|
||||||
static CDefHandler * giveDef(const std::string & defName);
|
static CDefHandler * giveDef(const std::string & defName);
|
||||||
static CDefEssential * giveDefEss(const std::string & defName);
|
|
||||||
};
|
};
|
||||||
|
@ -58,13 +58,13 @@ bool CBattleAnimation::isEarliest(bool perStackConcurrency)
|
|||||||
{
|
{
|
||||||
int lowestMoveID = owner->animIDhelper + 5;
|
int lowestMoveID = owner->animIDhelper + 5;
|
||||||
CBattleStackAnimation * thAnim = dynamic_cast<CBattleStackAnimation *>(this);
|
CBattleStackAnimation * thAnim = dynamic_cast<CBattleStackAnimation *>(this);
|
||||||
CSpellEffectAnimation * thSen = dynamic_cast<CSpellEffectAnimation *>(this);
|
CEffectAnimation * thSen = dynamic_cast<CEffectAnimation *>(this);
|
||||||
|
|
||||||
for(auto & elem : owner->pendingAnims)
|
for(auto & elem : owner->pendingAnims)
|
||||||
{
|
{
|
||||||
|
|
||||||
CBattleStackAnimation * stAnim = dynamic_cast<CBattleStackAnimation *>(elem.first);
|
CBattleStackAnimation * stAnim = dynamic_cast<CBattleStackAnimation *>(elem.first);
|
||||||
CSpellEffectAnimation * sen = dynamic_cast<CSpellEffectAnimation *>(elem.first);
|
CEffectAnimation * sen = dynamic_cast<CEffectAnimation *>(elem.first);
|
||||||
if(perStackConcurrency && stAnim && thAnim && stAnim->stack->ID != thAnim->stack->ID)
|
if(perStackConcurrency && stAnim && thAnim && stAnim->stack->ID != thAnim->stack->ID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ bool CDefenceAnimation::init()
|
|||||||
if(attAnim && attAnim->stack->ID != stack->ID)
|
if(attAnim && attAnim->stack->ID != stack->ID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CSpellEffectAnimation * sen = dynamic_cast<CSpellEffectAnimation *>(elem.first);
|
CEffectAnimation * sen = dynamic_cast<CEffectAnimation *>(elem.first);
|
||||||
if (sen)
|
if (sen)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ CCreatureAnim::EAnimType CDefenceAnimation::getMyAnimType()
|
|||||||
if(killed)
|
if(killed)
|
||||||
return CCreatureAnim::DEATH;
|
return CCreatureAnim::DEATH;
|
||||||
|
|
||||||
if (vstd::contains(stack->state, EBattleStackState::DEFENDING_ANIM))
|
if(vstd::contains(stack->state, EBattleStackState::DEFENDING_ANIM))
|
||||||
return CCreatureAnim::DEFENCE;
|
return CCreatureAnim::DEFENCE;
|
||||||
|
|
||||||
return CCreatureAnim::HITTED;
|
return CCreatureAnim::HITTED;
|
||||||
@ -270,10 +270,15 @@ void CDefenceAnimation::nextFrame()
|
|||||||
|
|
||||||
void CDefenceAnimation::endAnim()
|
void CDefenceAnimation::endAnim()
|
||||||
{
|
{
|
||||||
if (killed)
|
if(killed)
|
||||||
|
{
|
||||||
myAnim->setType(CCreatureAnim::DEAD);
|
myAnim->setType(CCreatureAnim::DEAD);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
myAnim->setType(CCreatureAnim::HOLDING);
|
myAnim->setType(CCreatureAnim::HOLDING);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CBattleAnimation::endAnim();
|
CBattleAnimation::endAnim();
|
||||||
|
|
||||||
@ -791,7 +796,7 @@ bool CShootingAnimation::init()
|
|||||||
Point animPos(destPos.x - 126 + img->width() / 2,
|
Point animPos(destPos.x - 126 + img->width() / 2,
|
||||||
destPos.y - 105 + img->height() / 2);
|
destPos.y - 105 + img->height() / 2);
|
||||||
|
|
||||||
owner->addNewAnim( new CSpellEffectAnimation(owner, catapultDamage ? "SGEXPL.DEF" : "CSGRCK.DEF", animPos.x, animPos.y));
|
owner->addNewAnim( new CEffectAnimation(owner, catapultDamage ? "SGEXPL.DEF" : "CSGRCK.DEF", animPos.x, animPos.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto & angles = shooterInfo->animation.missleFrameAngles;
|
auto & angles = shooterInfo->animation.missleFrameAngles;
|
||||||
@ -872,35 +877,40 @@ void CShootingAnimation::endAnim()
|
|||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSpellEffectAnimation::CSpellEffectAnimation(CBattleInterface * _owner, ui32 _effect, BattleHex _destTile, int _dx, int _dy, bool _Vflip, bool _alignToBottom)
|
CEffectAnimation::CEffectAnimation(CBattleInterface * _owner, std::string _customAnim, int _x, int _y, int _dx, int _dy, bool _Vflip, bool _alignToBottom)
|
||||||
:CBattleAnimation(_owner), effect(_effect), destTile(_destTile), customAnim(""), x(-1), y(-1), dx(_dx), dy(_dy), Vflip(_Vflip), alignToBottom(_alignToBottom)
|
: CBattleAnimation(_owner),
|
||||||
|
destTile(BattleHex::INVALID),
|
||||||
|
customAnim(_customAnim),
|
||||||
|
x(_x),
|
||||||
|
y(_y),
|
||||||
|
dx(_dx),
|
||||||
|
dy(_dy),
|
||||||
|
Vflip(_Vflip),
|
||||||
|
alignToBottom(_alignToBottom)
|
||||||
{
|
{
|
||||||
logAnim->debug("Created spell anim for effect #%d", effect);
|
logAnim->debug("Created effect animation %s", customAnim);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSpellEffectAnimation::CSpellEffectAnimation(CBattleInterface * _owner, std::string _customAnim, int _x, int _y, int _dx, int _dy, bool _Vflip, bool _alignToBottom)
|
CEffectAnimation::CEffectAnimation(CBattleInterface * _owner, std::string _customAnim, BattleHex _destTile, bool _Vflip, bool _alignToBottom)
|
||||||
:CBattleAnimation(_owner), effect(-1), destTile(BattleHex::INVALID), customAnim(_customAnim), x(_x), y(_y), dx(_dx), dy(_dy), Vflip(_Vflip), alignToBottom(_alignToBottom)
|
: CBattleAnimation(_owner),
|
||||||
|
destTile(_destTile),
|
||||||
|
customAnim(_customAnim),
|
||||||
|
x(-1),
|
||||||
|
y(-1),
|
||||||
|
dx(0),
|
||||||
|
dy(0),
|
||||||
|
Vflip(_Vflip),
|
||||||
|
alignToBottom(_alignToBottom)
|
||||||
{
|
{
|
||||||
logAnim->debug("Created spell anim for %s", customAnim);
|
logAnim->debug("Created effect animation %s", customAnim);
|
||||||
}
|
|
||||||
|
|
||||||
CSpellEffectAnimation::CSpellEffectAnimation(CBattleInterface * _owner, std::string _customAnim, BattleHex _destTile, bool _Vflip, bool _alignToBottom)
|
|
||||||
:CBattleAnimation(_owner), effect(-1), destTile(_destTile), customAnim(_customAnim), x(-1), y(-1), dx(0), dy(0), Vflip(_Vflip), alignToBottom(_alignToBottom)
|
|
||||||
{
|
|
||||||
logAnim->debug("Created spell anim for %s", customAnim);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CSpellEffectAnimation::init()
|
bool CEffectAnimation::init()
|
||||||
{
|
{
|
||||||
if(!isEarliest(true))
|
if(!isEarliest(true))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(customAnim.empty() && effect != ui32(-1) && !graphics->battleACToDef[effect].empty())
|
|
||||||
{
|
|
||||||
customAnim = graphics->battleACToDef[effect][0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(customAnim.empty())
|
if(customAnim.empty())
|
||||||
{
|
{
|
||||||
endAnim();
|
endAnim();
|
||||||
@ -990,7 +1000,7 @@ bool CSpellEffectAnimation::init()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSpellEffectAnimation::nextFrame()
|
void CEffectAnimation::nextFrame()
|
||||||
{
|
{
|
||||||
//notice: there may be more than one effect in owner->battleEffects correcponding to this animation (ie. armageddon)
|
//notice: there may be more than one effect in owner->battleEffects correcponding to this animation (ie. armageddon)
|
||||||
for(auto & elem : owner->battleEffects)
|
for(auto & elem : owner->battleEffects)
|
||||||
@ -1013,7 +1023,7 @@ void CSpellEffectAnimation::nextFrame()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSpellEffectAnimation::endAnim()
|
void CEffectAnimation::endAnim()
|
||||||
{
|
{
|
||||||
CBattleAnimation::endAnim();
|
CBattleAnimation::endAnim();
|
||||||
|
|
||||||
|
@ -213,11 +213,10 @@ public:
|
|||||||
virtual ~CShootingAnimation(){};
|
virtual ~CShootingAnimation(){};
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This class manages a spell effect animation
|
/// This class manages effect animation
|
||||||
class CSpellEffectAnimation : public CBattleAnimation
|
class CEffectAnimation : public CBattleAnimation
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ui32 effect;
|
|
||||||
BattleHex destTile;
|
BattleHex destTile;
|
||||||
std::string customAnim;
|
std::string customAnim;
|
||||||
int x, y, dx, dy;
|
int x, y, dx, dy;
|
||||||
@ -228,8 +227,7 @@ public:
|
|||||||
void nextFrame() override;
|
void nextFrame() override;
|
||||||
void endAnim() override;
|
void endAnim() override;
|
||||||
|
|
||||||
CSpellEffectAnimation(CBattleInterface * _owner, ui32 _effect, BattleHex _destTile, int _dx = 0, int _dy = 0, bool _Vflip = false, bool _alignToBottom = false);
|
CEffectAnimation(CBattleInterface * _owner, std::string _customAnim, int _x, int _y, int _dx = 0, int _dy = 0, bool _Vflip = false, bool _alignToBottom = false);
|
||||||
CSpellEffectAnimation(CBattleInterface * _owner, std::string _customAnim, int _x, int _y, int _dx = 0, int _dy = 0, bool _Vflip = false, bool _alignToBottom = false);
|
CEffectAnimation(CBattleInterface * _owner, std::string _customAnim, BattleHex _destTile, bool _Vflip = false, bool _alignToBottom = false);
|
||||||
CSpellEffectAnimation(CBattleInterface * _owner, std::string _customAnim, BattleHex _destTile, bool _Vflip = false, bool _alignToBottom = false);
|
virtual ~CEffectAnimation(){};
|
||||||
virtual ~CSpellEffectAnimation(){};
|
|
||||||
};
|
};
|
||||||
|
@ -1221,7 +1221,7 @@ void CBattleInterface::stackIsCatapulting(const CatapultAttack & ca)
|
|||||||
{
|
{
|
||||||
Point destPos = CClickableHex::getXYUnitAnim(attackInfo.destinationTile, nullptr, this) + Point(99, 120);
|
Point destPos = CClickableHex::getXYUnitAnim(attackInfo.destinationTile, nullptr, this) + Point(99, 120);
|
||||||
|
|
||||||
addNewAnim(new CSpellEffectAnimation(this, "SGEXPL.DEF", destPos.x, destPos.y));
|
addNewAnim(new CEffectAnimation(this, "SGEXPL.DEF", destPos.x, destPos.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1309,20 +1309,23 @@ void CBattleInterface::spellCast(const BattleSpellCast *sc)
|
|||||||
|
|
||||||
std::string animToDisplay = spell.animationInfo.selectProjectile(angle);
|
std::string animToDisplay = spell.animationInfo.selectProjectile(angle);
|
||||||
|
|
||||||
if (!animToDisplay.empty())
|
if(!animToDisplay.empty())
|
||||||
{
|
{
|
||||||
|
//TODO: calculate inside CEffectAnimation
|
||||||
|
std::shared_ptr<CAnimation> tmp = std::make_shared<CAnimation>(animToDisplay);
|
||||||
|
tmp->load(0, 0);
|
||||||
|
IImage * first = tmp->getImage(0, 0);
|
||||||
|
|
||||||
//displaying animation
|
//displaying animation
|
||||||
CDefEssential *animDef = CDefHandler::giveDefEss(animToDisplay);
|
|
||||||
double diffX = (destcoord.x - srccoord.x)*(destcoord.x - srccoord.x);
|
double diffX = (destcoord.x - srccoord.x)*(destcoord.x - srccoord.x);
|
||||||
double diffY = (destcoord.y - srccoord.y)*(destcoord.y - srccoord.y);
|
double diffY = (destcoord.y - srccoord.y)*(destcoord.y - srccoord.y);
|
||||||
double distance = sqrt(diffX + diffY);
|
double distance = sqrt(diffX + diffY);
|
||||||
|
|
||||||
int steps = distance / AnimationControls::getSpellEffectSpeed() + 1;
|
int steps = distance / AnimationControls::getSpellEffectSpeed() + 1;
|
||||||
int dx = (destcoord.x - srccoord.x - animDef->ourImages[0].bitmap->w)/steps;
|
int dx = (destcoord.x - srccoord.x - first->width())/steps;
|
||||||
int dy = (destcoord.y - srccoord.y - animDef->ourImages[0].bitmap->h)/steps;
|
int dy = (destcoord.y - srccoord.y - first->height())/steps;
|
||||||
|
|
||||||
delete animDef;
|
addNewAnim(new CEffectAnimation(this, animToDisplay, srccoord.x, srccoord.y, dx, dy, Vflip));
|
||||||
addNewAnim(new CSpellEffectAnimation(this, animToDisplay, srccoord.x, srccoord.y, dx, dy, Vflip));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
waitForAnims();
|
waitForAnims();
|
||||||
@ -1354,8 +1357,8 @@ void CBattleInterface::spellCast(const BattleSpellCast *sc)
|
|||||||
{
|
{
|
||||||
Point leftHero = Point(15, 30) + pos;
|
Point leftHero = Point(15, 30) + pos;
|
||||||
Point rightHero = Point(755, 30) + pos;
|
Point rightHero = Point(755, 30) + pos;
|
||||||
addNewAnim(new CSpellEffectAnimation(this, sc->side ? "SP07_A.DEF" : "SP07_B.DEF", leftHero.x, leftHero.y, 0, 0, false));
|
addNewAnim(new CEffectAnimation(this, sc->side ? "SP07_A.DEF" : "SP07_B.DEF", leftHero.x, leftHero.y, 0, 0, false));
|
||||||
addNewAnim(new CSpellEffectAnimation(this, sc->side ? "SP07_B.DEF" : "SP07_A.DEF", rightHero.x, rightHero.y, 0, 0, false));
|
addNewAnim(new CEffectAnimation(this, sc->side ? "SP07_B.DEF" : "SP07_A.DEF", rightHero.x, rightHero.y, 0, 0, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1418,9 +1421,11 @@ void CBattleInterface::castThisSpell(SpellID spellID)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBattleInterface::displayEffect(ui32 effect, int destTile)
|
void CBattleInterface::displayEffect(ui32 effect, BattleHex destTile)
|
||||||
{
|
{
|
||||||
addNewAnim(new CSpellEffectAnimation(this, effect, destTile, 0, 0, false));
|
std::string customAnim = graphics->battleACToDef[effect][0];
|
||||||
|
|
||||||
|
addNewAnim(new CEffectAnimation(this, customAnim, destTile));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBattleInterface::displaySpellAnimation(const CSpell::TAnimation & animation, BattleHex destinationTile)
|
void CBattleInterface::displaySpellAnimation(const CSpell::TAnimation & animation, BattleHex destinationTile)
|
||||||
@ -1431,7 +1436,7 @@ void CBattleInterface::displaySpellAnimation(const CSpell::TAnimation & animatio
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
addNewAnim(new CSpellEffectAnimation(this, animation.resourceName, destinationTile, false, animation.verticalPosition == VerticalPosition::BOTTOM));
|
addNewAnim(new CEffectAnimation(this, animation.resourceName, destinationTile, false, animation.verticalPosition == VerticalPosition::BOTTOM));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2737,7 +2742,7 @@ void CBattleInterface::obstaclePlaced(const CObstacleInstance & oi)
|
|||||||
//we assume here that effect graphics have the same size as the usual obstacle image
|
//we assume here that effect graphics have the same size as the usual obstacle image
|
||||||
// -> if we know how to blit obstacle, let's blit the effect in the same place
|
// -> if we know how to blit obstacle, let's blit the effect in the same place
|
||||||
Point whereTo = getObstaclePosition(getObstacleImage(oi), oi);
|
Point whereTo = getObstaclePosition(getObstacleImage(oi), oi);
|
||||||
addNewAnim(new CSpellEffectAnimation(this, defname, whereTo.x, whereTo.y));
|
addNewAnim(new CEffectAnimation(this, defname, whereTo.x, whereTo.y));
|
||||||
|
|
||||||
//TODO we need to wait after playing sound till it's finished, otherwise it overlaps and sounds really bad
|
//TODO we need to wait after playing sound till it's finished, otherwise it overlaps and sounds really bad
|
||||||
//CCS->soundh->playSound(sound);
|
//CCS->soundh->playSound(sound);
|
||||||
|
@ -120,6 +120,7 @@ class CBattleInterface : public CIntObject
|
|||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
SDL_Surface *background, *menu, *amountNormal, *amountNegative, *amountPositive, *amountEffNeutral, *cellBorders, *backgroundWithHexes;
|
SDL_Surface *background, *menu, *amountNormal, *amountNegative, *amountPositive, *amountEffNeutral, *cellBorders, *backgroundWithHexes;
|
||||||
|
|
||||||
CButton *bOptions, *bSurrender, *bFlee, *bAutofight, *bSpell,
|
CButton *bOptions, *bSurrender, *bFlee, *bAutofight, *bSpell,
|
||||||
* bWait, *bDefence, *bConsoleUp, *bConsoleDown, *btactNext, *btactEnd;
|
* bWait, *bDefence, *bConsoleUp, *bConsoleDown, *btactNext, *btactEnd;
|
||||||
CBattleConsole *console;
|
CBattleConsole *console;
|
||||||
@ -342,7 +343,7 @@ public:
|
|||||||
void spellCast(const BattleSpellCast *sc); //called when a hero casts a spell
|
void spellCast(const BattleSpellCast *sc); //called when a hero casts a spell
|
||||||
void battleStacksEffectsSet(const SetStackEffect & sse); //called when a specific effect is set to stacks
|
void battleStacksEffectsSet(const SetStackEffect & sse); //called when a specific effect is set to stacks
|
||||||
void castThisSpell(SpellID spellID); //called when player has chosen a spell from spellbook
|
void castThisSpell(SpellID spellID); //called when player has chosen a spell from spellbook
|
||||||
void displayEffect(ui32 effect, int destTile); //displays custom effect on the battlefield
|
void displayEffect(ui32 effect, BattleHex destTile); //displays custom effect on the battlefield
|
||||||
|
|
||||||
void displaySpellCast(SpellID spellID, BattleHex destinationTile); //displays spell`s cast animation
|
void displaySpellCast(SpellID spellID, BattleHex destinationTile); //displays spell`s cast animation
|
||||||
void displaySpellEffect(SpellID spellID, BattleHex destinationTile); //displays spell`s affected animation
|
void displaySpellEffect(SpellID spellID, BattleHex destinationTile); //displays spell`s affected animation
|
||||||
@ -378,7 +379,7 @@ public:
|
|||||||
|
|
||||||
friend class CBattleResultWindow;
|
friend class CBattleResultWindow;
|
||||||
friend class CBattleHero;
|
friend class CBattleHero;
|
||||||
friend class CSpellEffectAnimation;
|
friend class CEffectAnimation;
|
||||||
friend class CBattleStackAnimation;
|
friend class CBattleStackAnimation;
|
||||||
friend class CReverseAnimation;
|
friend class CReverseAnimation;
|
||||||
friend class CDefenceAnimation;
|
friend class CDefenceAnimation;
|
||||||
|
@ -138,8 +138,9 @@ void CCreatureAnimation::setType(CCreatureAnim::EAnimType type)
|
|||||||
play();
|
play();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCreatureAnimation::CCreatureAnimation(std::string name, TSpeedController controller)
|
CCreatureAnimation::CCreatureAnimation(const std::string & name_, TSpeedController controller)
|
||||||
: speed(0.1),
|
: name(name_),
|
||||||
|
speed(0.1),
|
||||||
currentFrame(0),
|
currentFrame(0),
|
||||||
elapsedTime(0),
|
elapsedTime(0),
|
||||||
type(CCreatureAnim::HOLDING),
|
type(CCreatureAnim::HOLDING),
|
||||||
@ -147,8 +148,8 @@ CCreatureAnimation::CCreatureAnimation(std::string name, TSpeedController contro
|
|||||||
speedController(controller),
|
speedController(controller),
|
||||||
once(false)
|
once(false)
|
||||||
{
|
{
|
||||||
forward = std::make_shared<CAnimation>(name);
|
forward = std::make_shared<CAnimation>(name_);
|
||||||
reverse = std::make_shared<CAnimation>(name);
|
reverse = std::make_shared<CAnimation>(name_);
|
||||||
|
|
||||||
//todo: optimize
|
//todo: optimize
|
||||||
forward->preload();
|
forward->preload();
|
||||||
@ -269,8 +270,6 @@ void CCreatureAnimation::genBorderPalette(IImage::BorderPallete & target)
|
|||||||
target[2] = addColors(genShadow(64), genBorderColor(getBorderStrength(elapsedTime), border));
|
target[2] = addColors(genShadow(64), genBorderColor(getBorderStrength(elapsedTime), border));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CCreatureAnimation::nextFrame(SDL_Surface *dest, bool attacker)
|
void CCreatureAnimation::nextFrame(SDL_Surface *dest, bool attacker)
|
||||||
{
|
{
|
||||||
size_t frame = floor(currentFrame);
|
size_t frame = floor(currentFrame);
|
||||||
@ -288,7 +287,6 @@ void CCreatureAnimation::nextFrame(SDL_Surface *dest, bool attacker)
|
|||||||
image->setBorderPallete(borderPallete);
|
image->setBorderPallete(borderPallete);
|
||||||
|
|
||||||
image->draw(dest, pos.x, pos.y);
|
image->draw(dest, pos.x, pos.y);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CCreatureAnimation::framesInGroup(CCreatureAnim::EAnimType group) const
|
int CCreatureAnimation::framesInGroup(CCreatureAnim::EAnimType group) const
|
||||||
@ -329,6 +327,7 @@ void CCreatureAnimation::pause()
|
|||||||
|
|
||||||
void CCreatureAnimation::play()
|
void CCreatureAnimation::play()
|
||||||
{
|
{
|
||||||
|
logAnim->trace("Play %s group %d at %d:%d", name, static_cast<int>(getType()), pos.x, pos.y);
|
||||||
speed = 0;
|
speed = 0;
|
||||||
if (speedController(this, type) != 0)
|
if (speedController(this, type) != 0)
|
||||||
speed = 1 / speedController(this, type);
|
speed = 1 / speedController(this, type);
|
||||||
|
@ -52,6 +52,7 @@ public:
|
|||||||
typedef std::function<float(CCreatureAnimation *, size_t)> TSpeedController;
|
typedef std::function<float(CCreatureAnimation *, size_t)> TSpeedController;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string name;
|
||||||
std::shared_ptr<CAnimation> forward;
|
std::shared_ptr<CAnimation> forward;
|
||||||
std::shared_ptr<CAnimation> reverse;
|
std::shared_ptr<CAnimation> reverse;
|
||||||
|
|
||||||
@ -92,7 +93,7 @@ public:
|
|||||||
/// name - path to .def file, relative to SPRITES/ directory
|
/// name - path to .def file, relative to SPRITES/ directory
|
||||||
/// controller - function that will return for how long *each* frame
|
/// controller - function that will return for how long *each* frame
|
||||||
/// in specified group of animation should be played, measured in seconds
|
/// in specified group of animation should be played, measured in seconds
|
||||||
CCreatureAnimation(std::string name, TSpeedController speedController);
|
CCreatureAnimation(const std::string & name_, TSpeedController speedController);
|
||||||
|
|
||||||
void setType(CCreatureAnim::EAnimType type); //sets type of animation and cleares framecount
|
void setType(CCreatureAnim::EAnimType type); //sets type of animation and cleares framecount
|
||||||
CCreatureAnim::EAnimType getType() const; //returns type of animation
|
CCreatureAnim::EAnimType getType() const; //returns type of animation
|
||||||
|
@ -37,7 +37,6 @@ class CGObjectInstance;
|
|||||||
class CCreature;
|
class CCreature;
|
||||||
class CMap;
|
class CMap;
|
||||||
struct StartInfo;
|
struct StartInfo;
|
||||||
struct SDL_Surface;
|
|
||||||
class CMapHandler;
|
class CMapHandler;
|
||||||
struct SetObjectProperty;
|
struct SetObjectProperty;
|
||||||
struct MetaString;
|
struct MetaString;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user