|
@@ -55,9 +55,11 @@ function OptionsMenu::onAdd(%this)
|
|
|
|
|
|
if(!isObject(%this.unappliedChanges))
|
|
|
{
|
|
|
- %this.unappliedChanges = new ArrayObject();
|
|
|
+ %this.unappliedChanges = new ArrayObject(OptionsMenuUnappliedChanges);
|
|
|
}
|
|
|
|
|
|
+ %this.currentCategory = "";
|
|
|
+
|
|
|
addOptionsMenuCategory("Display", "populateDisplaySettingsList();");
|
|
|
addOptionsMenuCategory("Graphics", "populateGraphicsSettingsList();");
|
|
|
addOptionsMenuCategory("Audio", "populateAudioSettingsList();");
|
|
@@ -121,12 +123,33 @@ function OptionsMenu::onWake(%this)
|
|
|
function OptionsButtonHolder::onWake(%this)
|
|
|
{
|
|
|
%this-->resetButton.set("btn_back", "R", "Reset", "OptionsMenu.resetToDefaults();");
|
|
|
- %this-->applyButton.set("btn_start", "Return", "Apply", "OptionsMenu.apply();");
|
|
|
+ %this-->selectButton.set("btn_a", "Return", "Select", "OptionsMenu.select();", true);
|
|
|
%this-->backButton.set("btn_b", "Escape", "Back", "OptionsMenu.backOut();");
|
|
|
|
|
|
//OptionsMenuCategoryList.getObject(0).performClick();
|
|
|
}
|
|
|
|
|
|
+function OptionsMenu::select(%this)
|
|
|
+{
|
|
|
+ if(OptionsMenuCategoryList.isActiveMenuList())
|
|
|
+ {
|
|
|
+ OptionsMenuSettingsList.setAsActiveMenuList();
|
|
|
+ %this.updateSelectButton();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function OptionsMenu::updateSelectButton(%this)
|
|
|
+{
|
|
|
+ if(OptionsMenuCategoryList.isActiveMenuList())
|
|
|
+ {
|
|
|
+ %this-->selectButton.setHidden(false);
|
|
|
+ }
|
|
|
+ else if(OptionsMenuSettingsList.isActiveMenuList())
|
|
|
+ {
|
|
|
+ %this-->selectButton.setHidden(true);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function OptionsMenu::apply(%this)
|
|
|
{
|
|
|
//Now we run through our list of unapplied changes and... apply them.
|
|
@@ -137,7 +160,7 @@ function OptionsMenu::apply(%this)
|
|
|
for(%i=0; %i < %this.unappliedChanges.count(); %i++)
|
|
|
{
|
|
|
%targetVar = %this.unappliedChanges.getKey(%i);
|
|
|
- %newValue = %this.unappliedChanges.getValue(%i);
|
|
|
+ %newValue = strReplace(%this.unappliedChanges.getValue(%i), "\"", "");
|
|
|
|
|
|
//First, lets just check through our action map names, see if any match
|
|
|
%wasKeybind = false;
|
|
@@ -245,6 +268,9 @@ function OptionsMenu::apply(%this)
|
|
|
export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false);
|
|
|
|
|
|
OptionsMenu.unappliedChanges.empty();
|
|
|
+
|
|
|
+ //Now we can back out of the options menu
|
|
|
+ OptionsMenu.doOptionsMenuBackOut();
|
|
|
}
|
|
|
|
|
|
function OptionsMenu::resetToDefaults(%this)
|
|
@@ -252,6 +278,40 @@ function OptionsMenu::resetToDefaults(%this)
|
|
|
MessageBoxOKCancel("", "This will set the graphical settings back to the auto-detected defaults. Do you wish to continue?", "AutodetectGraphics();", "");
|
|
|
}
|
|
|
|
|
|
+function OptionsMenu::refresh(%this)
|
|
|
+{
|
|
|
+ if(%this.currentCategory !$= "")
|
|
|
+ {
|
|
|
+ %category = %this.optionsCategories.getKey(%this.currentCategory);
|
|
|
+ %command = %this.optionsCategories.getValue(%this.currentCategory);
|
|
|
+ eval(%command);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function OptionsMenu::getOptionVariableValue(%this, %variableName)
|
|
|
+{
|
|
|
+ %unappliedPrefIndex = %this.unappliedChanges.getIndexFromKey(%variableName);
|
|
|
+ if(%unappliedPrefIndex != -1)
|
|
|
+ {
|
|
|
+ %value = %this.unappliedChanges.getValue(%unappliedPrefIndex);
|
|
|
+ return strreplace(%value, "\"", "");
|
|
|
+ }
|
|
|
+
|
|
|
+ return getVariable(%variableName);
|
|
|
+}
|
|
|
+
|
|
|
+function OptionsMenuSelectButton::onVisible(%this, %state)
|
|
|
+{
|
|
|
+ //We're sorta cheating here.
|
|
|
+ //This button should only be displayed when we're in the categories list
|
|
|
+ //so whenever the status changes, such as automatically refreshing due to
|
|
|
+ //navigation events, we'll just do a quick check to ensure we're
|
|
|
+ //in the right visibility mode
|
|
|
+ if(%state && OptionsMenuSettingsList.isActiveMenuList())
|
|
|
+ {
|
|
|
+ %this.setHidden(true);
|
|
|
+ }
|
|
|
+}
|
|
|
//
|
|
|
//
|
|
|
//
|
|
@@ -308,17 +368,16 @@ function populateDisplaySettingsList()
|
|
|
else
|
|
|
OptionsMenuSettingsList.setRowEnabled(1, false);
|
|
|
|
|
|
- %mode = getField($Video::ModeTags, $pref::Video::deviceMode);
|
|
|
+ %mode = OptionsMenu.getOptionVariableValue("$pref::Video::deviceMode");
|
|
|
+ if(isInt(%mode))
|
|
|
+ %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);
|
|
|
+ {
|
|
|
+ %resolutionList = getScreenResolutionList($pref::Video::deviceId, $pref::Video::deviceMode);
|
|
|
+ OptionsMenuSettingsList.addOptionRow("Resolution", "$pref::Video::Resolution", %resolutionList, false, "", true, "Resolution of the game window", _makePrettyResString( $pref::Video::mode ));
|
|
|
+ }
|
|
|
|
|
|
OptionsMenuSettingsList.addOptionRow("VSync", "$pref::Video::disableVerticalSync", "No\tYes", false, "", true, "", convertBoolToYesNo(!$pref::Video::disableVerticalSync));
|
|
|
|
|
@@ -333,27 +392,6 @@ function populateDisplaySettingsList()
|
|
|
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);
|
|
|
-}*/
|
|
|
-
|
|
|
//
|
|
|
//
|
|
|
//
|
|
@@ -394,6 +432,20 @@ function updateDisplaySettings()
|
|
|
//Update the display settings now
|
|
|
%deviceName = getDisplayDeviceName();
|
|
|
%newDeviceID = getWord(%deviceName, 0) - 1;
|
|
|
+
|
|
|
+ if(!isInt($pref::Video::deviceMode))
|
|
|
+ {
|
|
|
+ //probably saved out as the mode name, so just translate it back
|
|
|
+ for(%i=0; %i < getFieldCount($Video::ModeTags); %i++)
|
|
|
+ {
|
|
|
+ if(getField($Video::ModeTags, %i) $= $pref::Video::deviceMode)
|
|
|
+ {
|
|
|
+ $pref::Video::deviceMode = %i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
%deviceModeName = getField($Video::ModeTags, $pref::Video::deviceMode);
|
|
|
%newDeviceMode = 0;
|
|
|
foreach$(%modeName in $Video::ModeTags)
|
|
@@ -403,6 +455,14 @@ function updateDisplaySettings()
|
|
|
else
|
|
|
%newDeviceMode++;
|
|
|
}
|
|
|
+
|
|
|
+ if($pref::Video::deviceMode == $Video::ModeBorderless)
|
|
|
+ {
|
|
|
+ //if we're changing to borderless, we swap to the full resolution of the desktop
|
|
|
+ $pref::Video::mode = Canvas.getBestCanvasRes($pref::Video::deviceId, $pref::Video::deviceMode);
|
|
|
+
|
|
|
+ $pref::Video::Resolution = $pref::Video::mode.x SPC $pref::Video::mode.y;
|
|
|
+ }
|
|
|
|
|
|
%newRes = $pref::Video::Resolution;
|
|
|
%newBpp = 32; // ... its not 1997 anymore.
|
|
@@ -448,7 +508,7 @@ function updateDisplaySettings()
|
|
|
function updatePostFXSettings()
|
|
|
{
|
|
|
PostFXManager.settingsEffectSetEnabled(SSAOPostFx, $pref::PostFX::EnableSSAO);
|
|
|
- PostFXManager.settingsEffectSetEnabled(DOFPostEffect, $pref::PostFX::EnableDOF);
|
|
|
+ PostFXManager.settingsEffectSetEnabled(DepthOfFieldPostFX, $pref::PostFX::EnableDOF);
|
|
|
PostFXManager.settingsEffectSetEnabled(LightRayPostFX, $pref::PostFX::EnableLightRays);
|
|
|
PostFXManager.settingsEffectSetEnabled(vignettePostFX, $pref::PostFX::EnableVignette);
|
|
|
}
|
|
@@ -583,13 +643,21 @@ function OptionsMenuList::activateRow(%this)
|
|
|
|
|
|
function OptionsMenu::backOut(%this)
|
|
|
{
|
|
|
- if(%this.unappliedChanges.count() != 0)
|
|
|
+ if(OptionsMenuSettingsList.isActiveMenuList())
|
|
|
{
|
|
|
- MessageBoxOKCancel("Discard Changes?", "You have unapplied changes to your settings, do you wish to continue?", "OptionsMenu.doOptionsMenuBackOut();", "");
|
|
|
+ OptionsMenuCategoryList.setAsActiveMenuList();
|
|
|
+ %this.updateSelectButton();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- %this.doOptionsMenuBackOut();
|
|
|
+ if(%this.unappliedChanges.count() != 0)
|
|
|
+ {
|
|
|
+ MessageBoxOKCancel("Discard Changes?", "You have unapplied changes to your settings, do you wish to apply or discard them?", "OptionsMenu.apply();", "OptionsMenu.doOptionsMenuBackOut();", "Apply", "Discard");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ %this.doOptionsMenuBackOut();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -630,7 +698,7 @@ function OptionsMenuSettingsList::addOptionRow(%this, %label, %targetPrefVar, %o
|
|
|
%enabled = true;
|
|
|
|
|
|
%optionsRowSize = 30;
|
|
|
- %optionColumnWidth = %this.extent.x - 450;//todo, calculate off longest option text?
|
|
|
+ %optionColumnWidth = %this.extent.x * 0.3;//todo, calculate off longest option text?
|
|
|
|
|
|
%option = new GuiGameSettingsCtrl() {
|
|
|
class = "MenuOptionsButton";
|
|
@@ -723,6 +791,7 @@ function OptionsMenuSettingsList::addKeybindRow(%this, %label, %bitmapName, %cal
|
|
|
//
|
|
|
function OptionsMenuCategoryList::onNavigate(%this, %index)
|
|
|
{
|
|
|
+ OptionsMenu.currentCategory = %index;
|
|
|
%this.getObject(%index).performClick();
|
|
|
}
|
|
|
|
|
@@ -750,83 +819,6 @@ function convertBoolToOnOff(%val)
|
|
|
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();
|
|
@@ -880,10 +872,16 @@ function MenuOptionsButton::onChange(%this)
|
|
|
|
|
|
%prefIndex = OptionsMenu.unappliedChanges.getIndexFromKey(%targetVar);
|
|
|
if(%prefIndex == -1)
|
|
|
- OptionsMenu.unappliedChanges.add(%targetVar, %saveReadyValue);
|
|
|
+ {
|
|
|
+ echo("Setting UnappliedChanges via add: key:" @ %targetVar @", value: " @ %saveReadyValue);
|
|
|
+ OptionsMenu.unappliedChanges.add(%targetVar, "\"" @ %saveReadyValue @ "\"" );
|
|
|
+ }
|
|
|
else
|
|
|
- OptionsMenu.unappliedChanges.setValue(%saveReadyValue, %prefIndex);
|
|
|
+ OptionsMenu.unappliedChanges.setValue("\"" @ %saveReadyValue @ "\"", %prefIndex);
|
|
|
}
|
|
|
+
|
|
|
+ //Update the UI in case there's responsive logic
|
|
|
+ schedule(32, OptionsMenu, "refresh");
|
|
|
}
|
|
|
|
|
|
function OptionsMenu::onKeybindChanged(%this, %actionMap, %keybind)
|