mapHandler.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * mapHandler.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 "../gui/CIntObject.h"
  12. #include "../../lib/int3.h"
  13. #include "../../lib/spells/ViewSpellInt.h"
  14. #include "../../lib/Rect.h"
  15. #ifdef IN
  16. #undef IN
  17. #endif
  18. #ifdef OUT
  19. #undef OUT
  20. #endif
  21. VCMI_LIB_NAMESPACE_BEGIN
  22. class CGObjectInstance;
  23. class CGHeroInstance;
  24. class CGBoat;
  25. class CMap;
  26. struct TerrainTile;
  27. class PlayerColor;
  28. VCMI_LIB_NAMESPACE_END
  29. struct SDL_Surface;
  30. class CAnimation;
  31. class IImage;
  32. class CMapHandler;
  33. class IMapObjectObserver;
  34. class CMapHandler
  35. {
  36. const CMap * map;
  37. std::vector<IMapObjectObserver *> observers;
  38. public:
  39. explicit CMapHandler(const CMap * map);
  40. const CMap * getMap();
  41. /// returns true if tile is within map bounds
  42. bool isInMap(const int3 & tile);
  43. /// see MapObjectObserver interface
  44. void onObjectFadeIn(const CGObjectInstance * obj);
  45. void onObjectFadeOut(const CGObjectInstance * obj);
  46. void onObjectInstantAdd(const CGObjectInstance * obj);
  47. void onObjectInstantRemove(const CGObjectInstance * obj);
  48. void onBeforeHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
  49. void onAfterHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
  50. void onBeforeHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
  51. void onAfterHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
  52. void onBeforeHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
  53. void onAfterHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
  54. void onHeroMoved(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
  55. /// Add object to receive notifications on any changes in visible map state
  56. void addMapObserver(IMapObjectObserver * observer);
  57. void removeMapObserver(IMapObjectObserver * observer);
  58. /// returns string description for terrain interaction
  59. std::string getTerrainDescr(const int3 & pos, bool rightClick) const;
  60. /// returns list of ambient sounds for specified tile
  61. std::vector<std::string> getAmbientSounds(const int3 & tile);
  62. /// determines if the map is ready to handle new hero movement (not available during fading animations)
  63. bool hasOngoingAnimations();
  64. /// blocking wait until all ongoing animatins are over
  65. void waitForOngoingAnimations();
  66. static bool compareObjectBlitOrder(const CGObjectInstance * a, const CGObjectInstance * b);
  67. };