]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/util.qc
Merge branch 'master' into Mario/quickmenu_merge
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / util.qc
index 486bcce8dd0ac10095c3557131fada9592a32a82..0f8e341e74a782d75ec951d273e5d397ef4dd512 100644 (file)
@@ -31,7 +31,7 @@ string getZonedTooltipForIdentifier(string s)
                if(t != "")
                        return strzone(t);
        }
-       if(prvm_language == "en" || prvm_language == "")
+       if(prvm_language == "en")
        {
                t = cvar_description(s);
                if(t != "" && t != "custom cvar")
@@ -256,24 +256,31 @@ void setDependentWeird(entity e, float(entity) func)
 float _Nex_ExtResponseSystem_Queried;
 string _Nex_ExtResponseSystem_UpdateTo;
 string _Nex_ExtResponseSystem_UpdateToURL;
+string _Nex_ExtResponseSystem_Packs;
+float _Nex_ExtResponseSystem_PacksStep;
 
 void URI_Get_Callback(float id, float status, string data)
 {
-       if (id == URI_GET_DISCARD)
+       if(url_URI_Get_Callback(id, status, data))
        {
-               // discard
+               // handled
        }
-       else if(id == URI_GET_UPDATENOTIFICATION)
+       else if (id == URI_GET_DISCARD)
        {
-               UpdateNotification_URI_Get_Callback(id, status, data);
+               // discard
        }
-       else if(id >= URI_GET_CURL && id <= URI_GET_CURL_END)
+       else if (id >= URI_GET_CURL && id <= URI_GET_CURL_END)
        {
+               // sv_cmd curl
                Curl_URI_Get_Callback(id, status, data);
        }
+       else if (id == URI_GET_UPDATENOTIFICATION)
+       {
+               UpdateNotification_URI_Get_Callback(id, status, data);
+       }
        else
        {
-               print(sprintf(_("Received HTTP request data for an invalid id %d.\n"), id));
+               print(sprintf("Received HTTP request data for an invalid id %d.\n", id));
        }
 }
 
@@ -306,7 +313,7 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data)
                n = 0;
        else
                n = tokenizebyseparator(data, "\n");
-       
+
        if(n >= 1)
        {
                _Nex_ExtResponseSystem_UpdateTo = argv(0);
@@ -331,60 +338,22 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data)
                        _Nex_ExtResponseSystem_BannedServers = strzone(argv(3));
                        _Nex_ExtResponseSystem_BannedServersNeedsRefresh = 1;
                }
+
+               if(n >= 5)
+               {
+                       if(cvar("menu_updatecheck_getpacks"))
+                       {
+                               _Nex_ExtResponseSystem_Packs = strzone(argv(4));
+                               _Nex_ExtResponseSystem_PacksStep = 1;
+                       }
+               }
        }
 }
 
 // END OF URI SYSTEM ////////////////////////////////////////////////////////
 
