Sfoglia il codice sorgente

set values for map editor and rmg

Laserlicht 1 anno fa
parent
commit
018127b236

+ 1 - 1
config/widgets/mapOverview.json

@@ -41,7 +41,7 @@
 			"alignment": "right",
 			"color": "green",
 			"text": "",
-			"position": {"x": 418, "y": 40}
+			"position": {"x": 418, "y": 48}
 		},
 		{
 			"type": "boxWithBackground",

+ 8 - 0
docs/modders/Campaign_Format.md

@@ -35,12 +35,20 @@ In header are parameters describing campaign properties
     "regions": {...},
     "name": "Campaign name",
     "description": "Campaign description",
+    "author": "Author",
+    "authorContact": "Author contact",
+    "campaignVersion": "Campaign version",
+    "creationDateTime": "Creation date and time",
     "allowDifficultySelection": true, 
 ```
 
 - `"regions"` contains information about background and regions. See section [campaign regions](#regions-description) for more information
 - `"name"` is a human readable title of campaign
 - `"description"` is a human readable description of campaign
+- `"author"` is the author of the campaign
+- `"authorContact"` is a contact address for the author (e.g. email)
+- `"campaignVersion"` is creator defined version
+- `"creationDateTime"` unix time of campaign creation
 - `"allowDifficultySelection"` is a boolean field (`true`/`false`) which allows or disallows to choose difficulty before scenario start
 
 # Scenario description

+ 2 - 2
lib/campaign/CampaignHandler.cpp

@@ -153,7 +153,7 @@ void CampaignHandler::readHeaderFromJson(CampaignHeader & ret, JsonNode & reader
 	ret.description.appendTextID(reader["description"].String());
 	ret.author.appendRawString(reader["author"].String());
 	ret.authorContact.appendRawString(reader["authorContact"].String());
-	ret.mapVersion.appendRawString(reader["mapVersion"].String());
+	ret.campaignVersion.appendRawString(reader["campaignVersion"].String());
 	ret.creationDateTime = reader["creationDateTime"].Integer();
 	ret.difficultyChosenByPlayer = reader["allowDifficultySelection"].Bool();
 	ret.music = AudioPath::fromJson(reader["music"]);
@@ -391,7 +391,7 @@ void CampaignHandler::readHeaderFromMemory( CampaignHeader & ret, CBinaryReader
 	ret.description.appendTextID(readLocalizedString(ret, reader, filename, modName, encoding, "description"));
 	ret.author.appendRawString("");
 	ret.authorContact.appendRawString("");
-	ret.mapVersion.appendRawString("");
+	ret.campaignVersion.appendRawString("");
 	ret.creationDateTime = 0;
 	if (ret.version > CampaignVersion::RoE)
 		ret.difficultyChosenByPlayer = reader.readInt8();

+ 2 - 2
lib/campaign/CampaignState.h

@@ -83,7 +83,7 @@ class DLL_LINKAGE CampaignHeader : public boost::noncopyable
 	MetaString description;
 	MetaString author;
 	MetaString authorContact;
-	MetaString mapVersion;
+	MetaString campaignVersion;
 	std::time_t creationDateTime;
 	AudioPath music;
 	std::string filename;
@@ -122,7 +122,7 @@ public:
 		{
 			h & author;
 			h & authorContact;
-			h & mapVersion;
+			h & campaignVersion;
 			h & creationDateTime;
 		}
 		h & difficultyChosenByPlayer;

+ 7 - 0
lib/rmg/CMapGenerator.cpp

@@ -137,6 +137,13 @@ std::unique_ptr<CMap> CMapGenerator::generate()
 		throw;
 	}
 	Load::Progress::finish();
+
+	map->mapInstance->creationDateTime = std::time(nullptr);
+	map->mapInstance->author = MetaString::createFromTextID("core.genrltxt.740");
+	const auto * mapTemplate = mapGenOptions.getMapTemplate();
+	if(mapTemplate)
+		map->mapInstance->mapVersion = MetaString::createFromRawString(mapTemplate->getName());
+
 	return std::move(map->mapInstance);
 }
 

+ 1 - 0
mapeditor/windownewmap.cpp

@@ -201,6 +201,7 @@ std::unique_ptr<CMap> generateEmptyMap(CMapGenOptions & options)
 {
 	auto map = std::make_unique<CMap>(nullptr);
 	map->version = EMapFormat::VCMI;
+	map->creationDateTime = std::time(nullptr);
 	map->width = options.getWidth();
 	map->height = options.getHeight();
 	map->twoLevel = options.getHasTwoLevels();