diff --git a/config/menus_settings.cfg b/config/menus_settings.cfg index ae55bc10..3a5d8457 100644 --- a/config/menus_settings.cfg +++ b/config/menus_settings.cfg @@ -52,7 +52,9 @@ menuitemtextinput [Nickname: ] [] [ name $arg1 ] menuitemcheckbox [Use high-res player skins] "(>= (findlist (zipmodlist active) protox_hq_reskin) 0)" [ if $arg1 [addzipmod protox_hq_reskin] [zipmodremove protox_hq_reskin] ] menuitemtextinput [Resolution (width): ] "$scr_w" [ scr_w $arg1 ] menuitemtextinput [Resolution (height): ] "$scr_h" [ scr_h $arg1 ] -menuitem "\f2Set\f5 resolution as in desktop" [ setdesktopres; refreshcurmenudelayed ] +if (&& $desktopw $desktoph) [ + menuitem (concatword "\f2Set\f5 resolution as in desktop (" $desktopw "x" $desktoph ")") [ scr_w $desktopw ; scr_h $desktoph ; refreshcurmenudelayed ] +] menuitemcheckbox [Fullscreen: ] "$fullscreen" [ fullscreen $arg1 ] menuitemtextinput [Mouse sensitivity: ] "$sensitivity" [ sensitivity $arg1 ] menuitemcheckbox [Reduced violence mode: ] "$poniesmodeon" [ reducedviolencemode $arg1 ] @@ -324,7 +326,9 @@ newmenu video menuitemtextinput [Screen width: ] "$scr_w" [ scr_w $arg1 ] [] 11 menuitemtextinput [Screen height: ] "$scr_h" [ scr_h $arg1 ] [] 11 -menuitem "\f2Set\f5 resolution as in desktop" [ setdesktopres; refreshcurmenudelayed ] +if (&& $desktopw $desktoph) [ + menuitem (concatword "\f2Set\f5 resolution as in desktop (" $desktopw "x" $desktoph ")") [ scr_w $desktopw ; scr_h $desktoph ; refreshcurmenudelayed ] +] menuitem [Choose resolution from list...] [ showmenu [Display resolutions] ] menuitem [] -1 menuitemslider [Graphics detail: ] 1 6 "$gfxqualityalias" 1 [Horrible Low Medium Good High "INSANE! (May perform slowly on older gfx)"] [ new_gfx_quality $arg1 ] @@ -342,20 +346,21 @@ menuitem [] -1 menuitem "\f2\t\t\t [ Apply now! ]" [ resetgl ] newmenu [Display resolutions] - -menuitem " 640x480\t(4:3)" [ scr_w 640; scr_h 480; closecurmenu ] -menuitem " 800x600\t(4:3)" [ scr_w 800; scr_h 600; closecurmenu ] -menuitem "1024x768\t(4:3)" [ scr_w 1024; scr_h 768; closecurmenu ] -menuitem "1280x720\t(16:9)" [ scr_w 1280; scr_h 720; closecurmenu ] -menuitem "1280x800\t(16:10)" [ scr_w 1280; scr_h 800; closecurmenu ] -menuitem "1280x1024\t(5:4)" [ scr_w 1280; scr_h 1024; closecurmenu ] -menuitem "1360x768\t(~16:9)" [ scr_w 1360; scr_h 768; closecurmenu ] -menuitem "1366x768\t(~16:9)" [ scr_w 1366; scr_h 768; closecurmenu ] -menuitem "1440x900\t(16:10)" [ scr_w 1440; scr_h 900; closecurmenu ] -menuitem "1600x900\t(16:9)" [ scr_w 1600; scr_h 900; closecurmenu ] -menuitem "1680x1050\t(16:10)" [ scr_w 1680; scr_h 1050; closecurmenu ] -menuitem "1920x1080\t(16:9)" [ scr_w 1920; scr_h 1080; closecurmenu ] -menuitem "1920x1200\t(16:10)" [ scr_w 1920; scr_h 1200; closecurmenu ] +looplist (getdisplayresolutions) [w h] [ + push desc "" + push r (div (* $w 1000) $h) + looplist [1250 5:4 1333 4:3 1777 16:9 1600 16:10] [nr nd] [ + if (= $r $nr) [ + desc = $nd + ][ + if (= (div $r 10) (div $nr 10)) [ + desc = (concatword "~" $nd) + ] + ] + ] + if (< $w 1000) [ r = " " ] [ r = "" ] + menuitem (concatword (pop r) $w x $h "\t(" (pop desc) ")") (concat scr_w $w ";" scr_h $h ";" closecurmenu) +] const fsaa_valuemap [-1 0 2 4 8 16] const aniso_valuemap [0 2 4 8 16] diff --git a/source/src/main.cpp b/source/src/main.cpp index 96139ed1..e63848b7 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -414,19 +414,8 @@ void setresdata(char *s, enet_uint32 c) COMMANDF(screenres, "ii", (int *w, int *h) { screenres(*w, *h); }); -int desktopw = 0, desktoph = 0; - -void setdesktopres() -{ - if(desktopw && desktoph) - { - scr_w = desktopw; - scr_h = desktoph; - } - else conoutf("Could not set resolution as in desktop"); -} - -COMMAND(setdesktopres, ""); +VAR(desktopw, 1, 0, 0); +VAR(desktoph, 1, 0, 0); static int curgamma = 100; VARNFP(gamma, vgamma, 30, 100, 300, @@ -450,6 +439,22 @@ void restoregamma() SDL_SetGamma(f, f, f); } +void getdisplayresolutions() +{ + string res = ""; + int lh = 0, lw = 0; + SDL_Rect **modes = SDL_ListModes(NULL, SDL_OPENGL|SDL_RESIZABLE|SDL_FULLSCREEN); + if(modes && modes!=(SDL_Rect **)-1) + { + for(int i = 0; modes[i]; i++) + { + if(lw != modes[i]->w && lh != modes[i]->h) concatformatstring(res, "%s%d %d", *res ? " " : "", (lw = modes[i]->w), (lh = modes[i]->h)); + } + } + result(res); +} +COMMAND(getdisplayresolutions, ""); + void setupscreen(int &usedcolorbits, int &useddepthbits, int &usedfsaa) { int flags = SDL_RESIZABLE;