UI - Add Volume Controls + Mute Toggle (F2) (#2871)
* Add the ability to toggle mute in the status bar. * Add the ability to toggle mute in the status bar. * Formatting fixes * Add hotkey (F2) to mute * Add default hotkey to config.json * Add ability to change volume via slider. * Fix Headless * Fix SDL2 Problem : Credits to d3xMachina * Remove unnecessary work * Address gdk comments * Toggling with Hotkey now properly restores volume to original level. * Toggling with Hotkey now properly restores volume to original level. * Update UI to show Volume % instead of Muted/Unmuted * Clean up the volume ui a bit. * Undo unintentionally committed code. * Implement AudRen Support * Restore intiial volume level in function definition. * Finalize UI * Finalize UI * Use clamp for bounds check * Use Math.Clamp for volume in soundio * Address comments by gdkchan * Address remaining comments * Fix missing semicolon * Address remaining gdkchan comment * Fix comment * Change /* to // * Allow volume slider to change volume immediately. Also force label text to cast to int to prevent decimals from showing in status bar * Remove blank line * Undo setting of volume level when "Cancel" is pressed. * Fix allignment for settings window code
This commit is contained in:
parent
e7c2dc8ec3
commit
cb43cc7e32
35 changed files with 411 additions and 94 deletions
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
@ -132,6 +132,7 @@ namespace Ryujinx.Ui
|
|||
[GUI] ProgressBar _progressBar;
|
||||
[GUI] Box _viewBox;
|
||||
[GUI] Label _vSyncStatus;
|
||||
[GUI] Label _volumeStatus;
|
||||
[GUI] Box _listStatusBox;
|
||||
[GUI] Label _loadingStatusLabel;
|
||||
[GUI] ProgressBar _loadingStatusBar;
|
||||
|
@ -205,6 +206,7 @@ namespace Ryujinx.Ui
|
|||
ConfigurationState.Instance.System.IgnoreMissingServices.Event += UpdateIgnoreMissingServicesState;
|
||||
ConfigurationState.Instance.Graphics.AspectRatio.Event += UpdateAspectRatioState;
|
||||
ConfigurationState.Instance.System.EnableDockedMode.Event += UpdateDockedModeState;
|
||||
ConfigurationState.Instance.System.AudioVolume.Event += UpdateAudioVolumeState;
|
||||
|
||||
if (ConfigurationState.Instance.Ui.StartFullscreen)
|
||||
{
|
||||
|
@ -305,6 +307,11 @@ namespace Ryujinx.Ui
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateAudioVolumeState(object sender, ReactiveEventArgs<float> e)
|
||||
{
|
||||
_emulationContext?.SetVolume(e.NewValue);
|
||||
}
|
||||
|
||||
private void WindowStateEvent_Changed(object o, WindowStateEventArgs args)
|
||||
{
|
||||
_fullScreen.Label = args.Event.NewWindowState.HasFlag(Gdk.WindowState.Fullscreen) ? "Exit Fullscreen" : "Enter Fullscreen";
|
||||
|
@ -562,7 +569,8 @@ namespace Ryujinx.Ui
|
|||
ConfigurationState.Instance.System.TimeZone,
|
||||
ConfigurationState.Instance.System.MemoryManagerMode,
|
||||
ConfigurationState.Instance.System.IgnoreMissingServices,
|
||||
ConfigurationState.Instance.Graphics.AspectRatio);
|
||||
ConfigurationState.Instance.Graphics.AspectRatio,
|
||||
ConfigurationState.Instance.System.AudioVolume);
|
||||
|
||||
_emulationContext = new HLE.Switch(configuration);
|
||||
}
|
||||
|
@ -1108,11 +1116,12 @@ namespace Ryujinx.Ui
|
|||
{
|
||||
Application.Invoke(delegate
|
||||
{
|
||||
_gameStatus.Text = args.GameStatus;
|
||||
_fifoStatus.Text = args.FifoStatus;
|
||||
_gpuName.Text = args.GpuName;
|
||||
_dockedMode.Text = args.DockedMode;
|
||||
_aspectRatio.Text = args.AspectRatio;
|
||||
_gameStatus.Text = args.GameStatus;
|
||||
_fifoStatus.Text = args.FifoStatus;
|
||||
_gpuName.Text = args.GpuName;
|
||||
_dockedMode.Text = args.DockedMode;
|
||||
_aspectRatio.Text = args.AspectRatio;
|
||||
_volumeStatus.Text = GetVolumeLabelText(args.Volume);
|
||||
|
||||
if (args.VSyncEnabled)
|
||||
{
|
||||
|
@ -1173,6 +1182,28 @@ namespace Ryujinx.Ui
|
|||
ConfigurationState.Instance.System.EnableDockedMode.Value = !ConfigurationState.Instance.System.EnableDockedMode.Value;
|
||||
}
|
||||
|
||||
private string GetVolumeLabelText(float volume)
|
||||
{
|
||||
string icon = volume == 0 ? "🔇" : "🔊";
|
||||
|
||||
return $"{icon} {(int)(volume * 100)}%";
|
||||
}
|
||||
|
||||
private void VolumeStatus_Clicked(object sender, ButtonReleaseEventArgs args)
|
||||
{
|
||||
if (_emulationContext != null)
|
||||
{
|
||||
if (_emulationContext.IsAudioMuted())
|
||||
{
|
||||
_emulationContext.SetVolume(ConfigurationState.Instance.System.AudioVolume);
|
||||
}
|
||||
else
|
||||
{
|
||||
_emulationContext.SetVolume(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AspectRatio_Clicked(object sender, ButtonReleaseEventArgs args)
|
||||
{
|
||||
AspectRatio aspectRatio = ConfigurationState.Instance.Graphics.AspectRatio.Value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue