1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Refactor more fields from campaign header

This commit is contained in:
nordsoft
2023-04-17 04:47:54 +04:00
parent 70f4cc5e0f
commit 91b4782a2f
3 changed files with 10 additions and 10 deletions

View File

@@ -29,8 +29,8 @@ CPrologEpilogVideo::CPrologEpilogVideo(CCampaignScenario::SScenarioPrologEpilog
pos = center(Rect(0, 0, 800, 600)); pos = center(Rect(0, 0, 800, 600));
updateShadow(); updateShadow();
CCS->videoh->open(CCampaignHandler::prologVideoName(spe.prologVideo)); CCS->videoh->open(spe.prologVideo);
CCS->musich->playMusic("Music/" + CCampaignHandler::prologMusicName(spe.prologMusic), true, true); CCS->musich->playMusic("Music/" + spe.prologMusic, true, true);
// MPTODO: Custom campaign crashing on this? // MPTODO: Custom campaign crashing on this?
// voiceSoundHandle = CCS->soundh->playSound(CCampaignHandler::prologVoiceName(spe.prologVideo)); // voiceSoundHandle = CCS->soundh->playSound(CCampaignHandler::prologVoiceName(spe.prologVideo));

View File

@@ -254,8 +254,8 @@ CCampaignScenario CCampaignHandler::readScenarioFromJson(JsonNode & reader)
ret.hasPrologEpilog = !identifier.isNull(); ret.hasPrologEpilog = !identifier.isNull();
if(ret.hasPrologEpilog) if(ret.hasPrologEpilog)
{ {
ret.prologVideo = identifier["video"].Integer(); ret.prologVideo = identifier["video"].String();
ret.prologMusic = identifier["music"].Integer(); ret.prologMusic = identifier["music"].String();
ret.prologText = identifier["text"].String(); ret.prologText = identifier["text"].String();
} }
return ret; return ret;
@@ -508,8 +508,8 @@ CCampaignScenario CCampaignHandler::readScenarioFromMemory( CBinaryReader & read
ret.hasPrologEpilog = reader.readUInt8(); ret.hasPrologEpilog = reader.readUInt8();
if(ret.hasPrologEpilog) if(ret.hasPrologEpilog)
{ {
ret.prologVideo = reader.readUInt8(); ret.prologVideo = CCampaignHandler::prologVideoName(reader.readUInt8());
ret.prologMusic = reader.readUInt8(); ret.prologMusic = CCampaignHandler::prologMusicName(reader.readUInt8());
ret.prologText = readLocalizedString(reader, header.filename, header.modName, header.encoding, identifier); ret.prologText = readLocalizedString(reader, header.filename, header.modName, header.encoding, identifier);
} }
return ret; return ret;
@@ -519,7 +519,7 @@ CCampaignScenario CCampaignHandler::readScenarioFromMemory( CBinaryReader & read
ret.conquered = false; ret.conquered = false;
ret.mapName = reader.readBaseString(); ret.mapName = reader.readBaseString();
ret.packedMapSize = reader.readUInt32(); ret.packedMapSize = reader.readUInt32();
if(header.numberOfScenarios > 0) //unholy alliance if(header.numberOfScenarios > 8) //unholy alliance
{ {
ret.loadPreconditionRegions(reader.readUInt16()); ret.loadPreconditionRegions(reader.readUInt16());
} }

View File

@@ -161,8 +161,8 @@ public:
struct DLL_LINKAGE SScenarioPrologEpilog struct DLL_LINKAGE SScenarioPrologEpilog
{ {
bool hasPrologEpilog = false; bool hasPrologEpilog = false;
ui8 prologVideo = 0; // from CmpMovie.txt std::string prologVideo; // from CmpMovie.txt
ui8 prologMusic = 0; // from CmpMusic.txt std::string prologMusic; // from CmpMusic.txt
std::string prologText; std::string prologText;
template <typename Handler> void serialize(Handler &h, const int formatVersion) template <typename Handler> void serialize(Handler &h, const int formatVersion)
@@ -285,11 +285,11 @@ class DLL_LINKAGE CCampaignHandler
/// headerOnly - only header will be decompressed, returned vector wont have any maps /// headerOnly - only header will be decompressed, returned vector wont have any maps
static std::vector<std::vector<ui8>> getFile(std::unique_ptr<CInputStream> file, bool headerOnly); static std::vector<std::vector<ui8>> getFile(std::unique_ptr<CInputStream> file, bool headerOnly);
public:
static std::string prologVideoName(ui8 index); static std::string prologVideoName(ui8 index);
static std::string prologMusicName(ui8 index); static std::string prologMusicName(ui8 index);
static std::string prologVoiceName(ui8 index); static std::string prologVoiceName(ui8 index);
public:
static CCampaignHeader getHeader( const std::string & name); //name - name of appropriate file static CCampaignHeader getHeader( const std::string & name); //name - name of appropriate file
static std::unique_ptr<CCampaign> getCampaign(const std::string & name); //name - name of appropriate file static std::unique_ptr<CCampaign> getCampaign(const std::string & name); //name - name of appropriate file