mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
extra fixes for options menu and setting up from device name
This commit is contained in:
parent
d56bf257c7
commit
15a7b8cce0
7 changed files with 183 additions and 44 deletions
|
|
@ -25,6 +25,7 @@ function createCanvas(%windowTitle)
|
|||
if ($isDedicated)
|
||||
{
|
||||
GFXInit::createNullDevice();
|
||||
sfxCreateDevice("Null","Null Device", false, 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,12 @@ function Core_SFX::onCreate(%this)
|
|||
|
||||
function Core_SFX::onDestroy(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function Core_SFX::initClient(%this)
|
||||
{
|
||||
if($pref::SFX::autoDetect)
|
||||
{
|
||||
AutodetectSound();
|
||||
}
|
||||
}
|
||||
|
|
@ -26,55 +26,92 @@ new SimGroup(AudioSettingsGroup)
|
|||
};
|
||||
};
|
||||
|
||||
function getDeviceDisplayName(%fullName)
|
||||
{
|
||||
%openPos = strstr(%fullName, "(");
|
||||
%closePos = strstr(%fullName, ")");
|
||||
|
||||
if (%openPos == -1 || %closePos == -1)
|
||||
return %fullName;
|
||||
|
||||
// +1 to skip past the "(" itself
|
||||
return trim(getSubStr(%fullName, %openPos + 1, %closePos - %openPos - 1));
|
||||
}
|
||||
|
||||
function AudioSettingsGroup::populateSettings(%this)
|
||||
{
|
||||
AudioSettingsProviderGroup.clear();
|
||||
AudioSettingsDeviceGroup.clear();
|
||||
|
||||
%pCount = sfxGetProviderCount();
|
||||
for(%i = 0; %i < %pCount; %i++)
|
||||
|
||||
// --- First pass: build deduplicated provider list ---
|
||||
for (%i = 0; %i < %pCount; %i++)
|
||||
{
|
||||
%provider = sfxGetProviderType(%i);
|
||||
if(%provider !$= "NullProvider")
|
||||
%providerType = sfxGetProviderType(%i);
|
||||
|
||||
if (%providerType $= "NullProvider")
|
||||
continue;
|
||||
|
||||
%alreadyAdded = false;
|
||||
foreach (%entry in AudioSettingsProviderGroup)
|
||||
{
|
||||
//We can't have duplicate providers, so double check for uniqueness
|
||||
%foundProvider = false;
|
||||
foreach(%registeredProviders in AudioSettingsProviderGroup)
|
||||
if (%entry.displayName $= %providerType)
|
||||
{
|
||||
if(%registeredProviders.displayName $= %provider)
|
||||
{
|
||||
%foundProvider = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!%foundProvider)
|
||||
{
|
||||
//Provider entry
|
||||
%providerEntry = new ArrayObject()
|
||||
{
|
||||
class = "OptionsQualityLevel";
|
||||
displayName = %provider;
|
||||
key["$pref::SFX::provider"] = %provider;
|
||||
};
|
||||
AudioSettingsProviderGroup.add(%providerEntry);
|
||||
%alreadyAdded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(%i = 0; %i < %pCount; %i++)
|
||||
{
|
||||
%device = sfxGetProviderDevice(%i);
|
||||
//Device Entry
|
||||
%deviceEntry = new ArrayObject()
|
||||
{
|
||||
class = "OptionsQualityLevel";
|
||||
displayName = %device;
|
||||
provider = %provider; //this is for filtering later, if we need to
|
||||
key["$pref::SFX::device"] = %device;
|
||||
};
|
||||
|
||||
AudioSettingsDeviceGroup.add(%deviceEntry);
|
||||
if (!%alreadyAdded)
|
||||
{
|
||||
%providerEntry = new ArrayObject()
|
||||
{
|
||||
class = "OptionsQualityLevel";
|
||||
displayName = %providerType;
|
||||
key["$pref::SFX::provider"] = %providerType;
|
||||
};
|
||||
AudioSettingsProviderGroup.add(%providerEntry);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Second pass: for each provider, collect its devices ---
|
||||
foreach (%providerEntry in AudioSettingsProviderGroup)
|
||||
{
|
||||
%providerType = %providerEntry.displayName;
|
||||
|
||||
for (%i = 0; %i < %pCount; %i++)
|
||||
{
|
||||
if (sfxGetProviderType(%i) !$= %providerType)
|
||||
continue;
|
||||
|
||||
%deviceName = sfxGetProviderDevice(%i);
|
||||
|
||||
%deviceEntry = new ArrayObject()
|
||||
{
|
||||
class = "OptionsQualityLevel";
|
||||
displayName = getDeviceDisplayName(%deviceName);
|
||||
providerType = %providerType;
|
||||
key["$pref::SFX::device"] = %deviceName;
|
||||
};
|
||||
AudioSettingsDeviceGroup.add(%deviceEntry);
|
||||
}
|
||||
}
|
||||
|
||||
// Highlight the currently active entries
|
||||
%activeProvider = $pref::SFX::provider;
|
||||
%activeDevice = $pref::SFX::device;
|
||||
|
||||
foreach (%entry in AudioSettingsProviderGroup)
|
||||
{
|
||||
if (%entry.displayName $= %activeProvider)
|
||||
AudioSettingsProviderGroup.currentValue = %activeProvider;
|
||||
}
|
||||
|
||||
foreach (%entry in AudioSettingsDeviceGroup)
|
||||
{
|
||||
if (%entry.displayName $= %activeDevice && %entry.providerType $= %activeProvider)
|
||||
AudioSettingsDeviceGroup.currentValue = %activeDevice;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -90,8 +127,15 @@ function AudioSettingsDeviceGroup::onApply(%this)
|
|||
|
||||
function updateAudioOptionsSettings()
|
||||
{
|
||||
if ( !sfxCreateDevice() )
|
||||
if ( !sfxCreateDeviceFromName($pref::SFX::provider, $pref::SFX::device) )
|
||||
error( "Unable to create SFX device: " @ $pref::SFX::provider
|
||||
SPC $pref::SFX::device
|
||||
SPC $pref::SFX::useHardware );
|
||||
}
|
||||
|
||||
function AutodetectSound()
|
||||
{
|
||||
// Nothing to actually do in here?
|
||||
// function here for convenience.
|
||||
$pref::SFX::autoDetect = false;
|
||||
}
|
||||
|
|
@ -855,6 +855,8 @@ function OptionsMenu::resetSettings(%this)
|
|||
function OptionsMenu::populateAudioSettings(%this)
|
||||
{
|
||||
AudioSettingsList.clear();
|
||||
OptionsMenu.optsListCount = -1;
|
||||
|
||||
AudioSettingsGroup.populateSettings();
|
||||
|
||||
//Process the lists
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue