Adds ability to adjust padding to guiTextListCtrl's rows

ForcedMaterialMeshMgr tweaked to allow proper setting of override material
Ongoing WIP of update/fixing of options menus
WIP of expanded visualizers, including material complexity viz
Adds no-pie flag when compiling on linux with non-clang compilers
This commit is contained in:
Areloch 2019-09-06 00:00:17 -05:00
parent 9e1544880e
commit 52fcbecb9f
21 changed files with 912 additions and 487 deletions

View file

@ -73,8 +73,10 @@ function UI::initClient(%this)
//Load scripts
exec("./scripts/optionsList.cs");
exec("./scripts/displayMenu.cs");
exec("./scripts/graphicsMenu.cs");
exec("./scripts/controlsMenu.cs");
exec("./scripts/audioMenu.cs");
exec("./scripts/messageBoxes.cs");
exec("./scripts/help.cs");
exec("./scripts/cursors.cs");

View file

@ -70,6 +70,7 @@ function OptionsMenu::onWake(%this)
text = "Keyboard and Mouse";
profile = GuiMenuButtonProfile;
extent = %array.extent.x SPC "35";
command="ControlsMenu::loadSettings();";
};
%controllerMenuBtn = new GuiButtonCtrl(){
@ -104,14 +105,15 @@ function OptionsMenu::onWake(%this)
text = "Gameplay";
profile = GuiMenuButtonProfile;
extent = %array.extent.x SPC "35";
command="GameplayMenu::loadSettings();";
};
%array.add(%keyboardMenuBtn);
%array.add(%controllerMenuBtn);
//%array.add(%controllerMenuBtn);
%array.add(%displayMenuBtn);
%array.add(%graphicsMenuBtn);
%array.add(%audioMenuBtn);
%array.add(%gameplayMenuBtn);
//%array.add(%gameplayMenuBtn);
//We programmatically set up our settings here so we can do some prepwork on the fields/controls
//Presets
@ -143,6 +145,13 @@ function OptionsMenu::onWake(%this)
OptionsMenu.addSettingOption(%array, "Water Reflections", "On", ShadowQualityList, $pref::Video::Resolution);
OptionsMenu.addSettingOption(%array, "Anisotropic Filtering", "16x", ShadowQualityList, $pref::Video::Resolution);*/
if(!isObject(GraphicsSettingsCache))
{
new ArrayObject(GraphicsSettingsCache){};
}
GraphicsSettingsCache.empty();
}
function OptionsMenuOKButton::onClick(%this)
@ -438,228 +447,4 @@ function CameraMenuOKButton::onClick(%this)
function CameraMenuDefaultsButton::onClick(%this)
{
}
// =============================================================================
// AUDIO MENU
// =============================================================================
$AudioTestHandle = 0;
// Description to use for playing the volume test sound. This isn't
// played with the description of the channel that has its volume changed
// because we know nothing about the playback state of the channel. If it
// is paused or stopped, the test sound would not play then.
$AudioTestDescription = new SFXDescription()
{
sourceGroup = AudioChannelMaster;
};
function AudioMenu::loadSettings(%this)
{
// Audio
//OptAudioHardwareToggle.setStateOn($pref::SFX::useHardware);
//OptAudioHardwareToggle.setActive( true );
%this-->OptAudioVolumeMaster.setValue( $pref::SFX::masterVolume );
%this-->OptAudioVolumeShell.setValue( $pref::SFX::channelVolume[ $GuiAudioType] );
%this-->OptAudioVolumeSim.setValue( $pref::SFX::channelVolume[ $SimAudioType ] );
%this-->OptAudioVolumeMusic.setValue( $pref::SFX::channelVolume[ $MusicAudioType ] );
AudioMenuSoundDriver.clear();
%buffer = sfxGetAvailableDevices();
%count = getRecordCount( %buffer );
for(%i = 0; %i < %count; %i++)
{
%record = getRecord(%buffer, %i);
%provider = getField(%record, 0);
if ( AudioMenuSoundDriver.findText( %provider ) == -1 )
AudioMenuSoundDriver.add( %provider, %i );
}
AudioMenuSoundDriver.sort();
%selId = AudioMenuSoundDriver.findText($pref::SFX::provider);
if ( %selId == -1 )
AudioMenuSoundDriver.setFirstSelected();
else
AudioMenuSoundDriver.setSelected( %selId );
}
function AudioMenu::loadDevices(%this)
{
if(!isObject(SoundDeviceGroup))
{
new SimGroup( SoundDeviceGroup );
}
else
{
SoundDeviceGroup.clear();
}
%buffer = sfxGetAvailableDevices();
%count = getRecordCount( %buffer );
for (%i = 0; %i < %count; %i++)
{
%record = getRecord(%buffer, %i);
%provider = getField(%record, 0);
%device = getField(%record, 1);
if($pref::SFX::provider !$= %provider)
continue;
%setting = new ArrayObject()
{
class = "OptionsMenuSettingLevel";
caseSensitive = true;
displayName = %device;
key["$pref::SFX::Device"] = %device;
};
SoundDeviceGroup.add(%setting);
}
}
function AudioMenu::apply(%this)
{
sfxSetMasterVolume( $pref::SFX::masterVolume );
sfxSetChannelVolume( $GuiAudioType, $pref::SFX::channelVolume[ $GuiAudioType ] );
sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ $SimAudioType ] );
sfxSetChannelVolume( $MusicAudioType, $pref::SFX::channelVolume[ $MusicAudioType ] );
if ( !sfxCreateDevice( $pref::SFX::provider,
$pref::SFX::device,
$pref::SFX::useHardware,
-1 ) )
error( "Unable to create SFX device: " @ $pref::SFX::provider
SPC $pref::SFX::device
SPC $pref::SFX::useHardware );
if( !isObject( $AudioTestHandle ) )
{
sfxPlay(menuButtonPressed);
}
}
function AudioMenuOKButton::onClick(%this)
{
//save the settings and then back out
AudioMenu.apply();
OptionsMenu.backOut();
}
function AudioMenuDefaultsButton::onClick(%this)
{
sfxInit();
AudioMenu.loadSettings();
}
function OptAudioUpdateMasterVolume( %volume )
{
if( %volume == $pref::SFX::masterVolume )
return;
sfxSetMasterVolume( %volume );
$pref::SFX::masterVolume = %volume;
if( !isObject( $AudioTestHandle ) )
$AudioTestHandle = sfxPlayOnce( AudioChannel, "data/ui/sounds/volumeTest.wav" );
}
function OptAudioUpdateChannelVolume( %description, %volume )
{
%channel = sfxGroupToOldChannel( %description.sourceGroup );
if( %volume == $pref::SFX::channelVolume[ %channel ] )
return;
sfxSetChannelVolume( %channel, %volume );
$pref::SFX::channelVolume[ %channel ] = %volume;
if( !isObject( $AudioTestHandle ) )
{
$AudioTestDescription.volume = %volume;
$AudioTestHandle = sfxPlayOnce( $AudioTestDescription, "data/ui/sounds/volumeTest.wav" );
}
}
function AudioMenuSoundDriver::onSelect( %this, %id, %text )
{
// Skip empty provider selections.
if ( %text $= "" )
return;
$pref::SFX::provider = %text;
AudioMenuSoundDevice.clear();
%buffer = sfxGetAvailableDevices();
%count = getRecordCount( %buffer );
for(%i = 0; %i < %count; %i++)
{
%record = getRecord(%buffer, %i);
%provider = getField(%record, 0);
%device = getField(%record, 1);
if (%provider !$= %text)
continue;
if ( AudioMenuSoundDevice.findText( %device ) == -1 )
AudioMenuSoundDevice.add( %device, %i );
}
// Find the previous selected device.
%selId = AudioMenuSoundDevice.findText($pref::SFX::device);
if ( %selId == -1 )
AudioMenuSoundDevice.setFirstSelected();
else
AudioMenuSoundDevice.setSelected( %selId );
}
function AudioMenuSoundDevice::onSelect( %this, %id, %text )
{
// Skip empty selections.
if ( %text $= "" )
return;
$pref::SFX::device = %text;
if ( !sfxCreateDevice( $pref::SFX::provider,
$pref::SFX::device,
$pref::SFX::useHardware,
-1 ) )
error( "Unable to create SFX device: " @ $pref::SFX::provider
SPC $pref::SFX::device
SPC $pref::SFX::useHardware );
}
//==============================================================================
// DISPLAY MENU
//==============================================================================
function DisplayMenu::loadSettings()
{
OptionsSettingStack.clear();
OptionsMenu.addSettingOption(OptionsSettingStack, "Resolution", "1024 x 768", "", $pref::Video::Resolution);
OptionsMenu.addSettingOption(OptionsSettingStack, "Full Screen", "Off", "", $pref::Video::FullScreen);
OptionsMenu.addSettingOption(OptionsSettingStack, "Refresh Rate", "60", "", $pref::Video::RefreshRate);
OptionsMenu.addSettingOption(OptionsSettingStack, "VSync", "Off", "", $pref::Video::Vsync);
OptionsMenu.addSliderOption(OptionsSettingStack, "Field of View", $pref::Video::FOV, "65 120", 55, 75);
OptionsMenu.addSliderOption(OptionsSettingStack, "Brightness", $pref::Video::Brightness, "0 1", 10, 5);
OptionsMenu.addSliderOption(OptionsSettingStack, "Contrast", $pref::Video::Contrast, "0 1", 10, 5);
}
//==============================================================================
// AUDIO MENU
//==============================================================================
function AudioMenu::loadSettings()
{
OptionsSettingStack.clear();
OptionsMenu.addSliderOption(OptionsSettingStack, "Master Volume", $pref::Video::Brightness, "0 1", 10, 5);
OptionsMenu.addSliderOption(OptionsSettingStack, "Menu Volume", $pref::Video::Brightness, "0 1", 10, 5);
OptionsMenu.addSliderOption(OptionsSettingStack, "Effects Volume", $pref::Video::Brightness, "0 1", 10, 5);
OptionsMenu.addSliderOption(OptionsSettingStack, "Music Volume", $pref::Video::Brightness, "0 1", 10, 5);
}

