MapRendererContext.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. int attackedMonsterDirection(const CGObjectInstance * wanderingMonster) 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 showInvisible() const override;
  54. bool showSpellRange(const int3 & position) const override;
  55. };
  56. class MapRendererAdventureContext : public MapRendererBaseContext
  57. {
  58. public:
  59. uint32_t animationTime = 0;
  60. bool settingShowGrid = false;
  61. bool settingShowVisitable = false;
  62. bool settingShowBlocked = false;
  63. bool settingShowInvisible = false;
  64. bool settingTextOverlay = false;
  65. bool settingsAdventureObjectAnimation = true;
  66. bool settingsAdventureTerrainAnimation = true;
  67. explicit MapRendererAdventureContext(const MapRendererContextState & viewState);
  68. const CGPath * currentPath() const override;
  69. size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
  70. size_t terrainImageIndex(size_t groupSize) const override;
  71. std::string overlayText(const int3 & coordinates) const override;
  72. ColorRGBA overlayTextColor(const int3 & coordinates) const override;
  73. bool showBorder() const override;
  74. bool showGrid() const override;
  75. bool showVisitable() const override;
  76. bool showBlocked() const override;
  77. bool showInvisible() const override;
  78. bool showTextOverlay() const override;
  79. bool showSpellRange(const int3 & position) const override;
  80. };
  81. class MapRendererAdventureTransitionContext : public MapRendererAdventureContext
  82. {
  83. public:
  84. double progress = 0;
  85. explicit MapRendererAdventureTransitionContext(const MapRendererContextState & viewState);
  86. double viewTransitionProgress() const override;
  87. };
  88. class MapRendererAdventureFadingContext : public MapRendererAdventureContext
  89. {
  90. public:
  91. ObjectInstanceID target;
  92. double progress;
  93. explicit MapRendererAdventureFadingContext(const MapRendererContextState & viewState);
  94. bool tileAnimated(const int3 & coordinates) const override;
  95. double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
  96. };
  97. class MapRendererAdventureMovingContext : public MapRendererAdventureContext
  98. {
  99. public:
  100. ObjectInstanceID target;
  101. int3 tileFrom;
  102. int3 tileDest;
  103. double progress;
  104. explicit MapRendererAdventureMovingContext(const MapRendererContextState & viewState);
  105. bool tileAnimated(const int3 & coordinates) const override;
  106. size_t objectGroupIndex(ObjectInstanceID objectID) const override;
  107. Point objectImageOffset(ObjectInstanceID objectID, const int3 & coordinates) const override;
  108. size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
  109. };
  110. class MapRendererWorldViewContext : public MapRendererBaseContext
  111. {
  112. protected:
  113. size_t selectOverlayImageForObject(const ObjectPosInfo & object) const;
  114. public:
  115. explicit MapRendererWorldViewContext(const MapRendererContextState & viewState);
  116. size_t overlayImageIndex(const int3 & coordinates) const override;
  117. bool showImageOverlay() const override;
  118. };
  119. class MapRendererSpellViewContext : public MapRendererWorldViewContext
  120. {
  121. public:
  122. std::vector<ObjectPosInfo> additionalOverlayIcons;
  123. bool showAllTerrain = false;
  124. explicit MapRendererSpellViewContext(const MapRendererContextState & viewState);
  125. bool isVisible(const int3 & coordinates) const override;
  126. double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
  127. size_t overlayImageIndex(const int3 & coordinates) const override;
  128. };
  129. class MapRendererPuzzleMapContext : public MapRendererBaseContext
  130. {
  131. public:
  132. std::unique_ptr<CGPath> grailPos;
  133. explicit MapRendererPuzzleMapContext(const MapRendererContextState & viewState);
  134. ~MapRendererPuzzleMapContext();
  135. const CGPath * currentPath() const override;
  136. double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
  137. bool isVisible(const int3 & coordinates) const override;
  138. bool filterGrayscale() const override;
  139. bool showRoads() const override;
  140. bool showRivers() const override;
  141. };