From 3726db53b5537a90adfb85b108fd35e2064d5b49 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 22 Feb 2018 17:16:48 +0900 Subject: [PATCH 01/11] Allow instantiation of skins --- osu.Game/OsuGameBase.cs | 4 +-- osu.Game/Skinning/DefaultSkin.cs | 17 +++++++++++ osu.Game/Skinning/LegacySkin.cs | 49 ++++++++++++++++++++++++++++++++ osu.Game/Skinning/Skin.cs | 22 ++++++++++++++ osu.Game/Skinning/SkinManager.cs | 34 ++++++++++++++++++++-- osu.Game/osu.Game.csproj | 5 +++- 6 files changed, 125 insertions(+), 6 deletions(-) create mode 100644 osu.Game/Skinning/DefaultSkin.cs create mode 100644 osu.Game/Skinning/LegacySkin.cs create mode 100644 osu.Game/Skinning/Skin.cs diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 94ed696e49..f3c46269d5 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . +// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; @@ -106,7 +106,7 @@ namespace osu.Game runMigrations(); - dependencies.Cache(SkinManager = new SkinManager(Host.Storage, contextFactory, Host)); + dependencies.Cache(SkinManager = new SkinManager(Host.Storage, contextFactory, Host, Audio)); dependencies.Cache(API = new APIAccess { diff --git a/osu.Game/Skinning/DefaultSkin.cs b/osu.Game/Skinning/DefaultSkin.cs new file mode 100644 index 0000000000..794ed58fca --- /dev/null +++ b/osu.Game/Skinning/DefaultSkin.cs @@ -0,0 +1,17 @@ +using osu.Framework.Audio.Sample; +using osu.Framework.Graphics; + +namespace osu.Game.Skinning +{ + public class DefaultSkin : Skin + { + public DefaultSkin() + : base(SkinInfo.Default) + { + } + + public override Drawable GetDrawableComponent(string componentName) => null; + + public override SampleChannel GetSample(string sampleName) => null; + } +} diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs new file mode 100644 index 0000000000..1c56a64048 --- /dev/null +++ b/osu.Game/Skinning/LegacySkin.cs @@ -0,0 +1,49 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.IO; +using System.Linq; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Framework.IO.Stores; + +namespace osu.Game.Skinning +{ + public class LegacySkin : Skin + { + private readonly TextureStore textures; + + private readonly SampleManager samples; + + public LegacySkin(SkinInfo skin, IResourceStore storage, AudioManager audioManager) + : base(skin) + { + var audioStore = new ResourceStore(storage); + + samples = audioManager.GetSampleManager(audioStore); + textures = new TextureStore(new RawTextureLoaderStore(storage)); + } + + private string getPathForFile(string filename) => + SkinInfo.Files.FirstOrDefault(f => string.Equals(Path.GetFileNameWithoutExtension(f.Filename), filename, StringComparison.InvariantCultureIgnoreCase))?.FileInfo.StoragePath; + + public override Drawable GetDrawableComponent(string componentName) + { + var texture = textures.Get(getPathForFile(componentName.Split('/').Last())); + if (texture == null) return null; + + return new Sprite + { + RelativeSizeAxes = Axes.Both, + FillMode = FillMode.Fit, + Texture = texture, + }; + } + + public override SampleChannel GetSample(string sampleName) => samples.Get(getPathForFile(sampleName.Split('/').Last())); + } +} diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs new file mode 100644 index 0000000000..fafbdec8f0 --- /dev/null +++ b/osu.Game/Skinning/Skin.cs @@ -0,0 +1,22 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Audio.Sample; +using osu.Framework.Graphics; + +namespace osu.Game.Skinning +{ + public abstract class Skin + { + public readonly SkinInfo SkinInfo; + + public abstract Drawable GetDrawableComponent(string componentName); + + public abstract SampleChannel GetSample(string sampleName); + + protected Skin(SkinInfo skin) + { + SkinInfo = skin; + } + } +} diff --git a/osu.Game/Skinning/SkinManager.cs b/osu.Game/Skinning/SkinManager.cs index 0031968b2b..12e34ec0a0 100644 --- a/osu.Game/Skinning/SkinManager.cs +++ b/osu.Game/Skinning/SkinManager.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . +// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore; +using osu.Framework.Audio; using osu.Framework.Configuration; using osu.Framework.Platform; using osu.Game.Database; @@ -15,6 +16,9 @@ namespace osu.Game.Skinning { public class SkinManager : ArchiveModelManager { + private readonly AudioManager audio; + + public readonly Bindable CurrentSkin = new Bindable(new DefaultSkin()); public readonly Bindable CurrentSkinInfo = new Bindable(SkinInfo.Default) { Default = SkinInfo.Default }; public override string[] HandledExtensions => new[] { ".osk" }; @@ -30,13 +34,37 @@ namespace osu.Game.Skinning return userSkins; } - protected override SkinInfo CreateModel(ArchiveReader archive) => new SkinInfo { Name = archive.Name }; + protected override SkinInfo CreateModel(ArchiveReader archive) => new SkinInfo + { + Name = archive.Name + }; + + /// + /// Retrieve a instance for the provided + /// + /// The skin to lookup. + /// A instance correlating to the provided . + public Skin GetSkin(SkinInfo skinInfo) + { + if (skinInfo == SkinInfo.Default) + return new DefaultSkin(); + + return new LegacySkin(skinInfo, Files.Store, audio); + } private SkinStore store; - public SkinManager(Storage storage, DatabaseContextFactory contextFactory, IIpcHost importHost) + public SkinManager(Storage storage, DatabaseContextFactory contextFactory, IIpcHost importHost, AudioManager audio) : base(storage, contextFactory, new SkinStore(contextFactory, storage), importHost) { + this.audio = audio; + + CurrentSkinInfo.ValueChanged += info => { CurrentSkin.Value = GetSkin(info); }; + CurrentSkin.ValueChanged += skin => + { + if (skin.SkinInfo != CurrentSkinInfo.Value) + throw new InvalidOperationException($"Setting {nameof(CurrentSkin)}'s value directly is not supported. Use {nameof(CurrentSkinInfo)} isntead."); + }; } /// diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 829addc360..dc5914a76f 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -1,4 +1,4 @@ - + @@ -854,6 +854,9 @@ + + + From 84b707f4f8edd74c5c5f372c181cfccf679a15f9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 22 Feb 2018 17:33:47 +0900 Subject: [PATCH 02/11] Add basic hitcircle skinning --- .../Drawables/Pieces/ApproachCircle.cs | 12 +--- .../Objects/Drawables/Pieces/CirclePiece.cs | 27 +-------- .../Drawables/Pieces/DefaultCirclePiece.cs | 35 +++++++++++ .../Objects/Drawables/Pieces/GlowPiece.cs | 24 ++++---- .../Objects/Drawables/Pieces/NumberPiece.cs | 10 ++-- .../Objects/Drawables/Pieces/RingPiece.cs | 27 +++++---- .../osu.Game.Rulesets.Osu.csproj | 1 + osu.Game/Skinning/SkinnableDrawable.cs | 58 +++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 9 files changed, 129 insertions(+), 66 deletions(-) create mode 100644 osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/DefaultCirclePiece.cs create mode 100644 osu.Game/Skinning/SkinnableDrawable.cs diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ApproachCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ApproachCircle.cs index 61e9027157..51f8b7026a 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ApproachCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ApproachCircle.cs @@ -6,30 +6,24 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; +using osu.Game.Skinning; namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { public class ApproachCircle : Container { - private readonly Sprite approachCircle; - public ApproachCircle() { Anchor = Anchor.Centre; Origin = Anchor.Centre; - AutoSizeAxes = Axes.Both; - - Children = new Drawable[] - { - approachCircle = new Sprite() - }; + RelativeSizeAxes = Axes.Both; } [BackgroundDependencyLoader] private void load(TextureStore textures) { - approachCircle.Texture = textures.Get(@"Play/osu/approachcircle"); + Child = new SkinnableDrawable("Play/osu/approachcircle", name => new Sprite { Texture = textures.Get(name) }); } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs index 286df14056..e7b6598cf2 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs @@ -2,20 +2,16 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; using osu.Framework.Input.Bindings; +using osu.Game.Skinning; using OpenTK; namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { public class CirclePiece : Container, IKeyBindingHandler { - private readonly Sprite disc; - public Func Hit; public CirclePiece() @@ -27,26 +23,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces Anchor = Anchor.Centre; Origin = Anchor.Centre; - Children = new Drawable[] - { - disc = new Sprite - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }, - new TrianglesPiece - { - RelativeSizeAxes = Axes.Both, - Blending = BlendingMode.Additive, - Alpha = 0.5f, - } - }; - } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - disc.Texture = textures.Get(@"Play/osu/disc"); + InternalChild = new SkinnableDrawable("Play/osu/hitcircle", _ => new DefaultCirclePiece()); } public bool OnPressed(OsuAction action) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/DefaultCirclePiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/DefaultCirclePiece.cs new file mode 100644 index 0000000000..61f73b6d66 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/DefaultCirclePiece.cs @@ -0,0 +1,35 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; + +namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces +{ + public class DefaultCirclePiece : Container + { + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + RelativeSizeAxes = Axes.Both; + Children = new Drawable[] + { + new Sprite + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Texture = textures.Get(@"Play/osu/disc"), + }, + new TrianglesPiece + { + RelativeSizeAxes = Axes.Both, + Blending = BlendingMode.Additive, + Alpha = 0.5f, + } + }; + } + } +} diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/GlowPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/GlowPiece.cs index 9a1208f998..a4e1916659 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/GlowPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/GlowPiece.cs @@ -6,34 +6,30 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; +using osu.Game.Skinning; namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { public class GlowPiece : Container { - private readonly Sprite layer; - public GlowPiece() { Anchor = Anchor.Centre; Origin = Anchor.Centre; - - Children = new[] - { - layer = new Sprite - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Blending = BlendingMode.Additive, - Alpha = 0.5f - } - }; + RelativeSizeAxes = Axes.Both; } [BackgroundDependencyLoader] private void load(TextureStore textures) { - layer.Texture = textures.Get(@"Play/osu/ring-glow"); + Child = new SkinnableDrawable("Play/osu/ring-glow", name => new Sprite + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Texture = textures.Get(name), + Blending = BlendingMode.Additive, + Alpha = 0.5f + }, false); } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/NumberPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/NumberPiece.cs index afbf00f320..4220299c66 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/NumberPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/NumberPiece.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Graphics.Sprites; using OpenTK.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Game.Skinning; namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { @@ -28,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces Children = new Drawable[] { - new CircularContainer + new SkinnableDrawable("Play/osu/number-glow", name => new CircularContainer { Masking = true, Origin = Anchor.Centre, @@ -38,11 +39,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces Radius = 60, Colour = Color4.White.Opacity(0.5f), }, - Children = new[] - { - new Box() - } - }, + Child = new Box() + }, false), number = new OsuSpriteText { Text = @"1", diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/RingPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/RingPiece.cs index 2347927f2e..12cc0dc5d9 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/RingPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/RingPiece.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics.Containers; using OpenTK; using OpenTK.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Game.Skinning; namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { @@ -15,24 +16,26 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { Size = new Vector2(128); - Masking = true; - CornerRadius = Size.X / 2; - Anchor = Anchor.Centre; Origin = Anchor.Centre; - BorderThickness = 10; - BorderColour = Color4.White; - - Children = new Drawable[] + InternalChild = new SkinnableDrawable("Play/osu/hitcircleoverlay", _ => new Container { - new Box + Masking = true, + CornerRadius = Size.X / 2, + BorderThickness = 10, + BorderColour = Color4.White, + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] { - AlwaysPresent = true, - Alpha = 0, - RelativeSizeAxes = Axes.Both + new Box + { + AlwaysPresent = true, + Alpha = 0, + RelativeSizeAxes = Axes.Both + } } - }; + }); } } } diff --git a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj index 7838fb7707..04903d11bf 100644 --- a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj +++ b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj @@ -92,6 +92,7 @@ + diff --git a/osu.Game/Skinning/SkinnableDrawable.cs b/osu.Game/Skinning/SkinnableDrawable.cs new file mode 100644 index 0000000000..7310d1e476 --- /dev/null +++ b/osu.Game/Skinning/SkinnableDrawable.cs @@ -0,0 +1,58 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Skinning +{ + public class SkinnableDrawable : SkinnableDrawable + { + public SkinnableDrawable(string name, Func defaultImplementation, bool fallback = true) + : base(name, defaultImplementation, fallback) + { + RelativeSizeAxes = Axes.Both; + } + } + + public class SkinnableDrawable : CompositeDrawable + where T : Drawable + { + private Bindable skin; + protected Func CreateDefault; + + public string ComponentName { get; set; } + + public readonly bool DefaultFallback; + + public SkinnableDrawable(string name, Func defaultImplementation, bool fallback = true) + { + DefaultFallback = fallback; + ComponentName = name; + CreateDefault = defaultImplementation; + } + + [BackgroundDependencyLoader] + private void load(SkinManager skinManager) + { + skin = skinManager.CurrentSkin.GetBoundCopy(); + skin.ValueChanged += updateComponent; + skin.TriggerChange(); + } + + private void updateComponent(Skin skin) + { + var drawable = skin.GetDrawableComponent(ComponentName); + if (drawable == null && (DefaultFallback || skin.SkinInfo == SkinInfo.Default)) + drawable = CreateDefault(ComponentName); + + if (drawable != null) + InternalChild = drawable; + else + ClearInternal(); + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index dc5914a76f..f61a2a8dc6 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -860,6 +860,7 @@ + From 6ceabfe19ebed5b433cc3ec9d15b439164826ca6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 22 Feb 2018 17:34:35 +0900 Subject: [PATCH 03/11] Add basic hitsound skinning --- .../Audio/DrumSampleMapping.cs | 4 +-- osu.Game/Audio/SampleInfo.cs | 6 ++-- .../Objects/Drawables/DrawableHitObject.cs | 34 ++++++++++++------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs b/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs index 5493a5029b..85367b8bf6 100644 --- a/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs +++ b/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs @@ -29,8 +29,8 @@ namespace osu.Game.Rulesets.Taiko.Audio { mappings[s.Time] = new DrumSample { - Centre = s.GetSampleInfo().GetChannel(audio.Sample, "Taiko"), - Rim = s.GetSampleInfo(SampleInfo.HIT_CLAP).GetChannel(audio.Sample, "Taiko") + Centre = s.GetSampleInfo().GetChannel(audio.Sample.Get, "Taiko"), + Rim = s.GetSampleInfo(SampleInfo.HIT_CLAP).GetChannel(audio.Sample.Get, "Taiko") }; } } diff --git a/osu.Game/Audio/SampleInfo.cs b/osu.Game/Audio/SampleInfo.cs index e6f4a0b8d1..99d2da7ebc 100644 --- a/osu.Game/Audio/SampleInfo.cs +++ b/osu.Game/Audio/SampleInfo.cs @@ -14,16 +14,16 @@ namespace osu.Game.Audio public const string HIT_NORMAL = @"hitnormal"; public const string HIT_CLAP = @"hitclap"; - public SampleChannel GetChannel(SampleManager manager, string resourceNamespace = null) + public SampleChannel GetChannel(Func getChannel, string resourceNamespace = null) { SampleChannel channel = null; if (resourceNamespace != null) - channel = manager.Get($"Gameplay/{resourceNamespace}/{Bank}-{Name}"); + channel = getChannel($"Gameplay/{resourceNamespace}/{Bank}-{Name}"); // try without namespace as a fallback. if (channel == null) - channel = manager.Get($"Gameplay/{Bank}-{Name}"); + channel = getChannel($"Gameplay/{Bank}-{Name}"); if (channel != null) channel.Volume.Value = Volume / 100.0; diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 2db02724ed..2ecdccc31f 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -17,6 +17,7 @@ using osu.Framework.Configuration; using OpenTK; using osu.Framework.Graphics.Primitives; using osu.Game.Rulesets.Scoring; +using osu.Game.Skinning; namespace osu.Game.Rulesets.Objects.Drawables { @@ -82,8 +83,10 @@ namespace osu.Game.Rulesets.Objects.Drawables HitObject = hitObject; } + private readonly Bindable skin = new Bindable(); + [BackgroundDependencyLoader] - private void load(AudioManager audio) + private void load(AudioManager audio, SkinManager skins) { var samples = GetSamples(); if (samples.Any()) @@ -91,23 +94,30 @@ namespace osu.Game.Rulesets.Objects.Drawables if (HitObject.SampleControlPoint == null) throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)}s must always have an attached {nameof(HitObject.SampleControlPoint)}." + $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}."); - - foreach (SampleInfo s in samples) + void loadSamples(Skin skin) { - SampleInfo localSampleInfo = new SampleInfo + Samples.Clear(); + + foreach (SampleInfo s in samples) { - Bank = s.Bank ?? HitObject.SampleControlPoint.SampleBank, - Name = s.Name, - Volume = s.Volume > 0 ? s.Volume : HitObject.SampleControlPoint.SampleVolume - }; + SampleInfo localSampleInfo = new SampleInfo + { + Bank = s.Bank ?? HitObject.SampleControlPoint.SampleBank, + Name = s.Name, + Volume = s.Volume > 0 ? s.Volume : HitObject.SampleControlPoint.SampleVolume + }; - SampleChannel channel = localSampleInfo.GetChannel(audio.Sample, SampleNamespace); - if (channel == null) - continue; + SampleChannel channel = localSampleInfo.GetChannel(skin.GetSample, SampleNamespace) ?? localSampleInfo.GetChannel(audio.Sample.Get, SampleNamespace); - Samples.Add(channel); + if (channel == null) return; + + Samples.Add(channel); + } } + + skin.ValueChanged += loadSamples; + skin.BindTo(skins.CurrentSkin); } } From 92d20eea8cb5d2cc7165847ba71891579f91ffc9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 23 Feb 2018 12:35:25 +0900 Subject: [PATCH 04/11] Add missing licence header --- osu.Game/Skinning/DefaultSkin.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/osu.Game/Skinning/DefaultSkin.cs b/osu.Game/Skinning/DefaultSkin.cs index 794ed58fca..e40a43d400 100644 --- a/osu.Game/Skinning/DefaultSkin.cs +++ b/osu.Game/Skinning/DefaultSkin.cs @@ -1,4 +1,7 @@ -using osu.Framework.Audio.Sample; +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Audio.Sample; using osu.Framework.Graphics; namespace osu.Game.Skinning @@ -10,8 +13,14 @@ namespace osu.Game.Skinning { } - public override Drawable GetDrawableComponent(string componentName) => null; + public override Drawable GetDrawableComponent(string componentName) + { + return null; + } - public override SampleChannel GetSample(string sampleName) => null; + public override SampleChannel GetSample(string sampleName) + { + return null; + } } } From f81eb2de65cf6f162e69836b1a0c0ccca0584f9a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 23 Feb 2018 14:24:32 +0900 Subject: [PATCH 05/11] Remove unnecessary local store --- osu.Game/Skinning/LegacySkin.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 1c56a64048..5f34ddc2b5 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -22,9 +22,7 @@ namespace osu.Game.Skinning public LegacySkin(SkinInfo skin, IResourceStore storage, AudioManager audioManager) : base(skin) { - var audioStore = new ResourceStore(storage); - - samples = audioManager.GetSampleManager(audioStore); + samples = audioManager.GetSampleManager(storage); textures = new TextureStore(new RawTextureLoaderStore(storage)); } From ff75cf6b7596b6d5f5cd5c0ae9103a922a51cc07 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 23 Feb 2018 14:27:39 +0900 Subject: [PATCH 06/11] Remove unnecessary braces --- osu.Game/Skinning/SkinManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Skinning/SkinManager.cs b/osu.Game/Skinning/SkinManager.cs index 12e34ec0a0..7235ccc46e 100644 --- a/osu.Game/Skinning/SkinManager.cs +++ b/osu.Game/Skinning/SkinManager.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . +// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; @@ -59,7 +59,7 @@ namespace osu.Game.Skinning { this.audio = audio; - CurrentSkinInfo.ValueChanged += info => { CurrentSkin.Value = GetSkin(info); }; + CurrentSkinInfo.ValueChanged += info => CurrentSkin.Value = GetSkin(info); CurrentSkin.ValueChanged += skin => { if (skin.SkinInfo != CurrentSkinInfo.Value) From 0e20c4e6bbbe71d2582080588c0718f0532f0d12 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 23 Feb 2018 14:27:53 +0900 Subject: [PATCH 07/11] Fix typo --- osu.Game/Skinning/SkinManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Skinning/SkinManager.cs b/osu.Game/Skinning/SkinManager.cs index 7235ccc46e..88d51eca10 100644 --- a/osu.Game/Skinning/SkinManager.cs +++ b/osu.Game/Skinning/SkinManager.cs @@ -63,7 +63,7 @@ namespace osu.Game.Skinning CurrentSkin.ValueChanged += skin => { if (skin.SkinInfo != CurrentSkinInfo.Value) - throw new InvalidOperationException($"Setting {nameof(CurrentSkin)}'s value directly is not supported. Use {nameof(CurrentSkinInfo)} isntead."); + throw new InvalidOperationException($"Setting {nameof(CurrentSkin)}'s value directly is not supported. Use {nameof(CurrentSkinInfo)} instead."); }; } From a36986ef5af94df2f50ed2232e44a71484fe1165 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 23 Feb 2018 14:28:57 +0900 Subject: [PATCH 08/11] Make ComponentName readonly --- osu.Game/Skinning/SkinnableDrawable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Skinning/SkinnableDrawable.cs b/osu.Game/Skinning/SkinnableDrawable.cs index 7310d1e476..c1c78fdb05 100644 --- a/osu.Game/Skinning/SkinnableDrawable.cs +++ b/osu.Game/Skinning/SkinnableDrawable.cs @@ -24,7 +24,7 @@ namespace osu.Game.Skinning private Bindable skin; protected Func CreateDefault; - public string ComponentName { get; set; } + public readonly string ComponentName; public readonly bool DefaultFallback; From 6d4016e18bf9d1691683217975fe1c86ef579225 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 24 Feb 2018 22:41:04 +0900 Subject: [PATCH 09/11] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 16a4bef775..9a773e62eb 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 16a4bef775a49166f38faa6e952d83d8823fe3e0 +Subproject commit 9a773e62eb246206b918ba4fccf9f2507aaa4595 From 768e0a4e2a912c44d7a139ff8243a8b88435a228 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 23 Feb 2018 20:34:08 +0900 Subject: [PATCH 10/11] Add SkinnableSound class Tidy things up, move logic out of SampleInfo. --- .../Audio/DrumSampleMapping.cs | 29 ++++++-- osu.Game.Rulesets.Taiko/UI/InputDrum.cs | 7 +- osu.Game/Audio/SampleInfo.cs | 21 ++---- .../Objects/Drawables/DrawableHitObject.cs | 66 +++++++------------ osu.Game/Skinning/SkinReloadableDrawable.cs | 53 +++++++++++++++ osu.Game/Skinning/SkinnableDrawable.cs | 38 ++++------- osu.Game/Skinning/SkinnableSound.cs | 62 +++++++++++++++++ osu.Game/osu.Game.csproj | 4 +- 8 files changed, 184 insertions(+), 96 deletions(-) create mode 100644 osu.Game/Skinning/SkinReloadableDrawable.cs create mode 100644 osu.Game/Skinning/SkinnableSound.cs diff --git a/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs b/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs index 85367b8bf6..ef96e4c48a 100644 --- a/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs +++ b/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs @@ -2,10 +2,9 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; -using osu.Framework.Audio; -using osu.Framework.Audio.Sample; using osu.Game.Audio; using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Skinning; namespace osu.Game.Rulesets.Taiko.Audio { @@ -14,7 +13,9 @@ namespace osu.Game.Rulesets.Taiko.Audio private readonly ControlPointInfo controlPoints; private readonly Dictionary mappings = new Dictionary(); - public DrumSampleMapping(ControlPointInfo controlPoints, AudioManager audio) + public readonly List Drawables = new List(); + + public DrumSampleMapping(ControlPointInfo controlPoints) { this.controlPoints = controlPoints; @@ -27,20 +28,34 @@ namespace osu.Game.Rulesets.Taiko.Audio foreach (var s in samplePoints) { + var centre = s.GetSampleInfo(); + var rim = s.GetSampleInfo(SampleInfo.HIT_CLAP); + + // todo: this is ugly + centre.Namespace = "taiko"; + rim.Namespace = "taiko"; + mappings[s.Time] = new DrumSample { - Centre = s.GetSampleInfo().GetChannel(audio.Sample.Get, "Taiko"), - Rim = s.GetSampleInfo(SampleInfo.HIT_CLAP).GetChannel(audio.Sample.Get, "Taiko") + Centre = addDrawableSound(centre), + Rim = addDrawableSound(rim) }; } } + private SkinnableSound addDrawableSound(SampleInfo rim) + { + var drawable = new SkinnableSound(rim); + Drawables.Add(drawable); + return drawable; + } + public DrumSample SampleAt(double time) => mappings[controlPoints.SamplePointAt(time).Time]; public class DrumSample { - public SampleChannel Centre; - public SampleChannel Rim; + public SkinnableSound Centre; + public SkinnableSound Rim; } } } diff --git a/osu.Game.Rulesets.Taiko/UI/InputDrum.cs b/osu.Game.Rulesets.Taiko/UI/InputDrum.cs index 98f20fd558..ac4c077515 100644 --- a/osu.Game.Rulesets.Taiko/UI/InputDrum.cs +++ b/osu.Game.Rulesets.Taiko/UI/InputDrum.cs @@ -4,7 +4,6 @@ using System; using OpenTK; using osu.Framework.Allocation; -using osu.Framework.Audio; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -34,9 +33,9 @@ namespace osu.Game.Rulesets.Taiko.UI } [BackgroundDependencyLoader] - private void load(AudioManager audio) + private void load() { - var sampleMappings = new DrumSampleMapping(controlPoints, audio); + var sampleMappings = new DrumSampleMapping(controlPoints); Children = new Drawable[] { @@ -63,6 +62,8 @@ namespace osu.Game.Rulesets.Taiko.UI CentreAction = TaikoAction.RightCentre } }; + + AddRangeInternal(sampleMappings.Drawables); } /// diff --git a/osu.Game/Audio/SampleInfo.cs b/osu.Game/Audio/SampleInfo.cs index 99d2da7ebc..2014db6c61 100644 --- a/osu.Game/Audio/SampleInfo.cs +++ b/osu.Game/Audio/SampleInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.Audio.Sample; namespace osu.Game.Audio { @@ -14,22 +13,10 @@ namespace osu.Game.Audio public const string HIT_NORMAL = @"hitnormal"; public const string HIT_CLAP = @"hitclap"; - public SampleChannel GetChannel(Func getChannel, string resourceNamespace = null) - { - SampleChannel channel = null; - - if (resourceNamespace != null) - channel = getChannel($"Gameplay/{resourceNamespace}/{Bank}-{Name}"); - - // try without namespace as a fallback. - if (channel == null) - channel = getChannel($"Gameplay/{Bank}-{Name}"); - - if (channel != null) - channel.Volume.Value = Volume / 100.0; - - return channel; - } + /// + /// An optional ruleset namespace. + /// + public string Namespace; /// /// The bank to load the sample from. diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 2ecdccc31f..fcb472995a 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -3,21 +3,19 @@ using System; using System.Collections.Generic; -using osu.Framework.Allocation; -using osu.Framework.Audio; -using osu.Framework.Audio.Sample; -using osu.Game.Rulesets.Judgements; -using Container = osu.Framework.Graphics.Containers.Container; -using osu.Game.Rulesets.Objects.Types; -using OpenTK.Graphics; -using osu.Game.Audio; using System.Linq; -using osu.Game.Graphics; +using osu.Framework.Allocation; using osu.Framework.Configuration; -using OpenTK; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; +using osu.Game.Audio; +using osu.Game.Graphics; +using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Scoring; using osu.Game.Skinning; +using OpenTK; +using OpenTK.Graphics; namespace osu.Game.Rulesets.Objects.Drawables { @@ -33,8 +31,12 @@ namespace osu.Game.Rulesets.Objects.Drawables // Todo: Rulesets should be overriding the resources instead, but we need to figure out where/when to apply overrides first protected virtual string SampleNamespace => null; - protected List Samples = new List(); - protected virtual IEnumerable GetSamples() => HitObject.Samples; + protected SkinnableSound Samples; + + protected virtual IEnumerable GetSamples() + { + return HitObject.Samples; + } private List nestedHitObjects; public IReadOnlyList NestedHitObjects => nestedHitObjects; @@ -83,41 +85,23 @@ namespace osu.Game.Rulesets.Objects.Drawables HitObject = hitObject; } - private readonly Bindable skin = new Bindable(); - [BackgroundDependencyLoader] - private void load(AudioManager audio, SkinManager skins) + private void load() { - var samples = GetSamples(); + var samples = GetSamples().ToArray(); + if (samples.Any()) { if (HitObject.SampleControlPoint == null) throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)}s must always have an attached {nameof(HitObject.SampleControlPoint)}." + $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}."); - void loadSamples(Skin skin) + AddInternal(Samples = new SkinnableSound(samples.Select(s => new SampleInfo { - Samples.Clear(); - - foreach (SampleInfo s in samples) - { - SampleInfo localSampleInfo = new SampleInfo - { - Bank = s.Bank ?? HitObject.SampleControlPoint.SampleBank, - Name = s.Name, - Volume = s.Volume > 0 ? s.Volume : HitObject.SampleControlPoint.SampleVolume - }; - - - SampleChannel channel = localSampleInfo.GetChannel(skin.GetSample, SampleNamespace) ?? localSampleInfo.GetChannel(audio.Sample.Get, SampleNamespace); - - if (channel == null) return; - - Samples.Add(channel); - } - } - - skin.ValueChanged += loadSamples; - skin.BindTo(skins.CurrentSkin); + Bank = s.Bank ?? HitObject.SampleControlPoint.SampleBank, + Name = s.Name, + Volume = s.Volume > 0 ? s.Volume : HitObject.SampleControlPoint.SampleVolume, + Namespace = SampleNamespace + }).ToArray())); } } @@ -149,7 +133,7 @@ namespace osu.Game.Rulesets.Objects.Drawables /// /// Plays all the hitsounds for this . /// - public void PlaySamples() => Samples.ForEach(s => s?.Play()); + public void PlaySamples() => Samples?.Play(); protected override void Update() { @@ -231,10 +215,8 @@ namespace osu.Game.Rulesets.Objects.Drawables return false; if (NestedHitObjects != null) - { foreach (var d in NestedHitObjects) judgementOccurred |= d.UpdateJudgement(userTriggered); - } if (!ProvidesJudgement || judgementFinalized || judgementOccurred) return judgementOccurred; diff --git a/osu.Game/Skinning/SkinReloadableDrawable.cs b/osu.Game/Skinning/SkinReloadableDrawable.cs new file mode 100644 index 0000000000..1abfd8976e --- /dev/null +++ b/osu.Game/Skinning/SkinReloadableDrawable.cs @@ -0,0 +1,53 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Skinning +{ + /// + /// A drawable which has a callback when the skin changes. + /// + public abstract class SkinReloadableDrawable : CompositeDrawable + { + private Bindable skin; + + /// + /// Whether fallback to default skin should be allowed if the custom skin is missing this resource. + /// + private readonly bool allowDefaultFallback; + + /// + /// Create a new + /// + /// Whether fallback to default skin should be allowed if the custom skin is missing this resource. + protected SkinReloadableDrawable(bool fallback = true) + { + allowDefaultFallback = fallback; + } + + [BackgroundDependencyLoader] + private void load(SkinManager skinManager) + { + skin = skinManager.CurrentSkin.GetBoundCopy(); + skin.ValueChanged += skin => SkinChanged(skin, allowDefaultFallback || skin.SkinInfo == SkinInfo.Default); + } + + protected override void LoadAsyncComplete() + { + base.LoadAsyncComplete(); + skin.TriggerChange(); + } + + /// + /// Called when a change is made to the skin. + /// + /// The new skin. + /// Whether fallback to default skin should be allowed if the custom skin is missing this resource. + protected virtual void SkinChanged(Skin skin, bool allowFallback) + { + } + } +} diff --git a/osu.Game/Skinning/SkinnableDrawable.cs b/osu.Game/Skinning/SkinnableDrawable.cs index c1c78fdb05..cd669778a6 100644 --- a/osu.Game/Skinning/SkinnableDrawable.cs +++ b/osu.Game/Skinning/SkinnableDrawable.cs @@ -2,10 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; namespace osu.Game.Skinning { @@ -14,40 +11,29 @@ namespace osu.Game.Skinning public SkinnableDrawable(string name, Func defaultImplementation, bool fallback = true) : base(name, defaultImplementation, fallback) { - RelativeSizeAxes = Axes.Both; } } - public class SkinnableDrawable : CompositeDrawable + public class SkinnableDrawable : SkinReloadableDrawable where T : Drawable { - private Bindable skin; - protected Func CreateDefault; + private readonly Func createDefault; - public readonly string ComponentName; + private readonly string componentName; - public readonly bool DefaultFallback; - - public SkinnableDrawable(string name, Func defaultImplementation, bool fallback = true) + public SkinnableDrawable(string name, Func defaultImplementation, bool fallback = true) : base(fallback) { - DefaultFallback = fallback; - ComponentName = name; - CreateDefault = defaultImplementation; + componentName = name; + createDefault = defaultImplementation; + + RelativeSizeAxes = Axes.Both; } - [BackgroundDependencyLoader] - private void load(SkinManager skinManager) + protected override void SkinChanged(Skin skin, bool allowFallback) { - skin = skinManager.CurrentSkin.GetBoundCopy(); - skin.ValueChanged += updateComponent; - skin.TriggerChange(); - } - - private void updateComponent(Skin skin) - { - var drawable = skin.GetDrawableComponent(ComponentName); - if (drawable == null && (DefaultFallback || skin.SkinInfo == SkinInfo.Default)) - drawable = CreateDefault(ComponentName); + var drawable = skin.GetDrawableComponent(componentName); + if (drawable == null && allowFallback) + drawable = createDefault(componentName); if (drawable != null) InternalChild = drawable; diff --git a/osu.Game/Skinning/SkinnableSound.cs b/osu.Game/Skinning/SkinnableSound.cs new file mode 100644 index 0000000000..7cc13519da --- /dev/null +++ b/osu.Game/Skinning/SkinnableSound.cs @@ -0,0 +1,62 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Game.Audio; + +namespace osu.Game.Skinning +{ + public class SkinnableSound : SkinReloadableDrawable + { + private readonly SampleInfo[] samples; + private SampleChannel[] channels; + + private AudioManager audio; + + public SkinnableSound(params SampleInfo[] samples) + { + this.samples = samples; + } + + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + this.audio = audio; + } + + public void Play() => channels?.ForEach(c => c.Play()); + + protected override void SkinChanged(Skin skin, bool allowFallback) + { + channels = samples.Select(s => + { + var ch = loadChannel(s, skin.GetSample); + if (ch == null && allowFallback) + ch = loadChannel(s, audio.Sample.Get); + return ch; + }).ToArray(); + } + + private SampleChannel loadChannel(SampleInfo info, Func getSampleFunction) + { + SampleChannel ch = null; + + if (info.Namespace != null) + ch = getSampleFunction($"Gameplay/{info.Namespace}/{info.Bank}-{info.Name}"); + + // try without namespace as a fallback. + if (ch == null) + ch = getSampleFunction($"Gameplay/{info.Bank}-{info.Name}"); + + if (ch != null) + ch.Volume.Value = info.Volume / 100.0; + + return ch; + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 6a2ce82b23..6a06bf540b 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -1,4 +1,4 @@ - + @@ -861,6 +861,8 @@ + + From 4a52df2dd4f2e5b4b8c9efbeb6485132a380b100 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 24 Feb 2018 23:07:02 +0900 Subject: [PATCH 11/11] Apply review --- osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs | 12 ++++++------ osu.Game.Rulesets.Taiko/UI/InputDrum.cs | 2 +- .../Rulesets/Objects/Drawables/DrawableHitObject.cs | 5 +---- osu.Game/Skinning/SkinReloadableDrawable.cs | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs b/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs index ef96e4c48a..afa3d162f4 100644 --- a/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs +++ b/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs @@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Taiko.Audio private readonly ControlPointInfo controlPoints; private readonly Dictionary mappings = new Dictionary(); - public readonly List Drawables = new List(); + public readonly List Sounds = new List(); public DrumSampleMapping(ControlPointInfo controlPoints) { @@ -37,16 +37,16 @@ namespace osu.Game.Rulesets.Taiko.Audio mappings[s.Time] = new DrumSample { - Centre = addDrawableSound(centre), - Rim = addDrawableSound(rim) + Centre = addSound(centre), + Rim = addSound(rim) }; } } - private SkinnableSound addDrawableSound(SampleInfo rim) + private SkinnableSound addSound(SampleInfo sampleInfo) { - var drawable = new SkinnableSound(rim); - Drawables.Add(drawable); + var drawable = new SkinnableSound(sampleInfo); + Sounds.Add(drawable); return drawable; } diff --git a/osu.Game.Rulesets.Taiko/UI/InputDrum.cs b/osu.Game.Rulesets.Taiko/UI/InputDrum.cs index ac4c077515..b918f495fc 100644 --- a/osu.Game.Rulesets.Taiko/UI/InputDrum.cs +++ b/osu.Game.Rulesets.Taiko/UI/InputDrum.cs @@ -63,7 +63,7 @@ namespace osu.Game.Rulesets.Taiko.UI } }; - AddRangeInternal(sampleMappings.Drawables); + AddRangeInternal(sampleMappings.Sounds); } /// diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index fcb472995a..4c2683b389 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -33,10 +33,7 @@ namespace osu.Game.Rulesets.Objects.Drawables protected SkinnableSound Samples; - protected virtual IEnumerable GetSamples() - { - return HitObject.Samples; - } + protected virtual IEnumerable GetSamples() => HitObject.Samples; private List nestedHitObjects; public IReadOnlyList NestedHitObjects => nestedHitObjects; diff --git a/osu.Game/Skinning/SkinReloadableDrawable.cs b/osu.Game/Skinning/SkinReloadableDrawable.cs index 1abfd8976e..3e33f952cd 100644 --- a/osu.Game/Skinning/SkinReloadableDrawable.cs +++ b/osu.Game/Skinning/SkinReloadableDrawable.cs @@ -20,7 +20,7 @@ namespace osu.Game.Skinning private readonly bool allowDefaultFallback; /// - /// Create a new + /// Create a new /// /// Whether fallback to default skin should be allowed if the custom skin is missing this resource. protected SkinReloadableDrawable(bool fallback = true)