View file

@ -0,0 +1,200 @@
// =============================================================================
// AUDIO MENU
// =============================================================================
$AudioTestHandle = 0;
// Description to use for playing the volume test sound. This isn't
// played with the description of the channel that has its volume changed
// because we know nothing about the playback state of the channel. If it
// is paused or stopped, the test sound would not play then.
$AudioTestDescription = new SFXDescription()
{
sourceGroup = AudioChannelMaster;
};
function AudioMenu::loadSettings(%this)
{
// Audio
//OptAudioHardwareToggle.setStateOn($pref::SFX::useHardware);
//OptAudioHardwareToggle.setActive( true );
/*%this-->OptAudioVolumeMaster.setValue( $pref::SFX::masterVolume );
%this-->OptAudioVolumeShell.setValue( $pref::SFX::channelVolume[ $GuiAudioType] );
%this-->OptAudioVolumeSim.setValue( $pref::SFX::channelVolume[ $SimAudioType ] );
%this-->OptAudioVolumeMusic.setValue( $pref::SFX::channelVolume[ $MusicAudioType ] );
AudioMenuSoundDriver.clear();
%buffer = sfxGetAvailableDevices();
%count = getRecordCount( %buffer );
for(%i = 0; %i < %count; %i++)
{
%record = getRecord(%buffer, %i);
%provider = getField(%record, 0);
if ( AudioMenuSoundDriver.findText( %provider ) == -1 )
AudioMenuSoundDriver.add( %provider, %i );
}
AudioMenuSoundDriver.sort();
%selId = AudioMenuSoundDriver.findText($pref::SFX::provider);
if ( %selId == -1 )
AudioMenuSoundDriver.setFirstSelected();
else
AudioMenuSoundDriver.setSelected( %selId );*/
OptionsSettingStack.clear();
OptionsMenu.addSliderOption(OptionsSettingStack, "Master Volume", $pref::Video::Brightness, "0 1", 10, 5);
OptionsMenu.addSliderOption(OptionsSettingStack, "Menu Volume", $pref::Video::Brightness, "0 1", 10, 5);
OptionsMenu.addSliderOption(OptionsSettingStack, "Effects Volume", $pref::Video::Brightness, "0 1", 10, 5);
OptionsMenu.addSliderOption(OptionsSettingStack, "Music Volume", $pref::Video::Brightness, "0 1", 10, 5);
}
function AudioMenu::loadDevices(%this)
{
if(!isObject(SoundDeviceGroup))
{
new SimGroup( SoundDeviceGroup );
}
else
{
SoundDeviceGroup.clear();
}
%buffer = sfxGetAvailableDevices();
%count = getRecordCount( %buffer );
for (%i = 0; %i < %count; %i++)
{
%record = getRecord(%buffer, %i);
%provider = getField(%record, 0);
%device = getField(%record, 1);
if($pref::SFX::provider !$= %provider)
continue;
%setting = new ArrayObject()
{
class = "OptionsMenuSettingLevel";
caseSensitive = true;
displayName = %device;
key["$pref::SFX::Device"] = %device;
};
SoundDeviceGroup.add(%setting);
}
}
function AudioMenu::apply(%this)
{
sfxSetMasterVolume( $pref::SFX::masterVolume );
sfxSetChannelVolume( $GuiAudioType, $pref::SFX::channelVolume[ $GuiAudioType ] );
sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ $SimAudioType ] );
sfxSetChannelVolume( $MusicAudioType, $pref::SFX::channelVolume[ $MusicAudioType ] );
if ( !sfxCreateDevice( $pref::SFX::provider,
$pref::SFX::device,
$pref::SFX::useHardware,
-1 ) )
error( "Unable to create SFX device: " @ $pref::SFX::provider
SPC $pref::SFX::device
SPC $pref::SFX::useHardware );
if( !isObject( $AudioTestHandle ) )
{
sfxPlay(menuButtonPressed);
}
}
function AudioMenuOKButton::onClick(%this)
{
//save the settings and then back out
AudioMenu.apply();
OptionsMenu.backOut();
}
function AudioMenuDefaultsButton::onClick(%this)
{
sfxInit();
AudioMenu.loadSettings();
}
function OptAudioUpdateMasterVolume( %volume )
{
if( %volume == $pref::SFX::masterVolume )
return;
sfxSetMasterVolume( %volume );
$pref::SFX::masterVolume = %volume;
if( !isObject( $AudioTestHandle ) )
$AudioTestHandle = sfxPlayOnce( AudioChannel, "data/ui/sounds/volumeTest.wav" );
}
function OptAudioUpdateChannelVolume( %description, %volume )
{
%channel = sfxGroupToOldChannel( %description.sourceGroup );
if( %volume == $pref::SFX::channelVolume[ %channel ] )
return;
sfxSetChannelVolume( %channel, %volume );
$pref::SFX::channelVolume[ %channel ] = %volume;
if( !isObject( $AudioTestHandle ) )
{
$AudioTestDescription.volume = %volume;
$AudioTestHandle = sfxPlayOnce( $AudioTestDescription, "data/ui/sounds/volumeTest.wav" );
}
}
function AudioMenuSoundDriver::onSelect( %this, %id, %text )
{
// Skip empty provider selections.
if ( %text $= "" )
return;
$pref::SFX::provider = %text;
AudioMenuSoundDevice.clear();
%buffer = sfxGetAvailableDevices();
%count = getRecordCount( %buffer );
for(%i = 0; %i < %count; %i++)
{
%record = getRecord(%buffer, %i);
%provider = getField(%record, 0);
%device = getField(%record, 1);
if (%provider !$= %text)
continue;
if ( AudioMenuSoundDevice.findText( %device ) == -1 )
AudioMenuSoundDevice.add( %device, %i );
}
// Find the previous selected device.
%selId = AudioMenuSoundDevice.findText($pref::SFX::device);
if ( %selId == -1 )
AudioMenuSoundDevice.setFirstSelected();
else
AudioMenuSoundDevice.setSelected( %selId );
}
function AudioMenuSoundDevice::onSelect( %this, %id, %text )
{
// Skip empty selections.
if ( %text $= "" )
return;
$pref::SFX::device = %text;
if ( !sfxCreateDevice( $pref::SFX::provider,
$pref::SFX::device,
$pref::SFX::useHardware,
-1 ) )
error( "Unable to create SFX device: " @ $pref::SFX::provider
SPC $pref::SFX::device
SPC $pref::SFX::useHardware );
}

