コード例 #1
0
ファイル: UnitDefHandler.cpp プロジェクト: Dmytry/spring
void CUnitDefHandler::LoadSound(GuiSoundSet& gsound,
                                const string& fileName, const float volume)
{
	CFileHandler raw(fileName);
	if (!sound->HasSoundItem(fileName) && !raw.FileExists())
	{
		string soundFile = "sounds/" + fileName;

		if (soundFile.find(".wav") == string::npos && soundFile.find(".ogg") == string::npos) {
			// .wav extension missing, add it
			soundFile += ".wav";
		}
		CFileHandler fh(soundFile);
		if (fh.FileExists()) {
			// we have a valid soundfile: store name, ID, and default volume
			const int id = sound->GetSoundId(soundFile);
			GuiSoundSet::Data soundData(fileName, id, volume);
			gsound.sounds.push_back(soundData);
		}
	}
	else
	{
		const int id = sound->GetSoundId(fileName);
		GuiSoundSet::Data soundData(fileName, id, volume);
		gsound.sounds.push_back(soundData);
	}
}
コード例 #2
0
ファイル: UnitDefHandler.cpp プロジェクト: BrainDamage/spring
void CUnitDefHandler::LoadSound(GuiSoundSet& gsound, const string& fileName, const float volume)
{
	const int id = LoadSoundFile(fileName);
	if (id > 0)
	{
		GuiSoundSet::Data soundData(fileName, id, volume);
		gsound.sounds.push_back(soundData);
	}
}