InfoWindows.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. /*
  2. * InfoWindows.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "InfoWindows.h"
  12. #include "../CPlayerInterface.h"
  13. #include "../PlayerLocalState.h"
  14. #include "../adventureMap/AdventureMapInterface.h"
  15. #include "../adventureMap/CMinimap.h"
  16. #include "../GameEngine.h"
  17. #include "../GameInstance.h"
  18. #include "../gui/CursorHandler.h"
  19. #include "../gui/Shortcut.h"
  20. #include "../gui/WindowHandler.h"
  21. #include "../widgets/Buttons.h"
  22. #include "../widgets/CComponent.h"
  23. #include "../widgets/GraphicalPrimitiveCanvas.h"
  24. #include "../widgets/Images.h"
  25. #include "../widgets/MiscWidgets.h"
  26. #include "../widgets/TextControls.h"
  27. #include "../windows/CMessage.h"
  28. #include "../../lib/CConfigHandler.h"
  29. #include "../../lib/callback/CCallback.h"
  30. #include "../../lib/gameState/InfoAboutArmy.h"
  31. #include "../../lib/mapObjects/CGCreature.h"
  32. #include "../../lib/mapObjects/CGHeroInstance.h"
  33. #include "../../lib/mapObjects/CGTownInstance.h"
  34. #include "../../lib/mapObjects/CQuest.h"
  35. #include "../../lib/mapObjects/MiscObjects.h"
  36. #include "../../lib/ConditionalWait.h"
  37. 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)
  38. {
  39. OBJECT_CONSTRUCTION;
  40. backgroundTexture = std::make_shared<CFilledTexture>(ImagePath::builtin("DiBoxBck"), pos);
  41. ID = askID;
  42. for(int i = 0; i < Buttons.size(); i++)
  43. {
  44. buttons.push_back(std::make_shared<CButton>(Point(0, 0), Buttons[i].first, CButton::tooltip(), Buttons[i].second));
  45. if(!i && askID.getNum() >= 0)
  46. buttons.back()->addCallback(std::bind(&CSelWindow::madeChoice, this));
  47. buttons[i]->addCallback(std::bind(&CInfoWindow::close, this)); //each button will close the window apart from call-defined actions
  48. }
  49. text = std::make_shared<CTextBox>(Text, Rect(0, 0, 250, 100), 0, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
  50. if(buttons.size() > 1 && askID.getNum() >= 0) //cancel button functionality
  51. buttons.back()->addCallback([askID](){GAME->interface()->cb->selectionMade(0, askID);});
  52. if(buttons.size() == 1)
  53. buttons.front()->assignedKey = EShortcut::GLOBAL_RETURN;
  54. if(buttons.size() == 2)
  55. {
  56. buttons.front()->assignedKey = EShortcut::GLOBAL_ACCEPT;
  57. buttons.back()->assignedKey = EShortcut::GLOBAL_CANCEL;
  58. }
  59. if(!comps.empty())
  60. {
  61. components = std::make_shared<CComponentBox>(comps, Rect(0,0,0,0));
  62. for (auto & comp : comps)
  63. comp->onChoose = [this](){ madeChoiceAndClose(); };
  64. }
  65. CMessage::drawIWindow(this, Text, player);
  66. }
  67. void CSelWindow::madeChoice()
  68. {
  69. if(ID.getNum() < 0)
  70. return;
  71. int ret = -1;
  72. if(components)
  73. ret = components->selectedIndex();
  74. GAME->interface()->cb->selectionMade(ret + 1, ID);
  75. }
  76. void CSelWindow::madeChoiceAndClose()
  77. {
  78. madeChoice();
  79. close();
  80. }
  81. CInfoWindow::CInfoWindow(const std::string & Text, PlayerColor player, const TCompsInfo & comps, const TButtonsInfo & Buttons)
  82. {
  83. OBJECT_CONSTRUCTION;
  84. backgroundTexture = std::make_shared<CFilledTexture>(ImagePath::builtin("DiBoxBck"), pos);
  85. ID = QueryID(-1);
  86. for(const auto & Button : Buttons)
  87. {
  88. auto button = std::make_shared<CButton>(Point(0, 0), Button.first, CButton::tooltip(), std::bind(&CInfoWindow::close, this));
  89. button->setBorderColor(Colors::METALLIC_GOLD);
  90. button->addCallback(Button.second); //each button will close the window apart from call-defined actions
  91. buttons.push_back(button);
  92. }
  93. text = std::make_shared<CTextBox>(Text, Rect(0, 0, 250, 100), 0, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
  94. if(!text->slider)
  95. {
  96. int finalWidth = std::min(250, text->label->textSize.x + 32);
  97. int finalHeight = text->label->textSize.y;
  98. text->resize(Point(finalWidth, finalHeight));
  99. }
  100. if(buttons.size() == 1)
  101. buttons.front()->assignedKey = EShortcut::GLOBAL_RETURN;
  102. if(buttons.size() == 2)
  103. {
  104. buttons.front()->assignedKey = EShortcut::GLOBAL_ACCEPT;
  105. buttons.back()->assignedKey = EShortcut::GLOBAL_CANCEL;
  106. }
  107. if(!comps.empty())
  108. components = std::make_shared<CComponentBox>(comps, Rect(0,0,0,0));
  109. CMessage::drawIWindow(this, Text, player);
  110. }
  111. CInfoWindow::CInfoWindow()
  112. {
  113. ID = QueryID(-1);
  114. }
  115. void CInfoWindow::close()
  116. {
  117. WindowBase::close();
  118. if(GAME->interface())
  119. GAME->interface()->showingDialog->setFree();
  120. }
  121. void CInfoWindow::showAll(Canvas & to)
  122. {
  123. CIntObject::showAll(to);
  124. CMessage::drawBorder(GAME->interface() ? GAME->interface()->playerID : PlayerColor(1), to, pos.w+28, pos.h+29, pos.x-14, pos.y-15);
  125. }
  126. CInfoWindow::~CInfoWindow() = default;
  127. void CInfoWindow::showInfoDialog(const std::string & text, const TCompsInfo & components, PlayerColor player)
  128. {
  129. ENGINE->windows().pushWindow(CInfoWindow::create(text, player, components));
  130. }
  131. void CInfoWindow::showYesNoDialog(const std::string & text, const TCompsInfo & components, const CFunctionList<void()> & onYes, const CFunctionList<void()> & onNo, PlayerColor player)
  132. {
  133. assert(!GAME->interface() || GAME->interface()->showingDialog->isBusy());
  134. std::vector<std::pair<AnimationPath, CFunctionList<void()>>> pom;
  135. pom.emplace_back(AnimationPath::builtin("IOKAY.DEF"), nullptr);
  136. pom.emplace_back(AnimationPath::builtin("ICANCEL.DEF"), nullptr);
  137. auto temp = std::make_shared<CInfoWindow>(text, player, components, pom);
  138. temp->buttons[0]->addCallback(onYes);
  139. temp->buttons[1]->addCallback(onNo);
  140. ENGINE->windows().pushWindow(temp);
  141. }
  142. std::shared_ptr<CInfoWindow> CInfoWindow::create(const std::string & text, PlayerColor playerID, const TCompsInfo & components)
  143. {
  144. std::vector<std::pair<AnimationPath, CFunctionList<void()>>> pom;
  145. pom.emplace_back(AnimationPath::builtin("IOKAY.DEF"), nullptr);
  146. return std::make_shared<CInfoWindow>(text, playerID, components, pom);
  147. }
  148. std::string CInfoWindow::genText(const std::string & title, const std::string & description)
  149. {
  150. return std::string("{") + title + "}" + "\n\n" + description;
  151. }
  152. bool CRClickPopup::isPopupWindow() const
  153. {
  154. return true;
  155. }
  156. void CRClickPopup::createAndPush(const std::string & txt, const CInfoWindow::TCompsInfo & comps)
  157. {
  158. PlayerColor player = GAME->interface() ? GAME->interface()->playerID : PlayerColor(1); //if no player, then use blue
  159. if(settings["session"]["spectate"].Bool()) //TODO: there must be better way to implement this
  160. player = PlayerColor(1);
  161. auto temp = std::make_shared<CInfoWindow>(txt, player, comps);
  162. temp->center(ENGINE->getCursorPosition()); //center on mouse
  163. #ifdef VCMI_MOBILE
  164. temp->moveBy({0, -temp->pos.h / 2});
  165. #endif
  166. temp->fitToScreen(10);
  167. ENGINE->windows().createAndPushWindow<CRClickPopupInt>(temp);
  168. }
  169. void CRClickPopup::createAndPush(const std::string & txt, const std::shared_ptr<CComponent> & component)
  170. {
  171. CInfoWindow::TCompsInfo intComps;
  172. intComps.push_back(component);
  173. createAndPush(txt, intComps);
  174. }
  175. void CRClickPopup::createAndPush(const CGObjectInstance * obj, const Point & p, ETextAlignment alignment)
  176. {
  177. auto iWin = createCustomInfoWindow(p, obj); //try get custom infowindow for this obj
  178. if(iWin)
  179. {
  180. ENGINE->windows().pushWindow(iWin);
  181. }
  182. else
  183. {
  184. std::vector<Component> components;
  185. if(settings["general"]["enableUiEnhancements"].Bool())
  186. {
  187. if(GAME->interface()->localState->getCurrentHero())
  188. components = obj->getPopupComponents(GAME->interface()->localState->getCurrentHero());
  189. else
  190. components = obj->getPopupComponents(GAME->interface()->playerID);
  191. }
  192. std::vector<std::shared_ptr<CComponent>> guiComponents;
  193. for(auto & component : components)
  194. guiComponents.push_back(std::make_shared<CComponent>(component, CComponent::medium));
  195. if(GAME->interface()->localState->getCurrentHero())
  196. CRClickPopup::createAndPush(obj->getPopupText(GAME->interface()->localState->getCurrentHero()), guiComponents);
  197. else
  198. CRClickPopup::createAndPush(obj->getPopupText(GAME->interface()->playerID), guiComponents);
  199. }
  200. }
  201. CRClickPopupInt::CRClickPopupInt(const std::shared_ptr<CIntObject> & our) :
  202. dragDistance(Point(0, 0))
  203. {
  204. addUsedEvents(DRAG_POPUP);
  205. ENGINE->cursor().hide();
  206. inner = our;
  207. addChild(our.get(), false);
  208. }
  209. CRClickPopupInt::~CRClickPopupInt()
  210. {
  211. ENGINE->cursor().show();
  212. }
  213. void CRClickPopupInt::mouseDraggedPopup(const Point & cursorPosition, const Point & lastUpdateDistance)
  214. {
  215. if(!settings["adventure"]["rightButtonDrag"].Bool())
  216. return;
  217. dragDistance += lastUpdateDistance;
  218. if(dragDistance.length() > 16)
  219. close();
  220. }
  221. template<typename... Args>
  222. AdventureMapPopup::AdventureMapPopup(Args&&... args) :
  223. CWindowObject(std::forward<Args>(args)...), dragDistance(Point(0, 0))
  224. {
  225. addUsedEvents(DRAG_POPUP);
  226. }
  227. void AdventureMapPopup::mouseDraggedPopup(const Point & cursorPosition, const Point & lastUpdateDistance)
  228. {
  229. if(!settings["adventure"]["rightButtonDrag"].Bool())
  230. return;
  231. dragDistance += lastUpdateDistance;
  232. if(dragDistance.length() > 16)
  233. close();
  234. }
  235. CInfoBoxPopup::CInfoBoxPopup(Point position, const CGTownInstance * town)
  236. : AdventureMapPopup(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin("TOWNQVBK"), position)
  237. {
  238. InfoAboutTown iah;
  239. GAME->interface()->cb->getTownInfo(town, iah, GAME->interface()->localState->getCurrentArmy()); //todo: should this be nearest hero?
  240. OBJECT_CONSTRUCTION;
  241. tooltip = std::make_shared<CTownTooltip>(Point(9, 10), iah);
  242. addUsedEvents(DRAG_POPUP);
  243. fitToScreen(10);
  244. }
  245. CInfoBoxPopup::CInfoBoxPopup(Point position, const CGHeroInstance * hero)
  246. : AdventureMapPopup(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin("HEROQVBK"), position)
  247. {
  248. InfoAboutHero iah;
  249. GAME->interface()->cb->getHeroInfo(hero, iah, GAME->interface()->localState->getCurrentArmy()); //todo: should this be nearest hero?
  250. OBJECT_CONSTRUCTION;
  251. tooltip = std::make_shared<CHeroTooltip>(Point(9, 10), iah);
  252. addUsedEvents(DRAG_POPUP);
  253. fitToScreen(10);
  254. }
  255. CInfoBoxPopup::CInfoBoxPopup(Point position, const CGGarrison * garr)
  256. : AdventureMapPopup(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin(settings["general"]["enableUiEnhancements"].Bool() ? "GARRIPOP" : "TOWNQVBK"), position)
  257. {
  258. InfoAboutTown iah;
  259. GAME->interface()->cb->getTownInfo(garr, iah);
  260. OBJECT_CONSTRUCTION;
  261. if(settings["general"]["enableUiEnhancements"].Bool())
  262. {
  263. tooltip = std::make_shared<CGarrisonTooltip>(Point(9, 10), iah);
  264. }
  265. else
  266. {
  267. tooltip = std::make_shared<CTownTooltip>(Point(9, 10), iah);
  268. }
  269. addUsedEvents(DRAG_POPUP);
  270. fitToScreen(10);
  271. }
  272. CInfoBoxPopup::CInfoBoxPopup(Point position, const CGCreature * creature)
  273. : AdventureMapPopup(RCLICK_POPUP | BORDERED, ImagePath::builtin("DIBOXBCK"), position)
  274. {
  275. OBJECT_CONSTRUCTION;
  276. tooltip = std::make_shared<CreatureTooltip>(Point(9, 10), creature);
  277. addUsedEvents(DRAG_POPUP);
  278. fitToScreen(10);
  279. }
  280. MinimapWithIcons::MinimapWithIcons(const Point & position)
  281. {
  282. OBJECT_CONSTRUCTION;
  283. pos += position;
  284. Rect areaSurface(11, 41, 144, 144);
  285. Rect areaUnderground(167, 41, 144, 144);
  286. Rect borderSurface(10, 40, 147, 147);
  287. Rect borderUnderground(166, 40, 147, 147);
  288. bool singleLevelMap = GAME->interface()->cb->getMapSize().z == 1; // TODO: multilevel support
  289. if (singleLevelMap)
  290. {
  291. areaSurface.x += 78;
  292. borderSurface.x += 78;
  293. }
  294. backgroundSurface = std::make_shared<TransparentFilledRectangle>(borderSurface, Colors::TRANSPARENCY, Colors::YELLOW);
  295. surface = std::make_shared<CMinimapInstance>(areaSurface.topLeft(), areaSurface.dimensions(), 0);
  296. if (!singleLevelMap)
  297. {
  298. backgroundUnderground = std::make_shared<TransparentFilledRectangle>(borderUnderground, Colors::TRANSPARENCY, Colors::YELLOW);
  299. undergroud = std::make_shared<CMinimapInstance>(areaUnderground.topLeft(), areaUnderground.dimensions(), 1);
  300. }
  301. }
  302. void MinimapWithIcons::addIcon(const int3 & coordinates, const ImagePath & image )
  303. {
  304. OBJECT_CONSTRUCTION;
  305. Rect areaSurface(11, 41, 144, 144);
  306. Rect areaUnderground(167, 41, 144, 144);
  307. bool singleLevelMap = GAME->interface()->cb->getMapSize().z == 1; // TODO: multilevel support
  308. if (singleLevelMap)
  309. areaSurface.x += 78;
  310. int positionX = 144 * coordinates.x / GAME->interface()->cb->getMapSize().x;
  311. int positionY = 144 * coordinates.y / GAME->interface()->cb->getMapSize().y;
  312. Point iconPosition(positionX, positionY);
  313. iconPosition -= Point(8,8); // compensate for 16x16 icon half-size
  314. if (coordinates.z == 0)
  315. iconPosition += areaSurface.topLeft();
  316. else
  317. iconPosition += areaUnderground.topLeft();
  318. iconsOverlay.push_back(std::make_shared<CPicture>(image, iconPosition));
  319. }
  320. TeleporterPopup::TeleporterPopup(const Point & position, const CGTeleport * teleporter)
  321. : AdventureMapPopup(BORDERED | RCLICK_POPUP)
  322. {
  323. OBJECT_CONSTRUCTION;
  324. pos.w = 322;
  325. pos.h = 200;
  326. filledBackground = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
  327. labelTitle = std::make_shared<CLabel>(pos.w / 2, 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, teleporter->getPopupText(GAME->interface()->playerID));
  328. minimap = std::make_shared<MinimapWithIcons>(Point(0,0));
  329. const auto & entrances = teleporter->getAllEntrances();
  330. const auto & exits = teleporter->getAllExits();
  331. std::set<ObjectInstanceID> allTeleporters;
  332. allTeleporters.insert(entrances.begin(), entrances.end());
  333. allTeleporters.insert(exits.begin(), exits.end());
  334. for (const auto exit : allTeleporters)
  335. {
  336. const auto * exitObject = GAME->interface()->cb->getObj(exit, false);
  337. if (!exitObject)
  338. continue;
  339. int3 position = exitObject->visitablePos();
  340. ImagePath image;
  341. if (!vstd::contains(entrances, exit))
  342. image = ImagePath::builtin("minimapIcons/portalExit");
  343. else if (!vstd::contains(exits, exit))
  344. image = ImagePath::builtin("minimapIcons/portalEntrance");
  345. else
  346. image = ImagePath::builtin("minimapIcons/portalBidirectional");
  347. minimap->addIcon(position, image);
  348. }
  349. center(position);
  350. fitToScreen(10);
  351. }
  352. KeymasterPopup::KeymasterPopup(const Point & position, const CGKeys * keymasterOrGuard)
  353. : AdventureMapPopup(BORDERED | RCLICK_POPUP)
  354. {
  355. OBJECT_CONSTRUCTION;
  356. pos.w = 322;
  357. pos.h = 220;
  358. filledBackground = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
  359. labelTitle = std::make_shared<CLabel>(pos.w / 2, 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, keymasterOrGuard->getObjectName());
  360. labelDescription = std::make_shared<CLabel>(pos.w / 2, 40, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, keymasterOrGuard->getObjectDescription(GAME->interface()->playerID));
  361. minimap = std::make_shared<MinimapWithIcons>(Point(0,20));
  362. const auto allObjects = GAME->interface()->cb->getAllVisitableObjs();
  363. for (const auto mapObject : allObjects)
  364. {
  365. if (!mapObject)
  366. continue;
  367. switch (mapObject->ID)
  368. {
  369. case Obj::KEYMASTER:
  370. if (mapObject->subID == keymasterOrGuard->subID)
  371. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/keymaster"));
  372. break;
  373. case Obj::BORDERGUARD:
  374. if (mapObject->subID == keymasterOrGuard->subID)
  375. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/borderguard"));
  376. break;
  377. case Obj::BORDER_GATE:
  378. if (mapObject->subID == keymasterOrGuard->subID)
  379. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/bordergate"));
  380. break;
  381. }
  382. }
  383. center(position);
  384. fitToScreen(10);
  385. }
  386. ObeliskPopup::ObeliskPopup(const Point & position, const CGObelisk * obelisk)
  387. : AdventureMapPopup(BORDERED | RCLICK_POPUP)
  388. {
  389. OBJECT_CONSTRUCTION;
  390. pos.w = 322;
  391. pos.h = 220;
  392. filledBackground = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
  393. labelTitle = std::make_shared<CLabel>(pos.w / 2, 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, obelisk->getObjectName());
  394. labelDescription = std::make_shared<CLabel>(pos.w / 2, 40, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, obelisk->getObjectDescription(GAME->interface()->playerID));
  395. minimap = std::make_shared<MinimapWithIcons>(Point(0,20));
  396. const auto allObjects = GAME->interface()->cb->getAllVisitableObjs();
  397. for (const auto mapObject : allObjects)
  398. {
  399. if (!mapObject)
  400. continue;
  401. if (mapObject->ID != Obj::OBELISK)
  402. continue;
  403. if (mapObject->wasVisited(GAME->interface()->playerID))
  404. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/obeliskVisited"));
  405. else
  406. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/obelisk"));
  407. }
  408. center(position);
  409. fitToScreen(10);
  410. }
  411. std::shared_ptr<WindowBase>
  412. CRClickPopup::createCustomInfoWindow(Point position, const CGObjectInstance * specific) //specific=0 => draws info about selected town/hero
  413. {
  414. if(nullptr == specific)
  415. specific = GAME->interface()->localState->getCurrentArmy();
  416. if(nullptr == specific)
  417. {
  418. logGlobal->error("createCustomInfoWindow: no object to describe");
  419. return nullptr;
  420. }
  421. switch(specific->ID)
  422. {
  423. case Obj::HERO:
  424. return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGHeroInstance *>(specific));
  425. case Obj::TOWN:
  426. return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGTownInstance *>(specific));
  427. case Obj::MONSTER:
  428. return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGCreature *>(specific));
  429. case Obj::GARRISON:
  430. case Obj::GARRISON2:
  431. return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGGarrison *>(specific));
  432. case Obj::MONOLITH_ONE_WAY_ENTRANCE:
  433. case Obj::MONOLITH_ONE_WAY_EXIT:
  434. case Obj::MONOLITH_TWO_WAY:
  435. case Obj::SUBTERRANEAN_GATE:
  436. case Obj::WHIRLPOOL:
  437. return std::make_shared<TeleporterPopup>(position, dynamic_cast<const CGTeleport *>(specific));
  438. case Obj::KEYMASTER:
  439. case Obj::BORDERGUARD:
  440. case Obj::BORDER_GATE:
  441. return std::make_shared<KeymasterPopup>(position, dynamic_cast<const CGKeys *>(specific));
  442. case Obj::OBELISK:
  443. return std::make_shared<ObeliskPopup>(position, dynamic_cast<const CGObelisk *>(specific));
  444. default:
  445. return std::shared_ptr<WindowBase>();
  446. }
  447. }