mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
Updated all UI module controls to utilize a more standard structure with stack controls instead of the GameMenu ctrls, as well as more standardization of gamepad input handling
937 lines
33 KiB
Plaintext
937 lines
33 KiB
Plaintext
//options settings
|
|
|
|
//Screen and Display menu
|
|
//Renderer Mode
|
|
//Screen resolution
|
|
//Windowed/fullscreen(borderless?)
|
|
//VSync
|
|
|
|
//Screen brightness
|
|
//screen brightness
|
|
//screen gamma
|
|
|
|
//Lighting Menu
|
|
//Shadow Distance(Distance shadows are drawn to. Also affects shadowmap slices)
|
|
//Shadow Quality(Resolution of shadows rendered, setting to none disables dynamic shadows)
|
|
//Soft Shadows(Whether shadow softening is used)
|
|
//Shadow caching(If the lights enable it, shadow caching is activated)
|
|
//Light Draw Distance(How far away lights are still drawn. Doesn't impact vector lights like the sun)
|
|
|
|
//Mesh and Textures Menu
|
|
//Draw distance(Overall draw distance) -slider
|
|
//Object draw distance(Draw distance from small/unimportant objects) -slider
|
|
//Mesh quality
|
|
//Texture quality
|
|
//Foliage draw distance
|
|
//Terrain Quality
|
|
//Decal Quality
|
|
|
|
//Effects Menu
|
|
//Parallax
|
|
//HDR
|
|
//Light shafts
|
|
//Motion Blur
|
|
//Depth of Field
|
|
//SSAO
|
|
//AA(ModelXAmount)[defualt is FXAA]
|
|
//Anisotropic filtering
|
|
|
|
//Keybinds
|
|
|
|
//Camera
|
|
//horizontal mouse sensitivity
|
|
//vert mouse sensitivity
|
|
//invert vertical
|
|
//zoom mouse sensitivities(both horz/vert)
|
|
//headbob
|
|
//FOV
|
|
|
|
function OptionsMenu::onAdd(%this)
|
|
{
|
|
if(!isObject(%this.optionsCategories))
|
|
{
|
|
%this.optionsCategories = new ArrayObject();
|
|
}
|
|
|
|
if(!isObject(%this.unappliedChanges))
|
|
{
|
|
%this.unappliedChanges = new ArrayObject();
|
|
}
|
|
|
|
addOptionsMenuCategory("Display", "populateDisplaySettingsList();");
|
|
addOptionsMenuCategory("Graphics", "populateGraphicsSettingsList();");
|
|
addOptionsMenuCategory("Audio", "populateAudioSettingsList();");
|
|
addOptionsMenuCategory("Keyboard & Mouse", "populateKeyboardMouseSettingsList();");
|
|
addOptionsMenuCategory("Gamepad", "populateGamepadSettingsList();");
|
|
}
|
|
|
|
function OptionsMenuSettingsList::onAdd(%this)
|
|
{
|
|
}
|
|
|
|
function OptionsMenuSettingsList::getOptionsList(%this, %index)
|
|
{
|
|
|
|
}
|
|
|
|
function OptionsMenu::onWake(%this)
|
|
{
|
|
for(%i=0; %i < %this.optionsCategories.count(); %i++)
|
|
{
|
|
%catName = %this.optionsCategories.getKey(%i);
|
|
%callback = %this.optionsCategories.getValue(%i);
|
|
|
|
%newCatButton = new GuiButtonCtrl() {
|
|
text = %catName;
|
|
groupNum = "-1";
|
|
buttonType = "PushButton";
|
|
useMouseEvents = "0";
|
|
position = "0 180";
|
|
extent = "248 35";
|
|
minExtent = "8 2";
|
|
horizSizing = "right";
|
|
vertSizing = "bottom";
|
|
profile = "GuiMenuButtonProfile";
|
|
visible = "1";
|
|
active = "1";
|
|
command = %callback;
|
|
tooltipProfile = "GuiToolTipProfile";
|
|
hovertime = "1000";
|
|
isContainer = "0";
|
|
canSave = "1";
|
|
canSaveDynamicFields = "0";
|
|
};
|
|
|
|
OptionsMenuCategoryList.add(%newCatButton);
|
|
}
|
|
|
|
%this.unappliedChanges.empty();
|
|
|
|
MainMenuButtonList.hidden = true;
|
|
|
|
OptionsMenuCategoryList.setAsActiveMenuList();
|
|
|
|
OptionsButtonHolder.setActive();
|
|
|
|
OptionsMenuInputHandler.setFirstResponder();
|
|
}
|
|
|
|
function OptionsButtonHolder::onWake(%this)
|
|
{
|
|
%this-->resetButton.set("btn_back", "R", "Reset", "OptionsMenu.resetToDefaults();");
|
|
%this-->applyButton.set("btn_start", "Return", "Apply", "OptionsMenu.apply();");
|
|
%this-->backButton.set("btn_b", "Escape", "Back", "OptionsMenu.backOut();");
|
|
|
|
//OptionsMenuCategoryList.getObject(0).performClick();
|
|
}
|
|
|
|
function OptionsMenu::apply(%this)
|
|
{
|
|
//Now we run through our list of unapplied changes and... apply them.
|
|
%hasKeybindChanges = false;
|
|
%hasVideoChanges = false;
|
|
%hasPostFXChanges = false;
|
|
%hasAudioChanges = false;
|
|
for(%i=0; %i < %this.unappliedChanges.count(); %i++)
|
|
{
|
|
%targetVar = %this.unappliedChanges.getKey(%i);
|
|
%newValue = %this.unappliedChanges.getValue(%i);
|
|
|
|
//First, lets just check through our action map names, see if any match
|
|
%wasKeybind = false;
|
|
for(%am=0; %am < ActionMapGroup.getCount(); %am++)
|
|
{
|
|
%actionMap = ActionMapGroup.getObject(%am);
|
|
|
|
if(%actionMap == GlobalActionMap.getId())
|
|
continue;
|
|
|
|
%actionMapName = %actionMap.humanReadableName $= "" ? %actionMap.getName() : %actionMap.humanReadableName;
|
|
if(%actionMapName $= %targetVar)
|
|
{
|
|
%hasKeybindChanges = true;
|
|
%wasKeybind = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(!%wasKeybind)
|
|
{
|
|
%currentValue = getVariable(%targetVar);
|
|
if(%currentValue !$= %newValue)
|
|
{
|
|
setVariable(%targetVar, %newValue);
|
|
|
|
//now, lets check for special cases that need additional handling
|
|
//for updates
|
|
if ( %targetVar $= "$pref::Video::displayDevice" )
|
|
{
|
|
MessageBoxOK( "Change requires restart", "Please restart the game for a display device change to take effect." );
|
|
}
|
|
else if(startsWith(%targetVar, "$pref::Graphics::"))
|
|
{
|
|
//isolate the quality group name, like $pref::Graphics::LightingQuality
|
|
//we grab LightingQuality
|
|
%qualityGroupName = getSubStr(%targetVar, 17);
|
|
if(isObject(%qualityGroupName @ "List"))
|
|
{
|
|
//yep, it's a quality group, so apply it
|
|
(%qualityGroupName @ "List").applySetting(%newValue);
|
|
}
|
|
|
|
if(%qualityGroupName $= "TextureQuality")
|
|
{
|
|
reloadTextures();
|
|
}
|
|
}
|
|
else if(startsWith(%targetVar, "$pref::PostFX::"))
|
|
{
|
|
%hasPostFXChanges = true;
|
|
}
|
|
else if(startsWith(%targetVar, "$pref::Video::"))
|
|
{
|
|
%hasVideoChanges = true;
|
|
}
|
|
else if(startsWith(%targetVar, "$pref::SFX::"))
|
|
{
|
|
%hasAudioChanges = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//If we had keybind changes, go ahead and save those out
|
|
if(%hasKeybindChanges)
|
|
{
|
|
%prefPath = getPrefpath();
|
|
|
|
%actionMapCount = ActionMapGroup.getCount();
|
|
|
|
%actionMapList = "";
|
|
%append = false;
|
|
for(%i=0; %i < %actionMapCount; %i++)
|
|
{
|
|
%actionMap = ActionMapGroup.getObject(%i);
|
|
|
|
if(%actionMap == GlobalActionMap.getId())
|
|
continue;
|
|
|
|
%actionMap.save( %prefPath @ "/keybinds." @ $TorqueScriptFileExtension, %append );
|
|
|
|
if(%append != true)
|
|
%append = true;
|
|
}
|
|
}
|
|
|
|
if(%hasPostFXChanges)
|
|
{
|
|
updatePostFXSettings();
|
|
}
|
|
|
|
if(%hasVideoChanges)
|
|
{
|
|
updateDisplaySettings();
|
|
}
|
|
|
|
if(%hasAudioChanges)
|
|
{
|
|
updateAudioSettings();
|
|
}
|
|
|
|
//Finally, write our prefs to file
|
|
%prefPath = getPrefpath();
|
|
export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false);
|
|
|
|
OptionsMenu.unappliedChanges.empty();
|
|
}
|
|
|
|
function OptionsMenu::resetToDefaults(%this)
|
|
{
|
|
MessageBoxOKCancel("", "This will set the graphical settings back to the auto-detected defaults. Do you wish to continue?", "AutodetectGraphics();", "");
|
|
}
|
|
|
|
//
|
|
//
|
|
//
|
|
function populateDisplaySettingsList()
|
|
{
|
|
OptionsMenuSettingsList.clear();
|
|
|
|
OptionName.setText("");
|
|
OptionDescription.setText("");
|
|
|
|
//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", "$pref::Video::DisplayAPI", %apiList, false, "", true, "The display API used for rendering.", %displayDevice);
|
|
|
|
%numDevices = Canvas.getMonitorCount();
|
|
%devicesList = "";
|
|
for(%i = 0; %i < %numDevices; %i++)
|
|
{
|
|
%device = (%i+1) @ " - " @ Canvas.getMonitorName(%i);
|
|
if(%i==0)
|
|
%devicesList = %device;
|
|
else
|
|
%devicesList = %devicesList @ "\t" @ %device;
|
|
}
|
|
|
|
%selectedDevice = getField(%devicesList, $pref::Video::deviceId);
|
|
OptionsMenuSettingsList.addOptionRow("Display Device", "$pref::Video::deviceId", %devicesList, false, "", true, "The display devices the window should be on.", %selectedDevice);
|
|
|
|
if (%numDevices > 1)
|
|
OptionsMenuSettingsList.setRowEnabled(1, true);
|
|
else
|
|
OptionsMenuSettingsList.setRowEnabled(1, false);
|
|
|
|
%mode = getField($Video::ModeTags, $pref::Video::deviceMode);
|
|
OptionsMenuSettingsList.addOptionRow("Window Mode", "$pref::Video::deviceMode", $Video::ModeTags, false, "", true, "", %mode);
|
|
|
|
%resolutionList = getScreenResolutionList($pref::Video::deviceId, $pref::Video::deviceMode);
|
|
OptionsMenuSettingsList.addOptionRow("Resolution", "$pref::Video::Resolution", %resolutionList, false, "onDisplayResChange", true, "Resolution of the game window", _makePrettyResString( $pref::Video::mode ));
|
|
|
|
//If they're doing borderless, the window resolution must match the display resolution
|
|
if(%mode !$= "Borderless")
|
|
OptionsMenuSettingsList.setRowEnabled(3, true);
|
|
else
|
|
OptionsMenuSettingsList.setRowEnabled(3, false);
|
|
|
|
OptionsMenuSettingsList.addOptionRow("VSync", "$pref::Video::disableVerticalSync", "No\tYes", false, "", true, "", convertBoolToYesNo(!$pref::Video::disableVerticalSync));
|
|
|
|
|
|
%refreshList = getScreenRefreshList($pref::Video::mode);
|
|
OptionsMenuSettingsList.addOptionRow("Refresh Rate", "$pref::Video::RefreshRate", %refreshList, false, "", true, "", $pref::Video::RefreshRate);
|
|
|
|
//move to gameplay tab
|
|
OptionsMenuSettingsList.addSliderRow("Field of View", "", 75, 5, "65 100", "");
|
|
|
|
OptionsMenuSettingsList.addSliderRow("Brightness", "", 0.5, 0.1, "0 1", "");
|
|
OptionsMenuSettingsList.addSliderRow("Contrast", "", 0.5, 0.1, "0 1", "");
|
|
}
|
|
|
|
/*function OptionsMenu::applyDisplaySettings(%this)
|
|
{
|
|
%newDevice = OptionsMenuSettingsList.getCurrentOption(0);
|
|
|
|
// Change the device.
|
|
if ( %newDevice !$= $pref::Video::displayDevice )
|
|
{
|
|
$pref::Video::displayDevice = %newDevice;
|
|
if( %newDevice !$= getDisplayDeviceInformation() )
|
|
MessageBoxOK( "Change requires restart", "Please restart the game for a display device change to take effect." );
|
|
|
|
$changingDisplayDevice = %newDevice;
|
|
}
|
|
|
|
updateDisplaySettings();
|
|
|
|
echo("Exporting client prefs");
|
|
%prefPath = getPrefpath();
|
|
export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false);
|
|
}*/
|
|
|
|
//
|
|
//
|
|
//
|
|
function populateGraphicsSettingsList()
|
|
{
|
|
OptionsMenuSettingsList.clear();
|
|
|
|
OptionName.setText("");
|
|
OptionDescription.setText("");
|
|
|
|
%yesNoList = "No\tYes";
|
|
%onOffList = "Off\tOn";
|
|
%highMedLow = "Low\tMedium\tHigh";
|
|
%anisoFilter = "Off\t4\t8\t16";
|
|
%aaFilter = "Off\t1\t2\t4";
|
|
OptionsMenuSettingsList.addOptionRow("Lighting Quality", "$pref::Graphics::LightingQuality", getQualityLevels(LightingQualityList), false, "", true, "Amount and drawdistance of local lights", getCurrentQualityLevel(LightingQualityList));
|
|
OptionsMenuSettingsList.addOptionRow("Shadow Quality", "$pref::Graphics::ShadowQuality", getQualityLevels(ShadowQualityList), false, "", true, "Shadow revolution quality", getCurrentQualityLevel(ShadowQualityList));
|
|
OptionsMenuSettingsList.addOptionRow("Soft Shadow Quality", "$pref::Graphics::SoftShadowQuality", getQualityLevels(SoftShadowList), false, "", true, "Amount of softening applied to shadowmaps", getCurrentQualityLevel(SoftShadowList));
|
|
OptionsMenuSettingsList.addOptionRow("Mesh Quality", "$pref::Graphics::MeshQuality", getQualityLevels(MeshQualityGroup), false, "", true, "Fidelity of rendering of mesh objects", getCurrentQualityLevel(MeshQualityGroup));
|
|
OptionsMenuSettingsList.addOptionRow("Object Draw Distance", "$pref::Graphics::ObjectDrawDistance", getQualityLevels(MeshDrawDistQualityGroup), false, "", true, "Dictates if and when static objects fade out in the distance", getCurrentQualityLevel(MeshDrawDistQualityGroup));
|
|
OptionsMenuSettingsList.addOptionRow("Texture Quality", "$pref::Graphics::TextureQuality", getQualityLevels(TextureQualityGroup), false, "", true, "Fidelity of textures", getCurrentQualityLevel(TextureQualityGroup));
|
|
OptionsMenuSettingsList.addOptionRow("Terrain Quality", "$pref::Graphics::TerrainQuality", getQualityLevels(TerrainQualityGroup), false, "", true, "Quality level of terrain objects", getCurrentQualityLevel(TerrainQualityGroup));
|
|
OptionsMenuSettingsList.addOptionRow("Decal Lifetime", "$pref::Graphics::DecalLifetime", getQualityLevels(DecalLifetimeGroup), false, "", true, "How long decals are rendered", getCurrentQualityLevel(DecalLifetimeGroup));
|
|
OptionsMenuSettingsList.addOptionRow("Ground Cover Density", "$pref::Graphics::GroundCoverDensity", getQualityLevels(GroundCoverDensityGroup), false, "", true, "Density of ground cover items, such as grass", getCurrentQualityLevel(GroundCoverDensityGroup));
|
|
OptionsMenuSettingsList.addOptionRow("Shader Quality", "$pref::Graphics::ShaderQuality", getQualityLevels(ShaderQualityGroup), false, "", true, "Dictates the overall shader quality level, adjusting what features are enabled.", getCurrentQualityLevel(ShaderQualityGroup));
|
|
OptionsMenuSettingsList.addOptionRow("Anisotropic Filtering", "$pref::Video::defaultAnisotropy", %anisoFilter, false, "", true, "Amount of Anisotropic Filtering on textures, which dictates their sharpness at a distance", $pref::Video::defaultAnisotropy);
|
|
OptionsMenuSettingsList.addOptionRow("Anti-Aliasing", "$pref::Video::AA", %aaFilter, false, "", true, "Amount of Post-Processing Anti-Aliasing applied to rendering", $pref::Video::AA);
|
|
OptionsMenuSettingsList.addOptionRow("Parallax", "$pref::Video::disableParallaxMapping", %onOffList, false, "", true, "Whether the surface parallax shader effect is enabled", convertBoolToOnOff(!$pref::Video::disableParallaxMapping));
|
|
OptionsMenuSettingsList.addOptionRow("Water Reflections", "$pref::Water::disableTrueReflections", %onOffList, false, "", true, "Whether water reflections are enabled", convertBoolToOnOff(!$pref::Water::disableTrueReflections));
|
|
OptionsMenuSettingsList.addOptionRow("SSAO", "$pref::PostFX::EnableSSAO", %onOffList, false, "", true, "Whether Screen-Space Ambient Occlusion is enabled", convertBoolToOnOff($pref::PostFX::EnableSSAO));
|
|
OptionsMenuSettingsList.addOptionRow("Depth of Field", "$pref::PostFX::EnableDOF", %onOffList, false, "", true, "Whether the Depth of Field effect is enabled", convertBoolToOnOff($pref::PostFX::EnableDOF));
|
|
OptionsMenuSettingsList.addOptionRow("Vignette", "$pref::PostFX::EnableVignette", %onOffList, false, "", true, "Whether the vignette effect is enabled", convertBoolToOnOff($pref::PostFX::EnableVignette));
|
|
OptionsMenuSettingsList.addOptionRow("Light Rays", "$pref::PostFX::EnableLightRays", %onOffList, false, "", true, "Whether the light rays effect is enabled", convertBoolToOnOff($pref::PostFX::EnableLightRays));
|
|
}
|
|
|
|
function updateDisplaySettings()
|
|
{
|
|
//Update the display settings now
|
|
%deviceName = getDisplayDeviceName();
|
|
%newDeviceID = getWord(%deviceName, 0) - 1;
|
|
%deviceModeName = getField($Video::ModeTags, $pref::Video::deviceMode);
|
|
%newDeviceMode = 0;
|
|
foreach$(%modeName in $Video::ModeTags)
|
|
{
|
|
if (%deviceModeName $= %modeName)
|
|
break;
|
|
else
|
|
%newDeviceMode++;
|
|
}
|
|
|
|
%newRes = $pref::Video::Resolution;
|
|
%newBpp = 32; // ... its not 1997 anymore.
|
|
%newFullScreen = %deviceModeName $= "Fullscreen" ? true : false;
|
|
%newRefresh = $pref::Video::RefreshRate;
|
|
%newVsync = !$pref::Video::disableVerticalSync;
|
|
%newFSAA = $pref::Video::AA;
|
|
|
|
// Build the final mode string.
|
|
%newMode = $pref::Video::Resolution SPC %newFullScreen SPC %newBpp SPC %newRefresh SPC %newFSAA;
|
|
|
|
// Change the video mode.
|
|
if ( %newMode !$= $pref::Video::mode || %newDeviceID != $pref::Video::deviceId ||
|
|
%newVsync != $pref::Video::disableVerticalSync || %newDeviceMode != $pref::Video::deviceMode)
|
|
{
|
|
//****Edge Case Hack
|
|
// If we're in fullscreen mode and switching to a different monitor at the
|
|
// same resolution and maintaining fullscreen, GFX...WindowTarget::resetMode()
|
|
// will early-out because there is no "mode change" and the monitor change
|
|
// will not get applied. Instead of modifying platform code, we're going to
|
|
// move onto the new monitor in borderless and immediately switch to FS.
|
|
if (%newFullScreen && $pref::Video::FullScreen &&
|
|
($pref::Video::Resolution $= %newRes) && ($pref::Video::deviceId != %newDeviceID))
|
|
{
|
|
$pref::Video::deviceId = %newDeviceID;
|
|
$pref::Video::deviceMode = $Video::ModeBorderless;
|
|
%tmpModeStr = Canvas.getMonitorMode(%newDeviceID, 0);
|
|
Canvas.setVideoMode(%tmpModeStr.x, %tmpModeStr.y, false, 32, getWord(%tmpModeStr, $WORD::REFRESH), %newFSAA);
|
|
}
|
|
|
|
$pref::Video::mode = %newMode;
|
|
$pref::Video::disableVerticalSync = %newVsync;
|
|
$pref::Video::deviceId = %newDeviceID;
|
|
$pref::Video::deviceMode = %newDeviceMode;
|
|
$pref::Video::Resolution = %newRes;
|
|
$pref::Video::FullScreen = %newFullScreen;
|
|
$pref::Video::RefreshRate = %newRefresh;
|
|
$pref::Video::AA = %newFSAA;
|
|
configureCanvas();
|
|
}
|
|
}
|
|
|
|
function updatePostFXSettings()
|
|
{
|
|
PostFXManager.settingsEffectSetEnabled(SSAOPostFx, $pref::PostFX::EnableSSAO);
|
|
PostFXManager.settingsEffectSetEnabled(DOFPostEffect, $pref::PostFX::EnableDOF);
|
|
PostFXManager.settingsEffectSetEnabled(LightRayPostFX, $pref::PostFX::EnableLightRays);
|
|
PostFXManager.settingsEffectSetEnabled(vignettePostFX, $pref::PostFX::EnableVignette);
|
|
}
|
|
|
|
//
|
|
//
|
|
//
|
|
function populateAudioSettingsList()
|
|
{
|
|
OptionsMenuSettingsList.clear();
|
|
|
|
OptionName.setText("");
|
|
OptionDescription.setText("");
|
|
|
|
%buffer = sfxGetAvailableDevices();
|
|
%count = getRecordCount( %buffer );
|
|
%audioDriverList = "";
|
|
%audioProviderList = "";
|
|
%audioDeviceList = "";
|
|
|
|
$currentAudioProvider = $currentAudioProvider $= "" ? $pref::SFX::provider : $currentAudioProvider;
|
|
|
|
for(%i = 0; %i < %count; %i++)
|
|
{
|
|
%record = getRecord(%buffer, %i);
|
|
%provider = getField(%record, 0);
|
|
%device = getField(%record, 1);
|
|
|
|
//When the client is actually running, we don't care about null audo devices
|
|
if(%provider $= "null")
|
|
continue;
|
|
|
|
if(%audioProviderList $= "")
|
|
%audioProviderList = %provider;
|
|
else
|
|
%audioProviderList = %audioProviderList @ "\t" @ %provider;
|
|
|
|
if(%provider $= $currentAudioProvider)
|
|
{
|
|
if(%audioDeviceList $= "")
|
|
%audioDeviceList = %device;
|
|
else
|
|
%audioDeviceList = %audioDeviceList @ "\t" @ %device;
|
|
}
|
|
}
|
|
|
|
OptionsMenuSettingsList.addOptionRow("Audio Provider", "$pref::SFX::AudioProvider", %audioProviderList, false, "audioProviderChanged", true, "", $currentAudioProvider);
|
|
OptionsMenuSettingsList.addOptionRow("Audio Device", "$pref::SFX::device", %audioDeviceList, false, "", true, $pref::SFX::device);
|
|
|
|
OptionsMenuSettingsList.addSliderRow("Master Volume", "$pref::SFX::masterVolume", $pref::SFX::masterVolume, 0.1, "0 1", "");
|
|
OptionsMenuSettingsList.addSliderRow("GUI Volume", "$pref::SFX::channelVolume[ $GuiAudioType]", $pref::SFX::channelVolume[ $GuiAudioType], 0.1, "0 1", "");
|
|
OptionsMenuSettingsList.addSliderRow("Effects Volume", "$pref::SFX::channelVolume[ $SimAudioType ]", $pref::SFX::channelVolume[ $SimAudioType ], 0.1, "0 1", "");
|
|
OptionsMenuSettingsList.addSliderRow("Music Volume", "$pref::SFX::channelVolume[ $MusicAudioType ]", $pref::SFX::channelVolume[ $MusicAudioType ], 0.1, "0 1", "");
|
|
}
|
|
|
|
function audioProviderChanged()
|
|
{
|
|
//Get the option we have set for the provider
|
|
%provider = OptionsMenuSettingsList.getCurrentOption(0);
|
|
$currentAudioProvider = %provider;
|
|
|
|
//And now refresh the list to get the correct devices
|
|
populateAudioSettingsList();
|
|
}
|
|
|
|
function updateAudioSettings()
|
|
{
|
|
//$pref::SFX::masterVolume = OptionsMenuSettingsList.getValue(2);
|
|
sfxSetMasterVolume( $pref::SFX::masterVolume );
|
|
|
|
//$pref::SFX::channelVolume[ $GuiAudioType ] = OptionsMenuSettingsList.getValue(3);
|
|
//$pref::SFX::channelVolume[ $SimAudioType ] = OptionsMenuSettingsList.getValue(4);
|
|
//$pref::SFX::channelVolume[ $MusicAudioType ] = OptionsMenuSettingsList.getValue(5);
|
|
|
|
sfxSetChannelVolume( $GuiAudioType, $pref::SFX::channelVolume[ $GuiAudioType ] );
|
|
sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ $SimAudioType ] );
|
|
sfxSetChannelVolume( $MusicAudioType, $pref::SFX::channelVolume[ $MusicAudioType ] );
|
|
|
|
//$pref::SFX::provider = OptionsMenuSettingsList.getCurrentOption(0);
|
|
//$pref::SFX::device = OptionsMenuSettingsList.getCurrentOption(1);
|
|
|
|
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 populateKeyboardMouseSettingsList()
|
|
{
|
|
OptionsMenuSettingsList.clear();
|
|
|
|
OptionName.setText("");
|
|
OptionDescription.setText("");
|
|
|
|
$remapListDevice = "keyboard";
|
|
fillRemapList();
|
|
|
|
//OptionsMenuSettingsList.refresh();
|
|
}
|
|
|
|
function populateGamepadSettingsList()
|
|
{
|
|
OptionsMenuSettingsList.clear();
|
|
|
|
OptionName.setText("");
|
|
OptionDescription.setText("");
|
|
|
|
$remapListDevice = "gamepad";
|
|
fillRemapList();
|
|
|
|
OptionsMenuSettingsList.updateStack();
|
|
}
|
|
|
|
//
|
|
//
|
|
//
|
|
function OptionsMenuList::activateRow(%this)
|
|
{
|
|
OptionsMenuSettingsList.setFirstResponder();
|
|
}
|
|
|
|
function OptionsMenu::backOut(%this)
|
|
{
|
|
if(%this.unappliedChanges.count() != 0)
|
|
{
|
|
MessageBoxOKCancel("Discard Changes?", "You have unapplied changes to your settings, do you wish to continue?", "OptionsMenu.doOptionsMenuBackOut();", "");
|
|
}
|
|
else
|
|
{
|
|
%this.doOptionsMenuBackOut();
|
|
}
|
|
}
|
|
|
|
function OptionsMenu::doOptionsMenuBackOut(%this)
|
|
{
|
|
//save the settings and then back out
|
|
if(OptionsMain.hidden == false)
|
|
{
|
|
//we're not in a specific menu, so we're actually exiting
|
|
Canvas.popDialog(OptionsMenu);
|
|
|
|
if(isObject(OptionsMenu.returnGui) && OptionsMenu.returnGui.isMethod("onReturnTo"))
|
|
OptionsMenu.returnGui.onReturnTo();
|
|
}
|
|
else
|
|
{
|
|
OptionsMain.hidden = false;
|
|
ControlsMenu.hidden = true;
|
|
GraphicsMenu.hidden = true;
|
|
CameraMenu.hidden = true;
|
|
AudioMenu.hidden = true;
|
|
ScreenBrightnessMenu.hidden = true;
|
|
}
|
|
}
|
|
|
|
function OptionsMenuSettingsList::setRowEnabled(%this, %row, %status)
|
|
{
|
|
%option = %this.getObject(%row);
|
|
if(isObject(%option))
|
|
{
|
|
%option.setEnabled(%status);
|
|
}
|
|
}
|
|
|
|
function OptionsMenuSettingsList::addOptionRow(%this, %label, %targetPrefVar, %optionsList, %wrapOptions, %callback, %enabled, %description, %defaultValue)
|
|
{
|
|
if(%enabled $= "")
|
|
%enabled = true;
|
|
|
|
%optionsRowSize = 30;
|
|
%optionColumnWidth = %this.extent.x - 450;//todo, calculate off longest option text?
|
|
|
|
%option = new GuiGameSettingsCtrl() {
|
|
class = "MenuOptionsButton";
|
|
profile = "GuiMenuButtonProfile";
|
|
horizSizing = "width";
|
|
vertSizing = "bottom";
|
|
position = "0 0";
|
|
extent = %this.extent.x SPC %optionsRowSize;
|
|
columnSplit = %optionColumnWidth;
|
|
useMouseEvents = true;
|
|
previousBitmapAsset = "UI:previousOption_n_image";
|
|
nextBitmapAsset = "UI:nextOption_n_image";
|
|
};
|
|
|
|
%option.targetPrefVar = %targetPrefVar; //create a var-option association
|
|
|
|
//now some override trickery, if we have a value cached for unapplied changes, swapsies the defaultValue out
|
|
//with the unapplied, allowing us to change options categories without losing changes
|
|
%unappliedPrefIndex = OptionsMenu.unappliedChanges.getIndexFromValue(%targetPrefVar);
|
|
if(%unappliedPrefIndex != -1)
|
|
{
|
|
%unappliedValue = OptionsMenu.unappliedChanges.getValue(%unappliedPrefIndex);
|
|
%defaultValue = %unappliedValue;
|
|
}
|
|
|
|
%option.setListSetting(%label, %optionsList, %wrapOptions, %callback, %enabled, %description, %defaultValue);
|
|
|
|
%this.add(%option);
|
|
}
|
|
|
|
function OptionsMenuSettingsList::addSliderRow(%this, %label, %targetPrefVar, %defaultValue, %increment, %range, %callback, %enabled, %description)
|
|
{
|
|
if(%enabled $= "")
|
|
%enabled = true;
|
|
|
|
%optionsRowSize = 30;
|
|
%optionColumnWidth = %this.extent.x - 450;//todo, calculate off longest option text?
|
|
|
|
%option = new GuiGameSettingsCtrl() {
|
|
class = "MenuOptionsButton";
|
|
profile = "GuiMenuButtonProfile";
|
|
horizSizing = "width";
|
|
vertSizing = "bottom";
|
|
position = "0 0";
|
|
extent = %this.extent.x SPC %optionsRowSize;
|
|
columnSplit = %optionColumnWidth;
|
|
useMouseEvents = true;
|
|
};
|
|
|
|
%option.targetPrefVar = %targetPrefVar; //create a var-option association
|
|
|
|
//now some override trickery, if we have a value cached for unapplied changes, swapsies the defaultValue out
|
|
//with the unapplied, allowing us to change options categories without losing changes
|
|
%unappliedPrefIndex = OptionsMenu.unappliedChanges.getIndexFromValue(%targetPrefVar);
|
|
if(%unappliedPrefIndex != -1)
|
|
{
|
|
%unappliedValue = OptionsMenu.unappliedChanges.getValue(%unappliedPrefIndex);
|
|
%defaultValue = %unappliedValue;
|
|
}
|
|
|
|
%option.setSliderSetting(%label, %defaultValue, %increment, %range, %callback, %enabled, %description);
|
|
|
|
%this.add(%option);
|
|
}
|
|
|
|
function OptionsMenuSettingsList::addKeybindRow(%this, %label, %bitmapName, %callback, %enabled, %description)
|
|
{
|
|
if(%enabled $= "")
|
|
%enabled = true;
|
|
|
|
%optionsRowSize = 40;
|
|
%optionColumnWidth = %this.extent.x - 450;
|
|
|
|
%option = new GuiGameSettingsCtrl() {
|
|
class = "MenuOptionsButton";
|
|
profile = "GuiMenuButtonProfile";
|
|
horizSizing = "width";
|
|
vertSizing = "bottom";
|
|
position = "0 0";
|
|
extent = %this.extent.x SPC %optionsRowSize;
|
|
columnSplit = %optionColumnWidth;
|
|
useMouseEvents = true;
|
|
};
|
|
|
|
%option.setKeybindSetting(%label, %bitmapName, %callback, %enabled, %description);
|
|
|
|
%this.add(%option);
|
|
}
|
|
|
|
//
|
|
function OptionsMenuCategoryList::onNavigate(%this, %index)
|
|
{
|
|
%this.getObject(%index).performClick();
|
|
}
|
|
|
|
function convertOptionToBool(%val)
|
|
{
|
|
if(%val $= "yes" || %val $= "on")
|
|
return 1;
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
function convertBoolToYesNo(%val)
|
|
{
|
|
if(%val == 1)
|
|
return "Yes";
|
|
else
|
|
return "No";
|
|
}
|
|
|
|
function convertBoolToOnOff(%val)
|
|
{
|
|
if(%val == 1)
|
|
return "On";
|
|
else
|
|
return "Off";
|
|
}
|
|
|
|
function onDisplayModeChange(%val)
|
|
{
|
|
// The display device (monitor) or screen mode has changed. Refill the
|
|
// resolution list with only available options.
|
|
%deviceName = OptionsMenuSettingsList.getCurrentOption(1);
|
|
%newDeviceID = getWord(%deviceName, 0) - 1;
|
|
%deviceModeName = OptionsMenuSettingsList.getCurrentOption(2);
|
|
%newDeviceMode = 0;
|
|
foreach$(%modeName in $Video::ModeTags)
|
|
{
|
|
if (%deviceModeName $= %modeName)
|
|
break;
|
|
else
|
|
%newDeviceMode++;
|
|
}
|
|
%resolutionList = getScreenResolutionList(%newDeviceID, %newDeviceMode);
|
|
|
|
if (%newDeviceMode == $Video::ModeBorderless)
|
|
{ // If we're switching to borderless, default to monitor res on Windows OS,
|
|
// monitor usable area for other platforms.
|
|
if ($platform $= "windows")
|
|
%newRes = getWords(Canvas.getMonitorRect(%newDeviceID), 2);
|
|
else
|
|
%newRes = getWords(Canvas.getMonitorUsableRect(%newDeviceID), 2);
|
|
}
|
|
else
|
|
{ // Otherwise, if our old resolution is still in the list, attempt to reset it.
|
|
%oldRes = getWord(OptionsMenuSettingsList.getCurrentOption(3), 0) SPC getWord(OptionsMenuSettingsList.getCurrentOption(3), 2);
|
|
|
|
%found = false;
|
|
%retCount = getFieldCount(%resolutionList);
|
|
for (%i = 0; %i < %retCount; %i++)
|
|
{
|
|
%existingEntry = getField(%resolutionList, %i);
|
|
if ((%existingEntry.x $= %oldRes.x) && (%existingEntry.z $= %oldRes.y))
|
|
{
|
|
%found = true;
|
|
%newRes = %oldRes;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!%found)
|
|
{ // Pick the best resoltion available for the device and mode
|
|
%newRes = Canvas.getBestCanvasRes(%newDeviceID, %newDeviceMode);
|
|
}
|
|
}
|
|
|
|
if(%newDeviceMode == $Video::ModeBorderless)
|
|
OptionsMenuSettingsList.setRowEnabled(3, false);
|
|
else
|
|
OptionsMenuSettingsList.setRowEnabled(3, true);
|
|
|
|
OptionsMenuSettingsList.setOptions(3, %resolutionList);
|
|
OptionsMenuSettingsList.selectOption(3, _makePrettyResString(%newRes));
|
|
}
|
|
|
|
function onDisplayResChange(%val)
|
|
{ // The resolution has changed. Setup refresh rates available at this res.
|
|
%newRes = getWord(OptionsMenuSettingsList.getCurrentOption(3), 0) SPC getWord(OptionsMenuSettingsList.getCurrentOption(3), 2);
|
|
%refreshList = getScreenRefreshList(%newRes);
|
|
|
|
// If our old rate still exists, select it
|
|
%oldRate = OptionsMenuSettingsList.getCurrentOption(5);
|
|
%retCount = getFieldCount(%refreshList);
|
|
for (%i = 0; %i < %retCount; %i++)
|
|
{
|
|
%existingEntry = getField(%refreshList, %i);
|
|
%newRate = %existingEntry;
|
|
if (%existingEntry $= %oldRate)
|
|
break;
|
|
}
|
|
|
|
OptionsMenuSettingsList.setOptions(5, %refreshList);
|
|
OptionsMenuSettingsList.selectOption(5, %newRate);
|
|
}
|
|
|
|
function getDisplayDeviceName()
|
|
{
|
|
%numDevices = Canvas.getMonitorCount();
|
|
%devicesList = "";
|
|
for(%i = 0; %i < %numDevices; %i++)
|
|
{
|
|
%device = (%i+1) @ " - " @ Canvas.getMonitorName(%i);
|
|
if(%i==0)
|
|
%devicesList = %device;
|
|
else
|
|
%devicesList = %devicesList @ "\t" @ %device;
|
|
}
|
|
|
|
return getField(%devicesList, $pref::Video::deviceId);
|
|
}
|
|
//
|
|
//
|
|
//
|
|
function MenuOptionsButton::onMouseEnter(%this)
|
|
{
|
|
OptionName.setText(%this.getLabel());
|
|
OptionDescription.setText(%this.getToolTip());
|
|
}
|
|
|
|
function MenuOptionsButton::onMouseLeave(%this)
|
|
{
|
|
OptionName.setText("");
|
|
OptionDescription.setText("");
|
|
}
|
|
|
|
function MenuOptionsButton::onChange(%this)
|
|
{
|
|
%optionMode = %this.getMode();
|
|
%optionName = %this.getLabel();
|
|
%tooltipText = %this.getTooltip();
|
|
|
|
%targetVar = %this.targetPrefVar;
|
|
|
|
OptionName.setText(%optionName);
|
|
OptionDescription.setText(%tooltipText);
|
|
|
|
%currentValue = %this.getCurrentOption();
|
|
if(%currentValue !$= "")
|
|
{
|
|
if(%currentValue $= "yes" || %currentValue $= "on")
|
|
%saveReadyValue = 1;
|
|
else if(%currentValue $= "no" || %currentValue $= "off")
|
|
%saveReadyValue = 0;
|
|
else
|
|
%saveReadyValue = %currentValue;
|
|
|
|
%prefIndex = OptionsMenu.unappliedChanges.getIndexFromKey(%targetVar);
|
|
if(%prefIndex == -1)
|
|
OptionsMenu.unappliedChanges.add(%targetVar, %saveReadyValue);
|
|
else
|
|
OptionsMenu.unappliedChanges.setValue(%saveReadyValue, %prefIndex);
|
|
}
|
|
}
|
|
|
|
function OptionsMenu::onKeybindChanged(%this, %actionMap, %keybind)
|
|
{
|
|
%prefIndex = OptionsMenu.unappliedChanges.getIndexFromKey(%actionMap);
|
|
if(%prefIndex == -1)
|
|
OptionsMenu.unappliedChanges.add(%actionMap, %keybind);
|
|
else
|
|
OptionsMenu.unappliedChanges.setValue(%keybind, %prefIndex);
|
|
}
|
|
|
|
//
|
|
// Indicates what category the options item should be added into
|
|
//
|
|
function addOptionsMenuCategory(%categoryName, %selectCallback)
|
|
{
|
|
OptionsMenu.optionsCategories.add(%categoryName, %selectCallback);
|
|
}
|
|
|
|
function removeOptionsMenuCategory(%categoryName)
|
|
{
|
|
%index = OptionsMenu.optionsCategories.getIndexFromKey(%categoryName);
|
|
if(%index != -1)
|
|
OptionsMenu.optionsCategories.erase(%index);
|
|
}
|
|
|
|
function addListOption(%label, %description, %targetPrefVar, %optionsList, %wrapOptions, %callback, %enabled)
|
|
{
|
|
if(%wrapOptions $= "")
|
|
%wrapOptions = false;
|
|
|
|
if(%enabled $= "")
|
|
%enabled = true;
|
|
|
|
OptionsMenuSettingsList.addOptionRow(%label, %targetPrefVar, %optionsList, %wrapOptions, %callback, %enabled, %description, %targetPrefVar);
|
|
}
|
|
|
|
function addSliderOption(%label, %description, %targetPrefVar, %defaultValue, %increment, %range, %callback, %enabled)
|
|
{
|
|
if(%enabled $= "")
|
|
%enabled = true;
|
|
|
|
OptionsMenuSettingsList.addSliderRow(%label, %targetPrefVar, %defaultValue, %increment, %range, %callback, %enabled, %description);
|
|
}
|
|
|
|
function addKeybindOption(%label, %description, %bitmapName, %callback, %enabled)
|
|
{
|
|
if(%enabled $= "")
|
|
%enabled = true;
|
|
|
|
OptionsMenuSettingsList.addSliderRow(%label, %bitmapName, %callback, %enabled, %description);
|
|
}
|