MapViewController.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. /*
  2. * MapViewController.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 "MapViewController.h"
  12. #include "MapRendererContext.h"
  13. #include "MapRendererContextState.h"
  14. #include "MapViewCache.h"
  15. #include "MapViewModel.h"
  16. #include "../CCallback.h"
  17. #include "../CPlayerInterface.h"
  18. #include "../adventureMap/AdventureMapInterface.h"
  19. #include "../gui/CGuiHandler.h"
  20. #include "../gui/WindowHandler.h"
  21. #include "../eventsSDL/InputHandler.h"
  22. #include "../../lib/CConfigHandler.h"
  23. #include "../../lib/StartInfo.h"
  24. #include "../../lib/UnlockGuard.h"
  25. #include "../../lib/mapObjects/CGHeroInstance.h"
  26. #include "../../lib/mapObjects/MiscObjects.h"
  27. #include "../../lib/pathfinder/CGPathNode.h"
  28. #include "../../lib/spells/ViewSpellInt.h"
  29. void MapViewController::setViewCenter(const int3 & position)
  30. {
  31. setViewCenter(Point(position) * model->getSingleTileSize() + model->getSingleTileSize() / 2, position.z);
  32. }
  33. void MapViewController::setViewCenter(const Point & position, int level)
  34. {
  35. Point upperLimit = Point(context->getMapSize()) * model->getSingleTileSize();
  36. Point lowerLimit = Point(0, 0);
  37. if(worldViewContext)
  38. {
  39. Point area = model->getPixelsVisibleDimensions();
  40. Point mapCenter = upperLimit / 2;
  41. Point desiredLowerLimit = lowerLimit + area / 2;
  42. Point desiredUpperLimit = upperLimit - area / 2;
  43. Point actualLowerLimit{
  44. std::min(desiredLowerLimit.x, mapCenter.x),
  45. std::min(desiredLowerLimit.y, mapCenter.y)
  46. };
  47. Point actualUpperLimit{
  48. std::max(desiredUpperLimit.x, mapCenter.x),
  49. std::max(desiredUpperLimit.y, mapCenter.y)
  50. };
  51. upperLimit = actualUpperLimit;
  52. lowerLimit = actualLowerLimit;
  53. }
  54. Point betterPosition = {std::clamp(position.x, lowerLimit.x, upperLimit.x), std::clamp(position.y, lowerLimit.y, upperLimit.y)};
  55. model->setViewCenter(betterPosition);
  56. model->setLevel(std::clamp(level, 0, context->getMapSize().z));
  57. if(adventureInt && !puzzleMapContext) // may be called before adventureInt is initialized
  58. adventureInt->onMapViewMoved(model->getTilesTotalRect(), model->getLevel());
  59. }
  60. void MapViewController::setTileSize(const Point & tileSize)
  61. {
  62. Point oldSize = model->getSingleTileSize();
  63. model->setTileSize(tileSize);
  64. double scaleChangeX = 1.0 * tileSize.x / oldSize.x;
  65. double scaleChangeY = 1.0 * tileSize.y / oldSize.y;
  66. Point newViewCenter {
  67. static_cast<int>(std::round(model->getMapViewCenter().x * scaleChangeX)),
  68. static_cast<int>(std::round(model->getMapViewCenter().y * scaleChangeY))
  69. };
  70. // force update of view center since changing tile size may invalidated it
  71. setViewCenter(newViewCenter, model->getLevel());
  72. }
  73. void MapViewController::modifyTileSize(int stepsChange)
  74. {
  75. // we want to zoom in/out in fixed 10% steps, to allow player to return back to exactly 100% zoom just by scrolling
  76. // so, zooming in for 5 steps will put game at 1.1^5 = 1.61 scale
  77. // try to determine current zooming level and change it by requested number of steps
  78. double currentZoomFactor = targetTileSize.x / static_cast<double>(defaultTileSize);
  79. double currentZoomSteps = std::round(std::log(currentZoomFactor) / std::log(1.01));
  80. double newZoomSteps = stepsChange != 0 ? currentZoomSteps + stepsChange : stepsChange;
  81. double newZoomFactor = std::pow(1.01, newZoomSteps);
  82. Point currentZoom = targetTileSize;
  83. Point desiredZoom = Point(defaultTileSize,defaultTileSize) * newZoomFactor;
  84. if (desiredZoom == currentZoom && stepsChange < 0)
  85. desiredZoom -= Point(1,1);
  86. if (desiredZoom == currentZoom && stepsChange > 0)
  87. desiredZoom += Point(1,1);
  88. Point minimal = model->getSingleTileSizeLowerLimit();
  89. Point maximal = model->getSingleTileSizeUpperLimit();
  90. Point actualZoom = {
  91. std::clamp(desiredZoom.x, minimal.x, maximal.x),
  92. std::clamp(desiredZoom.y, minimal.y, maximal.y)
  93. };
  94. if (actualZoom != currentZoom)
  95. {
  96. targetTileSize = actualZoom;
  97. if(actualZoom.x >= defaultTileSize - zoomTileDeadArea && actualZoom.x <= defaultTileSize + zoomTileDeadArea)
  98. actualZoom.x = defaultTileSize;
  99. if(actualZoom.y >= defaultTileSize - zoomTileDeadArea && actualZoom.y <= defaultTileSize + zoomTileDeadArea)
  100. actualZoom.y = defaultTileSize;
  101. bool isInDeadZone = targetTileSize != actualZoom || actualZoom == Point(defaultTileSize, defaultTileSize);
  102. if(!wasInDeadZone && isInDeadZone)
  103. GH.input().hapticFeedback();
  104. wasInDeadZone = isInDeadZone;
  105. setTileSize(actualZoom);
  106. }
  107. }
  108. MapViewController::MapViewController(std::shared_ptr<MapViewModel> model, std::shared_ptr<MapViewCache> view)
  109. : state(new MapRendererContextState())
  110. , model(std::move(model))
  111. , view(view)
  112. {
  113. adventureContext = std::make_shared<MapRendererAdventureContext>(*state);
  114. context = adventureContext;
  115. }
  116. std::shared_ptr<IMapRendererContext> MapViewController::getContext() const
  117. {
  118. return context;
  119. }
  120. void MapViewController::tick(uint32_t timeDelta)
  121. {
  122. // confirmed to match H3 for
  123. // - hero embarking on boat (500 ms)
  124. // - hero disembarking from boat (500 ms)
  125. // - TODO: picking up resources
  126. // - TODO: killing mosters
  127. // - teleporting ( 250 ms)
  128. static const double fadeOutDuration = 500;
  129. static const double fadeInDuration = 500;
  130. static const double heroTeleportDuration = 250;
  131. if(movementContext)
  132. {
  133. const auto * object = context->getObject(movementContext->target);
  134. const auto * hero = dynamic_cast<const CGHeroInstance *>(object);
  135. const auto * boat = dynamic_cast<const CGBoat *>(object);
  136. assert(boat || hero);
  137. if(!hero)
  138. hero = boat->hero;
  139. double heroMoveTime = LOCPLINT->playerID == hero->getOwner() ?
  140. settings["adventure"]["heroMoveTime"].Float() :
  141. settings["adventure"]["enemyMoveTime"].Float();
  142. movementContext->progress += timeDelta / heroMoveTime;
  143. movementContext->progress = std::min( 1.0, movementContext->progress);
  144. Point positionFrom = Point(hero->convertToVisitablePos(movementContext->tileFrom)) * model->getSingleTileSize() + model->getSingleTileSize() / 2;
  145. Point positionDest = Point(hero->convertToVisitablePos(movementContext->tileDest)) * model->getSingleTileSize() + model->getSingleTileSize() / 2;
  146. Point positionCurr = vstd::lerp(positionFrom, positionDest, movementContext->progress);
  147. setViewCenter(positionCurr, movementContext->tileDest.z);
  148. }
  149. if(teleportContext)
  150. {
  151. teleportContext->progress += timeDelta / heroTeleportDuration;
  152. teleportContext->progress = std::min( 1.0, teleportContext->progress);
  153. }
  154. if(fadingOutContext)
  155. {
  156. fadingOutContext->progress -= timeDelta / fadeOutDuration;
  157. fadingOutContext->progress = std::max( 0.0, fadingOutContext->progress);
  158. }
  159. if(fadingInContext)
  160. {
  161. fadingInContext->progress += timeDelta / fadeInDuration;
  162. fadingInContext->progress = std::min( 1.0, fadingInContext->progress);
  163. }
  164. if (adventureContext)
  165. adventureContext->animationTime += timeDelta;
  166. updateState();
  167. }
  168. void MapViewController::updateState()
  169. {
  170. if(adventureContext)
  171. {
  172. adventureContext->settingsSessionSpectate = settings["session"]["spectate"].Bool();
  173. adventureContext->settingsAdventureObjectAnimation = settings["adventure"]["objectAnimation"].Bool();
  174. adventureContext->settingsAdventureTerrainAnimation = settings["adventure"]["terrainAnimation"].Bool();
  175. adventureContext->settingShowGrid = settings["gameTweaks"]["showGrid"].Bool();
  176. adventureContext->settingShowVisitable = settings["session"]["showVisitable"].Bool();
  177. adventureContext->settingShowBlocked = settings["session"]["showBlocked"].Bool();
  178. adventureContext->settingSpellRange = settings["session"]["showSpellRange"].Bool();
  179. }
  180. }
  181. void MapViewController::afterRender()
  182. {
  183. if(movementContext)
  184. {
  185. const auto * object = context->getObject(movementContext->target);
  186. const auto * hero = dynamic_cast<const CGHeroInstance *>(object);
  187. const auto * boat = dynamic_cast<const CGBoat *>(object);
  188. assert(boat || hero);
  189. if(!hero)
  190. hero = boat->hero;
  191. if(movementContext->progress >= 0.999)
  192. {
  193. logGlobal->debug("Ending movement animation");
  194. setViewCenter(hero->getSightCenter());
  195. removeObject(context->getObject(movementContext->target));
  196. addObject(context->getObject(movementContext->target));
  197. activateAdventureContext(movementContext->animationTime);
  198. }
  199. }
  200. if(teleportContext && teleportContext->progress >= 0.999)
  201. {
  202. logGlobal->debug("Ending teleport animation");
  203. activateAdventureContext(teleportContext->animationTime);
  204. }
  205. if(fadingOutContext && fadingOutContext->progress <= 0.001)
  206. {
  207. logGlobal->debug("Ending fade out animation");
  208. removeObject(context->getObject(fadingOutContext->target));
  209. activateAdventureContext(fadingOutContext->animationTime);
  210. }
  211. if(fadingInContext && fadingInContext->progress >= 0.999)
  212. {
  213. logGlobal->debug("Ending fade in animation");
  214. activateAdventureContext(fadingInContext->animationTime);
  215. }
  216. }
  217. bool MapViewController::isEventInstant(const CGObjectInstance * obj, const PlayerColor & initiator)
  218. {
  219. if(settings["gameTweaks"]["skipAdventureMapAnimations"].Bool())
  220. return true;
  221. if (!isEventVisible(obj, initiator))
  222. return true;
  223. if (!initiator.isValidPlayer())
  224. return true; // skip effects such as new monsters on new month
  225. if(initiator != LOCPLINT->playerID && settings["adventure"]["enemyMoveTime"].Float() <= 0)
  226. return true; // instant movement speed
  227. if(initiator == LOCPLINT->playerID && settings["adventure"]["heroMoveTime"].Float() <= 0)
  228. return true; // instant movement speed
  229. return false;
  230. }
  231. bool MapViewController::isEventVisible(const CGObjectInstance * obj, const PlayerColor & initiator)
  232. {
  233. if(adventureContext == nullptr)
  234. return false;
  235. if(initiator != LOCPLINT->playerID && settings["adventure"]["enemyMoveTime"].Float() < 0)
  236. return false; // enemy move speed set to "hidden/none"
  237. if(!GH.windows().isTopWindow(adventureInt))
  238. return false;
  239. // do not focus on actions of other players except for AI with simturns off
  240. if (initiator != LOCPLINT->playerID && initiator.isValidPlayer())
  241. {
  242. if (LOCPLINT->makingTurn)
  243. return false;
  244. if (LOCPLINT->cb->getStartInfo()->playerInfos.at(initiator).isControlledByHuman() && !settings["session"]["adventureTrackHero"].Bool())
  245. return false;
  246. }
  247. if(obj->isVisitable())
  248. return context->isVisible(obj->visitablePos());
  249. else
  250. return context->isVisible(obj->pos);
  251. }
  252. bool MapViewController::isEventVisible(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  253. {
  254. if(adventureContext == nullptr)
  255. return false;
  256. if(obj->getOwner() != LOCPLINT->playerID && settings["adventure"]["enemyMoveTime"].Float() < 0)
  257. return false; // enemy move speed set to "hidden/none"
  258. if(!GH.windows().isTopWindow(adventureInt))
  259. return false;
  260. // do not focus on actions of other players except for AI with simturns off
  261. if (obj->getOwner() != LOCPLINT->playerID)
  262. {
  263. if (LOCPLINT->makingTurn)
  264. return false;
  265. if (LOCPLINT->cb->getStartInfo()->playerInfos.at(obj->getOwner()).isControlledByHuman() && !settings["session"]["adventureTrackHero"].Bool())
  266. return false;
  267. }
  268. if(context->isVisible(obj->convertToVisitablePos(from)))
  269. return true;
  270. if(context->isVisible(obj->convertToVisitablePos(dest)))
  271. return true;
  272. return false;
  273. }
  274. void MapViewController::fadeOutObject(const CGObjectInstance * obj)
  275. {
  276. animationWait.setBusy();
  277. logGlobal->debug("Starting fade out animation");
  278. fadingOutContext = std::make_shared<MapRendererAdventureFadingContext>(*state);
  279. fadingOutContext->animationTime = adventureContext->animationTime;
  280. adventureContext = fadingOutContext;
  281. context = fadingOutContext;
  282. const CGObjectInstance * movingObject = obj;
  283. if (obj->ID == Obj::HERO)
  284. {
  285. auto * hero = dynamic_cast<const CGHeroInstance*>(obj);
  286. if (hero->boat)
  287. movingObject = hero->boat;
  288. }
  289. fadingOutContext->target = movingObject->id;
  290. fadingOutContext->progress = 1.0;
  291. }
  292. void MapViewController::fadeInObject(const CGObjectInstance * obj)
  293. {
  294. animationWait.setBusy();
  295. logGlobal->debug("Starting fade in animation");
  296. fadingInContext = std::make_shared<MapRendererAdventureFadingContext>(*state);
  297. fadingInContext->animationTime = adventureContext->animationTime;
  298. adventureContext = fadingInContext;
  299. context = fadingInContext;
  300. const CGObjectInstance * movingObject = obj;
  301. if (obj->ID == Obj::HERO)
  302. {
  303. auto * hero = dynamic_cast<const CGHeroInstance*>(obj);
  304. if (hero->boat)
  305. movingObject = hero->boat;
  306. }
  307. fadingInContext->target = movingObject->id;
  308. fadingInContext->progress = 0.0;
  309. }
  310. void MapViewController::removeObject(const CGObjectInstance * obj)
  311. {
  312. if (obj->ID == Obj::BOAT)
  313. {
  314. auto * boat = dynamic_cast<const CGBoat*>(obj);
  315. if (boat->hero)
  316. {
  317. view->invalidate(context, boat->hero->id);
  318. state->removeObject(boat->hero);
  319. }
  320. }
  321. if (obj->ID == Obj::HERO)
  322. {
  323. auto * hero = dynamic_cast<const CGHeroInstance*>(obj);
  324. if (hero->boat)
  325. {
  326. view->invalidate(context, hero->boat->id);
  327. state->removeObject(hero->boat);
  328. }
  329. }
  330. view->invalidate(context, obj->id);
  331. state->removeObject(obj);
  332. }
  333. void MapViewController::addObject(const CGObjectInstance * obj)
  334. {
  335. state->addObject(obj);
  336. view->invalidate(context, obj->id);
  337. }
  338. void MapViewController::onBeforeHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  339. {
  340. if(isEventVisible(obj, from, dest))
  341. {
  342. if (!isEventInstant(obj, obj->getOwner()))
  343. fadeOutObject(obj);
  344. setViewCenter(obj->getSightCenter());
  345. }
  346. else
  347. removeObject(obj);
  348. }
  349. void MapViewController::onAfterHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  350. {
  351. if(isEventVisible(obj, from, dest))
  352. setViewCenter(obj->getSightCenter());
  353. }
  354. void MapViewController::onBeforeHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  355. {
  356. if(isEventVisible(obj, from, dest))
  357. setViewCenter(obj->getSightCenter());
  358. }
  359. void MapViewController::onAfterHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  360. {
  361. if(isEventVisible(obj, from, dest))
  362. {
  363. if (!isEventInstant(obj, obj->getOwner()))
  364. fadeInObject(obj);
  365. setViewCenter(obj->getSightCenter());
  366. }
  367. addObject(obj);
  368. }
  369. void MapViewController::onObjectFadeIn(const CGObjectInstance * obj, const PlayerColor & initiator)
  370. {
  371. assert(!hasOngoingAnimations());
  372. if(isEventVisible(obj, initiator) && !isEventInstant(obj, initiator) )
  373. fadeInObject(obj);
  374. addObject(obj);
  375. }
  376. void MapViewController::onObjectFadeOut(const CGObjectInstance * obj, const PlayerColor & initiator)
  377. {
  378. assert(!hasOngoingAnimations());
  379. if(isEventVisible(obj, initiator) && !isEventInstant(obj, initiator) )
  380. fadeOutObject(obj);
  381. else
  382. removeObject(obj);
  383. }
  384. void MapViewController::onObjectInstantAdd(const CGObjectInstance * obj, const PlayerColor & initiator)
  385. {
  386. addObject(obj);
  387. };
  388. void MapViewController::onObjectInstantRemove(const CGObjectInstance * obj, const PlayerColor & initiator)
  389. {
  390. removeObject(obj);
  391. };
  392. void MapViewController::onBeforeHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  393. {
  394. assert(!hasOngoingAnimations());
  395. if(isEventVisible(obj, from, dest))
  396. {
  397. setViewCenter(obj->getSightCenter());
  398. view->createTransitionSnapshot(context);
  399. }
  400. }
  401. void MapViewController::onAfterHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  402. {
  403. assert(!hasOngoingAnimations());
  404. const CGObjectInstance * movingObject = obj;
  405. if(obj->boat)
  406. movingObject = obj->boat;
  407. removeObject(movingObject);
  408. addObject(movingObject);
  409. if(isEventVisible(obj, from, dest))
  410. {
  411. animationWait.setBusy();
  412. logGlobal->debug("Starting teleport animation");
  413. teleportContext = std::make_shared<MapRendererAdventureTransitionContext>(*state);
  414. teleportContext->animationTime = adventureContext->animationTime;
  415. adventureContext = teleportContext;
  416. context = teleportContext;
  417. setViewCenter(movingObject->getSightCenter());
  418. }
  419. }
  420. void MapViewController::onHeroMoved(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  421. {
  422. assert(!hasOngoingAnimations());
  423. // revisiting via spacebar, no need to animate
  424. if(from == dest)
  425. return;
  426. const CGObjectInstance * movingObject = obj;
  427. if(obj->boat)
  428. movingObject = obj->boat;
  429. removeObject(movingObject);
  430. if(!isEventVisible(obj, from, dest))
  431. {
  432. addObject(movingObject);
  433. return;
  434. }
  435. double movementTime = LOCPLINT->playerID == obj->tempOwner ?
  436. settings["adventure"]["heroMoveTime"].Float() :
  437. settings["adventure"]["enemyMoveTime"].Float();
  438. if(movementTime > 1)
  439. {
  440. animationWait.setBusy();
  441. logGlobal->debug("Starting movement animation");
  442. movementContext = std::make_shared<MapRendererAdventureMovingContext>(*state);
  443. movementContext->animationTime = adventureContext->animationTime;
  444. adventureContext = movementContext;
  445. context = movementContext;
  446. state->addMovingObject(movingObject, from, dest);
  447. movementContext->target = movingObject->id;
  448. movementContext->tileFrom = from;
  449. movementContext->tileDest = dest;
  450. movementContext->progress = 0.0;
  451. }
  452. else // instant movement
  453. {
  454. addObject(movingObject);
  455. setViewCenter(movingObject->visitablePos());
  456. }
  457. }
  458. bool MapViewController::hasOngoingAnimations()
  459. {
  460. if(movementContext)
  461. return true;
  462. if(fadingOutContext)
  463. return true;
  464. if(fadingInContext)
  465. return true;
  466. if(teleportContext)
  467. return true;
  468. return false;
  469. }
  470. void MapViewController::waitForOngoingAnimations()
  471. {
  472. auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex);
  473. animationWait.waitWhileBusy();
  474. }
  475. void MapViewController::endNetwork()
  476. {
  477. animationWait.requestTermination();
  478. }
  479. void MapViewController::activateAdventureContext(uint32_t animationTime)
  480. {
  481. resetContext();
  482. adventureContext = std::make_shared<MapRendererAdventureContext>(*state);
  483. adventureContext->animationTime = animationTime;
  484. context = adventureContext;
  485. updateState();
  486. }
  487. void MapViewController::activateAdventureContext()
  488. {
  489. activateAdventureContext(0);
  490. }
  491. void MapViewController::activateWorldViewContext()
  492. {
  493. if(worldViewContext)
  494. return;
  495. resetContext();
  496. worldViewContext = std::make_shared<MapRendererWorldViewContext>(*state);
  497. context = worldViewContext;
  498. }
  499. void MapViewController::activateSpellViewContext()
  500. {
  501. if(spellViewContext)
  502. return;
  503. resetContext();
  504. spellViewContext = std::make_shared<MapRendererSpellViewContext>(*state);
  505. worldViewContext = spellViewContext;
  506. context = spellViewContext;
  507. }
  508. void MapViewController::activatePuzzleMapContext(const int3 & grailPosition)
  509. {
  510. resetContext();
  511. puzzleMapContext = std::make_shared<MapRendererPuzzleMapContext>(*state);
  512. context = puzzleMapContext;
  513. CGPathNode fakeNode;
  514. fakeNode.coord = grailPosition;
  515. puzzleMapContext->grailPos = std::make_unique<CGPath>();
  516. // create two nodes since 1st one is normally not visible
  517. puzzleMapContext->grailPos->nodes.push_back(fakeNode);
  518. puzzleMapContext->grailPos->nodes.push_back(fakeNode);
  519. }
  520. void MapViewController::resetContext()
  521. {
  522. adventureContext.reset();
  523. movementContext.reset();
  524. fadingOutContext.reset();
  525. fadingInContext.reset();
  526. teleportContext.reset();
  527. worldViewContext.reset();
  528. spellViewContext.reset();
  529. puzzleMapContext.reset();
  530. animationWait.setFree();
  531. }
  532. void MapViewController::setTerrainVisibility(bool showAllTerrain)
  533. {
  534. assert(spellViewContext);
  535. spellViewContext->showAllTerrain = showAllTerrain;
  536. }
  537. void MapViewController::setOverlayVisibility(const std::vector<ObjectPosInfo> & objectPositions)
  538. {
  539. assert(spellViewContext);
  540. spellViewContext->additionalOverlayIcons = objectPositions;
  541. }