1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-10-31 00:07:39 +02:00

Define public interface of CDrawRoadsOperation

This commit is contained in:
AlexVinS
2015-01-03 02:29:42 +03:00
parent e42ca15a0d
commit 877634b3a3
6 changed files with 85 additions and 2 deletions

View File

@@ -231,6 +231,7 @@
<ClCompile Include="mapping\CMapEditManager.cpp" />
<ClCompile Include="mapping\MapFormatH3M.cpp" />
<ClCompile Include="mapping\MapFormatJson.cpp" />
<ClCompile Include="mapping\CDrawRoadsOperation.cpp" />
<ClCompile Include="registerTypes\RegisterTypes.cpp" />
<ClCompile Include="registerTypes\TypesClientPacks1.cpp" />
<ClCompile Include="registerTypes\TypesClientPacks2.cpp" />

View File

@@ -0,0 +1,40 @@
/*
* CDrawRoadsOperation.cpp, 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
*
*/
#include "StdInc.h"
#include "CDrawRoadsOperation.h"
///CDrawRoadsOperation
CDrawRoadsOperation::CDrawRoadsOperation(CMap * map, const CTerrainSelection & terrainSel, ERoadType::ERoadType roadType, CRandomGenerator * gen):
CMapOperation(map),terrainSel(terrainSel), roadType(roadType), gen(gen)
{
}
void CDrawRoadsOperation::execute()
{
}
void CDrawRoadsOperation::undo()
{
//TODO
}
void CDrawRoadsOperation::redo()
{
//TODO
}
std::string CDrawRoadsOperation::getLabel() const
{
return "Draw Roads";
}

View File

@@ -0,0 +1,30 @@
/*
* CDrawRoadsOperation.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
#include "../CRandomGenerator.h"
#include "CMap.h"
#include "CMapEditManager.h"
class CDrawRoadsOperation : public CMapOperation
{
public:
CDrawRoadsOperation(CMap * map, const CTerrainSelection & terrainSel, ERoadType::ERoadType roadType, CRandomGenerator * gen);
void execute() override;
void undo() override;
void redo() override;
std::string getLabel() const override;
private:
CTerrainSelection terrainSel;
ERoadType::ERoadType roadType;
CRandomGenerator * gen;
};

View File

@@ -6,6 +6,7 @@
#include "../mapObjects/CObjectClassesHandler.h"
#include "../mapObjects/CGHeroInstance.h"
#include "../VCMI_Lib.h"
#include "CDrawRoadsOperation.h"
MapRect::MapRect() : x(0), y(0), z(0), width(0), height(0)
{
@@ -226,6 +227,13 @@ void CMapEditManager::drawTerrain(ETerrainType terType, CRandomGenerator * gen/*
terrainSel.clearSelection();
}
void CMapEditManager::drawRoad(ERoadType::ERoadType roadType, CRandomGenerator* gen)
{
execute(make_unique<CDrawRoadsOperation>(map, terrainSel, roadType, gen ? gen : &(this->gen)));
terrainSel.clearSelection();
}
void CMapEditManager::insertObject(CGObjectInstance * obj, const int3 & pos)
{
execute(make_unique<CInsertObjectOperation>(map, obj, pos));

View File

@@ -161,7 +161,11 @@ public:
/// Draws terrain at the current terrain selection. The selection will be cleared automatically.
void drawTerrain(ETerrainType terType, CRandomGenerator * gen = nullptr);
void insertObject(CGObjectInstance * obj, const int3 & pos);
/// Draws roads at the current terrain selection. The selection will be cleared automatically.
void drawRoad(ERoadType::ERoadType roadType, CRandomGenerator * gen = nullptr);
void insertObject(CGObjectInstance * obj, const int3 & pos);
CTerrainSelection & getTerrainSelection();
CObjectSelection & getObjectSelection();

View File

@@ -27,13 +27,13 @@
<Depends filename="lib/VCMI_lib.cbp" />
</Project>
<Project filename="test/Test.cbp">
<Depends filename="client/VCMI_client.cbp" />
<Depends filename="server/VCMI_server.cbp" />
<Depends filename="AI/EmptyAI/EmptyAI.cbp" />
<Depends filename="AI/VCAI/VCAI.cbp" />
<Depends filename="AI/StupidAI/StupidAI.cbp" />
<Depends filename="AI/BattleAI/BattleAI.cbp" />
<Depends filename="lib/VCMI_lib.cbp" />
<Depends filename="client/VCMI_client.cbp" />
</Project>
<Project filename="scripting/erm/ERM.cbp">
<Depends filename="lib/VCMI_lib.cbp" />