mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-08-17 14:18:44 +02:00
Replace the Audio Backend ComboBoxText to a ComboBox with a custom model (#1451)
* Use a combobox with a custom model to be able to disable entries within it * Address Ack's comments
This commit is contained in:
parent
9c6a3aacc2
commit
58f65b6523
2 changed files with 67 additions and 50 deletions
|
@ -19,11 +19,12 @@ namespace Ryujinx.Ui
|
||||||
{
|
{
|
||||||
public class SettingsWindow : Window
|
public class SettingsWindow : Window
|
||||||
{
|
{
|
||||||
private static ListStore _gameDirsBoxStore;
|
private readonly VirtualFileSystem _virtualFileSystem;
|
||||||
private static VirtualFileSystem _virtualFileSystem;
|
private readonly ListStore _gameDirsBoxStore;
|
||||||
|
private readonly ListStore _audioBackendStore;
|
||||||
|
private readonly TimeZoneContentManager _timeZoneContentManager;
|
||||||
|
private readonly HashSet<string> _validTzRegions;
|
||||||
|
|
||||||
private TimeZoneContentManager _timeZoneContentManager;
|
|
||||||
private HashSet<string> _validTzRegions;
|
|
||||||
private long _systemTimeOffset;
|
private long _systemTimeOffset;
|
||||||
|
|
||||||
#pragma warning disable CS0649, IDE0044
|
#pragma warning disable CS0649, IDE0044
|
||||||
|
@ -49,7 +50,8 @@ namespace Ryujinx.Ui
|
||||||
[GUI] ComboBoxText _systemRegionSelect;
|
[GUI] ComboBoxText _systemRegionSelect;
|
||||||
[GUI] Entry _systemTimeZoneEntry;
|
[GUI] Entry _systemTimeZoneEntry;
|
||||||
[GUI] EntryCompletion _systemTimeZoneCompletion;
|
[GUI] EntryCompletion _systemTimeZoneCompletion;
|
||||||
[GUI] ComboBoxText _audioBackendSelect;
|
[GUI] Box _audioBackendBox;
|
||||||
|
[GUI] ComboBox _audioBackendSelect;
|
||||||
[GUI] SpinButton _systemTimeYearSpin;
|
[GUI] SpinButton _systemTimeYearSpin;
|
||||||
[GUI] SpinButton _systemTimeMonthSpin;
|
[GUI] SpinButton _systemTimeMonthSpin;
|
||||||
[GUI] SpinButton _systemTimeDaySpin;
|
[GUI] SpinButton _systemTimeDaySpin;
|
||||||
|
@ -203,30 +205,6 @@ namespace Ryujinx.Ui
|
||||||
_custThemeToggle.Click();
|
_custThemeToggle.Click();
|
||||||
}
|
}
|
||||||
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
if (SoundIoAudioOut.IsSupported)
|
|
||||||
{
|
|
||||||
Application.Invoke(delegate
|
|
||||||
{
|
|
||||||
_audioBackendSelect.Append(AudioBackend.SoundIo.ToString(), "SoundIO");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OpenALAudioOut.IsSupported)
|
|
||||||
{
|
|
||||||
Application.Invoke(delegate
|
|
||||||
{
|
|
||||||
_audioBackendSelect.Append(AudioBackend.OpenAl.ToString(), "OpenAL");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Application.Invoke(delegate
|
|
||||||
{
|
|
||||||
_audioBackendSelect.SetActiveId(ConfigurationState.Instance.System.AudioBackend.Value.ToString());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Custom EntryCompletion Columns. If added to glade, need to override more signals
|
// Custom EntryCompletion Columns. If added to glade, need to override more signals
|
||||||
ListStore tzList = new ListStore(typeof(string), typeof(string), typeof(string));
|
ListStore tzList = new ListStore(typeof(string), typeof(string), typeof(string));
|
||||||
_systemTimeZoneCompletion.Model = tzList;
|
_systemTimeZoneCompletion.Model = tzList;
|
||||||
|
@ -290,6 +268,55 @@ namespace Ryujinx.Ui
|
||||||
|
|
||||||
//Setup system time spinners
|
//Setup system time spinners
|
||||||
UpdateSystemTimeSpinners();
|
UpdateSystemTimeSpinners();
|
||||||
|
|
||||||
|
_audioBackendStore = new ListStore(typeof(string), typeof(AudioBackend));
|
||||||
|
|
||||||
|
TreeIter openAlIter = _audioBackendStore.AppendValues("OpenAL", AudioBackend.OpenAl);
|
||||||
|
TreeIter soundIoIter = _audioBackendStore.AppendValues("SoundIO", AudioBackend.SoundIo);
|
||||||
|
TreeIter dummyIter = _audioBackendStore.AppendValues("Dummy", AudioBackend.Dummy);
|
||||||
|
|
||||||
|
_audioBackendSelect = ComboBox.NewWithModelAndEntry(_audioBackendStore);
|
||||||
|
_audioBackendSelect.EntryTextColumn = 0;
|
||||||
|
_audioBackendSelect.Entry.IsEditable = false;
|
||||||
|
|
||||||
|
switch (ConfigurationState.Instance.System.AudioBackend.Value)
|
||||||
|
{
|
||||||
|
case AudioBackend.OpenAl:
|
||||||
|
_audioBackendSelect.SetActiveIter(openAlIter);
|
||||||
|
break;
|
||||||
|
case AudioBackend.SoundIo:
|
||||||
|
_audioBackendSelect.SetActiveIter(soundIoIter);
|
||||||
|
break;
|
||||||
|
case AudioBackend.Dummy:
|
||||||
|
_audioBackendSelect.SetActiveIter(dummyIter);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
|
|
||||||
|
_audioBackendBox.Add(_audioBackendSelect);
|
||||||
|
_audioBackendSelect.Show();
|
||||||
|
|
||||||
|
bool openAlIsSupported = false;
|
||||||
|
bool soundIoIsSupported = false;
|
||||||
|
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
openAlIsSupported = OpenALAudioOut.IsSupported;
|
||||||
|
soundIoIsSupported = SoundIoAudioOut.IsSupported;
|
||||||
|
});
|
||||||
|
|
||||||
|
// This function runs whenever the dropdown is opened
|
||||||
|
_audioBackendSelect.SetCellDataFunc(_audioBackendSelect.Cells[0], (layout, cell, model, iter) =>
|
||||||
|
{
|
||||||
|
cell.Sensitive = ((AudioBackend)_audioBackendStore.GetValue(iter, 1)) switch
|
||||||
|
{
|
||||||
|
AudioBackend.OpenAl => openAlIsSupported,
|
||||||
|
AudioBackend.SoundIo => soundIoIsSupported,
|
||||||
|
AudioBackend.Dummy => true,
|
||||||
|
_ => throw new ArgumentOutOfRangeException()
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateSystemTimeSpinners()
|
private void UpdateSystemTimeSpinners()
|
||||||
|
@ -486,8 +513,7 @@ namespace Ryujinx.Ui
|
||||||
_gameDirsBoxStore.IterNext(ref treeIter);
|
_gameDirsBoxStore.IterNext(ref treeIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
float resScaleCustom;
|
if (!float.TryParse(_resScaleText.Buffer.Text, out float resScaleCustom) || resScaleCustom <= 0.0f)
|
||||||
if (!float.TryParse(_resScaleText.Buffer.Text, out resScaleCustom) || resScaleCustom <= 0.0f)
|
|
||||||
{
|
{
|
||||||
resScaleCustom = 1.0f;
|
resScaleCustom = 1.0f;
|
||||||
}
|
}
|
||||||
|
@ -517,7 +543,6 @@ namespace Ryujinx.Ui
|
||||||
ConfigurationState.Instance.Ui.EnableCustomTheme.Value = _custThemeToggle.Active;
|
ConfigurationState.Instance.Ui.EnableCustomTheme.Value = _custThemeToggle.Active;
|
||||||
ConfigurationState.Instance.System.Language.Value = Enum.Parse<Language>(_systemLanguageSelect.ActiveId);
|
ConfigurationState.Instance.System.Language.Value = Enum.Parse<Language>(_systemLanguageSelect.ActiveId);
|
||||||
ConfigurationState.Instance.System.Region.Value = Enum.Parse<Configuration.System.Region>(_systemRegionSelect.ActiveId);
|
ConfigurationState.Instance.System.Region.Value = Enum.Parse<Configuration.System.Region>(_systemRegionSelect.ActiveId);
|
||||||
ConfigurationState.Instance.System.AudioBackend.Value = Enum.Parse<AudioBackend>(_audioBackendSelect.ActiveId);
|
|
||||||
ConfigurationState.Instance.System.SystemTimeOffset.Value = _systemTimeOffset;
|
ConfigurationState.Instance.System.SystemTimeOffset.Value = _systemTimeOffset;
|
||||||
ConfigurationState.Instance.Ui.CustomThemePath.Value = _custThemePath.Buffer.Text;
|
ConfigurationState.Instance.Ui.CustomThemePath.Value = _custThemePath.Buffer.Text;
|
||||||
ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = _graphicsShadersDumpPath.Buffer.Text;
|
ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = _graphicsShadersDumpPath.Buffer.Text;
|
||||||
|
@ -527,6 +552,11 @@ namespace Ryujinx.Ui
|
||||||
ConfigurationState.Instance.Graphics.ResScale.Value = int.Parse(_resScaleCombo.ActiveId);
|
ConfigurationState.Instance.Graphics.ResScale.Value = int.Parse(_resScaleCombo.ActiveId);
|
||||||
ConfigurationState.Instance.Graphics.ResScaleCustom.Value = resScaleCustom;
|
ConfigurationState.Instance.Graphics.ResScaleCustom.Value = resScaleCustom;
|
||||||
|
|
||||||
|
if (_audioBackendSelect.GetActiveIter(out TreeIter activeIter))
|
||||||
|
{
|
||||||
|
ConfigurationState.Instance.System.AudioBackend.Value = (AudioBackend)_audioBackendStore.GetValue(activeIter, 1);
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow.SaveConfig();
|
MainWindow.SaveConfig();
|
||||||
MainWindow.UpdateGraphicsConfig();
|
MainWindow.UpdateGraphicsConfig();
|
||||||
MainWindow.ApplyTheme();
|
MainWindow.ApplyTheme();
|
||||||
|
|
|
@ -1476,15 +1476,19 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="AudioBackendBox">
|
<object class="GtkBox" id="_audioBackendBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="tooltip_text" translatable="yes">Change System Region</property>
|
<property name="tooltip_text" translatable="yes">Change System Region</property>
|
||||||
<property name="halign">end</property>
|
<property name="halign">end</property>
|
||||||
|
<property name="margin_right">5</property>
|
||||||
<property name="label" translatable="yes">Audio Backend: </property>
|
<property name="label" translatable="yes">Audio Backend: </property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
|
@ -1494,23 +1498,6 @@
|
||||||
<property name="position">2</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkComboBoxText" id="_audioBackendSelect">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="tooltip_text" translatable="yes">Change Audio Backend</property>
|
|
||||||
<property name="margin_left">5</property>
|
|
||||||
<property name="active_id">Dummy</property>
|
|
||||||
<items>
|
|
||||||
<item id="Dummy" translatable="yes">Dummy</item>
|
|
||||||
</items>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
|
Loading…
Reference in a new issue