]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
More cleanup.
authorRudolf Polzer <divverent@xonotic.org>
Wed, 18 Sep 2013 06:07:19 +0000 (08:07 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Wed, 18 Sep 2013 06:07:19 +0000 (08:07 +0200)
qcsrc/common/util-pre.qh
qcsrc/menu/menu.qc
qcsrc/menu/xonotic/dialog_settings_video.c
qcsrc/menu/xonotic/slider_resolution.c

index 5f94230bd5c713bb5fdcf57aef19e7d55093cfbe..3912773fba3794cdb2c7c7e838f2948f2472422b 100644 (file)
@@ -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
index fcf80e3a4b11aace6e97fa262a93a0c586d16b43..312a2dc2cbfb80aaa26296a656ac16de0d23d27f 100644 (file)
@@ -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)
        {
index 57bbc3cd21ecb93def8f27455bc01636e7905a29..00bb7de5afa9a89e11338a18d3bc353b76373a59 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', "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
index f29b35e173af6dde24a961735857fd0be95fd7ad..d404e809918092c01858689f256dc68eed8d40aa 100644 (file)
@@ -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)));
 }