From bd952ce370453f7e63ae18153dc56f9098db5c7e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Mar 2018 18:20:20 +0900 Subject: [PATCH 01/11] Allow skinnable drawables to be of non-restricted size --- osu.Game/Skinning/LegacySkin.cs | 10 +++------ osu.Game/Skinning/SkinnableDrawable.cs | 29 ++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 17fe6369a7..f03d1ce632 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -32,12 +32,7 @@ namespace osu.Game.Skinning var texture = textures.Get(componentName); if (texture == null) return null; - return new Sprite - { - RelativeSizeAxes = Axes.Both, - FillMode = FillMode.Fit, - Texture = texture, - }; + return new Sprite { Texture = texture }; } public override SampleChannel GetSample(string sampleName) => samples.Get(sampleName); @@ -48,7 +43,8 @@ namespace osu.Game.Skinning private readonly IResourceStore underlyingStore; private string getPathForFile(string filename) => - skin.Files.FirstOrDefault(f => string.Equals(Path.GetFileNameWithoutExtension(f.Filename), filename.Split('/').Last(), StringComparison.InvariantCultureIgnoreCase))?.FileInfo.StoragePath; + skin.Files.FirstOrDefault(f => string.Equals(Path.GetFileNameWithoutExtension(f.Filename), filename.Split('/').Last(), StringComparison.InvariantCultureIgnoreCase))?.FileInfo + .StoragePath; public LegacySkinResourceStore(SkinInfo skin, IResourceStore underlyingStore) { diff --git a/osu.Game/Skinning/SkinnableDrawable.cs b/osu.Game/Skinning/SkinnableDrawable.cs index cd669778a6..a5f22f60a2 100644 --- a/osu.Game/Skinning/SkinnableDrawable.cs +++ b/osu.Game/Skinning/SkinnableDrawable.cs @@ -3,13 +3,14 @@ using System; using osu.Framework.Graphics; +using OpenTK; namespace osu.Game.Skinning { public class SkinnableDrawable : SkinnableDrawable { - public SkinnableDrawable(string name, Func defaultImplementation, bool fallback = true) - : base(name, defaultImplementation, fallback) + public SkinnableDrawable(string name, Func defaultImplementation, bool fallback = true, bool restrictSize = true) + : base(name, defaultImplementation, fallback, restrictSize) { } } @@ -21,10 +22,16 @@ namespace osu.Game.Skinning private readonly string componentName; - public SkinnableDrawable(string name, Func defaultImplementation, bool fallback = true) : base(fallback) + /// + /// Whether a user-skin drawable should be limited to the size of our parent. + /// + public readonly bool RestrictSize; + + public SkinnableDrawable(string name, Func defaultImplementation, bool fallback = true, bool restrictSize = true) : base(fallback) { componentName = name; createDefault = defaultImplementation; + RestrictSize = restrictSize; RelativeSizeAxes = Axes.Both; } @@ -32,11 +39,25 @@ namespace osu.Game.Skinning protected override void SkinChanged(Skin skin, bool allowFallback) { var drawable = skin.GetDrawableComponent(componentName); - if (drawable == null && allowFallback) + if (drawable != null) + { + if (RestrictSize) + { + drawable.RelativeSizeAxes = Axes.Both; + drawable.Size = Vector2.One; + drawable.FillMode = FillMode.Fit; + } + } + else if (allowFallback) drawable = createDefault(componentName); if (drawable != null) + { + drawable.Origin = Anchor.Centre; + drawable.Anchor = Anchor.Centre; + InternalChild = drawable; + } else ClearInternal(); } From 05eb6786548780dd2231f24c466ba84411de1fa2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Mar 2018 18:20:35 +0900 Subject: [PATCH 02/11] Add skin support for judgements --- .../Objects/Drawables/DrawableOsuJudgement.cs | 2 +- .../Rulesets/Judgements/DrawableJudgement.cs | 42 ++++++++++++------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuJudgement.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuJudgement.cs index 716f4b629b..6d6cae9ca5 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuJudgement.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuJudgement.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables protected override void LoadComplete() { if (Judgement.Result != HitResult.Miss) - JudgementText.TransformSpacingTo(new Vector2(14, 0), 1800, Easing.OutQuint); + JudgementText?.TransformSpacingTo(new Vector2(14, 0), 1800, Easing.OutQuint); base.LoadComplete(); } diff --git a/osu.Game/Rulesets/Judgements/DrawableJudgement.cs b/osu.Game/Rulesets/Judgements/DrawableJudgement.cs index c1bf55b214..4664517312 100644 --- a/osu.Game/Rulesets/Judgements/DrawableJudgement.cs +++ b/osu.Game/Rulesets/Judgements/DrawableJudgement.cs @@ -10,6 +10,8 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Scoring; +using osu.Game.Skinning; +using OpenTK.Graphics; namespace osu.Game.Rulesets.Judgements { @@ -18,9 +20,11 @@ namespace osu.Game.Rulesets.Judgements /// public class DrawableJudgement : Container { + private const float judgement_size = 80; + protected readonly Judgement Judgement; - protected readonly SpriteText JudgementText; + protected SpriteText JudgementText; /// /// Creates a drawable which visualises a . @@ -30,31 +34,37 @@ namespace osu.Game.Rulesets.Judgements { Judgement = judgement; - AutoSizeAxes = Axes.Both; - - Children = new[] - { - JudgementText = new OsuSpriteText - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Text = judgement.Result.GetDescription().ToUpper(), - Font = @"Venera", - Scale = new Vector2(0.85f, 1), - TextSize = 12 - } - }; + Size = new Vector2(judgement_size); } [BackgroundDependencyLoader] private void load(OsuColour colours) { + string legacyName = string.Empty; switch (Judgement.Result) { case HitResult.Miss: - Colour = colours.Red; + legacyName = "hit0"; + break; + case HitResult.Meh: + legacyName = "hit50"; + break; + case HitResult.Good: + legacyName = "hit100"; + break; + case HitResult.Great: + legacyName = "hit300"; break; } + + Child = new SkinnableDrawable($"Play/osu/{legacyName}", _ => JudgementText = new OsuSpriteText + { + Text = Judgement.Result.GetDescription().ToUpper(), + Font = @"Venera", + Colour = Judgement.Result == HitResult.Miss ? colours.Red : Color4.White, + Scale = new Vector2(0.85f, 1), + TextSize = 12 + }, restrictSize: false); } protected override void LoadComplete() From f2d7621df3a05a662819a4c83c7c5a598f6cff0f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Mar 2018 18:20:52 +0900 Subject: [PATCH 03/11] Add skin support for explode/flash layers Basically to hide them for legacy skins, though. --- .../Objects/Drawables/Pieces/ExplodePiece.cs | 14 ++++++-------- .../Objects/Drawables/Pieces/FlashPiece.cs | 12 ++++++------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ExplodePiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ExplodePiece.cs index 9be951e29c..76ed89be67 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ExplodePiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ExplodePiece.cs @@ -3,6 +3,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Skinning; using OpenTK; namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces @@ -19,15 +20,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces Blending = BlendingMode.Additive; Alpha = 0; - Children = new Drawable[] + Child = new SkinnableDrawable("Play/osu/hitcircle-explode", _ => new TrianglesPiece { - new TrianglesPiece - { - Blending = BlendingMode.Additive, - RelativeSizeAxes = Axes.Both, - Alpha = 0.2f, - } - }; + Blending = BlendingMode.Additive, + RelativeSizeAxes = Axes.Both, + Alpha = 0.2f, + }, false); } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/FlashPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/FlashPiece.cs index 56faa335b1..921d24f69d 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/FlashPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/FlashPiece.cs @@ -5,6 +5,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK; using osu.Framework.Graphics.Shapes; +using osu.Game.Skinning; namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { @@ -14,22 +15,21 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { Size = new Vector2(128); - Masking = true; - CornerRadius = Size.X / 2; - Anchor = Anchor.Centre; Origin = Anchor.Centre; Blending = BlendingMode.Additive; Alpha = 0; - Children = new Drawable[] + Child = new SkinnableDrawable("Play/osu/hitcircle-flash", name => new CircularContainer { - new Box + Masking = true, + RelativeSizeAxes = Axes.Both, + Child = new Box { RelativeSizeAxes = Axes.Both } - }; + }, false); } } } From fe3ab94afbfc84665e28fa8df731a507d6a3656c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Mar 2018 19:19:56 +0900 Subject: [PATCH 04/11] Fix mania judgement regression --- osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs b/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs index 8a03f5a785..ab3c5bcbb8 100644 --- a/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs +++ b/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs @@ -1,6 +1,7 @@ // 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.Game.Rulesets.Judgements; @@ -11,7 +12,13 @@ namespace osu.Game.Rulesets.Mania.UI public DrawableManiaJudgement(Judgement judgement) : base(judgement) { - JudgementText.TextSize = 25; + } + + [BackgroundDependencyLoader] + private void load() + { + if (JudgementText != null) + JudgementText.TextSize = 25; } protected override void LoadComplete() From 1447ca55a3a128a3adb0fee0206178893640e256 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 12 Mar 2018 11:02:02 +0900 Subject: [PATCH 05/11] Add xmldoc, make restrictSize private --- osu.Game/Skinning/SkinnableDrawable.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/osu.Game/Skinning/SkinnableDrawable.cs b/osu.Game/Skinning/SkinnableDrawable.cs index a5f22f60a2..81abc9e80c 100644 --- a/osu.Game/Skinning/SkinnableDrawable.cs +++ b/osu.Game/Skinning/SkinnableDrawable.cs @@ -22,16 +22,20 @@ namespace osu.Game.Skinning private readonly string componentName; - /// - /// Whether a user-skin drawable should be limited to the size of our parent. - /// - public readonly bool RestrictSize; + private readonly bool restrictSize; + /// + /// + /// + /// The namespace-complete resource name for this skinnable element. + /// A function to create the default skin implementation of this element. + /// Whther to fallback to the default implementation when a custom skin is specified but not implementation is present. + /// Whether a user-skin drawable should be limited to the size of our parent. public SkinnableDrawable(string name, Func defaultImplementation, bool fallback = true, bool restrictSize = true) : base(fallback) { componentName = name; createDefault = defaultImplementation; - RestrictSize = restrictSize; + this.restrictSize = restrictSize; RelativeSizeAxes = Axes.Both; } @@ -41,7 +45,7 @@ namespace osu.Game.Skinning var drawable = skin.GetDrawableComponent(componentName); if (drawable != null) { - if (RestrictSize) + if (restrictSize) { drawable.RelativeSizeAxes = Axes.Both; drawable.Size = Vector2.One; From c70be29edacbdebb10dd874d15cd6dda145ef5ca Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 12 Mar 2018 11:30:13 +0900 Subject: [PATCH 06/11] Move legacy conversion to LegacySkin --- .../Rulesets/Judgements/DrawableJudgement.cs | 19 +------------------ osu.Game/Skinning/LegacySkin.cs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/osu.Game/Rulesets/Judgements/DrawableJudgement.cs b/osu.Game/Rulesets/Judgements/DrawableJudgement.cs index 4664517312..8639812aff 100644 --- a/osu.Game/Rulesets/Judgements/DrawableJudgement.cs +++ b/osu.Game/Rulesets/Judgements/DrawableJudgement.cs @@ -40,24 +40,7 @@ namespace osu.Game.Rulesets.Judgements [BackgroundDependencyLoader] private void load(OsuColour colours) { - string legacyName = string.Empty; - switch (Judgement.Result) - { - case HitResult.Miss: - legacyName = "hit0"; - break; - case HitResult.Meh: - legacyName = "hit50"; - break; - case HitResult.Good: - legacyName = "hit100"; - break; - case HitResult.Great: - legacyName = "hit300"; - break; - } - - Child = new SkinnableDrawable($"Play/osu/{legacyName}", _ => JudgementText = new OsuSpriteText + Child = new SkinnableDrawable($"Play/{Judgement.Result}", _ => JudgementText = new OsuSpriteText { Text = Judgement.Result.GetDescription().ToUpper(), Font = @"Venera", diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index f03d1ce632..2caeed8480 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -29,6 +29,22 @@ namespace osu.Game.Skinning public override Drawable GetDrawableComponent(string componentName) { + switch (componentName) + { + case "Play/Miss": + componentName = "hit0"; + break; + case "Play/Meh": + componentName = "hit50"; + break; + case "Play/Good": + componentName = "hit100"; + break; + case "Play/Great": + componentName = "hit300"; + break; + } + var texture = textures.Get(componentName); if (texture == null) return null; From 2d9fcdcbd02c3f92c608d5f63ab0a7ab8705ff94 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 12 Mar 2018 17:18:50 +0900 Subject: [PATCH 07/11] Fix slider circle overlays moving with the endpoints --- .../Edit/Layers/Selection/Overlays/SliderCircleOverlay.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleOverlay.cs b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleOverlay.cs index 3c7f8a067b..50a325d6cc 100644 --- a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleOverlay.cs +++ b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleOverlay.cs @@ -5,6 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Graphics; using osu.Game.Rulesets.Edit.Layers.Selection; +using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using OpenTK; @@ -14,12 +15,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays public class SliderCircleOverlay : HitObjectOverlay { public SliderCircleOverlay(DrawableHitCircle sliderHead, DrawableSlider slider) - : this(sliderHead, sliderHead.Position, slider) + : this(sliderHead, Vector2.Zero, slider) { } public SliderCircleOverlay(DrawableSliderTail sliderTail, DrawableSlider slider) - : this(sliderTail, sliderTail.Position, slider) + : this(sliderTail, ((Slider)slider.HitObject).Curve.PositionAt(1), slider) { } From 3354849cc9c05eb47d58abf570935f1fbf36865a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 12 Mar 2018 22:01:18 +0900 Subject: [PATCH 08/11] Fix code formatting regression --- osu.Game/Skinning/LegacySkin.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 2caeed8480..5525cc483e 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -58,9 +58,14 @@ namespace osu.Game.Skinning private readonly SkinInfo skin; private readonly IResourceStore underlyingStore; - private string getPathForFile(string filename) => - skin.Files.FirstOrDefault(f => string.Equals(Path.GetFileNameWithoutExtension(f.Filename), filename.Split('/').Last(), StringComparison.InvariantCultureIgnoreCase))?.FileInfo - .StoragePath; + private string getPathForFile(string filename) + { + string lastPiece = filename.Split('/').Last(); + + var file = skin.Files.FirstOrDefault(f => + string.Equals(Path.GetFileNameWithoutExtension(f.Filename), lastPiece, StringComparison.InvariantCultureIgnoreCase)); + return file?.FileInfo.StoragePath; + } public LegacySkinResourceStore(SkinInfo skin, IResourceStore underlyingStore) { From 706c26c32b1f4a1912b119b7804a6f6a57b32c64 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 13 Mar 2018 09:27:28 +0900 Subject: [PATCH 09/11] Remove extra whitespace --- osu.Game/Tests/Beatmaps/TestBeatmap.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Tests/Beatmaps/TestBeatmap.cs b/osu.Game/Tests/Beatmaps/TestBeatmap.cs index 3b43459428..6d80ebffd4 100644 --- a/osu.Game/Tests/Beatmaps/TestBeatmap.cs +++ b/osu.Game/Tests/Beatmaps/TestBeatmap.cs @@ -341,9 +341,8 @@ SliderTickRate:2 226701,-100,4,2,0,10,0,0 227170,-100,4,2,0,5,0,0 - [Colours] - Combo1 : 17,254,176 +Combo1 : 17,254,176 Combo2 : 173,255,95 Combo3 : 255,88,100 Combo4 : 255,94,55 From 6ecd2afd2420cea1b11e7b704eb13a4ba68ed9d6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 13 Mar 2018 12:59:41 +0900 Subject: [PATCH 10/11] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 59004b46f2..d29c8365ba 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 59004b46f2c96ac02fec712e66f9f96fe252f2fa +Subproject commit d29c8365ba3cf7924b57cf22341f4af55658764c From e32eec9259ae7d463070e1e8da06402b50afa173 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 13 Mar 2018 15:22:46 +0900 Subject: [PATCH 11/11] No more caching --- osu.Game/Tests/Beatmaps/TestBeatmap.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/osu.Game/Tests/Beatmaps/TestBeatmap.cs b/osu.Game/Tests/Beatmaps/TestBeatmap.cs index 6d80ebffd4..7dc6079959 100644 --- a/osu.Game/Tests/Beatmaps/TestBeatmap.cs +++ b/osu.Game/Tests/Beatmaps/TestBeatmap.cs @@ -17,15 +17,11 @@ namespace osu.Game.Tests.Beatmaps BeatmapInfo.Ruleset = ruleset; } - private static Beatmap testBeatmapCache; private static Beatmap createTestBeatmap() { - if (testBeatmapCache != null) - return testBeatmapCache; - using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(test_beatmap_data))) using (var reader = new StreamReader(stream)) - return testBeatmapCache = Decoder.GetDecoder(reader).Decode(reader); + return Decoder.GetDecoder(reader).Decode(reader); } private const string test_beatmap_data =