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
/* 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));
r_x = width;
r_y = height;
r_z = pixelheight;
- sz = cvar("menu_vid_scale");
// calculate the base resolution
c_z = 0;
f = 1;
c = c * f; // fteqcc fail
- cvar_set("vid_conwidth", ftos(rint(c_x)));
- cvar_set("vid_conheight", ftos(rint(c_y)));
+ 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));
+ return 1;
+ }
+ return 0;
}
entity makeXonoticResolutionSlider()
{
}
else
me.insertValue(me, i, strzone(sprintf(_("%dx%d"), w, h)), strzone(strcat(ftos(w), " ", ftos(h), " ", ftos(pixelheight))));
- // FIXME (in case you ever want to dynamically instantiate this): THIS IS NEVER FREED
}
float autocvar_menu_vid_allowdualscreenresolution;
void XonoticResolutionSlider_configureXonoticResolutionSlider(entity me)
float i;
vector r;
+ // HACK: text slider assumes the strings are constants, so clearValues
+ // will not unzone them
+ for(i = 0; i < me.nValues; ++i)
+ {
+ strunzone(me.valueToIdentifier(me, i));
+ strunzone(me.valueToText(me, i));
+ }
+ // NOW we can safely clear.
me.clearValues(me);
if (fullscreen)
r = getresolution(-1);
if(r_x != 0 || r_y != 0)
me.addResolution(me, r_x, r_y, r_z);
+ dprint("Added system resolutions.\n");
}
if(me.nValues == 0)
{
me.addResolution(me, 640, 480, 1); // pc res
+#if 0
me.addResolution(me, 720, 480, 1.125); // DVD NTSC 4:3
me.addResolution(me, 720, 576, 0.9375); // DVD PAL 4:3
me.addResolution(me, 720, 480, 0.84375); // DVD NTSC 16:9
me.addResolution(me, 720, 576, 0.703125); // DVD PAL 16:9
+#endif
me.addResolution(me, 800, 480, 1); // 480p at 1:1 pixel aspect
me.addResolution(me, 800, 600, 1); // pc res
me.addResolution(me, 1024, 600, 1); // notebook res
me.addResolution(me, 1280, 960, 1); // pc res
me.addResolution(me, 1280, 1024, 1); // pc res
me.addResolution(me, 1920, 1080, 1); // 1080p
+ dprint("Added default resolutions.\n");
}
+ dprint("Total number of resolutions detected: ", ftos(me.nValues), "\n");
me.vid_fullscreen = fullscreen;