Skip to content

Commit

Permalink
Merge pull request #408 from Areloch/MiscOptionsMenuFix
Browse files Browse the repository at this point in the history
Fixes for AA toggle and GFX Device reporting for options menu
  • Loading branch information
Azaezel authored Dec 14, 2020
2 parents 196e80b + 334cd1d commit 41624ec
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
13 changes: 12 additions & 1 deletion Engine/source/gfx/gfxDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,17 @@ DefineEngineFunction( getDisplayDeviceInformation, const char*, (),,
return adapter.getName();
}

DefineEngineFunction(getDisplayDeviceType, GFXAdapterType, (), ,
"Get the string describing the active GFX device type.\n"
"@ingroup GFX\n")
{
if (!GFXDevice::devicePresent())
return NullDevice;

const GFXAdapter& adapter = GFX->getAdapter();
return adapter.mType;
}

DefineEngineFunction( getBestHDRFormat, GFXFormat, (),,
"Returns the best texture format for storage of HDR data for the active device.\n"
"@ingroup GFX\n" )
Expand All @@ -1388,4 +1399,4 @@ DefineEngineFunction( getBestHDRFormat, GFXFormat, (),,
DefineEngineFunction(ResetGFX, void, (), , "forces the gbuffer to be reinitialized in cases of improper/lack of buffer clears.")
{
GFX->beginReset();
}
}
10 changes: 5 additions & 5 deletions Templates/BaseGame/game/core/gui/scripts/canvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function createCanvas(%windowTitle)
// Set the window title
if (isObject(Canvas))
{
Canvas.setWindowTitle(%windowTitle @ " - " @ $pref::Video::displayDevice);
Canvas.setWindowTitle(%windowTitle @ " - " @ getDisplayDeviceType());
configureCanvas();
}
else
Expand Down Expand Up @@ -107,15 +107,15 @@ function configureCanvas()
%resY = $pref::Video::Resolution.y;
%bpp = $pref::Video::BitDepth;
%rate = $pref::Video::RefreshRate;
%fsaa = $pref::Video::AA;
%aa = $pref::Video::AA;
%fs = ($pref::Video::deviceMode == 2);

echo("Accepted Mode: " NL
"--Resolution : " @ %resX SPC %resY NL
"--Screen Mode : " @ %fsLabel NL
"--Bits Per Pixel : " @ %bpp NL
"--Refresh Rate : " @ %rate NL
"--FSAA Level : " @ %fsaa NL
"--FSAA Level : " @ %aa NL
"--------------");

// Actually set the new video mode
Expand All @@ -132,8 +132,8 @@ function configureCanvas()
// We need to parse the setting between AA modes, and then it's level
// It's formatted as AATypexAALevel
// So, FXAAx4 or MLAAx2
if ( isObject( FXAA_PostEffect ) )
FXAA_PostEffect.Enabled = ( %aa > 0 ) ? true : false;
if ( isObject( FXAAPostFX ) )
FXAAPostFX.Enabled = ( %aa > 0 ) ? true : false;
}

function GuiCanvas::modeStrToPrefs(%this, %modeStr)
Expand Down
31 changes: 29 additions & 2 deletions Templates/BaseGame/game/data/ui/guis/optionsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,32 @@
OptionName.setText("");
OptionDescription.setText("");

OptionsMenuSettingsList.addOptionRow("Display API", "D3D11\tOpenGL", false, "", -1, -30, true, "The display API used for rendering.", $pref::Video::displayDevice);
//First, lets double-check the active device is accurate. Sometimes the default value in our prefs doesn't match the active one
%displayDevice = getDisplayDeviceType();
if($changingDisplayDevice !$= "")
%displayDevice = $changingDisplayDevice;

%apiList = "";
%apiCount = GFXInit::getAdapterCount();
%apiIdx = 0;
for(%i=0; %i < %apiCount; %i++)
{
%api = GFXInit::getAdapterType(%i);

if(%api !$= "NullDevice")
{
if(%apiIdx==0)
%apiList = %api;
else
%apiList = %apiList TAB %api;

%apiIdx++;
}
}

trim(%apiList);

OptionsMenuSettingsList.addOptionRow("Display API", %apiList, false, "", -1, -30, true, "The display API used for rendering.", %displayDevice);

%numDevices = Canvas.getMonitorCount();
%devicesList = "";
Expand Down Expand Up @@ -246,7 +271,7 @@

function OptionsMenu::applyDisplaySettings(%this)
{
%newDevice = OptionsMenuSettingsList.getCurrentOption(0);
%newDevice = OptionsMenuSettingsList.getCurrentOption(0);

// Change the device.
if ( %newDevice !$= $pref::Video::displayDevice )
Expand All @@ -257,6 +282,8 @@
$pref::Video::displayDevice = %newDevice;
if( %newAdapter !$= getDisplayDeviceInformation() )
MessageBoxOK( "Change requires restart", "Please restart the game for a display device change to take effect." );

$changingDisplayDevice = %newDevice;
}

updateDisplaySettings();
Expand Down

0 comments on commit 41624ec

Please sign in to comment.