1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-28 23:06:24 +02:00
vcmi/CBattleInterface.h

86 lines
2.7 KiB
C
Raw Normal View History

#pragma once
#include "global.h"
#include "CPlayerInterface.h"
class CCreatureSet;
class CGHeroInstance;
class CDefHandler;
class CStack;
2008-03-10 22:19:41 +02:00
class CCallback;
template <typename T> class AdventureMapButton;
class CBattleHero : public IShowable, public CIntObject
{
public:
bool flip; //false if it's attacking hero, true otherwise
CDefHandler * dh, *flag; //animation and flag
int phase; //stage of animation
int image; //frame of animation
unsigned char flagAnim, flagAnimCount; //for flag animation
void show(SDL_Surface * to); //prints next frame of animation to to
CBattleHero(std::string defName, int phaseG, int imageG, bool filpG, unsigned char player); //c-tor
~CBattleHero(); //d-tor
};
2008-03-10 22:19:41 +02:00
class CBattleHex : public Hoverable
{
2008-03-10 22:19:41 +02:00
public:
unsigned int myNumber;
bool accesible;
2008-03-10 22:19:41 +02:00
//CStack * ourStack;
bool hovered;
static std::pair<int, int> getXYUnitAnim(int hexNum, bool attacker); //returns (x, y) of left top corner of animation
//for user interactions
void hover (bool on);
void activate();
void deactivate();
CBattleHex();
};
class CBattleObstacle
{
std::vector<int> lockedHexes;
};
class CBattleInterface : public IActivable, public IShowable
{
private:
SDL_Surface * background, * menu;
AdventureMapButton<CBattleInterface> * bOptions, * bSurrender, * bFlee, * bAutofight, * bSpell,
* bWait, * bDefence, * bConsoleUp, * bConsoleDown;
CBattleHero * attackingHero, * defendingHero;
CCreatureSet * army1, * army2; //fighting armies
2008-03-10 22:19:41 +02:00
CGHeroInstance * attackingHeroInstance, * defendingHeroInstance;
std::map< int, CCreatureAnimation * > creAnims; //animations of creatures from fighting armies (order like in BattleInfo's stacks)
2008-03-10 22:19:41 +02:00
public:
CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2); //c-tor
~CBattleInterface(); //d-tor
//std::vector<TimeInterested*> timeinterested; //animation handling
bool printCellBorders; //if true, cell borders will be printed
CBattleHex bfield[187]; //11 lines, 17 hexes on each
std::vector< CBattleObstacle * > obstacles; //vector of obstacles on the battlefield
static SDL_Surface * cellBorder, * cellShade;
//button handle funcs:
void bOptionsf();
void bSurrenderf();
void bFleef();
void bAutofightf();
void bSpellf();
void bWaitf();
void bDefencef();
void bConsoleUpf();
void bConsoleDownf();
//end of button handle funcs
//napisz tu klase odpowiadajaca za wyswietlanie bitwy i obsluge uzytkownika, polecenia ma przekazywac callbackiem
void activate();
void deactivate();
void show(SDL_Surface * to);
//call-ins
void newStack(CStack stack);
void stackRemoved(CStack stack);
};