2023-02-14 23:49:12 +02:00
|
|
|
/*
|
|
|
|
* MapView.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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2023-02-18 17:37:09 +02:00
|
|
|
#include "../gui/CIntObject.h"
|
2023-02-14 23:49:12 +02:00
|
|
|
|
2023-02-23 19:46:41 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
struct ObjectPosInfo;
|
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
2023-02-21 22:28:48 +02:00
|
|
|
class Canvas;
|
2023-02-23 19:46:41 +02:00
|
|
|
class MapViewActions;
|
2023-02-18 17:37:09 +02:00
|
|
|
class MapViewController;
|
2023-02-20 22:16:50 +02:00
|
|
|
class MapViewModel;
|
|
|
|
class MapViewCache;
|
2023-02-18 17:37:09 +02:00
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
/// Internal class that contains logic shared between all map views
|
|
|
|
class BasicMapView : public CIntObject
|
2023-02-18 17:37:09 +02:00
|
|
|
{
|
2023-02-26 18:17:53 +02:00
|
|
|
protected:
|
2023-02-18 17:37:09 +02:00
|
|
|
std::shared_ptr<MapViewModel> model;
|
2023-02-23 19:46:41 +02:00
|
|
|
std::shared_ptr<MapViewCache> tilesCache;
|
2023-02-18 17:37:09 +02:00
|
|
|
std::shared_ptr<MapViewController> controller;
|
2023-02-14 23:49:12 +02:00
|
|
|
|
2023-02-18 17:37:09 +02:00
|
|
|
std::shared_ptr<MapViewModel> createModel(const Point & dimensions) const;
|
|
|
|
|
2023-02-21 22:28:48 +02:00
|
|
|
void render(Canvas & target, bool fullUpdate);
|
2023-02-18 17:37:09 +02:00
|
|
|
|
2023-02-23 19:46:41 +02:00
|
|
|
public:
|
2023-02-26 18:17:53 +02:00
|
|
|
BasicMapView(const Point & offset, const Point & dimensions);
|
|
|
|
~BasicMapView() override;
|
|
|
|
|
2023-05-13 16:24:18 +02:00
|
|
|
void tick(uint32_t msPassed) override;
|
2023-02-26 18:17:53 +02:00
|
|
|
void show(SDL_Surface * to) override;
|
|
|
|
void showAll(SDL_Surface * to) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Main class that represents visible section of adventure map
|
|
|
|
/// Contains all public interface of view and translates calls to internal model
|
|
|
|
class MapView : public BasicMapView
|
|
|
|
{
|
|
|
|
std::shared_ptr<MapViewActions> actions;
|
|
|
|
|
|
|
|
bool isSwiping;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void show(SDL_Surface * to) override;
|
|
|
|
|
2023-02-18 17:37:09 +02:00
|
|
|
MapView(const Point & offset, const Point & dimensions);
|
2023-02-16 21:35:15 +02:00
|
|
|
|
2023-02-23 19:46:41 +02:00
|
|
|
/// Moves current view to another level, preserving position
|
|
|
|
void onMapLevelSwitched();
|
|
|
|
|
|
|
|
/// Moves current view by specified distance in pixels
|
|
|
|
void onMapScrolled(const Point & distance);
|
|
|
|
|
|
|
|
/// Moves current view to specified position, in pixels
|
|
|
|
void onMapSwiped(const Point & viewPosition);
|
|
|
|
|
|
|
|
/// Ends swiping mode and allows normal map scrolling once again
|
|
|
|
void onMapSwipeEnded();
|
|
|
|
|
|
|
|
/// Moves current view to specified tile
|
|
|
|
void onCenteredTile(const int3 & tile);
|
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
/// Moves current view to specified object
|
2023-02-23 19:46:41 +02:00
|
|
|
void onCenteredObject(const CGObjectInstance * target);
|
|
|
|
|
|
|
|
/// Switches view to "View Earth" / "View Air" mode, displaying downscaled map with overlay
|
2023-03-01 18:15:42 +02:00
|
|
|
void onViewSpellActivated(uint32_t tileSize, const std::vector<ObjectPosInfo> & objectPositions, bool showTerrain);
|
2023-02-23 19:46:41 +02:00
|
|
|
|
|
|
|
/// Switches view to downscaled View World
|
2023-03-01 18:15:42 +02:00
|
|
|
void onViewWorldActivated(uint32_t tileSize);
|
2023-02-23 19:46:41 +02:00
|
|
|
|
|
|
|
/// Switches view from View World mode back to standard view
|
|
|
|
void onViewMapActivated();
|
2023-02-26 18:17:53 +02:00
|
|
|
};
|
2023-02-23 19:46:41 +02:00
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
/// Main class that represents map view for puzzle map
|
|
|
|
class PuzzleMapView : public BasicMapView
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PuzzleMapView(const Point & offset, const Point & dimensions, const int3 & tileToCenter);
|
2023-02-14 23:49:12 +02:00
|
|
|
};
|