mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 05:52:55 +08:00
Avoid initial synchronous dropdown population overhead in AudioDevicesSettings
This commit is contained in:
parent
8d051d9fa0
commit
b541550ea9
@ -20,17 +20,26 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
|
|||||||
|
|
||||||
private SettingsDropdown<string> dropdown;
|
private SettingsDropdown<string> dropdown;
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
Children = new Drawable[]
|
||||||
|
|
||||||
if (audio != null)
|
|
||||||
{
|
{
|
||||||
audio.OnNewDevice -= onDeviceChanged;
|
dropdown = new AudioDeviceSettingsDropdown
|
||||||
audio.OnLostDevice -= onDeviceChanged;
|
{
|
||||||
}
|
Keywords = new[] { "speaker", "headphone", "output" }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
updateItems();
|
||||||
|
|
||||||
|
audio.OnNewDevice += onDeviceChanged;
|
||||||
|
audio.OnLostDevice += onDeviceChanged;
|
||||||
|
dropdown.Current = audio.AudioDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onDeviceChanged(string name) => updateItems();
|
||||||
|
|
||||||
private void updateItems()
|
private void updateItems()
|
||||||
{
|
{
|
||||||
var deviceItems = new List<string> { string.Empty };
|
var deviceItems = new List<string> { string.Empty };
|
||||||
@ -49,26 +58,15 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
|
|||||||
dropdown.Items = deviceItems.Distinct().ToList();
|
dropdown.Items = deviceItems.Distinct().ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDeviceChanged(string name) => updateItems();
|
protected override void Dispose(bool isDisposing)
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
Children = new Drawable[]
|
if (audio != null)
|
||||||
{
|
{
|
||||||
dropdown = new AudioDeviceSettingsDropdown
|
audio.OnNewDevice -= onDeviceChanged;
|
||||||
{
|
audio.OnLostDevice -= onDeviceChanged;
|
||||||
Keywords = new[] { "speaker", "headphone", "output" }
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
updateItems();
|
|
||||||
|
|
||||||
dropdown.Current = audio.AudioDevice;
|
|
||||||
|
|
||||||
audio.OnNewDevice += onDeviceChanged;
|
|
||||||
audio.OnLostDevice += onDeviceChanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AudioDeviceSettingsDropdown : SettingsDropdown<string>
|
private class AudioDeviceSettingsDropdown : SettingsDropdown<string>
|
||||||
|
Loading…
Reference in New Issue
Block a user