- Added a companion global var array for $AudioChannelsName[x] as well as utilizing $AudioChannelCount for keeping better tabs on the active defined audio channels. This allows modules to establish new channels more easily

- Updated the handling of the option slider entries to utilize temp vars and properly complied the audio channel options to the new setup
- Fixed issue where behavior of slider was erratic because of improperly defined tick count
- Added logic to check if audio sliders were changed for the 'check unchanged settings' logic
- Made the keybind remap inputCtrl ignore axis events
- Made the MessageBoxDlg input commands properly check for key makes, to prevent messages boxes from catching key breaks and blowing past follow-up messageboxes accidentally
- Fixed forward/backward iteration of options entries, especially on dpad, and added handling for gamepad stick to do the same
- Added logic so option sliders can also be manipulated by the forward/backward to make it standard for all
- Fixed erroneous marking of "restart required" message as true if any settings change, and not just settings expressly flagged as requiring a restart
This commit is contained in:
Areloch 2024-01-01 01:42:53 -06:00
parent 67ac556ecd
commit e71880b898
4 changed files with 90 additions and 19 deletions

View file

@ -309,17 +309,26 @@ function sfxAutodetect()
//-----------------------------------------------------------------------------
// Volume channel IDs for backwards-compatibility.
$AudioChannelCount = 5;
$GuiAudioType = 1; // Interface.
$SimAudioType = 2; // Game.
$MessageAudioType = 3; // Notifications.
$MusicAudioType = 4; // Music.
$AudioChannels[ 0 ] = AudioChannelDefault;
$AudioChannelsName[ 0 ] = "Master";
$AudioChannels[ $GuiAudioType ] = AudioChannelGui;
$AudioChannelsName[ $GuiAudioType ] = "Gui";
$AudioChannels[ $SimAudioType ] = AudioChannelEffects;
$AudioChannelsName[ $SimAudioType ] = "Effects";
$AudioChannels[ $MessageAudioType ] = AudioChannelMessages;
$AudioChannelsName[ $MessageAudioType ] = "Messages";
$AudioChannels[ $MusicAudioType ] = AudioChannelMusic;
$AudioChannelsName[ $MusicAudioType ] = "Music";
function sfxOldChannelToGroup( %channel )
{

View file

@ -137,14 +137,16 @@ function MessageBoxCtrl::syncGui(%this)
}
function messageBoxYesClicked(%this)
function messageBoxYesClicked(%val)
{
MessageCallback(MessageBoxDlg, MessageBoxDlg.callback);
if(%val)
MessageCallback(MessageBoxDlg, MessageBoxDlg.callback);
}
function messageBoxNoClicked(%this)
function messageBoxNoClicked(%val)
{
MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback);
if(%val)
MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback);
}
//MessageBoxOK("Test", "This is a test message box", "echo(\"Uhhhhhawhat?\"");

View file

