]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/util.qc
Add skin attributes for listbox focused items and allow customization of the fade...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / util.qc
index 49fe79b011df800f4ef3e553343658abb8bfcce7..58d1d934f521f4e6d1624c7e4424ce7b8beeb09f 100644 (file)
@@ -769,19 +769,18 @@ void dialog_hudpanel_common_notoggle(entity me, string panelname)
 }
 
 #define FADE_TIME 0.5
-#define MAX_ALPHA_INCREASE 0.1
 #define TRESHOLD_TIME 0.1
-float getHighlightAlpha(float baseAlpha, float highlightedTime)
+float getHighlightAlpha(float startAlpha, float targetAlpha, float highlightedTime)
 {
-       float alphaIncrease;
-       if (time - highlightedTime - TRESHOLD_TIME < FADE_TIME)
+       float theAlpha;
+       if((time - highlightedTime - TRESHOLD_TIME) < FADE_TIME)
        {
-               alphaIncrease = max(0, (time - highlightedTime - TRESHOLD_TIME) / FADE_TIME);
-               alphaIncrease = (1 - alphaIncrease) * MAX_ALPHA_INCREASE;
+               float f = max(0, (time - highlightedTime - TRESHOLD_TIME) / FADE_TIME);
+               theAlpha = startAlpha + f * (targetAlpha - startAlpha);
        }
        else
-               alphaIncrease = 0;
-       return baseAlpha + alphaIncrease;
+               theAlpha = targetAlpha;
+       return theAlpha;
 }
 
 void CheckSendCvars(entity me, string cvarnamestring)