Sfoglia il codice sorgente

Cleaned up old, deprecated apply function causing confusion
Cleaned up old refs to previous unapplied changes system
Added comments to some critical functions to better explain their behavior and purpose, as well as referencing the source files for the graphic and audio options groups

Areloch 1 anno fa
parent
commit
5d2d04791d
1 ha cambiato i file con 26 aggiunte e 200 eliminazioni
  1. 26 200
      Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript

+ 26 - 200
Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript

@@ -1,53 +1,3 @@
-//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
-
-$yesNoList = "No\tYes";
-$onOffList = "Off\tOn";
 $optionsEntryPad = 10;
 
 $OptionsMenuCategories[0] = "Video";
@@ -62,11 +12,6 @@ function OptionsMenu::onAdd(%this)
       %this.optionsCategories = new ArrayObject();
    }  
    
-   if(!isObject(%this.unappliedChanges))
-   {
-      %this.unappliedChanges = new ArrayObject(OptionsMenuUnappliedChanges);
-   }  
-   
    %this.currentCategory = "";
    
    callOnModules("populateOptionsMenuCategories", "Game");
@@ -74,8 +19,6 @@ function OptionsMenu::onAdd(%this)
 
 function OptionsMenu::onWake(%this)
 {
-   %this.unappliedChanges.empty();
-   
    %this.populateVideoSettings();
    
    %this.populateAudioSettings();
@@ -120,6 +63,9 @@ if(!isObject( OptionsMenuActionMap ) )
    OptionsMenuActionMap.bind( gamepad, btn_a, OptionsMenuActivateOption );
 }
 
+//==============================================================================
+// This function updates all the elements in the actual lists to ensure they're
+// sized, stylized and formatted correctly, as well as up to date values
 function OptionsMenuList::syncGui(%this)
 {
    %this.callOnChildren("setHighlighted", false);
@@ -265,6 +211,10 @@ function OptionsMenu::openOptionsCategory(%this, %categoryName)
    %this.syncGui();
 }
 
+//==============================================================================
+// This function updates the non-list items of the menu to be up to date and stylistically
+// complaint. This ensures keybind hint buttons are presented correctly based on the current input
+// device
 function OptionsMenu::syncGui(%this)
 {
    OptionsMenuCategoryList.callOnChildren("setHighlighted", false);
@@ -289,6 +239,9 @@ function OptionsMenu::syncGui(%this)
    OptionsMenuNextNavIcon.setBitmap(OptionsMenuActionMap.getCommandButtonBitmap(%device, "OptionsMenuNextCategory"));
 }
 
+//==============================================================================
+// Menu navigation functions
+// Primarily used by keybinds
 function OptionsMenuPrevCategory(%val)
 {
    if(%val)
@@ -323,7 +276,6 @@ function OptionsMenuNextCategory(%val)
    }
 }
 
-//
 function OptionMenuNavigatePrev(%val)
 {
    if(%val)
@@ -442,9 +394,14 @@ function OptionsMenuActivateOption(%val)
       eval(%option-->button.altCommand);
    }
 }
-//
-//
-//
+
+//==============================================================================
+// This function utilizes the VideoSettingsGroup SimGroup to populate options.
+// The object is defined in core/rendering/scripts/graphicsOptions.tscript
+// A majority of the options are statically defined, but some are dynamically populated
+// on refresh, like the display device or available resolution options.
+// Once populated, we loop over the simgroup structure to populate our option entry
+// rows in the options menu itself.
 function OptionsMenu::populateVideoSettings(%this)
 {
    VideoSettingsList.clear();
@@ -489,6 +446,11 @@ function OptionsMenu::populateVideoSettings(%this)
    }
 }
 
+//==============================================================================
+// This function utilizes the AudioSettingsGroup SimGroup to populate options.
+// The object is defined in core/sfx/scripts/audioOptions.tscript
+// Similar to the video options, it can be a mix of static and dynamically populated
+// option entries, which we then iterate over and populate the entry rows for the menu
 function OptionsMenu::populateAudioSettings(%this)
 {
    AudioSettingsList.clear();
@@ -642,6 +604,7 @@ function OptionsMenu::populateKeybinds(%this, %device, %controlsList)
    }
 }
 
