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 Width: | Height: | Size: 147 B |
BIN
Mods/vcmi/Content/Sprites/minimapIcons/borderguard.png
Normal file
After Width: | Height: | Size: 141 B |
BIN
Mods/vcmi/Content/Sprites/minimapIcons/keymaster.png
Normal file
After Width: | Height: | Size: 252 B |
BIN
Mods/vcmi/Content/Sprites/minimapIcons/obelisk.png
Normal file
After Width: | Height: | Size: 119 B |
BIN
Mods/vcmi/Content/Sprites/minimapIcons/obeliskVisited.png
Normal file
After Width: | Height: | Size: 119 B |
Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 138 B |
Before Width: | Height: | Size: 137 B After Width: | Height: | Size: 137 B |
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 139 B |
BIN
Mods/vcmi/Content/Sprites2x/minimapIcons/bordergate.png
Normal file
After Width: | Height: | Size: 206 B |
BIN
Mods/vcmi/Content/Sprites2x/minimapIcons/borderguard.png
Normal file
After Width: | Height: | Size: 208 B |
BIN
Mods/vcmi/Content/Sprites2x/minimapIcons/keymaster.png
Normal file
After Width: | Height: | Size: 391 B |
BIN
Mods/vcmi/Content/Sprites2x/minimapIcons/obelisk.png
Normal file
After Width: | Height: | Size: 154 B |
BIN
Mods/vcmi/Content/Sprites2x/minimapIcons/obeliskVisited.png
Normal file
After Width: | Height: | Size: 150 B |
Before Width: | Height: | Size: 182 B After Width: | Height: | Size: 182 B |
Before Width: | Height: | Size: 210 B After Width: | Height: | Size: 210 B |
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 198 B |
@ -31,12 +31,13 @@
|
|||||||
#include "../../CCallback.h"
|
#include "../../CCallback.h"
|
||||||
|
|
||||||
#include "../../lib/CConfigHandler.h"
|
#include "../../lib/CConfigHandler.h"
|
||||||
#include "../ConditionalWait.h"
|
|
||||||
#include "../../lib/gameState/InfoAboutArmy.h"
|
#include "../../lib/gameState/InfoAboutArmy.h"
|
||||||
#include "../../lib/mapObjects/CGCreature.h"
|
#include "../../lib/mapObjects/CGCreature.h"
|
||||||
#include "../../lib/mapObjects/CGHeroInstance.h"
|
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||||
#include "../../lib/mapObjects/CGTownInstance.h"
|
#include "../../lib/mapObjects/CGTownInstance.h"
|
||||||
|
#include "../../lib/mapObjects/CQuest.h"
|
||||||
#include "../../lib/mapObjects/MiscObjects.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)
|
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);
|
fitToScreen(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
TeleporterPopup::TeleporterPopup(const Point & position, const CGTeleport * teleporter)
|
MinimapWithIcons::MinimapWithIcons(const Point & position)
|
||||||
: CWindowObject(BORDERED | RCLICK_POPUP)
|
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION;
|
OBJECT_CONSTRUCTION;
|
||||||
pos.w = 322;
|
pos += position;
|
||||||
pos.h = 200;
|
|
||||||
|
|
||||||
Rect areaSurface(11, 41, 144, 144);
|
Rect areaSurface(11, 41, 144, 144);
|
||||||
Rect areaUnderground(167, 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 borderSurface(10, 40, 147, 147);
|
||||||
Rect borderUnderground(166, 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)
|
if (singleLevelMap)
|
||||||
{
|
{
|
||||||
areaSurface.x += 144;
|
areaSurface.x += 78;
|
||||||
borderSurface.x += 144;
|
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);
|
backgroundSurface = std::make_shared<TransparentFilledRectangle>(borderSurface, Colors::TRANSPARENCY, Colors::YELLOW);
|
||||||
surface = std::make_shared<CMinimapInstance>(areaSurface.topLeft(), areaSurface.dimensions(), 0);
|
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);
|
backgroundUnderground = std::make_shared<TransparentFilledRectangle>(borderUnderground, Colors::TRANSPARENCY, Colors::YELLOW);
|
||||||
undergroud = std::make_shared<CMinimapInstance>(areaUnderground.topLeft(), areaUnderground.dimensions(), 1);
|
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));
|
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 & entrances = teleporter->getAllEntrances();
|
||||||
const auto & exits = teleporter->getAllExits();
|
const auto & exits = teleporter->getAllExits();
|
||||||
@ -382,31 +414,87 @@ TeleporterPopup::TeleporterPopup(const Point & position, const CGTeleport * tele
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
int3 position = exitObject->visitablePos();
|
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;
|
ImagePath image;
|
||||||
|
|
||||||
if (!vstd::contains(entrances, exit))
|
if (!vstd::contains(entrances, exit))
|
||||||
image = ImagePath::builtin("portalExit");
|
image = ImagePath::builtin("minimapIcons/portalExit");
|
||||||
else if (!vstd::contains(exits, exit))
|
else if (!vstd::contains(exits, exit))
|
||||||
image = ImagePath::builtin("portalEntrance");
|
image = ImagePath::builtin("minimapIcons/portalEntrance");
|
||||||
else
|
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);
|
center(position);
|
||||||
fitToScreen(10);
|
fitToScreen(10);
|
||||||
}
|
}
|
||||||
@ -440,6 +528,12 @@ CRClickPopup::createCustomInfoWindow(Point position, const CGObjectInstance * sp
|
|||||||
case Obj::SUBTERRANEAN_GATE:
|
case Obj::SUBTERRANEAN_GATE:
|
||||||
case Obj::WHIRLPOOL:
|
case Obj::WHIRLPOOL:
|
||||||
return std::make_shared<TeleporterPopup>(position, dynamic_cast<const CGTeleport *>(specific));
|
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:
|
default:
|
||||||
return std::shared_ptr<WindowBase>();
|
return std::shared_ptr<WindowBase>();
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ class CGHeroInstance;
|
|||||||
class CGGarrison;
|
class CGGarrison;
|
||||||
class CGCreature;
|
class CGCreature;
|
||||||
class CGTeleport;
|
class CGTeleport;
|
||||||
|
class CGKeys;
|
||||||
|
class CGObelisk;
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_END
|
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);
|
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> backgroundSurface;
|
||||||
std::shared_ptr<TransparentFilledRectangle> backgroundUnderground;
|
std::shared_ptr<TransparentFilledRectangle> backgroundUnderground;
|
||||||
|
|
||||||
std::shared_ptr<CMinimapInstance> surface;
|
std::shared_ptr<CMinimapInstance> surface;
|
||||||
std::shared_ptr<CMinimapInstance> undergroud;
|
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::shared_ptr<CLabel> labelTitle;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<CPicture>> iconsOverlay;
|
|
||||||
public:
|
public:
|
||||||
TeleporterPopup(const Point & position, const CGTeleport * teleporter);
|
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();
|
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
|
bool CGKeymasterTent::wasVisited (PlayerColor player) const
|
||||||
{
|
{
|
||||||
return wasMyColorVisited (player);
|
return wasMyColorVisited (player);
|
||||||
|
@ -199,7 +199,8 @@ public:
|
|||||||
|
|
||||||
bool wasMyColorVisited(const PlayerColor & player) const;
|
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;
|
std::string getHoverText(PlayerColor player) const override;
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h)
|
template <typename Handler> void serialize(Handler &h)
|
||||||
|
@ -1289,6 +1289,11 @@ std::string CGObelisk::getHoverText(PlayerColor player) const
|
|||||||
return getObjectName() + " " + visitedTxt(wasVisited(player));
|
return getObjectName() + " " + visitedTxt(wasVisited(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CGObelisk::getObjectDescription(PlayerColor player) const
|
||||||
|
{
|
||||||
|
return visitedTxt(wasVisited(player));
|
||||||
|
}
|
||||||
|
|
||||||
void CGObelisk::setPropertyDer(ObjProperty what, ObjPropertyID identifier)
|
void CGObelisk::setPropertyDer(ObjProperty what, ObjPropertyID identifier)
|
||||||
{
|
{
|
||||||
switch(what)
|
switch(what)
|
||||||
|
@ -406,6 +406,7 @@ public:
|
|||||||
void onHeroVisit(const CGHeroInstance * h) const override;
|
void onHeroVisit(const CGHeroInstance * h) const override;
|
||||||
void initObj(vstd::RNG & rand) override;
|
void initObj(vstd::RNG & rand) override;
|
||||||
std::string getHoverText(PlayerColor player) const override;
|
std::string getHoverText(PlayerColor player) const override;
|
||||||
|
std::string getObjectDescription(PlayerColor player) const;
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h)
|
template <typename Handler> void serialize(Handler &h)
|
||||||
{
|
{
|
||||||
|