2011-12-14 00:23:17 +03:00
|
|
|
#pragma once
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2014-07-15 10:14:49 +03:00
|
|
|
#include "CWindowObject.h"
|
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;
|
2012-12-22 23:05:08 +03:00
|
|
|
class CGStatusBar;
|
2011-12-17 21:59:59 +03:00
|
|
|
class CPlayerInterface;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Spellbook button is used by the spell window class
|
2009-08-11 19:05:33 +03:00
|
|
|
class SpellbookInteractiveArea : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
private:
|
2013-06-26 14:18:27 +03:00
|
|
|
std::function<void()> onLeft;
|
2009-04-16 14:14:13 +03:00
|
|
|
std::string textOnRclick;
|
2013-06-26 14:18:27 +03:00
|
|
|
std::function<void()> onHoverOn;
|
|
|
|
std::function<void()> onHoverOff;
|
2010-02-19 18:02:34 +02:00
|
|
|
CPlayerInterface * myInt;
|
2009-04-16 14:14:13 +03:00
|
|
|
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);
|
|
|
|
|
2013-06-26 14:18:27 +03:00
|
|
|
SpellbookInteractiveArea(const SDL_Rect & myRect, std::function<void()> funcL, const std::string & textR,
|
|
|
|
std::function<void()> funcHon, std::function<void()> funcHoff, CPlayerInterface * _myInt);//c-tor
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// The spell window
|
2012-06-15 20:08:19 +03:00
|
|
|
class CSpellWindow : public CWindowObject
|
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:
|
2013-02-11 02:24:57 +03:00
|
|
|
SpellID mySpell;
|
2010-07-21 13:09:29 +03:00
|
|
|
int schoolLevel; //range: 0 none, 3 - expert
|
|
|
|
int whichSchool; //0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic,
|
|
|
|
int spellCost;
|
2009-04-16 14:14:13 +03:00
|
|
|
CSpellWindow * owner;
|
|
|
|
|
2014-03-10 19:00:58 +03:00
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
SpellArea(SDL_Rect pos, CSpellWindow * owner);
|
2010-07-21 13:09:29 +03:00
|
|
|
|
2013-02-11 02:24:57 +03:00
|
|
|
void setSpell(SpellID spellID);
|
2010-07-21 13:09:29 +03:00
|
|
|
|
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);
|
2011-12-22 16:05:19 +03:00
|
|
|
void showAll(SDL_Surface * to);
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
2012-06-15 20:08:19 +03:00
|
|
|
SDL_Surface * leftCorner, * rightCorner;
|
2014-03-10 19:00:58 +03:00
|
|
|
|
|
|
|
CAnimation * spells; //pictures of spells
|
|
|
|
|
|
|
|
CDefHandler * spellTab, //school select
|
2009-04-16 14:14:13 +03:00
|
|
|
* 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];
|
2012-12-22 23:05:08 +03:00
|
|
|
CGStatusBar * statusBar;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
|
|
|
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
|
2010-07-21 13:09:29 +03:00
|
|
|
Uint8 currentPage; //changes when corners are clicked
|
2013-02-11 02:24:57 +03:00
|
|
|
std::set<SpellID> mySpells; //all spels in this spellbook
|
2009-04-16 14:14:13 +03:00
|
|
|
|
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();
|
|
|
|
|
2010-02-19 18:02:34 +02:00
|
|
|
CPlayerInterface * myInt;
|
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
public:
|
2010-02-19 18:02:34 +02:00
|
|
|
|
|
|
|
CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * _myHero, CPlayerInterface * _myInt, 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 fLcornerb();
|
|
|
|
void fRcornerb();
|
|
|
|
|
2010-07-21 13:09:29 +03:00
|
|
|
void selectSchool(int school); //schools: 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, 4 - all schools
|
|
|
|
Uint8 pagesWithinCurrentTab();
|
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();
|
2010-07-21 13:09:29 +03:00
|
|
|
void showAll(SDL_Surface * to);
|
2012-09-30 13:35:17 +03:00
|
|
|
void show(SDL_Surface * to);
|
2010-08-04 16:41:01 +03:00
|
|
|
|
|
|
|
void teleportTo(int town, const CGHeroInstance * hero);
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|