mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
- 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:
parent
67ac556ecd
commit
e71880b898
4 changed files with 90 additions and 19 deletions
|
|
@ -309,17 +309,26 @@ function sfxAutodetect()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Volume channel IDs for backwards-compatibility.
|
// Volume channel IDs for backwards-compatibility.
|
||||||
|
$AudioChannelCount = 5;
|
||||||
$GuiAudioType = 1; // Interface.
|
$GuiAudioType = 1; // Interface.
|
||||||
$SimAudioType = 2; // Game.
|
$SimAudioType = 2; // Game.
|
||||||
$MessageAudioType = 3; // Notifications.
|
$MessageAudioType = 3; // Notifications.
|
||||||
$MusicAudioType = 4; // Music.
|
$MusicAudioType = 4; // Music.
|
||||||
|
|
||||||
$AudioChannels[ 0 ] = AudioChannelDefault;
|
$AudioChannels[ 0 ] = AudioChannelDefault;
|
||||||
|
$AudioChannelsName[ 0 ] = "Master";
|
||||||
|
|
||||||
$AudioChannels[ $GuiAudioType ] = AudioChannelGui;
|
$AudioChannels[ $GuiAudioType ] = AudioChannelGui;
|
||||||
|
$AudioChannelsName[ $GuiAudioType ] = "Gui";
|
||||||
|
|
||||||
$AudioChannels[ $SimAudioType ] = AudioChannelEffects;
|
$AudioChannels[ $SimAudioType ] = AudioChannelEffects;
|
||||||
|
$AudioChannelsName[ $SimAudioType ] = "Effects";
|
||||||
|
|
||||||
$AudioChannels[ $MessageAudioType ] = AudioChannelMessages;
|
$AudioChannels[ $MessageAudioType ] = AudioChannelMessages;
|
||||||
|
$AudioChannelsName[ $MessageAudioType ] = "Messages";
|
||||||
|
|
||||||
$AudioChannels[ $MusicAudioType ] = AudioChannelMusic;
|
$AudioChannels[ $MusicAudioType ] = AudioChannelMusic;
|
||||||
|
$AudioChannelsName[ $MusicAudioType ] = "Music";
|
||||||
|
|
||||||
function sfxOldChannelToGroup( %channel )
|
function sfxOldChannelToGroup( %channel )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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?\"");
|
//MessageBoxOK("Test", "This is a test message box", "echo(\"Uhhhhhawhat?\"");
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ function OptionsMenu::onAdd(%this)
|
||||||
|
|
||||||
function OptionsMenu::onWake(%this)
|
function OptionsMenu::onWake(%this)
|
||||||
{
|
{
|
||||||
|
$optionsChangeRequiresRestart = false;
|
||||||
|
|
||||||
%this.populateVideoSettings();
|
%this.populateVideoSettings();
|
||||||
|
|
||||||
%this.populateAudioSettings();
|
%this.populateAudioSettings();
|
||||||
|
|
@ -48,7 +50,7 @@ if(!isObject( OptionsMenuActionMap ) )
|
||||||
OptionsMenuActionMap.bind( keyboard, d, OptionMenuNextSetting );
|
OptionsMenuActionMap.bind( keyboard, d, OptionMenuNextSetting );
|
||||||
OptionsMenuActionMap.bind( gamepad, xaxis, "D", "-0.23 0.23", OptionMenuStickChangeSetting );
|
OptionsMenuActionMap.bind( gamepad, xaxis, "D", "-0.23 0.23", OptionMenuStickChangeSetting );
|
||||||
OptionsMenuActionMap.bind( gamepad, lpov, OptionMenuPrevSetting );
|
OptionsMenuActionMap.bind( gamepad, lpov, OptionMenuPrevSetting );
|
||||||
OptionsMenuActionMap.bind( gamepad, lpov, OptionMenuNextSetting );
|
OptionsMenuActionMap.bind( gamepad, rpov, OptionMenuNextSetting );
|
||||||
|
|
||||||
OptionsMenuActionMap.bind( keyboard, q, OptionsMenuPrevCategory );
|
OptionsMenuActionMap.bind( keyboard, q, OptionsMenuPrevCategory );
|
||||||
OptionsMenuActionMap.bind( gamepad, btn_l, OptionsMenuPrevCategory );
|
OptionsMenuActionMap.bind( gamepad, btn_l, OptionsMenuPrevCategory );
|
||||||
|
|
@ -145,7 +147,7 @@ function OptionsMenuList::checkForUnappliedChanges(%this)
|
||||||
if(!%targetOptionLevel.isCurrent())
|
if(!%targetOptionLevel.isCurrent())
|
||||||
%unappliedChanges = true;
|
%unappliedChanges = true;
|
||||||
|
|
||||||
if(%option.optionsObject.requiresRestart)
|
if(%unappliedChanges && %option.optionsObject.requiresRestart)
|
||||||
$optionsChangeRequiresRestart = true;
|
$optionsChangeRequiresRestart = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -365,6 +367,17 @@ function OptionMenuPrevSetting(%val)
|
||||||
|
|
||||||
//echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName);
|
//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();
|
$MenuList.syncGUI();
|
||||||
}
|
}
|
||||||
|
|
@ -390,13 +403,27 @@ function OptionMenuNextSetting(%val)
|
||||||
|
|
||||||
//echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName);
|
//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();
|
$MenuList.syncGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
function OptionMenuStickChangeSetting(%val)
|
function OptionMenuStickChangeSetting(%val)
|
||||||
{
|
{
|
||||||
|
if(%val == 1)
|
||||||
|
OptionMenuNextSetting(1);
|
||||||
|
else if(%val == -1)
|
||||||
|
OptionMenuPrevSetting(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function OptionsMenuActivateOption(%val)
|
function OptionsMenuActivateOption(%val)
|
||||||
|
|
@ -509,10 +536,19 @@ function OptionsMenu::populateAudioSettings(%this)
|
||||||
|
|
||||||
AudioSettingsList.add(addOptionGroup("Channel Volume"));
|
AudioSettingsList.add(addOptionGroup("Channel Volume"));
|
||||||
|
|
||||||
AudioSettingsList.add(addOptionSlider("Master Volume", "", "$pref::SFX::masterVolume", 0, 1, 0.1));
|
//Now we'll populate the sliders for the audio channels.
|
||||||
AudioSettingsList.add(addOptionSlider("GUI Volume", "", "$pref::SFX::channelVolume[" @ $GuiAudioType @ "]", 0, 1, 0.1));
|
//The defaults of these are defined in core/sfx/scripts/audio.tscript
|
||||||
AudioSettingsList.add(addOptionSlider("Effects Volume", "", "$pref::SFX::channelVolume[" @ $SimAudioType @ "]", 0, 1, 0.1));
|
//These define the MasterVolume channel, as well as several other common defualt ones
|
||||||
AudioSettingsList.add(addOptionSlider("Music Volume", "", "$pref::SFX::channelVolume[" @ $MusicAudioType @ "]", 0, 1, 0.1));
|
//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
|
//Ensure our newly templated options listings are sized right
|
||||||
for(%i=0; %i < AudioSettingsList.getCount(); %i++)
|
for(%i=0; %i < AudioSettingsList.getCount(); %i++)
|
||||||
|
|
@ -637,6 +673,17 @@ function tryCloseOptionsMenu(%val)
|
||||||
%unappliedVideoChanges = VideoSettingsList.checkForUnappliedChanges();
|
%unappliedVideoChanges = VideoSettingsList.checkForUnappliedChanges();
|
||||||
%unappliedAudioChanges = AudioSettingsList.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)
|
if(%unappliedVideoChanges || %unappliedAudioChanges)
|
||||||
{
|
{
|
||||||
MessageBoxOKCancel("Discard Changes?", "You have unapplied changes to your settings, do you wish to apply or discard them?",
|
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();
|
VideoSettingsList.applyChanges();
|
||||||
AudioSettingsList.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 );
|
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
|
//Finally, write our prefs to file
|
||||||
%prefPath = getPrefpath();
|
%prefPath = getPrefpath();
|
||||||
export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false);
|
export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false);
|
||||||
|
|
@ -838,13 +892,17 @@ function addOptionSlider(%optionName, %optionDesc, %prefName, %sliderMin, %slide
|
||||||
{
|
{
|
||||||
%currentVal = getVariable(%prefName);
|
%currentVal = getVariable(%prefName);
|
||||||
|
|
||||||
|
%tempVarName = %prefName @ "_tempVar";
|
||||||
|
|
||||||
if(%currentVal $= "")
|
if(%currentVal $= "")
|
||||||
%currentVal = %sliderMin;
|
%currentVal = %sliderMin;
|
||||||
|
|
||||||
|
setVariable(%tempVarName, %currentVal);
|
||||||
|
|
||||||
%optionNameHeight = 20;
|
%optionNameHeight = 20;
|
||||||
if(%optionDesc $= "")
|
if(%optionDesc $= "")
|
||||||
%optionNameHeight = 40;
|
%optionNameHeight = 40;
|
||||||
|
|
||||||
%entry = new GuiContainer() {
|
%entry = new GuiContainer() {
|
||||||
position = "0 0";
|
position = "0 0";
|
||||||
extent = "800 40";
|
extent = "800 40";
|
||||||
|
|
@ -897,11 +955,12 @@ function addOptionSlider(%optionName, %optionDesc, %prefName, %sliderMin, %slide
|
||||||
ticks = %sliderTicks;
|
ticks = %sliderTicks;
|
||||||
snap = "1";
|
snap = "1";
|
||||||
value = %currentVal;
|
value = %currentVal;
|
||||||
|
variable = %tempVarName;
|
||||||
useFillBar = "1";
|
useFillBar = "1";
|
||||||
fillBarColor = $TextMediumEmphasisColor;
|
fillBarColor = $TextMediumEmphasisColor;
|
||||||
renderTicks = "0";
|
renderTicks = "0";
|
||||||
position = "0 10";
|
position = "0 10";
|
||||||
extent = "300 20";
|
extent = "400 20";
|
||||||
minExtent = "8 2";
|
minExtent = "8 2";
|
||||||
horizSizing = "right";
|
horizSizing = "right";
|
||||||
vertSizing = "center";
|
vertSizing = "center";
|
||||||
|
|
@ -915,6 +974,7 @@ function addOptionSlider(%optionName, %optionDesc, %prefName, %sliderMin, %slide
|
||||||
canSave = "1";
|
canSave = "1";
|
||||||
canSaveDynamicFields = "0";
|
canSaveDynamicFields = "0";
|
||||||
class = "OptionsSliderEntrySlider";
|
class = "OptionsSliderEntrySlider";
|
||||||
|
internalName = "slider";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ $guiContent = new GuiControl(RemapDlg) {
|
||||||
vertSizing = "height";
|
vertSizing = "height";
|
||||||
profile = "GuiInputCtrlProfile";
|
profile = "GuiInputCtrlProfile";
|
||||||
tooltipProfile = "GuiToolTipProfile";
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
sendAxisEvents = "1";
|
sendAxisEvents = "0";
|
||||||
};
|
};
|
||||||
new GuiControl(RemapBoxCtrl) {
|
new GuiControl(RemapBoxCtrl) {
|
||||||
position = "-1 1";
|
position = "-1 1";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue