mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 21:32:57 +08:00
Remove collection ToLive
helper method to avoid confusion
This commit is contained in:
parent
d1a2256262
commit
45636ce04b
@ -216,12 +216,6 @@ namespace osu.Game.Database
|
|||||||
return new RealmLiveUnmanaged<T>(realmObject);
|
return new RealmLiveUnmanaged<T>(realmObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Live<T>> ToLive<T>(this IEnumerable<T> realmList, RealmAccess realm)
|
|
||||||
where T : RealmObject, IHasGuidPrimaryKey
|
|
||||||
{
|
|
||||||
return realmList.Select(l => new RealmLive<T>(l, realm)).Cast<Live<T>>().ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Live<T> ToLive<T>(this T realmObject, RealmAccess realm)
|
public static Live<T> ToLive<T>(this T realmObject, RealmAccess realm)
|
||||||
where T : RealmObject, IHasGuidPrimaryKey
|
where T : RealmObject, IHasGuidPrimaryKey
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
Name = "<Random Skin>",
|
Name = "<Random Skin>",
|
||||||
}.ToLiveUnmanaged();
|
}.ToLiveUnmanaged();
|
||||||
|
|
||||||
private List<Live<SkinInfo>> skinItems;
|
private readonly List<Live<SkinInfo>> dropdownItems = new List<Live<SkinInfo>>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private SkinManager skins { get; set; }
|
private SkinManager skins { get; set; }
|
||||||
@ -111,19 +111,23 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
configBindable.Value = skin.NewValue.ID.ToString();
|
configBindable.Value = skin.NewValue.ID.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void skinsChanged(IRealmCollection<SkinInfo> skins, ChangeSet changes, Exception error)
|
private void skinsChanged(IRealmCollection<SkinInfo> sender, ChangeSet changes, Exception error)
|
||||||
{
|
{
|
||||||
// This can only mean that realm is recycling, else we would see the protected skins.
|
// This can only mean that realm is recycling, else we would see the protected skins.
|
||||||
// Because we are using `Live<>` in this class, we don't need to worry about this scenario too much.
|
// Because we are using `Live<>` in this class, we don't need to worry about this scenario too much.
|
||||||
if (!skins.Any())
|
if (!sender.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int protectedCount = skins.Count(s => s.Protected);
|
int protectedCount = sender.Count(s => s.Protected);
|
||||||
|
|
||||||
skinItems = skins.ToLive(realm);
|
// For simplicity repopulate the full list.
|
||||||
skinItems.Insert(protectedCount, random_skin_info);
|
// In the future we should change this to properly handle ChangeSet events.
|
||||||
|
dropdownItems.Clear();
|
||||||
|
foreach (var skin in sender)
|
||||||
|
dropdownItems.Add(skin.ToLive(realm));
|
||||||
|
dropdownItems.Insert(protectedCount, random_skin_info);
|
||||||
|
|
||||||
skinDropdown.Items = skinItems;
|
skinDropdown.Items = dropdownItems;
|
||||||
|
|
||||||
updateSelectedSkinFromConfig();
|
updateSelectedSkinFromConfig();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user