2009-04-15 17:03:31 +03:00
|
|
|
/*
|
|
|
|
* mapHandler.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
2009-04-16 14:14:13 +03:00
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
2023-02-16 21:35:15 +02:00
|
|
|
#include "../gui/CIntObject.h"
|
2017-07-13 10:26:03 +02:00
|
|
|
|
2023-03-01 18:15:42 +02:00
|
|
|
#include "../../lib/Rect.h"
|
2023-02-01 20:42:06 +02:00
|
|
|
#include "../../lib/int3.h"
|
|
|
|
#include "../../lib/spells/ViewSpellInt.h"
|
2023-02-14 23:49:12 +02:00
|
|
|
|
2020-05-05 14:05:15 +02:00
|
|
|
#ifdef IN
|
2023-03-01 18:15:42 +02:00
|
|
|
# undef IN
|
2020-05-05 14:05:15 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef OUT
|
2023-03-01 18:15:42 +02:00
|
|
|
# undef OUT
|
2020-05-05 14:05:15 +02:00
|
|
|
#endif
|
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
class CGObjectInstance;
|
|
|
|
class CGHeroInstance;
|
2012-11-03 22:31:16 +03:00
|
|
|
class CMap;
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
2023-02-16 21:35:15 +02:00
|
|
|
class IMapObjectObserver;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2023-02-10 16:50:05 +02:00
|
|
|
class CMapHandler
|
|
|
|
{
|
2012-10-26 20:51:05 +03:00
|
|
|
const CMap * map;
|
2023-02-16 21:35:15 +02:00
|
|
|
std::vector<IMapObjectObserver *> observers;
|
2016-11-07 23:19:53 +02:00
|
|
|
|
2023-02-16 21:35:15 +02:00
|
|
|
public:
|
|
|
|
explicit CMapHandler(const CMap * map);
|
2016-11-06 20:39:32 +02:00
|
|
|
|
2023-02-16 21:35:15 +02:00
|
|
|
const CMap * getMap();
|
2016-11-06 03:28:57 +02:00
|
|
|
|
2023-02-16 21:35:15 +02:00
|
|
|
/// returns true if tile is within map bounds
|
|
|
|
bool isInMap(const int3 & tile);
|
2016-11-07 23:19:53 +02:00
|
|
|
|
2023-02-16 21:35:15 +02:00
|
|
|
/// see MapObjectObserver interface
|
|
|
|
void onObjectFadeIn(const CGObjectInstance * obj);
|
|
|
|
void onObjectFadeOut(const CGObjectInstance * obj);
|
|
|
|
void onObjectInstantAdd(const CGObjectInstance * obj);
|
|
|
|
void onObjectInstantRemove(const CGObjectInstance * obj);
|
2023-02-26 18:17:53 +02:00
|
|
|
void onBeforeHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
|
|
|
|
void onAfterHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
|
|
|
|
void onBeforeHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
|
|
|
|
void onAfterHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
|
|
|
|
void onBeforeHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
|
|
|
|
void onAfterHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
|
2023-02-16 21:35:15 +02:00
|
|
|
void onHeroMoved(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
|
2016-11-07 23:19:53 +02:00
|
|
|
|
2023-02-16 21:35:15 +02:00
|
|
|
/// Add object to receive notifications on any changes in visible map state
|
|
|
|
void addMapObserver(IMapObjectObserver * observer);
|
|
|
|
void removeMapObserver(IMapObjectObserver * observer);
|
2011-12-14 00:23:17 +03:00
|
|
|
|
2023-02-16 21:35:15 +02:00
|
|
|
/// returns string description for terrain interaction
|
2023-02-28 22:42:08 +02:00
|
|
|
std::string getTerrainDescr(const int3 & pos, bool rightClick) const;
|
2013-02-19 01:37:22 +03:00
|
|
|
|
2015-02-09 17:03:24 +02:00
|
|
|
/// determines if the map is ready to handle new hero movement (not available during fading animations)
|
2023-02-18 17:37:09 +02:00
|
|
|
bool hasOngoingAnimations();
|
|
|
|
|
|
|
|
/// blocking wait until all ongoing animatins are over
|
|
|
|
void waitForOngoingAnimations();
|
2014-06-24 02:26:36 +03:00
|
|
|
|
2015-01-13 21:57:41 +02:00
|
|
|
static bool compareObjectBlitOrder(const CGObjectInstance * a, const CGObjectInstance * b);
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|