]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Menu: avoid loading font twice on resolution switch; avoid extra r_restart on resolut...
authorRudolf Polzer <divverent@xonotic.org>
Sun, 13 Oct 2013 14:23:50 +0000 (16:23 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Sun, 13 Oct 2013 14:30:40 +0000 (16:30 +0200)
qcsrc/menu/command/menu_cmd.qc
qcsrc/menu/menu.qc
qcsrc/menu/xonotic/dialog_settings_video.c
qcsrc/menu/xonotic/slider_resolution.c

index 2c0b1edf38aa33fcd42e6117bf4a5c6c108bd04a..c7499e58e40a8a94ba1f31f2c504f0310bb465a3 100644 (file)
@@ -51,6 +51,12 @@ void GameCommand(string theCommand)
                return;
        }
 
+       if(argv(0) == "update_conwidths_before_vid_restart")
+       {
+               updateConwidths(cvar("vid_width"), cvar("vid_height"), cvar("vid_pixelheight"));
+               return;
+       }
+
        if(argv(0) == "directmenu" || argv(0) == "directpanelhudmenu")
        {
                string filter = string_null;
index 433b842778c945bc499c12948d5affcf52b9f182..0f2a525aa3950116eeb01914845351ccfc862ee9 100644 (file)
@@ -108,7 +108,8 @@ void UpdateConWidthHeight(float w, float h, float p)
 {
        if (w != vidwidth_s || h != vidheight_s || p != vidpixelheight_s)
        {
-               updateConwidths(w, h, p);
+               if (updateConwidths(w, h, p))
+                       localcmd(sprintf("\nexec %s\n", cvar_string("menu_font_cfg")));
                vidwidth_s = w;
                vidheight_s = h;
                vidpixelheight_s = p;
index 8d9f2192664cfd849eb4dc0372b616c82251bd09..076dd2337494296f0c0b4b4e8d8f5c7631f11c55 100644 (file)
@@ -140,6 +140,6 @@ void XonoticVideoSettingsTab_fill(entity me)
        }
 
        me.gotoRC(me, me.rows - 1, 0);
-               me.TD(me, 1, me.columns, makeXonoticCommandButton(_("Apply immediately"), '0 0 0', "vid_width $_menu_vid_width; vid_height $_menu_vid_height; vid_pixelheight $_menu_vid_pixelheight; vid_desktopfullscreen $_menu_vid_desktopfullscreen; vid_restart; menu_restart; menu_cmd videosettings", COMMANDBUTTON_APPLY));
+               me.TD(me, 1, me.columns, makeXonoticCommandButton(_("Apply immediately"), '0 0 0', "vid_width $_menu_vid_width; vid_height $_menu_vid_height; vid_pixelheight $_menu_vid_pixelheight; vid_desktopfullscreen $_menu_vid_desktopfullscreen; menu_cmd update_conwidths_before_vid_restart; vid_restart; menu_cmd sync", COMMANDBUTTON_APPLY));
 }
 #endif
index 5914e9aff068e812d7583ac813aa05a1266e1315..66f48f9e58ef2bf26f838e6736889632fe659d1a 100644 (file)
@@ -9,7 +9,7 @@ CLASS(XonoticResolutionSlider) EXTENDS(XonoticTextSlider)
        ATTRIB(XonoticResolutionSlider, vid_fullscreen, float, -1)
 ENDCLASS(XonoticResolutionSlider)
 entity makeXonoticResolutionSlider();
-void updateConwidths(float width, float height, float pixelheight);
+float updateConwidths(float width, float height, float pixelheight);
 #endif
 
 #ifdef IMPLEMENTATION
@@ -17,12 +17,16 @@ void updateConwidths(float width, float height, float pixelheight);
 /* private static */ float XonoticResolutionSlider_DataHasChanged;
 
 // Updates cvars (to be called by menu.qc at startup or on detected res change)
-void updateConwidths(float width, float height, float pixelheight)
+float updateConwidths(float width, float height, float pixelheight)
 {
        vector r, c;
        float minfactor, maxfactor;
        float sz, f;
 
+       sz = cvar("menu_vid_scale");
+       if (sz < -1)
+               return 0;  // No recalculation.
+
        // Save off current settings.
        cvar_set("_menu_vid_width", ftos(width));
        cvar_set("_menu_vid_height", ftos(height));
@@ -32,7 +36,6 @@ void updateConwidths(float width, float height, float pixelheight)
        r_x = width;
        r_y = height;
        r_z = pixelheight;
-       sz = cvar("menu_vid_scale");
 
        // calculate the base resolution
        c_z = 0;
@@ -64,14 +67,16 @@ void updateConwidths(float width, float height, float pixelheight)
        c_x = rint(c_x);
        c_y = rint(c_y);
 
+       // Please reload resolutions list and such stuff.
+       XonoticResolutionSlider_DataHasChanged = TRUE;
+
        if (c_x != cvar("vid_conwidth") || c_y != cvar("vid_conheight"))
        {
                cvar_set("vid_conwidth", ftos(c_x));
                cvar_set("vid_conheight", ftos(c_y));
-               localcmd("\nr_restart\n");
+               return 1;
        }
-
-       XonoticResolutionSlider_DataHasChanged = TRUE;
+       return 0;
 }
 entity makeXonoticResolutionSlider()
 {