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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
/*
* 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
*
*/
#pragma once
#include "CWindowObject.h"
#include "../gui/TextAlignment.h"
#include "../../lib/FunctionList.h"
VCMI_LIB_NAMESPACE_BEGIN
class CGObjectInstance;
class CGTownInstance;
class CGHeroInstance;
class CGGarrison;
class CGCreature;
class CGTeleport;
class CGKeys;
class CGObelisk;
VCMI_LIB_NAMESPACE_END
class CComponent;
class CComponentBox;
class CSelectableComponent;
class CTextBox;
class CButton;
class CFilledTexture;
class FilledTexturePlayerColored;
class TransparentFilledRectangle;
class CMinimapInstance;
class CLabel;
/// text + comp. + ok button
class CInfoWindow : public WindowBase
{
public:
using TButtonsInfo = std::vector<std::pair<AnimationPath, CFunctionList<void()>>>;
using TCompsInfo = std::vector<std::shared_ptr<CComponent>>;
QueryID ID; //for identification
std::shared_ptr<CFilledTexture> backgroundTexture;
std::shared_ptr<CTextBox> text;
std::shared_ptr<CComponentBox> components;
std::vector<std::shared_ptr<CButton>> buttons;
void close() override;
void showAll(Canvas & to) override;
void sliderMoved(int to);
CInfoWindow(const std::string & Text, PlayerColor player, const TCompsInfo & comps = TCompsInfo(), const TButtonsInfo & Buttons = TButtonsInfo());
CInfoWindow();
~CInfoWindow();
//use only before the game starts! (showYesNoDialog in LOCPLINT must be used then)
static void showInfoDialog(const std::string & text, const TCompsInfo & components, PlayerColor player = PlayerColor(1));
static void showYesNoDialog(const std::string & text, const TCompsInfo & components, const CFunctionList<void()> & onYes, const CFunctionList<void()> & onNo, PlayerColor player = PlayerColor(1));
static std::shared_ptr<CInfoWindow> create(const std::string & text, PlayerColor playerID = PlayerColor(1), const TCompsInfo & components = TCompsInfo());
/// create text from title and description: {title}\n\n description
static std::string genText(const std::string & title, const std::string & description);
};
/// popup displayed on R-click
class CRClickPopup : public WindowBase
{
public:
bool isPopupWindow() const override;
static std::shared_ptr<WindowBase> createCustomInfoWindow(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, const std::shared_ptr<CComponent> & component);
static void createAndPush(const CGObjectInstance * obj, const Point & p, ETextAlignment alignment = ETextAlignment::BOTTOMRIGHT);
};
/// popup displayed on R-click
class CRClickPopupInt : public CRClickPopup
{
std::shared_ptr<CIntObject> inner;
Point dragDistance;
public:
CRClickPopupInt(const std::shared_ptr<CIntObject> & our);
~CRClickPopupInt();
void mouseDraggedPopup(const Point & cursorPosition, const Point & lastUpdateDistance) override;
};
/// adventure map popup
class AdventureMapPopup : public CWindowObject
{
Point dragDistance;
public:
template<typename... Args>
AdventureMapPopup(Args&&... args);
void mouseDraggedPopup(const Point & cursorPosition, const Point & lastUpdateDistance) override;
};
/// popup on adventure map for town\hero and other objects with customized popup content
class CInfoBoxPopup : public AdventureMapPopup
{
std::shared_ptr<CIntObject> tooltip;
public:
CInfoBoxPopup(Point position, const CGTownInstance * town);
CInfoBoxPopup(Point position, const CGHeroInstance * hero);
CInfoBoxPopup(Point position, const CGGarrison * garr);
CInfoBoxPopup(Point position, const CGCreature * creature);
};
/// component selection window
class CSelWindow : public CInfoWindow
{
public:
void madeChoice(); //looks for selected component and calls callback
void madeChoiceAndClose();
CSelWindow(const std::string & text, PlayerColor player, int charperline, const std::vector<std::shared_ptr<CSelectableComponent>> & comps, const std::vector<std::pair<AnimationPath,CFunctionList<void()> > > &Buttons, QueryID askID);
};
class MinimapWithIcons : public CIntObject
{
std::shared_ptr<TransparentFilledRectangle> backgroundSurface;
std::shared_ptr<TransparentFilledRectangle> backgroundUnderground;
std::shared_ptr<CMinimapInstance> surface;
std::shared_ptr<CMinimapInstance> undergroud;
std::vector<std::shared_ptr<CPicture>> iconsOverlay;
public:
MinimapWithIcons(const Point & position);
void addIcon(const int3 & coordinates, const ImagePath & image);
};
class TeleporterPopup : public AdventureMapPopup
{
std::shared_ptr<FilledTexturePlayerColored> filledBackground;
std::shared_ptr<MinimapWithIcons> minimap;
std::shared_ptr<CLabel> labelTitle;
public:
TeleporterPopup(const Point & position, const CGTeleport * teleporter);
};
class KeymasterPopup : public AdventureMapPopup
{
std::shared_ptr<FilledTexturePlayerColored> filledBackground;
std::shared_ptr<MinimapWithIcons> minimap;
std::shared_ptr<CLabel> labelTitle;
std::shared_ptr<CLabel> labelDescription;
public:
KeymasterPopup(const Point & position, const CGKeys * keymasterOrGuard);
};
class ObeliskPopup : public AdventureMapPopup
{
std::shared_ptr<FilledTexturePlayerColored> filledBackground;
std::shared_ptr<MinimapWithIcons> minimap;
std::shared_ptr<CLabel> labelTitle;
std::shared_ptr<CLabel> labelDescription;
public:
ObeliskPopup(const Point & position, const CGObelisk * obelisk);
};
|