1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00
vcmi/CHeroWindow.h
Michał W. Urbańczyk 7722d058f0 Fixed issues reported by Zamolxis:
* dismiss Hero works blocked in the castles
* the backpack scrollable arrows aren't available (yellow, clickable) even when backpack is empty.
* added missing info texts for buttons in hero window (and added functionality of enable tactic formations button)
* can select (single click) and enter castle (double click) from the map. Same for hero.
* Hero gets automatically selected after End Turn 
* Hero is automatically selected when exiting town
* In Garrison or Hero army: units are selected when we first click on them
Fixed (at least partially) also a problem with disappearing path
2008-08-28 17:36:34 +00:00

140 lines
4.9 KiB
C++

#pragma once
#include "CPlayerInterface.h"
class AdventureMapButton;
struct SDL_Surface;
class CGHeroInstance;
class CDefHandler;
class CArtifact;
class CHeroWindow;
class LClickableArea: public ClickableL
{
public:
virtual void clickLeft (tribool down);
virtual void activate();
virtual void deactivate();
};
class RClickableArea: public ClickableR
{
public:
virtual void clickRight (tribool down);
virtual void activate();
virtual void deactivate();
};
class LClickableAreaHero : public LClickableArea
{
public:
int id;
CHeroWindow * owner;
virtual void clickLeft (tribool down);
};
class LRClickableAreaWText: public LClickableArea, public RClickableArea, public Hoverable
{
public:
std::string text, hoverText;
virtual void activate();
virtual void deactivate();
virtual void clickLeft (tribool down);
virtual void clickRight (tribool down);
virtual void hover(bool on);
};
class LRClickableAreaWTextComp: public LClickableArea, public RClickableArea, public Hoverable
{
public:
std::string text, hoverText;
int baseType;
int bonus, type;
virtual void activate();
virtual void deactivate();
virtual void clickLeft (tribool down);
virtual void clickRight (tribool down);
virtual void hover(bool on);
};
class CArtPlace: public IShowable, public LRClickableAreaWTextComp
{
private:
bool active;
public:
//bool spellBook, warMachine1, warMachine2, warMachine3, warMachine4,
// misc1, misc2, misc3, misc4, misc5, feet, lRing, rRing, torso,
// lHand, rHand, neck, shoulders, head; //my types
ui16 slotID; //0 head 1 shoulders 2 neck 3 right hand 4 left hand 5 torso 6 right ring 7 left ring 8 feet 9 misc. slot 1 10 misc. slot 2 11 misc. slot 3 12 misc. slot 4 13 ballista (war machine 1) 14 ammo cart (war machine 2) 15 first aid tent (war machine 3) 16 catapult 17 spell book 18 misc. slot 5 19+ backpack slots
bool clicked;
CHeroWindow * ourWindow;
const CArtifact * ourArt;
CArtPlace(const CArtifact * Art);
void clickLeft (tribool down);
void clickRight (tribool down);
void activate();
void deactivate();
void show(SDL_Surface * to = NULL);
bool fitsHere(const CArtifact * art); //returns true if given artifact can be placed here
~CArtPlace();
};
class CHeroWindow: public IShowActivable, public virtual CIntObject
{
SDL_Surface * background, * curBack;
const CGHeroInstance * curHero;
CGarrisonInt * garInt;
CStatusBar * ourBar; //heroWindow's statusBar
//general graphics
CDefHandler *flags;
//buttons
AdventureMapButton * gar4button; //splitting
//std::vector< AdventureMapButton<CHeroWindow> * > heroList; //list of heroes
std::vector<LClickableAreaHero *> heroListMi; //new better list of heroes
//artifact places
//CArtPlace * artHead, * artLRing, * artRRing, * artLHand, * artRhand,
// * artFeet, * artSpellBook, * artMach1, * artMach2, * artMach3,
// * artMach4, * artMisc1, * artMisc2, * artMisc3, * artMisc4,
// * artMisc5, * artTorso, * artNeck, * artShoulders; //hero's artifacts
std::vector<CArtPlace *> artWorn; // 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
std::vector<CArtPlace *> backpack; //hero's visible backpack (only 5 elements!)
int backpackPos; //unmber of first art visible in backpack (in hero's vector)
CArtPlace * activeArtPlace;
//clickable areas
LRClickableAreaWText * portraitArea;
std::vector<LRClickableAreaWTextComp *> primSkillAreas;
LRClickableAreaWText * expArea;
LRClickableAreaWText * spellPointsArea;
std::vector<LRClickableAreaWTextComp *> secSkillAreas;
public:
AdventureMapButton * quitButton, * dismissButton, * questlogButton, //general
* gar1button, * gar3button, //garrison / formation handling
* leftArtRoll, * rightArtRoll;
CHighlightableButton *gar2button;
int player;
CHeroWindow(int playerColor); //c-tor
~CHeroWindow(); //d-tor
void setHero(const CGHeroInstance * Hero); //sets main displayed hero
void activate(); //activates hero window;
void deactivate(); //activates hero window;
virtual void show(SDL_Surface * to = NULL); //shows hero window
void redrawCurBack(); //redraws curBAck from scratch
void quit(); //stops displaying hero window
void dismissCurrent(); //dissmissed currently displayed hero (curHero)
void questlog(); //show quest log in hero window
void gar1(); //garrison / formation handling
void gar2(); //garrison / formation handling
void gar3(); //garrison / formation handling
void gar4(); //garrison / formation handling
void leftArtRoller(); //scrolls artifacts in bag left
void rightArtRoller(); //scrolls artifacts in bag right
void switchHero(); //changes displayed hero
//friends
friend void CArtPlace::clickLeft(tribool down);
friend class CPlayerInterface;
};