1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
This commit is contained in:
Laserlicht 2024-08-31 13:15:07 +02:00
parent 46c169d20f
commit e4ec26e613
5 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,22 @@
{
"MAPS/HC1_MAIN" : { // Heroes Chronicles 1
"regions":
{
"background": "Hc1_CamBkHc",
"prefix": "Hc1_HcSc",
"suffix": ["_1", "_2", "_3"],
"color_suffix_length": 0,
"desc": [
{ "infix": "1", "x": 27, "y": 43 },
{ "infix": "2", "x": 225, "y": 43 },
{ "infix": "3", "x": 27, "y": 173 },
{ "infix": "4", "x": 225, "y": 173 },
{ "infix": "5", "x": 27, "y": 303 },
{ "infix": "6", "x": 225, "y": 303 },
{ "infix": "7", "x": 27, "y": 433 },
{ "infix": "8", "x": 225, "y": 433 }
]
},
"scenarioCount": 8
}
}

View File

@ -203,7 +203,7 @@ void ChroniclesExtractor::extractFiles(int no)
auto rename = [tmpDir, no](QDir dest){
dest.refresh();
for(auto & entry : dest.entryList())
if(!entry.startsWith("Hc"))
if(!entry.startsWith("Hc" + QString::number(no) + "_"))
dest.rename(entry, "Hc" + QString::number(no) + "_" + entry);
};

View File

@ -38,6 +38,7 @@ void CampaignHandler::readCampaign(Campaign * ret, const std::vector<ui8> & inpu
CBinaryReader reader(&stream);
readHeaderFromMemory(*ret, reader, filename, modName, encoding);
ret->overrideCampaign();
for(int g = 0; g < ret->numberOfScenarios; ++g)
{

View File

@ -20,6 +20,7 @@
#include "../mapObjects/CGHeroInstance.h"
#include "../serializer/JsonDeserializer.h"
#include "../serializer/JsonSerializer.h"
#include "../json/JsonUtils.h"
VCMI_LIB_NAMESPACE_BEGIN
@ -138,6 +139,20 @@ void CampaignHeader::loadLegacyData(ui8 campId)
numberOfScenarios = VLC->generaltexth->getCampaignLength(campId);
}
void CampaignHeader::loadLegacyData(CampaignRegions regions, int numOfScenario)
{
campaignRegions = regions;
numberOfScenarios = numOfScenario;
}
void CampaignHeader::overrideCampaign()
{
JsonNode node = JsonUtils::assembleFromFiles("config/campaignOverrides.json");
for (auto & entry : node.Struct())
if(filename == entry.first && !entry.second["regions"].isNull() && !entry.second["scenarioCount"].isNull())
loadLegacyData(CampaignRegions::fromJson(entry.second["regions"]), entry.second["scenarioCount"].Integer());
}
bool CampaignHeader::playerSelectedDifficulty() const
{
return difficultyChosenByPlayer;

View File

@ -101,6 +101,7 @@ class DLL_LINKAGE CampaignHeader : public boost::noncopyable
bool difficultyChosenByPlayer = false;
void loadLegacyData(ui8 campId);
void loadLegacyData(CampaignRegions regions, int numOfScenario);
TextContainerRegistrable textContainer;
@ -122,6 +123,8 @@ public:
const CampaignRegions & getRegions() const;
TextContainerRegistrable & getTexts();
void overrideCampaign();
template <typename Handler> void serialize(Handler &h)
{
h & version;