2011-12-14 00:23:17 +03:00
|
|
|
#pragma once
|
|
|
|
|
2013-04-07 14:52:07 +03:00
|
|
|
#include "gui/CIntObject.h"
|
2011-03-03 20:25:48 +02:00
|
|
|
#include "../lib/HeroBonus.h"
|
2011-12-22 16:05:19 +03:00
|
|
|
#include "GUIClasses.h"
|
2011-03-03 20:25:48 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CCreatureWindow.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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-07-10 01:42:39 +03:00
|
|
|
struct Bonus;
|
2011-03-03 20:25:48 +02:00
|
|
|
class CCreature;
|
|
|
|
class CStackInstance;
|
2012-05-16 20:29:05 +03:00
|
|
|
class CCommanderInstance;
|
2011-03-03 20:25:48 +02:00
|
|
|
class CStack;
|
2012-05-28 22:29:32 +03:00
|
|
|
struct ArtifactLocation;
|
2012-02-10 13:32:21 +03:00
|
|
|
class CCreatureArtifactInstance;
|
2011-12-22 16:05:19 +03:00
|
|
|
class CAdventureMapButton;
|
2011-04-09 22:34:48 +03:00
|
|
|
class CBonusItem;
|
2011-12-22 16:05:19 +03:00
|
|
|
class CGHeroInstance;
|
|
|
|
class CComponent;
|
|
|
|
class LRClickableAreaWText;
|
|
|
|
class MoraleLuckBox;
|
|
|
|
class CAdventureMapButton;
|
|
|
|
struct UpgradeInfo;
|
|
|
|
class CPicture;
|
|
|
|
class CCreaturePic;
|
|
|
|
class LRClickableAreaWTextComp;
|
|
|
|
class CSlider;
|
|
|
|
class CLabel;
|
|
|
|
class CAnimImage;
|
2012-07-03 11:07:34 +03:00
|
|
|
class CSelectableSkill;
|
2011-03-03 20:25:48 +02:00
|
|
|
|
2012-02-10 13:32:21 +03:00
|
|
|
// New creature window
|
2012-06-15 20:08:19 +03:00
|
|
|
class CCreatureWindow : public CWindowObject, public CArtifactHolder
|
2011-03-03 20:25:48 +02:00
|
|
|
{
|
|
|
|
public:
|
2012-08-20 19:10:50 +03:00
|
|
|
enum CreWinType {OTHER = 0, BATTLE = 1, ARMY = 2, HERO = 3, COMMANDER = 4, COMMANDER_LEVEL_UP = 5, COMMANDER_BATTLE = 6}; // > 3 are opened permanently
|
2011-03-03 20:25:48 +02:00
|
|
|
//bool active; //TODO: comment me
|
2013-01-31 00:28:31 +03:00
|
|
|
CreWinType type;
|
2011-04-09 22:34:48 +03:00
|
|
|
int bonusRows; //height of skill window
|
2013-02-12 22:49:40 +03:00
|
|
|
ArtifactPosition displayedArtifact;
|
2011-03-03 20:25:48 +02:00
|
|
|
|
2011-04-09 22:34:48 +03:00
|
|
|
std::string count; //creature count in text format
|
2011-03-03 20:25:48 +02:00
|
|
|
const CCreature *c; //related creature
|
2011-04-09 22:34:48 +03:00
|
|
|
const CStackInstance *stack;
|
|
|
|
const CBonusSystemNode *stackNode;
|
2012-05-16 20:29:05 +03:00
|
|
|
const CCommanderInstance * commander;
|
2011-04-09 22:34:48 +03:00
|
|
|
const CGHeroInstance *heroOwner;
|
2012-04-14 05:20:22 +03:00
|
|
|
const CArtifactInstance *creatureArtifact; //currently worn artifact
|
2011-12-22 16:05:19 +03:00
|
|
|
std::vector<CComponent*> upgResCost; //cost of upgrade (if not possible then empty)
|
2011-04-09 22:34:48 +03:00
|
|
|
std::vector<CBonusItem*> bonusItems;
|
2011-05-21 10:07:07 +03:00
|
|
|
std::vector<LRClickableAreaWText*> spellEffects;
|
2011-03-03 20:25:48 +02:00
|
|
|
|
2011-04-09 22:34:48 +03:00
|
|
|
CCreaturePic *anim; //related creature's animation
|
2011-03-03 20:25:48 +02:00
|
|
|
MoraleLuckBox *luck, *morale;
|
2011-05-21 10:07:07 +03:00
|
|
|
LRClickableAreaWTextComp * expArea; //displays exp details
|
2011-03-03 20:25:48 +02:00
|
|
|
CSlider * slider; //Abilities
|
2011-12-22 16:05:19 +03:00
|
|
|
CAdventureMapButton *dismiss, *upgrade, *ok;
|
|
|
|
CAdventureMapButton * leftArtRoll, * rightArtRoll; //artifact selection
|
2012-02-04 19:34:29 +03:00
|
|
|
CAdventureMapButton * passArtToHero;
|
2014-03-10 19:00:58 +03:00
|
|
|
CAnimImage * artifactImage;
|
|
|
|
CAnimation * spellEffectsPics; //bitmaps representing spells affecting a stack in battle
|
2012-05-13 18:04:21 +03:00
|
|
|
|
2012-07-03 11:07:34 +03:00
|
|
|
//commander level-up
|
2012-07-04 17:41:53 +03:00
|
|
|
int selectedOption; //index for upgradeOptions
|
|
|
|
std::vector<ui32> upgradeOptions; //value 0-5 - secondary skills, 100+ - special skills
|
|
|
|
std::vector<CSelectableSkill *> selectableSkills, selectableBonuses;
|
2012-07-03 11:07:34 +03:00
|
|
|
std::vector<CPicture *> skillPictures; //secondary skills
|
|
|
|
|
|
|
|
std::string skillToFile(int skill); //return bitmap for secondary skill depending on selection / avaliability
|
|
|
|
void selectSkill (ui32 which);
|
2012-05-13 18:04:21 +03:00
|
|
|
void setArt(const CArtifactInstance *creatureArtifact);
|
2011-03-03 20:25:48 +02:00
|
|
|
|
2012-04-17 17:50:23 +03:00
|
|
|
void artifactRemoved (const ArtifactLocation &artLoc);
|
|
|
|
void artifactMoved (const ArtifactLocation &artLoc, const ArtifactLocation &destLoc);
|
|
|
|
void artifactDisassembled (const ArtifactLocation &artLoc) {return;};
|
|
|
|
void artifactAssembled (const ArtifactLocation &artLoc) {return;};
|
|
|
|
|
2013-06-26 14:18:27 +03:00
|
|
|
std::function<void()> dsm; //dismiss button callback
|
|
|
|
std::function<void()> Upg; //upgrade button callback
|
|
|
|
std::function<void(ui32)> levelUp; //choose commander skill to level up
|
2011-04-09 22:34:48 +03:00
|
|
|
|
2013-01-31 00:28:31 +03:00
|
|
|
CCreatureWindow(const CStack & stack, CreWinType type); //battle c-tor
|
|
|
|
CCreatureWindow (const CStackInstance &stack, CreWinType Type); //pop-up c-tor
|
2013-06-26 14:18:27 +03:00
|
|
|
CCreatureWindow(const CStackInstance &st, CreWinType Type, std::function<void()> Upg, std::function<void()> Dsm, UpgradeInfo *ui); //full garrison window
|
|
|
|
CCreatureWindow(const CCommanderInstance * commander, const CStack * stack = nullptr); //commander window
|
|
|
|
CCreatureWindow(std::vector<ui32> &skills, const CCommanderInstance * commander, std::function<void(ui32)> callback);
|
2013-02-11 02:24:57 +03:00
|
|
|
CCreatureWindow(CreatureID Cid, CreWinType Type, int creatureCount); //c-tor
|
2012-02-10 13:32:21 +03:00
|
|
|
|
2011-03-03 20:25:48 +02:00
|
|
|
void init(const CStackInstance *stack, const CBonusSystemNode *stackNode, const CGHeroInstance *heroOwner);
|
2011-04-09 22:34:48 +03:00
|
|
|
void showAll(SDL_Surface * to);
|
2011-08-05 10:59:15 +03:00
|
|
|
void show(SDL_Surface * to);
|
2011-03-03 20:25:48 +02:00
|
|
|
void printLine(int nr, const std::string &text, int baseVal, int val=-1, bool range=false);
|
2011-04-09 22:34:48 +03:00
|
|
|
void sliderMoved(int newpos);
|
2012-07-03 11:07:34 +03:00
|
|
|
void close();
|
2012-02-10 13:32:21 +03:00
|
|
|
~CCreatureWindow(); //d-tor
|
|
|
|
|
|
|
|
void recreateSkillList(int pos);
|
2011-03-03 20:25:48 +02:00
|
|
|
void scrollArt(int dir);
|
2012-02-10 13:32:21 +03:00
|
|
|
void passArtifactToHero();
|
2011-03-03 20:25:48 +02:00
|
|
|
};
|
|
|
|
|
2011-04-09 22:34:48 +03:00
|
|
|
class CBonusItem : public LRClickableAreaWTextComp //responsible for displaying creature skill, active or not
|
2011-03-03 20:25:48 +02:00
|
|
|
{
|
2011-04-09 22:34:48 +03:00
|
|
|
public:
|
|
|
|
std::string name, description;
|
|
|
|
CPicture * bonusGraphics;
|
|
|
|
bool visible;
|
|
|
|
|
|
|
|
CBonusItem();
|
2011-12-22 16:05:19 +03:00
|
|
|
CBonusItem(const Rect &Pos, const std::string &Name, const std::string &Description, const std::string &graphicsName);
|
2011-04-09 22:34:48 +03:00
|
|
|
~CBonusItem();
|
|
|
|
|
|
|
|
void showAll (SDL_Surface * to);
|
2011-05-28 01:34:58 +03:00
|
|
|
};
|
2011-12-22 16:05:19 +03:00
|
|
|
|
2012-07-03 11:07:34 +03:00
|
|
|
class CSelectableSkill : public LRClickableAreaWText
|
|
|
|
{
|
|
|
|
public:
|
2013-06-26 14:18:27 +03:00
|
|
|
std::function<void()> callback; //TODO: create more generic clickable class than AdvMapButton?
|
2012-07-03 11:07:34 +03:00
|
|
|
|
|
|
|
virtual void clickLeft(tribool down, bool previousState);
|
|
|
|
virtual void clickRight(tribool down, bool previousState){};
|
|
|
|
};
|
|
|
|
|
2012-02-10 13:32:21 +03:00
|
|
|
/// original creature info window
|
2012-06-15 20:08:19 +03:00
|
|
|
class CCreInfoWindow : public CWindowObject
|
2011-12-22 16:05:19 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CLabel * creatureCount;
|
|
|
|
CLabel * creatureName;
|
|
|
|
CLabel * abilityText;
|
|
|
|
|
|
|
|
CCreaturePic * animation;
|
|
|
|
std::vector<CComponent *> upgResCost; //cost of upgrade (if not possible then empty)
|
|
|
|
std::vector<CAnimImage *> effects;
|
|
|
|
std::map<size_t, std::pair<CLabel *, CLabel * > > infoTexts;
|
|
|
|
|
|
|
|
MoraleLuckBox * luck, * morale;
|
|
|
|
|
|
|
|
CAdventureMapButton * dismiss, * upgrade, * ok;
|
|
|
|
|
2013-07-02 15:08:30 +03:00
|
|
|
CCreInfoWindow(const CStackInstance & st, bool LClicked, std::function<void()> Upg = nullptr, std::function<void()> Dsm = nullptr, UpgradeInfo * ui = nullptr);
|
2011-12-22 16:05:19 +03:00
|
|
|
CCreInfoWindow(const CStack & st, bool LClicked = 0);
|
|
|
|
CCreInfoWindow(int Cid, bool LClicked, int creatureCount);
|
|
|
|
~CCreInfoWindow();
|
|
|
|
|
|
|
|
void init(const CCreature * cre, const CBonusSystemNode * stackNode, const CGHeroInstance * heroOwner, int creatureCount, bool LClicked);
|
|
|
|
void printLine(int nr, const std::string & text, int baseVal, int val = -1, bool range = false);
|
|
|
|
|
|
|
|
void show(SDL_Surface * to);
|
|
|
|
};
|
|
|
|
|
2012-03-31 00:36:07 +03:00
|
|
|
CIntObject *createCreWindow(const CStack *s, bool lclick = false);
|
2013-02-11 02:24:57 +03:00
|
|
|
CIntObject *createCreWindow(CreatureID Cid, CCreatureWindow::CreWinType Type, int creatureCount);
|
2013-07-02 15:08:30 +03:00
|
|
|
CIntObject *createCreWindow(const CStackInstance *s, CCreatureWindow::CreWinType type, std::function<void()> Upg = nullptr, std::function<void()> Dsm = nullptr, UpgradeInfo *ui = nullptr);
|