From: Rudolf Polzer Date: Tue, 17 Mar 2015 11:03:11 +0000 (+0100) Subject: Support workarea limiting of the window size. X-Git-Tag: xonotic-v0.8.1~102 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=79ca3605fb683eabb612c3ae823f52076f1a23e0;p=xonotic%2Fxonotic-data.pk3dir.git Support workarea limiting of the window size. Requires an engine change to support getresolution(-2) to return the workarea. --- diff --git a/qcsrc/menu/xonotic/slider_resolution.qc b/qcsrc/menu/xonotic/slider_resolution.qc index 476c441ed..c14436281 100644 --- a/qcsrc/menu/xonotic/slider_resolution.qc +++ b/qcsrc/menu/xonotic/slider_resolution.qc @@ -7,6 +7,8 @@ CLASS(XonoticResolutionSlider) EXTENDS(XonoticTextSlider) METHOD(XonoticResolutionSlider, saveCvars, void(entity)) METHOD(XonoticResolutionSlider, draw, void(entity)) ATTRIB(XonoticResolutionSlider, vid_fullscreen, float, -1) + ATTRIB(XonoticResolutionSlider, maxAllowedWidth, float, 0) + ATTRIB(XonoticResolutionSlider, maxAllowedHeight, float, 0) ENDCLASS(XonoticResolutionSlider) entity makeXonoticResolutionSlider(); float updateConwidths(float width, float height, float pixelheight); @@ -87,6 +89,10 @@ entity makeXonoticResolutionSlider() } void XonoticResolutionSlider_addResolution(entity me, float w, float h, float pixelheight) { + if (me.maxAllowedWidth && w > me.maxAllowedWidth) + return; + if (me.maxAllowedHeight && h > me.maxAllowedHeight) + return; float i; for (i = 0; i < me.nValues; ++i) { @@ -138,6 +144,8 @@ void XonoticResolutionSlider_loadResolutions(entity me, float fullscreen) } // NOW we can safely clear. me.clearValues(me); + me.maxAllowedWidth = 0; + me.maxAllowedHeight = 0; if (fullscreen) { @@ -161,6 +169,21 @@ void XonoticResolutionSlider_loadResolutions(entity me, float fullscreen) if(me.nValues == 0) { + // Get workarea. + r = getresolution(-2); + // If workarea is not supported, get desktop size. + if(r.x == 0 && r.y == 0) + r = getresolution(-1); + + // Add it, and limit all other resolutions to the workarea/desktop size. + if(r.x != 0 || r.y != 0) + { + me.maxAllowedWidth = r.x; + me.maxAllowedHeight = r.y; + me.addResolution(me, r.x, r.y, r.z); + } + + // Add nice hardcoded defaults. me.addResolution(me, 640, 480, 1); // pc res #if 0 me.addResolution(me, 720, 480, 1.125); // DVD NTSC 4:3