From cfe99b4bed8c8c0603d77203e3421209cea0118f Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Fri, 2 Jan 2026 23:14:03 +0100 Subject: [PATCH] show map popup for searched objects --- .../Content/Sprites/minimapIcons/generic.png | Bin 0 -> 174 bytes client/adventureMap/AdventureMapShortcuts.cpp | 19 ++++++++++++++- client/windows/InfoWindows.cpp | 23 ++++++++++++++++++ client/windows/InfoWindows.h | 10 ++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 Mods/vcmi/Content/Sprites/minimapIcons/generic.png diff --git a/Mods/vcmi/Content/Sprites/minimapIcons/generic.png b/Mods/vcmi/Content/Sprites/minimapIcons/generic.png new file mode 100644 index 0000000000000000000000000000000000000000..2534926fa81ca4ba4a593e125396a774ed416fea GIT binary patch literal 174 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt`1o-U3d z7QM*{5^o;Zi#%rO`C(GOC-C3_5Lkb)F<4iR`N6D2hUtnocn)0XIWJJc9AM&XYLFn< z{My-!VRo9EQ;|=^T`#5utHd`*HSu(Cy3A>tAk-_-_Q2bth2h{5n-2^O0X9Y)eOI4( Q0Ig&2boFyt=akR{0QzJ+bpQYW literal 0 HcmV?d00001 diff --git a/client/adventureMap/AdventureMapShortcuts.cpp b/client/adventureMap/AdventureMapShortcuts.cpp index 0ddf828f4..0af7ff6fb 100644 --- a/client/adventureMap/AdventureMapShortcuts.cpp +++ b/client/adventureMap/AdventureMapShortcuts.cpp @@ -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 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(selVisitableObjInstances); + }; if(next) selectObjOnMap(lastSel); else - ENGINE->windows().createAndPushWindow(texts, nullptr, LIBRARY->generaltexth->translate("vcmi.adventureMap.search.hover"), LIBRARY->generaltexth->translate("vcmi.adventureMap.search.help"), [selectObjOnMap](int index){ selectObjOnMap(index); }, lastSel, std::vector>(), true); + { + auto window = std::make_shared(texts, nullptr, LIBRARY->generaltexth->translate("vcmi.adventureMap.search.hover"), LIBRARY->generaltexth->translate("vcmi.adventureMap.search.help"), [selectObjOnMap](int index){ selectObjOnMap(index); }, lastSel, std::vector>(), true); + window->onPopup = [openObjMap](int index){ openObjMap(index); }; + ENGINE->windows().pushWindow(window); + } } void AdventureMapShortcuts::nextObject() diff --git a/client/windows/InfoWindows.cpp b/client/windows/InfoWindows.cpp index a12516900..7d47c3d60 100644 --- a/client/windows/InfoWindows.cpp +++ b/client/windows/InfoWindows.cpp @@ -522,6 +522,29 @@ ObeliskPopup::ObeliskPopup(const Point & position, const CGObelisk * obelisk) fitToScreen(10); } +SearchPopup::SearchPopup(std::vector 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(Rect(0, 0, pos.w, pos.h)); + labelTitle = std::make_shared(pos.w / 2, 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, name); + minimap = std::make_shared(Point(0,20)); + + for (const auto obj : objs) + minimap->addIcon(obj->visitablePos(), ImagePath::builtin("minimapIcons/generic")); + + center(); + fitToScreen(10); +} + std::shared_ptr CRClickPopup::createCustomInfoWindow(Point position, const CGObjectInstance * specific) //specific=0 => draws info about selected town/hero { diff --git a/client/windows/InfoWindows.h b/client/windows/InfoWindows.h index 324558fbb..b02edef03 100644 --- a/client/windows/InfoWindows.h +++ b/client/windows/InfoWindows.h @@ -172,3 +172,13 @@ class ObeliskPopup : public AdventureMapPopup public: ObeliskPopup(const Point & position, const CGObelisk * obelisk); }; + +class SearchPopup : public AdventureMapPopup +{ + std::shared_ptr filledBackground; + std::shared_ptr minimap; + std::shared_ptr labelTitle; + +public: + SearchPopup(std::vector objs); +};