Abort in RenderSoundNotification if no active notification

This commit is contained in:
Jordy Ruiz 2019-03-08 19:18:37 +01:00
parent 456c4ac79b
commit bc430595eb

View file

@ -38,6 +38,10 @@ void CNotifications::RenderSoundNotification()
const float ItemWidth = 20.f;
const float DisplayTime = 1.5f; // includes FadeTime
const float FadeTime = 0.6f;
const float RemainingDisplayTime = max(0.0f, m_SoundToggleTime + DisplayTime - Client()->LocalTime());
if(RemainingDisplayTime == 0.0f)
return;
Graphics()->MapScreen(0.0f, 0.0f, Width, Height);
@ -47,8 +51,7 @@ void CNotifications::RenderSoundNotification()
Area.w = ItemWidth;
Area.h = ItemHeight;
float Fade = max(0.0f, m_SoundToggleTime + DisplayTime - Client()->LocalTime());
Fade = min(1.0f, Fade / FadeTime); // 0.0 ≤ Fade ≤ 1.0
const float Fade = min(1.0f, RemainingDisplayTime / FadeTime); // 0.0 ≤ Fade ≤ 1.0
vec4 Color = (g_Config.m_SndEnable == 0) ? vec4(1.f/0xff*0xf9, 1.f/0xff*0x2b, 1.f/0xff*0x2b, 0.55f) : vec4(1.f/0xff*0x2b, 1.f/0xff*0xf9, 1.f/0xff*0x2b, 0.55f);
Color = mix(vec4(Color.r, Color.g, Color.b, 0.0f), Color, 0.8*Fade);