diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-30 12:02:00 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-30 12:02:00 +1000 |
commit | ee2e134bbf2327389973aa6f035ad227cbd4f389 (patch) | |
tree | 1cd03002a735b2641a7e3dc6e79a6c61565e391c /source/frontend | |
parent | 33b980dacb84cfc0e90d07032a8e53c9d8636b55 (diff) |
Title music fades in/out
Diffstat (limited to 'source/frontend')
-rw-r--r-- | source/frontend/StarTitleScreen.cpp | 7 | ||||
-rw-r--r-- | source/frontend/StarTitleScreen.hpp | 1 |
2 files changed, 7 insertions, 1 deletions
diff --git a/source/frontend/StarTitleScreen.cpp b/source/frontend/StarTitleScreen.cpp index e7fa573..842efc9 100644 --- a/source/frontend/StarTitleScreen.cpp +++ b/source/frontend/StarTitleScreen.cpp @@ -126,7 +126,9 @@ void TitleScreen::update() { if (!finishedState()) { if (auto audioSample = m_musicTrackManager.updateAmbient(m_musicTrack, m_skyBackdrop->isDayTime())) { + m_currentMusicTrack = audioSample; audioSample->setMixerGroup(MixerGroup::Music); + audioSample->setLoops(0); m_mixer->play(audioSample); } } @@ -153,6 +155,8 @@ bool TitleScreen::finishedState() const { void TitleScreen::resetState() { switchState(TitleState::Main); + if (m_currentMusicTrack) + m_currentMusicTrack->setVolume(1.0f, 4.0f); } void TitleScreen::goToMultiPlayerSelectCharacter(bool skipConnection) { @@ -161,7 +165,8 @@ void TitleScreen::goToMultiPlayerSelectCharacter(bool skipConnection) { } void TitleScreen::stopMusic() { - m_musicTrackManager.cancelAll(); + if (m_currentMusicTrack) + m_currentMusicTrack->stop(8.0f); } PlayerPtr TitleScreen::currentlySelectedPlayer() const { diff --git a/source/frontend/StarTitleScreen.hpp b/source/frontend/StarTitleScreen.hpp index baad200..5ce000d 100644 --- a/source/frontend/StarTitleScreen.hpp +++ b/source/frontend/StarTitleScreen.hpp @@ -124,6 +124,7 @@ private: SkyPtr m_skyBackdrop; AmbientNoisesDescriptionPtr m_musicTrack; + AudioInstancePtr m_currentMusicTrack; AmbientManager m_musicTrackManager; }; |