MapRendererContext.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * MapRendererContext.h, 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. #pragma once
  11. #include "IMapRendererContext.h"
  12. #include "../lib/GameConstants.h"
  13. #include "../lib/int3.h"
  14. #include "../lib/spells/ViewSpellInt.h"
  15. struct MapRendererContextState;
  16. class MapRendererBaseContext : public IMapRendererContext
  17. {
  18. public:
  19. const MapRendererContextState & viewState;
  20. bool settingsSessionSpectate = false;
  21. explicit MapRendererBaseContext(const MapRendererContextState & viewState);
  22. uint32_t getObjectRotation(ObjectInstanceID objectID) const;
  23. int3 getMapSize() const override;
  24. bool isInMap(const int3 & coordinates) const override;
  25. bool isVisible(const int3 & coordinates) const override;
  26. bool tileAnimated(const int3 & coordinates) const override;
  27. bool isActiveHero(const CGObjectInstance* obj) const override;
  28. int attackedMonsterDirection(const CGObjectInstance * wanderingMonster) const override;
  29. const TerrainTile & getMapTile(const int3 & coordinates) const override;
  30. const MapObjectsList & getObjects(const int3 & coordinates) const override;
  31. const CGObjectInstance * getObject(ObjectInstanceID objectID) const override;
  32. const CGPath * currentPath() const override;
  33. size_t objectGroupIndex(ObjectInstanceID objectID) const override;
  34. Point objectImageOffset(ObjectInstanceID objectID, const int3 & coordinates) const override;
  35. double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
  36. size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
  37. size_t terrainImageIndex(size_t groupSize) const override;
  38. size_t overlayImageIndex(const int3 & coordinates) const override;
  39. std::string overlayText(const int3 & coordinates) const override;
  40. ColorRGBA overlayTextColor(const int3 & coordinates) const override;
  41. double viewTransitionProgress() const override;
  42. bool filterGrayscale() const override;
  43. bool showRoads() const override;
  44. bool showRivers() const override;
  45. bool showBorder() const override;
  46. bool showImageOverlay() const override;
  47. bool showTextOverlay() const override;
  48. bool showGrid() const override;
  49. bool showVisitable() const override;
  50. bool showBlocked() const override;
  51. bool showInvisible() const override;
  52. bool showSpellRange(const int3 & position) const override;
  53. };
  54. class MapRendererAdventureContext : public MapRendererBaseContext
  55. {
  56. public:
  57. uint32_t animationTime = 0;
  58. bool settingShowGrid = false;
  59. bool settingShowVisitable = false;
  60. bool settingShowBlocked = false;
  61. bool settingShowInvisible = false;
  62. bool settingTextOverlay = false;
  63. bool settingsAdventureObjectAnimation = true;
  64. bool settingsAdventureTerrainAnimation = true;
  65. explicit MapRendererAdventureContext(const MapRendererContextState & viewState);
  66. const CGPath * currentPath() const override;
  67. size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
  68. size_t terrainImageIndex(size_t groupSize) const override;
  69. std::string overlayText(const int3 & coordinates) const override;
  70. ColorRGBA overlayTextColor(const int3 & coordinates) const override;
  71. bool showBorder() const override;
  72. bool showGrid() const override;
  73. bool showVisitable() const override;
  74. bool showBlocked() const override;
  75. bool showInvisible() const override;
  76. bool showTextOverlay() const override;
  77. bool showSpellRange(const int3 & position) const override;
  78. };
  79. class MapRendererAdventureTransitionContext : public MapRendererAdventureContext
  80. {
  81. public:
  82. double progress = 0;
  83. explicit MapRendererAdventureTransitionContext(const MapRendererContextState & viewState);
  84. double viewTransitionProgress() const override;
  85. };
  86. class MapRendererAdventureFadingContext : public MapRendererAdventureContext
  87. {
  88. public:
  89. ObjectInstanceID target;
  90. double progress;
  91. explicit MapRendererAdventureFadingContext(const MapRendererContextState & viewState);
  92. bool tileAnimated(const int3 & coordinates) const override;
  93. double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
  94. };
  95. class MapRendererAdventureMovingContext : public MapRendererAdventureContext
  96. {
  97. public:
  98. ObjectInstanceID target;
  99. int3 tileFrom;
  100. int3 tileDest;
  101. double progress;
  102. explicit MapRendererAdventureMovingContext(const MapRendererContextState & viewState);
  103. bool tileAnimated(const int3 & coordinates) const override;
  104. size_t objectGroupIndex(ObjectInstanceID objectID) const override;
  105. Point objectImageOffset(ObjectInstanceID objectID, const int3 & coordinates) const override;
  106. size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
  107. };
  108. class MapRendererWorldViewContext : public MapRendererBaseContext
  109. {
  110. protected:
  111. size_t selectOverlayImageForObject(const ObjectPosInfo & object) const;
  112. public:
  113. explicit MapRendererWorldViewContext(const MapRendererContextState & viewState);
  114. size_t overlayImageIndex(const int3 & coordinates) const override;
  115. bool showImageOverlay() const override;
  116. };
  117. class MapRendererSpellViewContext : public MapRendererWorldViewContext
  118. {
  119. public:
  120. std::vector<ObjectPosInfo> additionalOverlayIcons;
  121. bool showAllTerrain = false;
  122. explicit MapRendererSpellViewContext(const MapRendererContextState & viewState);
  123. bool isVisible(const int3 & coordinates) const override;
  124. double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
  125. size_t overlayImageIndex(const int3 & coordinates) const override;
  126. };
  127. class MapRendererPuzzleMapContext : public MapRendererBaseContext
  128. {
  129. public:
  130. std::unique_ptr<CGPath> grailPos;
  131. explicit MapRendererPuzzleMapContext(const MapRendererContextState & viewState);
  132. ~MapRendererPuzzleMapContext();
  133. const CGPath * currentPath() const override;
  134. double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
  135. bool isVisible(const int3 & coordinates) const override;
  136. bool filterGrayscale() const override;
  137. bool showRoads() const override;
  138. bool showRivers() const override;
  139. };