From 956a7288fb27aa524a1ea3e8640bbe328f4c887b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 15:50:42 +0900 Subject: [PATCH] Add basic DrawableNote. --- .../Tests/TestCaseManiaHitObjects.cs | 40 ++++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + .../Objects/Drawable/DrawableNote.cs | 36 ----------- .../Drawables/DrawableManiaHitObject.cs | 52 +++++++++++++++ .../Objects/Drawables/DrawableNote.cs | 27 ++++++++ .../Objects/Drawables/Pieces/NotePiece.cs | 64 +++++++++++++++++++ .../osu.Game.Rulesets.Mania.csproj | 4 +- .../Objects/Drawables/DrawableHitObject.cs | 2 +- 8 files changed, 188 insertions(+), 38 deletions(-) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs delete mode 100644 osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs new file mode 100644 index 0000000000..b2baf26228 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -0,0 +1,40 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Testing; +using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Mania.Objects.Drawables; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseManiaHitObjects : TestCase + { + public override void Reset() + { + base.Reset(); + + Add(new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Y, + Width = 50, + Children = new[] + { + new DrawableNote(new Note()) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre + } + } + }); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 135e4596c7..4312ac4d3b 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -190,6 +190,7 @@ + diff --git a/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs deleted file mode 100644 index 72d1e5314b..0000000000 --- a/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; -using osu.Framework.Graphics.Transforms; -using osu.Framework.Graphics; -using OpenTK; - -namespace osu.Game.Rulesets.Mania.Objects.Drawable -{ - public class DrawableNote : Sprite - { - private readonly ManiaHitObject note; - - public DrawableNote(ManiaHitObject note) - { - this.note = note; - Origin = Anchor.Centre; - Scale = new Vector2(0.1f); - } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - Texture = textures.Get(@"Menu/logo"); - - const double duration = 0; - - Transforms.Add(new TransformPositionY { StartTime = note.StartTime - 200, EndTime = note.StartTime, StartValue = -0.1f, EndValue = 0.9f }); - Transforms.Add(new TransformAlpha { StartTime = note.StartTime + duration + 200, EndTime = note.StartTime + duration + 400, StartValue = 1, EndValue = 0 }); - Expire(true); - } - } -} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs new file mode 100644 index 0000000000..ebf99de72b --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -0,0 +1,52 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Mania.Judgements; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public abstract class DrawableManiaHitObject : DrawableHitObject + where TObject : ManiaHitObject + { + public override Color4 AccentColour + { + get { return base.AccentColour; } + set + { + base.AccentColour = value; + UpdateAccent(); + } + } + + public new TObject HitObject; + + protected override Container Content => noteFlow; + private FlowContainer noteFlow; + + public DrawableManiaHitObject(TObject hitObject) + : base(hitObject) + { + HitObject = hitObject; + + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + AddInternal(noteFlow = new FillFlowContainer + { + Name = "Main container", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y + }); + } + + protected override ManiaJudgement CreateJudgement() => new ManiaJudgement(); + + protected virtual void UpdateAccent() { } + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs new file mode 100644 index 0000000000..d9603fb8ea --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public class DrawableNote : DrawableManiaHitObject + { + private NotePiece headPiece; + + public DrawableNote(Note hitObject) + : base(hitObject) + { + Add(new NotePiece()); + } + + protected override void UpdateState(ArmedState state) + { + } + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs new file mode 100644 index 0000000000..e456dc3363 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -0,0 +1,64 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces +{ + internal class NotePiece : Container, IHasAccentColour + { + private const float head_height = 10; + private const float head_colour_height = 6; + + private Box colouredBox; + + public NotePiece() + { + RelativeSizeAxes = Axes.X; + Height = head_height; + + Masking = true; + + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both + }, + colouredBox = new Box + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.X, + Height = head_colour_height, + Alpha = 0.5f + } + }; + } + + private Color4 accentColour; + public Color4 AccentColour + { + get { return accentColour; } + set + { + if (accentColour == value) + return; + accentColour = value; + + colouredBox.Colour = AccentColour; + + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 5, + Colour = AccentColour + }; + } + } + } +} diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 46a006b09c..32925dcc45 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -51,9 +51,11 @@ + + + - diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index f9b2cd5966..21eca346c4 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -88,7 +88,7 @@ namespace osu.Game.Rulesets.Objects.Drawables /// /// The colour used for various elements of this DrawableHitObject. /// - public Color4 AccentColour { get; protected set; } + public virtual Color4 AccentColour { get; set; } protected DrawableHitObject(TObject hitObject) {