From: Rudolf Polzer Date: Sun, 13 Oct 2013 14:23:50 +0000 (+0200) Subject: Menu: avoid loading font twice on resolution switch; avoid extra r_restart on resolut... X-Git-Tag: xonotic-v0.8.0~285 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=bfd3892eeb1401e14fc7da982f8b33d77d91384a;p=xonotic%2Fxonotic-data.pk3dir.git Menu: avoid loading font twice on resolution switch; avoid extra r_restart on resolution switch; avoid menu reload on resolution switch --- diff --git a/qcsrc/menu/command/menu_cmd.qc b/qcsrc/menu/command/menu_cmd.qc index 2c0b1edf3..c7499e58e 100644 --- a/qcsrc/menu/command/menu_cmd.qc +++ b/qcsrc/menu/command/menu_cmd.qc @@ -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; diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index 433b84277..0f2a525aa 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -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; diff --git a/qcsrc/menu/xonotic/dialog_settings_video.c b/qcsrc/menu/xonotic/dialog_settings_video.c index 8d9f21926..076dd2337 100644 --- a/qcsrc/menu/xonotic/dialog_settings_video.c +++ b/qcsrc/menu/xonotic/dialog_settings_video.c @@ -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 diff --git a/qcsrc/menu/xonotic/slider_resolution.c b/qcsrc/menu/xonotic/slider_resolution.c index 5914e9aff..66f48f9e5 100644 --- a/qcsrc/menu/xonotic/slider_resolution.c +++ b/qcsrc/menu/xonotic/slider_resolution.c @@ -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() {