1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-02 09:02:03 +02:00
vcmi/client/windows/CSpellWindow.h

114 lines
3.2 KiB
C
Raw Normal View History

#pragma once
#include "CWindowObject.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;
struct SDL_Rect;
2016-10-16 14:27:35 +02:00
class IImage;
2016-10-16 12:22:07 +02:00
class CAnimImage;
2016-10-16 14:27:35 +02:00
class CPicture;
class CGHeroInstance;
class CGStatusBar;
class CPlayerInterface;
class CSpellWindow;
2016-10-16 09:32:12 +02:00
class CSpell;
/// The spell window
class CSpellWindow : public CWindowObject
{
private:
class SpellArea : public CIntObject
{
public:
2016-10-16 09:32:12 +02:00
const CSpell * 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;
2016-10-16 12:22:07 +02:00
CAnimImage * image;
2016-10-16 14:27:35 +02:00
IImage * schoolBorder;
SpellArea(SDL_Rect pos, CSpellWindow * owner);
~SpellArea();
2016-10-16 09:32:12 +02:00
void setSpell(const CSpell * spell);
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void hover(bool on) override;
void showAll(SDL_Surface * to) override;
};
class InteractiveArea : public CIntObject
{
private:
std::function<void()> onLeft;
CSpellWindow * owner;
std::string hoverText;
std::string helpText;
public:
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void hover(bool on) override;
InteractiveArea(const SDL_Rect & myRect, std::function<void()> funcL, int helpTextId, CSpellWindow * _owner);//c-tor
};
2016-10-16 14:27:35 +02:00
CPicture * leftCorner, * rightCorner;
2016-10-16 10:28:50 +02:00
std::shared_ptr<CAnimation> spells; //pictures of spells
2016-10-16 14:27:35 +02:00
CAnimImage * spellTab; //school select
CAnimImage * schools; //schools' pictures
std::array< std::shared_ptr<CAnimation>, 4> schoolBorders; //schools' 'borders': [0]: air, [1]: fire, [2]: water, [3]: earth
SpellArea * spellAreas[12];
CGStatusBar * statusBar;
int sitesPerTabAdv[5];
int 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
int currentPage; //changes when corners are clicked
2016-10-16 09:32:12 +02:00
std::vector<const CSpell *> mySpells; //all spels in this spellbook
const CGHeroInstance * myHero; //hero whose spells are presented
2016-10-16 14:27:35 +02:00
CPlayerInterface * myInt;
void computeSpellsPerArea(); //recalculates spellAreas::mySpell
2016-10-16 14:27:35 +02:00
void setCurrentPage(int value);
2009-06-20 04:42:19 +03:00
void turnPageLeft();
void turnPageRight();
public:
2016-10-16 08:27:22 +02:00
CSpellWindow(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
int pagesWithinCurrentTab();
void keyPressed(const SDL_KeyboardEvent & key);
void showAll(SDL_Surface * to);
void show(SDL_Surface * to);
};