]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/util.qc
Merge remote-tracking branch 'origin/master' into terencehill/menu_remove_tab_title
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / util.qc
index cf4139fdeea9c51582fecfdd7d710fb9782b2abb..444292712d1a968861d673f960441bd8d7d48347 100644 (file)
@@ -1,3 +1,13 @@
+#include "util.qh"
+#include "../menu.qh"
+#include "../oo/base.qh"
+#include "../../common/campaign_common.qh"
+#include "../../common/constants.qh"
+#include "../../common/mapinfo.qh"
+#include "../../common/urllib.qh"
+#include "../../common/util.qh"
+#include "../../common/command/generic.qh"
+
 float GL_CheckExtension(string ext)
 {
        return (strstrofs(strcat(" ", cvar_string("gl_info_extensions"), " "), strcat(" ", ext, " "), 0) >= 0);
@@ -41,6 +51,7 @@ string getZonedTooltipForIdentifier(string s)
        return string_null;
 }
 
+.entity parent, firstChild, nextSibling;
 void forAllDescendants(entity root, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass)
 {
        depthfirst(root, parent, firstChild, nextSibling, funcPre, funcPost, pass);
@@ -50,11 +61,15 @@ void forAllDescendants(entity root, void(entity, entity) funcPre, void(entity, e
 void SUB_Null_ee(entity e1, entity e2)
 {
 }
+
+.void(entity) saveCvars;
 void saveCvarsOf(entity ignore, entity e)
 {
        if(e.saveCvars)
                e.saveCvars(e);
 }
+
+.void(entity) loadCvars;
 void loadCvarsOf(entity ignore, entity e)
 {
        if(e.loadCvars)
@@ -133,6 +148,7 @@ void makeCallback(entity e, entity cbent, void(entity, entity) cbfunc)
 .string cvarString_setDependent;
 .string cvarValue_setDependent;
 .float(entity) func_setDependent;
+.bool disabled;
 void setDependent_Check(entity e)
 {
        float f;
@@ -179,6 +195,7 @@ void setDependent_Draw(entity e)
        setDependent_Check(e);
        e.draw_setDependent(e);
 }
+.void(entity) draw;
 void setDependent(entity e, string theCvarName, float theCvarMin, float theCvarMax)
 {
        e.draw_setDependent = e.draw;
@@ -327,8 +344,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 +354,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 +420,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 +472,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");
                }
@@ -494,11 +511,11 @@ float preMenuInit()
        {
                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);
+               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;
+               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;
@@ -508,17 +525,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()
 {
@@ -527,6 +544,8 @@ void postMenuDraw()
                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 DialogOpenButton_Click_withCoords(entity button, entity tab, vector theOrigin, vector theSize);
+.entity winnerDialog;
 void preMenuDraw()
 {
        vector fs, sz = '0 0 0', line, mid;
@@ -536,8 +555,8 @@ void preMenuDraw()
        if(_Nex_ExtResponseSystem_UpdateTo != "")
        {
                // TODO rather turn this into a dialog
-               fs = ((1/draw_scale_x) * eX + (1/draw_scale_y) * eY) * 12;
-               line = eY * fs_y;
+               fs = ((1/draw_scale.x) * eX + (1/draw_scale.y) * eY) * 12;
+               line = eY * fs.y;
                string l1, l2;
                l1 = sprintf(_("Update to %s now!"), _Nex_ExtResponseSystem_UpdateTo);
                l2 = "http://www.xonotic.org/";
@@ -548,11 +567,11 @@ void preMenuDraw()
                                draw_TextWidth(l1, 0, fs),
                                draw_TextWidth(l2, 0, fs)
                        );
-               sz_y = 3 * fs_y;
+               sz_y = 3 * fs.y;
 
                draw_alpha = bound(0, sin(time * 0.112 - 0.3) * 10, 1);
-               mid = eX * (0.5 + 0.5 * (1 - sz_x) * cos(time * 0.071))
-                   + eY * (0.5 + 0.5 * (1 - sz_y) * sin(time * 0.071));
+               mid = eX * (0.5 + 0.5 * (1 - sz.x) * cos(time * 0.071))
+                   + eY * (0.5 + 0.5 * (1 - sz.y) * sin(time * 0.071));
 
                draw_Fill(mid - 0.5 * sz, sz, '1 1 0', 1);
                draw_CenterText(mid - 1 * line, l1, fs, '1 0 0', 1, 0);
@@ -663,12 +682,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 +695,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 +706,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 +716,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));
@@ -709,6 +726,18 @@ string GameType_GetIcon(float cnt)
        return "";
 }
 
+.void(entity) TR;
+.void(entity, float, float, entity) TD;
+.void(entity, float) TDempty;
+entity makeXonoticTextLabel(float theAlign, string theText);
+entity makeXonoticTextSlider(string);
+.void(entity, string, string) addValue;
+.void(entity) configureXonoticTextSliderValues;
+entity makeXonoticColorpickerString(string theCvar, string theDefaultCvar);
+entity makeXonoticCheckBoxString(string, string, string, string);
+entity makeXonoticCheckBox(float, string, string);
+.bool sendCvars;
+
 void dialog_hudpanel_common_notoggle(entity me, string panelname)
 {
        float i;