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 2c0b1ed..c7499e5 100644 (file)
@@ -51,6 +51,12 @@ void GameCommand(string theCommand)
                return;
        }
 
                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;
        if(argv(0) == "directmenu" || argv(0) == "directpanelhudmenu")
        {
                string filter = string_null;
index 433b842..0f2a525 100644 (file)
@@ -108,7 +108,8 @@ void UpdateConWidthHeight(float w, float h, float p)
 {
        if (w != vidwidth_s || h != vidheight_s || p != vidpixelheight_s)
        {
 {
        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;
                vidwidth_s = w;
                vidheight_s = h;
                vidpixelheight_s = p;
index 8d9f219..076dd23 100644 (file)
@@ -140,6 +140,6 @@ void XonoticVideoSettingsTab_fill(entity me)
        }
 
        me.gotoRC(me, me.rows - 1, 0);
        }
 
        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
 }
 #endif
index 5914e9a..66f48f9 100644 (file)
@@ -9,7 +9,7 @@ CLASS(XonoticResolutionSlider) EXTENDS(XonoticTextSlider)
        ATTRIB(XonoticResolutionSlider, vid_fullscreen, float, -1)
 ENDCLASS(XonoticResolutionSlider)
 entity makeXonoticResolutionSlider();
        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
 #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)
 /* 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;
 
 {
        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));
        // 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;
        r_x = width;
        r_y = height;
        r_z = pixelheight;
-       sz = cvar("menu_vid_scale");
 
        // calculate the base resolution
        c_z = 0;
 
        // 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);
 
        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));
        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()
 {
 }
 entity makeXonoticResolutionSlider()
 {