mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 07:02:54 +08:00
Apply requested changes
This commit is contained in:
parent
ac2c2b1499
commit
c4c2191500
@ -2,10 +2,12 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -28,9 +30,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
private static readonly SkinInfo random_skin_info = new RandomSkinInfo();
|
private static readonly SkinInfo random_skin_info = new RandomSkinInfo();
|
||||||
|
|
||||||
private SkinManager skins;
|
private SkinManager skins;
|
||||||
private SkinInfo[] usableSkins;
|
private List<SkinInfo> usableSkins;
|
||||||
|
|
||||||
private readonly Random random = new Random();
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config, SkinManager skins)
|
private void load(OsuConfigManager config, SkinManager skins)
|
||||||
@ -65,10 +65,10 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
|
|
||||||
config.BindWith(OsuSetting.Skin, configBindable);
|
config.BindWith(OsuSetting.Skin, configBindable);
|
||||||
|
|
||||||
usableSkins = skins.GetAllUsableSkins().ToArray();
|
usableSkins = skins.GetAllUsableSkins();
|
||||||
|
|
||||||
skinDropdown.Bindable = dropdownBindable;
|
skinDropdown.Bindable = dropdownBindable;
|
||||||
skinDropdown.Items = usableSkins.Length > 1 ? usableSkins.Concat(new[] { random_skin_info }) : usableSkins;
|
resetSkinButtons();
|
||||||
|
|
||||||
// Todo: This should not be necessary when OsuConfigManager is databased
|
// Todo: This should not be necessary when OsuConfigManager is databased
|
||||||
if (skinDropdown.Items.All(s => s.ID != configBindable.Value))
|
if (skinDropdown.Items.All(s => s.ID != configBindable.Value))
|
||||||
@ -86,15 +86,29 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
|
|
||||||
private void randomizeSkin()
|
private void randomizeSkin()
|
||||||
{
|
{
|
||||||
int n = usableSkins.Length;
|
int n = usableSkins.Count();
|
||||||
if (n > 1)
|
if (n > 1)
|
||||||
configBindable.Value = (configBindable.Value + random.Next(n - 1) + 1) % n; // make sure it's always a different one
|
configBindable.Value = (configBindable.Value + RNG.Next(n - 1) + 1) % n; // make sure it's always a different one
|
||||||
else
|
else
|
||||||
configBindable.Value = 0;
|
configBindable.Value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void itemRemoved(SkinInfo s) => Schedule(() => skinDropdown.Items = skinDropdown.Items.Where(i => i.ID != s.ID).ToArray());
|
private void itemRemoved(SkinInfo s) => Schedule(() =>
|
||||||
private void itemAdded(SkinInfo s) => Schedule(() => skinDropdown.Items = skinDropdown.Items.Append(s).ToArray());
|
{
|
||||||
|
usableSkins.RemoveAll(i => i.ID == s.ID);
|
||||||
|
resetSkinButtons();
|
||||||
|
});
|
||||||
|
|
||||||
|
private void itemAdded(SkinInfo s) => Schedule(() =>
|
||||||
|
{
|
||||||
|
usableSkins.Add(s);
|
||||||
|
resetSkinButtons();
|
||||||
|
});
|
||||||
|
|
||||||
|
private void resetSkinButtons()
|
||||||
|
{
|
||||||
|
skinDropdown.Items = usableSkins.Count() > 1 ? usableSkins.Concat(new[] { random_skin_info }) : usableSkins;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Skinning
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a list of all usable <see cref="SkinInfo"/>s. Includes the special default skin plus all skins from <see cref="GetAllUserSkins"/>.
|
/// Returns a list of all usable <see cref="SkinInfo"/>s. Includes the special default skin plus all skins from <see cref="GetAllUserSkins"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A list of available <see cref="SkinInfo"/>.</returns>
|
/// <returns>A newly allocated list of available <see cref="SkinInfo"/>.</returns>
|
||||||
public List<SkinInfo> GetAllUsableSkins()
|
public List<SkinInfo> GetAllUsableSkins()
|
||||||
{
|
{
|
||||||
var userSkins = GetAllUserSkins();
|
var userSkins = GetAllUserSkins();
|
||||||
@ -42,7 +42,7 @@ namespace osu.Game.Skinning
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a list of all usable <see cref="SkinInfo"/>s that have been loaded by the user.
|
/// Returns a list of all usable <see cref="SkinInfo"/>s that have been loaded by the user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A list of available <see cref="SkinInfo"/>.</returns>
|
/// <returns>A newly allocated list of available <see cref="SkinInfo"/>.</returns>
|
||||||
public List<SkinInfo> GetAllUserSkins() => ModelStore.ConsumableItems.Where(s => !s.DeletePending).ToList();
|
public List<SkinInfo> GetAllUserSkins() => ModelStore.ConsumableItems.Where(s => !s.DeletePending).ToList();
|
||||||
|
|
||||||
protected override SkinInfo CreateModel(ArchiveReader archive) => new SkinInfo
|
protected override SkinInfo CreateModel(ArchiveReader archive) => new SkinInfo
|
||||||
|
Loading…
Reference in New Issue
Block a user