MapViewController.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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, bool useDeadZone)
  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 (useDeadZone)
  98. {
  99. if(actualZoom.x >= defaultTileSize - zoomTileDeadArea && actualZoom.x <= defaultTileSize + zoomTileDeadArea)
  100. actualZoom.x = defaultTileSize;
  101. if(actualZoom.y >= defaultTileSize - zoomTileDeadArea && actualZoom.y <= defaultTileSize + zoomTileDeadArea)
  102. actualZoom.y = defaultTileSize;
  103. }
  104. bool isInDeadZone = targetTileSize != actualZoom || actualZoom == Point(defaultTileSize, defaultTileSize);
  105. if(!wasInDeadZone && isInDeadZone)
  106. GH.input().hapticFeedback();
  107. wasInDeadZone = isInDeadZone;
  108. setTileSize(actualZoom);
  109. }
  110. }
  111. MapViewController::MapViewController(std::shared_ptr<MapViewModel> model, std::shared_ptr<MapViewCache> view)
  112. : state(new MapRendererContextState())
  113. , model(std::move(model))
  114. , view(view)
  115. {
  116. adventureContext = std::make_shared<MapRendererAdventureContext>(*state);
  117. context = adventureContext;
  118. }
  119. std::shared_ptr<IMapRendererContext> MapViewController::getContext() const
  120. {
  121. return context;
  122. }
  123. void MapViewController::tick(uint32_t timeDelta)
  124. {
  125. // confirmed to match H3 for
  126. // - hero embarking on boat (500 ms)
  127. // - hero disembarking from boat (500 ms)
  128. // - TODO: picking up resources
  129. // - TODO: killing mosters
  130. // - teleporting ( 250 ms)
  131. static const double fadeOutDuration = 500;
  132. static const double fadeInDuration = 500;
  133. static const double heroTeleportDuration = 250;
  134. if(movementContext)
  135. {
  136. const auto * object = context->getObject(movementContext->target);
  137. const auto * hero = dynamic_cast<const CGHeroInstance *>(object);
  138. const auto * boat = dynamic_cast<const CGBoat *>(object);
  139. assert(boat || hero);
  140. if(!hero)
  141. hero = boat->hero;
  142. double heroMoveTime = LOCPLINT->playerID == hero->getOwner() ?
  143. settings["adventure"]["heroMoveTime"].Float() :
  144. settings["adventure"]["enemyMoveTime"].Float();
  145. movementContext->progress += timeDelta / heroMoveTime;
  146. movementContext->progress = std::min( 1.0, movementContext->progress);
  147. Point positionFrom = Point(hero->convertToVisitablePos(movementContext->tileFrom)) * model->getSingleTileSize() + model->getSingleTileSize() / 2;
  148. Point positionDest = Point(hero->convertToVisitablePos(movementContext->tileDest)) * model->getSingleTileSize() + model->getSingleTileSize() / 2;
  149. Point positionCurr = vstd::lerp(positionFrom, positionDest, movementContext->progress);
  150. setViewCenter(positionCurr, movementContext->tileDest.z);
  151. }
  152. if(teleportContext)
  153. {
  154. teleportContext->progress += timeDelta / heroTeleportDuration;
  155. teleportContext->progress = std::min( 1.0, teleportContext->progress);
  156. }
  157. if(fadingOutContext)
  158. {
  159. fadingOutContext->progress -= timeDelta / fadeOutDuration;
  160. fadingOutContext->progress = std::max( 0.0, fadingOutContext->progress);
  161. }
  162. if(fadingInContext)
  163. {
  164. fadingInContext->progress += timeDelta / fadeInDuration;
  165. fadingInContext->progress = std::min( 1.0, fadingInContext->progress);
  166. }
  167. if (adventureContext)
  168. adventureContext->animationTime += timeDelta;
  169. updateState();
  170. }
  171. void MapViewController::updateState()
  172. {
  173. if(adventureContext)
  174. {
  175. adventureContext->settingsSessionSpectate = settings["session"]["spectate"].Bool();
  176. adventureContext->settingsAdventureObjectAnimation = settings["adventure"]["objectAnimation"].Bool();
  177. adventureContext->settingsAdventureTerrainAnimation = settings["adventure"]["terrainAnimation"].Bool();
  178. adventureContext->settingShowGrid = settings["gameTweaks"]["showGrid"].Bool();
  179. adventureContext->settingShowVisitable = settings["session"]["showVisitable"].Bool();
  180. adventureContext->settingShowBlocked = settings["session"]["showBlocked"].Bool();
  181. adventureContext->settingSpellRange = settings["session"]["showSpellRange"].Bool();
  182. }
  183. }
  184. void MapViewController::afterRender()
  185. {
  186. if(movementContext)
  187. {
  188. const auto * object = context->getObject(movementContext->target);
  189. const auto * hero = dynamic_cast<const CGHeroInstance *>(object);
  190. const auto * boat = dynamic_cast<const CGBoat *>(object);
  191. assert(boat || hero);
  192. if(!hero)
  193. hero = boat->hero;
  194. if(movementContext->progress >= 0.999)
  195. {
  196. logGlobal->debug("Ending movement animation");
  197. setViewCenter(hero->getSightCenter());
  198. removeObject(context->getObject(movementContext->target));
  199. addObject(context->getObject(movementContext->target));
  200. activateAdventureContext(movementContext->animationTime);
  201. }
  202. }
  203. if(teleportContext && teleportContext->progress >= 0.999)
  204. {
  205. logGlobal->debug("Ending teleport animation");
  206. activateAdventureContext(teleportContext->animationTime);
  207. }
  208. if(fadingOutContext && fadingOutContext->progress <= 0.001)
  209. {
  210. logGlobal->debug("Ending fade out animation");
  211. removeObject(context->getObject(fadingOutContext->target));
  212. activateAdventureContext(fadingOutContext->animationTime);
  213. }
  214. if(fadingInContext && fadingInContext->progress >= 0.999)
  215. {
  216. logGlobal->debug("Ending fade in animation");
  217. activateAdventureContext(fadingInContext->animationTime);
  218. }
  219. }
  220. bool MapViewController::isEventInstant(const CGObjectInstance * obj, const PlayerColor & initiator)
  221. {
  222. if(settings["gameTweaks"]["skipAdventureMapAnimations"].Bool())
  223. return true;
  224. if (!isEventVisible(obj, initiator))
  225. return true;
  226. if (!initiator.isValidPlayer())
  227. return true; // skip effects such as new monsters on new month
  228. if(initiator != LOCPLINT->playerID && settings["adventure"]["enemyMoveTime"].Float() <= 0)
  229. return true; // instant movement speed
  230. if(initiator == LOCPLINT->playerID && settings["adventure"]["heroMoveTime"].Float() <= 0)
  231. return true; // instant movement speed
  232. return false;
  233. }
  234. bool MapViewController::isEventVisible(const CGObjectInstance * obj, const PlayerColor & initiator)
  235. {
  236. if(adventureContext == nullptr)
  237. return false;
  238. if(initiator != LOCPLINT->playerID && settings["adventure"]["enemyMoveTime"].Float() < 0)
  239. return false; // enemy move speed set to "hidden/none"
  240. if(!GH.windows().isTopWindow(adventureInt))
  241. return false;
  242. // do not focus on actions of other players except for AI with simturns off
  243. if (initiator != LOCPLINT->playerID && initiator.isValidPlayer())
  244. {
  245. if (LOCPLINT->makingTurn)
  246. return false;
  247. if (LOCPLINT->cb->getStartInfo()->playerInfos.at(initiator).isControlledByHuman() && !settings["session"]["adventureTrackHero"].Bool())
  248. return false;
  249. }
  250. if(obj->isVisitable())
  251. return context->isVisible(obj->visitablePos());
  252. else
  253. return context->isVisible(obj->pos);
  254. }
  255. bool MapViewController::isEventVisible(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  256. {
  257. if(adventureContext == nullptr)
  258. return false;
  259. if(obj->getOwner() != LOCPLINT->playerID && settings["adventure"]["enemyMoveTime"].Float() < 0)
  260. return false; // enemy move speed set to "hidden/none"
  261. if(!GH.windows().isTopWindow(adventureInt))
  262. return false;
  263. // do not focus on actions of other players except for AI with simturns off
  264. if (obj->getOwner() != LOCPLINT->playerID)
  265. {
  266. if (LOCPLINT->makingTurn)
  267. return false;
  268. if (LOCPLINT->cb->getStartInfo()->playerInfos.at(obj->getOwner()).isControlledByHuman() && !settings["session"]["adventureTrackHero"].Bool())
  269. return false;
  270. }
  271. if(context->isVisible(obj->convertToVisitablePos(from)))
  272. return true;
  273. if(context->isVisible(obj->convertToVisitablePos(dest)))
  274. return true;
  275. return false;
  276. }
  277. void MapViewController::fadeOutObject(const CGObjectInstance * obj)
  278. {
  279. animationWait.setBusy();
  280. logGlobal->debug("Starting fade out animation");
  281. fadingOutContext = std::make_shared<MapRendererAdventureFadingContext>(*state);
  282. fadingOutContext->animationTime = adventureContext->animationTime;
  283. adventureContext = fadingOutContext;
  284. context = fadingOutContext;
  285. const CGObjectInstance * movingObject = obj;
  286. if (obj->ID == Obj::HERO)
  287. {
  288. auto * hero = dynamic_cast<const CGHeroInstance*>(obj);
  289. if (hero->boat)
  290. movingObject = hero->boat;
  291. }
  292. fadingOutContext->target = movingObject->id;
  293. fadingOutContext->progress = 1.0;
  294. }
  295. void MapViewController::fadeInObject(const CGObjectInstance * obj)
  296. {
  297. animationWait.setBusy();
  298. logGlobal->debug("Starting fade in animation");
  299. fadingInContext = std::make_shared<MapRendererAdventureFadingContext>(*state);
  300. fadingInContext->animationTime = adventureContext->animationTime;
  301. adventureContext = fadingInContext;
  302. context = fadingInContext;
  303. const CGObjectInstance * movingObject = obj;
  304. if (obj->ID == Obj::HERO)
  305. {
  306. auto * hero = dynamic_cast<const CGHeroInstance*>(obj);
  307. if (hero->boat)
  308. movingObject = hero->boat;
  309. }
  310. fadingInContext->target = movingObject->id;
  311. fadingInContext->progress = 0.0;
  312. }
  313. void MapViewController::removeObject(const CGObjectInstance * obj)
  314. {
  315. if (obj->ID == Obj::BOAT)
  316. {
  317. auto * boat = dynamic_cast<const CGBoat*>(obj);
  318. if (boat->hero)
  319. {
  320. view->invalidate(context, boat->hero->id);
  321. state->removeObject(boat->hero);
  322. }
  323. }
  324. if (obj->ID == Obj::HERO)
  325. {
  326. auto * hero = dynamic_cast<const CGHeroInstance*>(obj);
  327. if (hero->boat)
  328. {
  329. view->invalidate(context, hero->boat->id);
  330. state->removeObject(hero->boat);
  331. }
  332. }
  333. view->invalidate(context, obj->id);
  334. state->removeObject(obj);
  335. }
  336. void MapViewController::addObject(const CGObjectInstance * obj)
  337. {
  338. state->addObject(obj);
  339. view->invalidate(context, obj->id);
  340. }
  341. void MapViewController::onBeforeHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  342. {
  343. if(isEventVisible(obj, from, dest))
  344. {
  345. if (!isEventInstant(obj, obj->getOwner()))
  346. fadeOutObject(obj);
  347. setViewCenter(obj->getSightCenter());
  348. }
  349. else
  350. removeObject(obj);
  351. }
  352. void MapViewController::onAfterHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  353. {
  354. if(isEventVisible(obj, from, dest))
  355. setViewCenter(obj->getSightCenter());
  356. }
  357. void MapViewController::onBeforeHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  358. {
  359. if(isEventVisible(obj, from, dest))
  360. setViewCenter(obj->getSightCenter());
  361. }
  362. void MapViewController::onAfterHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  363. {
  364. if(isEventVisible(obj, from, dest))
  365. {
  366. if (!isEventInstant(obj, obj->getOwner()))
  367. fadeInObject(obj);
  368. setViewCenter(obj->getSightCenter());
  369. }
  370. addObject(obj);
  371. }
  372. void MapViewController::onObjectFadeIn(const CGObjectInstance * obj, const PlayerColor & initiator)
  373. {
  374. assert(!hasOngoingAnimations());
  375. if(isEventVisible(obj, initiator) && !isEventInstant(obj, initiator) )
  376. fadeInObject(obj);
  377. addObject(obj);
  378. }
  379. void MapViewController::onObjectFadeOut(const CGObjectInstance * obj, const PlayerColor & initiator)
  380. {
  381. assert(!hasOngoingAnimations());
  382. if(isEventVisible(obj, initiator) && !isEventInstant(obj, initiator) )
  383. fadeOutObject(obj);
  384. else
  385. removeObject(obj);
  386. }
  387. void MapViewController::onObjectInstantAdd(const CGObjectInstance * obj, const PlayerColor & initiator)
  388. {
  389. addObject(obj);
  390. };
  391. void MapViewController::onObjectInstantRemove(const CGObjectInstance * obj, const PlayerColor & initiator)
  392. {
  393. removeObject(obj);
  394. };
  395. void MapViewController::onBeforeHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  396. {
  397. assert(!hasOngoingAnimations());
  398. if(isEventVisible(obj, from, dest))
  399. {
  400. setViewCenter(obj->getSightCenter());
  401. view->createTransitionSnapshot(context);
  402. }
  403. }
  404. void MapViewController::onAfterHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  405. {
  406. assert(!hasOngoingAnimations());
  407. const CGObjectInstance * movingObject = obj;
  408. if(obj->boat)
  409. movingObject = obj->boat;
  410. removeObject(movingObject);
  411. addObject(movingObject);
  412. if(isEventVisible(obj, from, dest))
  413. {
  414. animationWait.setBusy();
  415. logGlobal->debug("Starting teleport animation");
  416. teleportContext = std::make_shared<MapRendererAdventureTransitionContext>(*state);
  417. teleportContext->animationTime = adventureContext->animationTime;
  418. adventureContext = teleportContext;
  419. context = teleportContext;
  420. setViewCenter(movingObject->getSightCenter());
  421. }
  422. }
  423. void MapViewController::onHeroMoved(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
  424. {
  425. assert(!hasOngoingAnimations());
  426. // revisiting via spacebar, no need to animate
  427. if(from == dest)
  428. return;
  429. const CGObjectInstance * movingObject = obj;
  430. if(obj->boat)
  431. movingObject = obj->boat;
  432. removeObject(movingObject);
  433. if(!isEventVisible(obj, from, dest))
  434. {
  435. addObject(movingObject);
  436. return;
  437. }
  438. double movementTime = LOCPLINT->playerID == obj->tempOwner ?
  439. settings["adventure"]["heroMoveTime"].Float() :
  440. settings["adventure"]["enemyMoveTime"].Float();
  441. if(movementTime > 1)
  442. {
  443. animationWait.setBusy();
  444. logGlobal->debug("Starting movement animation");
  445. movementContext = std::make_shared<MapRendererAdventureMovingContext>(*state);
  446. movementContext->animationTime = adventureContext->animationTime;
  447. adventureContext = movementContext;
  448. context = movementContext;
  449. state->addMovingObject(movingObject, from, dest);
  450. movementContext->target = movingObject->id;
  451. movementContext->tileFrom = from;
  452. movementContext->tileDest = dest;
  453. movementContext->progress = 0.0;
  454. }
  455. else // instant movement
  456. {
  457. addObject(movingObject);
  458. setViewCenter(movingObject->visitablePos());
  459. }
  460. }
  461. bool MapViewController::hasOngoingAnimations()
  462. {
  463. if(movementContext)
  464. return true;
  465. if(fadingOutContext)
  466. return true;
  467. if(fadingInContext)
  468. return true;
  469. if(teleportContext)
  470. return true;
  471. return false;
  472. }
  473. void MapViewController::waitForOngoingAnimations()
  474. {
  475. auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex);
  476. animationWait.waitWhileBusy();
  477. }
  478. void MapViewController::endNetwork()
  479. {
  480. animationWait.requestTermination();
  481. }
  482. void MapViewController::activateAdventureContext(uint32_t animationTime)
  483. {
  484. resetContext();
  485. adventureContext = std::make_shared<MapRendererAdventureContext>(*state);
  486. adventureContext->animationTime = animationTime;
  487. context = adventureContext;
  488. updateState();
  489. }
  490. void MapViewController::activateAdventureContext()
  491. {
  492. activateAdventureContext(0);
  493. }
  494. void MapViewController::activateWorldViewContext()
  495. {
  496. if(worldViewContext)
  497. return;
  498. resetContext();
  499. worldViewContext = std::make_shared<MapRendererWorldViewContext>(*state);
  500. context = worldViewContext;
  501. }
  502. void MapViewController::activateSpellViewContext()
  503. {
  504. if(spellViewContext)
  505. return;
  506. resetContext();
  507. spellViewContext = std::make_shared<MapRendererSpellViewContext>(*state);
  508. worldViewContext = spellViewContext;
  509. context = spellViewContext;
  510. }
  511. void MapViewController::activatePuzzleMapContext(const int3 & grailPosition)
  512. {
  513. resetContext();
  514. puzzleMapContext = std::make_shared<MapRendererPuzzleMapContext>(*state);
  515. context = puzzleMapContext;
  516. CGPathNode fakeNode;
  517. fakeNode.coord = grailPosition;
  518. puzzleMapContext->grailPos = std::make_unique<CGPath>();
  519. // create two nodes since 1st one is normally not visible
  520. puzzleMapContext->grailPos->nodes.push_back(fakeNode);
  521. puzzleMapContext->grailPos->nodes.push_back(fakeNode);
  522. }
  523. void MapViewController::resetContext()
  524. {
  525. adventureContext.reset();
  526. movementContext.reset();
  527. fadingOutContext.reset();
  528. fadingInContext.reset();
  529. teleportContext.reset();
  530. worldViewContext.reset();
  531. spellViewContext.reset();
  532. puzzleMapContext.reset();
  533. animationWait.setFree();
  534. }
  535. void MapViewController::setTerrainVisibility(bool showAllTerrain)
  536. {
  537. assert(spellViewContext);
  538. spellViewContext->showAllTerrain = showAllTerrain;
  539. }
  540. void MapViewController::setOverlayVisibility(const std::vector<ObjectPosInfo> & objectPositions)
  541. {
  542. assert(spellViewContext);
  543. spellViewContext->additionalOverlayIcons = objectPositions;
  544. }