CBonusSelection.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. /*
  2. * CBonusSelection.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 "CBonusSelection.h"
  12. #include <vcmi/spells/Spell.h>
  13. #include <vcmi/spells/Service.h>
  14. #include "CSelectionBase.h"
  15. #include "ExtraOptionsTab.h"
  16. #include "../CGameInfo.h"
  17. #include "../CPlayerInterface.h"
  18. #include "../CServerHandler.h"
  19. #include "../mainmenu/CMainMenu.h"
  20. #include "../mainmenu/CPrologEpilogVideo.h"
  21. #include "../media/IMusicPlayer.h"
  22. #include "../widgets/CComponent.h"
  23. #include "../widgets/Buttons.h"
  24. #include "../widgets/MiscWidgets.h"
  25. #include "../widgets/ObjectLists.h"
  26. #include "../widgets/TextControls.h"
  27. #include "../widgets/VideoWidget.h"
  28. #include "../windows/GUIClasses.h"
  29. #include "../windows/InfoWindows.h"
  30. #include "../render/IImage.h"
  31. #include "../render/IRenderHandler.h"
  32. #include "../render/CAnimation.h"
  33. #include "../render/Graphics.h"
  34. #include "../gui/CGuiHandler.h"
  35. #include "../gui/Shortcut.h"
  36. #include "../gui/WindowHandler.h"
  37. #include "../../lib/CConfigHandler.h"
  38. #include "../../lib/CCreatureHandler.h"
  39. #include "../../lib/CHeroHandler.h"
  40. #include "../../lib/CSkillHandler.h"
  41. #include "../../lib/StartInfo.h"
  42. #include "../../lib/entities/building/CBuilding.h"
  43. #include "../../lib/entities/building/CBuildingHandler.h"
  44. #include "../../lib/entities/faction/CFaction.h"
  45. #include "../../lib/entities/faction/CTown.h"
  46. #include "../../lib/entities/faction/CTownHandler.h"
  47. #include "../../lib/filesystem/Filesystem.h"
  48. #include "../../lib/texts/CGeneralTextHandler.h"
  49. #include "../../lib/campaign/CampaignState.h"
  50. #include "../../lib/mapping/CMapService.h"
  51. #include "../../lib/mapping/CMapInfo.h"
  52. #include "../../lib/mapObjects/CGHeroInstance.h"
  53. std::shared_ptr<CampaignState> CBonusSelection::getCampaign()
  54. {
  55. return CSH->si->campState;
  56. }
  57. CBonusSelection::CBonusSelection()
  58. : CWindowObject(BORDERED)
  59. {
  60. OBJECT_CONSTRUCTION;
  61. setBackground(getCampaign()->getRegions().getBackgroundName());
  62. panelBackground = std::make_shared<CPicture>(ImagePath::builtin("CAMPBRF.BMP"), 456, 6);
  63. const auto & playVideo = [this]()
  64. {
  65. GH.windows().createAndPushWindow<CPrologEpilogVideo>(
  66. getCampaign()->scenario(CSH->campaignMap).prolog,
  67. [this]() { redraw(); } );
  68. };
  69. buttonStart = std::make_shared<CButton>(
  70. Point(475, 536), AnimationPath::builtin("CBBEGIB.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::startMap, this), EShortcut::GLOBAL_ACCEPT
  71. );
  72. buttonRestart = std::make_shared<CButton>(Point(475, 536), AnimationPath::builtin("CBRESTB.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::restartMap, this), EShortcut::GLOBAL_ACCEPT);
  73. buttonVideo = std::make_shared<CButton>(Point(705, 214), AnimationPath::builtin("CBVIDEB.DEF"), CButton::tooltip(), playVideo, EShortcut::LOBBY_REPLAY_VIDEO);
  74. buttonBack = std::make_shared<CButton>(Point(624, 536), AnimationPath::builtin("CBCANCB.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::goBack, this), EShortcut::GLOBAL_CANCEL);
  75. campaignName = std::make_shared<CLabel>(481, 28, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW, CSH->si->getCampaignName(), 250);
  76. iconsMapSizes = std::make_shared<CAnimImage>(AnimationPath::builtin("SCNRMPSZ"), 4, 0, 735, 26);
  77. labelCampaignDescription = std::make_shared<CLabel>(481, 63, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[38]);
  78. campaignDescription = std::make_shared<CTextBox>(getCampaign()->getDescriptionTranslated(), Rect(480, 86, 286, 117), 1);
  79. bool videoButtonActive = CSH->getState() == EClientState::GAMEPLAY;
  80. int availableSpace = videoButtonActive ? 225 : 285;
  81. mapName = std::make_shared<CLabel>(481, 219, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW, CSH->mi->getNameTranslated(), availableSpace );
  82. labelMapDescription = std::make_shared<CLabel>(481, 253, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[496]);
  83. mapDescription = std::make_shared<CTextBox>("", Rect(480, 278, 292, 108), 1);
  84. labelChooseBonus = std::make_shared<CLabel>(475, 432, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[71]);
  85. groupBonuses = std::make_shared<CToggleGroup>(std::bind(&IServerAPI::setCampaignBonus, CSH, _1));
  86. flagbox = std::make_shared<CFlagBox>(Rect(486, 407, 335, 23));
  87. std::vector<std::string> difficulty;
  88. std::string difficultyString = CGI->generaltexth->allTexts[492];
  89. boost::split(difficulty, difficultyString, boost::is_any_of(" "));
  90. labelDifficulty = std::make_shared<CLabel>(724, settings["general"]["enableUiEnhancements"].Bool() ? 457 : 432, FONT_MEDIUM, ETextAlignment::TOPCENTER, Colors::WHITE, difficulty.back());
  91. for(size_t b = 0; b < difficultyIcons.size(); ++b)
  92. {
  93. difficultyIcons[b] = std::make_shared<CAnimImage>(AnimationPath::builtinTODO("GSPBUT" + std::to_string(b + 3) + ".DEF"), 0, 0, 709, settings["general"]["enableUiEnhancements"].Bool() ? 480 : 455);
  94. }
  95. if(getCampaign()->playerSelectedDifficulty())
  96. {
  97. Point posLeft = settings["general"]["enableUiEnhancements"].Bool() ? Point(693, 495) : Point(694, 508);
  98. Point posRight = settings["general"]["enableUiEnhancements"].Bool() ? Point(739, 495) : Point(738, 508);
  99. buttonDifficultyLeft = std::make_shared<CButton>(posLeft, AnimationPath::builtin("SCNRBLF.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::decreaseDifficulty, this), EShortcut::MOVE_LEFT);
  100. buttonDifficultyRight = std::make_shared<CButton>(posRight, AnimationPath::builtin("SCNRBRT.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::increaseDifficulty, this), EShortcut::MOVE_RIGHT);
  101. }
  102. for(auto scenarioID : getCampaign()->allScenarios())
  103. {
  104. if(getCampaign()->isAvailable(scenarioID))
  105. regions.push_back(std::make_shared<CRegion>(scenarioID, true, true, getCampaign()->getRegions()));
  106. else if(getCampaign()->isConquered(scenarioID)) //display as striped
  107. regions.push_back(std::make_shared<CRegion>(scenarioID, false, false, getCampaign()->getRegions()));
  108. }
  109. if (!getCampaign()->getMusic().empty())
  110. CCS->musich->playMusic( getCampaign()->getMusic(), true, false);
  111. if(CSH->getState() != EClientState::GAMEPLAY && settings["general"]["enableUiEnhancements"].Bool())
  112. {
  113. tabExtraOptions = std::make_shared<ExtraOptionsTab>();
  114. tabExtraOptions->recActions = UPDATE | SHOWALL | LCLICK | RCLICK_POPUP;
  115. tabExtraOptions->recreate(true);
  116. tabExtraOptions->setEnabled(false);
  117. buttonExtraOptions = std::make_shared<CButton>(Point(643, 431), AnimationPath::builtin("GSPBUT2.DEF"), CGI->generaltexth->zelp[46], [this]{ tabExtraOptions->setEnabled(!tabExtraOptions->isActive()); GH.windows().totalRedraw(); }, EShortcut::LOBBY_EXTRA_OPTIONS);
  118. buttonExtraOptions->setTextOverlay(CGI->generaltexth->translate("vcmi.optionsTab.extraOptions.hover"), FONT_SMALL, Colors::WHITE);
  119. }
  120. }
  121. void CBonusSelection::createBonusesIcons()
  122. {
  123. OBJECT_CONSTRUCTION;
  124. const CampaignScenario & scenario = getCampaign()->scenario(CSH->campaignMap);
  125. const std::vector<CampaignBonus> & bonDescs = scenario.travelOptions.bonusesToChoose;
  126. groupBonuses = std::make_shared<CToggleGroup>(std::bind(&IServerAPI::setCampaignBonus, CSH, _1));
  127. constexpr std::array bonusPics =
  128. {
  129. "SPELLBON.DEF", // Spell
  130. "TWCRPORT.DEF", // Monster
  131. "", // Building - BO*.BMP
  132. "ARTIFBON.DEF", // Artifact
  133. "SPELLBON.DEF", // Spell scroll
  134. "PSKILBON.DEF", // Primary skill
  135. "SSKILBON.DEF", // Secondary skill
  136. "BORES.DEF", // Resource
  137. "PORTRAITSLARGE", // Hero HPL*.BMP
  138. "PORTRAITSLARGE"
  139. // Player - CREST58.DEF
  140. };
  141. for(int i = 0; i < bonDescs.size(); i++)
  142. {
  143. int bonusType = static_cast<size_t>(bonDescs[i].type);
  144. std::string picName = bonusPics[bonusType];
  145. size_t picNumber = bonDescs[i].info2;
  146. MetaString desc;
  147. switch(bonDescs[i].type)
  148. {
  149. case CampaignBonusType::SPELL:
  150. desc.appendLocalString(EMetaText::GENERAL_TXT, 715);
  151. desc.replaceName(SpellID(bonDescs[i].info2));
  152. break;
  153. case CampaignBonusType::MONSTER:
  154. picNumber = bonDescs[i].info2 + 2;
  155. desc.appendLocalString(EMetaText::GENERAL_TXT, 717);
  156. desc.replaceNumber(bonDescs[i].info3);
  157. desc.replaceNamePlural(bonDescs[i].info2);
  158. break;
  159. case CampaignBonusType::BUILDING:
  160. {
  161. FactionID faction;
  162. for(auto & elem : CSH->si->playerInfos)
  163. {
  164. if(elem.second.isControlledByHuman())
  165. {
  166. faction = elem.second.castle;
  167. break;
  168. }
  169. }
  170. assert(faction != -1);
  171. BuildingID buildID;
  172. if(getCampaign()->formatVCMI())
  173. buildID = BuildingID(bonDescs[i].info1);
  174. else
  175. buildID = CBuildingHandler::campToERMU(bonDescs[i].info1, faction, std::set<BuildingID>());
  176. picName = graphics->ERMUtoPicture[faction][buildID];
  177. picNumber = -1;
  178. if(vstd::contains((*CGI->townh)[faction]->town->buildings, buildID))
  179. desc.appendTextID((*CGI->townh)[faction]->town->buildings.find(buildID)->second->getNameTextID());
  180. break;
  181. }
  182. case CampaignBonusType::ARTIFACT:
  183. desc.appendLocalString(EMetaText::GENERAL_TXT, 715);
  184. desc.replaceName(ArtifactID(bonDescs[i].info2));
  185. break;
  186. case CampaignBonusType::SPELL_SCROLL:
  187. desc.appendLocalString(EMetaText::GENERAL_TXT, 716);
  188. desc.replaceName(SpellID(bonDescs[i].info2));
  189. break;
  190. case CampaignBonusType::PRIMARY_SKILL:
  191. {
  192. int leadingSkill = -1;
  193. std::vector<std::pair<int, int>> toPrint; //primary skills to be listed <num, val>
  194. const ui8 * ptr = reinterpret_cast<const ui8 *>(&bonDescs[i].info2);
  195. for(int g = 0; g < GameConstants::PRIMARY_SKILLS; ++g)
  196. {
  197. if(leadingSkill == -1 || ptr[g] > ptr[leadingSkill])
  198. {
  199. leadingSkill = g;
  200. }
  201. if(ptr[g] != 0)
  202. {
  203. toPrint.push_back(std::make_pair(g, ptr[g]));
  204. }
  205. }
  206. picNumber = leadingSkill;
  207. desc.appendLocalString(EMetaText::GENERAL_TXT, 715);
  208. std::string substitute; //text to be printed instead of %s
  209. for(int v = 0; v < toPrint.size(); ++v)
  210. {
  211. substitute += std::to_string(toPrint[v].second);
  212. substitute += " " + CGI->generaltexth->primarySkillNames[toPrint[v].first];
  213. if(v != toPrint.size() - 1)
  214. {
  215. substitute += ", ";
  216. }
  217. }
  218. desc.replaceRawString(substitute);
  219. break;
  220. }
  221. case CampaignBonusType::SECONDARY_SKILL:
  222. desc.appendLocalString(EMetaText::GENERAL_TXT, 718);
  223. desc.replaceTextID(TextIdentifier("core", "skilllev", bonDescs[i].info3 - 1).get());
  224. desc.replaceName(SecondarySkill(bonDescs[i].info2));
  225. picNumber = bonDescs[i].info2 * 3 + bonDescs[i].info3 - 1;
  226. break;
  227. case CampaignBonusType::RESOURCE:
  228. {
  229. desc.appendLocalString(EMetaText::GENERAL_TXT, 717);
  230. switch(bonDescs[i].info1)
  231. {
  232. case 0xFD: //wood + ore
  233. {
  234. desc.replaceLocalString(EMetaText::GENERAL_TXT, 721);
  235. picNumber = 7;
  236. break;
  237. }
  238. case 0xFE: //wood + ore
  239. {
  240. desc.replaceLocalString(EMetaText::GENERAL_TXT, 722);
  241. picNumber = 8;
  242. break;
  243. }
  244. default:
  245. {
  246. desc.replaceName(GameResID(bonDescs[i].info1));
  247. picNumber = bonDescs[i].info1;
  248. }
  249. }
  250. desc.replaceNumber(bonDescs[i].info2);
  251. break;
  252. }
  253. case CampaignBonusType::HEROES_FROM_PREVIOUS_SCENARIO:
  254. {
  255. auto superhero = getCampaign()->strongestHero(static_cast<CampaignScenarioID>(bonDescs[i].info2), PlayerColor(bonDescs[i].info1));
  256. if(!superhero)
  257. logGlobal->warn("No superhero! How could it be transferred?");
  258. picNumber = superhero ? superhero->getIconIndex() : 0;
  259. desc.appendLocalString(EMetaText::GENERAL_TXT, 719);
  260. desc.replaceRawString(getCampaign()->scenario(static_cast<CampaignScenarioID>(bonDescs[i].info2)).scenarioName.toString());
  261. break;
  262. }
  263. case CampaignBonusType::HERO:
  264. if(bonDescs[i].info2 == 0xFFFF)
  265. {
  266. desc.appendLocalString(EMetaText::GENERAL_TXT, 720); // Start with random hero
  267. picNumber = -1;
  268. picName = "CBONN1A3.BMP";
  269. }
  270. else
  271. {
  272. desc.appendLocalString(EMetaText::GENERAL_TXT, 715); // Start with %s
  273. desc.replaceTextID(CGI->heroh->objects[bonDescs[i].info2]->getNameTextID());
  274. }
  275. break;
  276. }
  277. std::shared_ptr<CToggleButton> bonusButton = std::make_shared<CToggleButton>(Point(475 + i * 68, 455), AnimationPath::builtin("campaignBonusSelection"), CButton::tooltip(desc.toString(), desc.toString()), nullptr, EShortcut::NONE, false, [this](){
  278. if(buttonStart->isActive() && !buttonStart->isBlocked())
  279. CBonusSelection::startMap();
  280. });
  281. if(picNumber != -1)
  282. bonusButton->setOverlay(std::make_shared<CAnimImage>(AnimationPath::builtin(picName), picNumber));
  283. else
  284. bonusButton->setOverlay(std::make_shared<CPicture>(ImagePath::builtin(picName)));
  285. if(CSH->campaignBonus == i)
  286. bonusButton->setBorderColor(Colors::BRIGHT_YELLOW);
  287. groupBonuses->addToggle(i, bonusButton);
  288. }
  289. if(getCampaign()->getBonusID(CSH->campaignMap))
  290. groupBonuses->setSelected(*getCampaign()->getBonusID(CSH->campaignMap));
  291. }
  292. void CBonusSelection::updateAfterStateChange()
  293. {
  294. if(CSH->getState() != EClientState::GAMEPLAY)
  295. {
  296. buttonRestart->disable();
  297. buttonVideo->disable();
  298. buttonStart->enable();
  299. buttonBack->block(!getCampaign()->conqueredScenarios().empty());
  300. }
  301. else
  302. {
  303. buttonStart->disable();
  304. buttonRestart->enable();
  305. buttonVideo->enable();
  306. buttonBack->block(false);
  307. if(buttonDifficultyLeft)
  308. buttonDifficultyLeft->disable();
  309. if(buttonDifficultyRight)
  310. buttonDifficultyRight->disable();
  311. }
  312. if(CSH->campaignBonus == -1)
  313. {
  314. buttonStart->block(getCampaign()->scenario(CSH->campaignMap).travelOptions.bonusesToChoose.size());
  315. }
  316. else
  317. {
  318. buttonStart->block(false);
  319. }
  320. for(auto region : regions)
  321. region->updateState();
  322. if(!CSH->mi)
  323. return;
  324. iconsMapSizes->setFrame(CSH->mi->getMapSizeIconId());
  325. mapName->setText(CSH->mi->getNameTranslated());
  326. mapDescription->setText(CSH->mi->getDescriptionTranslated());
  327. for(size_t i = 0; i < difficultyIcons.size(); i++)
  328. {
  329. if(i == CSH->si->difficulty)
  330. difficultyIcons[i]->enable();
  331. else
  332. difficultyIcons[i]->disable();
  333. }
  334. flagbox->recreate();
  335. createBonusesIcons();
  336. }
  337. void CBonusSelection::goBack()
  338. {
  339. if(CSH->getState() != EClientState::GAMEPLAY)
  340. {
  341. GH.windows().popWindows(2);
  342. }
  343. else
  344. {
  345. close();
  346. }
  347. // TODO: we can actually only pop bonus selection interface for custom campaigns
  348. // Though this would require clearing CLobbyScreen::bonusSel pointer when poping this interface
  349. /*
  350. else
  351. {
  352. close();
  353. CSH->state = EClientState::LOBBY;
  354. }
  355. */
  356. }
  357. void CBonusSelection::startMap()
  358. {
  359. if (!CSH->validateGameStart())
  360. return;
  361. auto showPrologVideo = [=]()
  362. {
  363. auto exitCb = [=]()
  364. {
  365. logGlobal->info("Starting scenario %d", static_cast<int>(CSH->campaignMap));
  366. CSH->sendStartGame();
  367. };
  368. const CampaignScenario & scenario = getCampaign()->scenario(CSH->campaignMap);
  369. if(scenario.prolog.hasPrologEpilog)
  370. {
  371. GH.windows().createAndPushWindow<CPrologEpilogVideo>(scenario.prolog, exitCb);
  372. }
  373. else
  374. {
  375. exitCb();
  376. }
  377. };
  378. //block buttons immediately
  379. buttonStart->block(true);
  380. buttonRestart->block(true);
  381. buttonVideo->block(true);
  382. buttonBack->block(true);
  383. if(LOCPLINT) // we're currently ingame, so ask for starting new map and end game
  384. {
  385. close();
  386. LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[67], [=]()
  387. {
  388. showPrologVideo();
  389. }, 0);
  390. }
  391. else
  392. {
  393. showPrologVideo();
  394. }
  395. }
  396. void CBonusSelection::restartMap()
  397. {
  398. close();
  399. LOCPLINT->showYesNoDialog(
  400. CGI->generaltexth->allTexts[67],
  401. [=]()
  402. {
  403. GH.dispatchMainThread(
  404. []()
  405. {
  406. CSH->sendRestartGame();
  407. }
  408. );
  409. },
  410. 0
  411. );
  412. }
  413. void CBonusSelection::increaseDifficulty()
  414. {
  415. CSH->setDifficulty(CSH->si->difficulty + 1);
  416. }
  417. void CBonusSelection::decreaseDifficulty()
  418. {
  419. // avoid negative overflow (0 - 1 = 255)
  420. if (CSH->si->difficulty > 0)
  421. CSH->setDifficulty(CSH->si->difficulty - 1);
  422. }
  423. CBonusSelection::CRegion::CRegion(CampaignScenarioID id, bool accessible, bool selectable, const CampaignRegions & campDsc)
  424. : CIntObject(LCLICK | SHOW_POPUP), idOfMapAndRegion(id), accessible(accessible), selectable(selectable)
  425. {
  426. OBJECT_CONSTRUCTION;
  427. pos += campDsc.getPosition(id);
  428. auto color = CSH->si->campState->scenario(idOfMapAndRegion).regionColor;
  429. graphicsNotSelected = std::make_shared<CPicture>(campDsc.getAvailableName(id, color));
  430. graphicsNotSelected->disable();
  431. graphicsSelected = std::make_shared<CPicture>(campDsc.getSelectedName(id, color));
  432. graphicsSelected->disable();
  433. graphicsStriped = std::make_shared<CPicture>(campDsc.getConqueredName(id, color));
  434. graphicsStriped->disable();
  435. pos.w = graphicsNotSelected->pos.w;
  436. pos.h = graphicsNotSelected->pos.h;
  437. }
  438. void CBonusSelection::CRegion::updateState()
  439. {
  440. if(!accessible)
  441. {
  442. graphicsNotSelected->disable();
  443. graphicsSelected->disable();
  444. graphicsStriped->enable();
  445. }
  446. else if(CSH->campaignMap == idOfMapAndRegion)
  447. {
  448. graphicsNotSelected->disable();
  449. graphicsSelected->enable();
  450. graphicsStriped->disable();
  451. }
  452. else
  453. {
  454. graphicsNotSelected->enable();
  455. graphicsSelected->disable();
  456. graphicsStriped->disable();
  457. }
  458. }
  459. void CBonusSelection::CRegion::clickReleased(const Point & cursorPosition)
  460. {
  461. if(selectable && !graphicsNotSelected->getSurface()->isTransparent(cursorPosition - pos.topLeft()))
  462. {
  463. CSH->setCampaignMap(idOfMapAndRegion);
  464. }
  465. }
  466. void CBonusSelection::CRegion::showPopupWindow(const Point & cursorPosition)
  467. {
  468. // FIXME: For some reason "down" is only ever contain indeterminate_value
  469. auto & text = CSH->si->campState->scenario(idOfMapAndRegion).regionText;
  470. if(!graphicsNotSelected->getSurface()->isTransparent(cursorPosition - pos.topLeft()) && !text.empty())
  471. {
  472. CRClickPopup::createAndPush(text.toString());
  473. }
  474. }