AdventureMapShortcuts.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. /*
  2. * AdventureMapShortcuts.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 "AdventureMapShortcuts.h"
  12. #include "../CGameInfo.h"
  13. #include "../CMT.h"
  14. #include "../CPlayerInterface.h"
  15. #include "../CServerHandler.h"
  16. #include "../PlayerLocalState.h"
  17. #include "../gui/CGuiHandler.h"
  18. #include "../gui/Shortcut.h"
  19. #include "../gui/WindowHandler.h"
  20. #include "../lobby/CSavingScreen.h"
  21. #include "../mapView/mapHandler.h"
  22. #include "../windows/CKingdomInterface.h"
  23. #include "../windows/CSpellWindow.h"
  24. #include "../windows/CMarketWindow.h"
  25. #include "../windows/settings/SettingsMainWindow.h"
  26. #include "AdventureMapInterface.h"
  27. #include "AdventureOptions.h"
  28. #include "AdventureState.h"
  29. #include "../../CCallback.h"
  30. #include "../../lib/CConfigHandler.h"
  31. #include "../../lib/texts/CGeneralTextHandler.h"
  32. #include "../../lib/mapObjects/CGHeroInstance.h"
  33. #include "../../lib/mapObjects/CGTownInstance.h"
  34. #include "../../lib/mapping/CMap.h"
  35. #include "../../lib/pathfinder/CGPathNode.h"
  36. AdventureMapShortcuts::AdventureMapShortcuts(AdventureMapInterface & owner)
  37. : owner(owner)
  38. , state(EAdventureState::NOT_INITIALIZED)
  39. , mapLevel(0)
  40. {}
  41. void AdventureMapShortcuts::setState(EAdventureState newState)
  42. {
  43. state = newState;
  44. }
  45. EAdventureState AdventureMapShortcuts::getState() const
  46. {
  47. return state;
  48. }
  49. void AdventureMapShortcuts::onMapViewMoved(const Rect & visibleArea, int newMapLevel)
  50. {
  51. mapLevel = newMapLevel;
  52. }
  53. std::vector<AdventureMapShortcutState> AdventureMapShortcuts::getShortcuts()
  54. {
  55. std::vector<AdventureMapShortcutState> result = {
  56. { EShortcut::ADVENTURE_KINGDOM_OVERVIEW, optionInMapView(), [this]() { this->showOverview(); } },
  57. { EShortcut::ADVENTURE_EXIT_WORLD_VIEW, optionInWorldView(), [this]() { this->worldViewBack(); } },
  58. { EShortcut::ADVENTURE_VIEW_WORLD, optionInMapView(), [this]() { this->worldViewScale1x(); } },
  59. { EShortcut::ADVENTURE_VIEW_WORLD_X1, optionInWorldView(), [this]() { this->worldViewScale1x(); } },
  60. { EShortcut::ADVENTURE_VIEW_WORLD_X2, optionInWorldView(), [this]() { this->worldViewScale2x(); } },
  61. { EShortcut::ADVENTURE_VIEW_WORLD_X4, optionInWorldView(), [this]() { this->worldViewScale4x(); } },
  62. { EShortcut::ADVENTURE_TOGGLE_MAP_LEVEL, optionCanToggleLevel(), [this]() { this->switchMapLevel(); } },
  63. { EShortcut::ADVENTURE_QUEST_LOG, optionCanViewQuests(), [this]() { this->showQuestlog(); } },
  64. { EShortcut::ADVENTURE_TOGGLE_SLEEP, optionHeroSelected(), [this]() { this->toggleSleepWake(); } },
  65. { EShortcut::ADVENTURE_TOGGLE_GRID, optionInMapView(), [this]() { this->toggleGrid(); } },
  66. { EShortcut::ADVENTURE_TOGGLE_VISITABLE, optionInMapView(), [this]() { this->toggleVisitable(); } },
  67. { EShortcut::ADVENTURE_TOGGLE_BLOCKED, optionInMapView(), [this]() { this->toggleBlocked(); } },
  68. { EShortcut::ADVENTURE_TRACK_HERO, optionInMapView(), [this]() { this->toggleTrackHero(); } },
  69. { EShortcut::ADVENTURE_SET_HERO_ASLEEP, optionHeroAwake(), [this]() { this->setHeroSleeping(); } },
  70. { EShortcut::ADVENTURE_SET_HERO_AWAKE, optionHeroSleeping(), [this]() { this->setHeroAwake(); } },
  71. { EShortcut::ADVENTURE_MOVE_HERO, optionHeroCanMove(), [this]() { this->moveHeroAlongPath(); } },
  72. { EShortcut::ADVENTURE_CAST_SPELL, optionHeroSelected(), [this]() { this->showSpellbook(); } },
  73. { EShortcut::ADVENTURE_GAME_OPTIONS, optionInMapView(), [this]() { this->adventureOptions(); } },
  74. { EShortcut::GLOBAL_OPTIONS, optionInMapView(), [this]() { this->systemOptions(); } },
  75. { EShortcut::ADVENTURE_FIRST_HERO, optionInMapView(), [this]() { this->firstHero(); } },
  76. { EShortcut::ADVENTURE_NEXT_HERO, optionHasNextHero(), [this]() { this->nextHero(); } },
  77. { EShortcut::ADVENTURE_END_TURN, optionCanEndTurn(), [this]() { this->endTurn(); } },
  78. { EShortcut::ADVENTURE_THIEVES_GUILD, optionInMapView(), [this]() { this->showThievesGuild(); } },
  79. { EShortcut::ADVENTURE_VIEW_SCENARIO, optionInMapView(), [this]() { this->showScenarioInfo(); } },
  80. { EShortcut::ADVENTURE_QUIT_GAME, optionInMapView(), [this]() { this->quitGame(); } },
  81. { EShortcut::ADVENTURE_TO_MAIN_MENU, optionInMapView(), [this]() { this->toMainMenu(); } },
  82. { EShortcut::ADVENTURE_SAVE_GAME, optionInMapView(), [this]() { this->saveGame(); } },
  83. { EShortcut::ADVENTURE_NEW_GAME, optionInMapView(), [this]() { this->newGame(); } },
  84. { EShortcut::ADVENTURE_LOAD_GAME, optionInMapView(), [this]() { this->loadGame(); } },
  85. { EShortcut::ADVENTURE_RESTART_GAME, optionInMapView(), [this]() { this->restartGame(); } },
  86. { EShortcut::ADVENTURE_DIG_GRAIL, optionHeroSelected(), [this]() { this->digGrail(); } },
  87. { EShortcut::ADVENTURE_VIEW_PUZZLE, optionSidePanelActive(),[this]() { this->viewPuzzleMap(); } },
  88. { EShortcut::ADVENTURE_VISIT_OBJECT, optionCanVisitObject(), [this]() { this->visitObject(); } },
  89. { EShortcut::ADVENTURE_VIEW_SELECTED, optionInMapView(), [this]() { this->openObject(); } },
  90. { EShortcut::ADVENTURE_MARKETPLACE, optionInMapView(), [this]() { this->showMarketplace(); } },
  91. { EShortcut::ADVENTURE_ZOOM_IN, optionSidePanelActive(),[this]() { this->zoom(+10); } },
  92. { EShortcut::ADVENTURE_ZOOM_OUT, optionSidePanelActive(),[this]() { this->zoom(-10); } },
  93. { EShortcut::ADVENTURE_ZOOM_RESET, optionSidePanelActive(),[this]() { this->zoom( 0); } },
  94. { EShortcut::ADVENTURE_FIRST_TOWN, optionInMapView(), [this]() { this->firstTown(); } },
  95. { EShortcut::ADVENTURE_NEXT_TOWN, optionInMapView(), [this]() { this->nextTown(); } },
  96. { EShortcut::ADVENTURE_NEXT_OBJECT, optionInMapView(), [this]() { this->nextObject(); } },
  97. { EShortcut::ADVENTURE_MOVE_HERO_SW, optionHeroSelected(), [this]() { this->moveHeroDirectional({-1, +1}); } },
  98. { EShortcut::ADVENTURE_MOVE_HERO_SS, optionHeroSelected(), [this]() { this->moveHeroDirectional({ 0, +1}); } },
  99. { EShortcut::ADVENTURE_MOVE_HERO_SE, optionHeroSelected(), [this]() { this->moveHeroDirectional({+1, +1}); } },
  100. { EShortcut::ADVENTURE_MOVE_HERO_WW, optionHeroSelected(), [this]() { this->moveHeroDirectional({-1, 0}); } },
  101. { EShortcut::ADVENTURE_MOVE_HERO_EE, optionHeroSelected(), [this]() { this->moveHeroDirectional({+1, 0}); } },
  102. { EShortcut::ADVENTURE_MOVE_HERO_NW, optionHeroSelected(), [this]() { this->moveHeroDirectional({-1, -1}); } },
  103. { EShortcut::ADVENTURE_MOVE_HERO_NN, optionHeroSelected(), [this]() { this->moveHeroDirectional({ 0, -1}); } },
  104. { EShortcut::ADVENTURE_MOVE_HERO_NE, optionHeroSelected(), [this]() { this->moveHeroDirectional({+1, -1}); } }
  105. };
  106. return result;
  107. }
  108. void AdventureMapShortcuts::showOverview()
  109. {
  110. GH.windows().createAndPushWindow<CKingdomInterface>();
  111. }
  112. void AdventureMapShortcuts::worldViewBack()
  113. {
  114. owner.hotkeyExitWorldView();
  115. auto hero = LOCPLINT->localState->getCurrentHero();
  116. if (hero)
  117. owner.centerOnObject(hero);
  118. }
  119. void AdventureMapShortcuts::worldViewScale1x()
  120. {
  121. // TODO set corresponding scale button to "selected" mode
  122. owner.openWorldView(7);
  123. }
  124. void AdventureMapShortcuts::worldViewScale2x()
  125. {
  126. owner.openWorldView(11);
  127. }
  128. void AdventureMapShortcuts::worldViewScale4x()
  129. {
  130. owner.openWorldView(16);
  131. }
  132. void AdventureMapShortcuts::switchMapLevel()
  133. {
  134. int maxLevels = LOCPLINT->cb->getMapSize().z;
  135. if (maxLevels < 2)
  136. return;
  137. owner.hotkeySwitchMapLevel();
  138. }
  139. void AdventureMapShortcuts::showQuestlog()
  140. {
  141. LOCPLINT->showQuestLog();
  142. }
  143. void AdventureMapShortcuts::toggleTrackHero()
  144. {
  145. Settings s = settings.write["session"];
  146. s["adventureTrackHero"].Bool() = !settings["session"]["adventureTrackHero"].Bool();
  147. }
  148. void AdventureMapShortcuts::toggleGrid()
  149. {
  150. Settings s = settings.write["gameTweaks"];
  151. s["showGrid"].Bool() = !settings["gameTweaks"]["showGrid"].Bool();
  152. }
  153. void AdventureMapShortcuts::toggleVisitable()
  154. {
  155. Settings s = settings.write["session"];
  156. s["showVisitable"].Bool() = !settings["session"]["showVisitable"].Bool();
  157. }
  158. void AdventureMapShortcuts::toggleBlocked()
  159. {
  160. Settings s = settings.write["session"];
  161. s["showBlocked"].Bool() = !settings["session"]["showBlocked"].Bool();
  162. }
  163. void AdventureMapShortcuts::toggleSleepWake()
  164. {
  165. if (!optionHeroSelected())
  166. return;
  167. if (optionHeroAwake())
  168. setHeroSleeping();
  169. else
  170. setHeroAwake();
  171. }
  172. void AdventureMapShortcuts::setHeroSleeping()
  173. {
  174. const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
  175. if (h)
  176. {
  177. LOCPLINT->localState->setHeroAsleep(h);
  178. owner.onHeroChanged(h);
  179. nextHero();
  180. }
  181. }
  182. void AdventureMapShortcuts::setHeroAwake()
  183. {
  184. const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
  185. if (h)
  186. {
  187. LOCPLINT->localState->setHeroAwaken(h);
  188. owner.onHeroChanged(h);
  189. }
  190. }
  191. void AdventureMapShortcuts::moveHeroAlongPath()
  192. {
  193. const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
  194. if (!h || !LOCPLINT->localState->hasPath(h))
  195. return;
  196. LOCPLINT->moveHero(h, LOCPLINT->localState->getPath(h));
  197. }
  198. void AdventureMapShortcuts::showSpellbook()
  199. {
  200. if (!LOCPLINT->localState->getCurrentHero())
  201. return;
  202. owner.centerOnObject(LOCPLINT->localState->getCurrentHero());
  203. GH.windows().createAndPushWindow<CSpellWindow>(LOCPLINT->localState->getCurrentHero(), LOCPLINT, false);
  204. }
  205. void AdventureMapShortcuts::adventureOptions()
  206. {
  207. GH.windows().createAndPushWindow<AdventureOptions>();
  208. }
  209. void AdventureMapShortcuts::systemOptions()
  210. {
  211. GH.windows().createAndPushWindow<SettingsMainWindow>();
  212. }
  213. void AdventureMapShortcuts::firstHero()
  214. {
  215. if (!LOCPLINT->localState->getWanderingHeroes().empty())
  216. {
  217. const auto * hero = LOCPLINT->localState->getWanderingHero(0);
  218. LOCPLINT->localState->setSelection(hero);
  219. owner.centerOnObject(hero);
  220. }
  221. }
  222. void AdventureMapShortcuts::nextHero()
  223. {
  224. const auto * currHero = LOCPLINT->localState->getCurrentHero();
  225. const auto * nextHero = LOCPLINT->localState->getNextWanderingHero(currHero);
  226. if (nextHero)
  227. {
  228. LOCPLINT->localState->setSelection(nextHero);
  229. owner.centerOnObject(nextHero);
  230. }
  231. }
  232. void AdventureMapShortcuts::endTurn()
  233. {
  234. if(!LOCPLINT->makingTurn)
  235. return;
  236. if(settings["adventure"]["heroReminder"].Bool())
  237. {
  238. for(auto hero : LOCPLINT->localState->getWanderingHeroes())
  239. {
  240. if(!LOCPLINT->localState->isHeroSleeping(hero) && hero->movementPointsRemaining() > 0)
  241. {
  242. // Only show hero reminder if conditions met:
  243. // - There still movement points
  244. // - Hero don't have a path or there not points for first step on path
  245. LOCPLINT->localState->verifyPath(hero);
  246. if(!LOCPLINT->localState->hasPath(hero))
  247. {
  248. LOCPLINT->showYesNoDialog( CGI->generaltexth->allTexts[55], [this](){ owner.hotkeyEndingTurn(); }, nullptr);
  249. return;
  250. }
  251. auto path = LOCPLINT->localState->getPath(hero);
  252. if (path.nodes.size() < 2 || path.nodes[path.nodes.size() - 2].turns)
  253. {
  254. LOCPLINT->showYesNoDialog( CGI->generaltexth->allTexts[55], [this](){ owner.hotkeyEndingTurn(); }, nullptr);
  255. return;
  256. }
  257. }
  258. }
  259. }
  260. owner.hotkeyEndingTurn();
  261. }
  262. void AdventureMapShortcuts::showThievesGuild()
  263. {
  264. //find first town with tavern
  265. auto itr = range::find_if(LOCPLINT->localState->getOwnedTowns(), [](const CGTownInstance * town)
  266. {
  267. return town->hasBuilt(BuildingID::TAVERN);
  268. });
  269. if(itr != LOCPLINT->localState->getOwnedTowns().end())
  270. LOCPLINT->showThievesGuildWindow(*itr);
  271. else
  272. LOCPLINT->showInfoDialog(CGI->generaltexth->translate("vcmi.adventureMap.noTownWithTavern"));
  273. }
  274. void AdventureMapShortcuts::showScenarioInfo()
  275. {
  276. AdventureOptions::showScenarioInfo();
  277. }
  278. void AdventureMapShortcuts::toMainMenu()
  279. {
  280. LOCPLINT->showYesNoDialog(
  281. CGI->generaltexth->allTexts[578],
  282. []()
  283. {
  284. CSH->endGameplay();
  285. CMM->menu->switchToTab("main");
  286. },
  287. 0
  288. );
  289. }
  290. void AdventureMapShortcuts::newGame()
  291. {
  292. LOCPLINT->showYesNoDialog(
  293. CGI->generaltexth->allTexts[578],
  294. []()
  295. {
  296. CSH->endGameplay();
  297. CMM->menu->switchToTab("new");
  298. },
  299. nullptr
  300. );
  301. }
  302. void AdventureMapShortcuts::quitGame()
  303. {
  304. LOCPLINT->showYesNoDialog(
  305. CGI->generaltexth->allTexts[578],
  306. []()
  307. {
  308. GH.dispatchMainThread( []()
  309. {
  310. handleQuit(false);
  311. });
  312. },
  313. 0
  314. );
  315. }
  316. void AdventureMapShortcuts::saveGame()
  317. {
  318. GH.windows().createAndPushWindow<CSavingScreen>();
  319. }
  320. void AdventureMapShortcuts::loadGame()
  321. {
  322. LOCPLINT->proposeLoadingGame();
  323. }
  324. void AdventureMapShortcuts::digGrail()
  325. {
  326. const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
  327. if(h && LOCPLINT->makingTurn)
  328. LOCPLINT->tryDigging(h);
  329. }
  330. void AdventureMapShortcuts::viewPuzzleMap()
  331. {
  332. LOCPLINT->showPuzzleMap();
  333. }
  334. void AdventureMapShortcuts::restartGame()
  335. {
  336. LOCPLINT->showYesNoDialog(
  337. CGI->generaltexth->translate("vcmi.adventureMap.confirmRestartGame"),
  338. []()
  339. {
  340. GH.dispatchMainThread(
  341. []()
  342. {
  343. CSH->sendRestartGame();
  344. }
  345. );
  346. },
  347. nullptr
  348. );
  349. }
  350. void AdventureMapShortcuts::visitObject()
  351. {
  352. const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
  353. if(h)
  354. LOCPLINT->cb->moveHero(h, h->pos, false);
  355. }
  356. void AdventureMapShortcuts::openObject()
  357. {
  358. const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
  359. const CGTownInstance *t = LOCPLINT->localState->getCurrentTown();
  360. if(h)
  361. LOCPLINT->openHeroWindow(h);
  362. if(t)
  363. LOCPLINT->openTownWindow(t);
  364. }
  365. void AdventureMapShortcuts::showMarketplace()
  366. {
  367. //check if we have any marketplace
  368. const CGTownInstance *townWithMarket = nullptr;
  369. for(const CGTownInstance *t : LOCPLINT->cb->getTownsInfo())
  370. {
  371. if(t->hasBuilt(BuildingID::MARKETPLACE))
  372. {
  373. townWithMarket = t;
  374. break;
  375. }
  376. }
  377. if(townWithMarket) //if any town has marketplace, open window
  378. GH.windows().createAndPushWindow<CMarketWindow>(townWithMarket, nullptr, nullptr, EMarketMode::RESOURCE_RESOURCE);
  379. else //if not - complain
  380. LOCPLINT->showInfoDialog(CGI->generaltexth->translate("vcmi.adventureMap.noTownWithMarket"));
  381. }
  382. void AdventureMapShortcuts::firstTown()
  383. {
  384. if (!LOCPLINT->localState->getOwnedTowns().empty())
  385. {
  386. const auto * town = LOCPLINT->localState->getOwnedTown(0);
  387. LOCPLINT->localState->setSelection(town);
  388. owner.centerOnObject(town);
  389. }
  390. }
  391. void AdventureMapShortcuts::nextTown()
  392. {
  393. owner.hotkeyNextTown();
  394. }
  395. void AdventureMapShortcuts::zoom( int distance)
  396. {
  397. owner.hotkeyZoom(distance, false);
  398. }
  399. void AdventureMapShortcuts::nextObject()
  400. {
  401. const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero();
  402. const CGTownInstance *t = LOCPLINT->localState->getCurrentTown();
  403. if(h)
  404. nextHero();
  405. if(t)
  406. nextTown();
  407. }
  408. void AdventureMapShortcuts::moveHeroDirectional(const Point & direction)
  409. {
  410. const CGHeroInstance *h = LOCPLINT->localState->getCurrentHero(); //selected hero
  411. if(!h)
  412. return;
  413. if (CGI->mh->hasOngoingAnimations())
  414. return;
  415. int3 dst = h->visitablePos() + int3(direction.x, direction.y, 0);
  416. if (!CGI->mh->isInMap((dst)))
  417. return;
  418. if ( !LOCPLINT->localState->setPath(h, dst))
  419. return;
  420. const CGPath & path = LOCPLINT->localState->getPath(h);
  421. if (path.nodes.size() > 2)
  422. owner.onHeroChanged(h);
  423. else
  424. if(path.nodes[0].turns == 0)
  425. LOCPLINT->moveHero(h, path);
  426. }
  427. bool AdventureMapShortcuts::optionCanViewQuests()
  428. {
  429. return optionInMapView() && !CGI->mh->getMap()->quests.empty();
  430. }
  431. bool AdventureMapShortcuts::optionCanToggleLevel()
  432. {
  433. return optionSidePanelActive() && LOCPLINT->cb->getMapSize().z > 1;
  434. }
  435. bool AdventureMapShortcuts::optionMapLevelSurface()
  436. {
  437. return mapLevel == 0;
  438. }
  439. bool AdventureMapShortcuts::optionHeroSleeping()
  440. {
  441. const CGHeroInstance *hero = LOCPLINT->localState->getCurrentHero();
  442. return optionInMapView() && hero && LOCPLINT->localState->isHeroSleeping(hero);
  443. }
  444. bool AdventureMapShortcuts::optionHeroAwake()
  445. {
  446. const CGHeroInstance *hero = LOCPLINT->localState->getCurrentHero();
  447. return optionInMapView() && hero && !LOCPLINT->localState->isHeroSleeping(hero);
  448. }
  449. bool AdventureMapShortcuts::optionCanVisitObject()
  450. {
  451. if (!optionHeroSelected())
  452. return false;
  453. auto * hero = LOCPLINT->localState->getCurrentHero();
  454. auto objects = LOCPLINT->cb->getVisitableObjs(hero->visitablePos());
  455. return objects.size() > 1; // there is object other than our hero
  456. }
  457. bool AdventureMapShortcuts::optionHeroSelected()
  458. {
  459. return optionInMapView() && LOCPLINT->localState->getCurrentHero() != nullptr;
  460. }
  461. bool AdventureMapShortcuts::optionHeroCanMove()
  462. {
  463. const auto * hero = LOCPLINT->localState->getCurrentHero();
  464. return optionInMapView() && hero && LOCPLINT->localState->hasPath(hero) && LOCPLINT->localState->getPath(hero).nextNode().turns == 0;
  465. }
  466. bool AdventureMapShortcuts::optionHasNextHero()
  467. {
  468. const auto * hero = LOCPLINT->localState->getCurrentHero();
  469. const auto * nextSuitableHero = LOCPLINT->localState->getNextWanderingHero(hero);
  470. return optionInMapView() && nextSuitableHero != nullptr;
  471. }
  472. bool AdventureMapShortcuts::optionCanEndTurn()
  473. {
  474. return optionInMapView() && LOCPLINT->makingTurn;
  475. }
  476. bool AdventureMapShortcuts::optionSpellcasting()
  477. {
  478. return state == EAdventureState::CASTING_SPELL;
  479. }
  480. bool AdventureMapShortcuts::optionInMapView()
  481. {
  482. return state == EAdventureState::MAKING_TURN;
  483. }
  484. bool AdventureMapShortcuts::optionInWorldView()
  485. {
  486. return state == EAdventureState::WORLD_VIEW;
  487. }
  488. bool AdventureMapShortcuts::optionSidePanelActive()
  489. {
  490. return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW;
  491. }
  492. bool AdventureMapShortcuts::optionMapScrollingActive()
  493. {
  494. return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW;
  495. }
  496. bool AdventureMapShortcuts::optionMapViewActive()
  497. {
  498. return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW || state == EAdventureState::CASTING_SPELL;
  499. }