1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

* CHexField renamed to CBattleHex

* CHexFieldControl renamed to CClickableHex
* CCreatureAnimation.cpp/.h moved to BattleInterface/CCreatureAnimation.cpp/.h
* Removed unused project files
* Added VCMI_client filters file for VS 2010
* Gathered common parts of StdInc.h in Global.h
* Boost.Spirit has been included in PCH for ERM project
* StopWatch renamed to CStopWatch
* GuiBase.cpp split up in UIFramework/...
This commit is contained in:
beegee1
2011-12-17 18:59:59 +00:00
parent 6ea88593db
commit 2f5d6f2684
176 changed files with 3257 additions and 9059 deletions

View File

@@ -4,7 +4,7 @@
#include "../CMusicHandler.h"
#include "../CGameInfo.h"
#include "CBattleInterface.h"
#include "../CCreatureAnimation.h"
#include "CCreatureAnimation.h"
#include "../../lib/BattleState.h"
#include "../CPlayerInterface.h"
#include "../../CCallback.h"
@@ -34,7 +34,7 @@ bool CAttackAnimation::checkInitialConditions()
return isEarliest(false);
}
CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SHexField _dest, const CStack *defender)
CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SBattleHex _dest, const CStack *defender)
: CBattleStackAnimation(_owner, attacker), dest(_dest), attackedStack(defender), attackingStack(attacker)
{

View File

@@ -2,7 +2,7 @@
#include "CBattleStackAnimation.h"
#include "../CAnimation.h"
#include "../../lib/SHexField.h"
#include "../../lib/SBattleHex.h"
class CBattleInterface;
class CStack;
@@ -21,7 +21,7 @@ class CStack;
class CAttackAnimation : public CBattleStackAnimation
{
protected:
SHexField dest; //attacked hex
SBattleHex dest; //attacked hex
bool shooting;
CCreatureAnim::EAnimType group; //if shooting is true, print this animation group
const CStack *attackedStack;
@@ -31,5 +31,5 @@ public:
void nextFrame();
bool checkInitialConditions();
CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SHexField _dest, const CStack *defender);
CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SBattleHex _dest, const CStack *defender);
};

View File

@@ -1,6 +1,6 @@
#pragma once
#include "../GUIBase.h"
#include "../UIFramework/CIntObject.h"
struct SDL_Surface;

View File

