MapRendererContext.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. VCMI_LIB_NAMESPACE_BEGIN
  15. struct ObjectPosInfo;
  16. VCMI_LIB_NAMESPACE_END
  17. struct MapRendererContextState;
  18. class MapRendererBaseContext : public IMapRendererContext
  19. {
  20. public:
  21. const MapRendererContextState & viewState;
  22. bool settingsSessionSpectate = false;
  23. explicit MapRendererBaseContext(const MapRendererContextState & viewState);
  24. uint32_t getObjectRotation(ObjectInstanceID objectID) const;
  25. int3 getMapSize() const override;
  26. bool isInMap(const int3 & coordinates) const override;
  27. bool isVisible(const int3 & coordinates) const override;
  28. bool tileAnimated(const int3 & coordinates) const override;
  29. bool isActiveHero(const CGObjectInstance* obj) const override;
  30. std::optional<int3> monsterAttacked(const CGObjectInstance * obj) const override;
  31. const TerrainTile & getMapTile(const int3 & coordinates) const override;
  32. const MapObjectsList & getObjects(const int3 & coordinates) const override;
  33. const CGObjectInstance * getObject(ObjectInstanceID objectID) const override;
  34. const CGPath * currentPath() const override;
  35. size_t objectGroupIndex(ObjectInstanceID objectID) const override;
  36. Point objectImageOffset(ObjectInstanceID objectID, const int3 & coordinates) const override;
  37. double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
  38. size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
  39. size_t terrainImageIndex(size_t groupSize) const override;
  40. size_t overlayImageIndex(const int3 & coordinates) const override;
  41. std::string overlayText(const int3 & coordinates) const override;
  42. ColorRGBA overlayTextColor(const int3 & coordinates) const override;
  43. double viewTransitionProgress() const override;
  44. bool filterGrayscale() const override;
  45. bool showRoads() const override;
  46. bool showRivers() const override;
  47. bool showBorder() const override;
  48. bool showImageOverlay() const override;
  49. bool showTextOverlay() const override;
  50. bool showGrid() const override;
  51. bool showVisitable() const override;
  52. bool showBlocked() const override;
  53. bool showSpellRange(const int3 & position) const override;
  54. };
  55. class MapRendererAdventureContext : public MapRendererBaseContext
  56. {
  57. public:
  58. uint32_t animationTime = 0;
  59. bool settingShowGrid = false;
  60. bool settingShowVisitable = false;
  61. bool settingShowBlocked = false;
  62. bool settingSpellRange= false;
  63. bool settingTextOverlay = false;
  64. bool settingsAdventureObjectAnimation = true;
  65. bool settingsAdventureTerrainAnimation = true;
  66. explicit MapRendererAdventureContext(const MapRendererContextState & viewState);
  67. const CGPath * currentPath() const override;
  68. size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
  69. size_t terrainImageIndex(size_t groupSize) const override;
  70. std::string overlayText(const int3 & coordinates) const override;
  71. ColorRGBA overlayTextColor(const int3 & coordinates) const override;
  72. bool showBorder() const override;
  73. bool showGrid() const override;
  74. bool showVisitable() const override;
  75. bool showBlocked() 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. };