1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 07:04:15 +08:00

Add skin seleciton dropdown to settings

This commit is contained in:
Dean Herbert 2018-02-22 15:44:25 +09:00
parent 2351b6ab26
commit 659cf629b6

View File

@ -1,26 +1,33 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// 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.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
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;
using osu.Game.Skinning;
using OpenTK; using OpenTK;
namespace osu.Game.Overlays.Settings.Sections namespace osu.Game.Overlays.Settings.Sections
{ {
public class SkinSection : SettingsSection public class SkinSection : SettingsSection
{ {
private SettingsDropdown<SkinInfo> skinDropdown;
public override string Header => "Skin"; public override string Header => "Skin";
public override FontAwesome Icon => FontAwesome.fa_paint_brush; public override FontAwesome Icon => FontAwesome.fa_paint_brush;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config) private void load(OsuConfigManager config, SkinManager skins)
{ {
FlowContent.Spacing = new Vector2(0, 5); FlowContent.Spacing = new Vector2(0, 5);
Children = new Drawable[] Children = new Drawable[]
{ {
skinDropdown = new SettingsDropdown<SkinInfo>(),
new SettingsSlider<double, SizeSlider> new SettingsSlider<double, SizeSlider>
{ {
LabelText = "Menu cursor size", LabelText = "Menu cursor size",
@ -39,6 +46,14 @@ namespace osu.Game.Overlays.Settings.Sections
Bindable = config.GetBindable<bool>(OsuSetting.AutoCursorSize) Bindable = config.GetBindable<bool>(OsuSetting.AutoCursorSize)
}, },
}; };
void reloadSkins() => skinDropdown.Items = skins.GetAllUsableSkins().Select(s => new KeyValuePair<string, SkinInfo>(s.Name, s));
skins.ItemAdded += _ => reloadSkins();
skins.ItemRemoved += _ => reloadSkins();
reloadSkins();
skinDropdown.Bindable = skins.CurrentSkinInfo;
} }
private class SizeSlider : OsuSliderBar<double> private class SizeSlider : OsuSliderBar<double>