mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Play correct music file in campaign menu
This commit is contained in:
@@ -112,6 +112,9 @@ CBonusSelection::CBonusSelection()
|
|||||||
else if(getCampaign()->isConquered(scenarioID)) //display as striped
|
else if(getCampaign()->isConquered(scenarioID)) //display as striped
|
||||||
regions.push_back(std::make_shared<CRegion>(scenarioID, false, false, getCampaign()->getRegions()));
|
regions.push_back(std::make_shared<CRegion>(scenarioID, false, false, getCampaign()->getRegions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!getCampaign()->getMusic().empty())
|
||||||
|
CCS->musich->playMusic( "Music/" + getCampaign()->getMusic(), true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBonusSelection::createBonusesIcons()
|
void CBonusSelection::createBonusesIcons()
|
||||||
|
@@ -73,6 +73,13 @@ CCampaignScreen::CCampaignScreen(const JsonNode & config)
|
|||||||
campButtons.push_back(std::make_shared<CCampaignButton>(node));
|
campButtons.push_back(std::make_shared<CCampaignButton>(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCampaignScreen::activate()
|
||||||
|
{
|
||||||
|
CCS->musich->playMusic("Music/MainMenu", true, false);
|
||||||
|
|
||||||
|
CWindowObject::activate();
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<CButton> CCampaignScreen::createExitButton(const JsonNode & button)
|
std::shared_ptr<CButton> CCampaignScreen::createExitButton(const JsonNode & button)
|
||||||
{
|
{
|
||||||
std::pair<std::string, std::string> help;
|
std::pair<std::string, std::string> help;
|
||||||
|
@@ -58,4 +58,6 @@ public:
|
|||||||
enum CampaignSet {ROE, AB, SOD, WOG};
|
enum CampaignSet {ROE, AB, SOD, WOG};
|
||||||
|
|
||||||
CCampaignScreen(const JsonNode & config);
|
CCampaignScreen(const JsonNode & config);
|
||||||
|
|
||||||
|
void activate() override;
|
||||||
};
|
};
|
||||||
|
@@ -150,7 +150,7 @@ void CampaignHandler::readHeaderFromJson(CampaignHeader & ret, JsonNode & reader
|
|||||||
ret.name = reader["name"].String();
|
ret.name = reader["name"].String();
|
||||||
ret.description = reader["description"].String();
|
ret.description = reader["description"].String();
|
||||||
ret.difficultyChoosenByPlayer = reader["allowDifficultySelection"].Bool();
|
ret.difficultyChoosenByPlayer = reader["allowDifficultySelection"].Bool();
|
||||||
//skip ret.music because it's unused in vcmi
|
ret.music = reader["music"].String();
|
||||||
ret.filename = filename;
|
ret.filename = filename;
|
||||||
ret.modName = modName;
|
ret.modName = modName;
|
||||||
ret.encoding = encoding;
|
ret.encoding = encoding;
|
||||||
@@ -386,7 +386,8 @@ void CampaignHandler::readHeaderFromMemory( CampaignHeader & ret, CBinaryReader
|
|||||||
ret.difficultyChoosenByPlayer = reader.readInt8();
|
ret.difficultyChoosenByPlayer = reader.readInt8();
|
||||||
else
|
else
|
||||||
ret.difficultyChoosenByPlayer = false;
|
ret.difficultyChoosenByPlayer = false;
|
||||||
reader.readInt8(); //music - skip as unused
|
|
||||||
|
ret.music = prologMusicName(reader.readInt8());
|
||||||
ret.filename = filename;
|
ret.filename = filename;
|
||||||
ret.modName = modName;
|
ret.modName = modName;
|
||||||
ret.encoding = encoding;
|
ret.encoding = encoding;
|
||||||
|
@@ -149,6 +149,21 @@ std::string CampaignHeader::getFilename() const
|
|||||||
return filename;
|
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
|
const CampaignRegions & CampaignHeader::getRegions() const
|
||||||
{
|
{
|
||||||
return campaignRegions;
|
return campaignRegions;
|
||||||
@@ -304,11 +319,11 @@ std::unique_ptr<CMap> CampaignState::getMap(CampaignScenarioID scenarioId) const
|
|||||||
scenarioId = currentMap.value();
|
scenarioId = currentMap.value();
|
||||||
|
|
||||||
CMapService mapService;
|
CMapService mapService;
|
||||||
std::string scenarioName = filename.substr(0, filename.find('.'));
|
std::string scenarioName = getFilename().substr(0, getFilename().find('.'));
|
||||||
boost::to_lower(scenarioName);
|
boost::to_lower(scenarioName);
|
||||||
scenarioName += ':' + std::to_string(static_cast<int>(scenarioId));
|
scenarioName += ':' + std::to_string(static_cast<int>(scenarioId));
|
||||||
const auto & mapContent = mapPieces.find(scenarioId)->second;
|
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
|
std::unique_ptr<CMapHeader> CampaignState::getMapHeader(CampaignScenarioID scenarioId) const
|
||||||
@@ -317,11 +332,11 @@ std::unique_ptr<CMapHeader> CampaignState::getMapHeader(CampaignScenarioID scena
|
|||||||
scenarioId = currentMap.value();
|
scenarioId = currentMap.value();
|
||||||
|
|
||||||
CMapService mapService;
|
CMapService mapService;
|
||||||
std::string scenarioName = filename.substr(0, filename.find('.'));
|
std::string scenarioName = getFilename().substr(0, getFilename().find('.'));
|
||||||
boost::to_lower(scenarioName);
|
boost::to_lower(scenarioName);
|
||||||
scenarioName += ':' + std::to_string(static_cast<int>(scenarioId));
|
scenarioName += ':' + std::to_string(static_cast<int>(scenarioId));
|
||||||
const auto & mapContent = mapPieces.find(scenarioId)->second;
|
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
|
std::shared_ptr<CMapInfo> CampaignState::getMapInfo(CampaignScenarioID scenarioId) const
|
||||||
@@ -330,7 +345,7 @@ std::shared_ptr<CMapInfo> CampaignState::getMapInfo(CampaignScenarioID scenarioI
|
|||||||
scenarioId = currentMap.value();
|
scenarioId = currentMap.value();
|
||||||
|
|
||||||
auto mapInfo = std::make_shared<CMapInfo>();
|
auto mapInfo = std::make_shared<CMapInfo>();
|
||||||
mapInfo->fileURI = filename;
|
mapInfo->fileURI = getFilename();
|
||||||
mapInfo->mapHeader = getMapHeader(scenarioId);
|
mapInfo->mapHeader = getMapHeader(scenarioId);
|
||||||
mapInfo->countPlayers();
|
mapInfo->countPlayers();
|
||||||
return mapInfo;
|
return mapInfo;
|
||||||
|
@@ -71,20 +71,20 @@ class DLL_LINKAGE CampaignHeader : public boost::noncopyable
|
|||||||
{
|
{
|
||||||
friend class CampaignHandler;
|
friend class CampaignHandler;
|
||||||
|
|
||||||
int numberOfScenarios = 0;
|
|
||||||
CampaignVersion version = CampaignVersion::NONE;
|
CampaignVersion version = CampaignVersion::NONE;
|
||||||
CampaignRegions campaignRegions;
|
CampaignRegions campaignRegions;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string description;
|
std::string description;
|
||||||
bool difficultyChoosenByPlayer = false;
|
std::string music;
|
||||||
|
|
||||||
void loadLegacyData(ui8 campId);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::string filename;
|
std::string filename;
|
||||||
std::string modName;
|
std::string modName;
|
||||||
std::string encoding;
|
std::string encoding;
|
||||||
|
|
||||||
|
int numberOfScenarios = 0;
|
||||||
|
bool difficultyChoosenByPlayer = false;
|
||||||
|
|
||||||
|
void loadLegacyData(ui8 campId);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool playerSelectedDifficulty() const;
|
bool playerSelectedDifficulty() const;
|
||||||
bool formatVCMI() const;
|
bool formatVCMI() const;
|
||||||
@@ -92,6 +92,9 @@ public:
|
|||||||
std::string getDescription() const;
|
std::string getDescription() const;
|
||||||
std::string getName() const;
|
std::string getName() const;
|
||||||
std::string getFilename() const;
|
std::string getFilename() const;
|
||||||
|
std::string getModName() const;
|
||||||
|
std::string getEncoding() const;
|
||||||
|
std::string getMusic() const;
|
||||||
|
|
||||||
const CampaignRegions & getRegions() const;
|
const CampaignRegions & getRegions() const;
|
||||||
|
|
||||||
@@ -105,6 +108,7 @@ public:
|
|||||||
h & difficultyChoosenByPlayer;
|
h & difficultyChoosenByPlayer;
|
||||||
h & filename;
|
h & filename;
|
||||||
h & modName;
|
h & modName;
|
||||||
|
h & music;
|
||||||
h & encoding;
|
h & encoding;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user