1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 18:12:56 +08:00

Merge branch 'master' into base-editor-testcase

This commit is contained in:
Dean Herbert 2018-03-13 15:53:33 +09:00 committed by GitHub
commit b93e83e3d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 94 additions and 58 deletions

@ -1 +1 @@
Subproject commit 59004b46f2c96ac02fec712e66f9f96fe252f2fa Subproject commit d29c8365ba3cf7924b57cf22341f4af55658764c

View File

@ -1,6 +1,7 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
@ -12,7 +13,13 @@ namespace osu.Game.Rulesets.Mania.UI
public DrawableManiaJudgement(Judgement judgement, DrawableHitObject judgedObject) public DrawableManiaJudgement(Judgement judgement, DrawableHitObject judgedObject)
: base(judgement, judgedObject) : base(judgement, judgedObject)
{ {
JudgementText.TextSize = 25; }
[BackgroundDependencyLoader]
private void load()
{
if (JudgementText != null)
JudgementText.TextSize = 25;
} }
protected override void LoadComplete() protected override void LoadComplete()

View File

@ -5,6 +5,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Edit.Layers.Selection; 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;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using OpenTK; using OpenTK;
@ -14,12 +15,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays
public class SliderCircleOverlay : HitObjectOverlay public class SliderCircleOverlay : HitObjectOverlay
{ {
public SliderCircleOverlay(DrawableHitCircle sliderHead, DrawableSlider slider) public SliderCircleOverlay(DrawableHitCircle sliderHead, DrawableSlider slider)
: this(sliderHead, sliderHead.Position, slider) : this(sliderHead, Vector2.Zero, slider)
{ {
} }
public SliderCircleOverlay(DrawableSliderTail sliderTail, DrawableSlider slider) public SliderCircleOverlay(DrawableSliderTail sliderTail, DrawableSlider slider)
: this(sliderTail, sliderTail.Position, slider) : this(sliderTail, ((Slider)slider.HitObject).Curve.PositionAt(1), slider)
{ {
} }

View File

@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected override void LoadComplete() protected override void LoadComplete()
{ {
if (Judgement.Result != HitResult.Miss) 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(); base.LoadComplete();
} }

View File

@ -3,6 +3,7 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Skinning;
using OpenTK; using OpenTK;
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
@ -19,15 +20,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
Blending = BlendingMode.Additive; Blending = BlendingMode.Additive;
Alpha = 0; Alpha = 0;
Children = new Drawable[] Child = new SkinnableDrawable("Play/osu/hitcircle-explode", _ => new TrianglesPiece
{ {
new TrianglesPiece Blending = BlendingMode.Additive,
{ RelativeSizeAxes = Axes.Both,
Blending = BlendingMode.Additive, Alpha = 0.2f,
RelativeSizeAxes = Axes.Both, }, false);
Alpha = 0.2f,
}
};
} }
} }
} }

View File

@ -5,6 +5,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using OpenTK; using OpenTK;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{ {
@ -14,22 +15,21 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{ {
Size = new Vector2(128); Size = new Vector2(128);
Masking = true;
CornerRadius = Size.X / 2;
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
Origin = Anchor.Centre; Origin = Anchor.Centre;
Blending = BlendingMode.Additive; Blending = BlendingMode.Additive;
Alpha = 0; 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 RelativeSizeAxes = Axes.Both
} }
}; }, false);
} }
} }
} }

View File

@ -11,6 +11,8 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning;
using OpenTK.Graphics;
namespace osu.Game.Rulesets.Judgements namespace osu.Game.Rulesets.Judgements
{ {
@ -19,11 +21,13 @@ namespace osu.Game.Rulesets.Judgements
/// </summary> /// </summary>
public class DrawableJudgement : Container public class DrawableJudgement : Container
{ {
private const float judgement_size = 80;
protected readonly Judgement Judgement; protected readonly Judgement Judgement;
public readonly DrawableHitObject JudgedObject; public readonly DrawableHitObject JudgedObject;
protected readonly SpriteText JudgementText; protected SpriteText JudgementText;
/// <summary> /// <summary>
/// Creates a drawable which visualises a <see cref="Judgements.Judgement"/>. /// Creates a drawable which visualises a <see cref="Judgements.Judgement"/>.
@ -34,31 +38,20 @@ namespace osu.Game.Rulesets.Judgements
Judgement = judgement; Judgement = judgement;
JudgedObject = judgedObject; JudgedObject = judgedObject;
AutoSizeAxes = Axes.Both; Size = new Vector2(judgement_size);
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
}
};
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
switch (Judgement.Result) Child = new SkinnableDrawable($"Play/{Judgement.Result}", _ => JudgementText = new OsuSpriteText
{ {
case HitResult.Miss: Text = Judgement.Result.GetDescription().ToUpper(),
Colour = colours.Red; Font = @"Venera",
break; Colour = Judgement.Result == HitResult.Miss ? colours.Red : Color4.White,
} Scale = new Vector2(0.85f, 1),
TextSize = 12
}, restrictSize: false);
} }
protected override void LoadComplete() protected override void LoadComplete()

