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:
		| @@ -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" /> | ||||
|   | ||||
							
								
								
									
										40
									
								
								lib/mapping/CDrawRoadsOperation.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								lib/mapping/CDrawRoadsOperation.cpp
									
									
									
									
									
										Normal 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"; | ||||
| } | ||||
|  | ||||
							
								
								
									
										30
									
								
								lib/mapping/CDrawRoadsOperation.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								lib/mapping/CDrawRoadsOperation.h
									
									
									
									
									
										Normal 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;	 | ||||
| }; | ||||
| @@ -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)); | ||||
|   | ||||
| @@ -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(); | ||||
|   | ||||
| @@ -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" /> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user