diff --git a/client/lobby/CBonusSelection.cpp b/client/lobby/CBonusSelection.cpp index ba6b530f7..e6de278b1 100644 --- a/client/lobby/CBonusSelection.cpp +++ b/client/lobby/CBonusSelection.cpp @@ -71,14 +71,16 @@ CampaignIntroVideo::CampaignIntroVideo(VideoPath video, ImagePath rim, std::shar videoPlayer = std::make_shared(Point(80, 186), video, true, [this](){ exit(); }); setBackground(rim); - audioVol = CCS->musich->getVolume(); - CCS->musich->setVolume(0); + CCS->musich->stopMusic(); } void CampaignIntroVideo::exit() { close(); - CCS->musich->setVolume(audioVol); + + if (!CSH->si->campState->getMusic().empty()) + CCS->musich->playMusic(CSH->si->campState->getMusic(), true, false); + GH.windows().pushWindow(bonusSel); } @@ -127,7 +129,9 @@ CBonusSelection::CBonusSelection() labelCampaignDescription = std::make_shared(481, 63, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[38]); campaignDescription = std::make_shared(getCampaign()->getDescriptionTranslated(), Rect(480, 86, 286, 117), 1); - mapName = std::make_shared(481, 219, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW, CSH->mi->getNameTranslated(), CSH->getState() == EClientState::GAMEPLAY ? 225 : 285); //if video button active theres fewer space + bool videoButtonActive = CSH->getState() == EClientState::GAMEPLAY; + int availableSpace = videoButtonActive ? 225 : 285; + mapName = std::make_shared(481, 219, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW, CSH->mi->getNameTranslated(), availableSpace ); labelMapDescription = std::make_shared(481, 253, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[496]); mapDescription = std::make_shared("", Rect(480, 278, 292, 108), 1); diff --git a/client/lobby/CBonusSelection.h b/client/lobby/CBonusSelection.h index 9f6d021f9..e6b486390 100644 --- a/client/lobby/CBonusSelection.h +++ b/client/lobby/CBonusSelection.h @@ -38,8 +38,6 @@ class CampaignIntroVideo : public CWindowObject std::shared_ptr videoPlayer; std::shared_ptr bonusSel; - ui32 audioVol; - void exit(); public: CampaignIntroVideo(VideoPath video, ImagePath rim, std::shared_ptr bonusSel); diff --git a/config/heroes/portraits.json b/config/heroes/portraits.json index 8b3fe59e1..ce95735df 100644 --- a/config/heroes/portraits.json +++ b/config/heroes/portraits.json @@ -206,7 +206,7 @@ "portraitTarnumBarbarian" : { "class" : "barbarian", - "special" : false, + "special" : true, "images": { "large" : "Hc_HPL137", "small" : "Hc_HPS137", @@ -235,7 +235,7 @@ "portraitTarnumKnight" : { "class" : "knight", - "special" : false, + "special" : true, "images": { "large" : "Hc_HPL138", "small" : "Hc_HPS138", @@ -264,7 +264,7 @@ "portraitTarnumWizard" : { "class" : "wizard", - "special" : false, + "special" : true, "images": { "large" : "Hc_HPL139", "small" : "Hc_HPS139", @@ -293,7 +293,7 @@ "portraitTarnumRanger" : { "class" : "ranger", - "special" : false, + "special" : true, "images": { "large" : "Hc_HPL140", "small" : "Hc_HPS140", @@ -322,7 +322,7 @@ "portraitTarnumOverlord" : { "class" : "overlord", - "special" : false, + "special" : true, "images": { "large" : "Hc_HPL141", "small" : "Hc_HPS141", @@ -351,7 +351,7 @@ "portraitTarnumBeastmaster" : { "class" : "beastmaster", - "special" : false, + "special" : true, "images": { "large" : "Hc_HPL142", "small" : "Hc_HPS142", diff --git a/lib/campaign/CampaignHandler.cpp b/lib/campaign/CampaignHandler.cpp index 394e48411..5c7110e00 100644 --- a/lib/campaign/CampaignHandler.cpp +++ b/lib/campaign/CampaignHandler.cpp @@ -38,14 +38,14 @@ void CampaignHandler::readCampaign(Campaign * ret, const std::vector & inpu CBinaryReader reader(&stream); readHeaderFromMemory(*ret, reader, filename, modName, encoding); - ret->overrideCampaign(false); + ret->overrideCampaign(); for(int g = 0; g < ret->numberOfScenarios; ++g) { auto scenarioID = static_cast(ret->scenarios.size()); ret->scenarios[scenarioID] = readScenarioFromMemory(reader, *ret); } - ret->overrideCampaign(true); + ret->overrideCampaignScenarios(); } else // text format (json) { @@ -397,7 +397,7 @@ void CampaignHandler::readHeaderFromMemory( CampaignHeader & ret, CBinaryReader { ret.version = static_cast(reader.readUInt32()); ui8 campId = reader.readUInt8() - 1;//change range of it from [1, 20] to [0, 19] - if(ret.version != CampaignVersion::Chr) + if(ret.version != CampaignVersion::Chr) // For chronicles: Will be overridden later; Chronicles uses own logic (reusing OH3 ID's) ret.loadLegacyData(campId); ret.name.appendTextID(readLocalizedString(ret, reader, filename, modName, encoding, "name")); ret.description.appendTextID(readLocalizedString(ret, reader, filename, modName, encoding, "description")); diff --git a/lib/campaign/CampaignState.cpp b/lib/campaign/CampaignState.cpp index 45a7b6161..f1fa305cb 100644 --- a/lib/campaign/CampaignState.cpp +++ b/lib/campaign/CampaignState.cpp @@ -477,37 +477,40 @@ std::set Campaign::allScenarios() const return result; } -void Campaign::overrideCampaign(bool scenario) +void Campaign::overrideCampaign() { - JsonNode node = JsonUtils::assembleFromFiles("config/campaignOverrides.json"); + const 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()); + if(!entry.second["loadingBackground"].isNull()) + loadingBackground = ImagePath::builtin(entry.second["loadingBackground"].String()); + if(!entry.second["introVideoRim"].isNull()) + introVideoRim = ImagePath::builtin(entry.second["introVideoRim"].String()); + if(!entry.second["introVideo"].isNull()) + introVideo = VideoPath::builtin(entry.second["introVideo"].String()); + } +} + +void Campaign::overrideCampaignScenarios() +{ + const JsonNode node = JsonUtils::assembleFromFiles("config/campaignOverrides.json"); + for (auto & entry : node.Struct()) + if(filename == entry.first) + { + if(!entry.second["scenarios"].isNull()) { - if(!entry.second["regions"].isNull() && !entry.second["scenarioCount"].isNull()) - loadLegacyData(CampaignRegions::fromJson(entry.second["regions"]), entry.second["scenarioCount"].Integer()); - if(!entry.second["loadingBackground"].isNull()) - loadingBackground = ImagePath::builtin(entry.second["loadingBackground"].String()); - if(!entry.second["introVideoRim"].isNull()) - introVideoRim = ImagePath::builtin(entry.second["introVideoRim"].String()); - if(!entry.second["introVideo"].isNull()) - introVideo = VideoPath::builtin(entry.second["introVideo"].String()); - } - else - { - if(!entry.second["scenarios"].isNull()) + auto sc = entry.second["scenarios"].Vector(); + for(int i = 0; i < sc.size(); i++) { - 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()); - } + 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()); } } } diff --git a/lib/campaign/CampaignState.h b/lib/campaign/CampaignState.h index 66f1dafad..303e7428e 100644 --- a/lib/campaign/CampaignState.h +++ b/lib/campaign/CampaignState.h @@ -261,7 +261,8 @@ public: std::set allScenarios() const; int scenariosCount() const; - void overrideCampaign(bool scenario); + void overrideCampaign(); + void overrideCampaignScenarios(); template void serialize(Handler &h) { diff --git a/lib/filesystem/CArchiveLoader.cpp b/lib/filesystem/CArchiveLoader.cpp index ec640e18d..e253de615 100644 --- a/lib/filesystem/CArchiveLoader.cpp +++ b/lib/filesystem/CArchiveLoader.cpp @@ -197,7 +197,7 @@ std::string CArchiveLoader::getMountPoint() const return mountPoint; } -std::unordered_map CArchiveLoader::getEntries() const +const std::unordered_map & CArchiveLoader::getEntries() const { return entries; } diff --git a/lib/filesystem/CArchiveLoader.h b/lib/filesystem/CArchiveLoader.h index f0c88b47c..d8797d7a5 100644 --- a/lib/filesystem/CArchiveLoader.h +++ b/lib/filesystem/CArchiveLoader.h @@ -63,7 +63,7 @@ public: std::unique_ptr load(const ResourcePath & resourceName) const override; bool existsResource(const ResourcePath & resourceName) const override; std::string getMountPoint() const override; - std::unordered_map getEntries() const; + const std::unordered_map & getEntries() const; void updateFilteredFiles(std::function filter) const override {} std::unordered_set getFilteredFiles(std::function filter) const override; /** Extracts one archive entry to the specified subfolder. Used for Video and Sound */