From: Rudolf Polzer Date: Tue, 20 Aug 2013 08:35:29 +0000 (+0200) Subject: menuqc: new width/height handling, no longer trust the vid_ cvars. Also fixes vid_res... X-Git-Tag: xonotic-v0.8.0~315^2~13 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a9e20bf70ac7ab858241a2213f89673165ea1f09;p=xonotic%2Fxonotic-data.pk3dir.git menuqc: new width/height handling, no longer trust the vid_ cvars. Also fixes vid_resizable. --- diff --git a/qcsrc/common/util-pre.qh b/qcsrc/common/util-pre.qh index 1c2c1cc9f..f0f243abc 100644 --- a/qcsrc/common/util-pre.qh +++ b/qcsrc/common/util-pre.qh @@ -12,6 +12,7 @@ //# 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 a76efb8e3..490a40a4d 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -93,7 +93,8 @@ void m_init() float MENU_ASPECT = 1.25; // 1280x1024 float MENU_MINHEIGHT = 600; -float conwidth_s, conheight_s, realconwidth, realconheight, screenconwidth, screenconheight; +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; @@ -658,7 +667,7 @@ void m_tooltip(vector pos) } } -void m_draw() +void m_draw(float width, float height) { float t; float realFrametime; @@ -673,7 +682,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) { diff --git a/qcsrc/menu/xonotic/slider_resolution.c b/qcsrc/menu/xonotic/slider_resolution.c index 8bd47e799..1a77f2adf 100644 --- a/qcsrc/menu/xonotic/slider_resolution.c +++ b/qcsrc/menu/xonotic/slider_resolution.c @@ -11,10 +11,10 @@ void updateConwidths(); #endif #ifdef IMPLEMENTATION -void initConwidths() +void initConwidths(float width, float height) { - cvar_set("_menu_vid_width", cvar_string("vid_width")); - cvar_set("_menu_vid_height", cvar_string("vid_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()