Merge pull request #5212 from IvanSavenko/keymaster_popup
Added popup for keymasters/border guards similar to teleporters
BIN
Mods/vcmi/Content/Sprites/minimapIcons/bordergate.png
Normal file
After ![]() (image error) Size: 147 B |
BIN
Mods/vcmi/Content/Sprites/minimapIcons/borderguard.png
Normal file
After ![]() (image error) Size: 141 B |
BIN
Mods/vcmi/Content/Sprites/minimapIcons/keymaster.png
Normal file
After ![]() (image error) Size: 252 B |
BIN
Mods/vcmi/Content/Sprites/minimapIcons/obelisk.png
Normal file
After ![]() (image error) Size: 119 B |
BIN
Mods/vcmi/Content/Sprites/minimapIcons/obeliskVisited.png
Normal file
After ![]() (image error) Size: 119 B |
Before ![]() (image error) Size: 138 B After ![]() (image error) Size: 138 B ![]() ![]() |
Before ![]() (image error) Size: 137 B After ![]() (image error) Size: 137 B ![]() ![]() |
Before ![]() (image error) Size: 139 B After ![]() (image error) Size: 139 B ![]() ![]() |
BIN
Mods/vcmi/Content/Sprites2x/minimapIcons/bordergate.png
Normal file
After ![]() (image error) Size: 206 B |
BIN
Mods/vcmi/Content/Sprites2x/minimapIcons/borderguard.png
Normal file
After ![]() (image error) Size: 208 B |
BIN
Mods/vcmi/Content/Sprites2x/minimapIcons/keymaster.png
Normal file
After ![]() (image error) Size: 391 B |
BIN
Mods/vcmi/Content/Sprites2x/minimapIcons/obelisk.png
Normal file
After ![]() (image error) Size: 154 B |
BIN
Mods/vcmi/Content/Sprites2x/minimapIcons/obeliskVisited.png
Normal file
After ![]() (image error) Size: 150 B |
Before ![]() (image error) Size: 182 B After ![]() (image error) Size: 182 B ![]() ![]() |
Before ![]() (image error) Size: 210 B After ![]() (image error) Size: 210 B ![]() ![]() |
0
Mods/vcmi/Content/Sprites2x/portalExit.png → Mods/vcmi/Content/Sprites2x/minimapIcons/portalExit.png
Before ![]() (image error) Size: 198 B After ![]() (image error) Size: 198 B ![]() ![]() |
@ -31,12 +31,13 @@
|
||||
#include "../../CCallback.h"
|
||||
|
||||
#include "../../lib/CConfigHandler.h"
|
||||
#include "../ConditionalWait.h"
|
||||
#include "../../lib/gameState/InfoAboutArmy.h"
|
||||
#include "../../lib/mapObjects/CGCreature.h"
|
||||
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||
#include "../../lib/mapObjects/CGTownInstance.h"
|
||||
#include "../../lib/mapObjects/CQuest.h"
|
||||
#include "../../lib/mapObjects/MiscObjects.h"
|
||||
#include "../ConditionalWait.h"
|
||||
|
||||
CSelWindow::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)
|
||||
{
|
||||
@ -333,12 +334,10 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGCreature * creature)
|
||||
fitToScreen(10);
|
||||
}
|
||||
|
||||
TeleporterPopup::TeleporterPopup(const Point & position, const CGTeleport * teleporter)
|
||||
: CWindowObject(BORDERED | RCLICK_POPUP)
|
||||
MinimapWithIcons::MinimapWithIcons(const Point & position)
|
||||
{
|
||||
OBJECT_CONSTRUCTION;
|
||||
pos.w = 322;
|
||||
pos.h = 200;
|
||||
pos += position;
|
||||
|
||||
Rect areaSurface(11, 41, 144, 144);
|
||||
Rect areaUnderground(167, 41, 144, 144);
|
||||
@ -346,16 +345,14 @@ TeleporterPopup::TeleporterPopup(const Point & position, const CGTeleport * tele
|
||||
Rect borderSurface(10, 40, 147, 147);
|
||||
Rect borderUnderground(166, 40, 147, 147);
|
||||
|
||||
bool singleLevelMap = LOCPLINT->cb->getMapSize().y == 0;
|
||||
bool singleLevelMap = LOCPLINT->cb->getMapSize().z == 1;
|
||||
|
||||
if (singleLevelMap)
|
||||
{
|
||||
areaSurface.x += 144;
|
||||
borderSurface.x += 144;
|
||||
areaSurface.x += 78;
|
||||
borderSurface.x += 78;
|
||||
}
|
||||
|
||||
filledBackground = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
|
||||
|
||||
backgroundSurface = std::make_shared<TransparentFilledRectangle>(borderSurface, Colors::TRANSPARENCY, Colors::YELLOW);
|
||||
surface = std::make_shared<CMinimapInstance>(areaSurface.topLeft(), areaSurface.dimensions(), 0);
|
||||
|
||||
@ -364,8 +361,43 @@ TeleporterPopup::TeleporterPopup(const Point & position, const CGTeleport * tele
|
||||
backgroundUnderground = std::make_shared<TransparentFilledRectangle>(borderUnderground, Colors::TRANSPARENCY, Colors::YELLOW);
|
||||
undergroud = std::make_shared<CMinimapInstance>(areaUnderground.topLeft(), areaUnderground.dimensions(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
void MinimapWithIcons::addIcon(const int3 & coordinates, const ImagePath & image )
|
||||
{
|
||||
OBJECT_CONSTRUCTION;
|
||||
|
||||
Rect areaSurface(11, 41, 144, 144);
|
||||
Rect areaUnderground(167, 41, 144, 144);
|
||||
bool singleLevelMap = LOCPLINT->cb->getMapSize().z == 1;
|
||||
if (singleLevelMap)
|
||||
areaSurface.x += 78;
|
||||
|
||||
int positionX = 144 * coordinates.x / LOCPLINT->cb->getMapSize().x;
|
||||
int positionY = 144 * coordinates.y / LOCPLINT->cb->getMapSize().y;
|
||||
|
||||
Point iconPosition(positionX, positionY);
|
||||
|
||||
iconPosition -= Point(8,8); // compensate for 16x16 icon half-size
|
||||
|
||||
if (coordinates.z == 0)
|
||||
iconPosition += areaSurface.topLeft();
|
||||
else
|
||||
iconPosition += areaUnderground.topLeft();
|
||||
|
||||
iconsOverlay.push_back(std::make_shared<CPicture>(image, iconPosition));
|
||||
}
|
||||
|
||||
TeleporterPopup::TeleporterPopup(const Point & position, const CGTeleport * teleporter)
|
||||
: CWindowObject(BORDERED | RCLICK_POPUP)
|
||||
{
|
||||
OBJECT_CONSTRUCTION;
|
||||
pos.w = 322;
|
||||
pos.h = 200;
|
||||
|
||||
filledBackground = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
|
||||
labelTitle = std::make_shared<CLabel>(pos.w / 2, 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, teleporter->getPopupText(LOCPLINT->playerID));
|
||||
minimap = std::make_shared<MinimapWithIcons>(Point(0,0));
|
||||
|
||||
const auto & entrances = teleporter->getAllEntrances();
|
||||
const auto & exits = teleporter->getAllExits();
|
||||
@ -382,31 +414,87 @@ TeleporterPopup::TeleporterPopup(const Point & position, const CGTeleport * tele
|
||||
continue;
|
||||
|
||||
int3 position = exitObject->visitablePos();
|
||||
|
||||
int positionX = 144 * position.x / LOCPLINT->cb->getMapSize().x;
|
||||
int positionY = 144 * position.y / LOCPLINT->cb->getMapSize().y;
|
||||
|
||||
Point iconPosition(positionX, positionY);
|
||||
|
||||
iconPosition -= Point(8,8); // compensate for 16x16 icon half-size
|
||||
|
||||
if (position.z == 0)
|
||||
iconPosition += areaSurface.topLeft();
|
||||
else
|
||||
iconPosition += areaUnderground.topLeft();
|
||||
|
||||
ImagePath image;
|
||||
|
||||
if (!vstd::contains(entrances, exit))
|
||||
image = ImagePath::builtin("portalExit");
|
||||
image = ImagePath::builtin("minimapIcons/portalExit");
|
||||
else if (!vstd::contains(exits, exit))
|
||||
image = ImagePath::builtin("portalEntrance");
|
||||
image = ImagePath::builtin("minimapIcons/portalEntrance");
|
||||
else
|
||||
image = ImagePath::builtin("portalBidirectional");
|
||||
image = ImagePath::builtin("minimapIcons/portalBidirectional");
|
||||
|
||||
iconsOverlay.push_back(std::make_shared<CPicture>(image, iconPosition));
|
||||
minimap->addIcon(position, image);
|
||||
}
|
||||
center(position);
|
||||
fitToScreen(10);
|
||||
}
|
||||
|
||||
KeymasterPopup::KeymasterPopup(const Point & position, const CGKeys * keymasterOrGuard)
|
||||
: CWindowObject(BORDERED | RCLICK_POPUP)
|
||||
{
|
||||
OBJECT_CONSTRUCTION;
|
||||
pos.w = 322;
|
||||
pos.h = 220;
|
||||
|
||||
filledBackground = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
|
||||
labelTitle = std::make_shared<CLabel>(pos.w / 2, 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, keymasterOrGuard->getObjectName());
|
||||
labelDescription = std::make_shared<CLabel>(pos.w / 2, 40, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, keymasterOrGuard->getObjectDescription(LOCPLINT->playerID));
|
||||
minimap = std::make_shared<MinimapWithIcons>(Point(0,20));
|
||||
|
||||
const auto allObjects = LOCPLINT->cb->getAllVisitableObjs();
|
||||
|
||||
for (const auto mapObject : allObjects)
|
||||
{
|
||||
if (!mapObject)
|
||||
continue;
|
||||
|
||||
switch (mapObject->ID)
|
||||
{
|
||||
case Obj::KEYMASTER:
|
||||
if (mapObject->subID == keymasterOrGuard->subID)
|
||||
minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/keymaster"));
|
||||
break;
|
||||
case Obj::BORDERGUARD:
|
||||
if (mapObject->subID == keymasterOrGuard->subID)
|
||||
minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/borderguard"));
|
||||
break;
|
||||
case Obj::BORDER_GATE:
|
||||
if (mapObject->subID == keymasterOrGuard->subID)
|
||||
minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/bordergate"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
center(position);
|
||||
fitToScreen(10);
|
||||
}
|
||||
|
||||
ObeliskPopup::ObeliskPopup(const Point & position, const CGObelisk * obelisk)
|
||||
: CWindowObject(BORDERED | RCLICK_POPUP)
|
||||
{
|
||||
OBJECT_CONSTRUCTION;
|
||||
pos.w = 322;
|
||||
pos.h = 220;
|
||||
|
||||
filledBackground = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
|
||||
labelTitle = std::make_shared<CLabel>(pos.w / 2, 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, obelisk->getObjectName());
|
||||
labelDescription = std::make_shared<CLabel>(pos.w / 2, 40, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, obelisk->getObjectDescription(LOCPLINT->playerID));
|
||||
minimap = std::make_shared<MinimapWithIcons>(Point(0,20));
|
||||
|
||||
const auto allObjects = LOCPLINT->cb->getAllVisitableObjs();
|
||||
|
||||
for (const auto mapObject : allObjects)
|
||||
{
|
||||
if (!mapObject)
|
||||
continue;
|
||||
|
||||
if (mapObject->ID != Obj::OBELISK)
|
||||
continue;
|
||||
|
||||
if (mapObject->wasVisited(LOCPLINT->playerID))
|
||||
minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/obeliskVisited"));
|
||||
else
|
||||
minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/obelisk"));
|
||||
}
|
||||
center(position);
|
||||
fitToScreen(10);
|
||||
}
|
||||
@ -440,6 +528,12 @@ CRClickPopup::createCustomInfoWindow(Point position, const CGObjectInstance * sp
|
||||
case Obj::SUBTERRANEAN_GATE:
|
||||
case Obj::WHIRLPOOL:
|
||||
return std::make_shared<TeleporterPopup>(position, dynamic_cast<const CGTeleport *>(specific));
|
||||
case Obj::KEYMASTER:
|
||||
case Obj::BORDERGUARD:
|
||||
case Obj::BORDER_GATE:
|
||||
return std::make_shared<KeymasterPopup>(position, dynamic_cast<const CGKeys *>(specific));
|
||||
case Obj::OBELISK:
|
||||
return std::make_shared<ObeliskPopup>(position, dynamic_cast<const CGObelisk *>(specific));
|
||||
default:
|
||||
return std::shared_ptr<WindowBase>();
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ class CGHeroInstance;
|
||||
class CGGarrison;
|
||||
class CGCreature;
|
||||
class CGTeleport;
|
||||
class CGKeys;
|
||||
class CGObelisk;
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
@ -116,20 +118,50 @@ public:
|
||||
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 TeleporterPopup : public CWindowObject
|
||||
class MinimapWithIcons : public CIntObject
|
||||
{
|
||||
std::shared_ptr<FilledTexturePlayerColored> filledBackground;
|
||||
|
||||
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 CWindowObject
|
||||
{
|
||||
std::shared_ptr<FilledTexturePlayerColored> filledBackground;
|
||||
std::shared_ptr<MinimapWithIcons> minimap;
|
||||
std::shared_ptr<CLabel> labelTitle;
|
||||
|
||||
std::vector<std::shared_ptr<CPicture>> iconsOverlay;
|
||||
public:
|
||||
TeleporterPopup(const Point & position, const CGTeleport * teleporter);
|
||||
};
|
||||
|
||||
class KeymasterPopup : public CWindowObject
|
||||
{
|
||||
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 CWindowObject
|
||||
{
|
||||
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);
|
||||
};
|
||||
|
@ -803,6 +803,11 @@ std::string CGKeys::getObjectName() const
|
||||
return VLC->generaltexth->tentColors[subID.getNum()] + " " + CGObjectInstance::getObjectName();
|
||||
}
|
||||
|
||||
std::string CGKeys::getObjectDescription(PlayerColor player) const
|
||||
{
|
||||
return visitedTxt(wasMyColorVisited(player));
|
||||
}
|
||||
|
||||
bool CGKeymasterTent::wasVisited (PlayerColor player) const
|
||||
{
|
||||
return wasMyColorVisited (player);
|
||||
|
@ -199,7 +199,8 @@ public:
|
||||
|
||||
bool wasMyColorVisited(const PlayerColor & player) const;
|
||||
|
||||
std::string getObjectName() const override; //depending on color
|
||||
std::string getObjectName() const override;
|
||||
std::string getObjectDescription(PlayerColor player) const;
|
||||
std::string getHoverText(PlayerColor player) const override;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h)
|
||||
|
@ -1289,6 +1289,11 @@ std::string CGObelisk::getHoverText(PlayerColor player) const
|
||||
return getObjectName() + " " + visitedTxt(wasVisited(player));
|
||||
}
|
||||
|
||||
std::string CGObelisk::getObjectDescription(PlayerColor player) const
|
||||
{
|
||||
return visitedTxt(wasVisited(player));
|
||||
}
|
||||
|
||||
void CGObelisk::setPropertyDer(ObjProperty what, ObjPropertyID identifier)
|
||||
{
|
||||
switch(what)
|
||||
|
@ -406,6 +406,7 @@ public:
|
||||
void onHeroVisit(const CGHeroInstance * h) const override;
|
||||
void initObj(vstd::RNG & rand) override;
|
||||
std::string getHoverText(PlayerColor player) const override;
|
||||
std::string getObjectDescription(PlayerColor player) const;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h)
|
||||
{
|
||||
|