]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/menu.qc
Merge branch 'master' into divVerent/desktopfullscreen
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / menu.qc
index 2dc73a8d22675d78d36d789408b907d6b40f2d75..fd4fced57db0aa0d2a1a3c6fb2f970def7baf1b9 100644 (file)
@@ -91,9 +91,10 @@ void m_init()
        }
 }
 
-float MENU_ASPECT = 1.25; // 1280x1024
-float MENU_MINHEIGHT = 600;
-float conwidth_s, conheight_s, realconwidth, realconheight, screenconwidth, screenconheight;
+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));
@@ -102,8 +103,16 @@ void draw_reset_full()
 {
        draw_reset(realconwidth, realconheight, 0, 0);
 }
-void UpdateConWidthHeight()
+
+void UpdateConWidthHeight(float w, float h)
 {
+       if (w != vidwidth_s || h != vidheight_s)
+       {
+               initConwidths(w, h);
+               updateConwidths();
+               vidwidth_s = w;
+               vidheight_s = h;
+       }
        conwidth_s = conwidth;
        conheight_s = conheight;
        realconwidth = cvar("vid_conwidth");
@@ -149,7 +158,7 @@ void m_init_delayed()
        string s;
 
        conwidth = conheight = -1;
-       UpdateConWidthHeight();
+       UpdateConWidthHeight(cvar("vid_width"), cvar("vid_height"));
        draw_reset_cropped();
 
        menuInitialized = 0;
@@ -257,6 +266,19 @@ void m_keydown(float key, float ascii)
                return;
        if(!Menu_Active)
                return;
+
+       if(menuMouseMode)
+       if(key >= K_MOUSE1 && key <= K_MOUSE3)
+       {
+               // detect a click outside of the game window
+               vector p = getmousepos();
+               if(p_x < 0 || p_x > realconwidth || p_y < 0 || p_y > realconheight)
+               {
+                       ++mouseButtonsPressed;
+                       return;
+               }
+       }
+
        if(keyGrabber)
        {
                entity e;
@@ -289,11 +311,11 @@ void m_keydown(float key, float ascii)
        if(key == K_SHIFT) menuShiftState |= S_SHIFT;
 }
 
-float SCALEMODE_CROP = 0;
-float SCALEMODE_LETTERBOX = 1;
-float SCALEMODE_WIDTH = 2;
-float SCALEMODE_HEIGHT = 3;
-float SCALEMODE_STRETCH = 4;
+const float SCALEMODE_CROP = 0;
+const float SCALEMODE_LETTERBOX = 1;
+const float SCALEMODE_WIDTH = 2;
+const float SCALEMODE_HEIGHT = 3;
+const float SCALEMODE_STRETCH = 4;
 void draw_Picture_Aligned(vector algn, float scalemode, string img, float a)
 {
        vector sz, org, isz, isz_w, isz_h;
@@ -658,7 +680,7 @@ void m_tooltip(vector pos)
        }
 }
 
-void m_draw()
+void m_draw(float width, float height)
 {
        float t;
        float realFrametime;
@@ -673,7 +695,13 @@ void m_draw()
                anim.tickAll(anim);
 
        if(main)
-               UpdateConWidthHeight();
+       {
+#ifdef COMPAT_XON070_OLD_M_DRAW
+               UpdateConWidthHeight(width ? width : cvar("vid_width"), height ? height : cvar("vid_height"));
+#else
+               UpdateConWidthHeight(width, height);
+#endif
+       }
 
        if(!menuInitialized)
        {
@@ -784,7 +812,12 @@ void m_draw()
 
        draw_alpha *= menuAlpha;
 
-       if(menuMouseMode)
+       if(!Menu_Active)
+       {
+               // do not update mouse position
+               // it prevents mouse jumping to '0 0 0' when menu is fading out
+       }
+       else if(menuMouseMode)
        {
                vector newMouse;
                newMouse = globalToBox(getmousepos(), draw_shift, draw_scale);
@@ -973,7 +1006,8 @@ void m_goto(string itemname)
                for(e = NULL; (e = find(e, name, itemname)); )
                        if(e.classname != "vtbl")
                                break;
-               if(e)
+                               
+               if((e) && (!e.requiresConnection || (gamestatus & (GAME_ISSERVER | GAME_CONNECTED))))
                {
                        m_hide();
                        m_activate_window(e);