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
|
#pragma once
#include "CWindowObject.h"
//#include "../gui/SDL_Extensions.h"
#include "../../lib/FunctionList.h"
struct SDL_Surface;
struct Rect;
class CAnimImage;
class CLabel;
class CAnimation;
class CComponent;
class CSelectableComponent;
class CGGarrison;
class CTextBox;
class CButton;
class CSlider;
/*
* InfoWindows.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
*
*/
// Window GUI class
class CSimpleWindow : public CIntObject
{
public:
SDL_Surface * bitmap; //background
virtual void show(SDL_Surface * to) override;
CSimpleWindow():bitmap(nullptr){}; //c-tor
virtual ~CSimpleWindow(); //d-tor
};
/// text + comp. + ok button
class CInfoWindow : public CSimpleWindow
{ //window able to delete its components when closed
bool delComps; //whether comps will be deleted
public:
typedef std::vector<std::pair<std::string,CFunctionList<void()> > > TButtonsInfo;
typedef std::vector<CComponent*> TCompsInfo;
QueryID ID; //for identification
CTextBox *text;
std::vector<CButton *> buttons;
std::vector<CComponent*> components;
CSlider *slider;
void setDelComps(bool DelComps);
virtual void close();
void show(SDL_Surface * to) override;
void showAll(SDL_Surface * to) override;
void sliderMoved(int to);
CInfoWindow(std::string Text, PlayerColor player, const TCompsInfo &comps = TCompsInfo(), const TButtonsInfo &Buttons = TButtonsInfo(), bool delComps = true); //c-tor
CInfoWindow(); //c-tor
~CInfoWindow(); //d-tor
//use only before the game starts! (showYesNoDialog in LOCPLINT must be used then)
static void showInfoDialog( const std::string & text, const std::vector<CComponent*> *components, bool DelComps = true, PlayerColor player = PlayerColor(1));
static void showOkDialog(const std::string & text, const std::vector<CComponent*> *components, const std::function<void()> & onOk, bool delComps = true, PlayerColor player = PlayerColor(1));
static void showYesNoDialog( const std::string & text, const std::vector<CComponent*> *components, const CFunctionList<void( ) > &onYes, const CFunctionList<void()> &onNo, bool DelComps = true, PlayerColor player = PlayerColor(1));
static CInfoWindow *create(const std::string &text, PlayerColor playerID = PlayerColor(1), const std::vector<CComponent*> *components = nullptr, bool DelComps = false);
/// create text from title and description: {title}\n\n description
static std::string genText(std::string title, std::string description);
};
/// popup displayed on R-click
class CRClickPopup : public CIntObject
{
public:
virtual void close();
void clickRight(tribool down, bool previousState) override;
CRClickPopup();
virtual ~CRClickPopup(); //d-tor
static CIntObject* createInfoWin(Point position, const CGObjectInstance * specific);
static void createAndPush(const std::string &txt, const CInfoWindow::TCompsInfo &comps = CInfoWindow::TCompsInfo());
static void createAndPush(const std::string &txt, CComponent * component);
static void createAndPush(const CGObjectInstance *obj, const Point &p, EAlignment alignment = BOTTOMRIGHT);
};
/// popup displayed on R-click
class CRClickPopupInt : public CRClickPopup
{
public:
IShowActivatable *inner;
bool delInner;
void show(SDL_Surface * to) override;
void showAll(SDL_Surface * to) override;
CRClickPopupInt(IShowActivatable *our, bool deleteInt); //c-tor
virtual ~CRClickPopupInt(); //d-tor
};
class CInfoPopup : public CRClickPopup
{
public:
bool free; //TODO: comment me
SDL_Surface * bitmap; //popup background
void close() override;
void show(SDL_Surface * to) override;
CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false); //c-tor
CInfoPopup(SDL_Surface * Bitmap, const Point &p, EAlignment alignment, bool Free=false); //c-tor
CInfoPopup(SDL_Surface * Bitmap = nullptr, bool Free = false); //default c-tor
void init(int x, int y);
~CInfoPopup(); //d-tor
};
/// popup on adventure map for town\hero objects
class CInfoBoxPopup : public CWindowObject
{
Point toScreen(Point pos);
public:
CInfoBoxPopup(Point position, const CGTownInstance * town);
CInfoBoxPopup(Point position, const CGHeroInstance * hero);
CInfoBoxPopup(Point position, const CGGarrison * garr);
};
/// component selection window
class CSelWindow : public CInfoWindow
{ //warning - this window deletes its components by closing!
public:
void selectionChange(unsigned to);
void madeChoice(); //looks for selected component and calls callback
CSelWindow(const std::string& text, PlayerColor player, int charperline ,const std::vector<CSelectableComponent*> &comps, const std::vector<std::pair<std::string,CFunctionList<void()> > > &Buttons, QueryID askID); //c-tor
CSelWindow(){}; //c-tor
//notification - this class inherits important destructor from CInfoWindow
};
|