+//==============================================================================
 function tryCloseOptionsMenu(%val)
 {
    if(!%val)
@@ -698,150 +661,13 @@ function doKeyRemap( %optionEntry )
 	Canvas.pushDialog( RemapDlg );
 }
 
-function OptionsMenu::apply(%this)
-{
-   //Now we run through our list of unapplied changes and... apply them.
-   %hasKeybindChanges = false;
-   %hasVideoChanges = false;
-   %hasPostFXChanges = false;
-   %hasAudioChanges = false;
-   %hasGraphicsChanges = false;
-   for(%i=0; %i < %this.unappliedChanges.count(); %i++)
-   {
-      %targetVar = %this.unappliedChanges.getKey(%i);
-      %newValue = strReplace(%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.getName();
-         if(%actionMapName $= %targetVar)
-         {
-            %hasKeybindChanges = true;
-            %wasKeybind = true;
-            break;
-         }
-      }
-      
-      if(!%wasKeybind)
-      {
-         %sanitizedVar = strReplace(%targetVar, "[", "");
-         %sanitizedVar = strReplace(%sanitizedVar, "]", "");
-         %sanitizedVar = strReplace(%sanitizedVar, ",", "_");
-         %currentValue = getVariable(%sanitizedVar);
-         if(%currentValue !$= %newValue)
-         {
-            setVariable(%targetVar, %newValue);
-            
-            //now, lets check for special cases that need additional handling
-            //for updates
-            if ( %targetVar $= "$pref::Video::displayDevice" )
-            {
-               schedule(32, 0, "MessageBoxOK", "Change requires restart", "Please restart the game for a display device change to take effect.");
-            }
-            else if(startsWith(%targetVar, "$pref::PostFX::"))
-            {
-               %hasPostFXChanges = true;
-            }
-            else if(startsWith(%targetVar, "$pref::Video::"))
-            {
-               %hasVideoChanges = true;
-               
-               //if it's the resolution, it's possible we got the human-friendly
-               //version stored off. if so, reprocess into the usable state
-               if(%targetVar $= "$pref::Video::Resolution")
-               {
-                  if(strpos(%newValue, " x ") != -1)
-                  {
-                     %newValue = strreplace(%newValue, " x ", " ");
-                     setVariable(%targetVar, %newValue);
-                  }
-               }
-               //This is a bit of hackery to have an intermediate variable because we display in text
-               //but save by index, so we take the applied name and get the index of the deviceId
-               else if(%targetVar $= "$pref::Video::displayDeviceId")
-               {
-                  %deviceId = getDisplayDeviceId($pref::Video::displayDeviceId);
-                  if(%deviceId == -1)
-                     %deviceId = 0;
-                  
-                   $pref::Video::deviceId = %deviceId;
-                   $pref::Video::displayDeviceId = "";
-               }
-            }
-            else if(startsWith(%targetVar, "$pref::SFX::"))
-            {
-               %hasAudioChanges = true;
-            }
-            else if(startsWith(%targetVar, "$pref::Graphics::"))
-            {
-               %hasGraphicsChanges = 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();
-   }
-   
-   if(%hasGraphicsChanges)
-   {
-      updateGraphicsSettings();  
-   }
-   
-   //Finally, write our prefs to file
-   %prefPath = getPrefpath();
-   export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false);
-   
-   OptionsMenu.unappliedChanges.empty();
-}
-
 function OptionsMenu::resetSettings(%this)
 {
    MessageBoxOKCancel("", "This will set the graphical settings back to the auto-detected defaults. Do you wish to continue?", "AutodetectGraphics();", "");
 }
 
+//==============================================================================
+// Option types
 function addOptionGroup(%displayName)
 {
    %group = new GuiTextCtrl() {