View File

@ -29,15 +29,26 @@ namespace osu.Game.Skinning
public override Drawable GetDrawableComponent(string componentName) 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); var texture = textures.Get(componentName);
if (texture == null) return null; if (texture == null) return null;
return new Sprite return new Sprite { Texture = texture };
{
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
Texture = texture,
};
} }
public override SampleChannel GetSample(string sampleName) => samples.Get(sampleName); public override SampleChannel GetSample(string sampleName) => samples.Get(sampleName);
@ -47,8 +58,14 @@ namespace osu.Game.Skinning
private readonly SkinInfo skin; private readonly SkinInfo skin;
private readonly IResourceStore<byte[]> underlyingStore; private readonly IResourceStore<byte[]> underlyingStore;
private string getPathForFile(string filename) => private string getPathForFile(string filename)
skin.Files.FirstOrDefault(f => string.Equals(Path.GetFileNameWithoutExtension(f.Filename), filename.Split('/').Last(), StringComparison.InvariantCultureIgnoreCase))?.FileInfo.StoragePath; {
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<byte[]> underlyingStore) public LegacySkinResourceStore(SkinInfo skin, IResourceStore<byte[]> underlyingStore)
{ {

View File

@ -3,13 +3,14 @@
using System; using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using OpenTK;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
public class SkinnableDrawable : SkinnableDrawable<Drawable> public class SkinnableDrawable : SkinnableDrawable<Drawable>
{ {
public SkinnableDrawable(string name, Func<string, Drawable> defaultImplementation, bool fallback = true) public SkinnableDrawable(string name, Func<string, Drawable> defaultImplementation, bool fallback = true, bool restrictSize = true)
: base(name, defaultImplementation, fallback) : base(name, defaultImplementation, fallback, restrictSize)
{ {
} }
} }
@ -21,10 +22,20 @@ namespace osu.Game.Skinning
private readonly string componentName; private readonly string componentName;
public SkinnableDrawable(string name, Func<string, T> defaultImplementation, bool fallback = true) : base(fallback) private readonly bool restrictSize;
/// <summary>
///
/// </summary>
/// <param name="name">The namespace-complete resource name for this skinnable element.</param>
/// <param name="defaultImplementation">A function to create the default skin implementation of this element.</param>
/// <param name="fallback">Whther to fallback to the default implementation when a custom skin is specified but not implementation is present.</param>
/// <param name="restrictSize">Whether a user-skin drawable should be limited to the size of our parent.</param>
public SkinnableDrawable(string name, Func<string, T> defaultImplementation, bool fallback = true, bool restrictSize = true) : base(fallback)
{ {
componentName = name; componentName = name;
createDefault = defaultImplementation; createDefault = defaultImplementation;
this.restrictSize = restrictSize;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
} }
@ -32,11 +43,25 @@ namespace osu.Game.Skinning
protected override void SkinChanged(Skin skin, bool allowFallback) protected override void SkinChanged(Skin skin, bool allowFallback)
{ {
var drawable = skin.GetDrawableComponent(componentName); 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); drawable = createDefault(componentName);
if (drawable != null) if (drawable != null)
{
drawable.Origin = Anchor.Centre;
drawable.Anchor = Anchor.Centre;
InternalChild = drawable; InternalChild = drawable;
}
else else
ClearInternal(); ClearInternal();
} }

View File

@ -17,15 +17,11 @@ namespace osu.Game.Tests.Beatmaps
BeatmapInfo.Ruleset = ruleset; BeatmapInfo.Ruleset = ruleset;
} }
private static Beatmap testBeatmapCache;
private static Beatmap createTestBeatmap() private static Beatmap createTestBeatmap()
{ {
if (testBeatmapCache != null)
return testBeatmapCache;
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(test_beatmap_data))) using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(test_beatmap_data)))
using (var reader = new StreamReader(stream)) using (var reader = new StreamReader(stream))
return testBeatmapCache = Decoder.GetDecoder<Beatmap>(reader).Decode(reader); return Decoder.GetDecoder<Beatmap>(reader).Decode(reader);
} }
private const string test_beatmap_data = private const string test_beatmap_data =
@ -341,9 +337,8 @@ SliderTickRate:2
226701,-100,4,2,0,10,0,0 226701,-100,4,2,0,10,0,0
227170,-100,4,2,0,5,0,0 227170,-100,4,2,0,5,0,0
[Colours] [Colours]
Combo1 : 17,254,176 Combo1 : 17,254,176
Combo2 : 173,255,95 Combo2 : 173,255,95
Combo3 : 255,88,100 Combo3 : 255,88,100
Combo4 : 255,94,55 Combo4 : 255,94,55