fix: main menu music transition, tutorial keyboard images

This commit is contained in:
Fireblade
2026-08-02 16:25:11 -04:00
parent 432024f6ca
commit f8a4de8afd
5 changed files with 27 additions and 2 deletions
@@ -82,6 +82,7 @@ void SoundEngine::stopStreamingNow()
m_StreamState = eMusicStreamState_Idle;
m_musicID = -1;
m_iMusicDelay = 0;
m_bCurrentStreamIsMenuMusic = false;
}
#ifdef _WINDOWS64
@@ -470,6 +471,7 @@ SoundEngine::SoundEngine()
m_musicFadeSecondsRemaining = 0.0f;
m_musicFadeLastUpdateTime = std::chrono::steady_clock::now();
m_bCurrentStreamIsCustom = false;
m_bCurrentStreamIsMenuMusic = true;
memset(CurrentSoundsPlaying,0,sizeof(int)*(eSoundType_MAX+eSFX_MAX));
memset(m_ListenerA,0,sizeof(AUDIO_LISTENER)*XUSER_MAX_COUNT);
@@ -847,6 +849,11 @@ void SoundEngine::playStreaming(const wstring& name, float x, float y, float z,
m_StreamingAudioInfo.volume = volume;
m_StreamingAudioInfo.pitch = pitch;
if (name.empty() && m_musicStreamActive && isPlayingMenuMusic() && !isCustomMusicRequest(name))
{
return;
}
bool bNextCustom = isCustomMusicRequest(name);
bool bCurrentCustom = m_musicStreamActive && m_bCurrentStreamIsCustom;
@@ -868,6 +875,7 @@ void SoundEngine::playStreaming(const wstring& name, float x, float y, float z,
{
// music, or stop CD
m_StreamingAudioInfo.bIs3D = false;
m_bCurrentStreamIsMenuMusic = false;
// random delay of up to 3 minutes for music
m_iMusicDelay = random->nextInt(20 * 60 * 3);
@@ -921,6 +929,7 @@ void SoundEngine::playStreaming(const wstring& name, float x, float y, float z,
{
// jukebox
m_StreamingAudioInfo.bIs3D=true;
m_bCurrentStreamIsMenuMusic = false;
m_musicID = getMusicID(name);
m_iMusicDelay = 0;
@@ -933,6 +942,11 @@ void SoundEngine::playStreaming(const wstring& name, float x, float y, float z,
}
}
bool SoundEngine::isPlayingMenuMusic() const
{
return m_musicStreamActive && m_bCurrentStreamIsMenuMusic;
}
bool SoundEngine::isCustomMusicRequest(const wstring& name) const
{
if (!name.empty())
@@ -136,6 +136,7 @@ public:
void stopElytraSound();
void playStreaming(const wstring& name, float x, float y , float z, float volume, float pitch, bool bMusicDelay=true) override;
void stopStreamingNow();
bool isPlayingMenuMusic() const;
void playUI(int iSound, float volume, float pitch) override;
void playMusicTick() override;
void updateMusicVolume(float fVal) override;
@@ -173,6 +174,7 @@ private:
float m_musicFadeSecondsRemaining;
std::chrono::steady_clock::time_point m_musicFadeLastUpdateTime;
bool m_bCurrentStreamIsCustom;
bool m_bCurrentStreamIsMenuMusic;
ma_engine m_engine;
ma_engine_config m_engineConfig;
+11 -2
View File
@@ -4563,8 +4563,17 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt
// Stop menu music and transition to game music for the new level
if (soundEngine != nullptr)
{
soundEngine->stopStreamingNow();
soundEngine->playStreaming(L"", 0, 0, 0, 1, 1);
const bool hasCustomMusic = (Minecraft::GetInstance() != nullptr &&
Minecraft::GetInstance()->skins != nullptr &&
Minecraft::GetInstance()->skins->getSelected() != nullptr &&
Minecraft::GetInstance()->skins->getSelected()->hasAudio());
const bool isMenuMusic = soundEngine->isPlayingMenuMusic();
if (hasCustomMusic || !isMenuMusic)
{
soundEngine->stopStreamingNow();
soundEngine->playStreaming(L"", 0, 0, 0, 1, 1);
}
}
// 4J - stop update thread from processing this level, which blocks until it is safe to move on - will be re-enabled if we set the level to be non-nullptr