1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Play correct music file in campaign menu

This commit is contained in:
Ivan Savenko
2023-06-27 20:09:11 +03:00
parent 0fdbf54937
commit cdc27d1fcf
6 changed files with 45 additions and 13 deletions

View File

@@ -149,6 +149,21 @@ std::string CampaignHeader::getFilename() const
return filename;
}
std::string CampaignHeader::getModName() const
{
return modName;
}
std::string CampaignHeader::getEncoding() const
{
return encoding;
}
std::string CampaignHeader::getMusic() const
{
return music;
}
const CampaignRegions & CampaignHeader::getRegions() const
{
return campaignRegions;
@@ -304,11 +319,11 @@ std::unique_ptr<CMap> CampaignState::getMap(CampaignScenarioID scenarioId) const
scenarioId = currentMap.value();
CMapService mapService;
std::string scenarioName = filename.substr(0, filename.find('.'));
std::string scenarioName = getFilename().substr(0, getFilename().find('.'));
boost::to_lower(scenarioName);
scenarioName += ':' + std::to_string(static_cast<int>(scenarioId));
const auto & mapContent = mapPieces.find(scenarioId)->second;
return mapService.loadMap(mapContent.data(), mapContent.size(), scenarioName, modName, encoding);
return mapService.loadMap(mapContent.data(), mapContent.size(), scenarioName, getModName(), getEncoding());
}
std::unique_ptr<CMapHeader> CampaignState::getMapHeader(CampaignScenarioID scenarioId) const
@@ -317,11 +332,11 @@ std::unique_ptr<CMapHeader> CampaignState::getMapHeader(CampaignScenarioID scena
scenarioId = currentMap.value();
CMapService mapService;
std::string scenarioName = filename.substr(0, filename.find('.'));
std::string scenarioName = getFilename().substr(0, getFilename().find('.'));
boost::to_lower(scenarioName);
scenarioName += ':' + std::to_string(static_cast<int>(scenarioId));
const auto & mapContent = mapPieces.find(scenarioId)->second;
return mapService.loadMapHeader(mapContent.data(), mapContent.size(), scenarioName, modName, encoding);
return mapService.loadMapHeader(mapContent.data(), mapContent.size(), scenarioName, getModName(), getEncoding());
}
std::shared_ptr<CMapInfo> CampaignState::getMapInfo(CampaignScenarioID scenarioId) const
@@ -330,7 +345,7 @@ std::shared_ptr<CMapInfo> CampaignState::getMapInfo(CampaignScenarioID scenarioI
scenarioId = currentMap.value();
auto mapInfo = std::make_shared<CMapInfo>();
mapInfo->fileURI = filename;
mapInfo->fileURI = getFilename();
mapInfo->mapHeader = getMapHeader(scenarioId);
mapInfo->countPlayers();
return mapInfo;