@ -19,6 +19,8 @@ function OptionsMenu::onAdd(%this)
function OptionsMenu::onWake(%this)
{
$optionsChangeRequiresRestart = false;
%this.populateVideoSettings();
%this.populateAudioSettings();
@ -48,7 +50,7 @@ if(!isObject( OptionsMenuActionMap ) )
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( gamepad, rpov, OptionMenuNextSetting );
OptionsMenuActionMap.bind( keyboard, q, OptionsMenuPrevCategory );
OptionsMenuActionMap.bind( gamepad, btn_l, OptionsMenuPrevCategory );
@ -145,7 +147,7 @@ function OptionsMenuList::checkForUnappliedChanges(%this)
if(!%targetOptionLevel.isCurrent())
%unappliedChanges = true;
if(%option.optionsObject.requiresRestart)
if(%unappliedChanges && %option.optionsObject.requiresRestart)
$optionsChangeRequiresRestart = true;
}
}
@ -365,6 +367,17 @@ function OptionMenuPrevSetting(%val)
//echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName);
}
else if(%option.class $= "OptionsListSliderEntry")
{
%sliderCtrl = %option-->valuesContainer-->slider;
%minValue = %sliderCtrl.range.x;
%maxValue = %sliderCtrl.range.y;
%ticks = %sliderCtrl.ticks;
%tickIncrementVal = (%maxValue - %minValue) / %ticks;
%sliderCtrl.value -= %tickIncrementVal;
}
$MenuList.syncGUI();
}
@ -390,13 +403,27 @@ function OptionMenuNextSetting(%val)
//echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName);
}
else if(%option.class $= "OptionsListSliderEntry")
{
%sliderCtrl = %option-->valuesContainer-->slider;
%minValue = %sliderCtrl.range.x;
%maxValue = %sliderCtrl.range.y;
%ticks = %sliderCtrl.ticks;
%tickIncrementVal = (%maxValue - %minValue) / %ticks;
%sliderCtrl.value += %tickIncrementVal;
}
$MenuList.syncGUI();
}
function OptionMenuStickChangeSetting(%val)
{
if(%val == 1)
OptionMenuNextSetting(1);
else if(%val == -1)
OptionMenuPrevSetting(1);
}
function OptionsMenuActivateOption(%val)
@ -509,10 +536,19 @@ function OptionsMenu::populateAudioSettings(%this)
AudioSettingsList.add(addOptionGroup("Channel Volume"));
AudioSettingsList.add(addOptionSlider("Master Volume", "", "$pref::SFX::masterVolume", 0, 1, 0.1));
AudioSettingsList.add(addOptionSlider("GUI Volume", "", "$pref::SFX::channelVolume[" @ $GuiAudioType @ "]", 0, 1, 0.1));
AudioSettingsList.add(addOptionSlider("Effects Volume", "", "$pref::SFX::channelVolume[" @ $SimAudioType @ "]", 0, 1, 0.1));
AudioSettingsList.add(addOptionSlider("Music Volume", "", "$pref::SFX::channelVolume[" @ $MusicAudioType @ "]", 0, 1, 0.1));
//Now we'll populate the sliders for the audio channels.
//The defaults of these are defined in core/sfx/scripts/audio.tscript
//These define the MasterVolume channel, as well as several other common defualt ones
//Because it's a variable list, this can be expanded by modules by just upping $AudioChannelCount
//and then defining the $AudioChannelName[x] with the displayed name and
//and the $AudioChannels[x] variable with the SFXSource object defined to it for the given channel
AudioSettingsList.add(addOptionSlider("Master Volume", "", "$pref::SFX::masterVolume", 0, 1, 10));
//We init to 1, because 0 is the reserved for the masterVolume in practice
for(%i=1; %i < $AudioChannelCount; %i++)
{
AudioSettingsList.add(addOptionSlider($AudioChannelsName[%i] @ " Volume", "", "$pref::SFX::channelVolume" @ %i, 0, 1, 10));
}
//Ensure our newly templated options listings are sized right
for(%i=0; %i < AudioSettingsList.getCount(); %i++)
@ -637,6 +673,17 @@ function tryCloseOptionsMenu(%val)
%unappliedVideoChanges = VideoSettingsList.checkForUnappliedChanges();
%unappliedAudioChanges = AudioSettingsList.checkForUnappliedChanges();
//validate audio prefs
if($pref::SFX::masterVolume_tempVar !$= "" && $pref::SFX::masterVolume_tempVar != $pref::SFX::masterVolume)
%unappliedAudioChanges = true;
for(%i=1; %i < $AudioChannelCount; %i++)
{
%tempVolume = getVariable("$pref::SFX::channelVolume" @ %i @ "_tempVar");
if(%tempVolume !$= "" && $pref::SFX::channelVolume[ %i ] != %tempVolume)
%unappliedAudioChanges = true;
}
if(%unappliedVideoChanges || %unappliedAudioChanges)
{
MessageBoxOKCancel("Discard Changes?", "You have unapplied changes to your settings, do you wish to apply or discard them?",
@ -668,12 +715,19 @@ function OptionsMenu::applyChangedOptions(%this)
VideoSettingsList.applyChanges();
AudioSettingsList.applyChanges();
//$pref::SFX::masterVolume = OptionsMenuSettingsList.getValue(2);
//Process the audio channel tempvars to get their values
//and then apply them to the actual pref variable, as well as the SFXChannelVolume
$pref::SFX::masterVolume = $pref::SFX::masterVolume_tempVar;
sfxSetMasterVolume( $pref::SFX::masterVolume );
sfxSetChannelVolume( $GuiAudioType, $pref::SFX::channelVolume[ $GuiAudioType ] );
sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ $SimAudioType ] );
sfxSetChannelVolume( $MusicAudioType, $pref::SFX::channelVolume[ $MusicAudioType ] );
//0 is always master anyways
for(%i=1; %i < $AudioChannelCount; %i++)
{
%volume = getVariable("$pref::SFX::channelVolume" @ %i @ "_tempVar");
sfxSetChannelVolume( %i, %volume );
$pref::SFX::channelVolume[ %i ] = %volume;
}
//Finally, write our prefs to file
%prefPath = getPrefpath();
export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false);
@ -838,13 +892,17 @@ function addOptionSlider(%optionName, %optionDesc, %prefName, %sliderMin, %slide
{
%currentVal = getVariable(%prefName);
%tempVarName = %prefName @ "_tempVar";
if(%currentVal $= "")
%currentVal = %sliderMin;
setVariable(%tempVarName, %currentVal);
%optionNameHeight = 20;
if(%optionDesc $= "")
%optionNameHeight = 40;
%entry = new GuiContainer() {
position = "0 0";
extent = "800 40";
@ -897,11 +955,12 @@ function addOptionSlider(%optionName, %optionDesc, %prefName, %sliderMin, %slide
ticks = %sliderTicks;
snap = "1";
value = %currentVal;
variable = %tempVarName;
useFillBar = "1";
fillBarColor = $TextMediumEmphasisColor;
renderTicks = "0";
position = "0 10";
extent = "300 20";
extent = "400 20";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "center";
@ -915,6 +974,7 @@ function addOptionSlider(%optionName, %optionDesc, %prefName, %sliderMin, %slide
canSave = "1";
canSaveDynamicFields = "0";
class = "OptionsSliderEntrySlider";
internalName = "slider";
};
};
};

View file

@ -24,7 +24,7 @@ $guiContent = new GuiControl(RemapDlg) {
vertSizing = "height";
profile = "GuiInputCtrlProfile";
tooltipProfile = "GuiToolTipProfile";
sendAxisEvents = "1";
sendAxisEvents = "0";
};
new GuiControl(RemapBoxCtrl) {
position = "-1 1";