2009-04-16 14:14:13 +03:00
|
|
|
#ifndef __CSPELLWINDOW_H__
|
|
|
|
#define __CSPELLWINDOW_H__
|
|
|
|
|
|
|
|
|
|
|
|
#include "../global.h"
|
2009-05-20 12:02:50 +03:00
|
|
|
#include "GUIBase.h"
|
|
|
|
#include "boost/function.hpp"
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2009-04-15 17:03:31 +03:00
|
|
|
/*
|
|
|
|
* CSpellWindow.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
|
|
|
|
*
|
2009-04-16 14:14:13 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct SDL_Surface;
|
|
|
|
class CDefHandler;
|
|
|
|
struct SDL_Rect;
|
|
|
|
class CGHeroInstance;
|
2009-05-20 12:02:50 +03:00
|
|
|
class CStatusBar;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2009-08-11 19:05:33 +03:00
|
|
|
class SpellbookInteractiveArea : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
boost::function<void()> onLeft;
|
|
|
|
std::string textOnRclick;
|
|
|
|
boost::function<void()> onHoverOn;
|
|
|
|
boost::function<void()> onHoverOff;
|
|
|
|
public:
|
2009-08-11 19:05:33 +03:00
|
|
|
void clickLeft(tribool down, bool previousState);
|
|
|
|
void clickRight(tribool down, bool previousState);
|
2009-04-16 14:14:13 +03:00
|
|
|
void hover(bool on);
|
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
|
|
|
|
SpellbookInteractiveArea(const SDL_Rect & myRect, boost::function<void()> funcL, const std::string & textR, boost::function<void()> funcHon, boost::function<void()> funcHoff);//c-tor
|
|
|
|
};
|
|
|
|
|
2009-08-11 19:05:33 +03:00
|
|
|
class CSpellWindow : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
private:
|
2009-08-11 19:05:33 +03:00
|
|
|
class SpellArea : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
int mySpell;
|
|
|
|
CSpellWindow * owner;
|
|
|
|
|
|
|
|
SpellArea(SDL_Rect pos, CSpellWindow * owner);
|
2009-08-11 19:05:33 +03:00
|
|
|
void clickLeft(tribool down, bool previousState);
|
|
|
|
void clickRight(tribool down, bool previousState);
|
2009-04-16 14:14:13 +03:00
|
|
|
void hover(bool on);
|
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
SpellbookInteractiveArea * exitBtn, * battleSpells, * adventureSpells, * manaPoints;
|
|
|
|
SpellbookInteractiveArea * selectSpellsA, * selectSpellsE, * selectSpellsF, * selectSpellsW, * selectSpellsAll;
|
|
|
|
SpellbookInteractiveArea * lCorner, * rCorner;
|
|
|
|
SpellArea * spellAreas[12];
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
2009-07-21 16:53:26 +03:00
|
|
|
const CGHeroInstance * myHero; //hero whose spells are presented
|
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
void computeSpellsPerArea(); //recalculates spellAreas::mySpell
|
|
|
|
|
2009-06-20 04:42:19 +03:00
|
|
|
void turnPageLeft();
|
|
|
|
void turnPageRight();
|
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
public:
|
2009-07-21 16:53:26 +03:00
|
|
|
CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * _myHero, bool openOnBattleSpells = true); //c-tor
|
2009-04-16 14:14:13 +03:00
|
|
|
~CSpellWindow(); //d-tor
|
|
|
|
|
|
|
|
void fexitb();
|
|
|
|
void fadvSpellsb();
|
|
|
|
void fbattleSpellsb();
|
|
|
|
void fmanaPtsb();
|
|
|
|
|
|
|
|
void fspellsAb();
|
|
|
|
void fspellsEb();
|
|
|
|
void fspellsFb();
|
|
|
|
void fspellsWb();
|
|
|
|
void fspellsAllb();
|
|
|
|
|
|
|
|
void fLcornerb();
|
|
|
|
void fRcornerb();
|
|
|
|
|
2009-07-03 22:57:14 +03:00
|
|
|
void keyPressed(const SDL_KeyboardEvent & key);
|
2009-04-16 14:14:13 +03:00
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
void show(SDL_Surface * to);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __CSPELLWINDOW_H__
|