1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00
vcmi/client/CSpellWindow.h
Ivan Savenko 2d8a15f27c - all windows except for pregame\battles are now CWindowObject-based
- added simple scaling algorithm that works with indexed surfaces
2012-06-15 17:08:19 +00:00

115 lines
3.4 KiB
C++

#pragma once
#include "UIFramework/CIntObject.h"
#include "UIFramework/CIntObjectClasses.h"
/*
* 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
*
*/
struct SDL_Surface;
class CDefHandler;
struct SDL_Rect;
class CGHeroInstance;
class CStatusBar;
class CPlayerInterface;
/// Spellbook button is used by the spell window class
class SpellbookInteractiveArea : public CIntObject
{
private:
boost::function<void()> onLeft;
std::string textOnRclick;
boost::function<void()> onHoverOn;
boost::function<void()> onHoverOff;
CPlayerInterface * myInt;
public:
void clickLeft(tribool down, bool previousState);
void clickRight(tribool down, bool previousState);
void hover(bool on);
SpellbookInteractiveArea(const SDL_Rect & myRect, boost::function<void()> funcL, const std::string & textR,
boost::function<void()> funcHon, boost::function<void()> funcHoff, CPlayerInterface * _myInt);//c-tor
};
/// The spell window
class CSpellWindow : public CWindowObject
{
private:
class SpellArea : public CIntObject
{
public:
int mySpell;
int schoolLevel; //range: 0 none, 3 - expert
int whichSchool; //0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic,
int spellCost;
CSpellWindow * owner;
SpellArea(SDL_Rect pos, CSpellWindow * owner);
void setSpell(int spellID);
void clickLeft(tribool down, bool previousState);
void clickRight(tribool down, bool previousState);
void hover(bool on);
void showAll(SDL_Surface * to);
};
SDL_Surface * 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 currentPage; //changes when corners are clicked
std::set<ui32> mySpells; //all spels in this spellbook
const CGHeroInstance * myHero; //hero whose spells are presented
void computeSpellsPerArea(); //recalculates spellAreas::mySpell
void turnPageLeft();
void turnPageRight();
CPlayerInterface * myInt;
public:
CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * _myHero, CPlayerInterface * _myInt, bool openOnBattleSpells = true); //c-tor
~CSpellWindow(); //d-tor
void fexitb();
void fadvSpellsb();
void fbattleSpellsb();
void fmanaPtsb();
void fLcornerb();
void fRcornerb();
void selectSchool(int school); //schools: 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, 4 - all schools
Uint8 pagesWithinCurrentTab();
void keyPressed(const SDL_KeyboardEvent & key);
void activate();
void deactivate();
void showAll(SDL_Surface * to);
void teleportTo(int town, const CGHeroInstance * hero);
};