mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Load sounds for new terrains later
This commit is contained in:
parent
494b0f0226
commit
11e1bb44a2
@ -115,17 +115,21 @@ CSoundHandler::CSoundHandler():
|
|||||||
{Terrain::WATER, soundBase::horseWater},
|
{Terrain::WATER, soundBase::horseWater},
|
||||||
{Terrain::ROCK, soundBase::horseRock}
|
{Terrain::ROCK, soundBase::horseRock}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSoundHandler::loadHorseSounds()
|
||||||
|
{
|
||||||
auto terrains = CGI->terrainTypeHandler->terrains();
|
auto terrains = CGI->terrainTypeHandler->terrains();
|
||||||
for(const auto * terrain : terrains)
|
for(const auto * terrain : terrains)
|
||||||
{
|
{
|
||||||
//since all sounds are hardcoded, let's keep it
|
//since all sounds are hardcoded, let's keep it
|
||||||
if(vstd::contains(horseSounds, terrain->id))
|
if(vstd::contains(horseSounds, terrain->id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//Use already existing horse sound
|
//Use already existing horse sound
|
||||||
horseSounds[terrain->id] = horseSounds.at(terrains[terrain->id]->horseSoundId);
|
horseSounds[terrain->id] = horseSounds.at(terrains[terrain->id]->horseSoundId);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
void CSoundHandler::init()
|
void CSoundHandler::init()
|
||||||
{
|
{
|
||||||
@ -368,7 +372,11 @@ CMusicHandler::CMusicHandler():
|
|||||||
addEntryToSet("enemy-turn", file.getName(), file.getName());
|
addEntryToSet("enemy-turn", file.getName(), file.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const auto * terrain : CGI->terrainTypeHandler->terrains())
|
}
|
||||||
|
|
||||||
|
void CMusicHandler::loadTerrainSounds()
|
||||||
|
{
|
||||||
|
for (const auto* terrain : CGI->terrainTypeHandler->terrains())
|
||||||
{
|
{
|
||||||
addEntryToSet("terrain", terrain->name, "Music/" + terrain->musicFilename);
|
addEntryToSet("terrain", terrain->name, "Music/" + terrain->musicFilename);
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@ public:
|
|||||||
CSoundHandler();
|
CSoundHandler();
|
||||||
|
|
||||||
void init() override;
|
void init() override;
|
||||||
|
void loadHorseSounds();
|
||||||
void release() override;
|
void release() override;
|
||||||
|
|
||||||
void setVolume(ui32 percent) override;
|
void setVolume(ui32 percent) override;
|
||||||
@ -139,6 +140,7 @@ public:
|
|||||||
void addEntryToSet(const std::string & set, const std::string & entryID, const std::string & musicURI);
|
void addEntryToSet(const std::string & set, const std::string & entryID, const std::string & musicURI);
|
||||||
|
|
||||||
void init() override;
|
void init() override;
|
||||||
|
void loadTerrainSounds();
|
||||||
void release() override;
|
void release() override;
|
||||||
void setVolume(ui32 percent) override;
|
void setVolume(ui32 percent) override;
|
||||||
|
|
||||||
|
@ -152,6 +152,10 @@ void CPlayerInterface::init(std::shared_ptr<Environment> ENV, std::shared_ptr<CC
|
|||||||
{
|
{
|
||||||
cb = CB;
|
cb = CB;
|
||||||
env = ENV;
|
env = ENV;
|
||||||
|
|
||||||
|
CCS->soundh->loadHorseSounds();
|
||||||
|
CCS->musich->loadTerrainSounds();
|
||||||
|
|
||||||
initializeHeroTownList();
|
initializeHeroTownList();
|
||||||
|
|
||||||
// always recreate advmap interface to avoid possible memory-corruption bugs
|
// always recreate advmap interface to avoid possible memory-corruption bugs
|
||||||
|
@ -96,7 +96,7 @@ TerrainTypeHandler::TerrainTypeHandler()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info->horseSoundId = terr.second["horseSoundId"].Integer();
|
info->horseSoundId = terr.second["horseSoundId"].Float();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!terr.second["text"].isNull())
|
if(!terr.second["text"].isNull())
|
||||||
|
Loading…
Reference in New Issue
Block a user