]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/util.qc
Listbox / Picker: Implement item fading in a different way so that it gets influenced...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / util.qc
index e5919fb7a242882bb508dd5f3854dc8a01631eae..a80b03fe1890d8dd47d4976f4cd87c5f05fd5c48 100644 (file)
@@ -1,3 +1,5 @@
+#include "../../common/urllib.qh"
+
 float GL_CheckExtension(string ext)
 {
        return (strstrofs(strcat(" ", cvar_string("gl_info_extensions"), " "), strcat(" ", ext, " "), 0) >= 0);
@@ -327,8 +329,8 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data)
                n = tokenizebyseparator(data, "\n");
 
        float i;
-       string s; 
-       
+       string s;
+
        string un_version = "";
        string un_download = "";
        string un_url = "";
@@ -337,12 +339,12 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data)
        string un_promoted = "";
        string un_recommended = "";
        string un_compatexpire = "";
-       
+
        for(i = 0; i < n; ++i)
        {
                s = substring(argv(i), 2, -1);
                if(s == "") { continue; } // ignore empty lines
-               
+
                switch(substring(argv(i), 0, 1))
                {
                        case "V":
@@ -403,13 +405,13 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data)
                {
                        if(un_compatexpire != "")
                        {
-                               string curdate = strftime(FALSE, "%Y%m%d%H%M%S");
+                               string curdate = strftime(false, "%Y%m%d%H%M%S");
                                if (strcmp(curdate, un_compatexpire) >= 0)
                                        DisableServerBackwardsCompatibility();
                        }
                }
        }
-       
+
        if(un_emergency_pk3s != "")
        {
                _Nex_ExtResponseSystem_Packs = strzone(un_emergency_pk3s);
@@ -455,12 +457,12 @@ void updateCheck()
                float n, i;
                float allgood;
                n = tokenize_console(_Nex_ExtResponseSystem_Packs);
-               allgood = TRUE;
+               allgood = true;
                for(i = 0; i+1 < n; i += 2)
                {
                        if(fexists(argv(i+1)))
                                continue;
-                       allgood = FALSE;
+                       allgood = false;
                        if(_Nex_ExtResponseSystem_PacksStep == 1) // first run
                                localcmd("\ncurl --pak \"", argv(i), "\"\n");
                }
@@ -508,17 +510,17 @@ float preMenuInit()
                boxB_x = boxA_x * (1 - MapInfo_progress) + boxB_x * MapInfo_progress;
                draw_Fill(boxA, boxB - boxA, '0 0 1', 1);
 
-               return FALSE;
+               return false;
        }
-       return TRUE;
+       return true;
 }
 
 string campaign_name_previous;
 float campaign_won_previous;
 #ifdef WATERMARK
-var string autocvar_menu_watermark = WATERMARK;
+string autocvar_menu_watermark = WATERMARK;
 #else
-var string autocvar_menu_watermark = "";
+string autocvar_menu_watermark = "";
 #endif
 void postMenuDraw()
 {
@@ -663,12 +665,11 @@ float updateCompression()
        //GAMETYPE(MAPINFO_TYPE_INVASION) \
        /* nothing */
 
-float GameType_GetID(float cnt)
+int GameType_GetID(int cnt)
 {
-       float i;
-       i = 0;
+       int i = 0;
 
-       #define GAMETYPE(id) { if(i++ == cnt) return id; }
+       #define GAMETYPE(id) { if (i++ == cnt) return id; }
        GAMETYPES
        #undef GAMETYPE
 
@@ -677,10 +678,9 @@ float GameType_GetID(float cnt)
        return 0;
 }
 
-float GameType_GetCount()
+int GameType_GetCount()
 {
-       float i;
-       i = 0;
+       int i = 0;
 
        #define GAMETYPE(id) ++i;
        GAMETYPES
@@ -689,9 +689,9 @@ float GameType_GetCount()
        return i;
 }
 
-string GameType_GetName(float cnt)
+string GameType_GetName(int cnt)
 {
-       float i = GameType_GetID(cnt);
+       int i = GameType_GetID(cnt);
 
        if(i)
                return MapInfo_Type_ToText(i);
@@ -699,9 +699,9 @@ string GameType_GetName(float cnt)
        return "";
 }
 
-string GameType_GetIcon(float cnt)
+string GameType_GetIcon(int cnt)
 {
-       float i = GameType_GetID(cnt);
+       int i = GameType_GetID(cnt);
 
        if(i)
                return strcat("gametype_", MapInfo_Type_ToString(i));
@@ -768,6 +768,15 @@ void dialog_hudpanel_common_notoggle(entity me, string panelname)
                                e.configureXonoticTextSliderValues(e);
 }
 
+float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha)
+{
+       if(startAlpha < targetAlpha)
+               currentAlpha = min(currentAlpha + frametime * 0.5, targetAlpha);
+       else
+               currentAlpha = max(currentAlpha - frametime * 0.5, targetAlpha);
+       return currentAlpha;
+}
+
 void CheckSendCvars(entity me, string cvarnamestring)
 {
        if(me.sendCvars)