mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
fixed flickering setting sound menu
This commit is contained in:
parent
c12ec2611f
commit
b2a93432e5
|
@ -1613,20 +1613,8 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
|
|||
UI()->DoLabel(&Label, Localize("Sound"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
|
||||
|
||||
Sound.HSplitTop(Spacing, 0, &Sound);
|
||||
Sound.HSplitTop(ButtonHeight, &Button, &Sound);
|
||||
static int s_ButtonSndEnable = 0;
|
||||
if(DoButton_CheckBox(&s_ButtonSndEnable, Localize("Use sounds"), g_Config.m_SndEnable, &Button))
|
||||
{
|
||||
g_Config.m_SndEnable ^= 1;
|
||||
if(g_Config.m_SndEnable)
|
||||
{
|
||||
g_Config.m_SndInit = 1;
|
||||
if(g_Config.m_SndMusic)
|
||||
m_pClient->m_pSounds->Play(CSounds::CHN_MUSIC, SOUND_MENU, 1.0f);
|
||||
}
|
||||
else
|
||||
m_pClient->m_pSounds->Stop(SOUND_MENU);
|
||||
}
|
||||
CUIRect UseSoundButton;
|
||||
Sound.HSplitTop(ButtonHeight, &UseSoundButton, &Sound);
|
||||
|
||||
if(g_Config.m_SndEnable)
|
||||
{
|
||||
|
@ -1710,6 +1698,20 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
|
|||
}
|
||||
}
|
||||
|
||||
static int s_ButtonSndEnable = 0;
|
||||
if(DoButton_CheckBox(&s_ButtonSndEnable, Localize("Use sounds"), g_Config.m_SndEnable, &UseSoundButton))
|
||||
{
|
||||
g_Config.m_SndEnable ^= 1;
|
||||
if(g_Config.m_SndEnable)
|
||||
{
|
||||
g_Config.m_SndInit = 1;
|
||||
if(g_Config.m_SndMusic)
|
||||
m_pClient->m_pSounds->Play(CSounds::CHN_MUSIC, SOUND_MENU, 1.0f);
|
||||
}
|
||||
else
|
||||
m_pClient->m_pSounds->Stop(SOUND_MENU);
|
||||
}
|
||||
|
||||
// reset button
|
||||
MainView.HSplitBottom(60.0f, 0, &BottomView);
|
||||
|
||||
|
|
Loading…
Reference in a new issue