1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

voice override

This commit is contained in:
Laserlicht 2024-08-31 14:17:25 +02:00
parent e4ec26e613
commit 2fef4b5d69
5 changed files with 48 additions and 13 deletions

View File

@ -4,7 +4,7 @@
{
"background": "Hc1_CamBkHc",
"prefix": "Hc1_HcSc",
"suffix": ["_1", "_2", "_3"],
"suffix": ["1", "2", "3"],
"color_suffix_length": 0,
"desc": [
{ "infix": "1", "x": 27, "y": 43 },
@ -17,6 +17,16 @@
{ "infix": "8", "x": 225, "y": 433 }
]
},
"scenarioCount": 8
"scenarioCount": 8,
"scenarios": [
{ "voiceProlog": "Hc1_ABvoFL4" },
{ "voiceProlog": "Hc1_H3x2UAe" },
{ "voiceProlog": "Hc1_H3x2BBa" },
{ "voiceProlog": "Hc1_H3x2RNd" },
{ "voiceProlog": "Hc1_G1C" },
{ "voiceProlog": "Hc1_G2C" },
{ "voiceProlog": "Hc1_ABvoFL3" },
{ "voiceProlog": "Hc1_H3x2BBf", "voiceEpilog": "Hc1_N1C_D" }
]
}
}

View File

@ -38,13 +38,14 @@ void CampaignHandler::readCampaign(Campaign * ret, const std::vector<ui8> & inpu
CBinaryReader reader(&stream);
readHeaderFromMemory(*ret, reader, filename, modName, encoding);
ret->overrideCampaign();
ret->overrideCampaign(false);
for(int g = 0; g < ret->numberOfScenarios; ++g)
{
auto scenarioID = static_cast<CampaignScenarioID>(ret->scenarios.size());
ret->scenarios[scenarioID] = readScenarioFromMemory(reader, *ret);
}
ret->overrideCampaign(true);
}
else // text format (json)
{

View File

@ -145,14 +145,6 @@ void CampaignHeader::loadLegacyData(CampaignRegions regions, int numOfScenario)
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;
@ -470,6 +462,36 @@ std::set<CampaignScenarioID> Campaign::allScenarios() const
return result;
}
void Campaign::overrideCampaign(bool scenario)
{
JsonNode node = JsonUtils::assembleFromFiles("config/campaignOverrides.json");
for (auto & entry : node.Struct())
if(filename == entry.first)
{
if(!scenario)
{
if(!entry.second["regions"].isNull() && !entry.second["scenarioCount"].isNull())
loadLegacyData(CampaignRegions::fromJson(entry.second["regions"]), entry.second["scenarioCount"].Integer());
}
else
{
if(!entry.second["scenarios"].isNull())
{
auto sc = entry.second["scenarios"].Vector();
for(int i = 0; i < sc.size(); i++)
{
auto it = scenarios.begin();
std::advance(it, i);
if(!sc.at(i)["voiceProlog"].isNull())
it->second.prolog.prologVoice = AudioPath::builtin(sc.at(i)["voiceProlog"].String());
if(!sc.at(i)["voiceEpilog"].isNull())
it->second.epilog.prologVoice = AudioPath::builtin(sc.at(i)["voiceEpilog"].String());
}
}
}
}
}
int Campaign::scenariosCount() const
{
return allScenarios().size();

View File

@ -83,6 +83,7 @@ public:
class DLL_LINKAGE CampaignHeader : public boost::noncopyable
{
friend class CampaignHandler;
friend class Campaign;
CampaignVersion version = CampaignVersion::NONE;
CampaignRegions campaignRegions;
@ -123,8 +124,6 @@ public:
const CampaignRegions & getRegions() const;
TextContainerRegistrable & getTexts();
void overrideCampaign();
template <typename Handler> void serialize(Handler &h)
{
h & version;
@ -251,6 +250,8 @@ public:
std::set<CampaignScenarioID> allScenarios() const;
int scenariosCount() const;
void overrideCampaign(bool scenario);
template <typename Handler> void serialize(Handler &h)
{
h & static_cast<CampaignHeader&>(*this);

View File

@ -161,6 +161,7 @@ static std::map<EMapFormat, MapIdentifiersH3M> generateMappings()
addMapping(EMapFormat::ROE);
addMapping(EMapFormat::AB);
addMapping(EMapFormat::SOD);
addMapping(EMapFormat::CHR);
addMapping(EMapFormat::HOTA);
addMapping(EMapFormat::WOG);