2017-07-13 10:26:03 +02:00
|
|
|
/*
|
|
|
|
* CBattleInterfaceClasses.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-12-22 16:05:19 +03:00
|
|
|
#pragma once
|
|
|
|
|
2013-04-07 14:52:07 +03:00
|
|
|
#include "../gui/CIntObject.h"
|
2017-06-24 16:42:05 +02:00
|
|
|
#include "../../lib/battle/BattleHex.h"
|
2016-09-27 14:13:20 +02:00
|
|
|
#include "../windows/CWindowObject.h"
|
2011-12-22 16:05:19 +03:00
|
|
|
|
|
|
|
struct SDL_Surface;
|
|
|
|
class CDefHandler;
|
|
|
|
class CGHeroInstance;
|
|
|
|
class CBattleInterface;
|
|
|
|
class CPicture;
|
2014-08-03 14:16:19 +03:00
|
|
|
class CButton;
|
|
|
|
class CToggleButton;
|
|
|
|
class CToggleGroup;
|
2011-12-22 16:05:19 +03:00
|
|
|
class CLabel;
|
2012-05-28 22:29:32 +03:00
|
|
|
struct BattleResult;
|
2011-12-22 16:05:19 +03:00
|
|
|
class CStack;
|
2012-08-28 19:28:21 +03:00
|
|
|
class CAnimImage;
|
2013-06-23 14:25:48 +03:00
|
|
|
class CPlayerInterface;
|
2011-12-22 16:05:19 +03:00
|
|
|
|
|
|
|
/// Class which shows the console at the bottom of the battle screen and manages the text of the console
|
|
|
|
class CBattleConsole : public CIntObject
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::vector< std::string > texts; //a place where texts are stored
|
|
|
|
int lastShown; //last shown line of text
|
|
|
|
public:
|
|
|
|
std::string alterTxt; //if it's not empty, this text is displayed
|
|
|
|
std::string ingcAlter; //alternative text set by in-game console - very important!
|
|
|
|
int whoSetAlter; //who set alter text; 0 - battle interface or none, 1 - button
|
2012-09-27 20:16:41 +03:00
|
|
|
CBattleConsole();
|
2015-10-12 15:47:10 +02:00
|
|
|
void showAll(SDL_Surface * to = 0) override;
|
2011-12-22 16:05:19 +03:00
|
|
|
bool addText(const std::string &text); //adds text at the last position; returns false if failed (e.g. text longer than 70 characters)
|
2012-02-20 11:19:03 +03:00
|
|
|
void alterText(const std::string &text); //place string at alterTxt
|
2011-12-22 16:05:19 +03:00
|
|
|
void eraseText(ui32 pos); //erases added text at position pos
|
|
|
|
void changeTextAt(const std::string &text, ui32 pos); //if we have more than pos texts, pos-th is changed to given one
|
|
|
|
void scrollUp(ui32 by = 1); //scrolls console up by 'by' positions
|
|
|
|
void scrollDown(ui32 by = 1); //scrolls console up by 'by' positions
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Hero battle animation
|
|
|
|
class CBattleHero : public CIntObject
|
|
|
|
{
|
2012-08-29 17:55:31 +03:00
|
|
|
void switchToNextPhase();
|
2011-12-22 16:05:19 +03:00
|
|
|
public:
|
|
|
|
bool flip; //false if it's attacking hero, true otherwise
|
|
|
|
CDefHandler *dh, *flag; //animation and flag
|
|
|
|
const CGHeroInstance * myHero; //this animation's hero instance
|
|
|
|
const CBattleInterface * myOwner; //battle interface to which this animation is assigned
|
|
|
|
int phase; //stage of animation
|
|
|
|
int nextPhase; //stage of animation to be set after current phase is fully displayed
|
2012-08-29 17:55:31 +03:00
|
|
|
int currentFrame, firstFrame, lastFrame; //frame of animation
|
|
|
|
ui8 flagAnim, animCount; //for flag animation
|
2015-10-12 15:47:10 +02:00
|
|
|
void show(SDL_Surface * to) override; //prints next frame of animation to to
|
2011-12-22 16:05:19 +03:00
|
|
|
void setPhase(int newPhase); //sets phase of hero animation
|
2016-09-27 14:13:20 +02:00
|
|
|
void hover(bool on) override;
|
2015-10-12 15:47:10 +02:00
|
|
|
void clickLeft(tribool down, bool previousState) override; //call-in
|
2016-09-27 14:13:20 +02:00
|
|
|
void clickRight(tribool down, bool previousState) override; //call-in
|
2013-03-03 20:06:03 +03:00
|
|
|
CBattleHero(const std::string &defName, bool filpG, PlayerColor player, const CGHeroInstance *hero, const CBattleInterface *owner); //c-tor
|
2011-12-22 16:05:19 +03:00
|
|
|
~CBattleHero(); //d-tor
|
|
|
|
};
|
|
|
|
|
2016-09-27 14:13:20 +02:00
|
|
|
class CHeroInfoWindow : public CWindowObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CHeroInfoWindow(const InfoAboutHero &hero, Point *position);
|
|
|
|
};
|
|
|
|
|
2011-12-22 16:05:19 +03:00
|
|
|
/// Class which manages the battle options window
|
|
|
|
class CBattleOptionsWindow : public CIntObject
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
CPicture * background;
|
2014-08-03 14:16:19 +03:00
|
|
|
CButton * setToDefault, * exit;
|
|
|
|
CToggleButton * viewGrid, * movementShadow, * mouseShadow;
|
|
|
|
CToggleGroup * animSpeeds;
|
2011-12-22 16:05:19 +03:00
|
|
|
|
|
|
|
std::vector<CLabel*> labels;
|
|
|
|
public:
|
|
|
|
CBattleOptionsWindow(const SDL_Rect &position, CBattleInterface *owner); //c-tor
|
|
|
|
|
|
|
|
void bDefaultf(); //default button callback
|
|
|
|
void bExitf(); //exit button callback
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Class which is responsible for showing the battle result window
|
|
|
|
class CBattleResultWindow : public CIntObject
|
|
|
|
{
|
|
|
|
private:
|
2014-08-03 14:16:19 +03:00
|
|
|
CButton *exit;
|
2013-06-23 14:25:48 +03:00
|
|
|
CPlayerInterface &owner;
|
2011-12-22 16:05:19 +03:00
|
|
|
public:
|
2013-06-23 14:25:48 +03:00
|
|
|
CBattleResultWindow(const BattleResult & br, const SDL_Rect & pos, CPlayerInterface &_owner); //c-tor
|
2011-12-22 16:05:19 +03:00
|
|
|
~CBattleResultWindow(); //d-tor
|
|
|
|
|
|
|
|
void bExitf(); //exit button callback
|
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
void activate() override;
|
|
|
|
void show(SDL_Surface * to = 0) override;
|
2011-12-22 16:05:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Class which stands for a single hex field on a battlefield
|
|
|
|
class CClickableHex : public CIntObject
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
bool setAlterText; //if true, this hex has set alternative text in console and will clean it
|
|
|
|
public:
|
|
|
|
ui32 myNumber; //number of hex in commonly used format
|
|
|
|
bool accessible; //if true, this hex is accessible for units
|
|
|
|
//CStack * ourStack;
|
|
|
|
bool hovered, strictHovered; //for determining if hex is hovered by mouse (this is different problem than hex's graphic hovering)
|
|
|
|
CBattleInterface * myInterface; //interface that owns me
|
2013-07-07 22:44:08 +03:00
|
|
|
static Point getXYUnitAnim(BattleHex hexNum, const CStack * creature, CBattleInterface * cbi); //returns (x, y) of left top corner of animation
|
2011-12-22 16:05:19 +03:00
|
|
|
|
|
|
|
//for user interactions
|
2015-10-12 15:47:10 +02:00
|
|
|
void hover (bool on) override;
|
|
|
|
void mouseMoved (const SDL_MouseMotionEvent &sEvent) override;
|
|
|
|
void clickLeft(tribool down, bool previousState) override;
|
|
|
|
void clickRight(tribool down, bool previousState) override;
|
2011-12-22 16:05:19 +03:00
|
|
|
CClickableHex();
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Shows the stack queue
|
|
|
|
class CStackQueue : public CIntObject
|
|
|
|
{
|
|
|
|
class StackBox : public CIntObject
|
|
|
|
{
|
|
|
|
public:
|
2012-08-28 19:28:21 +03:00
|
|
|
CPicture * bg;
|
|
|
|
CAnimImage * icon;
|
|
|
|
const CStack *stack;
|
|
|
|
bool small;
|
2011-12-22 16:05:19 +03:00
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
void showAll(SDL_Surface * to) override;
|
2011-12-22 16:05:19 +03:00
|
|
|
void setStack(const CStack *nStack);
|
2012-08-28 19:28:21 +03:00
|
|
|
StackBox(bool small);
|
2011-12-22 16:05:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
static const int QUEUE_SIZE = 10;
|
|
|
|
const bool embedded;
|
|
|
|
std::vector<const CStack *> stacksSorted;
|
|
|
|
std::vector<StackBox *> stackBoxes;
|
|
|
|
|
2012-08-28 19:28:21 +03:00
|
|
|
SDL_Surface * bg;
|
|
|
|
|
2011-12-22 16:05:19 +03:00
|
|
|
CBattleInterface * owner;
|
|
|
|
|
|
|
|
CStackQueue(bool Embedded, CBattleInterface * _owner);
|
|
|
|
~CStackQueue();
|
|
|
|
void update();
|
2015-10-12 15:47:10 +02:00
|
|
|
void showAll(SDL_Surface *to) override;
|
2012-08-28 19:28:21 +03:00
|
|
|
void blitBg(SDL_Surface * to);
|
2014-08-03 14:16:19 +03:00
|
|
|
};
|