Made GuiFadeinBitmapCtrl not only respond to mouse and keyboard events, but gamepad events as well, allowing gamepad inputs to skip opening splash pages

Ensured that guiGameListMenuCtrl adjusts values for rows marked as sliders via the left and right gamepad actions
Corrected the button maps for look and move on the gamepad for the ExampleModule's default movement binds
Fixed ExampleModule's default keybinds so alt+enter correctly toggles fullscreen
Fixed joinServerMenu so it has a guiInputCtrl that can catch keybind events and pass them to the menuInputButtons
Removed erroneous input consumption on OptionsMenuList
Removed unneeded check against Graphics API list
Flipped order of Anti Aliasing option to match ordering of the others
Removed old, unneeded legacy option menu script files
Added logic for message boxes to automatically return active MenuInputButton control to the holder before it was pushed
Added fill color for the UI list gui profile so the sliders render more legibly
This commit is contained in:
Areloch 2020-07-25 01:29:25 -05:00
parent 5b289bce5e
commit 5f95f9f8c0
15 changed files with 78 additions and 1518 deletions

View file

@ -1,200 +0,0 @@
// =============================================================================
// AUDIO MENU
// =============================================================================
$AudioTestHandle = 0;
// Description to use for playing the volume test sound. This isn't
// played with the description of the channel that has its volume changed
// because we know nothing about the playback state of the channel. If it
// is paused or stopped, the test sound would not play then.
$AudioTestDescription = new SFXDescription()
{
sourceGroup = AudioChannelMaster;
};
function AudioMenu::loadSettings(%this)
{
// Audio
//OptAudioHardwareToggle.setStateOn($pref::SFX::useHardware);
//OptAudioHardwareToggle.setActive( true );
/*%this-->OptAudioVolumeMaster.setValue( $pref::SFX::masterVolume );
%this-->OptAudioVolumeShell.setValue( $pref::SFX::channelVolume[ $GuiAudioType] );
%this-->OptAudioVolumeSim.setValue( $pref::SFX::channelVolume[ $SimAudioType ] );
%this-->OptAudioVolumeMusic.setValue( $pref::SFX::channelVolume[ $MusicAudioType ] );
AudioMenuSoundDriver.clear();
%buffer = sfxGetAvailableDevices();
%count = getRecordCount( %buffer );
for(%i = 0; %i < %count; %i++)
{
%record = getRecord(%buffer, %i);
%provider = getField(%record, 0);
if ( AudioMenuSoundDriver.findText( %provider ) == -1 )
AudioMenuSoundDriver.add( %provider, %i );
}
AudioMenuSoundDriver.sort();
%selId = AudioMenuSoundDriver.findText($pref::SFX::provider);
if ( %selId == -1 )
AudioMenuSoundDriver.setFirstSelected();
else
AudioMenuSoundDriver.setSelected( %selId );*/
OptionsSettingStack.clear();
OptionsMenu.addSliderOption(OptionsSettingStack, "Master Volume", $pref::Video::Brightness, "0 1", 10, 5);
OptionsMenu.addSliderOption(OptionsSettingStack, "Menu Volume", $pref::Video::Brightness, "0 1", 10, 5);
OptionsMenu.addSliderOption(OptionsSettingStack, "Effects Volume", $pref::Video::Brightness, "0 1", 10, 5);
OptionsMenu.addSliderOption(OptionsSettingStack, "Music Volume", $pref::Video::Brightness, "0 1", 10, 5);
}
function AudioMenu::loadDevices(%this)
{
if(!isObject(SoundDeviceGroup))
{
new SimGroup( SoundDeviceGroup );
}
else
{
SoundDeviceGroup.clear();
}
%buffer = sfxGetAvailableDevices();
%count = getRecordCount( %buffer );
for (%i = 0; %i < %count; %i++)
{
%record = getRecord(%buffer, %i);
%provider = getField(%record, 0);
%device = getField(%record, 1);
if($pref::SFX::provider !$= %provider)
continue;
%setting = new ArrayObject()
{
class = "OptionsMenuSettingLevel";
caseSensitive = true;
displayName = %device;
key["$pref::SFX::Device"] = %device;
};
SoundDeviceGroup.add(%setting);
}
}
function AudioMenu::apply(%this)
{
sfxSetMasterVolume( $pref::SFX::masterVolume );
sfxSetChannelVolume( $GuiAudioType, $pref::SFX::channelVolume[ $GuiAudioType ] );
sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ $SimAudioType ] );
sfxSetChannelVolume( $MusicAudioType, $pref::SFX::channelVolume[ $MusicAudioType ] );
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 AudioMenuOKButton::onClick(%this)
{
//save the settings and then back out
AudioMenu.apply();
OptionsMenu.backOut();
}
function AudioMenuDefaultsButton::onClick(%this)
{
sfxInit();
AudioMenu.loadSettings();
}
function OptAudioUpdateMasterVolume( %volume )
{
if( %volume == $pref::SFX::masterVolume )
return;
sfxSetMasterVolume( %volume );
$pref::SFX::masterVolume = %volume;
if( !isObject( $AudioTestHandle ) )
$AudioTestHandle = sfxPlayOnce( AudioChannel, "data/ui/sounds/volumeTest.wav" );
}
function OptAudioUpdateChannelVolume( %description, %volume )
{
%channel = sfxGroupToOldChannel( %description.sourceGroup );
if( %volume == $pref::SFX::channelVolume[ %channel ] )
return;
sfxSetChannelVolume( %channel, %volume );
$pref::SFX::channelVolume[ %channel ] = %volume;
if( !isObject( $AudioTestHandle ) )
{
$AudioTestDescription.volume = %volume;
$AudioTestHandle = sfxPlayOnce( $AudioTestDescription, "data/ui/sounds/volumeTest.wav" );
}
}
function AudioMenuSoundDriver::onSelect( %this, %id, %text )
{
// Skip empty provider selections.
if ( %text $= "" )
return;
$pref::SFX::provider = %text;
AudioMenuSoundDevice.clear();
%buffer = sfxGetAvailableDevices();
%count = getRecordCount( %buffer );
for(%i = 0; %i < %count; %i++)
{
%record = getRecord(%buffer, %i);
%provider = getField(%record, 0);
%device = getField(%record, 1);
if (%provider !$= %text)
continue;
if ( AudioMenuSoundDevice.findText( %device ) == -1 )
AudioMenuSoundDevice.add( %device, %i );
}
// Find the previous selected device.
%selId = AudioMenuSoundDevice.findText($pref::SFX::device);
if ( %selId == -1 )
AudioMenuSoundDevice.setFirstSelected();
else
AudioMenuSoundDevice.setSelected( %selId );
}
function AudioMenuSoundDevice::onSelect( %this, %id, %text )
{
// Skip empty selections.
if ( %text $= "" )
return;
$pref::SFX::device = %text;
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 );
}

View file

@ -1,245 +0,0 @@
function DisplayMenu::loadSettings()
{
OptionsMenu.currentMenu = "DisplayMenu";
OptionsSettingStack.clear();
%APICount = getTokenCount(GraphicsDriverSetting::getList(),",");
if(%APICount > 1)
OptionsMenu.addSettingOption(OptionsSettingStack, "Diplay API", "", "GraphicsDriverSetting");
OptionsMenu.addSettingOption(OptionsSettingStack, "Screen Resolution", "", "ScreenResolutionSetting");
OptionsMenu.addSettingOption(OptionsSettingStack, "Fullscreen", "", "FullscreenSetting");
OptionsMenu.addSettingOption(OptionsSettingStack, "VSync", "", "VSyncSetting");
OptionsMenu.addSliderOption(OptionsSettingStack, "Field of View", $pref::Video::FOV, "65 120", 55, 75);
OptionsMenu.addSliderOption(OptionsSettingStack, "Brightness", $pref::Video::Brightness, "0 1", 10, 5);
OptionsMenu.addSliderOption(OptionsSettingStack, "Contrast", $pref::Video::Contrast, "0 1", 10, 5);
GraphicsSettingsCache.empty();
}
function DisplayMenu::apply(%this)
{
//Loop through the settings cache and actually apply the values
%cachedSettingCount = GraphicsSettingsCache.count();
for(%i=0; %i < %cachedSettingCount; %i++)
{
%var = GraphicsSettingsCache.getKey(%i);
%val = GraphicsSettingsCache.getValue(%i);
if(%var $= "$pref::Video::displayDevice")
{
MessageBoxOK( "Change requires restart", "Please restart the game for a display device change to take effect." );
}
setVariable(%var, %val);
}
//Update the display settings now
if (getWord( $pref::Video::Resolution, 2) $= "")
{
$pref::Video::Resolution = getWord( $pref::Video::Resolution, 0 ) SPC getWord( $pref::Video::Resolution, 1 );
}
else
{
$pref::Video::Resolution = getWord( $pref::Video::Resolution, 0 ) SPC getWord( $pref::Video::Resolution, 2 );
}
/*if ( %newFullScreen $= "false" )
{
// If we're in windowed mode switch the fullscreen check
// if the resolution is bigger than the desktop.
%deskRes = getDesktopResolution();
%deskResX = getWord(%deskRes, $WORD::RES_X);
%deskResY = getWord(%deskRes, $WORD::RES_Y);
if ( getWord( %newRes, $WORD::RES_X ) > %deskResX ||
getWord( %newRes, $WORD::RES_Y ) > %deskResY )
{
$pref::Video::FullScreen = "true";
GraphicsMenuFullScreen.setStateOn( true );
}
}*/
// Build the final mode string.
%newMode = $pref::Video::Resolution SPC $pref::Video::FullScreen SPC 32 SPC $pref::Video::RefreshRate SPC $pref::Video::AA;
// Change the video mode.
/*if ( %newMode !$= $pref::Video::mode ||
%newVsync != $pref::Video::disableVerticalSync )
{
if ( %testNeedApply )
return true;*/
$pref::Video::mode = %newMode;
//$pref::Video::disableVerticalSync = %newVsync;
configureCanvas();
//}
echo("Exporting client prefs");
%prefPath = getPrefpath();
export("$pref::*", %prefPath @ "/clientPrefs.cs", false);
}
//
function GraphicsDriverSetting::set(%setting)
{
switch$(%setting)
{
case "D3D11":
GraphicsMenu::set("$pref::Video::displayDevice", "D3D11");
case "OpenGL":
GraphicsMenu::set("$pref::Video::displayDevice", "OpenGL");
default:
GraphicsMenu::set("$pref::Video::displayDevice", "OpenGL");
}
}
function GraphicsDriverSetting::get()
{
if($pref::Video::displayDevice $= "D3D11")
return "D3D11";
else if($pref::Video::displayDevice $= "OpenGL")
return "OpenGL";
else
return "Unknown";
}
function GraphicsDriverSetting::getList()
{
%returnsList = "";
%buffer = getDisplayDeviceList();
%deviceCount = getFieldCount( %buffer );
%numAdapters = GFXInit::getAdapterCount();
%count = 0;
for(%i = 0; %i < %deviceCount; %i++)
{
%deviceDesc = getField(%buffer, %i);
if(%deviceDesc $= "GFX Null Device")
continue;
for( %i = 0; %i < %numAdapters; %i ++ )
{
if( GFXInit::getAdapterName( %i ) $= %deviceDesc )
{
%deviceName = GFXInit::getAdapterType( %i );
break;
}
}
if(%count != 0)
%returnsList = %returnsList @ "," @ %deviceName;
else
%returnsList = %deviceName;
%count++;
}
return %returnsList;
}
//
function ScreenResolutionSetting::set(%setting)
{
GraphicsMenu::set("$pref::Video::Resolution", %setting);
}
function ScreenResolutionSetting::get()
{
return _makePrettyResString( $pref::Video::Resolution );
}
function ScreenResolutionSetting::getList()
{
%returnsList = "";
%resCount = Canvas.getModeCount();
for (%i = 0; %i < %resCount; %i++)
{
%testResString = Canvas.getMode( %i );
%testRes = _makePrettyResString( %testResString );
//sanitize
%found = false;
%retCount = getTokenCount(%returnsList, ",");
for (%x = 0; %x < %retCount; %x++)
{
%existingEntry = getToken(%returnsList, ",", %x);
if(%existingEntry $= %testRes)
{
%found = true;
break;
}
}
if(%found)
continue;
if(%i != 0)
%returnsList = %returnsList @ "," @ %testRes;
else
%returnsList = %testRes;
}
return %returnsList;
}
//
function FullscreenSetting::set(%setting)
{
switch$(%setting)
{
case "On":
GraphicsMenu::set("$pref::Video::FullScreen", "1");
case "Off":
GraphicsMenu::set("$pref::Video::FullScreen", "0");
default:
GraphicsMenu::set("$pref::Video::FullScreen", "0");
}
}
function FullscreenSetting::get()
{
if($pref::Video::FullScreen == 1)
return "On";
else if($pref::Video::FullScreen == 0)
return "Off";
else
return "Custom";
}
function FullscreenSetting::getList()
{
return "Off,On";
}
//
function VSyncSetting::set(%setting)
{
switch$(%setting)
{
case "On":
GraphicsMenu::set("$pref::Video::disableVerticalSync", "0");
case "Off":
GraphicsMenu::set("$pref::Video::disableVerticalSync", "1");
default:
GraphicsMenu::set("$pref::Video::disableVerticalSync", "1");
}
}
function VSyncSetting::get()
{
if($pref::Video::disableVerticalSync == 0)
return "On";
else if($pref::Video::disableVerticalSync == 1)
return "Off";
else
return "Custom";
}
function VSyncSetting::getList()
{
return "Off,On";
}

