1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
vcmi/mapeditor/mapcontroller.h

87 lines
2.3 KiB
C++
Raw Normal View History

2022-10-12 23:51:55 +02:00
/*
* mapcontroller.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
*
*/
2022-09-24 22:55:05 +02:00
#pragma once
2022-09-18 01:23:17 +02:00
#include "maphandler.h"
#include "mapview.h"
2023-05-24 01:05:59 +02:00
2023-09-21 04:31:08 +02:00
#include "../lib/modding/CModInfo.h"
2023-05-24 01:05:59 +02:00
VCMI_LIB_NAMESPACE_BEGIN
using ModCompatibilityInfo = std::map<std::string, ModVerificationInfo>;
2023-05-24 01:05:59 +02:00
class EditorObstaclePlacer;
VCMI_LIB_NAMESPACE_END
2022-09-18 01:23:17 +02:00
class MainWindow;
class MapController
{
public:
MapController(MainWindow *);
MapController(const MapController &) = delete;
MapController(const MapController &&) = delete;
~MapController();
void setMap(std::unique_ptr<CMap>);
2023-10-01 13:32:35 +02:00
void initObstaclePainters(CMap * map);
2022-09-18 01:23:17 +02:00
2023-10-01 13:32:35 +02:00
void repairMap(CMap * map) const;
2022-09-18 01:23:17 +02:00
void repairMap();
const std::unique_ptr<CMap> & getMapUniquePtr() const; //to be used for map saving
CMap * map();
MapHandler * mapHandler();
MapScene * scene(int level);
MinimapScene * miniScene(int level);
void resetMapHandler();
void sceneForceUpdate();
void sceneForceUpdate(int level);
2022-10-08 21:54:45 +02:00
void commitTerrainChange(int level, const TerrainId & terrain);
void commitRoadOrRiverChange(int level, ui8 type, bool isRoad);
2022-09-18 01:23:17 +02:00
void commitObjectErase(const CGObjectInstance* obj);
void commitObjectErase(int level);
void commitObstacleFill(int level);
void commitChangeWithoutRedraw();
void commitObjectShift(int level);
void commitObjectCreate(int level);
void commitObjectChange(int level);
2022-12-04 23:32:50 +02:00
void copyToClipboard(int level);
void pasteFromClipboard(int level);
2022-09-18 01:23:17 +02:00
bool discardObject(int level) const;
void createObject(int level, CGObjectInstance * obj) const;
bool canPlaceObject(int level, CGObjectInstance * obj, QString & error) const;
2023-04-17 01:01:29 +02:00
static ModCompatibilityInfo modAssessmentAll();
static ModCompatibilityInfo modAssessmentMap(const CMap & map);
2022-09-18 01:23:17 +02:00
void undo();
void redo();
PlayerColor defaultPlayer;
private:
std::unique_ptr<CMap> _map;
std::unique_ptr<MapHandler> _mapHandler;
MainWindow * main;
mutable std::array<std::unique_ptr<MapScene>, 2> _scenes;
mutable std::array<std::unique_ptr<MinimapScene>, 2> _miniscenes;
2022-12-04 23:32:50 +02:00
std::vector<std::unique_ptr<CGObjectInstance>> _clipboard;
int _clipboardShiftIndex = 0;
2022-09-18 01:23:17 +02:00
std::map<TerrainId, std::unique_ptr<EditorObstaclePlacer>> _obstaclePainters;
2022-09-18 01:23:17 +02:00
void connectScenes();
};