Game User Settings

From Epic Wiki
Jump to: navigation, search

Template:Rating

In this guide we will look at the options for changing game settings, such as whether or not to use fullscreen, the window or fullscreen resolution used, the position of the window, and scalability/graphics settings.

This is a guide written by Furyhunter.

The UGameUserSettings class

API documentation: Template:Documentation/Class

Since version 4.11 of UE this class is also exposed to Blueprints, but in this guide we will work with it via a game code module (C++). A pointer to the global UGameUserSettings can be found in the global GEngine.

UGameUserSettings* GetGameUserSettings()
{
    if (GEngine != nullptr)
    {
        return GEngine->GameUserSettings;
    }
    return nullptr;
}

Several of the values used internally by this class are saved to the GameUserSettings.ini config file. If you have external automation needs, this would be the place to start.

Setting the mode

When you use the various mode setting functions, the mode is not immediately applied, much like you would expect from a PC game settings menu. Instead, the value is saved to the Game config. To set up a mode test flow (e.g. user selects mode, clicks apply, and is prompted to confirm if the mode is worked), you should use the following:

int32 Width = 1280, Height = 720;
UGameUserSettings* Settings = GetGameUserSettings(); // note we are using the function defined above
if (Settings != nullptr)
{
    Settings->RequestResolutionChange(Width, Height, EWindowMode::Type::Windowed, false); // we can choose to ignore the command line arguments, this is probably best when the game UI sets the mode after startup
}

// ...

if (UserConfirmed)
{
    Settings->ConfirmVideoMode();

    // Save the requested settings to our local data now
    Settings->SetScreenResolution(Settings->GetLastConfirmedScreenResolution());
    Settings->SetFullscreenMode(Settings->GetLastConfirmedFullscreenMode());
    Settings->SaveSettings();
}
else
{
    Settings->RevertVideoMode();
}

Setting the scalability settings

The UGameUserSettings class provides access to a Template:Documentation/Class instance which it refers to when using the ApplySettings(bool) and ApplyNonResolutionSettings() functions. It is very simple to set these. Note that a GetQualityLevels() function exists in GEngine to obtain the current quality levels, unrelated to the quality levels in the user settings (these can diverge for the purposes of easy settings dialog implementations).

Settings->ScalabilityQuality.AntiAliasingQuality = 0; // Use "Low" AA quality
Settings->ScalabilityQuality.ResolutionQuality   = 3; // Use "Epic" resolution quality

Settings->ApplyNonResolutionSettings();
Settings->SaveSettings();

The values range from 0 to 3 and correspond to "Low", "Medium", "High" and "Epic" as in the editor quick settings dialog and in the scalability cvars. The actual meaning of these (e.g. the cvar presets to use) can be set in Scalability.ini (some sane defaults are copied to your Saved/CleanSourceConfigs and are a good basis for your own). More info on Scalability from UE4 documentation.