View file

@ -49,7 +49,7 @@ $RemapCmd[$RemapCount] = "toggleCamera";
$RemapGroup[$RemapCount] = "Miscellaneous";
$RemapCount++;
function ControlsMenu::onWake(%this)
function ControlsMenu::loadSettings(%this)
{
ControlSetList.clear();
ControlSetList.add( "Movement", "Movement" );
@ -58,9 +58,9 @@ function ControlsMenu::onWake(%this)
ControlSetList.setSelected( "Movement", false );
ControlsMenuOptionsArray.clear();
ControlsMenu.loadGroupKeybinds("Movement");
ControlsMenuOptionsArray.refresh();
OptionsSettingStack.clear();
loadGroupKeybinds("Movement");
//ControlsMenuOptionsArray.refresh();
}
function ControlSetList::onSelect( %this, %id, %text )
@ -68,13 +68,13 @@ function ControlSetList::onSelect( %this, %id, %text )
ControlsMenuOptionsArray.clear();
if(%text $= "Movement")
ControlsMenu.loadGroupKeybinds("Movement");
loadGroupKeybinds("Movement");
else if(%text $= "Combat")
ControlsMenu.loadGroupKeybinds("Combat");
loadGroupKeybinds("Combat");
else if(%text $= "Miscellaneous")
ControlsMenu.loadGroupKeybinds("Miscellaneous");
loadGroupKeybinds("Miscellaneous");
ControlsMenuOptionsArray.refresh();
//ControlsMenuOptionsArray.refresh();
}
function ControlsMenuOKButton::onClick(%this)
@ -94,7 +94,7 @@ function ControlsMenuDefaultsButton::onClick(%this)
ControlsMenu.reload();
}
function ControlsMenu::loadGroupKeybinds(%this, %keybindGroup)
function loadGroupKeybinds(%keybindGroup)
{
%optionIndex = 0;
for(%i=0; %i < $RemapCount; %i++)
@ -102,9 +102,9 @@ function ControlsMenu::loadGroupKeybinds(%this, %keybindGroup)
//find and add all the keybinds for the particular group we're looking at
if($RemapGroup[%i] $= %keybindGroup)
{
%temp = %this.getKeybindString(%i);
%temp = getKeybindString(%i);
%option = %this.addKeybindOption();
%option = addKeybindOption();
%option-->nameText.setText($RemapName[%i]);
%option-->rebindButton.setText(%temp);
%option-->rebindButton.keybindIndex = %i;
@ -114,18 +114,18 @@ function ControlsMenu::loadGroupKeybinds(%this, %keybindGroup)
}
}
function ControlsMenu::addKeybindOption(%this)
function addKeybindOption()
{
%tamlReader = new Taml();
%graphicsOption = %tamlReader.read("data/ui/guis/controlsMenuSetting.taml");
ControlsMenuOptionsArray.add(%graphicsOption);
OptionsSettingStack.add(%graphicsOption);
return %graphicsOption;
}
function ControlsMenu::getKeybindString(%this, %index )
function getKeybindString(%index )
{
%name = $RemapName[%index];
%cmd = $RemapCmd[%index];
@ -142,11 +142,11 @@ function ControlsMenu::getKeybindString(%this, %index )
%device = getField( %temp, %i + 0 );
%object = getField( %temp, %i + 1 );
%displayName = %this.getMapDisplayName( %device, %object );
%displayName = getMapDisplayName( %device, %object );
if(%displayName !$= "")
{
%tmpMapString = %this.getMapDisplayName( %device, %object );
%tmpMapString = getMapDisplayName( %device, %object );
if(%mapString $= "")
{
@ -175,7 +175,7 @@ function ControlsMenu::redoMapping( %device, %action, %cmd, %oldIndex, %newIndex
%remapList.setRowById( %newIndex, buildFullMapString( %newIndex ) );
}
function ControlsMenu::getMapDisplayName( %this, %device, %action )
function getMapDisplayName( %device, %action )
{
if ( %device $= "keyboard" )
return( %action );

View file

@ -0,0 +1,228 @@
function DisplayMenu::loadSettings()
{
OptionsMenu.currentMenu = "DisplayMenu";
OptionsSettingStack.clear();
%APICount = getTokenCount(GraphicsDriverSetting::getList(),",");
if(%APICount > 1)
OptionsMenu.addSettingOption(OptionsSettingStack, "Diplay API", "", "GraphicsDriverSetting");
OptionsMenu.addSettingOption(OptionsSettingStack, "Screen Resolution", "", "ScreenResolutionSetting");
OptionsMenu.addSettingOption(OptionsSettingStack, "Fullscreen", "", "FullscreenSetting");
OptionsMenu.addSettingOption(OptionsSettingStack, "VSync", "", "VSyncSetting");
OptionsMenu.addSliderOption(OptionsSettingStack, "Field of View", $pref::Video::FOV, "65 120", 55, 75);
OptionsMenu.addSliderOption(OptionsSettingStack, "Brightness", $pref::Video::Brightness, "0 1", 10, 5);
OptionsMenu.addSliderOption(OptionsSettingStack, "Contrast", $pref::Video::Contrast, "0 1", 10, 5);
GraphicsSettingsCache.empty();
}
function DisplayMenu::apply(%this)
{
//Loop through the settings cache and actually apply the values
%cachedSettingCount = GraphicsSettingsCache.count();
for(%i=0; %i < %cachedSettingCount; %i++)
{
%var = GraphicsSettingsCache.getKey(%i);
%val = GraphicsSettingsCache.getValue(%i);
if(%var $= "$pref::Video::displayDevice")
{
MessageBoxOK( "Change requires restart", "Please restart the game for a display device change to take effect." );
}
setVariable(%var, %val);
}
//Update the display settings now
$pref::Video::Resolution = getWord( $pref::Video::Resolution, 0 ) SPC getWord( $pref::Video::Resolution, 2 );
/*if ( %newFullScreen $= "false" )
{
// If we're in windowed mode switch the fullscreen check
// if the resolution is bigger than the desktop.
%deskRes = getDesktopResolution();
%deskResX = getWord(%deskRes, $WORD::RES_X);
%deskResY = getWord(%deskRes, $WORD::RES_Y);
if ( getWord( %newRes, $WORD::RES_X ) > %deskResX ||
getWord( %newRes, $WORD::RES_Y ) > %deskResY )
{
$pref::Video::FullScreen = "true";
GraphicsMenuFullScreen.setStateOn( true );
}
}*/
// Build the final mode string.
%newMode = $pref::Video::Resolution SPC $pref::Video::FullScreen SPC 32 SPC $pref::Video::RefreshRate SPC $pref::Video::AA;
// Change the video mode.
/*if ( %newMode !$= $pref::Video::mode ||
%newVsync != $pref::Video::disableVerticalSync )
{
if ( %testNeedApply )
return true;*/
$pref::Video::mode = %newMode;
//$pref::Video::disableVerticalSync = %newVsync;
configureCanvas();
//}
echo("Exporting client prefs");
%prefPath = getPrefpath();
export("$pref::*", %prefPath @ "/clientPrefs.cs", false);
}
//
function GraphicsDriverSetting::set(%setting)
{
switch$(%setting)
{
case "D3D11":
GraphicsMenu::set("$pref::Video::displayDevice", "D3D11");
case "OpenGL":
GraphicsMenu::set("$pref::Video::displayDevice", "OpenGL");
default:
GraphicsMenu::set("$pref::Video::displayDevice", "OpenGL");
}
}
function GraphicsDriverSetting::get()
{
if($pref::Video::displayDevice == "D3D11")
return "D3D11";
else if($pref::Video::displayDevice == "OpenGL")
return "OpenGL";
else
return "Unknown";
}
function GraphicsDriverSetting::getList()
{
%returnsList = "";
%buffer = getDisplayDeviceList();
%deviceCount = getFieldCount( %buffer );
%count = 0;
for(%i = 0; %i < %deviceCount; %i++)
{
%deviceDesc = getField(%buffer, %i);
if(%deviceDesc $= "GFX Null Device")
continue;
if(%count != 0)
%returnsList = %returnsList @ "," @ %deviceDesc;
else
%returnsList = %deviceDesc;
%count++;
}
return %returnsList;
}
//
function ScreenResolutionSetting::set(%setting)
{
GraphicsMenu::set("$pref::Video::Resolution", %setting);
}
function ScreenResolutionSetting::get()
{
return _makePrettyResString( $pref::Video::Resolution );
}
function ScreenResolutionSetting::getList()
{
%returnsList = "";
%resCount = Canvas.getModeCount();
for (%i = 0; %i < %resCount; %i++)
{
%testResString = Canvas.getMode( %i );
%testRes = _makePrettyResString( %testResString );
//sanitize
%found = false;
%retCount = getTokenCount(%returnsList, ",");
for (%x = 0; %x < %retCount; %x++)
{
%existingEntry = getToken(%returnsList, ",", %x);
if(%existingEntry $= %testRes)
{
%found = true;
break;
}
}
if(%found)
continue;
if(%i != 0)
%returnsList = %returnsList @ "," @ %testRes;
else
%returnsList = %testRes;
}
return %returnsList;
}
//
function FullscreenSetting::set(%setting)
{
switch$(%setting)
{
case "On":
GraphicsMenu::set("$pref::Video::FullScreen", "1");
case "Off":
GraphicsMenu::set("$pref::Video::FullScreen", "0");
default:
GraphicsMenu::set("$pref::Video::FullScreen", "0");
}
}
function FullscreenSetting::get()
{
if($pref::Video::FullScreen == 1)
return "On";
else if($pref::Video::FullScreen == 0)
return "Off";
else
return "Custom";
}
function FullscreenSetting::getList()
{
return "Off,On";
}
//
function VSyncSetting::set(%setting)
{
switch$(%setting)
{
case "On":
GraphicsMenu::set("$pref::Video::disableVerticalSync", "0");
case "Off":
GraphicsMenu::set("$pref::Video::disableVerticalSync", "1");
default:
GraphicsMenu::set("$pref::Video::disableVerticalSync", "1");
}
}
function VSyncSetting::get()
{
if($pref::Video::disableVerticalSync == 0)
return "On";
else if($pref::Video::disableVerticalSync == 1)
return "Off";
else
return "Custom";
}
function VSyncSetting::getList()
{
return "Off,On";
}

View file

@ -293,7 +293,7 @@ function GraphicsMenu::Autodetect_Apply(%this, %shaderVer, %intel, %videoMem )
return "Graphics quality settings have been auto detected.";
}
function _makePrettyResString( %resString )
function _makePrettyResString( %resString, %giveAspectRation )
{
%width = getWord( %resString, $WORD::RES_X );
%height = getWord( %resString, $WORD::RES_Y );
@ -312,7 +312,7 @@ function _makePrettyResString( %resString )
}
%outRes = %width @ " x " @ %height;
if ( %aspect !$= "" )
if ( %giveAspectRation && %aspect !$= "" )
%outRes = %outRes @ " (" @ %aspect @ ")";
return %outRes;
@ -320,38 +320,20 @@ function _makePrettyResString( %resString )
function GraphicsMenu::apply(%this)
{
%newAdapter = GraphicsMenuDriver.getText();
%numAdapters = GFXInit::getAdapterCount();
%newDevice = $pref::Video::displayDevice;
for( %i = 0; %i < %numAdapters; %i ++ )
{
if( GFXInit::getAdapterName( %i ) $= %newAdapter )
{
%newDevice = GFXInit::getAdapterType( %i );
break;
}
}
// Change the device.
if ( %newDevice !$= $pref::Video::displayDevice )
{
if ( %testNeedApply )
return true;
$pref::Video::displayDevice = %newDevice;
if( %newAdapter !$= getDisplayDeviceInformation() )
MessageBoxOK( "Change requires restart", "Please restart the game for a display device change to take effect." );
}
//Loop through the settings cache and actually apply the values
%cachedSettingCount = GraphicsSettingsCache.count();
%canvasUpdate = false;
for(%i=0; %i < %cachedSettingCount; %i++)
{
%var = GraphicsSettingsCache.getKey(%i);
%val = GraphicsSettingsCache.getValue(%i);
if(%var $= "$pref::Video::AA")
{
%canvasUpdate = true;
}
setVariable(%var, %val);
}
@ -368,41 +350,10 @@ function GraphicsMenu::apply(%this)
PostFXManager.settingsEffectSetEnabled("DOF", $pref::PostFX::EnableDOF);
PostFXManager.settingsEffectSetEnabled("LightRays", $pref::PostFX::EnableLightRays);
PostFXManager.settingsEffectSetEnabled("Vignette", $pref::PostFX::EnableVignette);
//Update the display settings now
$pref::Video::Resolution = getWords( Canvas.getMode( GraphicsMenuResolution.getSelected() ), $WORD::RES_X, $WORD::RES_Y );
%newBpp = 32; // ... its not 1997 anymore.
$pref::Video::FullScreen = GraphicsMenuFullScreen.isStateOn() ? "true" : "false";
$pref::Video::RefreshRate = GraphicsMenuRefreshRate.getSelected();
$pref::Video::disableVerticalSync = !GraphicsMenuVSync.isStateOn();
if ( %newFullScreen $= "false" )
{
// If we're in windowed mode switch the fullscreen check
// if the resolution is bigger than the desktop.
%deskRes = getDesktopResolution();
%deskResX = getWord(%deskRes, $WORD::RES_X);
%deskResY = getWord(%deskRes, $WORD::RES_Y);
if ( getWord( %newRes, $WORD::RES_X ) > %deskResX ||
getWord( %newRes, $WORD::RES_Y ) > %deskResY )
{
$pref::Video::FullScreen = "true";
GraphicsMenuFullScreen.setStateOn( true );
}
}
// Build the final mode string.
%newMode = $pref::Video::Resolution SPC $pref::Video::FullScreen SPC %newBpp SPC $pref::Video::RefreshRate SPC $pref::Video::AA;
// Change the video mode.
if ( %newMode !$= $pref::Video::mode ||
%newVsync != $pref::Video::disableVerticalSync )
if ( %canvasUpdate )
{
if ( %testNeedApply )
return true;
$pref::Video::mode = %newMode;
$pref::Video::disableVerticalSync = %newVsync;
// Change the video mode.
configureCanvas();
}
@ -436,11 +387,6 @@ function GraphicsMenu::loadSettings()
OptionsMenu.addSettingOption(OptionsSettingStack, "Anti Aliasing", "", "AASetting");
OptionsMenu.addSettingOption(OptionsSettingStack, "Anisotropic Filtering", "", "AnisotropicFilteringSetting");
if(!isObject(GraphicsSettingsCache))
{
new ArrayObject(GraphicsSettingsCache){};
}
GraphicsSettingsCache.empty();
}