mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-08 03:28:03 +03:00
Refactor and fix sound code
This commit is contained in:
parent
feae212cef
commit
d470cdcf01
11 changed files with 240 additions and 238 deletions
|
@ -172,12 +172,14 @@ void GameFlow::SetGameFarView(byte val)
|
|||
void GameFlow::SetAudioTracks(sol::as_table_t<std::vector<GameScriptAudioTrack>>&& src)
|
||||
{
|
||||
std::vector<GameScriptAudioTrack> tracks = std::move(src);
|
||||
SoundTracks.clear();
|
||||
|
||||
for (auto t : tracks) {
|
||||
AudioTrack track;
|
||||
SoundTrackInfo track;
|
||||
track.Name = t.trackName;
|
||||
track.Mask = 0;
|
||||
track.looped = t.looped;
|
||||
SoundTracks.insert_or_assign(track.Name, track);
|
||||
track.Mode = t.looped ? SOUNDTRACK_PLAYTYPE::BGM : SOUNDTRACK_PLAYTYPE::OneShot;
|
||||
SoundTracks.push_back(track);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ Functions and callbacks for level-specific logic scripts.
|
|||
|
||||
static void PlayAudioTrack(std::string const & trackName, sol::optional<bool> looped)
|
||||
{
|
||||
PlaySoundTrack(trackName, looped.value_or(SOUND_TRACK_ONESHOT));
|
||||
auto mode = looped.value_or(false) ? SOUNDTRACK_PLAYTYPE::OneShot : SOUNDTRACK_PLAYTYPE::BGM;
|
||||
PlaySoundTrack(trackName, mode);
|
||||
}
|
||||
|
||||
static void PlaySoundEffect(int id, GameScriptPosition p, int flags)
|
||||
|
@ -54,7 +55,7 @@ static void PlaySoundEffect(int id, int flags)
|
|||
|
||||
static void SetAmbientTrack(std::string const & trackName)
|
||||
{
|
||||
PlaySoundTrack(trackName, SOUND_TRACK_BGM);
|
||||
PlaySoundTrack(trackName, SOUNDTRACK_PLAYTYPE::BGM);
|
||||
}
|
||||
|
||||
static int FindRoomNumber(GameScriptPosition pos)
|
||||
|
@ -516,8 +517,8 @@ void AddOneSecret()
|
|||
{
|
||||
if (Savegame.Level.Secrets >= 255)
|
||||
return;
|
||||
Savegame.Level.Secrets++;
|
||||
PlaySoundTrack(TRACK_FOUND_SECRET, SOUND_TRACK_ONESHOT);
|
||||
Savegame.Level.Secrets++;
|
||||
PlaySecretTrack();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue