]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/menu.qc
Merge branch 'master' into TimePath/combined_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / menu.qc
index fcf80e3a4b11aace6e97fa262a93a0c586d16b43..0926458bf37989f3100460e788b12b50c95a0fbd 100644 (file)
@@ -16,10 +16,13 @@ float menuInitialized;
 float menuNotTheFirstFrame;
 float menuMouseMode;
 
+float conwidth_s, conheight_s, vidwidth_s, vidheight_s, vidpixelheight_s,
+      realconwidth, realconheight;
+
 void m_sync()
 {
        updateCompression();
-       updateConwidths();
+       vidwidth_s = vidheight_s = vidpixelheight_s = 0;  // Force updateConwidths on next draw.
 
        loadAllCvars(main);
 }
@@ -50,10 +53,8 @@ void m_init()
        prvm_language = strzone(prvm_language);
        cvar_set("_menu_prvm_language", prvm_language);
 
-       check_unacceptable_compiler_bugs();
-
 #ifdef WATERMARK
-       print(sprintf(_("^4MQC Build information: ^1%s\n"), WATERMARK));
+       dprintf("^4MQC Build information: ^1%s\n", WATERMARK);
 #endif
 
        // list all game dirs (TEST)
@@ -64,7 +65,7 @@ void m_init()
                for(i = 0; ; ++i)
                {
                        s = getgamedirinfo(i, GETGAMEDIRINFO_NAME);
-                       if not(s)
+                       if (!s)
                                break;
                        dprint(s, ": ", getgamedirinfo(i, GETGAMEDIRINFO_DESCRIPTION));
                }
@@ -74,6 +75,8 @@ void m_init()
        CALL_ACCUMULATED_FUNCTION(RegisterWeapons);
        CALL_ACCUMULATED_FUNCTION(RegisterGametypes);
 
+       RegisterSLCategories();
+
        float ddsload = cvar("r_texture_dds_load");
        float texcomp = cvar("gl_texturecompression");
        updateCompression();
@@ -88,29 +91,31 @@ void m_init()
                        m_hide();
                cvar_set("_menu_initialized", "1");
        }
+
+       //PlayerInfo_Details();
+       PlayerStats_PlayerDetail_CheckUpdate();
 }
 
 const float MENU_ASPECT = 1.25; // 1280x1024
-const float MENU_MINHEIGHT = 600;
-float conwidth_s, conheight_s, vidwidth_s, vidheight_s, realconwidth,
-      realconheight, screenconwidth, screenconheight;
+
 void draw_reset_cropped()
 {
-       draw_reset(screenconwidth, screenconheight, 0.5 * (realconwidth - screenconwidth), 0.5 * (realconheight - screenconheight));
+       draw_reset(conwidth, conheight, 0.5 * (realconwidth - conwidth), 0.5 * (realconheight - conheight));
 }
 void draw_reset_full()
 {
        draw_reset(realconwidth, realconheight, 0, 0);
 }
 
-void UpdateConWidthHeight(float w, float h)
+void UpdateConWidthHeight(float w, float h, float p)
 {
-       if (w != vidwidth_s || h != vidheight_s)
+       if (w != vidwidth_s || h != vidheight_s || p != vidpixelheight_s)
        {
-               initConwidths(w, h);
-               updateConwidths();
+               if (updateConwidths(w, h, p))
+                       localcmd(sprintf("\nexec %s\n", cvar_string("menu_font_cfg")));
                vidwidth_s = w;
                vidheight_s = h;
+               vidpixelheight_s = p;
        }
        conwidth_s = conwidth;
        conheight_s = conheight;
@@ -128,18 +133,6 @@ void UpdateConWidthHeight(float w, float h)
                conwidth = realconwidth;
                conheight = realconwidth / MENU_ASPECT;
        }
-       screenconwidth = conwidth;
-       screenconheight = conheight;
-       if(conwidth < MENU_MINHEIGHT * MENU_ASPECT)
-       {
-               conheight *= MENU_MINHEIGHT * MENU_ASPECT / conwidth;
-               conwidth = MENU_MINHEIGHT * MENU_ASPECT;
-       }
-       if(conheight < MENU_MINHEIGHT)
-       {
-               conwidth *= MENU_MINHEIGHT / conheight;
-               conheight = MENU_MINHEIGHT;
-       }
        if(main)
        {
                if(conwidth_s != conwidth || conheight_s != conheight)
@@ -148,6 +141,10 @@ void UpdateConWidthHeight(float w, float h)
                        main.resizeNotify(main, '0 0 0', eX * conwidth + eY * conheight, '0 0 0', eX * conwidth + eY * conheight);
                }
        }
+       else
+       {
+               vidwidth_s = vidheight_s = vidpixelheight_s = 0; // retry next frame
+       }
 }
 
 string m_goto_buffer;
@@ -156,8 +153,6 @@ void m_init_delayed()
        float fh, glob, n, i;
        string s;
 
-       conwidth = conheight = -1;
-       UpdateConWidthHeight(cvar("vid_width"), cvar("vid_height"));
        draw_reset_cropped();
 
        menuInitialized = 0;
@@ -449,7 +444,7 @@ float m_allocatetooltipbox(vector pos)
        v = pos + avoidplus;
        if(m_testtooltipbox(v))
                return TRUE;
-       
+
        // bottom center
        v_x = pos_x - menuTooltipSize_x * 0.5;
        if(m_testtooltipbox(v))
@@ -469,12 +464,12 @@ float m_allocatetooltipbox(vector pos)
        v_x = pos_x - menuTooltipSize_x * 0.5;
        if(m_testtooltipbox(v))
                return TRUE;
-       
+
        // top right
        v_x = pos_x + avoidplus_x;
        if(m_testtooltipbox(v))
                return TRUE;
-       
+
        return FALSE;
 }
 entity m_findtooltipitem(entity root, vector pos)
@@ -672,7 +667,7 @@ void m_tooltip(vector pos)
                        while(getWrappedLine_remaining)
                        {
                                s = getWrappedLine(SKINWIDTH_TOOLTIP, fontsize, draw_TextWidth_WithoutColors);
-                               draw_Text(p, s, fontsize, '1 1 1', SKINALPHA_TOOLTIP * menuTooltipAlpha, FALSE);
+                               draw_Text(p, s, fontsize, SKINCOLOR_TOOLTIP, SKINALPHA_TOOLTIP * menuTooltipAlpha, FALSE);
                                p_y += fontsize_y;
                        }
                }
@@ -693,14 +688,7 @@ void m_draw(float width, float height)
        if (anim)
                anim.tickAll(anim);
 
-       if(main)
-       {
-#ifdef COMPAT_XON070_OLD_M_DRAW
-               UpdateConWidthHeight(width ? width : cvar("vid_width"), height ? height : cvar("vid_height"));
-#else
-               UpdateConWidthHeight(width, height);
-#endif
-       }
+       UpdateConWidthHeight(width, height, cvar("vid_pixelheight"));
 
        if(!menuInitialized)
        {
@@ -1005,7 +993,7 @@ void m_goto(string itemname)
                for(e = NULL; (e = find(e, name, itemname)); )
                        if(e.classname != "vtbl")
                                break;
-                               
+
                if((e) && (!e.requiresConnection || (gamestatus & (GAME_ISSERVER | GAME_CONNECTED))))
                {
                        m_hide();