1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

set values for map editor and rmg

This commit is contained in:
Laserlicht
2024-06-29 14:01:25 +02:00
parent 02bd52041b
commit 018127b236
6 changed files with 21 additions and 5 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -137,6 +137,13 @@ std::unique_ptr<CMap> CMapGenerator::generate()
throw; throw;
} }
Load::Progress::finish(); 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); return std::move(map->mapInstance);
} }

View File

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