InfoWindows.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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 "../CGameInfo.h"
  13. #include "../CPlayerInterface.h"
  14. #include "../PlayerLocalState.h"
  15. #include "../adventureMap/AdventureMapInterface.h"
  16. #include "../adventureMap/CMinimap.h"
  17. #include "../gui/CGuiHandler.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 "../../CCallback.h"
  29. #include "../../lib/CConfigHandler.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 "../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](){LOCPLINT->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. LOCPLINT->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(LOCPLINT)
  119. LOCPLINT->showingDialog->setFree();
  120. }
  121. void CInfoWindow::showAll(Canvas & to)
  122. {
  123. CIntObject::showAll(to);
  124. CMessage::drawBorder(LOCPLINT ? LOCPLINT->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. GH.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(!LOCPLINT || LOCPLINT->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. GH.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 = LOCPLINT ? LOCPLINT->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(GH.getCursorPosition()); //center on mouse
  163. #ifdef VCMI_MOBILE
  164. temp->moveBy({0, -temp->pos.h / 2});
  165. #endif
  166. temp->fitToScreen(10);
  167. GH.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. GH.windows().pushWindow(iWin);
  181. }
  182. else
  183. {
  184. std::vector<Component> components;
  185. if(settings["general"]["enableUiEnhancements"].Bool())
  186. {
  187. if(LOCPLINT->localState->getCurrentHero())
  188. components = obj->getPopupComponents(LOCPLINT->localState->getCurrentHero());
  189. else
  190. components = obj->getPopupComponents(LOCPLINT->playerID);
  191. }
  192. std::vector<std::shared_ptr<CComponent>> guiComponents;
  193. for(auto & component : components)
  194. guiComponents.push_back(std::make_shared<CComponent>(component));
  195. if(LOCPLINT->localState->getCurrentHero())
  196. CRClickPopup::createAndPush(obj->getPopupText(LOCPLINT->localState->getCurrentHero()), guiComponents);
  197. else
  198. CRClickPopup::createAndPush(obj->getPopupText(LOCPLINT->playerID), guiComponents);
  199. }
  200. }
  201. CRClickPopupInt::CRClickPopupInt(const std::shared_ptr<CIntObject> & our) :
  202. dragDistance(Point(0, 0))
  203. {
  204. addUsedEvents(DRAG_POPUP);
  205. CCS->curh->hide();
  206. inner = our;
  207. addChild(our.get(), false);
  208. }
  209. CRClickPopupInt::~CRClickPopupInt()
  210. {
  211. CCS->curh->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. LOCPLINT->cb->getTownInfo(town, iah, LOCPLINT->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. LOCPLINT->cb->getHeroInfo(hero, iah, LOCPLINT->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("TOWNQVBK"), position)
  257. {
  258. InfoAboutTown iah;
  259. LOCPLINT->cb->getTownInfo(garr, iah);
  260. OBJECT_CONSTRUCTION;
  261. tooltip = std::make_shared<CArmyTooltip>(Point(9, 10), iah);
  262. addUsedEvents(DRAG_POPUP);
  263. fitToScreen(10);
  264. }
  265. CInfoBoxPopup::CInfoBoxPopup(Point position, const CGCreature * creature)
  266. : AdventureMapPopup(RCLICK_POPUP | BORDERED, ImagePath::builtin("DIBOXBCK"), position)
  267. {
  268. OBJECT_CONSTRUCTION;
  269. tooltip = std::make_shared<CreatureTooltip>(Point(9, 10), creature);
  270. addUsedEvents(DRAG_POPUP);
  271. fitToScreen(10);
  272. }
  273. MinimapWithIcons::MinimapWithIcons(const Point & position)
  274. {
  275. OBJECT_CONSTRUCTION;
  276. pos += position;
  277. Rect areaSurface(11, 41, 144, 144);
  278. Rect areaUnderground(167, 41, 144, 144);
  279. Rect borderSurface(10, 40, 147, 147);
  280. Rect borderUnderground(166, 40, 147, 147);
  281. bool singleLevelMap = LOCPLINT->cb->getMapSize().z == 1;
  282. if (singleLevelMap)
  283. {
  284. areaSurface.x += 78;
  285. borderSurface.x += 78;
  286. }
  287. backgroundSurface = std::make_shared<TransparentFilledRectangle>(borderSurface, Colors::TRANSPARENCY, Colors::YELLOW);
  288. surface = std::make_shared<CMinimapInstance>(areaSurface.topLeft(), areaSurface.dimensions(), 0);
  289. if (!singleLevelMap)
  290. {
  291. backgroundUnderground = std::make_shared<TransparentFilledRectangle>(borderUnderground, Colors::TRANSPARENCY, Colors::YELLOW);
  292. undergroud = std::make_shared<CMinimapInstance>(areaUnderground.topLeft(), areaUnderground.dimensions(), 1);
  293. }
  294. }
  295. void MinimapWithIcons::addIcon(const int3 & coordinates, const ImagePath & image )
  296. {
  297. OBJECT_CONSTRUCTION;
  298. Rect areaSurface(11, 41, 144, 144);
  299. Rect areaUnderground(167, 41, 144, 144);
  300. bool singleLevelMap = LOCPLINT->cb->getMapSize().z == 1;
  301. if (singleLevelMap)
  302. areaSurface.x += 78;
  303. int positionX = 144 * coordinates.x / LOCPLINT->cb->getMapSize().x;
  304. int positionY = 144 * coordinates.y / LOCPLINT->cb->getMapSize().y;
  305. Point iconPosition(positionX, positionY);
  306. iconPosition -= Point(8,8); // compensate for 16x16 icon half-size
  307. if (coordinates.z == 0)
  308. iconPosition += areaSurface.topLeft();
  309. else
  310. iconPosition += areaUnderground.topLeft();
  311. iconsOverlay.push_back(std::make_shared<CPicture>(image, iconPosition));
  312. }
  313. TeleporterPopup::TeleporterPopup(const Point & position, const CGTeleport * teleporter)
  314. : AdventureMapPopup(BORDERED | RCLICK_POPUP)
  315. {
  316. OBJECT_CONSTRUCTION;
  317. pos.w = 322;
  318. pos.h = 200;
  319. filledBackground = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
  320. labelTitle = std::make_shared<CLabel>(pos.w / 2, 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, teleporter->getPopupText(LOCPLINT->playerID));
  321. minimap = std::make_shared<MinimapWithIcons>(Point(0,0));
  322. const auto & entrances = teleporter->getAllEntrances();
  323. const auto & exits = teleporter->getAllExits();
  324. std::set<ObjectInstanceID> allTeleporters;
  325. allTeleporters.insert(entrances.begin(), entrances.end());
  326. allTeleporters.insert(exits.begin(), exits.end());
  327. for (const auto exit : allTeleporters)
  328. {
  329. const auto * exitObject = LOCPLINT->cb->getObj(exit, false);
  330. if (!exitObject)
  331. continue;
  332. int3 position = exitObject->visitablePos();
  333. ImagePath image;
  334. if (!vstd::contains(entrances, exit))
  335. image = ImagePath::builtin("minimapIcons/portalExit");
  336. else if (!vstd::contains(exits, exit))
  337. image = ImagePath::builtin("minimapIcons/portalEntrance");
  338. else
  339. image = ImagePath::builtin("minimapIcons/portalBidirectional");
  340. minimap->addIcon(position, image);
  341. }
  342. center(position);
  343. fitToScreen(10);
  344. }
  345. KeymasterPopup::KeymasterPopup(const Point & position, const CGKeys * keymasterOrGuard)
  346. : AdventureMapPopup(BORDERED | RCLICK_POPUP)
  347. {
  348. OBJECT_CONSTRUCTION;
  349. pos.w = 322;
  350. pos.h = 220;
  351. filledBackground = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
  352. labelTitle = std::make_shared<CLabel>(pos.w / 2, 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, keymasterOrGuard->getObjectName());
  353. labelDescription = std::make_shared<CLabel>(pos.w / 2, 40, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, keymasterOrGuard->getObjectDescription(LOCPLINT->playerID));
  354. minimap = std::make_shared<MinimapWithIcons>(Point(0,20));
  355. const auto allObjects = LOCPLINT->cb->getAllVisitableObjs();
  356. for (const auto mapObject : allObjects)
  357. {
  358. if (!mapObject)
  359. continue;
  360. switch (mapObject->ID)
  361. {
  362. case Obj::KEYMASTER:
  363. if (mapObject->subID == keymasterOrGuard->subID)
  364. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/keymaster"));
  365. break;
  366. case Obj::BORDERGUARD:
  367. if (mapObject->subID == keymasterOrGuard->subID)
  368. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/borderguard"));
  369. break;
  370. case Obj::BORDER_GATE:
  371. if (mapObject->subID == keymasterOrGuard->subID)
  372. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/bordergate"));
  373. break;
  374. }
  375. }
  376. center(position);
  377. fitToScreen(10);
  378. }
  379. ObeliskPopup::ObeliskPopup(const Point & position, const CGObelisk * obelisk)
  380. : AdventureMapPopup(BORDERED | RCLICK_POPUP)
  381. {
  382. OBJECT_CONSTRUCTION;
  383. pos.w = 322;
  384. pos.h = 220;
  385. filledBackground = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
  386. labelTitle = std::make_shared<CLabel>(pos.w / 2, 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, obelisk->getObjectName());
  387. labelDescription = std::make_shared<CLabel>(pos.w / 2, 40, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, obelisk->getObjectDescription(LOCPLINT->playerID));
  388. minimap = std::make_shared<MinimapWithIcons>(Point(0,20));
  389. const auto allObjects = LOCPLINT->cb->getAllVisitableObjs();
  390. for (const auto mapObject : allObjects)
  391. {
  392. if (!mapObject)
  393. continue;
  394. if (mapObject->ID != Obj::OBELISK)
  395. continue;
  396. if (mapObject->wasVisited(LOCPLINT->playerID))
  397. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/obeliskVisited"));
  398. else
  399. minimap->addIcon(mapObject->visitablePos(), ImagePath::builtin("minimapIcons/obelisk"));
  400. }
  401. center(position);
  402. fitToScreen(10);
  403. }
  404. std::shared_ptr<WindowBase>
  405. CRClickPopup::createCustomInfoWindow(Point position, const CGObjectInstance * specific) //specific=0 => draws info about selected town/hero
  406. {
  407. if(nullptr == specific)
  408. specific = LOCPLINT->localState->getCurrentArmy();
  409. if(nullptr == specific)
  410. {
  411. logGlobal->error("createCustomInfoWindow: no object to describe");
  412. return nullptr;
  413. }
  414. switch(specific->ID)
  415. {
  416. case Obj::HERO:
  417. return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGHeroInstance *>(specific));
  418. case Obj::TOWN:
  419. return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGTownInstance *>(specific));
  420. case Obj::MONSTER:
  421. return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGCreature *>(specific));
  422. case Obj::GARRISON:
  423. case Obj::GARRISON2:
  424. return std::make_shared<CInfoBoxPopup>(position, dynamic_cast<const CGGarrison *>(specific));
  425. case Obj::MONOLITH_ONE_WAY_ENTRANCE:
  426. case Obj::MONOLITH_ONE_WAY_EXIT:
  427. case Obj::MONOLITH_TWO_WAY:
  428. case Obj::SUBTERRANEAN_GATE:
  429. case Obj::WHIRLPOOL:
  430. return std::make_shared<TeleporterPopup>(position, dynamic_cast<const CGTeleport *>(specific));
  431. case Obj::KEYMASTER:
  432. case Obj::BORDERGUARD:
  433. case Obj::BORDER_GATE:
  434. return std::make_shared<KeymasterPopup>(position, dynamic_cast<const CGKeys *>(specific));
  435. case Obj::OBELISK:
  436. return std::make_shared<ObeliskPopup>(position, dynamic_cast<const CGObelisk *>(specific));
  437. default:
  438. return std::shared_ptr<WindowBase>();
  439. }
  440. }