Remove unnecessary local item storage in SettingsDropdown (#5142)

Remove unnecessary local item storage in SettingsDropdown
This commit is contained in:
Dean Herbert 2019-06-25 15:22:20 +09:00 committed by GitHub
commit f2207aae4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 24 deletions

View File

@ -73,7 +73,7 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
private class AudioDeviceSettingsDropdown : SettingsDropdown<string>
{
protected override OsuDropdown<string> CreateDropdown() => new AudioDeviceDropdownControl { Items = Items };
protected override OsuDropdown<string> CreateDropdown() => new AudioDeviceDropdownControl();
private class AudioDeviceDropdownControl : DropdownControl
{

View File

@ -237,7 +237,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
private class ResolutionSettingsDropdown : SettingsDropdown<Size>
{
protected override OsuDropdown<Size> CreateDropdown() => new ResolutionDropdownControl { Items = Items };
protected override OsuDropdown<Size> CreateDropdown() => new ResolutionDropdownControl();
private class ResolutionDropdownControl : DropdownControl
{

View File

@ -108,7 +108,7 @@ namespace osu.Game.Overlays.Settings.Sections
private class SkinSettingsDropdown : SettingsDropdown<SkinInfo>
{
protected override OsuDropdown<SkinInfo> CreateDropdown() => new SkinDropdownControl { Items = Items };
protected override OsuDropdown<SkinInfo> CreateDropdown() => new SkinDropdownControl();
private class SkinDropdownControl : DropdownControl
{

View File

@ -13,39 +13,23 @@ namespace osu.Game.Overlays.Settings
{
protected new OsuDropdown<T> Control => (OsuDropdown<T>)base.Control;
private IEnumerable<T> items = Enumerable.Empty<T>();
public IEnumerable<T> Items
{
get => items;
set
{
items = value;
if (Control != null)
Control.Items = value;
}
get => Control.Items;
set => Control.Items = value;
}
private IBindableList<T> itemSource;
public IBindableList<T> ItemSource
{
get => itemSource;
set
{
itemSource = value;
if (Control != null)
Control.ItemSource = value;
}
get => Control.ItemSource;
set => Control.ItemSource = value;
}
public override IEnumerable<string> FilterTerms => base.FilterTerms.Concat(Control.Items.Select(i => i.ToString()));
protected sealed override Drawable CreateControl() => CreateDropdown();
protected virtual OsuDropdown<T> CreateDropdown() => new DropdownControl { Items = Items, ItemSource = ItemSource };
protected virtual OsuDropdown<T> CreateDropdown() => new DropdownControl();
protected class DropdownControl : OsuDropdown<T>
{