mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Renamed most of classes in client/battle directory to match current code
style
This commit is contained in:
parent
a06d7ec80e
commit
3f9a0a855e
@ -93,7 +93,7 @@ boost::recursive_mutex * CPlayerInterface::pim = new boost::recursive_mutex;
|
||||
|
||||
CPlayerInterface * LOCPLINT;
|
||||
|
||||
CBattleInterface * CPlayerInterface::battleInt;
|
||||
BattleInterface * CPlayerInterface::battleInt;
|
||||
|
||||
enum EMoveState {STOP_MOVE, WAITING_MOVE, CONTINUE_MOVE, DURING_MOVE};
|
||||
CondSh<EMoveState> stillMoveHero(STOP_MOVE); //used during hero movement
|
||||
@ -838,17 +838,17 @@ BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when i
|
||||
autofightingAI.reset();
|
||||
}
|
||||
|
||||
CBattleInterface *b = battleInt;
|
||||
BattleInterface *b = battleInt;
|
||||
|
||||
if(!b)
|
||||
{
|
||||
return BattleAction::makeDefend(stack); // probably battle is finished already
|
||||
}
|
||||
|
||||
if(CBattleInterface::givenCommand.get())
|
||||
if(BattleInterface::givenCommand.get())
|
||||
{
|
||||
logGlobal->error("Command buffer must be clean! (we don't want to use old command)");
|
||||
vstd::clear_pointer(CBattleInterface::givenCommand.data);
|
||||
vstd::clear_pointer(BattleInterface::givenCommand.data);
|
||||
}
|
||||
|
||||
{
|
||||
@ -857,17 +857,17 @@ BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when i
|
||||
//Regeneration & mana drain go there
|
||||
}
|
||||
//wait till BattleInterface sets its command
|
||||
boost::unique_lock<boost::mutex> lock(CBattleInterface::givenCommand.mx);
|
||||
while(!CBattleInterface::givenCommand.data)
|
||||
boost::unique_lock<boost::mutex> lock(BattleInterface::givenCommand.mx);
|
||||
while(!BattleInterface::givenCommand.data)
|
||||
{
|
||||
CBattleInterface::givenCommand.cond.wait(lock);
|
||||
BattleInterface::givenCommand.cond.wait(lock);
|
||||
if (!battleInt) //battle ended while we were waiting for movement (eg. because of spell)
|
||||
throw boost::thread_interrupted(); //will shut the thread peacefully
|
||||
}
|
||||
|
||||
//tidy up
|
||||
BattleAction ret = *(CBattleInterface::givenCommand.data);
|
||||
vstd::clear_pointer(CBattleInterface::givenCommand.data);
|
||||
BattleAction ret = *(BattleInterface::givenCommand.data);
|
||||
vstd::clear_pointer(BattleInterface::givenCommand.data);
|
||||
|
||||
if(ret.actionType == EActionType::CANCEL)
|
||||
{
|
||||
@ -892,7 +892,7 @@ void CPlayerInterface::battleEnd(const BattleResult *br)
|
||||
|
||||
if(!battleInt)
|
||||
{
|
||||
GH.pushIntT<CBattleResultWindow>(*br, *this);
|
||||
GH.pushIntT<BattleResultWindow>(*br, *this);
|
||||
// #1490 - during AI turn when quick combat is on, we need to display the message and wait for user to close it.
|
||||
// Otherwise NewTurn causes freeze.
|
||||
waitWhileDialog();
|
||||
|
@ -40,7 +40,7 @@ class CButton;
|
||||
class CToggleGroup;
|
||||
class CAdvMapInt;
|
||||
class CCastleInterface;
|
||||
class CBattleInterface;
|
||||
class BattleInterface;
|
||||
class CComponent;
|
||||
class CSelectableComponent;
|
||||
class CSlider;
|
||||
@ -84,7 +84,7 @@ public:
|
||||
static const int SAVES_COUNT = 5;
|
||||
|
||||
CCastleInterface * castleInt; //nullptr if castle window isn't opened
|
||||
static CBattleInterface * battleInt; //nullptr if no battle
|
||||
static BattleInterface * battleInt; //nullptr if no battle
|
||||
CInGameConsole * cingconsole;
|
||||
|
||||
std::shared_ptr<CCallback> cb; //to communicate with engine
|
||||
|
@ -598,7 +598,7 @@ void CClient::battleStarted(const BattleInfo * info)
|
||||
if(!!att || !!def)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim);
|
||||
GH.pushIntT<CBattleInterface>(leftSide.armyObject, rightSide.armyObject, leftSide.hero, rightSide.hero, battleIntRect, att, def);
|
||||
GH.pushIntT<BattleInterface>(leftSide.armyObject, rightSide.armyObject, leftSide.hero, rightSide.hero, battleIntRect, att, def);
|
||||
}
|
||||
else if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-skip-battle"].Bool())
|
||||
{
|
||||
@ -606,7 +606,7 @@ void CClient::battleStarted(const BattleInfo * info)
|
||||
auto spectratorInt = std::dynamic_pointer_cast<CPlayerInterface>(playerint[PlayerColor::SPECTATOR]);
|
||||
spectratorInt->cb->setBattle(info);
|
||||
boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim);
|
||||
GH.pushIntT<CBattleInterface>(leftSide.armyObject, rightSide.armyObject, leftSide.hero, rightSide.hero, battleIntRect, att, def, spectratorInt);
|
||||
GH.pushIntT<BattleInterface>(leftSide.armyObject, rightSide.armyObject, leftSide.hero, rightSide.hero, battleIntRect, att, def, spectratorInt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ static std::string formatDmgRange(std::pair<ui32, ui32> dmgRange)
|
||||
}
|
||||
|
||||
|
||||
CBattleActionsController::CBattleActionsController(CBattleInterface * owner):
|
||||
BattleActionsController::BattleActionsController(BattleInterface * owner):
|
||||
owner(owner),
|
||||
creatureCasting(false),
|
||||
spellDestSelectMode(false),
|
||||
@ -52,7 +52,7 @@ CBattleActionsController::CBattleActionsController(CBattleInterface * owner):
|
||||
selectedAction = PossiblePlayerBattleAction::INVALID;
|
||||
}
|
||||
|
||||
void CBattleActionsController::endCastingSpell()
|
||||
void BattleActionsController::endCastingSpell()
|
||||
{
|
||||
if(spellDestSelectMode)
|
||||
{
|
||||
@ -78,7 +78,7 @@ void CBattleActionsController::endCastingSpell()
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleActionsController::enterCreatureCastingMode()
|
||||
void BattleActionsController::enterCreatureCastingMode()
|
||||
{
|
||||
//silently check for possible errors
|
||||
if (!owner->myTurn)
|
||||
@ -141,7 +141,7 @@ void CBattleActionsController::enterCreatureCastingMode()
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<PossiblePlayerBattleAction> CBattleActionsController::getPossibleActionsForStack(const CStack *stack)
|
||||
std::vector<PossiblePlayerBattleAction> BattleActionsController::getPossibleActionsForStack(const CStack *stack)
|
||||
{
|
||||
BattleClientInterfaceData data; //hard to get rid of these things so for now they're required data to pass
|
||||
data.creatureSpellToCast = owner->stacksController->activeStackSpellToCast();
|
||||
@ -151,7 +151,7 @@ std::vector<PossiblePlayerBattleAction> CBattleActionsController::getPossibleAct
|
||||
return std::vector<PossiblePlayerBattleAction>(allActions);
|
||||
}
|
||||
|
||||
void CBattleActionsController::reorderPossibleActionsPriority(const CStack * stack, MouseHoveredHexContext context)
|
||||
void BattleActionsController::reorderPossibleActionsPriority(const CStack * stack, MouseHoveredHexContext context)
|
||||
{
|
||||
if(owner->tacticsMode || possibleActions.empty()) return; //this function is not supposed to be called in tactics mode or before getPossibleActionsForStack
|
||||
|
||||
@ -200,7 +200,7 @@ void CBattleActionsController::reorderPossibleActionsPriority(const CStack * sta
|
||||
std::make_heap(possibleActions.begin(), possibleActions.end(), comparer);
|
||||
}
|
||||
|
||||
void CBattleActionsController::castThisSpell(SpellID spellID)
|
||||
void BattleActionsController::castThisSpell(SpellID spellID)
|
||||
{
|
||||
spellToCast = std::make_shared<BattleAction>();
|
||||
spellToCast->actionType = EActionType::HERO_SPELL;
|
||||
@ -231,7 +231,7 @@ void CBattleActionsController::castThisSpell(SpellID spellID)
|
||||
}
|
||||
|
||||
|
||||
void CBattleActionsController::handleHex(BattleHex myNumber, int eventType)
|
||||
void BattleActionsController::handleHex(BattleHex myNumber, int eventType)
|
||||
{
|
||||
if (!owner->myTurn || !owner->battleActionsStarted) //we are not permit to do anything
|
||||
return;
|
||||
@ -690,7 +690,7 @@ void CBattleActionsController::handleHex(BattleHex myNumber, int eventType)
|
||||
}
|
||||
|
||||
|
||||
bool CBattleActionsController::isCastingPossibleHere(const CStack *sactive, const CStack *shere, BattleHex myNumber)
|
||||
bool BattleActionsController::isCastingPossibleHere(const CStack *sactive, const CStack *shere, BattleHex myNumber)
|
||||
{
|
||||
creatureCasting = owner->stacksController->activeStackSpellcaster() && !spellDestSelectMode; //TODO: allow creatures to cast aimed spells
|
||||
|
||||
@ -742,7 +742,7 @@ bool CBattleActionsController::isCastingPossibleHere(const CStack *sactive, cons
|
||||
return isCastingPossible;
|
||||
}
|
||||
|
||||
bool CBattleActionsController::canStackMoveHere(const CStack * stackToMove, BattleHex myNumber)
|
||||
bool BattleActionsController::canStackMoveHere(const CStack * stackToMove, BattleHex myNumber)
|
||||
{
|
||||
std::vector<BattleHex> acc = owner->curInt->cb->battleGetAvailableHexes(stackToMove);
|
||||
BattleHex shiftedDest = myNumber.cloneInDirection(stackToMove->destShiftDir(), false);
|
||||
@ -755,19 +755,19 @@ bool CBattleActionsController::canStackMoveHere(const CStack * stackToMove, Batt
|
||||
return false;
|
||||
}
|
||||
|
||||
void CBattleActionsController::activateStack()
|
||||
void BattleActionsController::activateStack()
|
||||
{
|
||||
const CStack * s = owner->stacksController->getActiveStack();
|
||||
if(s)
|
||||
possibleActions = getPossibleActionsForStack(s);
|
||||
}
|
||||
|
||||
bool CBattleActionsController::spellcastingModeActive()
|
||||
bool BattleActionsController::spellcastingModeActive()
|
||||
{
|
||||
return spellDestSelectMode;
|
||||
}
|
||||
|
||||
SpellID CBattleActionsController::selectedSpell()
|
||||
SpellID BattleActionsController::selectedSpell()
|
||||
{
|
||||
if (!spellToCast)
|
||||
return SpellID::NONE;
|
||||
|
@ -17,7 +17,7 @@ class BattleAction;
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
class CBattleInterface;
|
||||
class BattleInterface;
|
||||
|
||||
enum class MouseHoveredHexContext
|
||||
{
|
||||
@ -25,9 +25,9 @@ enum class MouseHoveredHexContext
|
||||
OCCUPIED_HEX
|
||||
};
|
||||
|
||||
class CBattleActionsController
|
||||
class BattleActionsController
|
||||
{
|
||||
CBattleInterface * owner;
|
||||
BattleInterface * owner;
|
||||
|
||||
std::vector<PossiblePlayerBattleAction> possibleActions; //all actions possible to call at the moment by player
|
||||
std::vector<PossiblePlayerBattleAction> localActions; //actions possible to take on hovered hex
|
||||
@ -49,7 +49,7 @@ class CBattleActionsController
|
||||
|
||||
std::string currentConsoleMsg;
|
||||
public:
|
||||
CBattleActionsController(CBattleInterface * owner);
|
||||
BattleActionsController(BattleInterface * owner);
|
||||
|
||||
void activateStack();
|
||||
void endCastingSpell(); //ends casting spell (eg. when spell has been cast or canceled)
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "../../lib/CTownHandler.h"
|
||||
#include "../../lib/mapObjects/CGTownInstance.h"
|
||||
|
||||
CBattleAnimation::CBattleAnimation(CBattleInterface * _owner)
|
||||
CBattleAnimation::CBattleAnimation(BattleInterface * _owner)
|
||||
: owner(_owner),
|
||||
ID(_owner->stacksController->animIDhelper++),
|
||||
initialized(false)
|
||||
@ -75,7 +75,7 @@ std::vector<CBattleAnimation *> & CBattleAnimation::pendingAnimations()
|
||||
return owner->stacksController->currentAnimations;
|
||||
}
|
||||
|
||||
std::shared_ptr<CCreatureAnimation> CBattleAnimation::stackAnimation(const CStack * stack) const
|
||||
std::shared_ptr<CreatureAnimation> CBattleAnimation::stackAnimation(const CStack * stack) const
|
||||
{
|
||||
return owner->stacksController->stackAnimation[stack->ID];
|
||||
}
|
||||
@ -116,7 +116,7 @@ bool CBattleAnimation::checkInitialConditions()
|
||||
return ID == lowestMoveID;
|
||||
}
|
||||
|
||||
CBattleStackAnimation::CBattleStackAnimation(CBattleInterface * owner, const CStack * stack)
|
||||
CBattleStackAnimation::CBattleStackAnimation(BattleInterface * owner, const CStack * stack)
|
||||
: CBattleAnimation(owner),
|
||||
myAnim(stackAnimation(stack)),
|
||||
stack(stack)
|
||||
@ -177,7 +177,7 @@ const CCreature * CAttackAnimation::getCreature() const
|
||||
return attackingStack->getCreature();
|
||||
}
|
||||
|
||||
CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, BattleHex _dest, const CStack *defender)
|
||||
CAttackAnimation::CAttackAnimation(BattleInterface *_owner, const CStack *attacker, BattleHex _dest, const CStack *defender)
|
||||
: CBattleStackAnimation(_owner, attacker),
|
||||
shooting(false),
|
||||
group(CCreatureAnim::SHOOT_FRONT),
|
||||
@ -190,7 +190,7 @@ CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attac
|
||||
attackingStackPosBeforeReturn = attackingStack->getPosition();
|
||||
}
|
||||
|
||||
CDefenceAnimation::CDefenceAnimation(StackAttackedInfo _attackedInfo, CBattleInterface * _owner)
|
||||
CDefenceAnimation::CDefenceAnimation(StackAttackedInfo _attackedInfo, BattleInterface * _owner)
|
||||
: CBattleStackAnimation(_owner, _attackedInfo.defender),
|
||||
attacker(_attackedInfo.attacker),
|
||||
rangedAttack(_attackedInfo.indirectAttack),
|
||||
@ -327,7 +327,7 @@ CDefenceAnimation::~CDefenceAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
CDummyAnimation::CDummyAnimation(CBattleInterface * _owner, int howManyFrames)
|
||||
CDummyAnimation::CDummyAnimation(BattleInterface * _owner, int howManyFrames)
|
||||
: CBattleAnimation(_owner),
|
||||
counter(0),
|
||||
howMany(howManyFrames)
|
||||
@ -438,13 +438,13 @@ bool CMeleeAttackAnimation::init()
|
||||
return true;
|
||||
}
|
||||
|
||||
CMeleeAttackAnimation::CMeleeAttackAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked)
|
||||
CMeleeAttackAnimation::CMeleeAttackAnimation(BattleInterface * _owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked)
|
||||
: CAttackAnimation(_owner, attacker, _dest, _attacked)
|
||||
{
|
||||
logAnim->debug("Created melee attack anim for %s", attacker->getName());
|
||||
}
|
||||
|
||||
CStackMoveAnimation::CStackMoveAnimation(CBattleInterface * _owner, const CStack * _stack, BattleHex _currentHex):
|
||||
CStackMoveAnimation::CStackMoveAnimation(BattleInterface * _owner, const CStack * _stack, BattleHex _currentHex):
|
||||
CBattleStackAnimation(_owner, _stack),
|
||||
currentHex(_currentHex)
|
||||
{
|
||||
@ -563,7 +563,7 @@ CMovementAnimation::~CMovementAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
CMovementAnimation::CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector<BattleHex> _destTiles, int _distance)
|
||||
CMovementAnimation::CMovementAnimation(BattleInterface *_owner, const CStack *_stack, std::vector<BattleHex> _destTiles, int _distance)
|
||||
: CStackMoveAnimation(_owner, _stack, _destTiles.front()),
|
||||
destTiles(_destTiles),
|
||||
curentMoveIndex(0),
|
||||
@ -576,7 +576,7 @@ CMovementAnimation::CMovementAnimation(CBattleInterface *_owner, const CStack *_
|
||||
logAnim->debug("Created movement anim for %s", stack->getName());
|
||||
}
|
||||
|
||||
CMovementEndAnimation::CMovementEndAnimation(CBattleInterface * _owner, const CStack * _stack, BattleHex destTile)
|
||||
CMovementEndAnimation::CMovementEndAnimation(BattleInterface * _owner, const CStack * _stack, BattleHex destTile)
|
||||
: CStackMoveAnimation(_owner, _stack, destTile)
|
||||
{
|
||||
logAnim->debug("Created movement end anim for %s", stack->getName());
|
||||
@ -611,7 +611,7 @@ CMovementEndAnimation::~CMovementEndAnimation()
|
||||
CCS->curh->show();
|
||||
}
|
||||
|
||||
CMovementStartAnimation::CMovementStartAnimation(CBattleInterface * _owner, const CStack * _stack)
|
||||
CMovementStartAnimation::CMovementStartAnimation(BattleInterface * _owner, const CStack * _stack)
|
||||
: CStackMoveAnimation(_owner, _stack, _stack->getPosition())
|
||||
{
|
||||
logAnim->debug("Created movement start anim for %s", stack->getName());
|
||||
@ -636,7 +636,7 @@ bool CMovementStartAnimation::init()
|
||||
return true;
|
||||
}
|
||||
|
||||
CReverseAnimation::CReverseAnimation(CBattleInterface * _owner, const CStack * stack, BattleHex dest, bool _priority)
|
||||
CReverseAnimation::CReverseAnimation(BattleInterface * _owner, const CStack * stack, BattleHex dest, bool _priority)
|
||||
: CStackMoveAnimation(_owner, stack, dest),
|
||||
priority(_priority)
|
||||
{
|
||||
@ -698,7 +698,7 @@ void CReverseAnimation::setupSecondPart()
|
||||
delete this;
|
||||
}
|
||||
|
||||
CRangedAttackAnimation::CRangedAttackAnimation(CBattleInterface * owner_, const CStack * attacker, BattleHex dest_, const CStack * defender)
|
||||
CRangedAttackAnimation::CRangedAttackAnimation(BattleInterface * owner_, const CStack * attacker, BattleHex dest_, const CStack * defender)
|
||||
: CAttackAnimation(owner_, attacker, dest_, defender),
|
||||
projectileEmitted(false)
|
||||
{
|
||||
@ -847,7 +847,7 @@ CRangedAttackAnimation::~CRangedAttackAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
CShootingAnimation::CShootingAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked)
|
||||
CShootingAnimation::CShootingAnimation(BattleInterface * _owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked)
|
||||
: CRangedAttackAnimation(_owner, attacker, _dest, _attacked)
|
||||
{
|
||||
logAnim->debug("Created shooting anim for %s", stack->getName());
|
||||
@ -879,7 +879,7 @@ CCreatureAnim::EAnimType CShootingAnimation::getDownwardsGroup() const
|
||||
return CCreatureAnim::SHOOT_DOWN;
|
||||
}
|
||||
|
||||
CCatapultAnimation::CCatapultAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked, int _catapultDmg)
|
||||
CCatapultAnimation::CCatapultAnimation(BattleInterface * _owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked, int _catapultDmg)
|
||||
: CShootingAnimation(_owner, attacker, _dest, _attacked),
|
||||
catapultDamage(_catapultDmg),
|
||||
explosionEmitted(false)
|
||||
@ -915,7 +915,7 @@ void CCatapultAnimation::createProjectile(const Point & from, const Point & dest
|
||||
}
|
||||
|
||||
|
||||
CCastAnimation::CCastAnimation(CBattleInterface * owner_, const CStack * attacker, BattleHex dest_, const CStack * defender, const CSpell * spell)
|
||||
CCastAnimation::CCastAnimation(BattleInterface * owner_, const CStack * attacker, BattleHex dest_, const CStack * defender, const CSpell * spell)
|
||||
: CRangedAttackAnimation(owner_, attacker, dest_, defender),
|
||||
spell(spell)
|
||||
{
|
||||
@ -983,7 +983,7 @@ uint32_t CCastAnimation::getAttackClimaxFrame() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
CPointEffectAnimation::CPointEffectAnimation(CBattleInterface * _owner, soundBase::soundID sound, std::string animationName, int effects):
|
||||
CPointEffectAnimation::CPointEffectAnimation(BattleInterface * _owner, soundBase::soundID sound, std::string animationName, int effects):
|
||||
CBattleAnimation(_owner),
|
||||
animation(std::make_shared<CAnimation>(animationName)),
|
||||
sound(sound),
|
||||
@ -994,32 +994,32 @@ CPointEffectAnimation::CPointEffectAnimation(CBattleInterface * _owner, soundBas
|
||||
{
|
||||
}
|
||||
|
||||
CPointEffectAnimation::CPointEffectAnimation(CBattleInterface * _owner, soundBase::soundID sound, std::string animationName, std::vector<BattleHex> hex, int effects):
|
||||
CPointEffectAnimation::CPointEffectAnimation(BattleInterface * _owner, soundBase::soundID sound, std::string animationName, std::vector<BattleHex> hex, int effects):
|
||||
CPointEffectAnimation(_owner, sound, animationName, effects)
|
||||
{
|
||||
battlehexes = hex;
|
||||
}
|
||||
|
||||
CPointEffectAnimation::CPointEffectAnimation(CBattleInterface * _owner, soundBase::soundID sound, std::string animationName, BattleHex hex, int effects):
|
||||
CPointEffectAnimation::CPointEffectAnimation(BattleInterface * _owner, soundBase::soundID sound, std::string animationName, BattleHex hex, int effects):
|
||||
CPointEffectAnimation(_owner, sound, animationName, effects)
|
||||
{
|
||||
assert(hex.isValid());
|
||||
battlehexes.push_back(hex);
|
||||
}
|
||||
|
||||
CPointEffectAnimation::CPointEffectAnimation(CBattleInterface * _owner, soundBase::soundID sound, std::string animationName, std::vector<Point> pos, int effects):
|
||||
CPointEffectAnimation::CPointEffectAnimation(BattleInterface * _owner, soundBase::soundID sound, std::string animationName, std::vector<Point> pos, int effects):
|
||||
CPointEffectAnimation(_owner, sound, animationName, effects)
|
||||
{
|
||||
positions = pos;
|
||||
}
|
||||
|
||||
CPointEffectAnimation::CPointEffectAnimation(CBattleInterface * _owner, soundBase::soundID sound, std::string animationName, Point pos, int effects):
|
||||
CPointEffectAnimation::CPointEffectAnimation(BattleInterface * _owner, soundBase::soundID sound, std::string animationName, Point pos, int effects):
|
||||
CPointEffectAnimation(_owner, sound, animationName, effects)
|
||||
{
|
||||
positions.push_back(pos);
|
||||
}
|
||||
|
||||
CPointEffectAnimation::CPointEffectAnimation(CBattleInterface * _owner, soundBase::soundID sound, std::string animationName, Point pos, BattleHex hex, int effects):
|
||||
CPointEffectAnimation::CPointEffectAnimation(BattleInterface * _owner, soundBase::soundID sound, std::string animationName, Point pos, BattleHex hex, int effects):
|
||||
CPointEffectAnimation(_owner, sound, animationName, effects)
|
||||
{
|
||||
assert(hex.isValid());
|
||||
@ -1191,7 +1191,7 @@ CPointEffectAnimation::~CPointEffectAnimation()
|
||||
assert(soundFinished);
|
||||
}
|
||||
|
||||
CWaitingAnimation::CWaitingAnimation(CBattleInterface * owner_):
|
||||
CWaitingAnimation::CWaitingAnimation(BattleInterface * owner_):
|
||||
CBattleAnimation(owner_)
|
||||
{}
|
||||
|
||||
@ -1201,7 +1201,7 @@ void CWaitingAnimation::nextFrame()
|
||||
delete this;
|
||||
}
|
||||
|
||||
CWaitingProjectileAnimation::CWaitingProjectileAnimation(CBattleInterface * owner_, const CStack * shooter):
|
||||
CWaitingProjectileAnimation::CWaitingProjectileAnimation(BattleInterface * owner_, const CStack * shooter):
|
||||
CWaitingAnimation(owner_),
|
||||
shooter(shooter)
|
||||
{}
|
||||
|
@ -19,8 +19,8 @@ class CStack;
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
class CBattleInterface;
|
||||
class CCreatureAnimation;
|
||||
class BattleInterface;
|
||||
class CreatureAnimation;
|
||||
class CBattleAnimation;
|
||||
struct CatapultProjectileInfo;
|
||||
struct StackAttackedInfo;
|
||||
@ -30,11 +30,11 @@ class CBattleAnimation
|
||||
{
|
||||
|
||||
protected:
|
||||
CBattleInterface * owner;
|
||||
BattleInterface * owner;
|
||||
bool initialized;
|
||||
|
||||
std::vector<CBattleAnimation *> & pendingAnimations();
|
||||
std::shared_ptr<CCreatureAnimation> stackAnimation(const CStack * stack) const;
|
||||
std::shared_ptr<CreatureAnimation> stackAnimation(const CStack * stack) const;
|
||||
bool stackFacingRight(const CStack * stack);
|
||||
void setStackFacingRight(const CStack * stack, bool facingRight);
|
||||
|
||||
@ -49,17 +49,17 @@ public:
|
||||
virtual void nextFrame() {} //call every new frame
|
||||
virtual ~CBattleAnimation();
|
||||
|
||||
CBattleAnimation(CBattleInterface * _owner);
|
||||
CBattleAnimation(BattleInterface * _owner);
|
||||
};
|
||||
|
||||
/// Sub-class which is responsible for managing the battle stack animation.
|
||||
class CBattleStackAnimation : public CBattleAnimation
|
||||
{
|
||||
public:
|
||||
std::shared_ptr<CCreatureAnimation> myAnim; //animation for our stack, managed by CBattleInterface
|
||||
std::shared_ptr<CreatureAnimation> myAnim; //animation for our stack, managed by CBattleInterface
|
||||
const CStack * stack; //id of stack whose animation it is
|
||||
|
||||
CBattleStackAnimation(CBattleInterface * _owner, const CStack * _stack);
|
||||
CBattleStackAnimation(BattleInterface * _owner, const CStack * _stack);
|
||||
|
||||
void shiftColor(const ColorShifter * shifter);
|
||||
void rotateStack(BattleHex hex);
|
||||
@ -83,7 +83,7 @@ public:
|
||||
void nextFrame() override;
|
||||
bool checkInitialConditions();
|
||||
|
||||
CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, BattleHex _dest, const CStack *defender);
|
||||
CAttackAnimation(BattleInterface *_owner, const CStack *attacker, BattleHex _dest, const CStack *defender);
|
||||
~CAttackAnimation();
|
||||
};
|
||||
|
||||
@ -104,7 +104,7 @@ public:
|
||||
bool init() override;
|
||||
void nextFrame() override;
|
||||
|
||||
CDefenceAnimation(StackAttackedInfo _attackedInfo, CBattleInterface * _owner);
|
||||
CDefenceAnimation(StackAttackedInfo _attackedInfo, BattleInterface * _owner);
|
||||
~CDefenceAnimation();
|
||||
};
|
||||
|
||||
@ -117,7 +117,7 @@ public:
|
||||
bool init() override;
|
||||
void nextFrame() override;
|
||||
|
||||
CDummyAnimation(CBattleInterface * _owner, int howManyFrames);
|
||||
CDummyAnimation(BattleInterface * _owner, int howManyFrames);
|
||||
};
|
||||
|
||||
/// Hand-to-hand attack
|
||||
@ -126,7 +126,7 @@ class CMeleeAttackAnimation : public CAttackAnimation
|
||||
public:
|
||||
bool init() override;
|
||||
|
||||
CMeleeAttackAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked);
|
||||
CMeleeAttackAnimation(BattleInterface * _owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked);
|
||||
};
|
||||
|
||||
/// Base class for all animations that play during stack movement
|
||||
@ -136,7 +136,7 @@ public:
|
||||
BattleHex currentHex;
|
||||
|
||||
protected:
|
||||
CStackMoveAnimation(CBattleInterface * _owner, const CStack * _stack, BattleHex _currentHex);
|
||||
CStackMoveAnimation(BattleInterface * _owner, const CStack * _stack, BattleHex _currentHex);
|
||||
};
|
||||
|
||||
/// Move animation of a creature
|
||||
@ -158,7 +158,7 @@ public:
|
||||
bool init() override;
|
||||
void nextFrame() override;
|
||||
|
||||
CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector<BattleHex> _destTiles, int _distance);
|
||||
CMovementAnimation(BattleInterface *_owner, const CStack *_stack, std::vector<BattleHex> _destTiles, int _distance);
|
||||
~CMovementAnimation();
|
||||
};
|
||||
|
||||
@ -168,7 +168,7 @@ class CMovementEndAnimation : public CStackMoveAnimation
|
||||
public:
|
||||
bool init() override;
|
||||
|
||||
CMovementEndAnimation(CBattleInterface * _owner, const CStack * _stack, BattleHex destTile);
|
||||
CMovementEndAnimation(BattleInterface * _owner, const CStack * _stack, BattleHex destTile);
|
||||
~CMovementEndAnimation();
|
||||
};
|
||||
|
||||
@ -178,7 +178,7 @@ class CMovementStartAnimation : public CStackMoveAnimation
|
||||
public:
|
||||
bool init() override;
|
||||
|
||||
CMovementStartAnimation(CBattleInterface * _owner, const CStack * _stack);
|
||||
CMovementStartAnimation(BattleInterface * _owner, const CStack * _stack);
|
||||
};
|
||||
|
||||
/// Class responsible for animation of stack chaning direction (left <-> right)
|
||||
@ -190,7 +190,7 @@ public:
|
||||
|
||||
void setupSecondPart();
|
||||
|
||||
CReverseAnimation(CBattleInterface * _owner, const CStack * stack, BattleHex dest, bool _priority);
|
||||
CReverseAnimation(BattleInterface * _owner, const CStack * stack, BattleHex dest, bool _priority);
|
||||
~CReverseAnimation();
|
||||
};
|
||||
|
||||
@ -213,7 +213,7 @@ protected:
|
||||
virtual uint32_t getAttackClimaxFrame() const = 0;
|
||||
|
||||
public:
|
||||
CRangedAttackAnimation(CBattleInterface * owner_, const CStack * attacker, BattleHex dest, const CStack * defender);
|
||||
CRangedAttackAnimation(BattleInterface * owner_, const CStack * attacker, BattleHex dest, const CStack * defender);
|
||||
~CRangedAttackAnimation();
|
||||
|
||||
bool init() override;
|
||||
@ -231,7 +231,7 @@ class CShootingAnimation : public CRangedAttackAnimation
|
||||
uint32_t getAttackClimaxFrame() const override;
|
||||
|
||||
public:
|
||||
CShootingAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex dest, const CStack * defender);
|
||||
CShootingAnimation(BattleInterface * _owner, const CStack * attacker, BattleHex dest, const CStack * defender);
|
||||
|
||||
};
|
||||
|
||||
@ -243,7 +243,7 @@ private:
|
||||
int catapultDamage;
|
||||
|
||||
public:
|
||||
CCatapultAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex dest, const CStack * defender, int _catapultDmg = 0);
|
||||
CCatapultAnimation(BattleInterface * _owner, const CStack * attacker, BattleHex dest, const CStack * defender, int _catapultDmg = 0);
|
||||
|
||||
void createProjectile(const Point & from, const Point & dest) const override;
|
||||
void nextFrame() override;
|
||||
@ -262,7 +262,7 @@ class CCastAnimation : public CRangedAttackAnimation
|
||||
uint32_t getAttackClimaxFrame() const override;
|
||||
|
||||
public:
|
||||
CCastAnimation(CBattleInterface * owner_, const CStack * attacker, BattleHex dest_, const CStack * defender, const CSpell * spell);
|
||||
CCastAnimation(BattleInterface * owner_, const CStack * attacker, BattleHex dest_, const CStack * defender, const CSpell * spell);
|
||||
};
|
||||
|
||||
struct CPointEffectParameters
|
||||
@ -313,17 +313,17 @@ public:
|
||||
};
|
||||
|
||||
/// Create animation with screen-wide effect
|
||||
CPointEffectAnimation(CBattleInterface * _owner, soundBase::soundID sound, std::string animationName, int effects = 0);
|
||||
CPointEffectAnimation(BattleInterface * _owner, soundBase::soundID sound, std::string animationName, int effects = 0);
|
||||
|
||||
/// Create animation positioned at point(s). Note that positions must be are absolute, including battleint position offset
|
||||
CPointEffectAnimation(CBattleInterface * _owner, soundBase::soundID sound, std::string animationName, Point pos , int effects = 0);
|
||||
CPointEffectAnimation(CBattleInterface * _owner, soundBase::soundID sound, std::string animationName, std::vector<Point> pos , int effects = 0);
|
||||
CPointEffectAnimation(BattleInterface * _owner, soundBase::soundID sound, std::string animationName, Point pos , int effects = 0);
|
||||
CPointEffectAnimation(BattleInterface * _owner, soundBase::soundID sound, std::string animationName, std::vector<Point> pos , int effects = 0);
|
||||
|
||||
/// Create animation positioned at certain hex(es)
|
||||
CPointEffectAnimation(CBattleInterface * _owner, soundBase::soundID sound, std::string animationName, BattleHex hex , int effects = 0);
|
||||
CPointEffectAnimation(CBattleInterface * _owner, soundBase::soundID sound, std::string animationName, std::vector<BattleHex> hex, int effects = 0);
|
||||
CPointEffectAnimation(BattleInterface * _owner, soundBase::soundID sound, std::string animationName, BattleHex hex , int effects = 0);
|
||||
CPointEffectAnimation(BattleInterface * _owner, soundBase::soundID sound, std::string animationName, std::vector<BattleHex> hex, int effects = 0);
|
||||
|
||||
CPointEffectAnimation(CBattleInterface * _owner, soundBase::soundID sound, std::string animationName, Point pos, BattleHex hex, int effects = 0);
|
||||
CPointEffectAnimation(BattleInterface * _owner, soundBase::soundID sound, std::string animationName, Point pos, BattleHex hex, int effects = 0);
|
||||
~CPointEffectAnimation();
|
||||
|
||||
bool init() override;
|
||||
@ -334,7 +334,7 @@ public:
|
||||
class CWaitingAnimation : public CBattleAnimation
|
||||
{
|
||||
protected:
|
||||
CWaitingAnimation(CBattleInterface * owner_);
|
||||
CWaitingAnimation(BattleInterface * owner_);
|
||||
public:
|
||||
void nextFrame() override;
|
||||
};
|
||||
@ -344,7 +344,7 @@ class CWaitingProjectileAnimation : public CWaitingAnimation
|
||||
{
|
||||
const CStack * shooter;
|
||||
public:
|
||||
CWaitingProjectileAnimation(CBattleInterface * owner_, const CStack * shooter);
|
||||
CWaitingProjectileAnimation(BattleInterface * owner_, const CStack * shooter);
|
||||
|
||||
bool init() override;
|
||||
};
|
||||
|
@ -29,28 +29,28 @@
|
||||
#include "../../lib/CStack.h"
|
||||
#include "../../lib/CConfigHandler.h"
|
||||
|
||||
CBattleControlPanel::CBattleControlPanel(CBattleInterface * owner, const Point & position):
|
||||
BattleControlPanel::BattleControlPanel(BattleInterface * owner, const Point & position):
|
||||
owner(owner)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||
pos += position;
|
||||
|
||||
//preparing buttons and console
|
||||
bOptions = std::make_shared<CButton> (Point( 3, 5), "icm003.def", CGI->generaltexth->zelp[381], std::bind(&CBattleControlPanel::bOptionsf,this), SDLK_o);
|
||||
bSurrender = std::make_shared<CButton> (Point( 54, 5), "icm001.def", CGI->generaltexth->zelp[379], std::bind(&CBattleControlPanel::bSurrenderf,this), SDLK_s);
|
||||
bFlee = std::make_shared<CButton> (Point(105, 5), "icm002.def", CGI->generaltexth->zelp[380], std::bind(&CBattleControlPanel::bFleef,this), SDLK_r);
|
||||
bAutofight = std::make_shared<CButton> (Point(157, 5), "icm004.def", CGI->generaltexth->zelp[382], std::bind(&CBattleControlPanel::bAutofightf,this), SDLK_a);
|
||||
bSpell = std::make_shared<CButton> (Point(645, 5), "icm005.def", CGI->generaltexth->zelp[385], std::bind(&CBattleControlPanel::bSpellf,this), SDLK_c);
|
||||
bWait = std::make_shared<CButton> (Point(696, 5), "icm006.def", CGI->generaltexth->zelp[386], std::bind(&CBattleControlPanel::bWaitf,this), SDLK_w);
|
||||
bDefence = std::make_shared<CButton> (Point(747, 5), "icm007.def", CGI->generaltexth->zelp[387], std::bind(&CBattleControlPanel::bDefencef,this), SDLK_d);
|
||||
bConsoleUp = std::make_shared<CButton> (Point(624, 5), "ComSlide.def", std::make_pair("", ""), std::bind(&CBattleControlPanel::bConsoleUpf,this), SDLK_UP);
|
||||
bConsoleDown = std::make_shared<CButton>(Point(624, 24), "ComSlide.def", std::make_pair("", ""), std::bind(&CBattleControlPanel::bConsoleDownf,this), SDLK_DOWN);
|
||||
bOptions = std::make_shared<CButton> (Point( 3, 5), "icm003.def", CGI->generaltexth->zelp[381], std::bind(&BattleControlPanel::bOptionsf,this), SDLK_o);
|
||||
bSurrender = std::make_shared<CButton> (Point( 54, 5), "icm001.def", CGI->generaltexth->zelp[379], std::bind(&BattleControlPanel::bSurrenderf,this), SDLK_s);
|
||||
bFlee = std::make_shared<CButton> (Point(105, 5), "icm002.def", CGI->generaltexth->zelp[380], std::bind(&BattleControlPanel::bFleef,this), SDLK_r);
|
||||
bAutofight = std::make_shared<CButton> (Point(157, 5), "icm004.def", CGI->generaltexth->zelp[382], std::bind(&BattleControlPanel::bAutofightf,this), SDLK_a);
|
||||
bSpell = std::make_shared<CButton> (Point(645, 5), "icm005.def", CGI->generaltexth->zelp[385], std::bind(&BattleControlPanel::bSpellf,this), SDLK_c);
|
||||
bWait = std::make_shared<CButton> (Point(696, 5), "icm006.def", CGI->generaltexth->zelp[386], std::bind(&BattleControlPanel::bWaitf,this), SDLK_w);
|
||||
bDefence = std::make_shared<CButton> (Point(747, 5), "icm007.def", CGI->generaltexth->zelp[387], std::bind(&BattleControlPanel::bDefencef,this), SDLK_d);
|
||||
bConsoleUp = std::make_shared<CButton> (Point(624, 5), "ComSlide.def", std::make_pair("", ""), std::bind(&BattleControlPanel::bConsoleUpf,this), SDLK_UP);
|
||||
bConsoleDown = std::make_shared<CButton>(Point(624, 24), "ComSlide.def", std::make_pair("", ""), std::bind(&BattleControlPanel::bConsoleDownf,this), SDLK_DOWN);
|
||||
|
||||
bDefence->assignedKeys.insert(SDLK_SPACE);
|
||||
bConsoleUp->setImageOrder(0, 1, 0, 0);
|
||||
bConsoleDown->setImageOrder(2, 3, 2, 2);
|
||||
|
||||
console = std::make_shared<CBattleConsole>(Rect(211, 4, 406,38));
|
||||
console = std::make_shared<BattleConsole>(Rect(211, 4, 406,38));
|
||||
GH.statusbar = console;
|
||||
|
||||
if ( owner->tacticsMode )
|
||||
@ -59,14 +59,14 @@ CBattleControlPanel::CBattleControlPanel(CBattleInterface * owner, const Point &
|
||||
tacticPhaseEnded();
|
||||
}
|
||||
|
||||
void CBattleControlPanel::show(SDL_Surface * to)
|
||||
void BattleControlPanel::show(SDL_Surface * to)
|
||||
{
|
||||
//show menu before all other elements to keep it in background
|
||||
menu->show(to);
|
||||
CIntObject::show(to);
|
||||
}
|
||||
|
||||
void CBattleControlPanel::showAll(SDL_Surface * to)
|
||||
void BattleControlPanel::showAll(SDL_Surface * to)
|
||||
{
|
||||
//show menu before all other elements to keep it in background
|
||||
menu->showAll(to);
|
||||
@ -74,7 +74,7 @@ void CBattleControlPanel::showAll(SDL_Surface * to)
|
||||
}
|
||||
|
||||
|
||||
void CBattleControlPanel::tacticPhaseStarted()
|
||||
void BattleControlPanel::tacticPhaseStarted()
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||
|
||||
@ -84,7 +84,7 @@ void CBattleControlPanel::tacticPhaseStarted()
|
||||
menu->colorize(owner->curInt->playerID);
|
||||
menu->recActions &= ~(SHOWALL | UPDATE);
|
||||
}
|
||||
void CBattleControlPanel::tacticPhaseEnded()
|
||||
void BattleControlPanel::tacticPhaseEnded()
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||
|
||||
@ -96,17 +96,17 @@ void CBattleControlPanel::tacticPhaseEnded()
|
||||
menu->recActions &= ~(SHOWALL | UPDATE);
|
||||
}
|
||||
|
||||
void CBattleControlPanel::bOptionsf()
|
||||
void BattleControlPanel::bOptionsf()
|
||||
{
|
||||
if (owner->actionsController->spellcastingModeActive())
|
||||
return;
|
||||
|
||||
CCS->curh->changeGraphic(ECursor::ADVENTURE,0);
|
||||
|
||||
GH.pushIntT<CBattleOptionsWindow>(owner);
|
||||
GH.pushIntT<BattleOptionsWindow>(owner);
|
||||
}
|
||||
|
||||
void CBattleControlPanel::bSurrenderf()
|
||||
void BattleControlPanel::bSurrenderf()
|
||||
{
|
||||
if (owner->actionsController->spellcastingModeActive())
|
||||
return;
|
||||
@ -126,14 +126,14 @@ void CBattleControlPanel::bSurrenderf()
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleControlPanel::bFleef()
|
||||
void BattleControlPanel::bFleef()
|
||||
{
|
||||
if (owner->actionsController->spellcastingModeActive())
|
||||
return;
|
||||
|
||||
if ( owner->curInt->cb->battleCanFlee() )
|
||||
{
|
||||
CFunctionList<void()> ony = std::bind(&CBattleControlPanel::reallyFlee,this);
|
||||
CFunctionList<void()> ony = std::bind(&BattleControlPanel::reallyFlee,this);
|
||||
owner->curInt->showYesNoDialog(CGI->generaltexth->allTexts[28], ony, nullptr); //Are you sure you want to retreat?
|
||||
}
|
||||
else
|
||||
@ -155,13 +155,13 @@ void CBattleControlPanel::bFleef()
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleControlPanel::reallyFlee()
|
||||
void BattleControlPanel::reallyFlee()
|
||||
{
|
||||
owner->giveCommand(EActionType::RETREAT);
|
||||
CCS->curh->changeGraphic(ECursor::ADVENTURE, 0);
|
||||
}
|
||||
|
||||
void CBattleControlPanel::reallySurrender()
|
||||
void BattleControlPanel::reallySurrender()
|
||||
{
|
||||
if (owner->curInt->cb->getResourceAmount(Res::GOLD) < owner->curInt->cb->battleGetSurrenderCost())
|
||||
{
|
||||
@ -174,7 +174,7 @@ void CBattleControlPanel::reallySurrender()
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleControlPanel::bAutofightf()
|
||||
void BattleControlPanel::bAutofightf()
|
||||
{
|
||||
if (owner->actionsController->spellcastingModeActive())
|
||||
return;
|
||||
@ -201,7 +201,7 @@ void CBattleControlPanel::bAutofightf()
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleControlPanel::bSpellf()
|
||||
void BattleControlPanel::bSpellf()
|
||||
{
|
||||
if (owner->actionsController->spellcastingModeActive())
|
||||
return;
|
||||
@ -243,7 +243,7 @@ void CBattleControlPanel::bSpellf()
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleControlPanel::bWaitf()
|
||||
void BattleControlPanel::bWaitf()
|
||||
{
|
||||
if (owner->actionsController->spellcastingModeActive())
|
||||
return;
|
||||
@ -252,7 +252,7 @@ void CBattleControlPanel::bWaitf()
|
||||
owner->giveCommand(EActionType::WAIT);
|
||||
}
|
||||
|
||||
void CBattleControlPanel::bDefencef()
|
||||
void BattleControlPanel::bDefencef()
|
||||
{
|
||||
if (owner->actionsController->spellcastingModeActive())
|
||||
return;
|
||||
@ -261,7 +261,7 @@ void CBattleControlPanel::bDefencef()
|
||||
owner->giveCommand(EActionType::DEFEND);
|
||||
}
|
||||
|
||||
void CBattleControlPanel::bConsoleUpf()
|
||||
void BattleControlPanel::bConsoleUpf()
|
||||
{
|
||||
if (owner->actionsController->spellcastingModeActive())
|
||||
return;
|
||||
@ -269,7 +269,7 @@ void CBattleControlPanel::bConsoleUpf()
|
||||
console->scrollUp();
|
||||
}
|
||||
|
||||
void CBattleControlPanel::bConsoleDownf()
|
||||
void BattleControlPanel::bConsoleDownf()
|
||||
{
|
||||
if (owner->actionsController->spellcastingModeActive())
|
||||
return;
|
||||
@ -277,17 +277,17 @@ void CBattleControlPanel::bConsoleDownf()
|
||||
console->scrollDown();
|
||||
}
|
||||
|
||||
void CBattleControlPanel::bTacticNextStack()
|
||||
void BattleControlPanel::bTacticNextStack()
|
||||
{
|
||||
owner->tacticNextStack(nullptr);
|
||||
}
|
||||
|
||||
void CBattleControlPanel::bTacticPhaseEnd()
|
||||
void BattleControlPanel::bTacticPhaseEnd()
|
||||
{
|
||||
owner->tacticPhaseEnd();
|
||||
}
|
||||
|
||||
void CBattleControlPanel::blockUI(bool on)
|
||||
void BattleControlPanel::blockUI(bool on)
|
||||
{
|
||||
bool canCastSpells = false;
|
||||
auto hero = owner->curInt->cb->battleGetMyHero();
|
||||
|
@ -17,12 +17,12 @@ class CStack;
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
class CButton;
|
||||
class CBattleInterface;
|
||||
class CBattleConsole;
|
||||
class BattleInterface;
|
||||
class BattleConsole;
|
||||
|
||||
class CBattleControlPanel : public CIntObject
|
||||
class BattleControlPanel : public CIntObject
|
||||
{
|
||||
CBattleInterface * owner;
|
||||
BattleInterface * owner;
|
||||
|
||||
std::shared_ptr<CPicture> menu;
|
||||
|
||||
@ -55,7 +55,7 @@ class CBattleControlPanel : public CIntObject
|
||||
void reallySurrender(); //performs surrendering without asking player
|
||||
|
||||
public:
|
||||
std::shared_ptr<CBattleConsole> console;
|
||||
std::shared_ptr<BattleConsole> console;
|
||||
|
||||
// block all UI elements, e.g. during enemy turn
|
||||
// unlike activate/deactivate this method will correctly grey-out all elements
|
||||
@ -67,6 +67,6 @@ public:
|
||||
void tacticPhaseStarted();
|
||||
void tacticPhaseEnded();
|
||||
|
||||
CBattleControlPanel(CBattleInterface * owner, const Point & position);
|
||||
BattleControlPanel(BattleInterface * owner, const Point & position);
|
||||
};
|
||||
|
||||
|
@ -31,23 +31,23 @@
|
||||
#include "../../lib/IGameEventsReceiver.h"
|
||||
#include "../../lib/CGeneralTextHandler.h"
|
||||
|
||||
CBattleEffectsController::CBattleEffectsController(CBattleInterface * owner):
|
||||
BattleEffectsController::BattleEffectsController(BattleInterface * owner):
|
||||
owner(owner)
|
||||
{}
|
||||
|
||||
void CBattleEffectsController::displayEffect(EBattleEffect::EBattleEffect effect, const BattleHex & destTile)
|
||||
void BattleEffectsController::displayEffect(EBattleEffect::EBattleEffect effect, const BattleHex & destTile)
|
||||
{
|
||||
displayEffect(effect, soundBase::invalid, destTile);
|
||||
}
|
||||
|
||||
void CBattleEffectsController::displayEffect(EBattleEffect::EBattleEffect effect, uint32_t soundID, const BattleHex & destTile)
|
||||
void BattleEffectsController::displayEffect(EBattleEffect::EBattleEffect effect, uint32_t soundID, const BattleHex & destTile)
|
||||
{
|
||||
std::string customAnim = graphics->battleACToDef[effect][0];
|
||||
|
||||
owner->stacksController->addNewAnim(new CPointEffectAnimation(owner, soundBase::soundID(soundID), customAnim, destTile));
|
||||
}
|
||||
|
||||
void CBattleEffectsController::displayCustomEffects(const std::vector<CustomEffectInfo> & customEffects)
|
||||
void BattleEffectsController::displayCustomEffects(const std::vector<CustomEffectInfo> & customEffects)
|
||||
{
|
||||
for(const CustomEffectInfo & one : customEffects)
|
||||
{
|
||||
@ -60,7 +60,7 @@ void CBattleEffectsController::displayCustomEffects(const std::vector<CustomEffe
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleEffectsController::battleTriggerEffect(const BattleTriggerEffect & bte)
|
||||
void BattleEffectsController::battleTriggerEffect(const BattleTriggerEffect & bte)
|
||||
{
|
||||
const CStack * stack = owner->curInt->cb->battleGetStackByID(bte.stackID);
|
||||
if(!stack)
|
||||
@ -98,7 +98,7 @@ void CBattleEffectsController::battleTriggerEffect(const BattleTriggerEffect & b
|
||||
//waitForAnims(); //fixme: freezes game :?
|
||||
}
|
||||
|
||||
void CBattleEffectsController::startAction(const BattleAction* action)
|
||||
void BattleEffectsController::startAction(const BattleAction* action)
|
||||
{
|
||||
const CStack *stack = owner->curInt->cb->battleGetStackByID(action->stackNumber);
|
||||
|
||||
@ -123,11 +123,11 @@ void CBattleEffectsController::startAction(const BattleAction* action)
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleEffectsController::collectRenderableObjects(CBattleRenderer & renderer)
|
||||
void BattleEffectsController::collectRenderableObjects(BattleRenderer & renderer)
|
||||
{
|
||||
for (auto & elem : battleEffects)
|
||||
{
|
||||
renderer.insert( EBattleFieldLayer::EFFECTS, elem.position, [&elem](CBattleRenderer::RendererPtr canvas)
|
||||
renderer.insert( EBattleFieldLayer::EFFECTS, elem.position, [&elem](BattleRenderer::RendererPtr canvas)
|
||||
{
|
||||
int currentFrame = static_cast<int>(floor(elem.currentFrame));
|
||||
currentFrame %= elem.animation->size();
|
||||
|
@ -22,8 +22,8 @@ VCMI_LIB_NAMESPACE_END
|
||||
struct SDL_Surface;
|
||||
class CAnimation;
|
||||
class CCanvas;
|
||||
class CBattleInterface;
|
||||
class CBattleRenderer;
|
||||
class BattleInterface;
|
||||
class BattleRenderer;
|
||||
class CPointEffectAnimation;
|
||||
|
||||
namespace EBattleEffect
|
||||
@ -57,15 +57,15 @@ struct BattleEffect
|
||||
BattleHex position; //Indicates if effect which hex the effect is drawn on
|
||||
};
|
||||
|
||||
class CBattleEffectsController
|
||||
class BattleEffectsController
|
||||
{
|
||||
CBattleInterface * owner;
|
||||
BattleInterface * owner;
|
||||
|
||||
/// list of current effects that are being displayed on screen (spells & creature abilities)
|
||||
std::vector<BattleEffect> battleEffects;
|
||||
|
||||
public:
|
||||
CBattleEffectsController(CBattleInterface * owner);
|
||||
BattleEffectsController(BattleInterface * owner);
|
||||
|
||||
void startAction(const BattleAction* action);
|
||||
|
||||
@ -78,7 +78,7 @@ public:
|
||||
|
||||
void battleTriggerEffect(const BattleTriggerEffect & bte);
|
||||
|
||||
void collectRenderableObjects(CBattleRenderer & renderer);
|
||||
void collectRenderableObjects(BattleRenderer & renderer);
|
||||
|
||||
friend class CPointEffectAnimation;
|
||||
};
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "../../lib/CStack.h"
|
||||
#include "../../lib/spells/ISpellMechanics.h"
|
||||
|
||||
CBattleFieldController::CBattleFieldController(CBattleInterface * owner):
|
||||
BattleFieldController::BattleFieldController(BattleInterface * owner):
|
||||
owner(owner),
|
||||
attackingHex(BattleHex::INVALID)
|
||||
{
|
||||
@ -77,7 +77,7 @@ CBattleFieldController::CBattleFieldController(CBattleInterface * owner):
|
||||
|
||||
for (int h = 0; h < GameConstants::BFIELD_SIZE; ++h)
|
||||
{
|
||||
auto hex = std::make_shared<CClickableHex>();
|
||||
auto hex = std::make_shared<ClickableHex>();
|
||||
hex->myNumber = h;
|
||||
hex->pos = hexPosition(h);
|
||||
hex->myInterface = owner;
|
||||
@ -89,18 +89,18 @@ CBattleFieldController::CBattleFieldController(CBattleInterface * owner):
|
||||
stackCountOutsideHexes[i] = (accessibility[i] == EAccessibility::ACCESSIBLE);
|
||||
}
|
||||
|
||||
void CBattleFieldController::renderBattlefield(std::shared_ptr<CCanvas> canvas)
|
||||
void BattleFieldController::renderBattlefield(std::shared_ptr<CCanvas> canvas)
|
||||
{
|
||||
showBackground(canvas);
|
||||
|
||||
CBattleRenderer renderer(owner);
|
||||
BattleRenderer renderer(owner);
|
||||
|
||||
renderer.execute(canvas);
|
||||
|
||||
owner->projectilesController->showProjectiles(canvas);
|
||||
}
|
||||
|
||||
void CBattleFieldController::showBackground(std::shared_ptr<CCanvas> canvas)
|
||||
void BattleFieldController::showBackground(std::shared_ptr<CCanvas> canvas)
|
||||
{
|
||||
if (owner->stacksController->getActiveStack() != nullptr ) //&& creAnims[stacksController->getActiveStack()->ID]->isIdle() //show everything with range
|
||||
showBackgroundImageWithHexes(canvas);
|
||||
@ -111,7 +111,7 @@ void CBattleFieldController::showBackground(std::shared_ptr<CCanvas> canvas)
|
||||
|
||||
}
|
||||
|
||||
void CBattleFieldController::showBackgroundImage(std::shared_ptr<CCanvas> canvas)
|
||||
void BattleFieldController::showBackgroundImage(std::shared_ptr<CCanvas> canvas)
|
||||
{
|
||||
canvas->draw(background, owner->pos.topLeft());
|
||||
|
||||
@ -123,12 +123,12 @@ void CBattleFieldController::showBackgroundImage(std::shared_ptr<CCanvas> canvas
|
||||
canvas->draw(cellBorders, owner->pos.topLeft());
|
||||
}
|
||||
|
||||
void CBattleFieldController::showBackgroundImageWithHexes(std::shared_ptr<CCanvas> canvas)
|
||||
void BattleFieldController::showBackgroundImageWithHexes(std::shared_ptr<CCanvas> canvas)
|
||||
{
|
||||
canvas->draw(backgroundWithHexes, owner->pos.topLeft());
|
||||
}
|
||||
|
||||
void CBattleFieldController::redrawBackgroundWithHexes()
|
||||
void BattleFieldController::redrawBackgroundWithHexes()
|
||||
{
|
||||
const CStack *activeStack = owner->stacksController->getActiveStack();
|
||||
std::vector<BattleHex> attackableHexes;
|
||||
@ -160,7 +160,7 @@ void CBattleFieldController::redrawBackgroundWithHexes()
|
||||
backgroundWithHexes->draw(cellBorders, Point(0, 0));
|
||||
}
|
||||
|
||||
void CBattleFieldController::showHighlightedHex(std::shared_ptr<CCanvas> to, BattleHex hex, bool darkBorder)
|
||||
void BattleFieldController::showHighlightedHex(std::shared_ptr<CCanvas> to, BattleHex hex, bool darkBorder)
|
||||
{
|
||||
Point hexPos = hexPosition(hex).topLeft();
|
||||
|
||||
@ -169,7 +169,7 @@ void CBattleFieldController::showHighlightedHex(std::shared_ptr<CCanvas> to, Bat
|
||||
to->draw(cellBorder, hexPos);
|
||||
}
|
||||
|
||||
std::set<BattleHex> CBattleFieldController::getHighlightedHexesStackRange()
|
||||
std::set<BattleHex> BattleFieldController::getHighlightedHexesStackRange()
|
||||
{
|
||||
std::set<BattleHex> result;
|
||||
|
||||
@ -196,7 +196,7 @@ std::set<BattleHex> CBattleFieldController::getHighlightedHexesStackRange()
|
||||
return result;
|
||||
}
|
||||
|
||||
std::set<BattleHex> CBattleFieldController::getHighlightedHexesSpellRange()
|
||||
std::set<BattleHex> BattleFieldController::getHighlightedHexesSpellRange()
|
||||
{
|
||||
std::set<BattleHex> result;
|
||||
auto hoveredHex = getHoveredHex();
|
||||
@ -242,7 +242,7 @@ std::set<BattleHex> CBattleFieldController::getHighlightedHexesSpellRange()
|
||||
return result;
|
||||
}
|
||||
|
||||
void CBattleFieldController::showHighlightedHexes(std::shared_ptr<CCanvas> canvas)
|
||||
void BattleFieldController::showHighlightedHexes(std::shared_ptr<CCanvas> canvas)
|
||||
{
|
||||
std::set<BattleHex> hoveredStack = getHighlightedHexesStackRange();
|
||||
std::set<BattleHex> hoveredMouse = getHighlightedHexesSpellRange();
|
||||
@ -269,7 +269,7 @@ void CBattleFieldController::showHighlightedHexes(std::shared_ptr<CCanvas> canva
|
||||
}
|
||||
}
|
||||
|
||||
Rect CBattleFieldController::hexPositionLocal(BattleHex hex) const
|
||||
Rect BattleFieldController::hexPositionLocal(BattleHex hex) const
|
||||
{
|
||||
int x = 14 + ((hex.getY())%2==0 ? 22 : 0) + 44*hex.getX();
|
||||
int y = 86 + 42 *hex.getY();
|
||||
@ -278,17 +278,17 @@ Rect CBattleFieldController::hexPositionLocal(BattleHex hex) const
|
||||
return Rect(x, y, w, h);
|
||||
}
|
||||
|
||||
Rect CBattleFieldController::hexPosition(BattleHex hex) const
|
||||
Rect BattleFieldController::hexPosition(BattleHex hex) const
|
||||
{
|
||||
return hexPositionLocal(hex) + owner->pos.topLeft();
|
||||
}
|
||||
|
||||
bool CBattleFieldController::isPixelInHex(Point const & position)
|
||||
bool BattleFieldController::isPixelInHex(Point const & position)
|
||||
{
|
||||
return !cellShade->isTransparent(position);
|
||||
}
|
||||
|
||||
BattleHex CBattleFieldController::getHoveredHex()
|
||||
BattleHex BattleFieldController::getHoveredHex()
|
||||
{
|
||||
for ( auto const & hex : bfield)
|
||||
if (hex->hovered && hex->strictHovered)
|
||||
@ -297,7 +297,7 @@ BattleHex CBattleFieldController::getHoveredHex()
|
||||
return BattleHex::INVALID;
|
||||
}
|
||||
|
||||
void CBattleFieldController::setBattleCursor(BattleHex myNumber)
|
||||
void BattleFieldController::setBattleCursor(BattleHex myNumber)
|
||||
{
|
||||
Rect hoveredHexPos = hexPosition(myNumber);
|
||||
CCursorHandler *cursor = CCS->curh;
|
||||
@ -470,7 +470,7 @@ void CBattleFieldController::setBattleCursor(BattleHex myNumber)
|
||||
attackingHex = -1;
|
||||
}
|
||||
|
||||
BattleHex CBattleFieldController::fromWhichHexAttack(BattleHex myNumber)
|
||||
BattleHex BattleFieldController::fromWhichHexAttack(BattleHex myNumber)
|
||||
{
|
||||
//TODO far too much repeating code
|
||||
BattleHex destHex;
|
||||
@ -618,7 +618,7 @@ BattleHex CBattleFieldController::fromWhichHexAttack(BattleHex myNumber)
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool CBattleFieldController::isTileAttackable(const BattleHex & number) const
|
||||
bool BattleFieldController::isTileAttackable(const BattleHex & number) const
|
||||
{
|
||||
for (auto & elem : occupyableHexes)
|
||||
{
|
||||
@ -628,7 +628,7 @@ bool CBattleFieldController::isTileAttackable(const BattleHex & number) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CBattleFieldController::stackCountOutsideHex(const BattleHex & number) const
|
||||
bool BattleFieldController::stackCountOutsideHex(const BattleHex & number) const
|
||||
{
|
||||
return stackCountOutsideHexes[number];
|
||||
}
|
||||
|
@ -22,14 +22,14 @@ struct SDL_Surface;
|
||||
struct Rect;
|
||||
struct Point;
|
||||
|
||||
class CClickableHex;
|
||||
class ClickableHex;
|
||||
class CCanvas;
|
||||
class IImage;
|
||||
class CBattleInterface;
|
||||
class BattleInterface;
|
||||
|
||||
class CBattleFieldController : public CIntObject
|
||||
class BattleFieldController : public CIntObject
|
||||
{
|
||||
CBattleInterface * owner;
|
||||
BattleInterface * owner;
|
||||
|
||||
std::shared_ptr<IImage> background;
|
||||
std::shared_ptr<IImage> cellBorder;
|
||||
@ -47,7 +47,7 @@ class CBattleFieldController : public CIntObject
|
||||
std::vector<BattleHex> occupyableHexes; //hexes available for active stack
|
||||
std::array<bool, GameConstants::BFIELD_SIZE> stackCountOutsideHexes; // hexes that when in front of a unit cause it's amount box to move back
|
||||
|
||||
std::vector<std::shared_ptr<CClickableHex>> bfield; //11 lines, 17 hexes on each
|
||||
std::vector<std::shared_ptr<ClickableHex>> bfield; //11 lines, 17 hexes on each
|
||||
|
||||
void showHighlightedHex(std::shared_ptr<CCanvas> to, BattleHex hex, bool darkBorder);
|
||||
|
||||
@ -60,7 +60,7 @@ class CBattleFieldController : public CIntObject
|
||||
void showHighlightedHexes(std::shared_ptr<CCanvas> canvas);
|
||||
|
||||
public:
|
||||
CBattleFieldController(CBattleInterface * owner);
|
||||
BattleFieldController(BattleInterface * owner);
|
||||
|
||||
void redrawBackgroundWithHexes();
|
||||
void renderBattlefield(std::shared_ptr<CCanvas> canvas);
|
||||
|
@ -42,10 +42,10 @@
|
||||
#include "../../lib/NetPacks.h"
|
||||
#include "../../lib/UnlockGuard.h"
|
||||
|
||||
CondSh<bool> CBattleInterface::animsAreDisplayed(false);
|
||||
CondSh<BattleAction *> CBattleInterface::givenCommand(nullptr);
|
||||
CondSh<bool> BattleInterface::animsAreDisplayed(false);
|
||||
CondSh<BattleAction *> BattleInterface::givenCommand(nullptr);
|
||||
|
||||
CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet *army2,
|
||||
BattleInterface::BattleInterface(const CCreatureSet *army1, const CCreatureSet *army2,
|
||||
const CGHeroInstance *hero1, const CGHeroInstance *hero2,
|
||||
const SDL_Rect & myRect,
|
||||
std::shared_ptr<CPlayerInterface> att, std::shared_ptr<CPlayerInterface> defen, std::shared_ptr<CPlayerInterface> spectatorInt)
|
||||
@ -55,7 +55,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
|
||||
{
|
||||
OBJ_CONSTRUCTION;
|
||||
|
||||
projectilesController.reset(new CBattleProjectileController(this));
|
||||
projectilesController.reset(new BattleProjectileController(this));
|
||||
|
||||
if(spectatorInt)
|
||||
{
|
||||
@ -90,7 +90,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
|
||||
else
|
||||
embedQueue = screen->h < 700 || queueSize == "small";
|
||||
|
||||
queue = std::make_shared<CStackQueue>(embedQueue, this);
|
||||
queue = std::make_shared<StackQueue>(embedQueue, this);
|
||||
if(!embedQueue)
|
||||
{
|
||||
if (settings["battle"]["showQueue"].Bool())
|
||||
@ -102,7 +102,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
|
||||
//preparing siege info
|
||||
const CGTownInstance *town = curInt->cb->battleGetDefendedTown();
|
||||
if(town && town->hasFort())
|
||||
siegeController.reset(new CBattleSiegeController(this, town));
|
||||
siegeController.reset(new BattleSiegeController(this, town));
|
||||
|
||||
CPlayerInterface::battleInt = this;
|
||||
|
||||
@ -110,13 +110,13 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
|
||||
this->army1 = army1;
|
||||
this->army2 = army2;
|
||||
|
||||
controlPanel = std::make_shared<CBattleControlPanel>(this, Point(0, 556));
|
||||
controlPanel = std::make_shared<BattleControlPanel>(this, Point(0, 556));
|
||||
|
||||
//preparing menu background and terrain
|
||||
fieldController.reset( new CBattleFieldController(this));
|
||||
stacksController.reset( new CBattleStacksController(this));
|
||||
actionsController.reset( new CBattleActionsController(this));
|
||||
effectsController.reset(new CBattleEffectsController(this));
|
||||
fieldController.reset( new BattleFieldController(this));
|
||||
stacksController.reset( new BattleStacksController(this));
|
||||
actionsController.reset( new BattleActionsController(this));
|
||||
effectsController.reset(new BattleEffectsController(this));
|
||||
|
||||
//loading hero animations
|
||||
if(hero1) // attacking hero
|
||||
@ -134,7 +134,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
|
||||
battleImage = hero1->type->heroClass->imageBattleMale;
|
||||
}
|
||||
|
||||
attackingHero = std::make_shared<CBattleHero>(battleImage, false, hero1->tempOwner, hero1->tempOwner == curInt->playerID ? hero1 : nullptr, this);
|
||||
attackingHero = std::make_shared<BattleHero>(battleImage, false, hero1->tempOwner, hero1->tempOwner == curInt->playerID ? hero1 : nullptr, this);
|
||||
|
||||
auto img = attackingHero->animation->getImage(0, 0, true);
|
||||
if(img)
|
||||
@ -158,14 +158,14 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
|
||||
battleImage = hero2->type->heroClass->imageBattleMale;
|
||||
}
|
||||
|
||||
defendingHero = std::make_shared<CBattleHero>(battleImage, true, hero2->tempOwner, hero2->tempOwner == curInt->playerID ? hero2 : nullptr, this);
|
||||
defendingHero = std::make_shared<BattleHero>(battleImage, true, hero2->tempOwner, hero2->tempOwner == curInt->playerID ? hero2 : nullptr, this);
|
||||
|
||||
auto img = defendingHero->animation->getImage(0, 0, true);
|
||||
if(img)
|
||||
defendingHero->pos = genRect(img->height(), img->width(), pos.x + 693, pos.y - 19);
|
||||
}
|
||||
|
||||
obstacleController.reset(new CBattleObstacleController(this));
|
||||
obstacleController.reset(new BattleObstacleController(this));
|
||||
|
||||
if(tacticsMode)
|
||||
tacticNextStack(nullptr);
|
||||
@ -191,7 +191,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
|
||||
queue->update();
|
||||
}
|
||||
|
||||
CBattleInterface::~CBattleInterface()
|
||||
BattleInterface::~BattleInterface()
|
||||
{
|
||||
CPlayerInterface::battleInt = nullptr;
|
||||
givenCommand.cond.notify_all(); //that two lines should make any stacksController->getActiveStack() waiting thread to finish
|
||||
@ -210,7 +210,7 @@ CBattleInterface::~CBattleInterface()
|
||||
animsAreDisplayed.setn(false);
|
||||
}
|
||||
|
||||
void CBattleInterface::setPrintCellBorders(bool set)
|
||||
void BattleInterface::setPrintCellBorders(bool set)
|
||||
{
|
||||
Settings cellBorders = settings.write["battle"]["cellBorders"];
|
||||
cellBorders->Bool() = set;
|
||||
@ -219,7 +219,7 @@ void CBattleInterface::setPrintCellBorders(bool set)
|
||||
GH.totalRedraw();
|
||||
}
|
||||
|
||||
void CBattleInterface::setPrintStackRange(bool set)
|
||||
void BattleInterface::setPrintStackRange(bool set)
|
||||
{
|
||||
Settings stackRange = settings.write["battle"]["stackRange"];
|
||||
stackRange->Bool() = set;
|
||||
@ -228,13 +228,13 @@ void CBattleInterface::setPrintStackRange(bool set)
|
||||
GH.totalRedraw();
|
||||
}
|
||||
|
||||
void CBattleInterface::setPrintMouseShadow(bool set)
|
||||
void BattleInterface::setPrintMouseShadow(bool set)
|
||||
{
|
||||
Settings shadow = settings.write["battle"]["mouseShadow"];
|
||||
shadow->Bool() = set;
|
||||
}
|
||||
|
||||
void CBattleInterface::activate()
|
||||
void BattleInterface::activate()
|
||||
{
|
||||
controlPanel->activate();
|
||||
|
||||
@ -256,7 +256,7 @@ void CBattleInterface::activate()
|
||||
LOCPLINT->cingconsole->activate();
|
||||
}
|
||||
|
||||
void CBattleInterface::deactivate()
|
||||
void BattleInterface::deactivate()
|
||||
{
|
||||
controlPanel->deactivate();
|
||||
CIntObject::deactivate();
|
||||
@ -273,7 +273,7 @@ void CBattleInterface::deactivate()
|
||||
LOCPLINT->cingconsole->deactivate();
|
||||
}
|
||||
|
||||
void CBattleInterface::keyPressed(const SDL_KeyboardEvent & key)
|
||||
void BattleInterface::keyPressed(const SDL_KeyboardEvent & key)
|
||||
{
|
||||
if(key.keysym.sym == SDLK_q && key.state == SDL_PRESSED)
|
||||
{
|
||||
@ -295,7 +295,7 @@ void CBattleInterface::keyPressed(const SDL_KeyboardEvent & key)
|
||||
actionsController->endCastingSpell();
|
||||
}
|
||||
}
|
||||
void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &event)
|
||||
void BattleInterface::mouseMoved(const SDL_MouseMotionEvent &event)
|
||||
{
|
||||
BattleHex selectedHex = fieldController->getHoveredHex();
|
||||
|
||||
@ -304,7 +304,7 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &event)
|
||||
controlPanel->mouseMoved(event);
|
||||
}
|
||||
|
||||
void CBattleInterface::clickRight(tribool down, bool previousState)
|
||||
void BattleInterface::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
if (!down)
|
||||
{
|
||||
@ -312,34 +312,34 @@ void CBattleInterface::clickRight(tribool down, bool previousState)
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::stackReset(const CStack * stack)
|
||||
void BattleInterface::stackReset(const CStack * stack)
|
||||
{
|
||||
stacksController->stackReset(stack);
|
||||
}
|
||||
|
||||
void CBattleInterface::stackAdded(const CStack * stack)
|
||||
void BattleInterface::stackAdded(const CStack * stack)
|
||||
{
|
||||
stacksController->stackAdded(stack);
|
||||
}
|
||||
|
||||
void CBattleInterface::stackRemoved(uint32_t stackID)
|
||||
void BattleInterface::stackRemoved(uint32_t stackID)
|
||||
{
|
||||
stacksController->stackRemoved(stackID);
|
||||
fieldController->redrawBackgroundWithHexes();
|
||||
queue->update();
|
||||
}
|
||||
|
||||
void CBattleInterface::stackActivated(const CStack *stack) //TODO: check it all before game state is changed due to abilities
|
||||
void BattleInterface::stackActivated(const CStack *stack) //TODO: check it all before game state is changed due to abilities
|
||||
{
|
||||
stacksController->stackActivated(stack);
|
||||
}
|
||||
|
||||
void CBattleInterface::stackMoved(const CStack *stack, std::vector<BattleHex> destHex, int distance)
|
||||
void BattleInterface::stackMoved(const CStack *stack, std::vector<BattleHex> destHex, int distance)
|
||||
{
|
||||
stacksController->stackMoved(stack, destHex, distance);
|
||||
}
|
||||
|
||||
void CBattleInterface::stacksAreAttacked(std::vector<StackAttackedInfo> attackedInfos)
|
||||
void BattleInterface::stacksAreAttacked(std::vector<StackAttackedInfo> attackedInfos)
|
||||
{
|
||||
stacksController->stacksAreAttacked(attackedInfos);
|
||||
|
||||
@ -363,22 +363,22 @@ void CBattleInterface::stacksAreAttacked(std::vector<StackAttackedInfo> attacked
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::stackAttacking( const CStack *attacker, BattleHex dest, const CStack *attacked, bool shooting )
|
||||
void BattleInterface::stackAttacking( const CStack *attacker, BattleHex dest, const CStack *attacked, bool shooting )
|
||||
{
|
||||
stacksController->stackAttacking(attacker, dest, attacked, shooting);
|
||||
}
|
||||
|
||||
void CBattleInterface::newRoundFirst( int round )
|
||||
void BattleInterface::newRoundFirst( int round )
|
||||
{
|
||||
waitForAnims();
|
||||
}
|
||||
|
||||
void CBattleInterface::newRound(int number)
|
||||
void BattleInterface::newRound(int number)
|
||||
{
|
||||
controlPanel->console->addText(CGI->generaltexth->allTexts[412]);
|
||||
}
|
||||
|
||||
void CBattleInterface::giveCommand(EActionType action, BattleHex tile, si32 additional)
|
||||
void BattleInterface::giveCommand(EActionType action, BattleHex tile, si32 additional)
|
||||
{
|
||||
const CStack * actor = nullptr;
|
||||
if(action != EActionType::HERO_SPELL && action != EActionType::RETREAT && action != EActionType::SURRENDER)
|
||||
@ -402,7 +402,7 @@ void CBattleInterface::giveCommand(EActionType action, BattleHex tile, si32 addi
|
||||
sendCommand(ba, actor);
|
||||
}
|
||||
|
||||
void CBattleInterface::sendCommand(BattleAction *& command, const CStack * actor)
|
||||
void BattleInterface::sendCommand(BattleAction *& command, const CStack * actor)
|
||||
{
|
||||
command->stackNumber = actor ? actor->unitId() : ((command->side == BattleSide::ATTACKER) ? -1 : -2);
|
||||
|
||||
@ -422,7 +422,7 @@ void CBattleInterface::sendCommand(BattleAction *& command, const CStack * actor
|
||||
}
|
||||
}
|
||||
|
||||
const CGHeroInstance * CBattleInterface::getActiveHero()
|
||||
const CGHeroInstance * BattleInterface::getActiveHero()
|
||||
{
|
||||
const CStack *attacker = stacksController->getActiveStack();
|
||||
if(!attacker)
|
||||
@ -438,24 +438,24 @@ const CGHeroInstance * CBattleInterface::getActiveHero()
|
||||
return defendingHeroInstance;
|
||||
}
|
||||
|
||||
void CBattleInterface::hexLclicked(int whichOne)
|
||||
void BattleInterface::hexLclicked(int whichOne)
|
||||
{
|
||||
actionsController->handleHex(whichOne, LCLICK);
|
||||
}
|
||||
|
||||
void CBattleInterface::stackIsCatapulting(const CatapultAttack & ca)
|
||||
void BattleInterface::stackIsCatapulting(const CatapultAttack & ca)
|
||||
{
|
||||
if (siegeController)
|
||||
siegeController->stackIsCatapulting(ca);
|
||||
}
|
||||
|
||||
void CBattleInterface::gateStateChanged(const EGateState state)
|
||||
void BattleInterface::gateStateChanged(const EGateState state)
|
||||
{
|
||||
if (siegeController)
|
||||
siegeController->gateStateChanged(state);
|
||||
}
|
||||
|
||||
void CBattleInterface::battleFinished(const BattleResult& br)
|
||||
void BattleInterface::battleFinished(const BattleResult& br)
|
||||
{
|
||||
bresult = &br;
|
||||
{
|
||||
@ -466,7 +466,7 @@ void CBattleInterface::battleFinished(const BattleResult& br)
|
||||
displayBattleFinished();
|
||||
}
|
||||
|
||||
void CBattleInterface::displayBattleFinished()
|
||||
void BattleInterface::displayBattleFinished()
|
||||
{
|
||||
CCS->curh->changeGraphic(ECursor::ADVENTURE,0);
|
||||
if(settings["session"]["spectate"].Bool() && settings["session"]["spectate-skip-battle-result"].Bool())
|
||||
@ -475,12 +475,12 @@ void CBattleInterface::displayBattleFinished()
|
||||
return;
|
||||
}
|
||||
|
||||
GH.pushInt(std::make_shared<CBattleResultWindow>(*bresult, *(this->curInt)));
|
||||
GH.pushInt(std::make_shared<BattleResultWindow>(*bresult, *(this->curInt)));
|
||||
curInt->waitWhileDialog(); // Avoid freeze when AI end turn after battle. Check bug #1897
|
||||
CPlayerInterface::battleInt = nullptr;
|
||||
}
|
||||
|
||||
void CBattleInterface::spellCast(const BattleSpellCast * sc)
|
||||
void BattleInterface::spellCast(const BattleSpellCast * sc)
|
||||
{
|
||||
const SpellID spellID = sc->spellID;
|
||||
const CSpell * spell = spellID.toSpell();
|
||||
@ -553,13 +553,13 @@ void CBattleInterface::spellCast(const BattleSpellCast * sc)
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::battleStacksEffectsSet(const SetStackEffect & sse)
|
||||
void BattleInterface::battleStacksEffectsSet(const SetStackEffect & sse)
|
||||
{
|
||||
if(stacksController->getActiveStack() != nullptr)
|
||||
fieldController->redrawBackgroundWithHexes();
|
||||
}
|
||||
|
||||
void CBattleInterface::setHeroAnimation(ui8 side, int phase)
|
||||
void BattleInterface::setHeroAnimation(ui8 side, int phase)
|
||||
{
|
||||
if(side == BattleSide::ATTACKER)
|
||||
{
|
||||
@ -573,7 +573,7 @@ void CBattleInterface::setHeroAnimation(ui8 side, int phase)
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::displayBattleLog(const std::vector<MetaString> & battleLog)
|
||||
void BattleInterface::displayBattleLog(const std::vector<MetaString> & battleLog)
|
||||
{
|
||||
for(const auto & line : battleLog)
|
||||
{
|
||||
@ -584,7 +584,7 @@ void CBattleInterface::displayBattleLog(const std::vector<MetaString> & battleLo
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::displaySpellAnimationQueue(const CSpell::TAnimationQueue & q, BattleHex destinationTile, bool isHit)
|
||||
void BattleInterface::displaySpellAnimationQueue(const CSpell::TAnimationQueue & q, BattleHex destinationTile, bool isHit)
|
||||
{
|
||||
for(const CSpell::TAnimation & animation : q)
|
||||
{
|
||||
@ -611,7 +611,7 @@ void CBattleInterface::displaySpellAnimationQueue(const CSpell::TAnimationQueue
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::displaySpellCast(SpellID spellID, BattleHex destinationTile)
|
||||
void BattleInterface::displaySpellCast(SpellID spellID, BattleHex destinationTile)
|
||||
{
|
||||
const CSpell * spell = spellID.toSpell();
|
||||
|
||||
@ -619,7 +619,7 @@ void CBattleInterface::displaySpellCast(SpellID spellID, BattleHex destinationTi
|
||||
displaySpellAnimationQueue(spell->animationInfo.cast, destinationTile, false);
|
||||
}
|
||||
|
||||
void CBattleInterface::displaySpellEffect(SpellID spellID, BattleHex destinationTile)
|
||||
void BattleInterface::displaySpellEffect(SpellID spellID, BattleHex destinationTile)
|
||||
{
|
||||
const CSpell *spell = spellID.toSpell();
|
||||
|
||||
@ -627,7 +627,7 @@ void CBattleInterface::displaySpellEffect(SpellID spellID, BattleHex destination
|
||||
displaySpellAnimationQueue(spell->animationInfo.affect, destinationTile, false);
|
||||
}
|
||||
|
||||
void CBattleInterface::displaySpellHit(SpellID spellID, BattleHex destinationTile)
|
||||
void BattleInterface::displaySpellHit(SpellID spellID, BattleHex destinationTile)
|
||||
{
|
||||
const CSpell * spell = spellID.toSpell();
|
||||
|
||||
@ -635,13 +635,13 @@ void CBattleInterface::displaySpellHit(SpellID spellID, BattleHex destinationTil
|
||||
displaySpellAnimationQueue(spell->animationInfo.hit, destinationTile, true);
|
||||
}
|
||||
|
||||
void CBattleInterface::setAnimSpeed(int set)
|
||||
void BattleInterface::setAnimSpeed(int set)
|
||||
{
|
||||
Settings speed = settings.write["battle"]["animationSpeed"];
|
||||
speed->Float() = float(set) / 100;
|
||||
}
|
||||
|
||||
int CBattleInterface::getAnimSpeed() const
|
||||
int BattleInterface::getAnimSpeed() const
|
||||
{
|
||||
if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-battle-speed"].isNull())
|
||||
return static_cast<int>(vstd::round(settings["session"]["spectate-battle-speed"].Float() *100));
|
||||
@ -649,12 +649,12 @@ int CBattleInterface::getAnimSpeed() const
|
||||
return static_cast<int>(vstd::round(settings["battle"]["animationSpeed"].Float() *100));
|
||||
}
|
||||
|
||||
CPlayerInterface *CBattleInterface::getCurrentPlayerInterface() const
|
||||
CPlayerInterface *BattleInterface::getCurrentPlayerInterface() const
|
||||
{
|
||||
return curInt.get();
|
||||
}
|
||||
|
||||
void CBattleInterface::trySetActivePlayer( PlayerColor player )
|
||||
void BattleInterface::trySetActivePlayer( PlayerColor player )
|
||||
{
|
||||
if ( attackerInt && attackerInt->playerID == player )
|
||||
curInt = attackerInt;
|
||||
@ -663,7 +663,7 @@ void CBattleInterface::trySetActivePlayer( PlayerColor player )
|
||||
curInt = defenderInt;
|
||||
}
|
||||
|
||||
void CBattleInterface::activateStack()
|
||||
void BattleInterface::activateStack()
|
||||
{
|
||||
if(!battleActionsStarted)
|
||||
return; //"show" function should re-call this function
|
||||
@ -681,7 +681,7 @@ void CBattleInterface::activateStack()
|
||||
GH.fakeMouseMove();
|
||||
}
|
||||
|
||||
void CBattleInterface::endAction(const BattleAction* action)
|
||||
void BattleInterface::endAction(const BattleAction* action)
|
||||
{
|
||||
const CStack *stack = curInt->cb->battleGetStackByID(action->stackNumber);
|
||||
|
||||
@ -710,7 +710,7 @@ void CBattleInterface::endAction(const BattleAction* action)
|
||||
// }
|
||||
}
|
||||
|
||||
void CBattleInterface::hideQueue()
|
||||
void BattleInterface::hideQueue()
|
||||
{
|
||||
Settings showQueue = settings.write["battle"]["showQueue"];
|
||||
showQueue->Bool() = false;
|
||||
@ -724,7 +724,7 @@ void CBattleInterface::hideQueue()
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::showQueue()
|
||||
void BattleInterface::showQueue()
|
||||
{
|
||||
Settings showQueue = settings.write["battle"]["showQueue"];
|
||||
showQueue->Bool() = true;
|
||||
@ -738,7 +738,7 @@ void CBattleInterface::showQueue()
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::startAction(const BattleAction* action)
|
||||
void BattleInterface::startAction(const BattleAction* action)
|
||||
{
|
||||
controlPanel->blockUI(true);
|
||||
|
||||
@ -778,13 +778,13 @@ void CBattleInterface::startAction(const BattleAction* action)
|
||||
effectsController->startAction(action);
|
||||
}
|
||||
|
||||
void CBattleInterface::waitForAnims()
|
||||
void BattleInterface::waitForAnims()
|
||||
{
|
||||
auto unlockPim = vstd::makeUnlockGuard(*CPlayerInterface::pim);
|
||||
animsAreDisplayed.waitWhileTrue();
|
||||
}
|
||||
|
||||
void CBattleInterface::tacticPhaseEnd()
|
||||
void BattleInterface::tacticPhaseEnd()
|
||||
{
|
||||
stacksController->setActiveStack(nullptr);
|
||||
controlPanel->blockUI(true);
|
||||
@ -796,7 +796,7 @@ static bool immobile(const CStack *s)
|
||||
return !s->Speed(0, true); //should bound stacks be immobile?
|
||||
}
|
||||
|
||||
void CBattleInterface::tacticNextStack(const CStack * current)
|
||||
void BattleInterface::tacticNextStack(const CStack * current)
|
||||
{
|
||||
if (!current)
|
||||
current = stacksController->getActiveStack();
|
||||
@ -820,12 +820,12 @@ void CBattleInterface::tacticNextStack(const CStack * current)
|
||||
|
||||
}
|
||||
|
||||
void CBattleInterface::obstaclePlaced(const std::vector<std::shared_ptr<const CObstacleInstance>> oi)
|
||||
void BattleInterface::obstaclePlaced(const std::vector<std::shared_ptr<const CObstacleInstance>> oi)
|
||||
{
|
||||
obstacleController->obstaclePlaced(oi);
|
||||
}
|
||||
|
||||
const CGHeroInstance *CBattleInterface::currentHero() const
|
||||
const CGHeroInstance *BattleInterface::currentHero() const
|
||||
{
|
||||
if (attackingHeroInstance->tempOwner == curInt->playerID)
|
||||
return attackingHeroInstance;
|
||||
@ -833,7 +833,7 @@ const CGHeroInstance *CBattleInterface::currentHero() const
|
||||
return defendingHeroInstance;
|
||||
}
|
||||
|
||||
InfoAboutHero CBattleInterface::enemyHero() const
|
||||
InfoAboutHero BattleInterface::enemyHero() const
|
||||
{
|
||||
InfoAboutHero ret;
|
||||
if (attackingHeroInstance->tempOwner == curInt->playerID)
|
||||
@ -844,7 +844,7 @@ InfoAboutHero CBattleInterface::enemyHero() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CBattleInterface::requestAutofightingAIToTakeAction()
|
||||
void BattleInterface::requestAutofightingAIToTakeAction()
|
||||
{
|
||||
assert(curInt->isAutoFightOn);
|
||||
|
||||
@ -884,12 +884,12 @@ void CBattleInterface::requestAutofightingAIToTakeAction()
|
||||
aiThread.detach();
|
||||
}
|
||||
|
||||
void CBattleInterface::showAll(SDL_Surface *to)
|
||||
void BattleInterface::showAll(SDL_Surface *to)
|
||||
{
|
||||
show(to);
|
||||
}
|
||||
|
||||
void CBattleInterface::show(SDL_Surface *to)
|
||||
void BattleInterface::show(SDL_Surface *to)
|
||||
{
|
||||
auto canvas = std::make_shared<CCanvas>(to);
|
||||
assert(to);
|
||||
@ -914,25 +914,25 @@ void CBattleInterface::show(SDL_Surface *to)
|
||||
//activateStack();
|
||||
}
|
||||
|
||||
void CBattleInterface::collectRenderableObjects(CBattleRenderer & renderer)
|
||||
void BattleInterface::collectRenderableObjects(BattleRenderer & renderer)
|
||||
{
|
||||
if (attackingHero)
|
||||
{
|
||||
renderer.insert(EBattleFieldLayer::HEROES, BattleHex(0),[this](CBattleRenderer::RendererPtr canvas)
|
||||
renderer.insert(EBattleFieldLayer::HEROES, BattleHex(0),[this](BattleRenderer::RendererPtr canvas)
|
||||
{
|
||||
attackingHero->show(canvas->getSurface());
|
||||
});
|
||||
}
|
||||
if (defendingHero)
|
||||
{
|
||||
renderer.insert(EBattleFieldLayer::HEROES, BattleHex(GameConstants::BFIELD_WIDTH-1),[this](CBattleRenderer::RendererPtr canvas)
|
||||
renderer.insert(EBattleFieldLayer::HEROES, BattleHex(GameConstants::BFIELD_WIDTH-1),[this](BattleRenderer::RendererPtr canvas)
|
||||
{
|
||||
defendingHero->show(canvas->getSurface());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::showInterface(std::shared_ptr<CCanvas> canvas)
|
||||
void BattleInterface::showInterface(std::shared_ptr<CCanvas> canvas)
|
||||
{
|
||||
//showing in-game console
|
||||
LOCPLINT->cingconsole->show(canvas->getSurface());
|
||||
@ -958,7 +958,7 @@ void CBattleInterface::showInterface(std::shared_ptr<CCanvas> canvas)
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::castThisSpell(SpellID spellID)
|
||||
void BattleInterface::castThisSpell(SpellID spellID)
|
||||
{
|
||||
actionsController->castThisSpell(spellID);
|
||||
}
|
||||
|
@ -32,26 +32,26 @@ struct CustomEffectInfo;
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
class CBattleHero;
|
||||
class BattleHero;
|
||||
class CCanvas;
|
||||
class CBattleResultWindow;
|
||||
class CStackQueue;
|
||||
class BattleResultWindow;
|
||||
class StackQueue;
|
||||
class CPlayerInterface;
|
||||
class CClickableHex;
|
||||
class ClickableHex;
|
||||
class CAnimation;
|
||||
struct BattleEffect;
|
||||
class IImage;
|
||||
class CStackQueue;
|
||||
class StackQueue;
|
||||
|
||||
class CBattleProjectileController;
|
||||
class CBattleSiegeController;
|
||||
class CBattleObstacleController;
|
||||
class CBattleFieldController;
|
||||
class CBattleRenderer;
|
||||
class CBattleControlPanel;
|
||||
class CBattleStacksController;
|
||||
class CBattleActionsController;
|
||||
class CBattleEffectsController;
|
||||
class BattleProjectileController;
|
||||
class BattleSiegeController;
|
||||
class BattleObstacleController;
|
||||
class BattleFieldController;
|
||||
class BattleRenderer;
|
||||
class BattleControlPanel;
|
||||
class BattleStacksController;
|
||||
class BattleActionsController;
|
||||
class BattleEffectsController;
|
||||
|
||||
/// Small struct which contains information about the id of the attacked stack, the damage dealt,...
|
||||
struct StackAttackedInfo
|
||||
@ -68,13 +68,13 @@ struct StackAttackedInfo
|
||||
|
||||
/// Big class which handles the overall battle interface actions and it is also responsible for
|
||||
/// drawing everything correctly.
|
||||
class CBattleInterface : public WindowBase
|
||||
class BattleInterface : public WindowBase
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<CBattleHero> attackingHero;
|
||||
std::shared_ptr<CBattleHero> defendingHero;
|
||||
std::shared_ptr<CStackQueue> queue;
|
||||
std::shared_ptr<CBattleControlPanel> controlPanel;
|
||||
std::shared_ptr<BattleHero> attackingHero;
|
||||
std::shared_ptr<BattleHero> defendingHero;
|
||||
std::shared_ptr<StackQueue> queue;
|
||||
std::shared_ptr<BattleControlPanel> controlPanel;
|
||||
|
||||
std::shared_ptr<CPlayerInterface> tacticianInterface; //used during tactics mode, points to the interface of player with higher tactics (can be either attacker or defender in hot-seat), valid onloy for human players
|
||||
std::shared_ptr<CPlayerInterface> attackerInt, defenderInt; //because LOCPLINT is not enough in hotSeat
|
||||
@ -102,13 +102,13 @@ private:
|
||||
|
||||
void setHeroAnimation(ui8 side, int phase);
|
||||
public:
|
||||
std::unique_ptr<CBattleProjectileController> projectilesController;
|
||||
std::unique_ptr<CBattleSiegeController> siegeController;
|
||||
std::unique_ptr<CBattleObstacleController> obstacleController;
|
||||
std::unique_ptr<CBattleFieldController> fieldController;
|
||||
std::unique_ptr<CBattleStacksController> stacksController;
|
||||
std::unique_ptr<CBattleActionsController> actionsController;
|
||||
std::unique_ptr<CBattleEffectsController> effectsController;
|
||||
std::unique_ptr<BattleProjectileController> projectilesController;
|
||||
std::unique_ptr<BattleSiegeController> siegeController;
|
||||
std::unique_ptr<BattleObstacleController> obstacleController;
|
||||
std::unique_ptr<BattleFieldController> fieldController;
|
||||
std::unique_ptr<BattleStacksController> stacksController;
|
||||
std::unique_ptr<BattleActionsController> actionsController;
|
||||
std::unique_ptr<BattleEffectsController> effectsController;
|
||||
|
||||
static CondSh<bool> animsAreDisplayed; //for waiting with the end of battle for end of anims
|
||||
static CondSh<BattleAction *> givenCommand; //data != nullptr if we have i.e. moved current unit
|
||||
@ -119,8 +119,8 @@ public:
|
||||
|
||||
const BattleResult *bresult; //result of a battle; if non-zero then display when all animations end
|
||||
|
||||
CBattleInterface(const CCreatureSet *army1, const CCreatureSet *army2, const CGHeroInstance *hero1, const CGHeroInstance *hero2, const SDL_Rect & myRect, std::shared_ptr<CPlayerInterface> att, std::shared_ptr<CPlayerInterface> defen, std::shared_ptr<CPlayerInterface> spectatorInt = nullptr);
|
||||
virtual ~CBattleInterface();
|
||||
BattleInterface(const CCreatureSet *army1, const CCreatureSet *army2, const CGHeroInstance *hero1, const CGHeroInstance *hero2, const SDL_Rect & myRect, std::shared_ptr<CPlayerInterface> att, std::shared_ptr<CPlayerInterface> defen, std::shared_ptr<CPlayerInterface> spectatorInt = nullptr);
|
||||
virtual ~BattleInterface();
|
||||
|
||||
void setPrintCellBorders(bool set); //if true, cell borders will be printed
|
||||
void setPrintStackRange(bool set); //if true,range of active stack will be printed
|
||||
@ -143,7 +143,7 @@ public:
|
||||
void show(SDL_Surface *to) override;
|
||||
void showAll(SDL_Surface *to) override;
|
||||
|
||||
void collectRenderableObjects(CBattleRenderer & renderer);
|
||||
void collectRenderableObjects(BattleRenderer & renderer);
|
||||
|
||||
//call-ins
|
||||
void startAction(const BattleAction* action);
|
||||
@ -184,9 +184,9 @@ public:
|
||||
|
||||
friend class CPlayerInterface;
|
||||
friend class CInGameConsole;
|
||||
friend class CStackQueue;
|
||||
friend class CBattleResultWindow;
|
||||
friend class CBattleHero;
|
||||
friend class StackQueue;
|
||||
friend class BattleResultWindow;
|
||||
friend class BattleHero;
|
||||
friend class CBattleStackAnimation;
|
||||
friend class CReverseAnimation;
|
||||
friend class CDefenceAnimation;
|
||||
@ -196,13 +196,13 @@ public:
|
||||
friend class CMeleeAttackAnimation;
|
||||
friend class CShootingAnimation;
|
||||
friend class CCastAnimation;
|
||||
friend class CClickableHex;
|
||||
friend class CBattleProjectileController;
|
||||
friend class CBattleSiegeController;
|
||||
friend class CBattleObstacleController;
|
||||
friend class CBattleFieldController;
|
||||
friend class CBattleControlPanel;
|
||||
friend class CBattleStacksController;
|
||||
friend class CBattleActionsController;
|
||||
friend class CBattleEffectsController;
|
||||
friend class ClickableHex;
|
||||
friend class BattleProjectileController;
|
||||
friend class BattleSiegeController;
|
||||
friend class BattleObstacleController;
|
||||
friend class BattleFieldController;
|
||||
friend class BattleControlPanel;
|
||||
friend class BattleStacksController;
|
||||
friend class BattleActionsController;
|
||||
friend class BattleEffectsController;
|
||||
};
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include "../../lib/CondSh.h"
|
||||
#include "../../lib/mapObjects/CGTownInstance.h"
|
||||
|
||||
void CBattleConsole::showAll(SDL_Surface * to)
|
||||
void BattleConsole::showAll(SDL_Surface * to)
|
||||
{
|
||||
Point textPos(pos.x + pos.w/2, pos.y + 17);
|
||||
|
||||
@ -67,7 +67,7 @@ void CBattleConsole::showAll(SDL_Surface * to)
|
||||
}
|
||||
}
|
||||
|
||||
bool CBattleConsole::addText(const std::string & text)
|
||||
bool BattleConsole::addText(const std::string & text)
|
||||
{
|
||||
logGlobal->trace("CBattleConsole message: %s", text);
|
||||
if(text.size()>70)
|
||||
@ -86,47 +86,47 @@ bool CBattleConsole::addText(const std::string & text)
|
||||
lastShown = (int)texts.size()-1;
|
||||
return true;
|
||||
}
|
||||
void CBattleConsole::scrollUp(ui32 by)
|
||||
void BattleConsole::scrollUp(ui32 by)
|
||||
{
|
||||
if(lastShown > static_cast<int>(by))
|
||||
lastShown -= by;
|
||||
}
|
||||
|
||||
void CBattleConsole::scrollDown(ui32 by)
|
||||
void BattleConsole::scrollDown(ui32 by)
|
||||
{
|
||||
if(lastShown + by < texts.size())
|
||||
lastShown += by;
|
||||
}
|
||||
|
||||
CBattleConsole::CBattleConsole(const Rect & position) : lastShown(-1)
|
||||
BattleConsole::BattleConsole(const Rect & position) : lastShown(-1)
|
||||
{
|
||||
pos += position.topLeft();
|
||||
pos.w = position.w;
|
||||
pos.h = position.h;
|
||||
}
|
||||
|
||||
void CBattleConsole::clearMatching(const std::string & Text)
|
||||
void BattleConsole::clearMatching(const std::string & Text)
|
||||
{
|
||||
if (ingcAlter == Text)
|
||||
clear();
|
||||
}
|
||||
|
||||
void CBattleConsole::clear()
|
||||
void BattleConsole::clear()
|
||||
{
|
||||
ingcAlter.clear();
|
||||
}
|
||||
|
||||
void CBattleConsole::write(const std::string & Text)
|
||||
void BattleConsole::write(const std::string & Text)
|
||||
{
|
||||
ingcAlter = Text;
|
||||
}
|
||||
|
||||
void CBattleConsole::lock(bool shouldLock)
|
||||
void BattleConsole::lock(bool shouldLock)
|
||||
{
|
||||
// no-op?
|
||||
}
|
||||
|
||||
void CBattleHero::show(SDL_Surface * to)
|
||||
void BattleHero::show(SDL_Surface * to)
|
||||
{
|
||||
auto flagFrame = flagAnimation->getImage(flagAnim, 0, true);
|
||||
|
||||
@ -175,14 +175,14 @@ void CBattleHero::show(SDL_Surface * to)
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleHero::setPhase(int newPhase)
|
||||
void BattleHero::setPhase(int newPhase)
|
||||
{
|
||||
nextPhase = newPhase;
|
||||
switchToNextPhase(); //immediately switch to next phase and then restore idling phase
|
||||
nextPhase = 0;
|
||||
}
|
||||
|
||||
void CBattleHero::hover(bool on)
|
||||
void BattleHero::hover(bool on)
|
||||
{
|
||||
//TODO: Make lines below work properly
|
||||
if (on)
|
||||
@ -191,7 +191,7 @@ void CBattleHero::hover(bool on)
|
||||
CCS->curh->changeGraphic(ECursor::COMBAT, 0);
|
||||
}
|
||||
|
||||
void CBattleHero::clickLeft(tribool down, bool previousState)
|
||||
void BattleHero::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(myOwner->actionsController->spellcastingModeActive()) //we are casting a spell
|
||||
return;
|
||||
@ -215,7 +215,7 @@ void CBattleHero::clickLeft(tribool down, bool previousState)
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleHero::clickRight(tribool down, bool previousState)
|
||||
void BattleHero::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
if(boost::logic::indeterminate(down))
|
||||
return;
|
||||
@ -229,11 +229,11 @@ void CBattleHero::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
auto h = flip ? myOwner->defendingHeroInstance : myOwner->attackingHeroInstance;
|
||||
targetHero.initFromHero(h, InfoAboutHero::EInfoLevel::INBATTLE);
|
||||
GH.pushIntT<CHeroInfoWindow>(targetHero, &windowPosition);
|
||||
GH.pushIntT<HeroInfoWindow>(targetHero, &windowPosition);
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleHero::switchToNextPhase()
|
||||
void BattleHero::switchToNextPhase()
|
||||
{
|
||||
if(phase != nextPhase)
|
||||
{
|
||||
@ -247,7 +247,7 @@ void CBattleHero::switchToNextPhase()
|
||||
currentFrame = firstFrame;
|
||||
}
|
||||
|
||||
CBattleHero::CBattleHero(const std::string & animationPath, bool flipG, PlayerColor player, const CGHeroInstance * hero, const CBattleInterface * owner):
|
||||
BattleHero::BattleHero(const std::string & animationPath, bool flipG, PlayerColor player, const CGHeroInstance * hero, const BattleInterface * owner):
|
||||
flip(flipG),
|
||||
myHero(hero),
|
||||
myOwner(owner),
|
||||
@ -274,9 +274,7 @@ CBattleHero::CBattleHero(const std::string & animationPath, bool flipG, PlayerCo
|
||||
switchToNextPhase();
|
||||
}
|
||||
|
||||
CBattleHero::~CBattleHero() = default;
|
||||
|
||||
CHeroInfoWindow::CHeroInfoWindow(const InfoAboutHero & hero, Point * position)
|
||||
HeroInfoWindow::HeroInfoWindow(const InfoAboutHero & hero, Point * position)
|
||||
: CWindowObject(RCLICK_POPUP | SHADOW_DISABLED, "CHRPOP")
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
@ -318,7 +316,7 @@ CHeroInfoWindow::CHeroInfoWindow(const InfoAboutHero & hero, Point * position)
|
||||
labels.push_back(std::make_shared<CLabel>(39, 186, EFonts::FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, std::to_string(currentSpellPoints) + "/" + std::to_string(maxSpellPoints)));
|
||||
}
|
||||
|
||||
CBattleOptionsWindow::CBattleOptionsWindow(CBattleInterface *owner):
|
||||
BattleOptionsWindow::BattleOptionsWindow(BattleInterface *owner):
|
||||
CWindowObject(PLAYER_COLORED, "comopbck.bmp")
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
@ -380,17 +378,17 @@ CBattleOptionsWindow::CBattleOptionsWindow(CBattleInterface *owner):
|
||||
labels.push_back(std::make_shared<CLabel>(61, 156, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[407]));
|
||||
}
|
||||
|
||||
void CBattleOptionsWindow::bDefaultf()
|
||||
void BattleOptionsWindow::bDefaultf()
|
||||
{
|
||||
//TODO: implement
|
||||
}
|
||||
|
||||
void CBattleOptionsWindow::bExitf()
|
||||
void BattleOptionsWindow::bExitf()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
CBattleResultWindow::CBattleResultWindow(const BattleResult & br, CPlayerInterface & _owner)
|
||||
BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface & _owner)
|
||||
: owner(_owner)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
@ -546,27 +544,25 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult & br, CPlayerInterfa
|
||||
}
|
||||
}
|
||||
|
||||
CBattleResultWindow::~CBattleResultWindow() = default;
|
||||
|
||||
void CBattleResultWindow::activate()
|
||||
void BattleResultWindow::activate()
|
||||
{
|
||||
owner.showingDialog->set(true);
|
||||
CIntObject::activate();
|
||||
}
|
||||
|
||||
void CBattleResultWindow::show(SDL_Surface * to)
|
||||
void BattleResultWindow::show(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::show(to);
|
||||
CCS->videoh->update(pos.x + 107, pos.y + 70, screen, true, false);
|
||||
}
|
||||
|
||||
void CBattleResultWindow::bExitf()
|
||||
void BattleResultWindow::bExitf()
|
||||
{
|
||||
CPlayerInterface &intTmp = owner; //copy reference because "this" will be destructed soon
|
||||
|
||||
close();
|
||||
|
||||
if(dynamic_cast<CBattleInterface*>(GH.topInt().get()))
|
||||
if(dynamic_cast<BattleInterface*>(GH.topInt().get()))
|
||||
GH.popInts(1); //pop battle interface if present
|
||||
|
||||
//Result window and battle interface are gone. We requested all dialogs to be closed before opening the battle,
|
||||
@ -575,7 +571,7 @@ void CBattleResultWindow::bExitf()
|
||||
CCS->videoh->close();
|
||||
}
|
||||
|
||||
void CClickableHex::hover(bool on)
|
||||
void ClickableHex::hover(bool on)
|
||||
{
|
||||
hovered = on;
|
||||
//Hoverable::hover(on);
|
||||
@ -586,12 +582,12 @@ void CClickableHex::hover(bool on)
|
||||
}
|
||||
}
|
||||
|
||||
CClickableHex::CClickableHex() : setAlterText(false), myNumber(-1), strictHovered(false), myInterface(nullptr)
|
||||
ClickableHex::ClickableHex() : setAlterText(false), myNumber(-1), strictHovered(false), myInterface(nullptr)
|
||||
{
|
||||
addUsedEvents(LCLICK | RCLICK | HOVER | MOVE);
|
||||
}
|
||||
|
||||
void CClickableHex::mouseMoved(const SDL_MouseMotionEvent &sEvent)
|
||||
void ClickableHex::mouseMoved(const SDL_MouseMotionEvent &sEvent)
|
||||
{
|
||||
strictHovered = myInterface->fieldController->isPixelInHex(Point(sEvent.x-pos.x, sEvent.y-pos.y));
|
||||
|
||||
@ -616,7 +612,7 @@ void CClickableHex::mouseMoved(const SDL_MouseMotionEvent &sEvent)
|
||||
}
|
||||
}
|
||||
|
||||
void CClickableHex::clickLeft(tribool down, bool previousState)
|
||||
void ClickableHex::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(!down && hovered && strictHovered) //we've been really clicked!
|
||||
{
|
||||
@ -624,7 +620,7 @@ void CClickableHex::clickLeft(tribool down, bool previousState)
|
||||
}
|
||||
}
|
||||
|
||||
void CClickableHex::clickRight(tribool down, bool previousState)
|
||||
void ClickableHex::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
const CStack * myst = myInterface->getCurrentPlayerInterface()->cb->battleGetStackByPos(myNumber); //stack info
|
||||
if(hovered && strictHovered && myst!=nullptr)
|
||||
@ -637,7 +633,7 @@ void CClickableHex::clickRight(tribool down, bool previousState)
|
||||
}
|
||||
}
|
||||
|
||||
CStackQueue::CStackQueue(bool Embedded, CBattleInterface * _owner)
|
||||
StackQueue::StackQueue(bool Embedded, BattleInterface * _owner)
|
||||
: embedded(Embedded),
|
||||
owner(_owner)
|
||||
{
|
||||
@ -674,9 +670,7 @@ CStackQueue::CStackQueue(bool Embedded, CBattleInterface * _owner)
|
||||
}
|
||||
}
|
||||
|
||||
CStackQueue::~CStackQueue() = default;
|
||||
|
||||
void CStackQueue::update()
|
||||
void StackQueue::update()
|
||||
{
|
||||
std::vector<battle::Units> queueData;
|
||||
|
||||
@ -694,12 +688,12 @@ void CStackQueue::update()
|
||||
stackBoxes[boxIndex]->setUnit(nullptr);
|
||||
}
|
||||
|
||||
int32_t CStackQueue::getSiegeShooterIconID()
|
||||
int32_t StackQueue::getSiegeShooterIconID()
|
||||
{
|
||||
return owner->siegeController->getSiegedTown()->town->faction->index;
|
||||
}
|
||||
|
||||
CStackQueue::StackBox::StackBox(CStackQueue * owner):
|
||||
StackQueue::StackBox::StackBox(StackQueue * owner):
|
||||
owner(owner)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
@ -726,7 +720,7 @@ CStackQueue::StackBox::StackBox(CStackQueue * owner):
|
||||
}
|
||||
}
|
||||
|
||||
void CStackQueue::StackBox::setUnit(const battle::Unit * unit, size_t turn)
|
||||
void StackQueue::StackBox::setUnit(const battle::Unit * unit, size_t turn)
|
||||
{
|
||||
if(unit)
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ class Unit;
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
struct SDL_Surface;
|
||||
class CBattleInterface;
|
||||
class BattleInterface;
|
||||
class CPicture;
|
||||
class CFilledTexture;
|
||||
class CButton;
|
||||
@ -39,7 +39,7 @@ class CAnimImage;
|
||||
class CPlayerInterface;
|
||||
|
||||
/// Class which shows the console at the bottom of the battle screen and manages the text of the console
|
||||
class CBattleConsole : public CIntObject, public IStatusBar
|
||||
class BattleConsole : public CIntObject, public IStatusBar
|
||||
{
|
||||
private:
|
||||
std::vector< std::string > texts; //a place where texts are stored
|
||||
@ -47,7 +47,7 @@ private:
|
||||
|
||||
std::string ingcAlter; //alternative text set by in-game console - very important!
|
||||
public:
|
||||
CBattleConsole(const Rect & position);
|
||||
BattleConsole(const Rect & position);
|
||||
void showAll(SDL_Surface * to = 0) override;
|
||||
|
||||
bool addText(const std::string &text); //adds text at the last position; returns false if failed (e.g. text longer than 70 characters)
|
||||
@ -62,7 +62,7 @@ public:
|
||||
};
|
||||
|
||||
/// Hero battle animation
|
||||
class CBattleHero : public CIntObject
|
||||
class BattleHero : public CIntObject
|
||||
{
|
||||
void switchToNextPhase();
|
||||
public:
|
||||
@ -72,7 +72,7 @@ public:
|
||||
std::shared_ptr<CAnimation> flagAnimation;
|
||||
|
||||
const CGHeroInstance * myHero; //this animation's hero instance
|
||||
const CBattleInterface * myOwner; //battle interface to which this animation is assigned
|
||||
const BattleInterface * myOwner; //battle interface to which this animation is assigned
|
||||
int phase; //stage of animation
|
||||
int nextPhase; //stage of animation to be set after current phase is fully displayed
|
||||
int currentFrame, firstFrame, lastFrame; //frame of animation
|
||||
@ -84,21 +84,20 @@ public:
|
||||
void hover(bool on) override;
|
||||
void clickLeft(tribool down, bool previousState) override; //call-in
|
||||
void clickRight(tribool down, bool previousState) override; //call-in
|
||||
CBattleHero(const std::string & animationPath, bool filpG, PlayerColor player, const CGHeroInstance * hero, const CBattleInterface * owner);
|
||||
~CBattleHero();
|
||||
BattleHero(const std::string & animationPath, bool filpG, PlayerColor player, const CGHeroInstance * hero, const BattleInterface * owner);
|
||||
};
|
||||
|
||||
class CHeroInfoWindow : public CWindowObject
|
||||
class HeroInfoWindow : public CWindowObject
|
||||
{
|
||||
private:
|
||||
std::vector<std::shared_ptr<CLabel>> labels;
|
||||
std::vector<std::shared_ptr<CAnimImage>> icons;
|
||||
public:
|
||||
CHeroInfoWindow(const InfoAboutHero & hero, Point * position);
|
||||
HeroInfoWindow(const InfoAboutHero & hero, Point * position);
|
||||
};
|
||||
|
||||
/// Class which manages the battle options window
|
||||
class CBattleOptionsWindow : public CWindowObject
|
||||
class BattleOptionsWindow : public CWindowObject
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<CButton> setToDefault;
|
||||
@ -107,14 +106,14 @@ private:
|
||||
std::vector<std::shared_ptr<CLabel>> labels;
|
||||
std::vector<std::shared_ptr<CToggleButton>> toggles;
|
||||
public:
|
||||
CBattleOptionsWindow(CBattleInterface * owner);
|
||||
BattleOptionsWindow(BattleInterface * owner);
|
||||
|
||||
void bDefaultf(); //default button callback
|
||||
void bExitf(); //exit button callback
|
||||
};
|
||||
|
||||
/// Class which is responsible for showing the battle result window
|
||||
class CBattleResultWindow : public WindowBase
|
||||
class BattleResultWindow : public WindowBase
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<CPicture> background;
|
||||
@ -124,8 +123,7 @@ private:
|
||||
std::shared_ptr<CTextBox> description;
|
||||
CPlayerInterface & owner;
|
||||
public:
|
||||
CBattleResultWindow(const BattleResult & br, CPlayerInterface & _owner);
|
||||
~CBattleResultWindow();
|
||||
BattleResultWindow(const BattleResult & br, CPlayerInterface & _owner);
|
||||
|
||||
void bExitf(); //exit button callback
|
||||
|
||||
@ -134,7 +132,7 @@ public:
|
||||
};
|
||||
|
||||
/// Class which stands for a single hex field on a battlefield
|
||||
class CClickableHex : public CIntObject
|
||||
class ClickableHex : public CIntObject
|
||||
{
|
||||
private:
|
||||
bool setAlterText; //if true, this hex has set alternative text in console and will clean it
|
||||
@ -143,22 +141,22 @@ public:
|
||||
//bool accessible; //if true, this hex is accessible for units
|
||||
//CStack * ourStack;
|
||||
bool strictHovered; //for determining if hex is hovered by mouse (this is different problem than hex's graphic hovering)
|
||||
CBattleInterface * myInterface; //interface that owns me
|
||||
BattleInterface * myInterface; //interface that owns me
|
||||
|
||||
//for user interactions
|
||||
void hover (bool on) override;
|
||||
void mouseMoved (const SDL_MouseMotionEvent &sEvent) override;
|
||||
void clickLeft(tribool down, bool previousState) override;
|
||||
void clickRight(tribool down, bool previousState) override;
|
||||
CClickableHex();
|
||||
ClickableHex();
|
||||
};
|
||||
|
||||
/// Shows the stack queue
|
||||
class CStackQueue : public CIntObject
|
||||
class StackQueue : public CIntObject
|
||||
{
|
||||
class StackBox : public CIntObject
|
||||
{
|
||||
CStackQueue * owner;
|
||||
StackQueue * owner;
|
||||
public:
|
||||
std::shared_ptr<CPicture> background;
|
||||
std::shared_ptr<CAnimImage> icon;
|
||||
@ -166,13 +164,13 @@ class CStackQueue : public CIntObject
|
||||
std::shared_ptr<CAnimImage> stateIcon;
|
||||
|
||||
void setUnit(const battle::Unit * unit, size_t turn = 0);
|
||||
StackBox(CStackQueue * owner);
|
||||
StackBox(StackQueue * owner);
|
||||
};
|
||||
|
||||
static const int QUEUE_SIZE = 10;
|
||||
std::shared_ptr<CFilledTexture> background;
|
||||
std::vector<std::shared_ptr<StackBox>> stackBoxes;
|
||||
CBattleInterface * owner;
|
||||
BattleInterface * owner;
|
||||
|
||||
std::shared_ptr<CAnimation> icons;
|
||||
std::shared_ptr<CAnimation> stateIcons;
|
||||
@ -181,7 +179,6 @@ class CStackQueue : public CIntObject
|
||||
public:
|
||||
const bool embedded;
|
||||
|
||||
CStackQueue(bool Embedded, CBattleInterface * _owner);
|
||||
~CStackQueue();
|
||||
StackQueue(bool Embedded, BattleInterface * _owner);
|
||||
void update();
|
||||
};
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "../../lib/battle/CObstacleInstance.h"
|
||||
#include "../../lib/ObstacleHandler.h"
|
||||
|
||||
CBattleObstacleController::CBattleObstacleController(CBattleInterface * owner):
|
||||
BattleObstacleController::BattleObstacleController(BattleInterface * owner):
|
||||
owner(owner)
|
||||
{
|
||||
auto obst = owner->curInt->cb->battleGetAllObstacles();
|
||||
@ -36,7 +36,7 @@ CBattleObstacleController::CBattleObstacleController(CBattleInterface * owner):
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleObstacleController::loadObstacleImage(const CObstacleInstance & oi)
|
||||
void BattleObstacleController::loadObstacleImage(const CObstacleInstance & oi)
|
||||
{
|
||||
std::string animationName;
|
||||
|
||||
@ -69,7 +69,7 @@ void CBattleObstacleController::loadObstacleImage(const CObstacleInstance & oi)
|
||||
obstacleAnimations[oi.uniqueID] = animationsCache[animationName];
|
||||
}
|
||||
|
||||
void CBattleObstacleController::obstaclePlaced(const std::vector<std::shared_ptr<const CObstacleInstance>> & obstacles)
|
||||
void BattleObstacleController::obstaclePlaced(const std::vector<std::shared_ptr<const CObstacleInstance>> & obstacles)
|
||||
{
|
||||
assert(obstaclesBeingPlaced.empty());
|
||||
for (auto const & oi : obstacles)
|
||||
@ -113,7 +113,7 @@ void CBattleObstacleController::obstaclePlaced(const std::vector<std::shared_ptr
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleObstacleController::showAbsoluteObstacles(std::shared_ptr<CCanvas> canvas, const Point & offset)
|
||||
void BattleObstacleController::showAbsoluteObstacles(std::shared_ptr<CCanvas> canvas, const Point & offset)
|
||||
{
|
||||
//Blit absolute obstacles
|
||||
for(auto & oi : owner->curInt->cb->battleGetAllObstacles())
|
||||
@ -127,7 +127,7 @@ void CBattleObstacleController::showAbsoluteObstacles(std::shared_ptr<CCanvas> c
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleObstacleController::collectRenderableObjects(CBattleRenderer & renderer)
|
||||
void BattleObstacleController::collectRenderableObjects(BattleRenderer & renderer)
|
||||
{
|
||||
for (auto obstacle : owner->curInt->cb->battleGetAllObstacles())
|
||||
{
|
||||
@ -137,7 +137,7 @@ void CBattleObstacleController::collectRenderableObjects(CBattleRenderer & rende
|
||||
if (obstacle->obstacleType == CObstacleInstance::MOAT)
|
||||
continue;
|
||||
|
||||
renderer.insert(EBattleFieldLayer::OBSTACLES, obstacle->pos, [this, obstacle]( CBattleRenderer::RendererPtr canvas ){
|
||||
renderer.insert(EBattleFieldLayer::OBSTACLES, obstacle->pos, [this, obstacle]( BattleRenderer::RendererPtr canvas ){
|
||||
auto img = getObstacleImage(*obstacle);
|
||||
if(img)
|
||||
{
|
||||
@ -148,7 +148,7 @@ void CBattleObstacleController::collectRenderableObjects(CBattleRenderer & rende
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<IImage> CBattleObstacleController::getObstacleImage(const CObstacleInstance & oi)
|
||||
std::shared_ptr<IImage> BattleObstacleController::getObstacleImage(const CObstacleInstance & oi)
|
||||
{
|
||||
int frameIndex = (owner->animCount+1) *25 / owner->getAnimSpeed();
|
||||
std::shared_ptr<CAnimation> animation;
|
||||
@ -178,7 +178,7 @@ std::shared_ptr<IImage> CBattleObstacleController::getObstacleImage(const CObsta
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Point CBattleObstacleController::getObstaclePosition(std::shared_ptr<IImage> image, const CObstacleInstance & obstacle)
|
||||
Point BattleObstacleController::getObstaclePosition(std::shared_ptr<IImage> image, const CObstacleInstance & obstacle)
|
||||
{
|
||||
int offset = obstacle.getAnimationYOffset(image->height());
|
||||
|
||||
|
@ -20,15 +20,15 @@ struct SDL_Surface;
|
||||
class IImage;
|
||||
class CCanvas;
|
||||
class CAnimation;
|
||||
class CBattleInterface;
|
||||
class CBattleRenderer;
|
||||
class BattleInterface;
|
||||
class BattleRenderer;
|
||||
struct Point;
|
||||
|
||||
class CBattleObstacleController
|
||||
class BattleObstacleController
|
||||
{
|
||||
std::map<std::string, std::shared_ptr<CAnimation>> animationsCache;
|
||||
|
||||
CBattleInterface * owner;
|
||||
BattleInterface * owner;
|
||||
|
||||
std::map<si32, std::shared_ptr<CAnimation>> obstacleAnimations;
|
||||
|
||||
@ -42,11 +42,11 @@ class CBattleObstacleController
|
||||
Point getObstaclePosition(std::shared_ptr<IImage> image, const CObstacleInstance & obstacle);
|
||||
|
||||
public:
|
||||
CBattleObstacleController(CBattleInterface * owner);
|
||||
BattleObstacleController(BattleInterface * owner);
|
||||
|
||||
void obstaclePlaced(const std::vector<std::shared_ptr<const CObstacleInstance>> & oi);
|
||||
void showObstacles(SDL_Surface *to, std::vector<std::shared_ptr<const CObstacleInstance>> &obstacles);
|
||||
void showAbsoluteObstacles(std::shared_ptr<CCanvas> canvas, const Point & offset);
|
||||
|
||||
void collectRenderableObjects(CBattleRenderer & renderer);
|
||||
void collectRenderableObjects(BattleRenderer & renderer);
|
||||
};
|
||||
|
@ -146,11 +146,11 @@ void ProjectileRay::show(std::shared_ptr<CCanvas> canvas)
|
||||
++step;
|
||||
}
|
||||
|
||||
CBattleProjectileController::CBattleProjectileController(CBattleInterface * owner):
|
||||
BattleProjectileController::BattleProjectileController(BattleInterface * owner):
|
||||
owner(owner)
|
||||
{}
|
||||
|
||||
const CCreature * CBattleProjectileController::getShooter(const CStack * stack)
|
||||
const CCreature * BattleProjectileController::getShooter(const CStack * stack)
|
||||
{
|
||||
const CCreature * creature = stack->getCreature();
|
||||
|
||||
@ -166,17 +166,17 @@ const CCreature * CBattleProjectileController::getShooter(const CStack * stack)
|
||||
return creature;
|
||||
}
|
||||
|
||||
bool CBattleProjectileController::stackUsesRayProjectile(const CStack * stack)
|
||||
bool BattleProjectileController::stackUsesRayProjectile(const CStack * stack)
|
||||
{
|
||||
return !getShooter(stack)->animation.projectileRay.empty();
|
||||
}
|
||||
|
||||
bool CBattleProjectileController::stackUsesMissileProjectile(const CStack * stack)
|
||||
bool BattleProjectileController::stackUsesMissileProjectile(const CStack * stack)
|
||||
{
|
||||
return !getShooter(stack)->animation.projectileImageName.empty();
|
||||
}
|
||||
|
||||
void CBattleProjectileController::initStackProjectile(const CStack * stack)
|
||||
void BattleProjectileController::initStackProjectile(const CStack * stack)
|
||||
{
|
||||
if (!stackUsesMissileProjectile(stack))
|
||||
return;
|
||||
@ -185,7 +185,7 @@ void CBattleProjectileController::initStackProjectile(const CStack * stack)
|
||||
projectilesCache[creature->animation.projectileImageName] = createProjectileImage(creature->animation.projectileImageName);
|
||||
}
|
||||
|
||||
std::shared_ptr<CAnimation> CBattleProjectileController::createProjectileImage(const std::string & path )
|
||||
std::shared_ptr<CAnimation> BattleProjectileController::createProjectileImage(const std::string & path )
|
||||
{
|
||||
std::shared_ptr<CAnimation> projectile = std::make_shared<CAnimation>(path);
|
||||
projectile->preload();
|
||||
@ -198,7 +198,7 @@ std::shared_ptr<CAnimation> CBattleProjectileController::createProjectileImage(c
|
||||
return projectile;
|
||||
}
|
||||
|
||||
std::shared_ptr<CAnimation> CBattleProjectileController::getProjectileImage(const CStack * stack)
|
||||
std::shared_ptr<CAnimation> BattleProjectileController::getProjectileImage(const CStack * stack)
|
||||
{
|
||||
const CCreature * creature = getShooter(stack);
|
||||
std::string imageName = creature->animation.projectileImageName;
|
||||
@ -209,7 +209,7 @@ std::shared_ptr<CAnimation> CBattleProjectileController::getProjectileImage(cons
|
||||
return projectilesCache[imageName];
|
||||
}
|
||||
|
||||
void CBattleProjectileController::emitStackProjectile(const CStack * stack)
|
||||
void BattleProjectileController::emitStackProjectile(const CStack * stack)
|
||||
{
|
||||
int stackID = stack ? stack->ID : -1;
|
||||
|
||||
@ -223,7 +223,7 @@ void CBattleProjectileController::emitStackProjectile(const CStack * stack)
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleProjectileController::showProjectiles(std::shared_ptr<CCanvas> canvas)
|
||||
void BattleProjectileController::showProjectiles(std::shared_ptr<CCanvas> canvas)
|
||||
{
|
||||
for ( auto it = projectiles.begin(); it != projectiles.end();)
|
||||
{
|
||||
@ -239,7 +239,7 @@ void CBattleProjectileController::showProjectiles(std::shared_ptr<CCanvas> canva
|
||||
}
|
||||
}
|
||||
|
||||
bool CBattleProjectileController::hasActiveProjectile(const CStack * stack)
|
||||
bool BattleProjectileController::hasActiveProjectile(const CStack * stack)
|
||||
{
|
||||
int stackID = stack ? stack->ID : -1;
|
||||
|
||||
@ -253,7 +253,7 @@ bool CBattleProjectileController::hasActiveProjectile(const CStack * stack)
|
||||
return false;
|
||||
}
|
||||
|
||||
int CBattleProjectileController::computeProjectileFlightTime( Point from, Point dest, double animSpeed)
|
||||
int BattleProjectileController::computeProjectileFlightTime( Point from, Point dest, double animSpeed)
|
||||
{
|
||||
double distanceSquared = (dest.x - from.x) * (dest.x - from.x) + (dest.y - from.y) * (dest.y - from.y);
|
||||
double distance = sqrt(distanceSquared);
|
||||
@ -264,7 +264,7 @@ int CBattleProjectileController::computeProjectileFlightTime( Point from, Point
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CBattleProjectileController::computeProjectileFrameID( Point from, Point dest, const CStack * stack)
|
||||
int BattleProjectileController::computeProjectileFrameID( Point from, Point dest, const CStack * stack)
|
||||
{
|
||||
const CCreature * creature = getShooter(stack);
|
||||
|
||||
@ -295,7 +295,7 @@ int CBattleProjectileController::computeProjectileFrameID( Point from, Point des
|
||||
return bestID;
|
||||
}
|
||||
|
||||
void CBattleProjectileController::createCatapultProjectile(const CStack * shooter, Point from, Point dest)
|
||||
void BattleProjectileController::createCatapultProjectile(const CStack * shooter, Point from, Point dest)
|
||||
{
|
||||
auto catapultProjectile = new ProjectileCatapult();
|
||||
|
||||
@ -312,7 +312,7 @@ void CBattleProjectileController::createCatapultProjectile(const CStack * shoote
|
||||
projectiles.push_back(std::shared_ptr<ProjectileBase>(catapultProjectile));
|
||||
}
|
||||
|
||||
void CBattleProjectileController::createProjectile(const CStack * shooter, const CStack * target, Point from, Point dest)
|
||||
void BattleProjectileController::createProjectile(const CStack * shooter, const CStack * target, Point from, Point dest)
|
||||
{
|
||||
assert(target);
|
||||
|
||||
@ -351,7 +351,7 @@ void CBattleProjectileController::createProjectile(const CStack * shooter, const
|
||||
projectiles.push_back(projectile);
|
||||
}
|
||||
|
||||
void CBattleProjectileController::createSpellProjectile(const CStack * shooter, const CStack * target, Point from, Point dest, const CSpell * spell)
|
||||
void BattleProjectileController::createSpellProjectile(const CStack * shooter, const CStack * target, Point from, Point dest, const CSpell * spell)
|
||||
{
|
||||
double projectileAngle = std::abs(atan2(dest.x - from.x, dest.y - from.y));
|
||||
std::string animToDisplay = spell->animationInfo.selectProjectile(projectileAngle);
|
||||
|
@ -23,7 +23,7 @@ struct Point;
|
||||
struct SDL_Surface;
|
||||
class CAnimation;
|
||||
class CCanvas;
|
||||
class CBattleInterface;
|
||||
class BattleInterface;
|
||||
|
||||
/// Small struct which contains information about the position and the velocity of a projectile
|
||||
struct ProjectileBase
|
||||
@ -70,9 +70,9 @@ struct ProjectileRay : ProjectileBase
|
||||
std::vector<CCreature::CreatureAnimation::RayColor> rayConfig;
|
||||
};
|
||||
|
||||
class CBattleProjectileController
|
||||
class BattleProjectileController
|
||||
{
|
||||
CBattleInterface * owner;
|
||||
BattleInterface * owner;
|
||||
|
||||
/// all projectiles loaded during current battle
|
||||
std::map<std::string, std::shared_ptr<CAnimation>> projectilesCache;
|
||||
@ -97,7 +97,7 @@ class CBattleProjectileController
|
||||
int computeProjectileFrameID( Point from, Point dest, const CStack * stack);
|
||||
int computeProjectileFlightTime( Point from, Point dest, double speed);
|
||||
public:
|
||||
CBattleProjectileController(CBattleInterface * owner);
|
||||
BattleProjectileController(BattleInterface * owner);
|
||||
|
||||
void showProjectiles(std::shared_ptr<CCanvas> canvas);
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "CBattleStacksController.h"
|
||||
#include "CBattleObstacleController.h"
|
||||
|
||||
void CBattleRenderer::collectObjects()
|
||||
void BattleRenderer::collectObjects()
|
||||
{
|
||||
owner->collectRenderableObjects(*this);
|
||||
owner->effectsController->collectRenderableObjects(*this);
|
||||
@ -27,7 +27,7 @@ void CBattleRenderer::collectObjects()
|
||||
owner->siegeController->collectRenderableObjects(*this);
|
||||
}
|
||||
|
||||
void CBattleRenderer::sortObjects()
|
||||
void BattleRenderer::sortObjects()
|
||||
{
|
||||
auto getRow = [](const RenderableInstance & object) -> int
|
||||
{
|
||||
@ -54,23 +54,23 @@ void CBattleRenderer::sortObjects()
|
||||
});
|
||||
}
|
||||
|
||||
void CBattleRenderer::renderObjects(CBattleRenderer::RendererPtr targetCanvas)
|
||||
void BattleRenderer::renderObjects(BattleRenderer::RendererPtr targetCanvas)
|
||||
{
|
||||
for (auto const & object : objects)
|
||||
object.functor(targetCanvas);
|
||||
}
|
||||
|
||||
CBattleRenderer::CBattleRenderer(CBattleInterface * owner):
|
||||
BattleRenderer::BattleRenderer(BattleInterface * owner):
|
||||
owner(owner)
|
||||
{
|
||||
}
|
||||
|
||||
void CBattleRenderer::insert(EBattleFieldLayer layer, BattleHex tile, CBattleRenderer::RenderFunctor functor)
|
||||
void BattleRenderer::insert(EBattleFieldLayer layer, BattleHex tile, BattleRenderer::RenderFunctor functor)
|
||||
{
|
||||
objects.push_back({ functor, layer, tile });
|
||||
}
|
||||
|
||||
void CBattleRenderer::execute(CBattleRenderer::RendererPtr targetCanvas)
|
||||
void BattleRenderer::execute(BattleRenderer::RendererPtr targetCanvas)
|
||||
{
|
||||
collectObjects();
|
||||
sortObjects();
|
||||
|
@ -24,7 +24,7 @@ VCMI_LIB_NAMESPACE_END
|
||||
//class CClickableHex;
|
||||
class CCanvas;
|
||||
//class IImage;
|
||||
class CBattleInterface;
|
||||
class BattleInterface;
|
||||
|
||||
enum class EBattleFieldLayer {
|
||||
// confirmed ordering requirements:
|
||||
@ -38,14 +38,14 @@ enum class EBattleFieldLayer {
|
||||
EFFECTS = 3, // after obstacles, battlements
|
||||
};
|
||||
|
||||
class CBattleRenderer
|
||||
class BattleRenderer
|
||||
{
|
||||
public:
|
||||
using RendererPtr = std::shared_ptr<CCanvas>;
|
||||
using RenderFunctor = std::function<void(RendererPtr)>;
|
||||
|
||||
private:
|
||||
CBattleInterface * owner;
|
||||
BattleInterface * owner;
|
||||
|
||||
struct RenderableInstance
|
||||
{
|
||||
@ -59,7 +59,7 @@ private:
|
||||
void sortObjects();
|
||||
void renderObjects(RendererPtr targetCanvas);
|
||||
public:
|
||||
CBattleRenderer(CBattleInterface * owner);
|
||||
BattleRenderer(BattleInterface * owner);
|
||||
|
||||
void insert(EBattleFieldLayer layer, BattleHex tile, RenderFunctor functor);
|
||||
void execute(RendererPtr targetCanvas);
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "../../lib/CStack.h"
|
||||
#include "../../lib/mapObjects/CGTownInstance.h"
|
||||
|
||||
std::string CBattleSiegeController::getWallPieceImageName(EWallVisual::EWallVisual what, EWallState::EWallState state) const
|
||||
std::string BattleSiegeController::getWallPieceImageName(EWallVisual::EWallVisual what, EWallState::EWallState state) const
|
||||
{
|
||||
auto getImageIndex = [&]() -> int
|
||||
{
|
||||
@ -106,7 +106,7 @@ std::string CBattleSiegeController::getWallPieceImageName(EWallVisual::EWallVisu
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleSiegeController::showWallPiece(std::shared_ptr<CCanvas> canvas, EWallVisual::EWallVisual what, const Point & offset)
|
||||
void BattleSiegeController::showWallPiece(std::shared_ptr<CCanvas> canvas, EWallVisual::EWallVisual what, const Point & offset)
|
||||
{
|
||||
auto & ci = town->town->clientInfo;
|
||||
auto const & pos = ci.siegePositions[what];
|
||||
@ -115,13 +115,13 @@ void CBattleSiegeController::showWallPiece(std::shared_ptr<CCanvas> canvas, EWal
|
||||
canvas->draw(wallPieceImages[what], offset + Point(pos.x, pos.y));
|
||||
}
|
||||
|
||||
std::string CBattleSiegeController::getBattleBackgroundName() const
|
||||
std::string BattleSiegeController::getBattleBackgroundName() const
|
||||
{
|
||||
const std::string & prefix = town->town->clientInfo.siegePrefix;
|
||||
return prefix + "BACK.BMP";
|
||||
}
|
||||
|
||||
bool CBattleSiegeController::getWallPieceExistance(EWallVisual::EWallVisual what) const
|
||||
bool BattleSiegeController::getWallPieceExistance(EWallVisual::EWallVisual what) const
|
||||
{
|
||||
//FIXME: use this instead of buildings test?
|
||||
//ui8 siegeLevel = owner->curInt->cb->battleGetSiegeLevel();
|
||||
@ -137,7 +137,7 @@ bool CBattleSiegeController::getWallPieceExistance(EWallVisual::EWallVisual what
|
||||
}
|
||||
}
|
||||
|
||||
BattleHex CBattleSiegeController::getWallPiecePosition(EWallVisual::EWallVisual what) const
|
||||
BattleHex BattleSiegeController::getWallPiecePosition(EWallVisual::EWallVisual what) const
|
||||
{
|
||||
static const std::array<BattleHex, 18> wallsPositions = {
|
||||
BattleHex::INVALID, // BACKGROUND, // handled separately
|
||||
@ -163,7 +163,7 @@ BattleHex CBattleSiegeController::getWallPiecePosition(EWallVisual::EWallVisual
|
||||
return wallsPositions[what];
|
||||
}
|
||||
|
||||
CBattleSiegeController::CBattleSiegeController(CBattleInterface * owner, const CGTownInstance *siegeTown):
|
||||
BattleSiegeController::BattleSiegeController(BattleInterface * owner, const CGTownInstance *siegeTown):
|
||||
owner(owner),
|
||||
town(siegeTown)
|
||||
{
|
||||
@ -181,12 +181,12 @@ CBattleSiegeController::CBattleSiegeController(CBattleInterface * owner, const C
|
||||
}
|
||||
}
|
||||
|
||||
const CCreature *CBattleSiegeController::getTurretCreature() const
|
||||
const CCreature *BattleSiegeController::getTurretCreature() const
|
||||
{
|
||||
return CGI->creh->objects[town->town->clientInfo.siegeShooter];
|
||||
}
|
||||
|
||||
Point CBattleSiegeController::getTurretCreaturePosition( BattleHex position ) const
|
||||
Point BattleSiegeController::getTurretCreaturePosition( BattleHex position ) const
|
||||
{
|
||||
// Turret positions are read out of the config/wall_pos.txt
|
||||
int posID = 0;
|
||||
@ -215,7 +215,7 @@ Point CBattleSiegeController::getTurretCreaturePosition( BattleHex position ) co
|
||||
return Point(0,0);
|
||||
}
|
||||
|
||||
void CBattleSiegeController::gateStateChanged(const EGateState state)
|
||||
void BattleSiegeController::gateStateChanged(const EGateState state)
|
||||
{
|
||||
auto oldState = owner->curInt->cb->battleGetGateState();
|
||||
bool playSound = false;
|
||||
@ -249,7 +249,7 @@ void CBattleSiegeController::gateStateChanged(const EGateState state)
|
||||
CCS->soundh->playSound(soundBase::DRAWBRG);
|
||||
}
|
||||
|
||||
void CBattleSiegeController::showAbsoluteObstacles(std::shared_ptr<CCanvas> canvas, const Point & offset)
|
||||
void BattleSiegeController::showAbsoluteObstacles(std::shared_ptr<CCanvas> canvas, const Point & offset)
|
||||
{
|
||||
if (getWallPieceExistance(EWallVisual::MOAT))
|
||||
showWallPiece(canvas, EWallVisual::MOAT, offset);
|
||||
@ -258,7 +258,7 @@ void CBattleSiegeController::showAbsoluteObstacles(std::shared_ptr<CCanvas> canv
|
||||
showWallPiece(canvas, EWallVisual::MOAT_BANK, offset);
|
||||
}
|
||||
|
||||
BattleHex CBattleSiegeController::getTurretBattleHex(EWallVisual::EWallVisual wallPiece) const
|
||||
BattleHex BattleSiegeController::getTurretBattleHex(EWallVisual::EWallVisual wallPiece) const
|
||||
{
|
||||
switch(wallPiece)
|
||||
{
|
||||
@ -270,7 +270,7 @@ BattleHex CBattleSiegeController::getTurretBattleHex(EWallVisual::EWallVisual wa
|
||||
return BattleHex::INVALID;
|
||||
}
|
||||
|
||||
const CStack * CBattleSiegeController::getTurretStack(EWallVisual::EWallVisual wallPiece) const
|
||||
const CStack * BattleSiegeController::getTurretStack(EWallVisual::EWallVisual wallPiece) const
|
||||
{
|
||||
for (auto & stack : owner->curInt->cb->battleGetAllStacks(true))
|
||||
{
|
||||
@ -281,7 +281,7 @@ const CStack * CBattleSiegeController::getTurretStack(EWallVisual::EWallVisual w
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CBattleSiegeController::collectRenderableObjects(CBattleRenderer & renderer)
|
||||
void BattleSiegeController::collectRenderableObjects(BattleRenderer & renderer)
|
||||
{
|
||||
for (int i = EWallVisual::WALL_FIRST; i <= EWallVisual::WALL_LAST; ++i)
|
||||
{
|
||||
@ -297,14 +297,14 @@ void CBattleSiegeController::collectRenderableObjects(CBattleRenderer & renderer
|
||||
wallPiece == EWallVisual::BOTTOM_BATTLEMENT ||
|
||||
wallPiece == EWallVisual::UPPER_BATTLEMENT)
|
||||
{
|
||||
renderer.insert( EBattleFieldLayer::STACKS, getWallPiecePosition(wallPiece), [this, wallPiece](CBattleRenderer::RendererPtr canvas){
|
||||
renderer.insert( EBattleFieldLayer::STACKS, getWallPiecePosition(wallPiece), [this, wallPiece](BattleRenderer::RendererPtr canvas){
|
||||
owner->stacksController->showStack(canvas, getTurretStack(wallPiece));
|
||||
});
|
||||
renderer.insert( EBattleFieldLayer::BATTLEMENTS, getWallPiecePosition(wallPiece), [this, wallPiece](CBattleRenderer::RendererPtr canvas){
|
||||
renderer.insert( EBattleFieldLayer::BATTLEMENTS, getWallPiecePosition(wallPiece), [this, wallPiece](BattleRenderer::RendererPtr canvas){
|
||||
showWallPiece(canvas, wallPiece, owner->pos.topLeft());
|
||||
});
|
||||
}
|
||||
renderer.insert( EBattleFieldLayer::WALLS, getWallPiecePosition(wallPiece), [this, wallPiece](CBattleRenderer::RendererPtr canvas){
|
||||
renderer.insert( EBattleFieldLayer::WALLS, getWallPiecePosition(wallPiece), [this, wallPiece](BattleRenderer::RendererPtr canvas){
|
||||
showWallPiece(canvas, wallPiece, owner->pos.topLeft());
|
||||
});
|
||||
|
||||
@ -312,7 +312,7 @@ void CBattleSiegeController::collectRenderableObjects(CBattleRenderer & renderer
|
||||
}
|
||||
}
|
||||
|
||||
bool CBattleSiegeController::isAttackableByCatapult(BattleHex hex) const
|
||||
bool BattleSiegeController::isAttackableByCatapult(BattleHex hex) const
|
||||
{
|
||||
if (owner->tacticsMode)
|
||||
return false;
|
||||
@ -325,7 +325,7 @@ bool CBattleSiegeController::isAttackableByCatapult(BattleHex hex) const
|
||||
return state != EWallState::DESTROYED && state != EWallState::NONE;
|
||||
}
|
||||
|
||||
void CBattleSiegeController::stackIsCatapulting(const CatapultAttack & ca)
|
||||
void BattleSiegeController::stackIsCatapulting(const CatapultAttack & ca)
|
||||
{
|
||||
if (ca.attacker != -1)
|
||||
{
|
||||
@ -362,7 +362,7 @@ void CBattleSiegeController::stackIsCatapulting(const CatapultAttack & ca)
|
||||
}
|
||||
}
|
||||
|
||||
const CGTownInstance *CBattleSiegeController::getSiegedTown() const
|
||||
const CGTownInstance *BattleSiegeController::getSiegedTown() const
|
||||
{
|
||||
return town;
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ VCMI_LIB_NAMESPACE_END
|
||||
struct Point;
|
||||
struct SDL_Surface;
|
||||
class CCanvas;
|
||||
class CBattleInterface;
|
||||
class CBattleRenderer;
|
||||
class BattleInterface;
|
||||
class BattleRenderer;
|
||||
class IImage;
|
||||
|
||||
namespace EWallVisual
|
||||
@ -66,9 +66,9 @@ namespace EWallVisual
|
||||
};
|
||||
}
|
||||
|
||||
class CBattleSiegeController
|
||||
class BattleSiegeController
|
||||
{
|
||||
CBattleInterface * owner;
|
||||
BattleInterface * owner;
|
||||
|
||||
/// besieged town
|
||||
const CGTownInstance *town;
|
||||
@ -91,7 +91,7 @@ class CBattleSiegeController
|
||||
const CStack * getTurretStack(EWallVisual::EWallVisual wallPiece) const;
|
||||
|
||||
public:
|
||||
CBattleSiegeController(CBattleInterface * owner, const CGTownInstance *siegeTown);
|
||||
BattleSiegeController(BattleInterface * owner, const CGTownInstance *siegeTown);
|
||||
|
||||
/// call-ins from server
|
||||
void gateStateChanged(const EGateState state);
|
||||
@ -99,7 +99,7 @@ public:
|
||||
|
||||
/// call-ins from other battle controllers
|
||||
void showAbsoluteObstacles(std::shared_ptr<CCanvas> canvas, const Point & offset);
|
||||
void collectRenderableObjects(CBattleRenderer & renderer);
|
||||
void collectRenderableObjects(BattleRenderer & renderer);
|
||||
|
||||
/// queries from other battle controllers
|
||||
bool isAttackableByCatapult(BattleHex hex) const;
|
||||
|
@ -35,9 +35,9 @@
|
||||
#include "../../lib/CStack.h"
|
||||
#include "../../lib/CondSh.h"
|
||||
|
||||
static void onAnimationFinished(const CStack *stack, std::weak_ptr<CCreatureAnimation> anim)
|
||||
static void onAnimationFinished(const CStack *stack, std::weak_ptr<CreatureAnimation> anim)
|
||||
{
|
||||
std::shared_ptr<CCreatureAnimation> animation = anim.lock();
|
||||
std::shared_ptr<CreatureAnimation> animation = anim.lock();
|
||||
if(!animation)
|
||||
return;
|
||||
|
||||
@ -61,7 +61,7 @@ static void onAnimationFinished(const CStack *stack, std::weak_ptr<CCreatureAnim
|
||||
animation->onAnimationReset += std::bind(&onAnimationFinished, stack, anim);
|
||||
}
|
||||
|
||||
CBattleStacksController::CBattleStacksController(CBattleInterface * owner):
|
||||
BattleStacksController::BattleStacksController(BattleInterface * owner):
|
||||
owner(owner),
|
||||
activeStack(nullptr),
|
||||
mouseHoveredStack(nullptr),
|
||||
@ -94,7 +94,7 @@ CBattleStacksController::CBattleStacksController(CBattleInterface * owner):
|
||||
}
|
||||
}
|
||||
|
||||
BattleHex CBattleStacksController::getStackCurrentPosition(const CStack * stack)
|
||||
BattleHex BattleStacksController::getStackCurrentPosition(const CStack * stack)
|
||||
{
|
||||
if ( !stackAnimation[stack->ID]->isMoving())
|
||||
return stack->getPosition();
|
||||
@ -117,7 +117,7 @@ BattleHex CBattleStacksController::getStackCurrentPosition(const CStack * stack)
|
||||
return stack->getPosition();
|
||||
}
|
||||
|
||||
void CBattleStacksController::collectRenderableObjects(CBattleRenderer & renderer)
|
||||
void BattleStacksController::collectRenderableObjects(BattleRenderer & renderer)
|
||||
{
|
||||
auto stacks = owner->curInt->cb->battleGetAllStacks(false);
|
||||
|
||||
@ -133,20 +133,20 @@ void CBattleStacksController::collectRenderableObjects(CBattleRenderer & rendere
|
||||
auto layer = stackAnimation[stack->ID]->isDead() ? EBattleFieldLayer::CORPSES : EBattleFieldLayer::STACKS;
|
||||
auto location = getStackCurrentPosition(stack);
|
||||
|
||||
renderer.insert(layer, location, [this, stack]( CBattleRenderer::RendererPtr renderer ){
|
||||
renderer.insert(layer, location, [this, stack]( BattleRenderer::RendererPtr renderer ){
|
||||
showStack(renderer, stack);
|
||||
});
|
||||
|
||||
if (stackNeedsAmountBox(stack))
|
||||
{
|
||||
renderer.insert(EBattleFieldLayer::STACK_AMOUNTS, location, [this, stack]( CBattleRenderer::RendererPtr renderer ){
|
||||
renderer.insert(EBattleFieldLayer::STACK_AMOUNTS, location, [this, stack]( BattleRenderer::RendererPtr renderer ){
|
||||
showStackAmountBox(renderer, stack);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleStacksController::stackReset(const CStack * stack)
|
||||
void BattleStacksController::stackReset(const CStack * stack)
|
||||
{
|
||||
auto iter = stackAnimation.find(stack->ID);
|
||||
|
||||
@ -170,7 +170,7 @@ void CBattleStacksController::stackReset(const CStack * stack)
|
||||
//TODO: handle more cases
|
||||
}
|
||||
|
||||
void CBattleStacksController::stackAdded(const CStack * stack)
|
||||
void BattleStacksController::stackAdded(const CStack * stack)
|
||||
{
|
||||
stackFacingRight[stack->ID] = stack->side == BattleSide::ATTACKER; // must be set before getting stack position
|
||||
|
||||
@ -199,7 +199,7 @@ void CBattleStacksController::stackAdded(const CStack * stack)
|
||||
stackAnimation[stack->ID]->setType(CCreatureAnim::HOLDING);
|
||||
}
|
||||
|
||||
void CBattleStacksController::setActiveStack(const CStack *stack)
|
||||
void BattleStacksController::setActiveStack(const CStack *stack)
|
||||
{
|
||||
if (activeStack) // update UI
|
||||
stackAnimation[activeStack->ID]->setBorderColor(AnimationControls::getNoBorder());
|
||||
@ -212,7 +212,7 @@ void CBattleStacksController::setActiveStack(const CStack *stack)
|
||||
owner->controlPanel->blockUI(activeStack == nullptr);
|
||||
}
|
||||
|
||||
void CBattleStacksController::setHoveredStack(const CStack *stack)
|
||||
void BattleStacksController::setHoveredStack(const CStack *stack)
|
||||
{
|
||||
if ( stack == mouseHoveredStack )
|
||||
return;
|
||||
@ -236,7 +236,7 @@ void CBattleStacksController::setHoveredStack(const CStack *stack)
|
||||
mouseHoveredStack = nullptr;
|
||||
}
|
||||
|
||||
bool CBattleStacksController::stackNeedsAmountBox(const CStack * stack)
|
||||
bool BattleStacksController::stackNeedsAmountBox(const CStack * stack)
|
||||
{
|
||||
BattleHex currentActionTarget;
|
||||
if(owner->curInt->curAction)
|
||||
@ -282,7 +282,7 @@ bool CBattleStacksController::stackNeedsAmountBox(const CStack * stack)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<IImage> CBattleStacksController::getStackAmountBox(const CStack * stack)
|
||||
std::shared_ptr<IImage> BattleStacksController::getStackAmountBox(const CStack * stack)
|
||||
{
|
||||
std::vector<si32> activeSpells = stack->activeSpells();
|
||||
|
||||
@ -303,7 +303,7 @@ std::shared_ptr<IImage> CBattleStacksController::getStackAmountBox(const CStack
|
||||
return amountEffNeutral;
|
||||
}
|
||||
|
||||
void CBattleStacksController::showStackAmountBox(std::shared_ptr<CCanvas> canvas, const CStack * stack)
|
||||
void BattleStacksController::showStackAmountBox(std::shared_ptr<CCanvas> canvas, const CStack * stack)
|
||||
{
|
||||
//blitting amount background box
|
||||
auto amountBG = getStackAmountBox(stack);
|
||||
@ -327,13 +327,13 @@ void CBattleStacksController::showStackAmountBox(std::shared_ptr<CCanvas> canvas
|
||||
canvas->drawText(textPos, EFonts::FONT_TINY, Colors::WHITE, ETextAlignment::CENTER, makeNumberShort(stack->getCount()));
|
||||
}
|
||||
|
||||
void CBattleStacksController::showStack(std::shared_ptr<CCanvas> canvas, const CStack * stack)
|
||||
void BattleStacksController::showStack(std::shared_ptr<CCanvas> canvas, const CStack * stack)
|
||||
{
|
||||
stackAnimation[stack->ID]->nextFrame(canvas, facingRight(stack)); // do actual blit
|
||||
stackAnimation[stack->ID]->incrementFrame(float(GH.mainFPSmng->getElapsedMilliseconds()) / 1000);
|
||||
}
|
||||
|
||||
void CBattleStacksController::updateBattleAnimations()
|
||||
void BattleStacksController::updateBattleAnimations()
|
||||
{
|
||||
for (auto & elem : currentAnimations)
|
||||
{
|
||||
@ -363,13 +363,13 @@ void CBattleStacksController::updateBattleAnimations()
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleStacksController::addNewAnim(CBattleAnimation *anim)
|
||||
void BattleStacksController::addNewAnim(CBattleAnimation *anim)
|
||||
{
|
||||
currentAnimations.push_back(anim);
|
||||
owner->animsAreDisplayed.setn(true);
|
||||
}
|
||||
|
||||
void CBattleStacksController::stackActivated(const CStack *stack) //TODO: check it all before game state is changed due to abilities
|
||||
void BattleStacksController::stackActivated(const CStack *stack) //TODO: check it all before game state is changed due to abilities
|
||||
{
|
||||
stackToActivate = stack;
|
||||
owner->waitForAnims();
|
||||
@ -377,7 +377,7 @@ void CBattleStacksController::stackActivated(const CStack *stack) //TODO: check
|
||||
owner->activateStack();
|
||||
}
|
||||
|
||||
void CBattleStacksController::stackRemoved(uint32_t stackID)
|
||||
void BattleStacksController::stackRemoved(uint32_t stackID)
|
||||
{
|
||||
if (getActiveStack() != nullptr)
|
||||
{
|
||||
@ -394,7 +394,7 @@ void CBattleStacksController::stackRemoved(uint32_t stackID)
|
||||
//todo: ensure that ghost stack animation has fadeout effect
|
||||
}
|
||||
|
||||
void CBattleStacksController::stacksAreAttacked(std::vector<StackAttackedInfo> attackedInfos)
|
||||
void BattleStacksController::stacksAreAttacked(std::vector<StackAttackedInfo> attackedInfos)
|
||||
{
|
||||
for(auto & attackedInfo : attackedInfos)
|
||||
{
|
||||
@ -417,13 +417,13 @@ void CBattleStacksController::stacksAreAttacked(std::vector<StackAttackedInfo> a
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleStacksController::stackMoved(const CStack *stack, std::vector<BattleHex> destHex, int distance)
|
||||
void BattleStacksController::stackMoved(const CStack *stack, std::vector<BattleHex> destHex, int distance)
|
||||
{
|
||||
addNewAnim(new CMovementAnimation(owner, stack, destHex, distance));
|
||||
owner->waitForAnims();
|
||||
}
|
||||
|
||||
void CBattleStacksController::stackAttacking( const CStack *attacker, BattleHex dest, const CStack *attacked, bool shooting )
|
||||
void BattleStacksController::stackAttacking( const CStack *attacker, BattleHex dest, const CStack *attacked, bool shooting )
|
||||
{
|
||||
if (shooting)
|
||||
{
|
||||
@ -436,7 +436,7 @@ void CBattleStacksController::stackAttacking( const CStack *attacker, BattleHex
|
||||
//waitForAnims();
|
||||
}
|
||||
|
||||
bool CBattleStacksController::shouldRotate(const CStack * stack, const BattleHex & oldPos, const BattleHex & nextHex)
|
||||
bool BattleStacksController::shouldRotate(const CStack * stack, const BattleHex & oldPos, const BattleHex & nextHex)
|
||||
{
|
||||
Point begPosition = getStackPositionAtHex(oldPos,stack);
|
||||
Point endPosition = getStackPositionAtHex(nextHex, stack);
|
||||
@ -450,7 +450,7 @@ bool CBattleStacksController::shouldRotate(const CStack * stack, const BattleHex
|
||||
}
|
||||
|
||||
|
||||
void CBattleStacksController::endAction(const BattleAction* action)
|
||||
void BattleStacksController::endAction(const BattleAction* action)
|
||||
{
|
||||
//check if we should reverse stacks
|
||||
//for some strange reason, it's not enough
|
||||
@ -467,7 +467,7 @@ void CBattleStacksController::endAction(const BattleAction* action)
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleStacksController::startAction(const BattleAction* action)
|
||||
void BattleStacksController::startAction(const BattleAction* action)
|
||||
{
|
||||
const CStack *stack = owner->curInt->cb->battleGetStackByID(action->stackNumber);
|
||||
setHoveredStack(nullptr);
|
||||
@ -487,7 +487,7 @@ void CBattleStacksController::startAction(const BattleAction* action)
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleStacksController::activateStack()
|
||||
void BattleStacksController::activateStack()
|
||||
{
|
||||
if ( !currentAnimations.empty())
|
||||
return;
|
||||
@ -524,39 +524,39 @@ void CBattleStacksController::activateStack()
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleStacksController::setSelectedStack(const CStack *stack)
|
||||
void BattleStacksController::setSelectedStack(const CStack *stack)
|
||||
{
|
||||
selectedStack = stack;
|
||||
}
|
||||
|
||||
const CStack* CBattleStacksController::getSelectedStack()
|
||||
const CStack* BattleStacksController::getSelectedStack()
|
||||
{
|
||||
return selectedStack;
|
||||
}
|
||||
|
||||
const CStack* CBattleStacksController::getActiveStack()
|
||||
const CStack* BattleStacksController::getActiveStack()
|
||||
{
|
||||
return activeStack;
|
||||
}
|
||||
|
||||
bool CBattleStacksController::facingRight(const CStack * stack)
|
||||
bool BattleStacksController::facingRight(const CStack * stack)
|
||||
{
|
||||
return stackFacingRight[stack->ID];
|
||||
}
|
||||
|
||||
bool CBattleStacksController::activeStackSpellcaster()
|
||||
bool BattleStacksController::activeStackSpellcaster()
|
||||
{
|
||||
return stackCanCastSpell;
|
||||
}
|
||||
|
||||
SpellID CBattleStacksController::activeStackSpellToCast()
|
||||
SpellID BattleStacksController::activeStackSpellToCast()
|
||||
{
|
||||
if (!stackCanCastSpell)
|
||||
return SpellID::NONE;
|
||||
return SpellID(creatureSpellToCast);
|
||||
}
|
||||
|
||||
Point CBattleStacksController::getStackPositionAtHex(BattleHex hexNum, const CStack * stack)
|
||||
Point BattleStacksController::getStackPositionAtHex(BattleHex hexNum, const CStack * stack)
|
||||
{
|
||||
Point ret(-500, -500); //returned value
|
||||
if(stack && stack->initialPosition < 0) //creatures in turrets
|
||||
|
@ -24,16 +24,16 @@ struct SDL_Surface;
|
||||
struct StackAttackedInfo;
|
||||
|
||||
class CCanvas;
|
||||
class CBattleInterface;
|
||||
class BattleInterface;
|
||||
class CBattleAnimation;
|
||||
class CCreatureAnimation;
|
||||
class CreatureAnimation;
|
||||
class CBattleAnimation;
|
||||
class CBattleRenderer;
|
||||
class BattleRenderer;
|
||||
class IImage;
|
||||
|
||||
class CBattleStacksController
|
||||
class BattleStacksController
|
||||
{
|
||||
CBattleInterface * owner;
|
||||
BattleInterface * owner;
|
||||
|
||||
std::shared_ptr<IImage> amountNormal;
|
||||
std::shared_ptr<IImage> amountNegative;
|
||||
@ -41,7 +41,7 @@ class CBattleStacksController
|
||||
std::shared_ptr<IImage> amountEffNeutral;
|
||||
|
||||
std::vector<CBattleAnimation *> currentAnimations; //currently displayed animations <anim, initialized>
|
||||
std::map<int32_t, std::shared_ptr<CCreatureAnimation>> stackAnimation; //animations of creatures from fighting armies (order by BattleInfo's stacks' ID)
|
||||
std::map<int32_t, std::shared_ptr<CreatureAnimation>> stackAnimation; //animations of creatures from fighting armies (order by BattleInfo's stacks' ID)
|
||||
std::map<int, bool> stackFacingRight; // <creatureID, if false reverse creature's animation> //TODO: move it to battle callback
|
||||
|
||||
const CStack *activeStack; //number of active stack; nullptr - no one
|
||||
@ -61,7 +61,7 @@ class CBattleStacksController
|
||||
std::shared_ptr<IImage> getStackAmountBox(const CStack * stack);
|
||||
|
||||
public:
|
||||
CBattleStacksController(CBattleInterface * owner);
|
||||
BattleStacksController(BattleInterface * owner);
|
||||
|
||||
bool shouldRotate(const CStack * stack, const BattleHex & oldPos, const BattleHex & nextHex);
|
||||
bool facingRight(const CStack * stack);
|
||||
@ -89,7 +89,7 @@ public:
|
||||
void showAliveStack(std::shared_ptr<CCanvas> canvas, const CStack * stack);
|
||||
void showStack(std::shared_ptr<CCanvas> canvas, const CStack * stack);
|
||||
|
||||
void collectRenderableObjects(CBattleRenderer & renderer);
|
||||
void collectRenderableObjects(BattleRenderer & renderer);
|
||||
|
||||
void addNewAnim(CBattleAnimation *anim); //adds new anim to pendingAnims
|
||||
void updateBattleAnimations();
|
||||
|
@ -34,13 +34,13 @@ SDL_Color AnimationControls::getNoBorder()
|
||||
return creatureNoBorder;
|
||||
}
|
||||
|
||||
std::shared_ptr<CCreatureAnimation> AnimationControls::getAnimation(const CCreature * creature)
|
||||
std::shared_ptr<CreatureAnimation> AnimationControls::getAnimation(const CCreature * creature)
|
||||
{
|
||||
auto func = std::bind(&AnimationControls::getCreatureAnimationSpeed, creature, _1, _2);
|
||||
return std::make_shared<CCreatureAnimation>(creature->animDefName, func);
|
||||
return std::make_shared<CreatureAnimation>(creature->animDefName, func);
|
||||
}
|
||||
|
||||
float AnimationControls::getCreatureAnimationSpeed(const CCreature * creature, const CCreatureAnimation * anim, size_t group)
|
||||
float AnimationControls::getCreatureAnimationSpeed(const CCreature * creature, const CreatureAnimation * anim, size_t group)
|
||||
{
|
||||
CCreatureAnim::EAnimType type = CCreatureAnim::EAnimType(group);
|
||||
|
||||
@ -133,12 +133,12 @@ float AnimationControls::getFlightDistance(const CCreature * creature)
|
||||
return static_cast<float>(creature->animation.flightAnimationDistance * 200);
|
||||
}
|
||||
|
||||
CCreatureAnim::EAnimType CCreatureAnimation::getType() const
|
||||
CCreatureAnim::EAnimType CreatureAnimation::getType() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
void CCreatureAnimation::setType(CCreatureAnim::EAnimType type)
|
||||
void CreatureAnimation::setType(CCreatureAnim::EAnimType type)
|
||||
{
|
||||
this->type = type;
|
||||
currentFrame = 0;
|
||||
@ -147,7 +147,7 @@ void CCreatureAnimation::setType(CCreatureAnim::EAnimType type)
|
||||
play();
|
||||
}
|
||||
|
||||
void CCreatureAnimation::shiftColor(const ColorShifter* shifter)
|
||||
void CreatureAnimation::shiftColor(const ColorShifter* shifter)
|
||||
{
|
||||
if(forward)
|
||||
forward->shiftColor(shifter);
|
||||
@ -156,7 +156,7 @@ void CCreatureAnimation::shiftColor(const ColorShifter* shifter)
|
||||
reverse->shiftColor(shifter);
|
||||
}
|
||||
|
||||
CCreatureAnimation::CCreatureAnimation(const std::string & name_, TSpeedController controller)
|
||||
CreatureAnimation::CreatureAnimation(const std::string & name_, TSpeedController controller)
|
||||
: name(name_),
|
||||
speed(0.1f),
|
||||
currentFrame(0),
|
||||
@ -203,7 +203,7 @@ CCreatureAnimation::CCreatureAnimation(const std::string & name_, TSpeedControll
|
||||
play();
|
||||
}
|
||||
|
||||
void CCreatureAnimation::endAnimation()
|
||||
void CreatureAnimation::endAnimation()
|
||||
{
|
||||
once = false;
|
||||
auto copy = onAnimationReset;
|
||||
@ -211,7 +211,7 @@ void CCreatureAnimation::endAnimation()
|
||||
copy();
|
||||
}
|
||||
|
||||
bool CCreatureAnimation::incrementFrame(float timePassed)
|
||||
bool CreatureAnimation::incrementFrame(float timePassed)
|
||||
{
|
||||
elapsedTime += timePassed;
|
||||
currentFrame += timePassed * speed;
|
||||
@ -236,27 +236,27 @@ bool CCreatureAnimation::incrementFrame(float timePassed)
|
||||
return false;
|
||||
}
|
||||
|
||||
void CCreatureAnimation::setBorderColor(SDL_Color palette)
|
||||
void CreatureAnimation::setBorderColor(SDL_Color palette)
|
||||
{
|
||||
border = palette;
|
||||
}
|
||||
|
||||
int CCreatureAnimation::getWidth() const
|
||||
int CreatureAnimation::getWidth() const
|
||||
{
|
||||
return fullWidth;
|
||||
}
|
||||
|
||||
int CCreatureAnimation::getHeight() const
|
||||
int CreatureAnimation::getHeight() const
|
||||
{
|
||||
return fullHeight;
|
||||
}
|
||||
|
||||
float CCreatureAnimation::getCurrentFrame() const
|
||||
float CreatureAnimation::getCurrentFrame() const
|
||||
{
|
||||
return currentFrame;
|
||||
}
|
||||
|
||||
void CCreatureAnimation::playOnce( CCreatureAnim::EAnimType type )
|
||||
void CreatureAnimation::playOnce( CCreatureAnim::EAnimType type )
|
||||
{
|
||||
setType(type);
|
||||
once = true;
|
||||
@ -294,14 +294,14 @@ static SDL_Color addColors(const SDL_Color & base, const SDL_Color & over)
|
||||
);
|
||||
}
|
||||
|
||||
void CCreatureAnimation::genBorderPalette(IImage::BorderPallete & target)
|
||||
void CreatureAnimation::genBorderPalette(IImage::BorderPallete & target)
|
||||
{
|
||||
target[0] = genBorderColor(getBorderStrength(elapsedTime), border);
|
||||
target[1] = addColors(genShadow(128), genBorderColor(getBorderStrength(elapsedTime), border));
|
||||
target[2] = addColors(genShadow(64), genBorderColor(getBorderStrength(elapsedTime), border));
|
||||
}
|
||||
|
||||
void CCreatureAnimation::nextFrame(std::shared_ptr<CCanvas> canvas, bool facingRight)
|
||||
void CreatureAnimation::nextFrame(std::shared_ptr<CCanvas> canvas, bool facingRight)
|
||||
{
|
||||
size_t frame = static_cast<size_t>(floor(currentFrame));
|
||||
|
||||
@ -323,24 +323,24 @@ void CCreatureAnimation::nextFrame(std::shared_ptr<CCanvas> canvas, bool facingR
|
||||
}
|
||||
}
|
||||
|
||||
int CCreatureAnimation::framesInGroup(CCreatureAnim::EAnimType group) const
|
||||
int CreatureAnimation::framesInGroup(CCreatureAnim::EAnimType group) const
|
||||
{
|
||||
return static_cast<int>(forward->size(group));
|
||||
}
|
||||
|
||||
bool CCreatureAnimation::isDead() const
|
||||
bool CreatureAnimation::isDead() const
|
||||
{
|
||||
return getType() == CCreatureAnim::DEAD
|
||||
|| getType() == CCreatureAnim::DEAD_RANGED;
|
||||
}
|
||||
|
||||
bool CCreatureAnimation::isDying() const
|
||||
bool CreatureAnimation::isDying() const
|
||||
{
|
||||
return getType() == CCreatureAnim::DEATH
|
||||
|| getType() == CCreatureAnim::DEATH_RANGED;
|
||||
}
|
||||
|
||||
bool CCreatureAnimation::isDeadOrDying() const
|
||||
bool CreatureAnimation::isDeadOrDying() const
|
||||
{
|
||||
return getType() == CCreatureAnim::DEAD
|
||||
|| getType() == CCreatureAnim::DEATH
|
||||
@ -348,13 +348,13 @@ bool CCreatureAnimation::isDeadOrDying() const
|
||||
|| getType() == CCreatureAnim::DEATH_RANGED;
|
||||
}
|
||||
|
||||
bool CCreatureAnimation::isIdle() const
|
||||
bool CreatureAnimation::isIdle() const
|
||||
{
|
||||
return getType() == CCreatureAnim::HOLDING
|
||||
|| getType() == CCreatureAnim::MOUSEON;
|
||||
}
|
||||
|
||||
bool CCreatureAnimation::isMoving() const
|
||||
bool CreatureAnimation::isMoving() const
|
||||
{
|
||||
return getType() == CCreatureAnim::MOVE_START
|
||||
|| getType() == CCreatureAnim::MOVING
|
||||
@ -363,19 +363,19 @@ bool CCreatureAnimation::isMoving() const
|
||||
|| getType() == CCreatureAnim::TURN_R;
|
||||
}
|
||||
|
||||
bool CCreatureAnimation::isShooting() const
|
||||
bool CreatureAnimation::isShooting() const
|
||||
{
|
||||
return getType() == CCreatureAnim::SHOOT_UP
|
||||
|| getType() == CCreatureAnim::SHOOT_FRONT
|
||||
|| getType() == CCreatureAnim::SHOOT_DOWN;
|
||||
}
|
||||
|
||||
void CCreatureAnimation::pause()
|
||||
void CreatureAnimation::pause()
|
||||
{
|
||||
speed = 0;
|
||||
}
|
||||
|
||||
void CCreatureAnimation::play()
|
||||
void CreatureAnimation::play()
|
||||
{
|
||||
//logAnim->trace("Play %s group %d at %d:%d", name, static_cast<int>(getType()), pos.x, pos.y);
|
||||
speed = 0;
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "../gui/CAnimation.h"
|
||||
|
||||
class CIntObject;
|
||||
class CCreatureAnimation;
|
||||
class CreatureAnimation;
|
||||
class CCanvas;
|
||||
|
||||
/// Namespace for some common controls of animations
|
||||
@ -26,10 +26,10 @@ namespace AnimationControls
|
||||
SDL_Color getNoBorder();
|
||||
|
||||
/// creates animation object with preset speed control
|
||||
std::shared_ptr<CCreatureAnimation> getAnimation(const CCreature * creature);
|
||||
std::shared_ptr<CreatureAnimation> getAnimation(const CCreature * creature);
|
||||
|
||||
/// returns animation speed of specific group, taking in mind game setting (in frames per second)
|
||||
float getCreatureAnimationSpeed(const CCreature * creature, const CCreatureAnimation * anim, size_t groupID);
|
||||
float getCreatureAnimationSpeed(const CCreature * creature, const CreatureAnimation * anim, size_t groupID);
|
||||
|
||||
/// returns how far projectile should move each frame
|
||||
/// TODO: make it time-based
|
||||
@ -50,10 +50,10 @@ namespace AnimationControls
|
||||
|
||||
/// Class which manages animations of creatures/units inside battles
|
||||
/// TODO: split into constant image container and class that does *control* of animation
|
||||
class CCreatureAnimation : public CIntObject
|
||||
class CreatureAnimation : public CIntObject
|
||||
{
|
||||
public:
|
||||
typedef std::function<float(CCreatureAnimation *, size_t)> TSpeedController;
|
||||
typedef std::function<float(CreatureAnimation *, size_t)> TSpeedController;
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
@ -97,7 +97,7 @@ public:
|
||||
/// name - path to .def file, relative to SPRITES/ directory
|
||||
/// controller - function that will return for how long *each* frame
|
||||
/// in specified group of animation should be played, measured in seconds
|
||||
CCreatureAnimation(const std::string & name_, TSpeedController speedController);
|
||||
CreatureAnimation(const std::string & name_, TSpeedController speedController);
|
||||
|
||||
void setType(CCreatureAnim::EAnimType type); //sets type of animation and cleares framecount
|
||||
CCreatureAnim::EAnimType getType() const; //returns type of animation
|
||||
|
Loading…
Reference in New Issue
Block a user