show map popup for searched objects

This commit is contained in:
Laserlicht
2026-01-02 23:14:03 +01:00
parent 7672bea319
commit cfe99b4bed
4 changed files with 51 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

+18 -1
View File
@@ -25,6 +25,7 @@
#include "../windows/CSpellWindow.h"
#include "../windows/CMarketWindow.h"
#include "../windows/GUIClasses.h"
#include "../windows/InfoWindows.h"
#include "../windows/settings/SettingsMainWindow.h"
#include "AdventureMapInterface.h"
#include "AdventureOptions.h"
@@ -537,11 +538,27 @@ void AdventureMapShortcuts::search(bool next)
owner.centerOnObject(objInst);
searchLast = objInst->getObjectName();
};
auto openObjMap = [this, textCountList](int index)
{
auto selObj = textCountList[index].first;
// filter for matching objects
std::vector<const CGObjectInstance *> selVisitableObjInstances;
for(auto & obj : GAME->interface()->cb->getAllVisitableObjs())
if(selObj.first == GAME->interface()->cb->getObjInstance(obj->id)->getObjectName())
selVisitableObjInstances.push_back(obj);
ENGINE->windows().createAndPushWindow<SearchPopup>(selVisitableObjInstances);
};
if(next)
selectObjOnMap(lastSel);
else
ENGINE->windows().createAndPushWindow<CObjectListWindow>(texts, nullptr, LIBRARY->generaltexth->translate("vcmi.adventureMap.search.hover"), LIBRARY->generaltexth->translate("vcmi.adventureMap.search.help"), [selectObjOnMap](int index){ selectObjOnMap(index); }, lastSel, std::vector<std::shared_ptr<IImage>>(), true);
{
auto window = std::make_shared<CObjectListWindow>(texts, nullptr, LIBRARY->generaltexth->translate("vcmi.adventureMap.search.hover"), LIBRARY->generaltexth->translate("vcmi.adventureMap.search.help"), [selectObjOnMap](int index){ selectObjOnMap(index); }, lastSel, std::vector<std::shared_ptr<IImage>>(), true);
window->onPopup = [openObjMap](int index){ openObjMap(index); };
ENGINE->windows().pushWindow(window);
}
}
void AdventureMapShortcuts::nextObject()
+23
View File
@@ -522,6 +522,29 @@ ObeliskPopup::ObeliskPopup(const Point & position, const CGObelisk * obelisk)
fitToScreen(10);
}
SearchPopup::SearchPopup(std::vector<const CGObjectInstance *> objs)
: AdventureMapPopup(BORDERED | RCLICK_POPUP)
{
OBJECT_CONSTRUCTION;
pos.w = 322;
pos.h = 220;
if(!objs.size())
return;
auto name = GAME->interface()->cb->getObjInstance(objs.at(0)->id)->getObjectName();
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, name);
minimap = std::make_shared<MinimapWithIcons>(Point(0,20));
for (const auto obj : objs)
minimap->addIcon(obj->visitablePos(), ImagePath::builtin("minimapIcons/generic"));
center();
fitToScreen(10);
}
std::shared_ptr<WindowBase>
CRClickPopup::createCustomInfoWindow(Point position, const CGObjectInstance * specific) //specific=0 => draws info about selected town/hero
{
+10
View File
@@ -172,3 +172,13 @@ class ObeliskPopup : public AdventureMapPopup
public:
ObeliskPopup(const Point & position, const CGObelisk * obelisk);
};
class SearchPopup : public AdventureMapPopup
{
std::shared_ptr<FilledTexturePlayerColored> filledBackground;
std::shared_ptr<MinimapWithIcons> minimap;
std::shared_ptr<CLabel> labelTitle;
public:
SearchPopup(std::vector<const CGObjectInstance *> objs);
};