-float preMenuInit()
-{
-       vector sz;
-       vector boxA, boxB;
-
-       MapInfo_Cache_Create();
-       MapInfo_Enumerate();
-       if(!MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
-       {
-               draw_reset_cropped();
-
-               sz = eX * 0.025 + eY * 0.025 * (draw_scale_x / draw_scale_y);
-               draw_CenterText('0.5 0.5 0' - 1.25 * sz_y * eY, _("Autogenerating mapinfo for newly added maps..."), sz, '1 1 1', 1, 0);
-
-               boxA = '0.05 0.5 0' + 0.25 * sz_y * eY;
-               boxB = '0.95 0.5 0' + 1.25 * sz_y * eY;
-               draw_Fill(boxA, boxB - boxA, '1 1 1', 1);
-               
-               boxA += sz * 0.1;
-               boxB -= sz * 0.1;
-               draw_Fill(boxA, boxB - boxA, '0.1 0.1 0.1', 1);
-
-               boxB_x = boxA_x * (1 - MapInfo_progress) + boxB_x * MapInfo_progress;
-               draw_Fill(boxA, boxB - boxA, '0 0 1', 1);
-
-               return FALSE;
-       }
-       return TRUE;
-}
-
-string campaign_name_previous;
-float campaign_won_previous;
-#ifdef WATERMARK
-var string autocvar_menu_watermark = WATERMARK();
-#else
-var string autocvar_menu_watermark = "";
-#endif
-void postMenuDraw()
+void updateCheck()
 {
-       if(autocvar_menu_watermark != "")
-       {
-               vector fs = '48 48 0';
-               draw_CenterText('0.5 0.1 0', sprintf(_("^1%s TEST BUILD"), autocvar_menu_watermark), globalToBoxSize('32 32 0', draw_scale), '1 1 1', 0.05, 1);
-       }
-}
-void preMenuDraw()
-{
-       vector fs, sz, line, mid;
-
        if(cvar("menu_updatecheck"))
        {
                if(!_Nex_ExtResponseSystem_Queried)
@@ -430,6 +399,89 @@ void preMenuDraw()
                }
        }
 
+       if(_Nex_ExtResponseSystem_PacksStep > 0)
+       {
+               float n, i;
+               float allgood;
+               n = tokenize_console(_Nex_ExtResponseSystem_Packs);
+               allgood = TRUE;
+               for(i = 0; i+1 < n; i += 2)
+               {
+                       if(fexists(argv(i+1)))
+                               continue;
+                       allgood = FALSE;
+                       if(_Nex_ExtResponseSystem_PacksStep == 1) // first run
+                               localcmd("\ncurl --pak \"", argv(i), "\"\n");
+               }
+               if(allgood)
+               {
+                       if(_Nex_ExtResponseSystem_PacksStep == 2)
+                       {
+                               if(!Menu_Active)
+                                       cvar_set("_menu_initialized", "0");
+                                       // HACK: cause m_hide call on next start
+                               localcmd("\nmenu_restart\n");
+                       }
+                       _Nex_ExtResponseSystem_PacksStep = 0;
+               }
+               else
+                       _Nex_ExtResponseSystem_PacksStep = 2;
+       }
+
+}
+
+float preMenuInit()
+{
+       vector sz;
+       vector boxA, boxB;
+
+       updateCheck();
+
+       MapInfo_Cache_Create();
+       MapInfo_Enumerate();
+       if(!MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
+       {
+               draw_reset_cropped();
+
+               sz = eX * 0.025 + eY * 0.025 * (draw_scale_x / draw_scale_y);
+               draw_CenterText('0.5 0.5 0' - 1.25 * sz_y * eY, _("Autogenerating mapinfo for newly added maps..."), sz, '1 1 1', 1, 0);
+
+               boxA = '0.05 0.5 0' + 0.25 * sz_y * eY;
+               boxB = '0.95 0.5 0' + 1.25 * sz_y * eY;
+               draw_Fill(boxA, boxB - boxA, '1 1 1', 1);
+
+               boxA += sz * 0.1;
+               boxB -= sz * 0.1;
+               draw_Fill(boxA, boxB - boxA, '0.1 0.1 0.1', 1);
+
+               boxB_x = boxA_x * (1 - MapInfo_progress) + boxB_x * MapInfo_progress;
+               draw_Fill(boxA, boxB - boxA, '0 0 1', 1);
+
+               return FALSE;
+       }
+       return TRUE;
+}
+
+string campaign_name_previous;
+float campaign_won_previous;
+#ifdef WATERMARK
+var string autocvar_menu_watermark = WATERMARK;
+#else
+var string autocvar_menu_watermark = "";
+#endif
+void postMenuDraw()
+{
+       if(autocvar_menu_watermark != "")
+       {
+               draw_CenterText('0.5 0.1 0', sprintf(_("^1%s TEST BUILD"), autocvar_menu_watermark), globalToBoxSize('32 32 0', draw_scale), '1 1 1', 0.05, 1);
+       }
+}
+void preMenuDraw()
+{
+       vector fs, sz = '0 0 0', line, mid;
+
+       updateCheck();
+
        if(_Nex_ExtResponseSystem_UpdateTo != "")
        {
                // TODO rather turn this into a dialog
@@ -455,7 +507,7 @@ void preMenuDraw()
                draw_CenterText(mid - 1 * line, l1, fs, '1 0 0', 1, 0);
                draw_CenterText(mid - 0 * line, l2, fs, '0 0 1', 1, 0);
        }
-       if not(campaign_name_previous)
+       if (!campaign_name_previous)
                campaign_name_previous = strzone(strcat(campaign_name, "x")); // force unequal
        if(campaign_name == campaign_name_previous)
        {
@@ -557,7 +609,6 @@ float updateCompression()
        GAMETYPE(MAPINFO_TYPE_ONSLAUGHT) \
        GAMETYPE(MAPINFO_TYPE_RACE) \
        GAMETYPE(MAPINFO_TYPE_CTS) \
-       GAMETYPE(MAPINFO_TYPE_RUNEMATCH) \
        GAMETYPE(MAPINFO_TYPE_TEAM_DEATHMATCH) \
        /* nothing */
 
@@ -565,11 +616,13 @@ float GameType_GetID(float cnt)
 {
        float i;
        i = 0;
-       
+
        #define GAMETYPE(id) if(i++ == cnt) return id;
        GAMETYPES
        #undef GAMETYPE
-       
+
+       unused_float = i;
+
        return 0;
 }
 
@@ -577,31 +630,31 @@ float GameType_GetCount()
 {
        float i;
        i = 0;
-       
+
        #define GAMETYPE(id) ++i;
        GAMETYPES
        #undef GAMETYPE
-       
+
        return i;
 }
 
 string GameType_GetName(float cnt)
 {
        float i = GameType_GetID(cnt);
-       
+
        if(i)
                return MapInfo_Type_ToText(i);
-       
+
        return "";
 }
 
 string GameType_GetIcon(float cnt)
 {
        float i = GameType_GetID(cnt);
-       
+
        if(i)
                return strcat("gametype_", MapInfo_Type_ToString(i));
-       
+
        return "";
 }
 
@@ -609,7 +662,7 @@ string GameType_GetIcon(float cnt)
 {
        float i = GameType_GetID(cnt);
        string s = _MapInfo_GetDefaultEx(i);
-       
+
        if(i)
        {
                if(strstrofs(s, "teams", 0) >= 0)
@@ -617,7 +670,7 @@ string GameType_GetIcon(float cnt)
                else
                        return _("free for all");
        }
-       
+
        return _("tuba for all");
 }*/