1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00
vcmi/client/CSpellWindow.h

89 lines
2.7 KiB
C
Raw Normal View History

2008-09-10 15:19:48 +03:00
#pragma once
#include "../global.h"
#include "../CPlayerInterface.h"
2008-09-10 15:19:48 +03:00
struct SDL_Surface;
class CDefHandler;
struct SDL_Rect;
class CGHeroInstance;
2008-09-11 15:29:22 +03:00
class SpellbookInteractiveArea : public ClickableL, public ClickableR, public Hoverable
2008-09-10 15:19:48 +03:00
{
private:
2008-09-11 15:29:22 +03:00
boost::function<void()> onLeft;
std::string textOnRclick;
boost::function<void()> onHoverOn;
boost::function<void()> onHoverOff;
2008-09-10 15:19:48 +03:00
public:
void clickLeft(boost::logic::tribool down);
2008-09-11 15:29:22 +03:00
void clickRight(boost::logic::tribool down);
void hover(bool on);
2008-09-10 15:19:48 +03:00
void activate();
void deactivate();
2008-09-11 15:29:22 +03:00
SpellbookInteractiveArea(SDL_Rect & myRect, boost::function<void()> funcL, std::string textR, boost::function<void()> funcHon, boost::function<void()> funcHoff);//c-tor
2008-09-10 15:19:48 +03:00
};
class CSpellWindow : public IShowActivable, public CIntObject
{
private:
class SpellArea : public ClickableL, public ClickableR, public Hoverable
{
public:
int mySpell;
CSpellWindow * owner;
SpellArea(SDL_Rect pos, CSpellWindow * owner);
void clickLeft(boost::logic::tribool down);
void clickRight(boost::logic::tribool down);
void hover(bool on);
void activate();
void deactivate();
};
2008-09-10 15:19:48 +03:00
SDL_Surface * background, * leftCorner, * rightCorner;
CDefHandler * spells, //pictures of spells
* spellTab, //school select
* schools, //schools' pictures
* schoolBorders [4]; //schools' 'borders': [0]: air, [1]: fire, [2]: water, [3]: earth
2008-09-10 15:19:48 +03:00
2008-09-11 15:29:22 +03:00
SpellbookInteractiveArea * exitBtn, * battleSpells, * adventureSpells, * manaPoints;
SpellbookInteractiveArea * selectSpellsA, * selectSpellsE, * selectSpellsF, * selectSpellsW, * selectSpellsAll;
SpellbookInteractiveArea * lCorner, * rCorner;
SpellArea * spellAreas[12];
2008-09-10 15:19:48 +03:00
CStatusBar * statusBar;
Uint8 sitesPerTabAdv[5];
Uint8 sitesPerTabBattle[5];
bool battleSpellsOnly; //if true, only battle spells are displayed; if false, only adventure map spells are displayed
2008-09-11 15:29:22 +03:00
Uint8 selectedTab; // 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, 4 - all schools
Uint8 spellSite; //changes when corners are clicked
std::set<ui32> mySpells; //all spels in this spellbook
Uint8 schoolLvls[4]; //levels of magic for different schools: [0]: air, [1]: fire, [2]: water, [3]: earth; 0 - none, 1 - beginner, 2 - medium, 3 - expert
void computeSpellsPerArea(); //recalculates spellAreas::mySpell
2008-09-10 15:19:48 +03:00
public:
CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero); //c-tor
~CSpellWindow(); //d-tor
void fexitb();
2008-09-11 15:29:22 +03:00
void fadvSpellsb();
void fbattleSpellsb();
void fmanaPtsb();
void fspellsAb();
void fspellsEb();
void fspellsFb();
void fspellsWb();
void fspellsAllb();
2008-09-10 15:19:48 +03:00
void fLcornerb();
void fRcornerb();
2008-09-10 15:19:48 +03:00
void activate();
void deactivate();
void show(SDL_Surface * to = NULL);
};