]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Support workarea limiting of the window size.
authorRudolf Polzer <divVerent@xonotic.org>
Tue, 17 Mar 2015 11:03:11 +0000 (12:03 +0100)
committerRudolf Polzer <divVerent@xonotic.org>
Tue, 17 Mar 2015 11:04:53 +0000 (12:04 +0100)
Requires an engine change to support getresolution(-2) to return the workarea.

qcsrc/menu/xonotic/slider_resolution.qc

index 476c441ed1a96a40afc2e3fcb2d7ff9b70a17d75..c1443628106e7b4b2947d8a86c669d6c2a2a5e88 100644 (file)
@@ -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