InfoWindows.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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. if(settings["general"]["enableUiEnhancements"].Bool())
  243. background->setPlayerColor(town->getOwner());
  244. addUsedEvents(DRAG_POPUP);
  245. fitToScreen(10);
  246. }
  247. CInfoBoxPopup::CInfoBoxPopup(Point position, const CGHeroInstance * hero)
  248. : AdventureMapPopup(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin("HEROQVBK"), position)
  249. {
  250. InfoAboutHero iah;
  251. GAME->interface()->cb->getHeroInfo(hero, iah, GAME->interface()->localState->getCurrentArmy()); //todo: should this be nearest hero?
  252. OBJECT_CONSTRUCTION;
  253. tooltip = std::make_shared<CHeroTooltip>(Point(9, 10), iah);
  254. if(settings["general"]["enableUiEnhancements"].Bool())
  255. background->setPlayerColor(hero->getOwner());
  256. addUsedEvents(DRAG_POPUP);
  257. fitToScreen(10);
  258. }
  259. CInfoBoxPopup::CInfoBoxPopup(Point position, const CGGarrison * garr)
  260. : AdventureMapPopup(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin(settings["general"]["enableUiEnhancements"].Bool() ? "GARRIPOP" : "TOWNQVBK"), position)
  261. {
  262. InfoAboutTown iah;
  263. GAME->interface()->cb->getTownInfo(garr, iah);
  264. OBJECT_CONSTRUCTION;
  265. if(settings["general"]["enableUiEnhancements"].Bool())
  266. {
  267. tooltip = std::make_shared<CGarrisonTooltip>(Point(9, 10), iah);
  268. }
  269. else
  270. {
  271. tooltip = std::make_shared<CArmyTooltip>(Point(9, 10), iah);
  272. }
  273. if(settings["general"]["enableUiEnhancements"].Bool())
  274. background->setPlayerColor(garr->getOwner());
  275. addUsedEvents(DRAG_POPUP);
  276. fitToScreen(10);
  277. }
  278. CInfoBoxPopup::CInfoBoxPopup(Point position, const CGCreature * creature)
  279. : AdventureMapPopup(RCLICK_POPUP | BORDERED, ImagePath::builtin("DIBOXBCK"), position)
  280. {
  281. OBJECT_CONSTRUCTION;
  282. tooltip = std::make_shared<CreatureTooltip>(Point(9, 10), creature);
  283. addUsedEvents(DRAG_POPUP);
  284. fitToScreen(10);
  285. }
  286. MinimapWithIcons::MinimapWithIcons(const Point & position)
  287. {
  288. OBJECT_CONSTRUCTION;
  289. pos += position;
  290. Rect areaSurface(11, 41, 144, 144);
  291. Rect areaUnderground(167, 41, 144, 144);
  292. Rect borderSurface(10, 40, 147, 147);
  293. Rect borderUnderground(166, 40, 147, 147);
  294. bool singleLevelMap = GAME->interface()->cb->getMapSize().z == 1; // TODO: multilevel support
  295. if (singleLevelMap)
  296. {
  297. areaSurface.x += 78;
  298. borderSurface.x += 78;
  299. }
  300. backgroundSurface = std::make_shared<TransparentFilledRectangle>(borderSurface, Colors::TRANSPARENCY, Colors::YELLOW);
  301. surface = std::make_shared<CMinimapInstance>(areaSurface.topLeft(), areaSurface.dimensions(), 0);
  302. if (!singleLevelMap)
  303. {
  304. backgroundUnderground = std::make_shared<TransparentFilledRectangle>(borderUnderground, Colors::TRANSPARENCY, Colors::YELLOW);
  305. undergroud = std::make_shared<CMinimapInstance>(areaUnderground.topLeft(), areaUnderground.dimensions(), 1);
  306. }
  307. }
  308. void MinimapWithIcons::addIcon(const int3 & coordinates, const ImagePath & image )
  309. {
  310. OBJECT_CONSTRUCTION;
  311. Rect areaSurface(11, 41, 144, 144);
  312. Rect areaUnderground(167, 41, 144, 144);
  313. bool singleLevelMap = GAME->interface()->cb->getMapSize().z == 1; // TODO: multilevel support
  314. if (singleLevelMap)
  315. areaSurface.x += 78;
  316. int positionX = 144 * coordinates.x / GAME->interface()->cb->getMapSize().x;
  317. int positionY = 144 * coordinates.y / GAME->interface()->cb->getMapSize().y;
  318. Point iconPosition(positionX, positionY);
  319. iconPosition -= Point(8,8); // compensate for 16x16 icon half-size
  320. if (coordinates.z == 0)
  321. iconPosition += areaSurface.topLeft();
  322. else
  323. iconPosition += areaUnderground.topLeft();
  324. iconsOverlay.push_back(std::make_shared<CPicture>(image, iconPosition));
  325. }
  326. TeleporterPopup::TeleporterPopup(const Point & position, const CGTeleport * teleporter)
  327. : AdventureMapPopup(BORDERED | RCLICK_POPUP)
  328. {
  329. OBJECT_CONSTRUCTION;
  330. pos.w = 322;
  331. pos.h = 200;
  332. filledBackground = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
  333. labelTitle = std::make_shared<CLabel>(pos.w / 2, 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, teleporter->getPopupText(GAME->interface()->playerID));
  334. minimap = std::make_shared<MinimapWithIcons>(Point(0,0));
  335. const auto & entrances = teleporter->getAllEntrances();
  336. const auto & exits = teleporter->getAllExits();
  337. std::set<ObjectInstanceID> allTeleporters;
  338. allTeleporters.insert(entrances.begin(), entrances.end());
  339. allTeleporters.insert(exits.begin(), exits.end());
  340. for (const auto exit : allTeleporters)
  341. {
  342. const auto * exitObject = GAME->interface()->cb->getObj(exit, false);
  343. if (!exitObject)
  344. continue;
  345. int3 position = exitObject->visitablePos();
  346. ImagePath image;
  347. if (!vstd::contains(entrances, exit))
  348. image = ImagePath::builtin("minimapIcons/portalExit");
  349. else if (!vstd::contains(exits, exit))
  350. image = ImagePath::builtin("minimapIcons/portalEntrance");
  351. else
  352. image = ImagePath::builtin("minimapIcons/portalBidirectional");
  353. minimap->addIcon(position, image);
  354. }
  355. center(position);
  356. fitToScreen(10);
  357. }
  358. KeymasterPopup::KeymasterPopup(const Point & position, const CGKeys * keymasterOrGuard)
  359. : AdventureMapPopup(BORDERED | RCLICK_POPUP)
  360. {
  361. OBJECT_CONSTRUCTION;
  362. pos.w = 322;
  363. pos.h = 220;
  364. filledBackground = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
  365. labelTitle = std::make_shared<CLabel>(pos.w / 2, 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, keymasterOrGuard->getObjectName());
  366. labelDescription = std::make_shared<CLabel>(pos.w / 2, 40, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, keymasterOrGuard->getObjectDescription(GAME->interface()->playerID));
  367. minimap = std::make_shared<MinimapWithIcons>(Point(0,20));
  368. const auto allObjects = GAME->interface()->cb->getAllVisitableObjs();
  369. for (const auto mapObject : allObjects)
  370. {
  371. if (!mapObject)
  372. continue;
  373. switch (mapObject->ID)
  374. {
  375. case Obj::KEYMASTER:
  376. if (mapObject->subID == keymasterOrGuard->subID)
  377. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/keymaster"));
  378. break;
  379. case Obj::BORDERGUARD:
  380. if (mapObject->subID == keymasterOrGuard->subID)
  381. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/borderguard"));
  382. break;
  383. case Obj::BORDER_GATE:
  384. if (mapObject->subID == keymasterOrGuard->subID)
  385. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/bordergate"));
  386. break;
  387. }
  388. }
  389. center(position);
  390. fitToScreen(10);
  391. }
  392. ObeliskPopup::ObeliskPopup(const Point & position, const CGObelisk * obelisk)
  393. : AdventureMapPopup(BORDERED | RCLICK_POPUP)
  394. {
  395. OBJECT_CONSTRUCTION;
  396. pos.w = 322;
  397. pos.h = 220;
  398. filledBackground = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
  399. labelTitle = std::make_shared<CLabel>(pos.w / 2, 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, obelisk->getObjectName());
  400. labelDescription = std::make_shared<CLabel>(pos.w / 2, 40, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, obelisk->getObjectDescription(GAME->interface()->playerID));
  401. minimap = std::make_shared<MinimapWithIcons>(Point(0,20));
  402. const auto allObjects = GAME->interface()->cb->getAllVisitableObjs();
  403. for (const auto mapObject : allObjects)
  404. {
  405. if (!mapObject)
  406. continue;
  407. if (mapObject->ID != Obj::OBELISK)
  408. continue;
  409. if (mapObject->wasVisited(GAME->interface()->playerID))
  410. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/obeliskVisited"));
  411. else
  412. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/obelisk"));
  413. }
  414. center(position);
  415. fitToScreen(10);
  416. }
  417. std::shared_ptr<WindowBase>
  418. CRClickPopup::createCustomInfoWindow(Point position, const CGObjectInstance * specific) //specific=0 => draws info about selected town/hero
  419. {
  420. if(nullptr == specific)
  421. specific = GAME->interface()->localState->getCurrentArmy();
  422. if(nullptr == specific)
  423. {
  424. logGlobal->error("createCustomInfoWindow: no object to describe");
  425. return nullptr;
  426. }
  427. switch(specific->ID)
  428. {
  429. case Obj::HERO:
  430. return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGHeroInstance *>(specific));
  431. case Obj::TOWN:
  432. return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGTownInstance *>(specific));
  433. case Obj::MONSTER:
  434. return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGCreature *>(specific));
  435. case Obj::GARRISON:
  436. case Obj::GARRISON2:
  437. return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGGarrison *>(specific));
  438. case Obj::MONOLITH_ONE_WAY_ENTRANCE:
  439. case Obj::MONOLITH_ONE_WAY_EXIT:
  440. case Obj::MONOLITH_TWO_WAY:
  441. case Obj::SUBTERRANEAN_GATE:
  442. case Obj::WHIRLPOOL:
  443. return std::make_shared<TeleporterPopup>(position, dynamic_cast<const CGTeleport *>(specific));
  444. case Obj::KEYMASTER:
  445. case Obj::BORDERGUARD:
  446. case Obj::BORDER_GATE:
  447. return std::make_shared<KeymasterPopup>(position, dynamic_cast<const CGKeys *>(specific));
  448. case Obj::OBELISK:
  449. return std::make_shared<ObeliskPopup>(position, dynamic_cast<const CGObelisk *>(specific));
  450. default:
  451. return std::shared_ptr<WindowBase>();
  452. }
  453. }