@@ -10,6 +10,7 @@
#include "../CSpellWindow.h"
#include "../Graphics.h"
#include "../CConfigHandler.h"
#include "../UIFramework/CGuiHandler.h"
void CBattleHero::show(SDL_Surface *to)
{

View File

@@ -1,6 +1,6 @@
#pragma once
#include "../GUIBase.h"
#include "../UIFramework/CIntObject.h"
class CBattleInterface;
class CDefHandler;

View File

@@ -17,7 +17,7 @@
#include "../../CCallback.h"
#include "../../lib/BattleState.h"
#include "../../lib/CGeneralTextHandler.h"
#include "../CCreatureAnimation.h"
#include "CCreatureAnimation.h"
#include "../Graphics.h"
#include "../CSpellWindow.h"
#include "../CConfigHandler.h"
@@ -29,7 +29,6 @@
#include "../../lib/CTownHandler.h"
#include "../../lib/map.h"
#include "CBattleHero.h"
#include "CStackQueue.h"
#include "CBattleConsole.h"
@@ -37,7 +36,7 @@
#include "CBattleAnimation.h"
#include "CBattleOptionsWindow.h"
#include "CDummyAnimation.h"
#include "CHexFieldControl.h"
#include "CClickableHex.h"
#include "CShootingAnimation.h"
#include "CSpellEffectAnimation.h"
#include "CMeleeAttackAnimation.h"
@@ -47,6 +46,7 @@
#include "CDefenceAnimation.h"
#include "CMovementAnimation.h"
#include "../UIFramework/CGuiHandler.h"
#ifndef __GNUC__
const double M_PI = 3.14159265358979323846;
@@ -112,7 +112,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
myTurn(false), resWindow(NULL), moveStarted(false), moveSh(-1), bresult(NULL)
{
ObjectConstruction h__l__p(this);
OBJ_CONSTRUCTION;
if(!curInt) curInt = LOCPLINT; //may happen when we are defending during network MP game
@@ -136,7 +136,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
if(curInt->sysOpts.showQueue)
pos.y += queue->pos.h / 2; //center whole window
queue->moveTo(Point(pos.x, pos.y - queue->pos.h));
queue->moveTo(SPoint(pos.x, pos.y - queue->pos.h));
// queue->pos.x = pos.x;
// queue->pos.y = pos.y - queue->pos.h;
// pos.h += queue->pos.h;
@@ -173,7 +173,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
SDL_Surface * moat = BitmapHandler::loadBitmap( siegeH->getSiegeName(13) ),
* mlip = BitmapHandler::loadBitmap( siegeH->getSiegeName(14) );
Point moatPos = graphics->wallPositions[siegeH->town->town->typeID][12],
SPoint moatPos = graphics->wallPositions[siegeH->town->town->typeID][12],
mlipPos = graphics->wallPositions[siegeH->town->town->typeID][13];
if(moat) //eg. tower has no moat
@@ -603,8 +603,8 @@ void CBattleInterface::show(SDL_Surface * to)
{//TODO: do not check it every frame
if (activeStack) //highlight all attackable hexes
{
std::set<SHexField> set = curInt->cb->battleGetAttackedHexes(activeStack, currentlyHoveredHex, attackingHex);
BOOST_FOREACH(SHexField hex, set)
std::set<SBattleHex> set = curInt->cb->battleGetAttackedHexes(activeStack, currentlyHoveredHex, attackingHex);
BOOST_FOREACH(SBattleHex hex, set)
{
int x = 14 + ((hex/GameConstants::BFIELD_WIDTH)%2==0 ? 22 : 0) + 44*(hex%GameConstants::BFIELD_WIDTH) + pos.x;
int y = 86 + 42 * (hex/GameConstants::BFIELD_WIDTH) + pos.y;
@@ -630,10 +630,10 @@ void CBattleInterface::show(SDL_Surface * to)
//preparing obstacles to be shown
std::vector<CObstacleInstance> obstacles = curInt->cb->battleGetAllObstacles();
std::multimap<SHexField, int> hexToObstacle;
std::multimap<SBattleHex, int> hexToObstacle;
for(size_t b = 0; b < obstacles.size(); ++b)
{
SHexField position = CGI->heroh->obstacles.find(obstacles[b].ID)->second.getMaxBlocked(obstacles[b].pos);
SBattleHex position = CGI->heroh->obstacles.find(obstacles[b].ID)->second.getMaxBlocked(obstacles[b].pos);
hexToObstacle.insert(std::make_pair(position, b));
}
@@ -845,7 +845,7 @@ void CBattleInterface::show(SDL_Surface * to)
//showing in-game console
LOCPLINT->cingconsole->show(to);
Rect posWithQueue = Rect(pos.x, pos.y, 800, 600);
SRect posWithQueue = SRect(pos.x, pos.y, 800, 600);
if(curInt->sysOpts.showQueue)
{
@@ -891,12 +891,12 @@ void CBattleInterface::showAliveStacks(std::vector<const CStack *> *aliveStacks,
}
}
void CBattleInterface::showObstacles(std::multimap<SHexField, int> *hexToObstacle, std::vector<CObstacleInstance> &obstacles, int hex, SDL_Surface *to)
void CBattleInterface::showObstacles(std::multimap<SBattleHex, int> *hexToObstacle, std::vector<CObstacleInstance> &obstacles, int hex, SDL_Surface *to)
{
std::pair<std::multimap<SHexField, int>::const_iterator, std::multimap<SHexField, int>::const_iterator> obstRange =
std::pair<std::multimap<SBattleHex, int>::const_iterator, std::multimap<SBattleHex, int>::const_iterator> obstRange =
hexToObstacle->equal_range(hex);
for(std::multimap<SHexField, int>::const_iterator it = obstRange.first; it != obstRange.second; ++it)
for(std::multimap<SBattleHex, int>::const_iterator it = obstRange.first; it != obstRange.second; ++it)
{
CObstacleInstance & curOb = obstacles[it->second];
std::pair<si16, si16> shift = CGI->heroh->obstacles.find(curOb.ID)->second.posShift;
@@ -963,7 +963,7 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent)
if ((int)creatureSpellToCast > -1) //use randomized spell (Faerie Dragon), or only avaliable spell (Archangel)
{
const CSpell * spell = CGI->spellh->spells[creatureSpellToCast];
if (curInt->cb->battleCanCastThisSpell(spell, SHexField(myNumber)) == ESpellCastProblem::OK)
if (curInt->cb->battleCanCastThisSpell(spell, SBattleHex(myNumber)) == ESpellCastProblem::OK)
{
if ((spell->positiveness > -1 && ourStack) || (spell->positiveness < 1 && !ourStack))
{
@@ -1210,7 +1210,7 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent)
void CBattleInterface::setBattleCursor(const int myNumber)
{
const CHexFieldControl & hoveredHex = bfield[myNumber];
const CClickableHex & hoveredHex = bfield[myNumber];
CCursorHandler *cursor = CCS->curh;
const double subdividingAngle = 2.0*M_PI/6.0; // Divide a hex into six sectors.
@@ -1368,7 +1368,7 @@ void CBattleInterface::setBattleCursor(const int myNumber)
attackingHex = myNumber + GameConstants::BFIELD_WIDTH - 1 + zigzagCorrection; //bottom left
break;
}
SHexField hex(attackingHex);
SBattleHex hex(attackingHex);
if (!hex.isValid())
attackingHex = -1;
}
@@ -1388,7 +1388,7 @@ void CBattleInterface::bOptionsf()
CCS->curh->changeGraphic(0,0);
Rect tempRect = genRect(431, 481, 160, 84);
SRect tempRect = genRect(431, 481, 160, 84);
tempRect += pos.topLeft();
CBattleOptionsWindow * optionsWin = new CBattleOptionsWindow(tempRect, this);
GH.pushInt(optionsWin);
@@ -1516,7 +1516,7 @@ void CBattleInterface::bConsoleDownf()
void CBattleInterface::newStack(const CStack * stack)
{
Point coords = CHexFieldControl::getXYUnitAnim(stack->position, stack->owner == attackingHeroInstance->tempOwner, stack, this);;
SPoint coords = CClickableHex::getXYUnitAnim(stack->position, stack->owner == attackingHeroInstance->tempOwner, stack, this);;
if(stack->position < 0) //turret
{
@@ -1549,7 +1549,7 @@ void CBattleInterface::newStack(const CStack * stack)
creAnims[stack->ID] = new CCreatureAnimation(stack->getCreature()->animDefName);
}
creAnims[stack->ID]->setType(CCreatureAnim::HOLDING);
creAnims[stack->ID]->pos = Rect(coords.x, coords.y, creAnims[stack->ID]->fullWidth, creAnims[stack->ID]->fullHeight);
creAnims[stack->ID]->pos = SRect(coords.x, coords.y, creAnims[stack->ID]->fullWidth, creAnims[stack->ID]->fullHeight);
creDir[stack->ID] = stack->attackerOwned;
}
@@ -1568,7 +1568,7 @@ void CBattleInterface::stackActivated(const CStack * stack) //TODO: check it all
activateStack();
}
void CBattleInterface::stackMoved(const CStack * stack, std::vector<SHexField> destHex, int distance)
void CBattleInterface::stackMoved(const CStack * stack, std::vector<SBattleHex> destHex, int distance)
{
addNewAnim(new CMovementAnimation(this, stack, destHex, distance));
waitForAnims();
@@ -1605,7 +1605,7 @@ void CBattleInterface::stacksAreAttacked(std::vector<SStackAttackedInfo> attacke
}
}
void CBattleInterface::stackAttacking( const CStack * attacker, SHexField dest, const CStack * attacked, bool shooting )
void CBattleInterface::stackAttacking( const CStack * attacker, SBattleHex dest, const CStack * attacked, bool shooting )
{
if (shooting)
{
@@ -1639,7 +1639,7 @@ void CBattleInterface::newRound(int number)
}
void CBattleInterface::giveCommand(ui8 action, SHexField tile, ui32 stack, si32 additional)
void CBattleInterface::giveCommand(ui8 action, SBattleHex tile, ui32 stack, si32 additional)
{
if(!curInt->cb->battleGetStackByID(stack) && action != 1 && action != 4 && action != 5)
{
@@ -1678,30 +1678,30 @@ void CBattleInterface::giveCommand(ui8 action, SHexField tile, ui32 stack, si32
}
}
bool CBattleInterface::isTileAttackable(const SHexField & number) const
bool CBattleInterface::isTileAttackable(const SBattleHex & number) const
{
for(size_t b=0; b<occupyableHexes.size(); ++b)
{
if(SHexField::mutualPosition(occupyableHexes[b], number) != -1 || occupyableHexes[b] == number)
if(SBattleHex::mutualPosition(occupyableHexes[b], number) != -1 || occupyableHexes[b] == number)
return true;
}
return false;
}
bool CBattleInterface::blockedByObstacle(SHexField hex) const
bool CBattleInterface::blockedByObstacle(SBattleHex hex) const
{
std::vector<CObstacleInstance> obstacles = curInt->cb->battleGetAllObstacles();
std::set<SHexField> coveredHexes;
std::set<SBattleHex> coveredHexes;
for(size_t b = 0; b < obstacles.size(); ++b)
{
std::vector<SHexField> blocked = CGI->heroh->obstacles.find(obstacles[b].ID)->second.getBlocked(obstacles[b].pos);
std::vector<SBattleHex> blocked = CGI->heroh->obstacles.find(obstacles[b].ID)->second.getBlocked(obstacles[b].pos);
for(size_t w = 0; w < blocked.size(); ++w)
coveredHexes.insert(blocked[w]);
}
return vstd::contains(coveredHexes, hex);
}
bool CBattleInterface::isCatapultAttackable(SHexField hex) const
bool CBattleInterface::isCatapultAttackable(SBattleHex hex) const
{
if(!siegeH)
return false;
@@ -1799,7 +1799,7 @@ void CBattleInterface::hexLclicked(int whichOne)
if ((int)creatureSpellToCast > -1) //use randomized spell (Faerie Dragon), or only avaliable spell (Archangel)
{
const CSpell * spell = CGI->spellh->spells[creatureSpellToCast];
if (curInt->cb->battleCanCastThisSpell(spell, SHexField(whichOne)) == ESpellCastProblem::OK)
if (curInt->cb->battleCanCastThisSpell(spell, SBattleHex(whichOne)) == ESpellCastProblem::OK)
{
if ((spell->positiveness > -1 && ourStack) || (spell->positiveness < 1 && !ourStack))
{
@@ -1880,7 +1880,7 @@ void CBattleInterface::hexLclicked(int whichOne)
{
if(actStack->doubleWide() && !actStack->attackerOwned)
{
std::vector<SHexField> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
std::vector<SBattleHex> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
if(vstd::contains(acc, whichOne))
attackFromHex = whichOne - 1;
else
@@ -1932,7 +1932,7 @@ void CBattleInterface::hexLclicked(int whichOne)
{
if(actStack->doubleWide() && actStack->attackerOwned)
{
std::vector<SHexField> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
std::vector<SBattleHex> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
if(vstd::contains(acc, whichOne))
attackFromHex = whichOne + 1;
else
@@ -2018,7 +2018,7 @@ void CBattleInterface::hexLclicked(int whichOne)
CCS->curh->changeGraphic(1, 6); //cursor should be changed
if(activeStack->doubleWide())
{
std::vector<SHexField> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
std::vector<SBattleHex> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
int shiftedDest = whichOne + (activeStack->attackerOwned ? 1 : -1);
if(vstd::contains(acc, whichOne))
giveCommand (BattleAction::WALK ,whichOne, activeStack->ID);
@@ -2101,8 +2101,8 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
{ //common ice bolt and magic arrow part
//initial variables
std::string animToDisplay;
Point srccoord = (sc->side ? Point(770, 60) : Point(30, 60)) + pos;
Point destcoord = CHexFieldControl::getXYUnitAnim(sc->tile, !sc->side, curInt->cb->battleGetStackByPos(sc->tile), this); //position attacked by arrow
SPoint srccoord = (sc->side ? SPoint(770, 60) : SPoint(30, 60)) + pos;
SPoint destcoord = CClickableHex::getXYUnitAnim(sc->tile, !sc->side, curInt->cb->battleGetStackByPos(sc->tile), this); //position attacked by arrow
destcoord.x += 250; destcoord.y += 240;
//animation angle
@@ -2320,8 +2320,8 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
//mana absorption
if (sc->manaGained)
{
Point leftHero = Point(15, 30) + pos;
Point rightHero = Point(755, 30) + pos;
SPoint leftHero = SPoint(15, 30) + pos;
SPoint rightHero = SPoint(755, 30) + pos;
addNewAnim(new CSpellEffectAnimation(this, sc->side ? "SP07_A.DEF" : "SP07_B.DEF", leftHero.x, leftHero.y, 0, 0, false));
addNewAnim(new CSpellEffectAnimation(this, sc->side ? "SP07_B.DEF" : "SP07_A.DEF", rightHero.x, rightHero.y, 0, 0, false));
}
@@ -2632,7 +2632,7 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
&& !stack->hasBonusOfType(Bonus::SIEGE_WEAPON) //and not a war machine...
)
{
const SHexField nextPos = stack->position + (stack->attackerOwned ? 1 : -1);
const SBattleHex nextPos = stack->position + (stack->attackerOwned ? 1 : -1);
const bool edge = stack->position % GameConstants::BFIELD_WIDTH == (stack->attackerOwned ? GameConstants::BFIELD_WIDTH - 2 : 1);
const bool moveInside = !edge && !stackCountOutsideHexes[nextPos];
int xAdd = (stack->attackerOwned ? 220 : 202) +
@@ -2769,9 +2769,9 @@ void CBattleInterface::redrawBackgroundWithHexes(const CStack * activeStack)
if(curInt->sysOpts.printStackRange)
{
std::vector<SHexField> hexesToShade = occupyableHexes;
std::vector<SBattleHex> hexesToShade = occupyableHexes;
hexesToShade.insert(hexesToShade.end(), attackableHexes.begin(), attackableHexes.end());
BOOST_FOREACH(SHexField hex, hexesToShade)
BOOST_FOREACH(SBattleHex hex, hexesToShade)
{
int i = hex.getY(); //row
int j = hex.getX()-1; //column
@@ -2937,7 +2937,7 @@ void CBattleInterface::hideQueue()
if(!queue->embedded)
{
moveBy(Point(0, -queue->pos.h / 2));
moveBy(SPoint(0, -queue->pos.h / 2));
GH.totalRedraw();
}
}
@@ -2950,7 +2950,7 @@ void CBattleInterface::showQueue()
if(!queue->embedded)
{
moveBy(Point(0, +queue->pos.h / 2));
moveBy(SPoint(0, +queue->pos.h / 2));
GH.totalRedraw();
}
}
@@ -3170,7 +3170,7 @@ std::string CBattleInterface::SiegeHelper::getSiegeName(ui16 what, ui16 additInf
/// Positions are loaded from the config file: /config/wall_pos.txt
void CBattleInterface::SiegeHelper::printPartOfWall(SDL_Surface * to, int what)
{
Point pos = Point(-1, -1);
SPoint pos = SPoint(-1, -1);
if (what >= 1 && what <= 17)
{

View File

@@ -1,14 +1,13 @@
#pragma once
#include "../GUIBase.h"
#include "../../lib/CCreatureSet.h"
#include "../../lib/ConstTransitivePtr.h" //may be reundant
#include "../CAnimation.h"
#include "SStackAttackedInfo.h"
#include "CHexFieldControl.h"
#include "CClickableHex.h"
#include "CShootingAnimation.h"
#include "../../lib/SHexField.h"
#include "../../lib/SBattleHex.h"
#include "../../lib/GameConstants.h"
/*
@@ -46,6 +45,7 @@ class CBattleHero;
class CBattleConsole;
class CBattleResultWindow;
class CStackQueue;
class CPlayerInterface;
/// Class which manages the locked hex fields that are blocked e.g. by obstacles
class CBattleObstacle
@@ -103,7 +103,7 @@ private:
int mouseHoveredStack; //stack hovered by mouse; if -1 -> none
time_t lastMouseHoveredStackAnimationTime; // time when last mouse hovered animation occurred
static const time_t HOVER_ANIM_DELTA;
std::vector<SHexField> occupyableHexes, //hexes available for active stack
std::vector<SBattleHex> occupyableHexes, //hexes available for active stack
attackableHexes; //hexes attackable by active stack
bool stackCountOutsideHexes[GameConstants::BFIELD_SIZE]; // hexes that when in front of a unit cause it's amount box to move back
int previouslyHoveredHex; //number of hex that was hovered by the cursor a while ago
@@ -112,7 +112,7 @@ private:
double getAnimSpeedMultiplier() const; //returns multiplier for number of frames in a group
std::map<int, int> standingFrame; //number of frame in standing animation by stack ID, helps in showing 'random moves'
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
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
bool tacticsMode;
bool stackCanCastSpell; //if true, active stack could possibly cats some target spell
bool spellDestSelectMode; //if true, player is choosing destination for his spell
@@ -124,16 +124,16 @@ private:
void showAliveStack(const CStack *stack, SDL_Surface * to); //helper function for function show
void showAliveStacks(std::vector<const CStack *> *aliveStacks, int hex, std::vector<const CStack *> *flyingStacks, SDL_Surface *to); // loops through all stacks at a given hex position
void showPieceOfWall(SDL_Surface * to, int hex, const std::vector<const CStack*> & stacks); //helper function for show
void showObstacles(std::multimap<SHexField, int> *hexToObstacle, std::vector<CObstacleInstance> &obstacles, int hex, SDL_Surface *to); // show all obstacles at a given hex position
void showObstacles(std::multimap<SBattleHex, int> *hexToObstacle, std::vector<CObstacleInstance> &obstacles, int hex, SDL_Surface *to); // show all obstacles at a given hex position
void redrawBackgroundWithHexes(const CStack * activeStack);
void printConsoleAttacked(const CStack * defender, int dmg, int killed, const CStack * attacker, bool Multiple);
std::list<SProjectileInfo> projectiles; //projectiles flying on battlefield
void projectileShowHelper(SDL_Surface * to); //prints projectiles present on the battlefield
void giveCommand(ui8 action, SHexField tile, ui32 stack, si32 additional=-1);
bool isTileAttackable(const SHexField & number) const; //returns true if tile 'number' is neighboring any tile from active stack's range or is one of these tiles
bool blockedByObstacle(SHexField hex) const;
bool isCatapultAttackable(SHexField hex) const; //returns true if given tile can be attacked by catapult
void giveCommand(ui8 action, SBattleHex tile, ui32 stack, si32 additional=-1);
bool isTileAttackable(const SBattleHex & number) const; //returns true if tile 'number' is neighboring any tile from active stack's range or is one of these tiles
bool blockedByObstacle(SBattleHex hex) const;
bool isCatapultAttackable(SBattleHex hex) const; //returns true if given tile can be attacked by catapult
std::list<SBattleEffect> battleEffects; //different animations to display on the screen like spell effects
@@ -177,7 +177,7 @@ public:
void setAnimSpeed(int set); //speed of animation; 1 - slowest, 2 - medium, 4 - fastest
int getAnimSpeed() const; //speed of animation; 1 - slowest, 2 - medium, 4 - fastest
CHexFieldControl bfield[GameConstants::BFIELD_SIZE]; //11 lines, 17 hexes on each
CClickableHex bfield[GameConstants::BFIELD_SIZE]; //11 lines, 17 hexes on each
//std::vector< CBattleObstacle * > obstacles; //vector of obstacles on the battlefield
SDL_Surface * cellBorder, * cellShade;
CondSh<BattleAction *> *givenCommand; //data != NULL if we have i.e. moved current unit
@@ -215,10 +215,10 @@ public:
void newStack(const CStack * stack); //new stack appeared on battlefield
void stackRemoved(int stackID); //stack disappeared from batlefiled
void stackActivated(const CStack * stack); //active stack has been changed
void stackMoved(const CStack * stack, std::vector<SHexField> destHex, int distance); //stack with id number moved to destHex
void stackMoved(const CStack * stack, std::vector<SBattleHex> destHex, int distance); //stack with id number moved to destHex
void waitForAnims();
void stacksAreAttacked(std::vector<SStackAttackedInfo> attackedInfos); //called when a certain amount of stacks has been attacked
void stackAttacking(const CStack * attacker, SHexField dest, const CStack * attacked, bool shooting); //called when stack with id ID is attacking something on hex dest
void stackAttacking(const CStack * attacker, SBattleHex dest, const CStack * attacked, bool shooting); //called when stack with id ID is attacking something on hex dest
void newRoundFirst( int round );
void newRound(int number); //caled when round is ended; number is the number of round
void hexLclicked(int whichOne); //hex only call-in
@@ -252,5 +252,5 @@ public:
friend class CAttackAnimation;
friend class CMeleeAttackAnimation;
friend class CShootingAnimation;
friend class CHexFieldControl;
friend class CClickableHex;
};

View File

@@ -2,12 +2,12 @@
#include "CBattleOptionsWindow.h"
#include "CBattleInterface.h"
#include "../GUIBase.h"
#include "../GUIClasses.h"
#include "../AdventureMapButton.h"
#include "../CGameInfo.h"
#include "../CPlayerInterface.h"
#include "../../lib/CGeneralTextHandler.h"
#include "../UIFramework/CGuiHandler.h"
CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInterface *owner): myInt(owner)
{

View File

@@ -1,6 +1,6 @@
#pragma once
#include "../GUIBase.h"
#include "../UIFramework/CIntObject.h"
class CBattleInterface;
class CPicture;

View File

@@ -15,6 +15,7 @@
#include "../CVideoHandler.h"
#include "../SDL_Extensions.h"
#include "../CBitmapHandler.h"
#include "../UIFramework/CGuiHandler.h"
CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect & pos, CBattleInterface * _owner)
: owner(_owner)

View File

@@ -1,6 +1,6 @@
#pragma once
#include "../GUIBase.h"
#include "../UIFramework/CIntObject.h"
struct SDL_Surface;
class AdventureMapButton;

View File

@@ -9,7 +9,7 @@ CBattleStackAnimation::CBattleStackAnimation(CBattleInterface * _owner, const CS
{
}
bool CBattleStackAnimation::isToReverseHlp(SHexField hexFrom, SHexField hexTo, bool curDir)
bool CBattleStackAnimation::isToReverseHlp(SBattleHex hexFrom, SBattleHex hexTo, bool curDir)
{
int fromMod = hexFrom % GameConstants::BFIELD_WIDTH;
int fromDiv = hexFrom / GameConstants::BFIELD_WIDTH;
@@ -35,7 +35,7 @@ bool CBattleStackAnimation::isToReverseHlp(SHexField hexFrom, SHexField hexTo, b
return false; //should never happen
}
bool CBattleStackAnimation::isToReverse(SHexField hexFrom, SHexField hexTo, bool curDir, bool toDoubleWide, bool toDir)
bool CBattleStackAnimation::isToReverse(SBattleHex hexFrom, SBattleHex hexTo, bool curDir, bool toDoubleWide, bool toDir)
{
if(hexTo < 0) //turret
return false;

View File

@@ -1,7 +1,7 @@
#pragma once
#include "CBattleAnimation.h"
#include "../../lib/SHexField.h"
#include "../../lib/SBattleHex.h"
class CStack;
class CBattleInterface;
@@ -24,8 +24,8 @@ public:
const CStack * stack; //id of stack whose animation it is
CBattleStackAnimation(CBattleInterface * _owner, const CStack * _stack);
static bool isToReverseHlp(SHexField hexFrom, SHexField hexTo, bool curDir); //helper for isToReverse
static bool isToReverse(SHexField hexFrom, SHexField hexTo, bool curDir /*if true, creature is in attacker's direction*/, bool toDoubleWide, bool toDir); //determines if creature should be reversed (it stands on hexFrom and should 'see' hexTo)
static bool isToReverseHlp(SBattleHex hexFrom, SBattleHex hexTo, bool curDir); //helper for isToReverse
static bool isToReverse(SBattleHex hexFrom, SBattleHex hexTo, bool curDir /*if true, creature is in attacker's direction*/, bool toDoubleWide, bool toDir); //determines if creature should be reversed (it stands on hexFrom and should 'see' hexTo)
CCreatureAnimation *myAnim(); //animation for our stack
};

View File

@@ -1,5 +1,5 @@
#include "StdInc.h"
#include "CHexFieldControl.h"
#include "CClickableHex.h"
#include "CBattleInterface.h"
#include "../../lib/BattleState.h"
#include "../CGameInfo.h"
@@ -11,10 +11,11 @@
#include "../SDL_Extensions.h"
#include "../GUIClasses.h"
#include "CBattleConsole.h"
#include "../UIFramework/CGuiHandler.h"
Point CHexFieldControl::getXYUnitAnim(const int & hexNum, const bool & attacker, const CStack * stack, const CBattleInterface * cbi)
SPoint CClickableHex::getXYUnitAnim(const int & hexNum, const bool & attacker, const CStack * stack, const CBattleInterface * cbi)
{
Point ret(-500, -500); //returned value
SPoint ret(-500, -500); //returned value
if(stack && stack->position < 0) //creatures in turrets
{
switch(stack->position)
@@ -58,7 +59,7 @@ Point CHexFieldControl::getXYUnitAnim(const int & hexNum, const bool & attacker,
//returning
return ret +CPlayerInterface::battleInt->pos;
}
void CHexFieldControl::activate()
void CClickableHex::activate()
{
activateHover();
activateMouseMove();
@@ -66,7 +67,7 @@ void CHexFieldControl::activate()
activateRClick();
}
void CHexFieldControl::deactivate()
void CClickableHex::deactivate()
{
deactivateHover();
deactivateMouseMove();
@@ -74,7 +75,7 @@ void CHexFieldControl::deactivate()
deactivateRClick();
}
void CHexFieldControl::hover(bool on)
void CClickableHex::hover(bool on)
{
hovered = on;
//Hoverable::hover(on);
@@ -85,11 +86,11 @@ void CHexFieldControl::hover(bool on)
}
}
CHexFieldControl::CHexFieldControl() : setAlterText(false), myNumber(-1), accessible(true), hovered(false), strictHovered(false), myInterface(NULL)
CClickableHex::CClickableHex() : setAlterText(false), myNumber(-1), accessible(true), hovered(false), strictHovered(false), myInterface(NULL)
{
}
void CHexFieldControl::mouseMoved(const SDL_MouseMotionEvent &sEvent)
void CClickableHex::mouseMoved(const SDL_MouseMotionEvent &sEvent)
{
if(myInterface->cellShade)
{
@@ -124,7 +125,7 @@ void CHexFieldControl::mouseMoved(const SDL_MouseMotionEvent &sEvent)
}
}
void CHexFieldControl::clickLeft(tribool down, bool previousState)
void CClickableHex::clickLeft(tribool down, bool previousState)
{
if(!down && hovered && strictHovered) //we've been really clicked!
{
@@ -132,7 +133,7 @@ void CHexFieldControl::clickLeft(tribool down, bool previousState)
}
}
void CHexFieldControl::clickRight(tribool down, bool previousState)
void CClickableHex::clickRight(tribool down, bool previousState)
{
const CStack * myst = myInterface->curInt->cb->battleGetStackByPos(myNumber); //stack info
if(hovered && strictHovered && myst!=NULL)

View File

@@ -1,13 +1,13 @@
#pragma once
#include "../GUIBase.h"
#include "../UIFramework/CIntObject.h"
class CBattleInterface;
class CStack;
struct SDL_MouseMotionEvent;
/*
* CHexFieldControl.h, part of VCMI engine
* CClickableHex.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
@@ -17,7 +17,7 @@ struct SDL_MouseMotionEvent;
*/
/// Class which stands for a single hex field on a battlefield
class CHexFieldControl : public CIntObject
class CClickableHex : public CIntObject
{
private:
bool setAlterText; //if true, this hex has set alternative text in console and will clean it
@@ -27,7 +27,7 @@ public:
//CStack * ourStack;
bool hovered, strictHovered; //for determining if hex is hovered by mouse (this is different problem than hex's graphic hovering)
CBattleInterface * myInterface; //interface that owns me
static Point getXYUnitAnim(const int &hexNum, const bool &attacker, const CStack *creature, const CBattleInterface *cbi); //returns (x, y) of left top corner of animation
static SPoint getXYUnitAnim(const int &hexNum, const bool &attacker, const CStack *creature, const CBattleInterface *cbi); //returns (x, y) of left top corner of animation
//for user interactions
void hover (bool on);
@@ -36,5 +36,5 @@ public:
void mouseMoved (const SDL_MouseMotionEvent &sEvent);
void clickLeft(tribool down, bool previousState);
void clickRight(tribool down, bool previousState);
CHexFieldControl();
CClickableHex();
};

View File

@@ -0,0 +1,345 @@
#include "StdInc.h"
#include "CCreatureAnimation.h"
#include "../../lib/CLodHandler.h"
#include "../../lib/VCMI_Lib.h"
#include "../../lib/vcmi_endian.h"
#include "../SDL_Extensions.h"
/*
* CCreatureAnimation.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
CCreatureAnim::EAnimType CCreatureAnimation::getType() const
{
return type;
}
void CCreatureAnimation::setType(CCreatureAnim::EAnimType type)
{
assert(framesInGroup(type) > 0 && "Bad type for void CCreatureAnimation::setType(int type)!");
this->type = type;
internalFrame = 0;
if(type!=-1)
{
curFrame = frameGroups[type][0];
}
else
{
if(curFrame>=frames)
{
curFrame = 0;
}
}
}
CCreatureAnimation::CCreatureAnimation(std::string name) : internalFrame(0), once(false)
{
FDef = spriteh->giveFile(name, FILE_ANIMATION); //load main file
//init anim data
int i,j, totalInBlock;
defName=name;
i = 0;
DEFType = read_le_u32(FDef + i); i+=4;
fullWidth = read_le_u32(FDef + i); i+=4;
fullHeight = read_le_u32(FDef + i); i+=4;
i=0xc;
totalBlocks = read_le_u32(FDef + i); i+=4;
i=0x10;
for (int it=0;it<256;it++)
{
palette[it].R = FDef[i++];
palette[it].G = FDef[i++];
palette[it].B = FDef[i++];
palette[it].F = 0;
}
i=0x310;
totalEntries=0;
for (int z=0; z<totalBlocks; z++)
{
std::vector<int> frameIDs;
int group = read_le_u32(FDef + i); i+=4; //block ID
totalInBlock = read_le_u32(FDef + i); i+=4;
for (j=SEntries.size(); j<totalEntries+totalInBlock; j++)
{
SEntries.push_back(SEntry());
SEntries[j].group = group;
frameIDs.push_back(j);
}
/*int unknown2 = read_le_u32(FDef + i);*/ i+=4; //TODO use me
/*int unknown3 = read_le_u32(FDef + i);*/ i+=4; //TODO use me
i+=13*totalInBlock; //omitting names
for (j=0; j<totalInBlock; j++)
{
SEntries[totalEntries+j].offset = read_le_u32(FDef + i); i+=4;
}
//totalEntries+=totalInBlock;
for(int hh=0; hh<totalInBlock; ++hh)
{
++totalEntries;
}
frameGroups[group] = frameIDs;
}
//init vars
curFrame = 0;
type = CCreatureAnim::WHOLE_ANIM;
frames = totalEntries;
}
int CCreatureAnimation::nextFrameMiddle(SDL_Surface *dest, int x, int y, bool attacker, ui8 animCount, bool incrementFrame, bool yellowBorder, bool blueBorder, SDL_Rect * destRect)
{
return nextFrame(dest, x-fullWidth/2, y-fullHeight/2, attacker, animCount, incrementFrame, yellowBorder, blueBorder, destRect);
}
void CCreatureAnimation::incrementFrame()
{
if(type!=-1) //when a specific part of animation is played
{
++internalFrame;
if(internalFrame == frameGroups[type].size()) //rewind
{
internalFrame = 0;
if(once) //playing animation once - return to standing animation
{
type = CCreatureAnim::HOLDING;
once = false;
curFrame = frameGroups[2][0];
}
else //
{
curFrame = frameGroups[type][0];
}
}
curFrame = frameGroups[type][internalFrame];
}
else //when whole animation is played
{
++curFrame;
if(curFrame>=frames)
curFrame = 0;
}
}
int CCreatureAnimation::getFrame() const
{
return curFrame;
}
int CCreatureAnimation::getAnimationFrame() const
{
return internalFrame;
}
bool CCreatureAnimation::onFirstFrameInGroup()
{
return internalFrame == 0;
}
bool CCreatureAnimation::onLastFrameInGroup()
{
if(internalFrame == frameGroups[type].size() - 1)
return true;
return false;
}
void CCreatureAnimation::playOnce( CCreatureAnim::EAnimType type )
{
setType(type);
once = true;
}
template<int bpp>
int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame /*= true*/, bool yellowBorder /*= false*/, bool blueBorder /*= false*/, SDL_Rect * destRect /*= NULL*/)
{
//increasing frame number
int SIndex = curFrame;
if (IncrementFrame)
incrementFrame();
#if 0
long SpriteWidth, SpriteHeight, //sprite format
LeftMargin, RightMargin, TopMargin,BottomMargin,
i, FullHeight,
#endif
ui8 SegmentType, SegmentLength;
ui32 i;
i = SEntries[SIndex].offset;
/*int prSize = read_le_u32(FDef + i);*/ i += 4; //TODO use me
const ui32 defType2 = read_le_u32(FDef + i); i += 4;
const ui32 FullWidth = read_le_u32(FDef + i); i += 4;
const ui32 FullHeight = read_le_u32(FDef + i); i += 4;
const ui32 SpriteWidth = read_le_u32(FDef + i); i += 4;
const ui32 SpriteHeight = read_le_u32(FDef + i); i += 4;
const int LeftMargin = read_le_u32(FDef + i); i += 4;
const int TopMargin = read_le_u32(FDef + i); i += 4;
const int RightMargin = FullWidth - SpriteWidth - LeftMargin;
const int BottomMargin = FullHeight - SpriteHeight - TopMargin;
if (defType2 == 1) //as it should be always in creature animations
{
const int BaseOffsetor = i;
int ftcp = 0;
if (TopMargin > 0)
{
ftcp += FullWidth * TopMargin;
}
ui32 *RLEntries = (ui32 *)(FDef + BaseOffsetor);
for (int i = 0; i < SpriteHeight; i++)
{
int BaseOffset = BaseOffsetor + read_le_u32(RLEntries + i);
int TotalRowLength; // length of read segment
if (LeftMargin > 0)
{
ftcp += LeftMargin;
}
TotalRowLength = 0;
// Note: Bug fixed (Rev 2115): The implementation of omitting lines was false.
// We've to calculate several things so not showing/putting pixels should suffice.
int yB = ftcp / FullWidth + y;
do
{
SegmentType = FDef[BaseOffset++];
SegmentLength = FDef[BaseOffset++];
const int remainder = ftcp % FullWidth;
int xB = (attacker ? remainder : FullWidth - remainder - 1) + x;
const ui8 aCountMod = (animCount & 0x20) ? ((animCount & 0x1e) >> 1) << 4 : (0x0f - ((animCount & 0x1e) >> 1)) << 4;
for (int k = 0; k <= SegmentLength; k++)
{
if(xB >= 0 && xB < dest->w && yB >= 0 && yB < dest->h)
{
if(!destRect || (destRect->x <= xB && destRect->x + destRect->w > xB && destRect->y <= yB && destRect->y + destRect->h > yB))
{
const ui8 colorNr = SegmentType == 0xff ? FDef[BaseOffset+k] : SegmentType;
putPixel<bpp>(dest, xB, yB, palette[colorNr], colorNr, yellowBorder, blueBorder, aCountMod);
}
}
ftcp++; //increment pos
if(attacker)
xB++;
else
xB--;
if ( SegmentType == 0xFF && TotalRowLength+k+1 >= SpriteWidth )
break;
}
if (SegmentType == 0xFF)
{
BaseOffset += SegmentLength+1;
}
TotalRowLength+=SegmentLength+1;
} while(TotalRowLength < SpriteWidth);
if (RightMargin > 0)
{
ftcp += RightMargin;
}
}
if (BottomMargin > 0)
{
ftcp += BottomMargin * FullWidth;
}
}
return 0;
}
int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame, bool yellowBorder, bool blueBorder, SDL_Rect * destRect)
{
switch(dest->format->BytesPerPixel)
{
case 2: return nextFrameT<2>(dest, x, y, attacker, animCount, IncrementFrame, yellowBorder, blueBorder, destRect);
case 3: return nextFrameT<3>(dest, x, y, attacker, animCount, IncrementFrame, yellowBorder, blueBorder, destRect);
case 4: return nextFrameT<4>(dest, x, y, attacker, animCount, IncrementFrame, yellowBorder, blueBorder, destRect);
default:
tlog1 << (int)dest->format->BitsPerPixel << " bpp is not supported!!!\n";
return -1;
}
}
int CCreatureAnimation::framesInGroup(CCreatureAnim::EAnimType group) const
{
if(frameGroups.find(group) == frameGroups.end())
return 0;
return frameGroups.find(group)->second.size();
}
CCreatureAnimation::~CCreatureAnimation()
{
delete [] FDef;
}
template<int bpp>
inline void CCreatureAnimation::putPixel(
SDL_Surface * dest,
const int & ftcpX,
const int & ftcpY,
const BMPPalette & color,
const ui8 & palc,
const bool & yellowBorder,
const bool & blueBorder,
const ui8 & animCount
) const
{
if(palc!=0)
{
Uint8 * p = (Uint8*)dest->pixels + ftcpX*dest->format->BytesPerPixel + ftcpY*dest->pitch;
if(palc > 7) //normal color
{
ColorPutter<bpp, 0>::PutColor(p, color.R, color.G, color.B);
}
else if((yellowBorder || blueBorder) && (palc == 6 || palc == 7)) //selection highlight
{
if(blueBorder)
ColorPutter<bpp, 0>::PutColor(p, 0, 0x0f + animCount, 0x0f + animCount);
else
ColorPutter<bpp, 0>::PutColor(p, 0x0f + animCount, 0x0f + animCount, 0);
}
else if (palc == 5) //selection highlight or transparent
{
if(blueBorder)
ColorPutter<bpp, 0>::PutColor(p, color.B, color.G - 0xf0 + animCount, color.R - 0xf0 + animCount); //shouldn't it be reversed? its bgr instead of rgb
else if (yellowBorder)
ColorPutter<bpp, 0>::PutColor(p, color.R - 0xf0 + animCount, color.G - 0xf0 + animCount, color.B);
}
else //shadow
{
//determining transparency value, 255 or 0 should be already filtered
static Uint16 colToAlpha[8] = {255,192,128,128,128,255,128,192};
Uint16 alpha = colToAlpha[palc];
if(bpp != 3 && bpp != 4)
{
ColorPutter<bpp, 0>::PutColor(p, 0, 0, 0, alpha);
}
else
{
p[0] = (p[0] * alpha)>>8;
p[1] = (p[1] * alpha)>>8;
p[2] = (p[2] * alpha)>>8;
}
}
}
}

View File

@@ -0,0 +1,80 @@
#pragma once
#include "../CDefHandler.h"
#include "../../client/CBitmapHandler.h"
#include "../CAnimation.h"
/*
* CCreatureAnimation.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
struct BMPPalette;
class CIntObject;
/// Class which manages animations of creatures/units inside battles
class CCreatureAnimation : public CIntObject
{
private:
int totalEntries, DEFType, totalBlocks;
int length;
BMPPalette palette[256];
struct SEntry
{
int offset;
int group;
} ;
std::vector<SEntry> SEntries ;
std::string defName, curDir;
template<int bpp>
void putPixel(
SDL_Surface * dest,
const int & ftcpX,
const int & ftcpY,
const BMPPalette & color,
const ui8 & palc,
const bool & yellowBorder,
const bool & blueBorder,
const ui8 & animCount
) const;
////////////
ui8 * FDef; //animation raw data
int curFrame, internalFrame; //number of currently displayed frame
ui32 frames; //number of frames
CCreatureAnim::EAnimType type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
template<int bpp>
int nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
std::map<int, std::vector<int> > frameGroups; //groups of frames; [groupID] -> vector of frame IDs in group
bool once;
public:
int fullWidth, fullHeight; //read-only, please!
CCreatureAnimation(std::string name); //c-tor
~CCreatureAnimation(); //d-tor
void setType(CCreatureAnim::EAnimType type); //sets type of animation and cleares framecount
CCreatureAnim::EAnimType getType() const; //returns type of animation
int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
void incrementFrame();
int getFrame() const; // Gets the current frame ID relative to DEF file.
int getAnimationFrame() const; // Gets the current frame ID relative to frame group.
bool onFirstFrameInGroup();
bool onLastFrameInGroup();
void playOnce(CCreatureAnim::EAnimType type); //plays once given stage of animation, then resets to 2
int framesInGroup(CCreatureAnim::EAnimType group) const; //retirns number of fromes in given group
};

View File

@@ -3,7 +3,7 @@
#include "CBattleInterface.h"
#include "../CGameInfo.h"
#include "../CCreatureAnimation.h"
#include "CCreatureAnimation.h"
#include "../CPlayerInterface.h"
#include "../CMusicHandler.h"
#include "../../lib/BattleState.h"

View File

@@ -2,7 +2,7 @@
#include "CMeleeAttackAnimation.h"
#include "CBattleInterface.h"
#include "../CCreatureAnimation.h"
#include "CCreatureAnimation.h"
#include "../../lib/BattleState.h"
#include "CReverseAnimation.h"
@@ -40,18 +40,18 @@ bool CMeleeAttackAnimation::init()
int revShiftattacker = (attackingStack->attackerOwned ? -1 : 1);
int mutPos = SHexField::mutualPosition(attackingStackPosBeforeReturn, dest);
int mutPos = SBattleHex::mutualPosition(attackingStackPosBeforeReturn, dest);
if(mutPos == -1 && attackingStack->doubleWide())
{
mutPos = SHexField::mutualPosition(attackingStackPosBeforeReturn + revShiftattacker, attackedStack->position);
mutPos = SBattleHex::mutualPosition(attackingStackPosBeforeReturn + revShiftattacker, attackedStack->position);
}
if (mutPos == -1 && attackedStack->doubleWide())
{
mutPos = SHexField::mutualPosition(attackingStackPosBeforeReturn, attackedStack->occupiedHex());
mutPos = SBattleHex::mutualPosition(attackingStackPosBeforeReturn, attackedStack->occupiedHex());
}
if (mutPos == -1 && attackedStack->doubleWide() && attackingStack->doubleWide())
{
mutPos = SHexField::mutualPosition(attackingStackPosBeforeReturn + revShiftattacker, attackedStack->occupiedHex());
mutPos = SBattleHex::mutualPosition(attackingStackPosBeforeReturn + revShiftattacker, attackedStack->occupiedHex());
}
@@ -89,7 +89,7 @@ void CMeleeAttackAnimation::endAnim()
delete this;
}
CMeleeAttackAnimation::CMeleeAttackAnimation(CBattleInterface * _owner, const CStack * attacker, SHexField _dest, const CStack * _attacked)
CMeleeAttackAnimation::CMeleeAttackAnimation(CBattleInterface * _owner, const CStack * attacker, SBattleHex _dest, const CStack * _attacked)
: CAttackAnimation(_owner, attacker, _dest, _attacked)
{
}

View File

@@ -24,5 +24,5 @@ public:
void nextFrame();
void endAnim();
CMeleeAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SHexField _dest, const CStack *_attacked);
CMeleeAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SBattleHex _dest, const CStack *_attacked);
};

View File

@@ -2,13 +2,13 @@
#include "CMovementAnimation.h"
#include "CBattleInterface.h"
#include "../CCreatureAnimation.h"
#include "CCreatureAnimation.h"
#include "../../lib/BattleState.h"
#include "../CGameInfo.h"
#include "../CMusicHandler.h"
#include "CReverseAnimation.h"
#include "CMovementEndAnimation.h"
#include "CHexFieldControl.h"
#include "CClickableHex.h"
bool CMovementAnimation::init()
{
@@ -32,10 +32,10 @@ bool CMovementAnimation::init()
}
//bool twoTiles = movedStack->doubleWide();
Point begPosition = CHexFieldControl::getXYUnitAnim(curStackPos, movedStack->attackerOwned, movedStack, owner);
Point endPosition = CHexFieldControl::getXYUnitAnim(nextHex, movedStack->attackerOwned, movedStack, owner);
SPoint begPosition = CClickableHex::getXYUnitAnim(curStackPos, movedStack->attackerOwned, movedStack, owner);
SPoint endPosition = CClickableHex::getXYUnitAnim(nextHex, movedStack->attackerOwned, movedStack, owner);
int mutPos = SHexField::mutualPosition(curStackPos, nextHex);
int mutPos = SBattleHex::mutualPosition(curStackPos, nextHex);
//reverse unit if necessary
if((begPosition.x > endPosition.x) && owner->creDir[stack->ID] == true)
@@ -116,7 +116,7 @@ void CMovementAnimation::nextFrame()
if(whichStep == steps)
{
// Sets the position of the creature animation sprites
Point coords = CHexFieldControl::getXYUnitAnim(nextHex, owner->creDir[stack->ID], stack, owner);
SPoint coords = CClickableHex::getXYUnitAnim(nextHex, owner->creDir[stack->ID], stack, owner);
myAnim()->pos = coords;
// true if creature haven't reached the final destination hex
@@ -168,7 +168,7 @@ void CMovementAnimation::endAnim()
delete this;
}
CMovementAnimation::CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector<SHexField> _destTiles, int _distance)
CMovementAnimation::CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector<SBattleHex> _destTiles, int _distance)
: CBattleStackAnimation(_owner, _stack), destTiles(_destTiles), nextPos(0), distance(_distance), stepX(0.0), stepY(0.0)
{
curStackPos = stack->position;

View File

@@ -20,8 +20,8 @@ class CStack;
class CMovementAnimation : public CBattleStackAnimation
{
private:
std::vector<SHexField> destTiles; //destination
SHexField nextHex;
std::vector<SBattleHex> destTiles; //destination
SBattleHex nextHex;
ui32 nextPos;
int distance;
double stepX, stepY; //how far stack is moved in one frame
@@ -33,5 +33,5 @@ public:
void nextFrame();
void endAnim();
CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector<SHexField> _destTiles, int _distance);
CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector<SBattleHex> _destTiles, int _distance);
};

View File

@@ -1,7 +1,7 @@
#include "StdInc.h"
#include "CMovementEndAnimation.h"
#include "../CCreatureAnimation.h"
#include "CCreatureAnimation.h"
#include "../CMusicHandler.h"
#include "../CGameInfo.h"
#include "../../lib/BattleState.h"
@@ -46,7 +46,7 @@ void CMovementEndAnimation::endAnim()
delete this;
}
CMovementEndAnimation::CMovementEndAnimation(CBattleInterface * _owner, const CStack * _stack, SHexField destTile)
CMovementEndAnimation::CMovementEndAnimation(CBattleInterface * _owner, const CStack * _stack, SBattleHex destTile)
: CBattleStackAnimation(_owner, _stack), destinationTile(destTile)
{
}

View File

@@ -20,11 +20,11 @@ class CStack;
class CMovementEndAnimation : public CBattleStackAnimation
{
private:
SHexField destinationTile;
SBattleHex destinationTile;
public:
bool init();
void nextFrame();
void endAnim();
CMovementEndAnimation(CBattleInterface *_owner, const CStack *_stack, SHexField destTile);
CMovementEndAnimation(CBattleInterface *_owner, const CStack *_stack, SBattleHex destTile);
};

View File

@@ -4,7 +4,7 @@
#include "../CMusicHandler.h"
#include "CBattleInterface.h"
#include "../CGameInfo.h"
#include "../CCreatureAnimation.h"
#include "CCreatureAnimation.h"
#include "../../lib/BattleState.h"
#include "../CPlayerInterface.h"

View File

@@ -1,10 +1,10 @@
#include "StdInc.h"
#include "CReverseAnimation.h"
#include "../CCreatureAnimation.h"
#include "CCreatureAnimation.h"
#include "../../lib/BattleState.h"
#include "CBattleInterface.h"
#include "CHexFieldControl.h"
#include "CClickableHex.h"
bool CReverseAnimation::init()
{
@@ -58,7 +58,7 @@ void CReverseAnimation::endAnim()
delete this;
}
CReverseAnimation::CReverseAnimation(CBattleInterface * _owner, const CStack * stack, SHexField dest, bool _priority)
CReverseAnimation::CReverseAnimation(CBattleInterface * _owner, const CStack * stack, SBattleHex dest, bool _priority)
: CBattleStackAnimation(_owner, stack), partOfAnim(1), secondPartSetup(false), hex(dest), priority(_priority)
{
}
@@ -73,7 +73,7 @@ void CReverseAnimation::setupSecondPart()
return;
}
Point coords = CHexFieldControl::getXYUnitAnim(hex, owner->creDir[stack->ID], stack, owner);
SPoint coords = CClickableHex::getXYUnitAnim(hex, owner->creDir[stack->ID], stack, owner);
myAnim()->pos.x = coords.x;
//creAnims[stackID]->pos.y = coords.second;

View File

@@ -21,7 +21,7 @@ class CReverseAnimation : public CBattleStackAnimation
private:
int partOfAnim; //1 - first, 2 - second
bool secondPartSetup;
SHexField hex;
SBattleHex hex;
public:
bool priority; //true - high, false - low
bool init();
@@ -30,5 +30,5 @@ public:
void setupSecondPart();
void endAnim();
CReverseAnimation(CBattleInterface *_owner, const CStack *stack, SHexField dest, bool _priority);
CReverseAnimation(CBattleInterface *_owner, const CStack *stack, SBattleHex dest, bool _priority);
};

View File

@@ -4,13 +4,13 @@
#include "../../lib/BattleState.h"
#include "CBattleInterface.h"
#include "../CCreatureAnimation.h"
#include "CCreatureAnimation.h"
#include "../CGameInfo.h"
#include "../../lib/CTownHandler.h"
#include "CMovementStartAnimation.h"
#include "CReverseAnimation.h"
#include "CSpellEffectAnimation.h"
#include "CHexFieldControl.h"
#include "CClickableHex.h"
bool CShootingAnimation::init()
{
@@ -59,16 +59,16 @@ bool CShootingAnimation::init()
spi.spin = false;
}
Point xycoord = CHexFieldControl::getXYUnitAnim(shooter->position, true, shooter, owner);
Point destcoord;
SPoint xycoord = CClickableHex::getXYUnitAnim(shooter->position, true, shooter, owner);
SPoint destcoord;
// The "master" point where all projectile positions relate to.
static const Point projectileOrigin(181, 252);
static const SPoint projectileOrigin(181, 252);
if (attackedStack)
{
destcoord = CHexFieldControl::getXYUnitAnim(dest, false, attackedStack, owner);
destcoord = CClickableHex::getXYUnitAnim(dest, false, attackedStack, owner);
destcoord.x += 250; destcoord.y += 210; //TODO: find a better place to shoot
// Calculate projectile start position. Offsets are read out of the CRANIM.TXT.
@@ -185,7 +185,7 @@ void CShootingAnimation::endAnim()
delete this;
}
CShootingAnimation::CShootingAnimation(CBattleInterface * _owner, const CStack * attacker, SHexField _dest, const CStack * _attacked, bool _catapult, int _catapultDmg)
CShootingAnimation::CShootingAnimation(CBattleInterface * _owner, const CStack * attacker, SBattleHex _dest, const CStack * _attacked, bool _catapult, int _catapultDmg)
: CAttackAnimation(_owner, attacker, _dest, _attacked), catapultDamage(_catapultDmg), catapult(_catapult)
{

View File

@@ -1,7 +1,7 @@
#pragma once
#include "CAttackAnimation.h"
#include "../../lib/SHexField.h"
#include "../../lib/SBattleHex.h"
class CBattleInterface;
class CStack;
@@ -45,5 +45,5 @@ public:
//last param only for catapult attacks
CShootingAnimation(CBattleInterface *_owner, const CStack *attacker,
SHexField _dest, const CStack *_attacked, bool _catapult = false, int _catapultDmg = 0);
SBattleHex _dest, const CStack *_attacked, bool _catapult = false, int _catapultDmg = 0);
};

View File

@@ -8,6 +8,7 @@
#include "../../CCallback.h"
#include "../../lib/BattleState.h"
#include "../SDL_Extensions.h"
#include "../UIFramework/SRect.h"
//effect animation
bool CSpellEffectAnimation::init()
@@ -67,7 +68,7 @@ bool CSpellEffectAnimation::init()
if(effect == -1 || graphics->battleACToDef[effect].size() != 0)
{
const CStack* destStack = owner->curInt->cb->battleGetStackByPos(destTile, false);
Rect &tilePos = owner->bfield[destTile].pos;
SRect &tilePos = owner->bfield[destTile].pos;
SBattleEffect be;
be.effectID = ID;
if(customAnim.size())
@@ -170,7 +171,7 @@ void CSpellEffectAnimation::endAnim()
delete this;
}
CSpellEffectAnimation::CSpellEffectAnimation(CBattleInterface * _owner, ui32 _effect, SHexField _destTile, int _dx, int _dy, bool _Vflip)
CSpellEffectAnimation::CSpellEffectAnimation(CBattleInterface * _owner, ui32 _effect, SBattleHex _destTile, int _dx, int _dy, bool _Vflip)
:CBattleAnimation(_owner), effect(_effect), destTile(_destTile), customAnim(""), dx(_dx), dy(_dy), Vflip(_Vflip)
{
}

View File

@@ -2,7 +2,7 @@
#include "CBattleAnimation.h"
#include "../../lib/SHexField.h"
#include "../../lib/SBattleHex.h"
class CBattleInterface;
@@ -21,7 +21,7 @@ class CSpellEffectAnimation : public CBattleAnimation
{
private:
ui32 effect;
SHexField destTile;
SBattleHex destTile;
std::string customAnim;
int x, y, dx, dy;
bool Vflip;
@@ -30,6 +30,6 @@ public:
void nextFrame();
void endAnim();
CSpellEffectAnimation(CBattleInterface *_owner, ui32 _effect, SHexField _destTile, int _dx = 0, int _dy = 0, bool _Vflip = false);
CSpellEffectAnimation(CBattleInterface *_owner, ui32 _effect, SBattleHex _destTile, int _dx = 0, int _dy = 0, bool _Vflip = false);
CSpellEffectAnimation(CBattleInterface *_owner, std::string _customAnim, int _x, int _y, int _dx = 0, int _dy = 0, bool _Vflip = false);
};

View File

@@ -8,6 +8,7 @@
#include "../CPlayerInterface.h"
#include "../CBitmapHandler.h"
#include "../../CCallback.h"
#include "../UIFramework/CGuiHandler.h"
void CStackQueue::update()
{

View File

@@ -1,6 +1,6 @@
#pragma once
#include "../GUIBase.h"
#include "../UIFramework/CIntObject.h"
struct SDL_Surface;
class CStack;