1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-21 21:17:49 +02:00

- Changed visibility of curInt member of BattleInterface from public to private and provided a getter method

This commit is contained in:
beegee1 2013-11-03 16:44:47 +00:00
parent 0e3eae3095
commit 94bee3fd1b
4 changed files with 19 additions and 13 deletions

View File

@ -138,7 +138,7 @@ CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attac
assert(attackingStack && "attackingStack is nullptr in CBattleAttack::CBattleAttack !\n");
bool isCatapultAttack = attackingStack->hasBonusOfType(Bonus::CATAPULT)
&& owner->curInt->cb->battleHexToWallPart(_dest) >= 0;
&& owner->getCurrentPlayerInterface()->cb->battleHexToWallPart(_dest) >= 0;
assert(attackedStack || isCatapultAttack);
attackingStackPosBeforeReturn = attackingStack->position;
@ -185,7 +185,7 @@ bool CDefenceAnimation::init()
//reverse unit if necessary
if (attacker && owner->curInt->cb->isToReverse(stack->position, attacker->position, owner->creDir[stack->ID], attacker->doubleWide(), owner->creDir[attacker->ID]))
if (attacker && owner->getCurrentPlayerInterface()->cb->isToReverse(stack->position, attacker->position, owner->creDir[stack->ID], attacker->doubleWide(), owner->creDir[attacker->ID]))
{
owner->addNewAnim(new CReverseAnimation(owner, stack, stack->position, true));
return false;
@ -309,7 +309,7 @@ bool CMeleeAttackAnimation::init()
return false;
}
bool toReverse = owner->curInt->cb->isToReverse(attackingStackPosBeforeReturn, dest, owner->creDir[stack->ID], attackedStack->doubleWide(), owner->creDir[attackedStack->ID]);
bool toReverse = owner->getCurrentPlayerInterface()->cb->isToReverse(attackingStackPosBeforeReturn, dest, owner->creDir[stack->ID], attackedStack->doubleWide(), owner->creDir[attackedStack->ID]);
if (toReverse)
{
@ -668,7 +668,7 @@ bool CShootingAnimation::init()
}
//reverse unit if necessary
if (attackingStack && attackedStack && owner->curInt->cb->isToReverse(attackingStack->position, attackedStack->position, owner->creDir[attackingStack->ID], attackingStack->doubleWide(), owner->creDir[attackedStack->ID]))
if (attackingStack && attackedStack && owner->getCurrentPlayerInterface()->cb->isToReverse(attackingStack->position, attackedStack->position, owner->creDir[attackingStack->ID], attackingStack->doubleWide(), owner->creDir[attackedStack->ID]))
{
owner->addNewAnim(new CReverseAnimation(owner, attackingStack, attackingStack->position, true));
return false;
@ -902,7 +902,7 @@ bool CSpellEffectAnimation::init()
{
if(effect == -1 || graphics->battleACToDef[effect].size() != 0)
{
const CStack* destStack = owner->curInt->cb->battleGetStackByPos(destTile, false);
const CStack* destStack = owner->getCurrentPlayerInterface()->cb->battleGetStackByPos(destTile, false);
Rect &tilePos = owner->bfield[destTile]->pos;
BattleEffect be;
be.effectID = ID;

View File

@ -1643,6 +1643,11 @@ int CBattleInterface::getAnimSpeed() const
return vstd::round(settings["battle"]["animationSpeed"].Float() * 100);
}
CPlayerInterface * CBattleInterface::getCurrentPlayerInterface() const
{
return curInt.get();
}
void CBattleInterface::setActiveStack(const CStack * stack)
{
if (activeStack) // update UI

View File

@ -213,6 +213,7 @@ private:
} * siegeH;
shared_ptr<CPlayerInterface> attackerInt, defenderInt; //because LOCPLINT is not enough in hotSeat
shared_ptr<CPlayerInterface> curInt; //current player interface
const CGHeroInstance * getActiveHero(); //returns hero that can currently cast a spell
/** Methods for displaying battle screen */
@ -243,7 +244,6 @@ private:
/** End of battle screen blitting methods */
public:
shared_ptr<CPlayerInterface> curInt; //current player interface
std::list<std::pair<CBattleAnimation *, bool> > pendingAnims; //currently displayed animations <anim, initialized>
void addNewAnim(CBattleAnimation * anim); //adds new anim to pendingAnims
ui32 animIDhelper; //for giving IDs for animations
@ -258,6 +258,7 @@ public:
void setPrintMouseShadow(bool set); //if true, hex under mouse will be shaded
void setAnimSpeed(int set); //speed of animation; range 1..100
int getAnimSpeed() const; //speed of animation; range 1..100
CPlayerInterface * getCurrentPlayerInterface() const;
std::vector<CClickableHex*> bfield; //11 lines, 17 hexes on each
SDL_Surface * cellBorder, * cellShade;

View File

@ -175,7 +175,7 @@ void CBattleHero::clickLeft(tribool down, bool previousState)
if(myOwner->spellDestSelectMode) //we are casting a spell
return;
if(!down && myHero != nullptr && myOwner->myTurn && myOwner->curInt->cb->battleCanCastSpell()) //check conditions
if(!down && myHero != nullptr && myOwner->myTurn && myOwner->getCurrentPlayerInterface()->cb->battleCanCastSpell()) //check conditions
{
for(int it=0; it<GameConstants::BFIELD_SIZE; ++it) //do nothing when any hex is hovered - hero's animation overlaps battlefield
{
@ -184,7 +184,7 @@ void CBattleHero::clickLeft(tribool down, bool previousState)
}
CCS->curh->changeGraphic(ECursor::ADVENTURE, 0);
auto spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), myHero, myOwner->curInt.get());
auto spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), myHero, myOwner->getCurrentPlayerInterface());
GH.pushInt(spellWindow);
}
}
@ -256,7 +256,7 @@ CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInt
OBJ_CONSTRUCTION_CAPTURING_ALL;
pos = position;
background = new CPicture("comopbck.bmp");
background->colorize(owner->curInt->playerID);
background->colorize(owner->getCurrentPlayerInterface()->playerID);
viewGrid = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintCellBorders, owner, true), boost::bind(&CBattleInterface::setPrintCellBorders, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[427].first)(3,CGI->generaltexth->zelp[427].first), CGI->generaltexth->zelp[427].second, false, "sysopchk.def", nullptr, 25, 56, false);
viewGrid->select(settings["battle"]["cellBorders"].Bool());
@ -570,9 +570,9 @@ void CClickableHex::mouseMoved(const SDL_MouseMotionEvent &sEvent)
if(hovered && strictHovered) //print attacked creature to console
{
const CStack * attackedStack = myInterface->curInt->cb->battleGetStackByPos(myNumber);
const CStack * attackedStack = myInterface->getCurrentPlayerInterface()->cb->battleGetStackByPos(myNumber);
if(myInterface->console->alterTxt.size() == 0 &&attackedStack != nullptr &&
attackedStack->owner != myInterface->curInt->playerID &&
attackedStack->owner != myInterface->getCurrentPlayerInterface()->playerID &&
attackedStack->alive())
{
char tabh[160];
@ -599,7 +599,7 @@ void CClickableHex::clickLeft(tribool down, bool previousState)
void CClickableHex::clickRight(tribool down, bool previousState)
{
const CStack * myst = myInterface->curInt->cb->battleGetStackByPos(myNumber); //stack info
const CStack * myst = myInterface->getCurrentPlayerInterface()->cb->battleGetStackByPos(myNumber); //stack info
if(hovered && strictHovered && myst!=nullptr)
{
@ -614,7 +614,7 @@ void CClickableHex::clickRight(tribool down, bool previousState)
void CStackQueue::update()
{
stacksSorted.clear();
owner->curInt->cb->battleGetStackQueue(stacksSorted, stackBoxes.size());
owner->getCurrentPlayerInterface()->cb->battleGetStackQueue(stacksSorted, stackBoxes.size());
if(stacksSorted.size())
{
for (int i = 0; i < stackBoxes.size() ; i++)