//# define COMPAT_XON050_ENGINE
# define COMPAT_NO_MOD_IS_XONOTIC
# define COMPAT_XON060_DONTCRASH_CHECKPVS
-# define COMPAT_XON070_OLD_M_DRAW
#endif
#ifdef FTEQCC
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);
}
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));
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;
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;
float fh, glob, n, i;
string s;
- conwidth = conheight = -1;
- UpdateConWidthHeight(cvar("vid_width"), cvar("vid_height"));
draw_reset_cropped();
menuInitialized = 0;
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)
{
}
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
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
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)));
}