| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458 |
- //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;
- function OptionsMenu::onAdd(%this)
- {
- if(!isObject(%this.optionsCategories))
- {
- %this.optionsCategories = new ArrayObject();
- }
-
- if(!isObject(%this.unappliedChanges))
- {
- %this.unappliedChanges = new ArrayObject(OptionsMenuUnappliedChanges);
- }
-
- %this.currentCategory = "";
-
- callOnModules("populateOptionsMenuCategories", "Game");
- }
- function OptionsMenu::onWake(%this)
- {
- VideoSettingsList.clear();
-
- for(%i=0; %i < VideoSettingsGroup.getCount(); %i++)
- {
- %setting = VideoSettingsGroup.getObject(%i);
-
- echo(" OptionsMenu::onWake() - video: " @ %setting.class);
- if(%setting.class $= "SubOptionsGroup")
- {
- %entry = addOptionGroup();
- %entry.text = %setting.displayName;
-
- if(isObject(%entry))
- VideoSettingsList.add(%entry);
-
- for(%s=0; %s < %setting.getCount(); %s++)
- {
- %option = %setting.getObject(%s);
-
- %optionsEntry = addOptionEntry(%option);
- if(isObject(%optionsEntry))
- {
- %optionsEntry.resize(0, 0, VideoSettingsList.extent.x, %optionsEntry.extent.y);
-
- VideoSettingsList.add(%optionsEntry);
- }
- }
- }
- else if(%setting.class $= "OptionsSettings")
- {
- %optionsEntry = addOptionEntry(%option);
-
- if(isObject(%optionsEntry))
- {
- %optionsEntry.resize(0, 0, VideoSettingsList.extent.x, %optionsEntry.extent.y);
-
- VideoSettingsList.add(%optionsEntry);
- }
- }
- }
-
- $MenuList = VideoSettingsList;
-
- //Find our first non-group entry
- while($MenuList.getObject($MenuList.listPosition).class !$= OptionsListEntry && $MenuList.listPosition < $MenuList.getCount())
- {
- $MenuList.listPosition += 1;
- }
- }
- if(!isObject( OptionsMenuActionMap ) )
- {
- new ActionMap(OptionsMenuActionMap){};
-
- OptionsMenuActionMap.bind( keyboard, w, OptionMenuNavigatePrev );
- OptionsMenuActionMap.bind( keyboard, s, OptionMenuNavigateNext );
- OptionsMenuActionMap.bind( gamepad, yaxis, "D", "-0.23 0.23", OptionMenuStickNavigate );
- OptionsMenuActionMap.bind( gamepad, upov, OptionMenuNavigatePrev );
- OptionsMenuActionMap.bind( gamepad, dpov, OptionMenuNavigateNext );
-
- OptionsMenuActionMap.bind( keyboard, a, OptionMenuPrevSetting );
- OptionsMenuActionMap.bind( keyboard, d, OptionMenuNextSetting );
- OptionsMenuActionMap.bind( gamepad, xaxis, "D", "-0.23 0.23", OptionMenuStickChangeSetting );
- OptionsMenuActionMap.bind( gamepad, lpov, OptionMenuPrevSetting );
- OptionsMenuActionMap.bind( gamepad, lpov, OptionMenuNextSetting );
-
- //OptionsMenuActionMap.bind( keyboard, Enter, BaseUIActivateSelected );
- //OptionsMenuActionMap.bind( gamepad, btn_a, BaseUIActivateSelected );
- }
- function VideoSettingsList::syncGui(%this)
- {
- %this.callOnChildren("setHighlighted", false);
-
- %btn = %this.getObject(%this.listPosition);
- if(%btn.class $= "OptionsListEntry")
- %btn-->button.setHighlighted(true);
- }
- //
- function OptionMenuNavigatePrev(%val)
- {
- if(%val)
- {
- $MenuList.listPosition -= 1;
- while( $MenuList.listPosition >= 0 && $MenuList.getObject($MenuList.listPosition).class !$= OptionsListEntry)
- {
- $MenuList.listPosition -= 1;
- }
-
- if($MenuList.listPosition < 0)
- $MenuList.listPosition = 0;
-
- $MenuList.syncGUI();
- }
- }
- function OptionMenuNavigateNext(%val)
- {
- if(%val)
- {
- $MenuList.listPosition += 1;
- while($MenuList.listPosition < $MenuList.getCount() && $MenuList.getObject($MenuList.listPosition).class !$= OptionsListEntry)
- {
- $MenuList.listPosition += 1;
- }
-
- if($MenuList.listPosition >= $MenuList.getCount())
- $MenuList.listPosition = $MenuList.getCount()-1;
-
- $MenuList.syncGUI();
- }
- }
- function OptionMenuStickNavigate(%val)
- {
- if(%val == -1)
- BaseUINavigateNext(1);
- else if(%val == 1)
- mainMenuNavigateDown(1);
- }
- function OptionMenuPrevSetting(%val)
- {
- %option = $MenuList.getObject($MenuList.listPosition);
- echo("Option: " @ %option.className);
- %optionObject = %option.optionsObject;
- %currentOptionLevel = %optionObject.getObject(%option.currentOptionIndex);
-
- echo("Changed option: " @ %optionObject.optionName @ " to level: " @ %currentOptionLevel.displayName);
- /*$MenuList.listPosition -= 1;
-
- if($MenuList.listPosition < 0)
- $MenuList.listPosition = 0;*/
-
- $MenuList.syncGUI();
- }
- function OptionMenuNextSetting(%val)
- {
- %option = $MenuList.getObject($MenuList.listPosition);
- %optionObject = %option.optionsObject;
- %currentOptionLevel = %optionObject.getObject(%option.currentOptionIndex);
-
- echo("Changed option: " @ %optionObject.optionName @ " to level: " @ %currentOptionLevel.displayName);
-
- /*$MenuList.listPosition += 1;
-
- if($MenuList.listPosition >= $MenuList.getCount())
- $MenuList.listPosition = $MenuList.getCount()-1;*/
-
- $MenuList.syncGUI();
- }
- function OptionMenuStickChangeSetting(%val)
- {
-
- }
- //
- function OptionsMenu::onOpen(%this)
- {
- OptionsMenuCategoryList.clear();
-
- 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();
- $pref::Video::displayDeviceId = "";
-
- OptionsMenuCategoryList.setAsActiveMenuList();
-
- $activeMenuButtonContainer-->button1.set("btn_back", "R", "Reset", "OptionsMenu.resetToDefaults();");
- $activeMenuButtonContainer-->button2.disable();
- $activeMenuButtonContainer-->button3.set("", "Space", "Apply", "OptionsMenu.apply();");
- $activeMenuButtonContainer-->button4.set("btn_a", "", "Select", "OptionsMenu.select();");
- $activeMenuButtonContainer-->button5.set("btn_b", "Escape", "Back", %this @ ".navigation.popPage();");
- }
-
- //We capitalize on the canClose test here, because we want to prompt for unapplied options changes before
- //backing out. So when the UINavigation test canClose, we can see if we have unapplied settings and prompt
- //that via the message box and return false.
- //This gives the user a chance to choose how they wish to proceed before we allow the
- //UINavigation to move away from the options menu
- function OptionsMenu::canClose(%this)
- {
- //Another special case is us catching the 'back/pop' action by just shifting from one
- //menu list to another. In this case, we check if we were on the settings list as our active MenuList
- //if so, then the back/pop just moves us to the Category list as our active and we inform the
- //UINavigation to not close the page
- if(OptionsMenuSettingsList.isActiveMenuList())
- {
- OptionsMenuCategoryList.setAsActiveMenuList();
- return false;
- }
- else
- {
- //Here, we're on the category list as our active, so we're actually trying to leae the page
- //If we have unapplied changes, we want to prompt about them before closing the page and navigating away
- //If we don't, then we can process the popPage as normal and let the OptionsMenu close
- 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(); MainMenuGUI.popPage();", "" @ %this @ ".unappliedChanges.empty(); " @ %this @ ".navigation.popPage();",
- "Apply", "Discard");
- return false;
- }
- }
-
- return true;
- }
- function OptionsMenu::onClose(%this)
- {
-
- }
- function OptionsMenuSettingsList::onAdd(%this)
- {
- }
-
- function OptionsMenuSettingsList::getOptionsList(%this, %index)
- {
- }
- function OptionsMenu::select(%this)
- {
- if(OptionsMenuCategoryList.isActiveMenuList())
- {
- OptionsMenuSettingsList.setAsActiveMenuList();
- }
- }
- 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::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)
- {
- //cache our scroll position so we can ensure we end up back at it after the refresh
- %lastScrollPos = OptionsMenuSettingsScroll.getScrollPosition();
-
- %cat = %this.currentCategory;
- if(%this.currentCategory !$= "")
- {
- if(!isInt(%this.currentCategory))
- {
- %this.currentCategory = getOptionsCategoryIndexByName(%this.currentCategory);
- }
-
- if(%this.currentCategory == -1)
- return;
-
- %category = %this.optionsCategories.getKey(%this.currentCategory);
- %command = %this.optionsCategories.getValue(%this.currentCategory);
- eval(%command);
- }
-
- //now, because we reconstruct the displayed set, we'll force the mouse(if we're using it as our input)
- //to be poked so we can re-track to whatever control, if any, we're over
- if($activeControllerType !$= "gamepad")
- {
- Canvas.setCursorPos(Canvas.getCursorPos());
- }
-
- //restore scroll position
- OptionsMenuSettingsScroll.setScrollPosition(%lastScrollPos.x, %lastScrollPos.y);
- }
- function OptionsMenu::getOptionVariableValue(%this, %variableName)
- {
- %unappliedPrefIndex = %this.unappliedChanges.getIndexFromKey(%variableName);
- if(%unappliedPrefIndex != -1)
- {
- %value = %this.unappliedChanges.getValue(%unappliedPrefIndex);
- return strreplace(%value, "\"", "");
- }
-
- %sanitizedVar = strReplace(%variableName, "[", "");
- %sanitizedVar = strReplace(%sanitizedVar, "]", "");
- %sanitizedVar = strReplace(%sanitizedVar, ",", "_");
- return getVariable(%sanitizedVar);
- }
- 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);
- }
- }
- //
- //
- //
- function populateDisplaySettingsList()
- {
- OptionsMenuSettingsList.clear();
-
- OptionsMenu.currentCategory = "Display";
-
- if(isObject(OptionName))
- OptionName.setText("");
- if(isObject(OptionDescription))
- OptionDescription.setText("");
-
- %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);
-
- %displayDevice = OptionsMenu.getOptionVariableValue("$pref::Video::displayDevice");
- if(%displayDevice $= "")
- %displayDevice = getDisplayDeviceType();
-
- OptionsMenuSettingsList.addOptionRow("Display API", "$pref::Video::displayDevice", %apiList, false, "", true, "The display API used for rendering.", %displayDevice);
-
- %numDevices = Canvas.getMonitorCount();
-
- %devicesList = getDisplayDeviceList();
-
- if($pref::Video::displayDeviceId $= "")
- $pref::Video::displayDeviceId = getField(%devicesList, $pref::Video::deviceId);
-
- OptionsMenuSettingsList.addOptionRow("Display Device", "$pref::Video::displayDeviceId", %devicesList, false, "", true, "The display devices the window should be on.");
-
- if (%numDevices > 1)
- OptionsMenuSettingsList.setRowEnabled(1, true);
- else
- OptionsMenuSettingsList.setRowEnabled(1, false);
-
- %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);
-
- if(%mode !$= "Borderless")
- {
- %resolutionList = getScreenResolutionList($pref::Video::deviceId, $Video::Mode[%mode]);
- %resolution = OptionsMenu.getOptionVariableValue("$pref::Video::Resolution");
- if(%resolution $= "")
- %resolution = $pref::Video::mode;
-
- %resolution = _makePrettyResString(%resolution);
-
- OptionsMenuSettingsList.addOptionRow("Resolution", "$pref::Video::Resolution", %resolutionList, false, "", true, "Resolution of the game window", %resolution);
- // If the requested resolution could not be set, mark the control and pref as changed.
- %resControl = OptionsMenuSettingsList.getObject(OptionsMenuSettingsList.getCount()-1);
- if (%resControl.getCurrentOption() !$= %resolution)
- %resControl.onChange();
- }
-
- OptionsMenuSettingsList.addOptionBoolRow("VSync", "$pref::Video::enableVerticalSync", $YesNoList, false, "", true, "", "");
- %refreshList = getScreenRefreshList($pref::Video::mode);
- OptionsMenuSettingsList.addOptionRow("Refresh Rate", "$pref::Video::RefreshRate", %refreshList, false, "", true, "", OptionsMenu.getOptionVariableValue("$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 populateGraphicsSettingsList()
- {
- OptionsMenuSettingsList.clear();
-
- OptionsMenu.currentCategory = "Graphics";
-
- if(isObject(OptionName))
- OptionName.setText("");
- if(isObject(OptionDescription))
- OptionDescription.setText("");
-
- %yesNoList = "No\tYes";
- %onOffList = "Off\tOn";
- %anisoFilter = "Off\t4\t8\t16";
- %aaTypeFilter = "None\tFXAA\tSMAA\tSMAA High";
- OptionsMenuSettingsList.addOptionQualityLevelRow("Lighting Quality", "$pref::Graphics::LightingQuality",
- LightingQualityList, false, "", true, "Amount and drawdistance of local lights");
- OptionsMenuSettingsList.addOptionQualityLevelRow("Shadow Quality", "$pref::Graphics::ShadowQuality",
- ShadowQualityList, false, "", true, "Shadow revolution quality");
-
- %shadowQuality = OptionsMenu.getOptionVariableValue("$pref::Graphics::ShadowQuality");
- if(%shadowQuality !$= "None")
- {
- OptionsMenuSettingsList.addOptionQualityLevelRow("Soft Shadow Quality", "$pref::Graphics::SoftShadowQuality",
- SoftShadowList, false, "", true, "Amount of softening applied to shadowmaps");
- }
-
- OptionsMenuSettingsList.addOptionQualityLevelRow("Mesh Quality", "$pref::Graphics::MeshQuality",
- MeshQualityGroup, false, "", true, "Fidelity of rendering of mesh objects");
- OptionsMenuSettingsList.addOptionQualityLevelRow("Object Draw Distance", "$pref::Graphics::ObjectDrawDistance",
- MeshDrawDistQualityGroup, false, "", true, "Dictates if and when static objects fade out in the distance");
- OptionsMenuSettingsList.addOptionQualityLevelRow("Texture Quality", "$pref::Graphics::TextureQuality",
- TextureQualityGroup, false, "", true, "Fidelity of textures");
- OptionsMenuSettingsList.addOptionQualityLevelRow("Terrain Quality", "$pref::Graphics::TerrainQuality",
- TerrainQualityGroup, false, "", true, "Quality level of terrain objects");
- OptionsMenuSettingsList.addOptionQualityLevelRow("Decal Lifetime", "$pref::Graphics::DecalLifetime",
- DecalLifetimeGroup, false, "", true, "How long decals are rendered");
- OptionsMenuSettingsList.addOptionQualityLevelRow("Ground Cover Density", "$pref::Graphics::GroundCoverDensity",
- GroundCoverDensityGroup, false, "", true, "Density of ground cover items, such as grass");
- OptionsMenuSettingsList.addOptionQualityLevelRow("Shader Quality", "$pref::Graphics::ShaderQuality",
- ShaderQualityGroup, false, "", true, "Dictates the overall shader quality level, adjusting what features are enabled.");
- OptionsMenuSettingsList.addOptionRow("Anisotropic Filtering", "$pref::Video::defaultAnisotropy", %anisoFilter, false, "", true, "Amount of Anisotropic Filtering on textures, which dictates their sharpness at a distance");
-
- OptionsMenuSettingsList.addOptionRow("Anti-Aliasing Type", "$pref::Video::AAMode", %aaTypeFilter, false, "", true, "The Anti-Aliasing Method applied to rendering");
- OptionsMenuSettingsList.addOptionBoolRow("Parallax", "$pref::Video::enableParallaxMapping", %onOffList, false, "", true, "Whether the surface parallax shader effect is enabled", "");
- OptionsMenuSettingsList.addOptionBoolRow("Water Reflections", "$pref::Water::enableTrueReflections", %onOffList, false, "", true, "Whether water reflections are enabled", "");
-
- OptionsMenuSettingsList.addOptionBoolRow("SSAO", "$pref::PostFX::EnableSSAO", %onOffList, false, "", true, "Whether Screen-Space Ambient Occlusion is enabled");
- OptionsMenuSettingsList.addOptionBoolRow("Depth of Field", "$pref::PostFX::EnableDOF", %onOffList, false, "", true, "Whether the Depth of Field effect is enabled");
- OptionsMenuSettingsList.addOptionBoolRow("Vignette", "$pref::PostFX::EnableVignette", %onOffList, false, "", true, "Whether the vignette effect is enabled");
- OptionsMenuSettingsList.addOptionBoolRow("Light Rays", "$pref::PostFX::EnableLightRays", %onOffList, false, "", true, "Whether the light rays effect is enabled");
- }
- function updateGraphicsSettings()
- {
- if($pref::Graphics::LightingQuality !$= getCurrentQualityLevel(LightingQualityList))
- LightingQualityList.applySetting($pref::Graphics::LightingQuality);
- if($pref::Graphics::ShadowQuality !$= getCurrentQualityLevel(ShadowQualityList))
- ShadowQualityList.applySetting($pref::Graphics::ShadowQuality);
- if($pref::Graphics::SoftShadowQuality !$= getCurrentQualityLevel(SoftShadowList))
- SoftShadowList.applySetting($pref::Graphics::SoftShadowQuality);
-
- if($pref::Graphics::MeshQuality !$= getCurrentQualityLevel(MeshQualityGroup))
- MeshQualityGroup.applySetting($pref::Graphics::MeshQuality);
- if($pref::Graphics::ObjectDrawDistance !$= getCurrentQualityLevel(MeshDrawDistQualityGroup))
- MeshDrawDistQualityGroup.applySetting($pref::Graphics::ObjectDrawDistance);
- if($pref::Graphics::TextureQuality !$= getCurrentQualityLevel(TextureQualityGroup))
- {
- TextureQualityGroup.applySetting($pref::Graphics::TextureQuality);
-
- reloadTextures();
- }
- if($pref::Graphics::TerrainQuality !$= getCurrentQualityLevel(TerrainQualityGroup))
- TerrainQualityGroup.applySetting($pref::Graphics::TerrainQuality);
- if($pref::Graphics::DecalLifetime !$= getCurrentQualityLevel(DecalLifetimeGroup))
- DecalLifetimeGroup.applySetting($pref::Graphics::DecalLifetime);
- if($pref::Graphics::GroundCoverDensity !$= getCurrentQualityLevel(GroundCoverDensityGroup))
- GroundCoverDensityGroup.applySetting($pref::Graphics::GroundCoverDensity);
- if($pref::Graphics::ShaderQuality !$= getCurrentQualityLevel(ShaderQualityGroup))
- {
- ShaderQualityGroup.applySetting($pref::Graphics::ShaderQuality);
- //this has ties into postFX behaviors, so we'll force an update to it here
- updatePostFXSettings();
- }
- }
- 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)
- {
- if (%deviceModeName $= %modeName)
- break;
- 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.
- %newFullScreen = %deviceModeName $= "Fullscreen" ? true : false;
- %newRefresh = $pref::Video::RefreshRate;
- %newVsync = $pref::Video::enableVerticalSync;
- %newAA = $pref::Video::AA;
-
- // Build the final mode string.
- %newMode = $pref::Video::Resolution SPC %newFullScreen SPC %newBpp SPC %newRefresh SPC %newAA;
-
- // Change the video mode.
- if ( %newMode !$= $pref::Video::mode || %newDeviceID != $pref::Video::deviceId ||
- %newVsync != $pref::Video::enableVerticalSync || %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), %newAA);
- }
- $pref::Video::mode = %newMode;
- $pref::Video::enableVerticalSync = %newVsync;
- $pref::Video::deviceId = %newDeviceID;
- $pref::Video::deviceMode = %newDeviceMode;
- $pref::Video::Resolution = %newRes;
- $pref::Video::FullScreen = %newFullScreen;
- $pref::Video::RefreshRate = %newRefresh;
- $pref::Video::AA = %newAA;
- configureCanvas();
- }
- }
- function updatePostFXSettings()
- {
- PostFXManager.settingsEffectSetEnabled(SSAOPostFx, $pref::PostFX::EnableSSAO);
- PostFXManager.settingsEffectSetEnabled(DepthOfFieldPostFX, $pref::PostFX::EnableDOF);
- PostFXManager.settingsEffectSetEnabled(LightRayPostFX, $pref::PostFX::EnableLightRays);
- PostFXManager.settingsEffectSetEnabled(vignettePostFX, $pref::PostFX::EnableVignette);
- }
- //
- //
- //
- function populateAudioSettingsList()
- {
- OptionsMenuSettingsList.clear();
-
- OptionsMenu.currentCategory = "Audio";
-
- if(isObject(OptionName))
- OptionName.setText("");
- if(isObject(OptionDescription))
- 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::provider", %audioProviderList, false, "audioProviderChanged", true, "");
- OptionsMenuSettingsList.addOptionRow("Audio Device", "$pref::SFX::device", %audioDeviceList, false, "", true);
-
- OptionsMenuSettingsList.addSliderRow("Master Volume", "$pref::SFX::masterVolume", 0.1, "0 1", "");
- OptionsMenuSettingsList.addSliderRow("GUI Volume", "$pref::SFX::channelVolume[" @ $GuiAudioType @ "]", 0.1, "0 1", "");
- OptionsMenuSettingsList.addSliderRow("Effects Volume", "$pref::SFX::channelVolume[" @ $SimAudioType @ "]", 0.1, "0 1", "");
- OptionsMenuSettingsList.addSliderRow("Music Volume", "$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();
-
- OptionsMenu.currentCategory = "Keyboard & Mouse";
-
- if(isObject(OptionName))
- OptionName.setText("");
- if(isObject(OptionDescription))
- OptionDescription.setText("");
-
- $remapListDevice = "keyboard";
- fillRemapList();
-
- //OptionsMenuSettingsList.refresh();
- }
- function populateGamepadSettingsList()
- {
- OptionsMenuSettingsList.clear();
-
- OptionsMenu.currentCategory = "Gamepad";
-
- if(isObject(OptionName))
- OptionName.setText("");
- if(isObject(OptionDescription))
- OptionDescription.setText("");
-
- $remapListDevice = "gamepad";
- fillRemapList();
-
- OptionsMenuSettingsList.updateStack();
- }
- //
- //
- //
- function getDisplayDeviceList()
- {
- %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 %devicesList;
- }
- function getDisplayDeviceId(%displayDeviceName)
- {
- %deviceList = getDisplayDeviceList();
-
- %deviceCount = getFieldCount(%deviceList);
- for(%d = 0; %d < %deviceCount; %d++)
- {
- %deviceName = getField(%deviceList, %d);
- if(%deviceName $= %displayDeviceName)
- return %d;
- }
-
- return -1;
- }
- //
- //
- //
- function OptionsMenuList::activateRow(%this)
- {
- //OptionsMenuSettingsList.setFirstResponder();
- OptionsMenuSettingsList.setAsActiveMenuList();
- }
- 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 * 0.5;//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
-
- if(%defaultValue $= "")
- {
- %unappliedPrefIndex = OptionsMenu.unappliedChanges.getIndexFromKey(%targetPrefVar);
- if(%unappliedPrefIndex != -1)
- {
- %value = OptionsMenu.unappliedChanges.getValue(%unappliedPrefIndex);
- %defaultValue = strreplace(%value, "\"", "");
- }
-
- if(%defaultValue $= "")
- {
- %sanitizedVar = strReplace(%targetPrefVar, "[", "");
- %sanitizedVar = strReplace(%sanitizedVar, "]", "");
- %sanitizedVar = strReplace(%sanitizedVar, ",", "_");
- %defaultValue = getVariable(%sanitizedVar);
- }
- }
-
- /*if(%defaultValue $= "Off" || %defaultValue $= "No")
- %defaultValue = "0";
- if(%defaultValue $= "On" || %defaultValue $= "Yes")
- %defaultValue = "1";*/
-
- %option.setListSetting(%label, %optionsList, %wrapOptions, %callback, %enabled, %description, %defaultValue);
- %this.add(%option);
- }
- function OptionsMenuSettingsList::addOptionQualityLevelRow(%this, %label, %targetPrefVar, %qualityLevelList, %wrapOptions, %callback, %enabled, %description, %defaultValue)
- {
- if(%defaultValue $= "")
- {
- %unappliedPrefIndex = OptionsMenu.unappliedChanges.getIndexFromKey(%targetPrefVar);
- if(%unappliedPrefIndex != -1)
- {
- %value = OptionsMenu.unappliedChanges.getValue(%unappliedPrefIndex);
- %defaultValue = strreplace(%value, "\"", "");
- }
-
- if(%defaultValue $= "")
- {
- %sanitizedVar = strReplace(%targetPrefVar, "[", "");
- %sanitizedVar = strReplace(%sanitizedVar, "]", "");
- %sanitizedVar = strReplace(%sanitizedVar, ",", "_");
- %defaultValue = getVariable(%sanitizedVar);
- }
-
- if(%defaultValue $= "")
- %defaultValue = getCurrentQualityLevel(%qualityLevelList);
- }
-
- return %this.addOptionRow(%label, %targetPrefVar, getQualityLevels(%qualityLevelList),
- %wrapOptions, %callback, %enabled, %description, %defaultValue);
- }
- function OptionsMenuSettingsList::addOptionBoolRow(%this, %label, %targetPrefVar, %qualityLevelList, %wrapOptions, %callback, %enabled, %description, %defaultValue, %inverted)
- {
- if(%defaultValue $= "")
- %defaultValue = OptionsMenu.getOptionVariableValue(%targetPrefVar);
-
- if(%inverted $= "")
- %inverted = false;
-
- //Lame and hacky, but some variables are 'disabled' and some are 'enabled'
- if(isInt(%defaultValue) && %inverted)
- {
- if(%defaultValue == 0)
- %defaultValue = 1;
- else
- %defaultValue = 0;
- }
-
- if(%qualityLevelList $= $yesNoList && isInt(%defaultValue))
- {
- %defaultValue = convertBoolToYesNo(%defaultValue);
- }
- else if(%qualityLevelList $= $onOffList && isInt(%defaultValue))
- {
- %defaultValue = convertBoolToOnOff(%defaultValue);
- }
- return %this.addOptionRow(%label, %targetPrefVar, %qualityLevelList,
- %wrapOptions, %callback, %enabled, %description, %defaultValue);
- }
- function OptionsMenuSettingsList::addSliderRow(%this, %label, %targetPrefVar, %increment, %range, %callback, %enabled, %description, %defaultValue)
- {
- if(%enabled $= "")
- %enabled = true;
-
- %optionsRowSize = 30;
- %optionColumnWidth = %this.extent.x * 0.5;//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
-
- if(%defaultValue $= "")
- %defaultValue = OptionsMenu.getOptionVariableValue(%targetPrefVar);
-
- %option.setSliderSetting(%label, %defaultValue, %increment, %range, %callback, %enabled, %description);
- %this.add(%option);
- }
- function OptionsMenuSettingsList::addKeybindRow(%this, %label, %bitmapName, %callback, %enabled, %description, %remapIndex)
- {
- if(%enabled $= "")
- %enabled = true;
-
- %optionsRowSize = 40;
- %optionColumnWidth = %this.extent.x * 0.5;//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.remapIndex = %remapIndex;
-
- %option.setKeybindSetting(%label, %bitmapName, %callback, %enabled, %description);
- %this.add(%option);
- }
- //
- function OptionsMenuCategoryList::onNavigate(%this, %index)
- {
- OptionsMenu.currentCategory = %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 if(%val == 0)
- return "No";
-
- return %val;
- }
- function convertBoolToOnOff(%val)
- {
- if(%val == 1)
- return "On";
- else if(%val == 0)
- return "Off";
-
- return %val;
- }
- 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)
- {
- if(isObject(OptionName))
- OptionName.setText(%this.getLabel());
- if(isObject(OptionDescription))
- OptionDescription.setText(%this.getToolTip());
- }
- function MenuOptionsButton::onMouseLeave(%this)
- {
- if(isObject(OptionName))
- OptionName.setText("");
- if(isObject(OptionDescription))
- OptionDescription.setText("");
- }
- function MenuOptionsButton::onHighlighted(%this, %state)
- {
- MenuListButton::onHighlighted(%this, %state);
- }
- function MenuOptionsButton::onChange(%this)
- {
- %optionMode = %this.getMode();
- %optionName = %this.getLabel();
- %tooltipText = %this.getTooltip();
-
- %targetVar = %this.targetPrefVar;
-
- OptionName.setText(%optionName);
- OptionDescription.setText(%tooltipText);
-
- if(%optionMode == 0)
- {
- %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)
- {
- echo("Setting UnappliedChanges via add: key:" @ %targetVar @", value: " @ %saveReadyValue);
- OptionsMenu.unappliedChanges.add(%targetVar, "\"" @ %saveReadyValue @ "\"" );
- }
- else
- {
- echo("Setting UnappliedChanges via modify: key:" @ %targetVar @", value: " @ %saveReadyValue);
- OptionsMenu.unappliedChanges.setValue("\"" @ %saveReadyValue @ "\"", %prefIndex);
- }
- }
- }
- else if(%optionMode == 1)
- {
- %currentValue = %this.getValue();
-
- %prefIndex = OptionsMenu.unappliedChanges.getIndexFromKey(%targetVar);
- if(%prefIndex == -1)
- {
- echo("Setting UnappliedChanges via add: key:" @ %targetVar @", value: " @ %currentValue);
- OptionsMenu.unappliedChanges.add(%targetVar, "\"" @ %currentValue @ "\"" );
- }
- else
- {
- OptionsMenu.unappliedChanges.setValue("\"" @ %currentValue @ "\"", %prefIndex);
- }
- }
-
- //Update the UI in case there's responsive logic
- OptionsMenu.schedule(32, "refresh");
- }
- 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)
- {
- //Don't add duplicates!
- %index = OptionsMenu.optionsCategories.getIndexFromKey(%categoryName);
- if(%index == -1)
- OptionsMenu.optionsCategories.add(%categoryName, %selectCallback);
- }
- function removeOptionsMenuCategory(%categoryName)
- {
- %index = OptionsMenu.optionsCategories.getIndexFromKey(%categoryName);
- if(%index != -1)
- OptionsMenu.optionsCategories.erase(%index);
- }
- function getOptionsCategoryIndexByName(%categoryName)
- {
- for(%i=0; %i < OptionsMenu.optionsCategories.count(); %i++)
- {
- if(OptionsMenu.optionsCategories.getKey(%i) $= %categoryName)
- return %i;
- }
-
- return -1;
- }
- 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);
- }
- //
- //
- //
- function addOptionGroup()
- {
- %group = new GuiTextCtrl() {
- text = "Graphics";
- position = "0 0";
- extent = "500 30";
- profile = "MenuHeaderText";
- tooltipProfile = "GuiToolTipProfile";
- };
-
- return %group;
- }
- function optionsMenuButton::onHighlighted(%this, %highlighted)
- {
- %container = %this.getParent();
-
- %container-->optionName.profile = %highlighted ? MenuSubHeaderTextHighlighted : MenuSubHeaderText;
- %container-->optionDescription.profile = %highlighted ? GuiMLTextProfileHighlighted : GuiMLTextProfile;
-
- %valuesContainer = %container-->valuesContainer;
- %valuesContainer-->optionValue.profile = %highlighted ? GuiMenuTextProfileHighlighted : GuiMenuTextProfile;
- }
- function optionsMenuButton::onMouseDown(%this)
- {
- //check if we're clicking on the left or right of the value and adjust it accordingly
- }
- function addOptionEntry(%optionObj)
- {
- if(!isObject(%optionObj) || %optionObj.class !$= "OptionsSettings")
- {
- error("addOptionsEntry() - attempting to create a new options entry, but was provided an invalid options object");
- return 0;
- }
-
- %qualityLevel = %optionObj.getObject(0);
-
- %entry = new GuiContainer() {
- position = "0 0";
- extent = "500 40";
- profile = GuiMenuDefaultProfile;
- tooltipProfile = "GuiToolTipProfile";
- horizSizing = "width";
- vertSizing = "bottom";
- class = "OptionsListEntry";
- optionsObject = %optionObj;
- currentOptionIndex = 0;
-
- new GuiButtonCtrl() {
- profile = GuiMenuButtonProfile;
- position = "0 0";
- extent = "500 40";
- horizSizing = "width";
- vertSizing = "height";
- internalName = "button";
- class = "optionsMenuButton";
- };
- new GuiTextCtrl() {
- text = %optionObj.OptionName;
- position = $optionsEntryPad SPC -1;
- extent = "250 20";
- profile = "MenuSubHeaderText";
- tooltipProfile = "GuiToolTipProfile";
- internalName = "optionName";
- };
- new GuiTextCtrl() {
- text = %optionObj.Description;
- position = $optionsEntryPad SPC 17;
- extent = "250 18";
- profile = "GuiMLTextProfile";
- tooltipProfile = "GuiToolTipProfile";
- internalName = "optionDescription";
- };
-
- new GuiContainer() {
- position = "250 0";
- extent = "250 40";
- profile = GuiModelessDialogProfile;
- tooltipProfile = "GuiToolTipProfile";
- horizSizing = "left";
- vertSizing = "height";
- internalName = "valuesContainer";
-
- new GuiButtonCtrl() {
- position = "160 0";
- extent = "20 40";
- text = "<";
- profile = GuiMenuButtonProfile;
- };
-
- new GuiTextCtrl() {
- text = %qualityLevel.displayName;
- position = "180 0";
- extent = "50 40";
- profile = "GuiMenuTextProfile";
- tooltipProfile = "GuiToolTipProfile";
- horizSizing = "right";
- vertSizing = "center";
- internalName = "optionValue";
- };
-
- new GuiButtonCtrl() {
- position = "230 0";
- extent = "20 40";
- text = ">";
- profile = GuiMenuButtonProfile;
- };
- };
- };
-
- return %entry;
- }
|