So, you want to populate your options menu dropdown with the supported display resolutions in UDK-2012-05 and later?
The function is poorly named as this pseudocode isnt storing or returning anything currently as the vars are all local. Also probably needs some protection against accessed nones, although the PC and Viewport really should exist ;p Alter to taste, copypasta will not work.
The convoluted Player Controller reference is because this is lifted from our GFxMoviePlayer object class. ConsoleCommand() has to be called on an actor in this instance- the movieplayer implementation doesnt seem to return anything to store.
It appears that some entries are duplicated, perhaps due to colourdepth variations, but that info is not visible; so you should perhaps write a few lines to strip the array of duplicate references for now.
To get the current viewport resolution and whether it's windowed
When you're ready to set the resolution, some form of
This might work in a build or two before 2012-05. In older builds, dumpavailableresolutions didnt store anything, I've not verified which; ymmv.
(With thanks to nick_p (epic) and SolidSnake)
Code:
function GetSupportedResolutions() { local array<string> TheStrings; local string TempString; TempString = class'WorldInfo'.static.GetWorldInfo().GetALocalPlayerController().ConsoleCommand("DUMPAVAILABLERESOLUTIONS", false); ParseStringIntoArray(TempString, TheStrings, "\n", true); for(i=0; i<TheStrings.Length; i++) { `log("Found"@TheStrings[i]); } }
The convoluted Player Controller reference is because this is lifted from our GFxMoviePlayer object class. ConsoleCommand() has to be called on an actor in this instance- the movieplayer implementation doesnt seem to return anything to store.
It appears that some entries are duplicated, perhaps due to colourdepth variations, but that info is not visible; so you should perhaps write a few lines to strip the array of duplicate references for now.
Code:
for(i=TheStrings.Length-1; i >= 0; i--) { if(i>0 && TheStrings[i] == TheStrings[i-1]) TheStrings.Remove(i,1); }
Code:
function GetCurrentResolution() { local PlayerController PC; local Vector2D VSize; local bool bIsFullScreen; PC = class'WorldInfo'.static.GetWorldInfo().GetALocalPlayerController(); LocalPlayer(PC.Player).ViewportClient.GetViewportSize(VSize); `log("Current Resolution"@((int(VSize.X))$"x"$(int(VSize.Y))))); bIsFullscreen = LocalPlayer(PC.Player).ViewportClient.IsFullScreenViewport(); `log("Fullscreen"@bIsFullscreen); }
Code:
//Fullscreen PC.ConsoleCommand("setres"@TheStrings[n]$"f"); //Windowed PC.ConsoleCommand("setres"@TheStrings[n]$"w");
(With thanks to nick_p (epic) and SolidSnake)
Comment