File diff suppressed because it is too large Load diff

View file

@ -103,6 +103,7 @@ function MessageBoxOK(%title, %message, %callback)
MessageBoxOKButtonHolder-->OKButton.set("btn_a", "Return", "OK", "MessageCallback(MessageBoxDlg,MessageBoxDlg.callback);");
MessageBoxCtrl.originalMenuInputContainer = $activeMenuButtonContainer;
MessageBoxOKButtonHolder.setActive();
MBSetText(MessageBoxText, MessageBoxCtrl, %message);
@ -112,6 +113,7 @@ function MessageBoxOK(%title, %message, %callback)
function MessageBoxOKDlg::onSleep( %this )
{
%this.callback = "";
MessageBoxCtrl.originalMenuInputContainer.setActive();
}
function MessageBoxOKCancel(%title, %message, %callback, %cancelCallback)
@ -126,6 +128,7 @@ function MessageBoxOKCancel(%title, %message, %callback, %cancelCallback)
MessageBoxOCButtonHolder-->OKButton.set("btn_a", "Return", "OK", "MessageCallback(MessageBoxDlg,MessageBoxDlg.callback);");
MessageBoxOCButtonHolder-->CancelButton.set("btn_b", "Escape", "Cancel", "MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback);");
MessageBoxCtrl.originalMenuInputContainer = $activeMenuButtonContainer;
MessageBoxOCButtonHolder.setActive();
MBSetText(MessageBoxText, MessageBoxCtrl, %message);
@ -136,6 +139,7 @@ function MessageBoxOKCancel(%title, %message, %callback, %cancelCallback)
function MessageBoxOKCancelDlg::onSleep( %this )
{
%this.callback = "";
MessageBoxCtrl.originalMenuInputContainer.setActive();
}
function MessageBoxOKCancelDetails(%title, %message, %details, %callback, %cancelCallback)
@ -207,6 +211,7 @@ function MBOKCancelDetailsToggleInfoFrame()
function MessageBoxOKCancelDetailsDlg::onSleep( %this )
{
%this.callback = "";
MessageBoxCtrl.originalMenuInputContainer.setActive();
}
function MessageBoxYesNo(%title, %message, %yesCallback, %noCallback)
@ -221,6 +226,7 @@ function MessageBoxYesNo(%title, %message, %yesCallback, %noCallback)
MessageBoxOCButtonHolder-->OKButton.set("btn_a", "Return", "Yes", "MessageCallback(MessageBoxDlg,MessageBoxDlg.yesCallBack);");
MessageBoxOCButtonHolder-->CancelButton.set("btn_b", "Escape", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.noCallback);");
MessageBoxCtrl.originalMenuInputContainer = $activeMenuButtonContainer;
MessageBoxOCButtonHolder.setActive();
MBSetText(MessageBoxText, MessageBoxCtrl, %message);
@ -241,6 +247,7 @@ function MessageBoxYesNoCancel(%title, %message, %yesCallback, %noCallback, %can
MessageBoxYNCButtonHolder-->noButton.set("btn_x", "backspace", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.noCallback);");
MessageBoxYNCButtonHolder-->cancelButton.set("btn_b", "Escape", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback);");
MessageBoxCtrl.originalMenuInputContainer = $activeMenuButtonContainer;
MessageBoxYNCButtonHolder.setActive();
MBSetText(MessageBoxText, MessageBoxCtrl, %message);
@ -256,6 +263,7 @@ function MessageBoxDlg::onSleep( %this )
%this.yesCallback = "";
%this.noCallback = "";
%this.cancelCallback = "";
MessageBoxCtrl.originalMenuInputContainer.setActive();
}
//---------------------------------------------------------------------------------------------

View file

@ -10,6 +10,11 @@ new GuiGameListMenuProfile(DefaultListMenuProfile)
fontColorSEL = $TextMediumEmphasisColor;
fontColorNA = $TextDisabledColor;
fontColorHL = $TextMediumEmphasisColor;
fillColor = "108 108 108";
fillColorHL = "140 140 140";
fillColorSEL = "180 180 180";
HitAreaUpperLeft = "16 20";
HitAreaLowerRight = "503 74";
IconOffset = "40 0";