From: Rudolf Polzer Date: Wed, 18 Sep 2013 06:07:19 +0000 (+0200) Subject: More cleanup. X-Git-Tag: xonotic-v0.8.0~315^2~8 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=def24368510d38164b0f6756a1cd5e3bb82f67a8;p=xonotic%2Fxonotic-data.pk3dir.git More cleanup. --- diff --git a/qcsrc/common/util-pre.qh b/qcsrc/common/util-pre.qh index 5f94230bd..3912773fb 100644 --- a/qcsrc/common/util-pre.qh +++ b/qcsrc/common/util-pre.qh @@ -12,7 +12,6 @@ //# define COMPAT_XON050_ENGINE # define COMPAT_NO_MOD_IS_XONOTIC # define COMPAT_XON060_DONTCRASH_CHECKPVS -# define COMPAT_XON070_OLD_M_DRAW #endif #ifdef FTEQCC diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index fcf80e3a4..312a2dc2c 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -16,10 +16,13 @@ float menuInitialized; float menuNotTheFirstFrame; float menuMouseMode; +float conwidth_s, conheight_s, vidwidth_s, vidheight_s, vidpixelheight_s, + realconwidth, realconheight, screenconwidth, screenconheight; + void m_sync() { updateCompression(); - updateConwidths(); + vidwidth_s = vidheight_s = vidpixelheight_s = 0; loadAllCvars(main); } @@ -92,8 +95,7 @@ void m_init() 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)); @@ -103,14 +105,14 @@ 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(); + updateConwidths(w, h, p); vidwidth_s = w; vidheight_s = h; + vidpixelheight_s = p; } conwidth_s = conwidth; conheight_s = conheight; @@ -148,6 +150,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 +162,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; @@ -693,14 +697,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) { diff --git a/qcsrc/menu/xonotic/dialog_settings_video.c b/qcsrc/menu/xonotic/dialog_settings_video.c index 57bbc3cd2..00bb7de5a 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', "menu_cmd sync; 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_restart; menu_restart; menu_cmd videosettings", COMMANDBUTTON_APPLY)); } #endif diff --git a/qcsrc/menu/xonotic/slider_resolution.c b/qcsrc/menu/xonotic/slider_resolution.c index f29b35e17..d404e8099 100644 --- a/qcsrc/menu/xonotic/slider_resolution.c +++ b/qcsrc/menu/xonotic/slider_resolution.c @@ -6,25 +6,25 @@ CLASS(XonoticResolutionSlider) EXTENDS(XonoticTextSlider) METHOD(XonoticResolutionSlider, saveCvars, void(entity)) ENDCLASS(XonoticResolutionSlider) entity makeXonoticResolutionSlider(); -void initConwidths(float width, float height); -void updateConwidths(); +void updateConwidths(float width, float height, float pixelheight); #endif #ifdef IMPLEMENTATION -void initConwidths(float width, float height) -{ - cvar_set("_menu_vid_width", ftos(width)); - cvar_set("_menu_vid_height", ftos(height)); - cvar_set("_menu_vid_pixelheight", cvar_string("vid_pixelheight")); -} -void updateConwidths() +// Updates cvars (to be called by menu.qc at startup or on detected res change) +void updateConwidths(float width, float height, float pixelheight) { vector r, c; float minfactor, maxfactor; float sz, f; - r_x = cvar("_menu_vid_width"); - r_y = cvar("_menu_vid_height"); - r_z = cvar("_menu_vid_pixelheight"); + + // Save off current settings. + cvar_set("_menu_vid_width", ftos(width)); + cvar_set("_menu_vid_height", ftos(height)); + cvar_set("_menu_vid_pixelheight", ftos(pixelheight)); + + r_x = width; + r_y = height; + r_z = pixelheight; sz = cvar("menu_vid_scale"); // calculate the base resolution @@ -54,9 +54,6 @@ void updateConwidths() f = 1; c = c * f; // fteqcc fail - cvar_set("vid_width", ftos(rint(r_x))); - cvar_set("vid_height", ftos(rint(r_y))); - cvar_set("vid_pixelheight", ftos(rint(r_z))); cvar_set("vid_conwidth", ftos(rint(c_x))); cvar_set("vid_conheight", ftos(rint(c_y))); }