X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Fslider_resolution.c;h=d404e809918092c01858689f256dc68eed8d40aa;hp=de34a410d9fb2ef9722efb6b9e28382f11b563dd;hb=def24368510d38164b0f6756a1cd5e3bb82f67a8;hpb=222228f3a13c61dd01668e201bfdfd437598ebe4 diff --git a/qcsrc/menu/xonotic/slider_resolution.c b/qcsrc/menu/xonotic/slider_resolution.c index de34a410d9..d404e80991 100644 --- a/qcsrc/menu/xonotic/slider_resolution.c +++ b/qcsrc/menu/xonotic/slider_resolution.c @@ -6,18 +6,25 @@ CLASS(XonoticResolutionSlider) EXTENDS(XonoticTextSlider) METHOD(XonoticResolutionSlider, saveCvars, void(entity)) ENDCLASS(XonoticResolutionSlider) entity makeXonoticResolutionSlider(); -void updateConwidths(); +void updateConwidths(float width, float height, float pixelheight); #endif #ifdef IMPLEMENTATION -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 @@ -34,8 +41,8 @@ void updateConwidths() if(f < 1) c = c * f; // ensures that c_x <= r_x and c_y <= r_y - minfactor = min(1, 640 / c_x); // can be > 1 only if c_x is <640 - maxfactor = max3(1, r_x / c_x, r_y / c_y); // can be < 1 only if r_x < c_x and r_y < c_y + minfactor = min(1, 640 / c_x); // can be > 1 only if c_x is <640 + maxfactor = max(1, r_x / c_x, r_y / c_y); // can be < 1 only if r_x < c_x and r_y < c_y dprint("min factor: ", ftos(minfactor), "\n"); dprint("max factor: ", ftos(maxfactor), "\n"); @@ -47,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))); } @@ -62,15 +66,16 @@ entity makeXonoticResolutionSlider() } void XonoticResolutionSlider_addResolution(entity me, float w, float h, float pixelheight) { - me.addValue(me, strzone(strcat(ftos(w), "x", ftos(h))), strzone(strcat(ftos(w), " ", ftos(h), " ", ftos(pixelheight)))); + me.addValue(me, 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 r0, r; - me.configureXonoticTextSlider(me, "menu_vid_width"); + me.configureXonoticTextSlider(me, "_menu_vid_width"); r0 = '0 0 0'; for(i = 0;; ++i) @@ -83,25 +88,40 @@ void XonoticResolutionSlider_configureXonoticResolutionSlider(entity me) if(r == r0) continue; r0 = r; - if(r_x < 640 || r_y < 400) + if(r_x < 640 || r_y < 480) continue; + if(r_x > 2 * r_y) // likely dualscreen resolution, skip this one + if(autocvar_menu_vid_allowdualscreenresolution <= 0) + continue; + me.addResolution(me, r_x, r_y, r_z); } + if(me.nValues == 0) + { + me.addResolution(me, 640, 480, 1); + me.addResolution(me, 800, 600, 1); + me.addResolution(me, 1024, 768, 1); + me.addResolution(me, 1280, 960, 1); + me.addResolution(me, 1280, 1024, 1); + me.addResolution(me, 1650, 1080, 1); + me.addResolution(me, 1920, 1080, 1); + } + me.configureXonoticTextSliderValues(me); } void XonoticResolutionSlider_loadCvars(entity me) { - me.setValueFromIdentifier(me, strcat(cvar_string("menu_vid_width"), " ", cvar_string("menu_vid_height"), " ", cvar_string("menu_vid_pixelheight"))); + me.setValueFromIdentifier(me, strcat(cvar_string("_menu_vid_width"), " ", cvar_string("_menu_vid_height"), " ", cvar_string("_menu_vid_pixelheight"))); } void XonoticResolutionSlider_saveCvars(entity me) { if(me.value >= 0 || me.value < me.nValues) { tokenize_console(me.getIdentifier(me)); - cvar_set("menu_vid_width", argv(0)); - cvar_set("menu_vid_height", argv(1)); - cvar_set("menu_vid_pixelheight", argv(2)); + cvar_set("_menu_vid_width", argv(0)); + cvar_set("_menu_vid_height", argv(1)); + cvar_set("_menu_vid_pixelheight", argv(2)); } } #endif