]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/util.qc
Listbox: highlight item under the cursor
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / util.qc
index 330b2bb726a0e89ccc19822ee8c8af0182b82e0e..49fe79b011df800f4ef3e553343658abb8bfcce7 100644 (file)
@@ -768,6 +768,22 @@ void dialog_hudpanel_common_notoggle(entity me, string panelname)
                                e.configureXonoticTextSliderValues(e);
 }
 
+#define FADE_TIME 0.5
+#define MAX_ALPHA_INCREASE 0.1
+#define TRESHOLD_TIME 0.1
+float getHighlightAlpha(float baseAlpha, float highlightedTime)
+{
+       float alphaIncrease;
+       if (time - highlightedTime - TRESHOLD_TIME < FADE_TIME)
+       {
+               alphaIncrease = max(0, (time - highlightedTime - TRESHOLD_TIME) / FADE_TIME);
+               alphaIncrease = (1 - alphaIncrease) * MAX_ALPHA_INCREASE;
+       }
+       else
+               alphaIncrease = 0;
+       return baseAlpha + alphaIncrease;
+}
+
 void CheckSendCvars(entity me, string cvarnamestring)
 {
        if(me.sendCvars)