1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
/*
* 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
*
*/
#pragma once
#include "CWindowObject.h"
#include "../widgets/IVideoHolder.h"
VCMI_LIB_NAMESPACE_BEGIN
class CGHeroInstance;
class CSpell;
VCMI_LIB_NAMESPACE_END
class IImage;
class CAnimImage;
class CPicture;
class CLabel;
class CGStatusBar;
class CPlayerInterface;
class CSpellWindow;
class CTextInput;
class TransparentFilledRectangle;
class CToggleButton;
class VideoWidgetOnce;
/// The spell window
class CSpellWindow : public CWindowObject, public IVideoHolder
{
class SpellArea : public CIntObject
{
const CSpell * mySpell;
int schoolLevel; //range: 0 none, 3 - expert
CSpellWindow * owner;
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;
public:
SpellArea(Rect pos, CSpellWindow * owner);
~SpellArea();
void setSpell(const CSpell * spell);
void clickPressed(const Point & cursorPosition) override;
void showPopupWindow(const Point & cursorPosition) override;
void hover(bool on) override;
};
class InteractiveArea : public CIntObject
{
std::function<void()> onLeft;
CSpellWindow * owner;
std::string hoverText;
std::string helpText;
public:
void clickPressed(const Point & cursorPosition) override;
void showPopupWindow(const Point & cursorPosition) override;
void hover(bool on) override;
InteractiveArea(const Rect &myRect, std::function<void()> funcL, int helpTextId, CSpellWindow * _owner);
};
std::shared_ptr<CPicture> leftCorner;
std::shared_ptr<CPicture> rightCorner;
std::shared_ptr<CAnimImage> schoolTab;
std::shared_ptr<CAnimImage> schoolPicture;
std::array<std::shared_ptr<SpellArea>, 24> spellAreas;
std::shared_ptr<CLabel> mana;
std::shared_ptr<CGStatusBar> statusBar;
std::vector<std::shared_ptr<InteractiveArea>> interactiveAreas;
std::shared_ptr<CTextInput> searchBox;
std::shared_ptr<TransparentFilledRectangle> searchBoxRectangle;
std::shared_ptr<CLabel> searchBoxDescription;
std::shared_ptr<CToggleButton> showAllSpells;
std::shared_ptr<CLabel> showAllSpellsDescription;
std::shared_ptr<VideoWidgetOnce> video;
bool isBigSpellbook;
int spellsPerPage;
int offL;
int offR;
int offRM;
int offT;
int offB;
int sitesPerTabAdv[5];
int sitesPerTabBattle[5];
bool battleSpellsOnly; //if true, only battle spells are displayed; if false, only adventure map spells are displayed
uint8_t selectedTab; // 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, 4 - all schools
int currentPage; //changes when corners are clicked
std::vector<const CSpell *> mySpells; //all spels in this spellbook
const CGHeroInstance * myHero; //hero whose spells are presented
CPlayerInterface * myInt;
void processSpells();
void searchInput();
void computeSpellsPerArea(); //recalculates spellAreas::mySpell
void setCurrentPage(int value);
void turnPageLeft();
void turnPageRight();
void onVideoPlaybackFinished() override;
bool openOnBattleSpells;
std::function<void(SpellID)> onSpellSelect; //external processing of selected spell
public:
CSpellWindow(const CGHeroInstance * _myHero, CPlayerInterface * _myInt, bool openOnBattleSpells = true, const std::function<void(SpellID)> & onSpellSelect = nullptr);
~CSpellWindow();
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(EShortcut key) override;
void show(Canvas & to) override;
};
|