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
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "CWindowObject.h"
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class CGHeroInstance;
|
|
|
|
class CSpell;
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
struct SDL_Surface;
|
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;
|
2016-10-17 03:05:33 +02:00
|
|
|
class CLabel;
|
2012-12-22 23:05:08 +03:00
|
|
|
class CGStatusBar;
|
2011-12-17 21:59:59 +03:00
|
|
|
class CPlayerInterface;
|
2016-10-16 08:03:13 +02:00
|
|
|
class CSpellWindow;
|
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
|
|
|
{
|
2009-08-11 19:05:33 +03:00
|
|
|
class SpellArea : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2016-10-16 09:32:12 +02:00
|
|
|
const CSpell * mySpell;
|
2010-07-21 13:09:29 +03:00
|
|
|
int schoolLevel; //range: 0 none, 3 - expert
|
2009-04-16 14:14:13 +03:00
|
|
|
CSpellWindow * owner;
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CAnimImage> image;
|
|
|
|
std::shared_ptr<CAnimImage> schoolBorder;
|
|
|
|
std::shared_ptr<CLabel> name;
|
|
|
|
std::shared_ptr<CLabel> level;
|
|
|
|
std::shared_ptr<CLabel> cost;
|
2016-10-17 04:05:48 +02:00
|
|
|
public:
|
2023-01-17 22:01:35 +02:00
|
|
|
SpellArea(Rect pos, CSpellWindow * owner);
|
2016-10-16 11:58:18 +02:00
|
|
|
~SpellArea();
|
2016-10-16 09:32:12 +02:00
|
|
|
void setSpell(const CSpell * spell);
|
2010-07-21 13:09:29 +03:00
|
|
|
|
2016-10-16 08:17:23 +02:00
|
|
|
void clickLeft(tribool down, bool previousState) override;
|
|
|
|
void clickRight(tribool down, bool previousState) override;
|
|
|
|
void hover(bool on) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class InteractiveArea : public CIntObject
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2023-01-17 22:01:35 +02:00
|
|
|
InteractiveArea(const Rect &myRect, std::function<void()> funcL, int helpTextId, CSpellWindow * _owner);
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CAnimation> spellIcons;
|
|
|
|
std::array<std::shared_ptr<CAnimation>, 4> schoolBorders; //[0]: air, [1]: fire, [2]: water, [3]: earth
|
2016-10-16 10:28:50 +02:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CPicture> leftCorner;
|
|
|
|
std::shared_ptr<CPicture> rightCorner;
|
2016-10-16 08:03:13 +02:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CAnimImage> schoolTab;
|
|
|
|
std::shared_ptr<CAnimImage> schoolPicture;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::array<std::shared_ptr<SpellArea>, 12> spellAreas;
|
|
|
|
std::shared_ptr<CLabel> mana;
|
|
|
|
std::shared_ptr<CGStatusBar> statusBar;
|
|
|
|
|
|
|
|
std::vector<std::shared_ptr<InteractiveArea>> interactiveAreas;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2016-10-16 08:03:13 +02:00
|
|
|
int sitesPerTabAdv[5];
|
|
|
|
int sitesPerTabBattle[5];
|
2009-04-16 14:14:13 +03:00
|
|
|
|
|
|
|
bool battleSpellsOnly; //if true, only battle spells are displayed; if false, only adventure map spells are displayed
|
2023-01-30 19:55:32 +02:00
|
|
|
uint8_t selectedTab; // 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, 4 - all schools
|
2016-10-16 08:03:13 +02:00
|
|
|
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
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2009-07-21 16:53:26 +03:00
|
|
|
const CGHeroInstance * myHero; //hero whose spells are presented
|
2016-10-16 14:27:35 +02:00
|
|
|
CPlayerInterface * myInt;
|
2009-07-21 16:53:26 +03:00
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
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();
|
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
public:
|
2017-07-17 23:04:00 +02:00
|
|
|
CSpellWindow(const CGHeroInstance * _myHero, CPlayerInterface * _myInt, bool openOnBattleSpells = true);
|
|
|
|
~CSpellWindow();
|
2009-04-16 14:14:13 +03:00
|
|
|
|
|
|
|
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
|
2016-10-16 08:03:13 +02:00
|
|
|
int pagesWithinCurrentTab();
|
2016-10-17 03:05:33 +02:00
|
|
|
|
2023-04-27 19:21:06 +02:00
|
|
|
void keyPressed(EShortcut key) override;
|
2023-02-02 18:02:25 +02:00
|
|
|
|
2016-10-17 03:05:33 +02:00
|
|
|
void show(SDL_Surface * to) override;
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|