MapRendererContext.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. const TerrainTile & getMapTile(const int3 & coordinates) const override;
  31. const MapObjectsList & getObjects(const int3 & coordinates) const override;
  32. const CGObjectInstance * getObject(ObjectInstanceID objectID) const override;
  33. const CGPath * currentPath() const override;
  34. size_t objectGroupIndex(ObjectInstanceID objectID) const override;
  35. Point objectImageOffset(ObjectInstanceID objectID, const int3 & coordinates) const override;
  36. double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
  37. size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
  38. size_t terrainImageIndex(size_t groupSize) const override;
  39. size_t overlayImageIndex(const int3 & coordinates) const override;
  40. double viewTransitionProgress() const override;
  41. bool filterGrayscale() const override;
  42. bool showRoads() const override;
  43. bool showRivers() const override;
  44. bool showBorder() const override;
  45. bool showOverlay() const override;
  46. bool showGrid() const override;
  47. bool showVisitable() const override;
  48. bool showBlocked() const override;
  49. bool showSpellRange(const int3 & position) const override;
  50. };
  51. class MapRendererAdventureContext : public MapRendererBaseContext
  52. {
  53. public:
  54. uint32_t animationTime = 0;
  55. bool settingShowGrid = false;
  56. bool settingShowVisitable = false;
  57. bool settingShowBlocked = false;
  58. bool settingSpellRange= false;
  59. bool settingsAdventureObjectAnimation = true;
  60. bool settingsAdventureTerrainAnimation = true;
  61. explicit MapRendererAdventureContext(const MapRendererContextState & viewState);
  62. const CGPath * currentPath() const override;
  63. size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
  64. size_t terrainImageIndex(size_t groupSize) const override;
  65. bool showBorder() const override;
  66. bool showGrid() const override;
  67. bool showVisitable() const override;
  68. bool showBlocked() const override;
  69. bool showSpellRange(const int3 & position) const override;
  70. };
  71. class MapRendererAdventureTransitionContext : public MapRendererAdventureContext
  72. {
  73. public:
  74. double progress = 0;
  75. explicit MapRendererAdventureTransitionContext(const MapRendererContextState & viewState);
  76. double viewTransitionProgress() const override;
  77. };
  78. class MapRendererAdventureFadingContext : public MapRendererAdventureContext
  79. {
  80. public:
  81. ObjectInstanceID target;
  82. double progress;
  83. explicit MapRendererAdventureFadingContext(const MapRendererContextState & viewState);
  84. bool tileAnimated(const int3 & coordinates) const override;
  85. double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
  86. };
  87. class MapRendererAdventureMovingContext : public MapRendererAdventureContext
  88. {
  89. public:
  90. ObjectInstanceID target;
  91. int3 tileFrom;
  92. int3 tileDest;
  93. double progress;
  94. explicit MapRendererAdventureMovingContext(const MapRendererContextState & viewState);
  95. bool tileAnimated(const int3 & coordinates) const override;
  96. size_t objectGroupIndex(ObjectInstanceID objectID) const override;
  97. Point objectImageOffset(ObjectInstanceID objectID, const int3 & coordinates) const override;
  98. size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
  99. };
  100. class MapRendererWorldViewContext : public MapRendererBaseContext
  101. {
  102. protected:
  103. size_t selectOverlayImageForObject(const ObjectPosInfo & object) const;
  104. public:
  105. explicit MapRendererWorldViewContext(const MapRendererContextState & viewState);
  106. size_t overlayImageIndex(const int3 & coordinates) const override;
  107. bool showOverlay() const override;
  108. };
  109. class MapRendererSpellViewContext : public MapRendererWorldViewContext
  110. {
  111. public:
  112. std::vector<ObjectPosInfo> additionalOverlayIcons;
  113. bool showAllTerrain = false;
  114. explicit MapRendererSpellViewContext(const MapRendererContextState & viewState);
  115. bool isVisible(const int3 & coordinates) const override;
  116. double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
  117. size_t overlayImageIndex(const int3 & coordinates) const override;
  118. };
  119. class MapRendererPuzzleMapContext : public MapRendererBaseContext
  120. {
  121. public:
  122. std::unique_ptr<CGPath> grailPos;
  123. explicit MapRendererPuzzleMapContext(const MapRendererContextState & viewState);
  124. ~MapRendererPuzzleMapContext();
  125. const CGPath * currentPath() const override;
  126. double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
  127. bool isVisible(const int3 & coordinates) const override;
  128. bool filterGrayscale() const override;
  129. bool showRoads() const override;
  130. bool showRivers() const override;
  131. };