2008-02-25 01:06:27 +02:00
|
|
|
#pragma once
|
|
|
|
#include "global.h"
|
|
|
|
#include "CPlayerInterface.h"
|
2008-02-26 20:01:26 +02:00
|
|
|
|
2008-02-25 01:06:27 +02:00
|
|
|
class CCreatureSet;
|
|
|
|
class CGHeroInstance;
|
2008-03-03 21:41:10 +02:00
|
|
|
class CDefHandler;
|
2008-03-04 19:25:58 +02:00
|
|
|
class CStack;
|
2008-03-10 22:19:41 +02:00
|
|
|
class CCallback;
|
2008-02-26 20:01:26 +02:00
|
|
|
template <typename T> class AdventureMapButton;
|
|
|
|
|
2008-03-03 21:41:10 +02:00
|
|
|
class CBattleHero : public IShowable, public CIntObject
|
|
|
|
{
|
|
|
|
public:
|
2008-03-04 19:25:58 +02:00
|
|
|
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
|
2008-03-03 21:41:10 +02:00
|
|
|
~CBattleHero(); //d-tor
|
|
|
|
};
|
|
|
|
|
2008-03-10 22:19:41 +02:00
|
|
|
class CBattleHex : public Hoverable
|
2008-03-04 19:25:58 +02:00
|
|
|
{
|
2008-03-10 22:19:41 +02:00
|
|
|
public:
|
2008-03-04 19:25:58 +02:00
|
|
|
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();
|
2008-03-04 19:25:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class CBattleObstacle
|
|
|
|
{
|
|
|
|
std::vector<int> lockedHexes;
|
|
|
|
};
|
|
|
|
|
2008-02-26 20:01:26 +02:00
|
|
|
class CBattleInterface : public IActivable, public IShowable
|
2008-02-25 01:06:27 +02:00
|
|
|
{
|
2008-02-26 20:01:26 +02:00
|
|
|
private:
|
|
|
|
SDL_Surface * background, * menu;
|
|
|
|
AdventureMapButton<CBattleInterface> * bOptions, * bSurrender, * bFlee, * bAutofight, * bSpell,
|
|
|
|
* bWait, * bDefence, * bConsoleUp, * bConsoleDown;
|
2008-03-03 21:41:10 +02:00
|
|
|
CBattleHero * attackingHero, * defendingHero;
|
2008-03-05 19:01:41 +02:00
|
|
|
CCreatureSet * army1, * army2; //fighting armies
|
2008-03-10 22:19:41 +02:00
|
|
|
CGHeroInstance * attackingHeroInstance, * defendingHeroInstance;
|
2008-03-14 20:24:37 +02:00
|
|
|
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
|
|
|
|
2008-02-25 01:06:27 +02:00
|
|
|
public:
|
2008-03-14 20:24:37 +02:00
|
|
|
CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2); //c-tor
|
2008-03-04 19:25:58 +02:00
|
|
|
~CBattleInterface(); //d-tor
|
2008-02-26 20:01:26 +02:00
|
|
|
|
2008-03-03 21:41:10 +02:00
|
|
|
//std::vector<TimeInterested*> timeinterested; //animation handling
|
2008-03-04 19:25:58 +02:00
|
|
|
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
|
2008-03-14 20:24:37 +02:00
|
|
|
static SDL_Surface * cellBorder, * cellShade;
|
2008-03-03 21:41:10 +02:00
|
|
|
|
2008-02-26 20:01:26 +02:00
|
|
|
//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
|
2008-02-25 01:06:27 +02:00
|
|
|
//napisz tu klase odpowiadajaca za wyswietlanie bitwy i obsluge uzytkownika, polecenia ma przekazywac callbackiem
|
|
|
|
void activate();
|
|
|
|
void deactivate();
|
2008-02-26 20:01:26 +02:00
|
|
|
void show(SDL_Surface * to);
|
2008-03-14 20:24:37 +02:00
|
|
|
|
|
|
|
//call-ins
|
|
|
|
void newStack(CStack stack);
|
|
|
|
void stackRemoved(CStack stack);
|
2008-03-04 19:25:58 +02:00
|
|
|
};
|