From 29d15c3ab8e6cc8f9e35049a1db16829dbe02a72 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 6 Dec 2016 16:58:12 +0900 Subject: [PATCH 01/13] Fix incorrect snaking on non-repeat sliders. --- .../Objects/Drawables/DrawableSlider.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs index cd907fc001..3c49f5b2cd 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs @@ -93,26 +93,24 @@ namespace osu.Game.Modes.Osu.Objects.Drawables private void updateBody(int repeat, double progress) { - double drawStartProgress = 0; - double drawEndProgress = MathHelper.Clamp((Time.Current - slider.StartTime + TIME_PREEMPT) / TIME_FADEIN, 0, 1); + double start = 0; + double end = snakingIn ? MathHelper.Clamp((Time.Current - (slider.StartTime - TIME_PREEMPT)) / TIME_FADEIN, 0, 1) : 1; if (repeat >= slider.RepeatCount - 1) { if (Math.Min(repeat, slider.RepeatCount - 1) % 2 == 1) { - drawStartProgress = 0; - drawEndProgress = progress; + start = 0; + end = snakingOut ? progress : 1; } else { - drawStartProgress = progress; - drawEndProgress = 1; + start = snakingOut ? progress : 0; + end = 1; } } - body.SetRange( - snakingOut ? drawStartProgress : 0, - snakingIn ? drawEndProgress : 1); + body.SetRange(start, end); } protected override void Update() From 421dd19aafaafc9c121ed23a6e98947651987109 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 6 Dec 2016 18:26:21 +0900 Subject: [PATCH 02/13] Move initial state updates to DrawableHitObject. --- osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs | 8 -------- osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs | 2 -- osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs | 3 +++ 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs index 94e9a41c5a..c9d2901930 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -64,14 +64,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables Size = circle.DrawSize; } - protected override void LoadComplete() - { - base.LoadComplete(); - - //force application of the state that was set before we loaded. - UpdateState(State); - } - double hit50 = 150; double hit100 = 80; double hit300 = 30; diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs index 3c49f5b2cd..f41b88b21f 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs @@ -68,8 +68,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { base.LoadComplete(); - //force application of the state that was set before we loaded. - UpdateState(State); body.PathWidth = 32; } diff --git a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs index ed57f06e51..352615eeab 100644 --- a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs @@ -48,6 +48,9 @@ namespace osu.Game.Modes.Objects.Drawables base.LoadComplete(); Judgement = CreateJudgementInfo(); + + //force application of the state that was set before we loaded. + UpdateState(State); } /// From 4042a9e71edf1bf93c12fdc3c1b9d58ac2ace423 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 6 Dec 2016 18:54:32 +0900 Subject: [PATCH 03/13] Add preliminary (correctly) textured sliders; split out components into their own files. --- .../Objects/Drawables/DrawableOsuHitObject.cs | 11 +- .../Objects/Drawables/DrawableSlider.cs | 274 ++---------------- .../Objects/Drawables/Pieces/SliderBall.cs | 107 +++++++ .../Objects/Drawables/Pieces/SliderBody.cs | 204 +++++++++++++ osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj | 2 + 5 files changed, 347 insertions(+), 251 deletions(-) create mode 100644 osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBall.cs create mode 100644 osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableOsuHitObject.cs index 80e1f2bb7f..dca9ac9b28 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -1,4 +1,7 @@ -using System; +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; @@ -11,9 +14,9 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { public class DrawableOsuHitObject : DrawableHitObject { - protected const float TIME_PREEMPT = 600; - protected const float TIME_FADEIN = 400; - protected const float TIME_FADEOUT = 500; + public const float TIME_PREEMPT = 600; + public const float TIME_FADEIN = 400; + public const float TIME_FADEOUT = 500; public DrawableOsuHitObject(OsuHitObject hitObject) : base(hitObject) diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs index f41b88b21f..e93ebba366 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs @@ -1,21 +1,11 @@ -// Copyright (c) 2007-2016 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Game.Modes.Objects.Drawables; +using osu.Game.Modes.Osu.Objects.Drawables.Pieces; using OpenTK; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Transformations; -using OpenTK.Graphics; -using osu.Framework.Input; -using OpenTK.Graphics.ES30; -using osu.Framework.Allocation; -using osu.Framework.Graphics.Textures; -using osu.Game.Configuration; -using osu.Framework.Configuration; -using System; namespace osu.Game.Modes.Osu.Objects.Drawables { @@ -24,11 +14,14 @@ namespace osu.Game.Modes.Osu.Objects.Drawables private Slider slider; private DrawableHitCircle startCircle; - private Container ball; - private Body body; + + private List components = new List(); public DrawableSlider(Slider s) : base(s) { + SliderBody body; + SliderBall ball; + slider = s; Origin = Anchor.TopLeft; @@ -37,11 +30,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables Children = new Drawable[] { - body = new Body(s) + body = new SliderBody(s) { Position = s.Position, + PathWidth = 36, }, - ball = new Ball(), + ball = new SliderBall(slider), startCircle = new DrawableHitCircle(new HitCircle { StartTime = s.StartTime, @@ -52,75 +46,24 @@ namespace osu.Game.Modes.Osu.Objects.Drawables Depth = -1 //override time-based depth. }, }; - } - private Bindable snakingIn; - private Bindable snakingOut; - - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - snakingIn = config.GetBindable(OsuConfig.SnakingInSliders); - snakingOut = config.GetBindable(OsuConfig.SnakingOutSliders); - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - - body.PathWidth = 32; - } - - private void computeProgress(out int repeat, out double progress) - { - progress = MathHelper.Clamp((Time.Current - slider.StartTime) / slider.Duration, 0, 1); - - repeat = (int)(progress * slider.RepeatCount); - progress = (progress * slider.RepeatCount) % 1; - - if (repeat % 2 == 1) - progress = 1 - progress; - } - - private void updateBall(double progress) - { - ball.Alpha = Time.Current >= slider.StartTime && Time.Current <= slider.EndTime ? 1 : 0; - ball.Position = slider.Curve.PositionAt(progress); - } - - private void updateBody(int repeat, double progress) - { - double start = 0; - double end = snakingIn ? MathHelper.Clamp((Time.Current - (slider.StartTime - TIME_PREEMPT)) / TIME_FADEIN, 0, 1) : 1; - - if (repeat >= slider.RepeatCount - 1) - { - if (Math.Min(repeat, slider.RepeatCount - 1) % 2 == 1) - { - start = 0; - end = snakingOut ? progress : 1; - } - else - { - start = snakingOut ? progress : 0; - end = 1; - } - } - - body.SetRange(start, end); + components.Add(body); + components.Add(ball); } protected override void Update() { base.Update(); - double progress; - int repeat; - computeProgress(out repeat, out progress); + double progress = MathHelper.Clamp((Time.Current - slider.StartTime) / slider.Duration, 0, 1); - updateBall(progress); - updateBody(repeat, progress); + int repeat = (int)(progress * slider.RepeatCount); + progress = (progress * slider.RepeatCount) % 1; + + if (repeat % 2 == 1) + progress = 1 - progress; + + components.ForEach(c => c.UpdateProgress(progress, repeat)); } protected override void CheckJudgement(bool userTriggered) @@ -142,173 +85,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables Delay(HitObject.Duration); FadeOut(300); } - - private class Ball : Container - { - private Box follow; - - public Ball() - { - Masking = true; - AutoSizeAxes = Axes.Both; - BlendingMode = BlendingMode.Additive; - Origin = Anchor.Centre; - - Children = new Drawable[] - { - follow = new Box - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Colour = Color4.Orange, - Width = 64, - Height = 64, - }, - new Container - { - Masking = true, - AutoSizeAxes = Axes.Both, - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Colour = Color4.Cyan, - CornerRadius = 32, - Children = new[] - { - new Box - { - - Width = 64, - Height = 64, - }, - } - } - - }; - } - - private InputState lastState; - - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) - { - lastState = state; - return base.OnMouseDown(state, args); - } - - protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) - { - lastState = state; - return base.OnMouseUp(state, args); - } - - protected override bool OnMouseMove(InputState state) - { - lastState = state; - return base.OnMouseMove(state); - } - - bool tracking; - protected bool Tracking - { - get { return tracking; } - set - { - if (value == tracking) return; - - tracking = value; - - follow.ScaleTo(tracking ? 2.4f : 1, 140, EasingTypes.Out); - follow.FadeTo(tracking ? 0.8f : 0, 140, EasingTypes.Out); - } - } - - protected override void Update() - { - base.Update(); - - CornerRadius = DrawWidth / 2; - Tracking = lastState != null && Contains(lastState.Mouse.NativeState.Position) && lastState.Mouse.HasMainButtonPressed; - } - } - - private class Body : Container - { - private Path path; - private BufferedContainer container; - - public float PathWidth - { - get { return path.PathWidth; } - set { path.PathWidth = value; } - } - - private double? drawnProgressStart; - private double? drawnProgressEnd; - - private Slider slider; - public Body(Slider s) - { - slider = s; - - Children = new Drawable[] - { - container = new BufferedContainer - { - CacheDrawnFrameBuffer = true, - Children = new Drawable[] - { - path = new Path - { - Colour = s.Colour, - BlendingMode = BlendingMode.None, - }, - } - } - }; - - container.Attach(RenderbufferInternalFormat.DepthComponent16); - } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - // Surprisingly, this looks somewhat okay and works well as a test for self-overlaps. - // TODO: Don't do this. - path.Texture = textures.Get(@"Menu/logo"); - } - - public void SetRange(double p0, double p1) - { - if (p0 > p1) - MathHelper.Swap(ref p0, ref p1); - - if (updateSnaking(p0, p1)) - { - // Autosizing does not give us the desired behaviour here. - // We want the container to have the same size as the slider, - // and to be positioned such that the slider head is at (0,0). - container.Size = path.Size; - container.Position = -path.PositionInBoundingBox(slider.Curve.PositionAt(0) - currentCurve[0]); - - container.ForceRedraw(); - } - } - - private List currentCurve = new List(); - private bool updateSnaking(double p0, double p1) - { - if (drawnProgressStart == p0 && drawnProgressEnd == p1) return false; - - drawnProgressStart = p0; - drawnProgressEnd = p1; - - slider.Curve.GetPathToProgress(currentCurve, p0, p1); - - path.ClearVertices(); - foreach (Vector2 p in currentCurve) - path.AddVertex(p - currentCurve[0]); - - return true; - } - } } -} + + internal interface ISliderProgress + { + void UpdateProgress(double progress, int repeat); + } +} \ No newline at end of file diff --git a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBall.cs b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBall.cs new file mode 100644 index 0000000000..f7765a5057 --- /dev/null +++ b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBall.cs @@ -0,0 +1,107 @@ +//Copyright (c) 2007-2016 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.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; +using osu.Framework.Input; +using OpenTK.Graphics; + +namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces +{ + public class SliderBall : Container, ISliderProgress + { + private readonly Slider slider; + private Box follow; + + public SliderBall(Slider slider) + { + this.slider = slider; + Masking = true; + AutoSizeAxes = Axes.Both; + BlendingMode = BlendingMode.Additive; + Origin = Anchor.Centre; + + Children = new Drawable[] + { + follow = new Box + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Colour = Color4.Orange, + Width = 64, + Height = 64, + }, + new Container + { + Masking = true, + AutoSizeAxes = Axes.Both, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Colour = Color4.Cyan, + CornerRadius = 32, + Children = new[] + { + new Box + { + + Width = 64, + Height = 64, + }, + } + } + + }; + } + + private InputState lastState; + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + lastState = state; + return base.OnMouseDown(state, args); + } + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + lastState = state; + return base.OnMouseUp(state, args); + } + + protected override bool OnMouseMove(InputState state) + { + lastState = state; + return base.OnMouseMove(state); + } + + bool tracking; + protected bool Tracking + { + get { return tracking; } + set + { + if (value == tracking) return; + + tracking = value; + + follow.ScaleTo(tracking ? 2.4f : 1, 140, EasingTypes.Out); + follow.FadeTo(tracking ? 0.8f : 0, 140, EasingTypes.Out); + } + } + + protected override void Update() + { + base.Update(); + + CornerRadius = DrawWidth / 2; + Tracking = lastState != null && Contains(lastState.Mouse.NativeState.Position) && lastState.Mouse.HasMainButtonPressed; + } + + public void UpdateProgress(double progress, int repeat) + { + Alpha = Time.Current >= slider.StartTime && Time.Current <= slider.EndTime ? 1 : 0; + Position = slider.Curve.PositionAt(progress); + } + } +} \ No newline at end of file diff --git a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs new file mode 100644 index 0000000000..354bf80619 --- /dev/null +++ b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs @@ -0,0 +1,204 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Game.Configuration; +using OpenTK; +using OpenTK.Graphics; +using OpenTK.Graphics.ES30; + +namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces +{ + public class SliderBody : Container, ISliderProgress + { + private Path path; + private BodyTexture pathTexture; + private BufferedContainer container; + + public float PathWidth + { + get { return path.PathWidth; } + set + { + path.PathWidth = value; + pathTexture.Size = new Vector2(value, 1); + } + } + + private double? drawnProgressStart; + private double? drawnProgressEnd; + + private Slider slider; + public SliderBody(Slider s) + { + slider = s; + + Children = new Drawable[] + { + pathTexture = new BodyTexture + { + MainColour = s.Colour + }, + container = new BufferedContainer + { + CacheDrawnFrameBuffer = true, + Children = new Drawable[] + { + path = new Path + { + BlendingMode = BlendingMode.None, + }, + } + }, + + }; + + container.Attach(RenderbufferInternalFormat.DepthComponent16); + } + + public void SetRange(double p0, double p1) + { + if (p0 > p1) + MathHelper.Swap(ref p0, ref p1); + + if (updateSnaking(p0, p1)) + { + // Autosizing does not give us the desired behaviour here. + // We want the container to have the same size as the slider, + // and to be positioned such that the slider head is at (0,0). + container.Size = path.Size; + container.Position = -path.PositionInBoundingBox(slider.Curve.PositionAt(0) - currentCurve[0]); + + container.ForceRedraw(); + } + } + + private Bindable snakingIn; + private Bindable snakingOut; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + snakingIn = config.GetBindable(OsuConfig.SnakingInSliders); + snakingOut = config.GetBindable(OsuConfig.SnakingOutSliders); + } + + private List currentCurve = new List(); + private bool updateSnaking(double p0, double p1) + { + if (drawnProgressStart == p0 && drawnProgressEnd == p1) return false; + + drawnProgressStart = p0; + drawnProgressEnd = p1; + + slider.Curve.GetPathToProgress(currentCurve, p0, p1); + + path.ClearVertices(); + foreach (Vector2 p in currentCurve) + path.AddVertex(p - currentCurve[0]); + + return true; + } + + protected override void Update() + { + base.Update(); + + var texture = pathTexture.Texture; + if (texture != null) + { + path.Texture = texture; + pathTexture.Alpha = 0; + } + } + + public void UpdateProgress(double progress, int repeat) + { + double start = 0; + double end = snakingIn ? MathHelper.Clamp((Time.Current - (slider.StartTime - DrawableOsuHitObject.TIME_PREEMPT)) / DrawableOsuHitObject.TIME_FADEIN, 0, 1) : 1; + + if (repeat >= slider.RepeatCount - 1) + { + if (Math.Min(repeat, slider.RepeatCount - 1) % 2 == 1) + { + start = 0; + end = snakingOut ? progress : 1; + } + else + { + start = snakingOut ? progress : 0; + } + } + + SetRange(start, end); + } + + public class BodyTexture : BufferedContainer + { + private Box gradientPortion; + private BufferedContainerDrawNode lastNode; + public Texture Texture => lastNode?.FrameBuffers[0].Texture != null ? new Texture(lastNode.FrameBuffers[0].Texture) : null; + + protected override void ApplyDrawNode(DrawNode node) + { + base.ApplyDrawNode(node); + lastNode = node as BufferedContainerDrawNode; + } + + public Color4 MainColour + { + set + { + gradientPortion.ColourInfo = ColourInfo.GradientHorizontal( + value, + new Color4(value.R, value.G, value.B, value.A * 0.4f) + ); + } + } + + public BodyTexture() + { + Children = new[] + { + new FlowContainer + { + RelativeSizeAxes = Axes.Both, + Direction = FlowDirection.HorizontalOnly, + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + ColourInfo = ColourInfo.GradientHorizontal( + new Color4(255, 255, 255, 0), + Color4.White + ), + Size = new Vector2(0.02f, 1), + }, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White, + Size = new Vector2(0.13f, 1), + }, + gradientPortion = new Box + { + RelativeSizeAxes = Axes.Both, + Size = new Vector2(0.85f, 1), + }, + }, + } + }; + } + } + } +} \ No newline at end of file diff --git a/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj index ba6e714e0a..1f53c706cc 100644 --- a/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj @@ -53,6 +53,8 @@ + + From ae72f91975aa946616368a4d58eb8c9c9f543105 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 6 Dec 2016 21:14:38 +0900 Subject: [PATCH 04/13] Reshuffle hit explosions to be on their own layer. Style misses better. --- .../Objects/Drawables/DrawableHitCircle.cs | 11 ----- .../Objects/Drawables/DrawableSlider.cs | 2 +- .../Objects/Drawables/HitExplosion.cs | 42 ++++++++++++++++--- osu.Game.Mode.Osu/Objects/OsuHitObject.cs | 2 + osu.Game.Mode.Osu/Objects/Slider.cs | 3 ++ osu.Game.Mode.Osu/UI/OsuHitRenderer.cs | 1 - osu.Game.Mode.Osu/UI/OsuPlayfield.cs | 20 +++++++-- osu.Game/Modes/UI/Playfield.cs | 15 ++++++- 8 files changed, 72 insertions(+), 24 deletions(-) diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs index c9d2901930..b916a7bc74 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -22,7 +22,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables private ExplodePiece explode; private NumberPiece number; private GlowPiece glow; - private HitExplosion explosion; public DrawableHitCircle(OsuHitObject h) : base(h) { @@ -130,9 +129,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables case ArmedState.Idle: Delay(osuObject.Duration + TIME_PREEMPT); FadeOut(TIME_FADEOUT); - - explosion?.Expire(); - explosion = null; break; case ArmedState.Miss: ring.FadeOut(); @@ -140,11 +136,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables number.FadeOut(); glow.FadeOut(); - explosion?.Expire(); - explosion = null; - - Schedule(() => Add(explosion = new HitExplosion((OsuJudgementInfo)Judgement))); - FadeOut(800); break; case ArmedState.Hit: @@ -156,8 +147,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables explode.FadeIn(flash_in); - Schedule(() => Add(explosion = new HitExplosion((OsuJudgementInfo)Judgement))); - Delay(flash_in, true); //after the flash, we can hide some elements that were behind it diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs index e93ebba366..34318d3cec 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs @@ -83,7 +83,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables base.UpdateState(state); Delay(HitObject.Duration); - FadeOut(300); + FadeOut(100); } } diff --git a/osu.Game.Mode.Osu/Objects/Drawables/HitExplosion.cs b/osu.Game.Mode.Osu/Objects/Drawables/HitExplosion.cs index 43a8aa1f92..a288e93068 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/HitExplosion.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/HitExplosion.cs @@ -5,22 +5,25 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Game.Modes.Objects.Drawables; using OpenTK; +using OpenTK.Graphics; namespace osu.Game.Modes.Osu.Objects.Drawables { public class HitExplosion : FlowContainer { + private readonly OsuJudgementInfo judgement; private SpriteText line1; private SpriteText line2; - public HitExplosion(OsuJudgementInfo judgement) + public HitExplosion(OsuJudgementInfo judgement, OsuHitObject h = null) { + this.judgement = judgement; AutoSizeAxes = Axes.Both; - Anchor = Anchor.Centre; Origin = Anchor.Centre; Direction = FlowDirection.VerticalOnly; Spacing = new Vector2(0, 2); + Position = (h?.EndPosition ?? Vector2.Zero) + judgement.PositionOffset; Children = new Drawable[] { @@ -30,13 +33,13 @@ namespace osu.Game.Modes.Osu.Objects.Drawables Origin = Anchor.TopCentre, Text = judgement.Score.GetDescription(), Font = @"Venera", - TextSize = 20, + TextSize = 16, }, line2 = new SpriteText { Text = judgement.Combo.GetDescription(), Font = @"Venera", - TextSize = 14, + TextSize = 11, } }; } @@ -44,8 +47,35 @@ namespace osu.Game.Modes.Osu.Objects.Drawables protected override void LoadComplete() { base.LoadComplete(); - line1.TransformSpacingTo(new Vector2(14, 0), 1800, EasingTypes.OutQuint); - line2.TransformSpacingTo(new Vector2(14, 0), 1800, EasingTypes.OutQuint); + + if (judgement.Result == HitResult.Miss) + { + FadeInFromZero(60); + + ScaleTo(1.6f); + ScaleTo(1, 100, EasingTypes.In); + + MoveToRelative(new Vector2(0, 100), 800, EasingTypes.InQuint); + RotateTo(40, 800, EasingTypes.InQuint); + + Delay(600); + FadeOut(200); + } + else + { + line1.TransformSpacingTo(new Vector2(14, 0), 1800, EasingTypes.OutQuint); + line2.TransformSpacingTo(new Vector2(14, 0), 1800, EasingTypes.OutQuint); + FadeOut(500); + } + + switch (judgement.Result) + { + case HitResult.Miss: + Colour = Color4.Red; + break; + } + + Expire(); } } } \ No newline at end of file diff --git a/osu.Game.Mode.Osu/Objects/OsuHitObject.cs b/osu.Game.Mode.Osu/Objects/OsuHitObject.cs index 35f24699f1..61932f80a3 100644 --- a/osu.Game.Mode.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Mode.Osu/Objects/OsuHitObject.cs @@ -12,6 +12,8 @@ namespace osu.Game.Modes.Osu.Objects { public Vector2 Position { get; set; } + public virtual Vector2 EndPosition => Position; + [Flags] internal enum HitObjectType { diff --git a/osu.Game.Mode.Osu/Objects/Slider.cs b/osu.Game.Mode.Osu/Objects/Slider.cs index a0cdbeae7c..3c11ead7e4 100644 --- a/osu.Game.Mode.Osu/Objects/Slider.cs +++ b/osu.Game.Mode.Osu/Objects/Slider.cs @@ -4,6 +4,7 @@ using osu.Game.Database; using osu.Game.Beatmaps; using System; +using OpenTK; namespace osu.Game.Modes.Osu.Objects { @@ -11,6 +12,8 @@ namespace osu.Game.Modes.Osu.Objects { public override double EndTime => StartTime + RepeatCount * Curve.Length / Velocity; + public override Vector2 EndPosition => RepeatCount % 2 == 0 ? Position : Curve.PositionAt(1); + public double Velocity; public override void SetDefaultsFromBeatmap(Beatmap beatmap) diff --git a/osu.Game.Mode.Osu/UI/OsuHitRenderer.cs b/osu.Game.Mode.Osu/UI/OsuHitRenderer.cs index 01f95de5fb..02e7521c4f 100644 --- a/osu.Game.Mode.Osu/UI/OsuHitRenderer.cs +++ b/osu.Game.Mode.Osu/UI/OsuHitRenderer.cs @@ -6,7 +6,6 @@ using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects.Drawables; using osu.Game.Modes.UI; -using OsuConverter = osu.Game.Modes.Osu.Objects.OsuHitObjectConverter; namespace osu.Game.Modes.Osu.UI { diff --git a/osu.Game.Mode.Osu/UI/OsuPlayfield.cs b/osu.Game.Mode.Osu/UI/OsuPlayfield.cs index 1e69cd78a3..3ee3339f2a 100644 --- a/osu.Game.Mode.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Mode.Osu/UI/OsuPlayfield.cs @@ -3,19 +3,18 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects.Drawables; using osu.Game.Modes.UI; using OpenTK; -using OpenTK.Graphics; namespace osu.Game.Modes.Osu.UI { public class OsuPlayfield : Playfield { private Container approachCircles; + private Container judgementLayer; public override Vector2 Size { @@ -35,11 +34,17 @@ namespace osu.Game.Modes.Osu.UI RelativeSizeAxes = Axes.Both; Size = new Vector2(0.75f); - AddInternal(new Drawable[] + Add(new Drawable[] { + judgementLayer = new Container + { + RelativeSizeAxes = Axes.Both, + Depth = 1, + }, approachCircles = new Container { RelativeSizeAxes = Axes.Both, + Depth = -1, } }); } @@ -52,7 +57,16 @@ namespace osu.Game.Modes.Osu.UI approachCircles.Add(c.ApproachCircle.CreateProxy()); } + h.OnJudgement += judgement; + base.Add(h); } + + private void judgement(DrawableHitObject h, JudgementInfo j) + { + HitExplosion explosion = new HitExplosion((OsuJudgementInfo)j, (OsuHitObject)h.HitObject); + + judgementLayer.Add(explosion); + } } } \ No newline at end of file diff --git a/osu.Game/Modes/UI/Playfield.cs b/osu.Game/Modes/UI/Playfield.cs index ff8a03db2a..ec91536f29 100644 --- a/osu.Game/Modes/UI/Playfield.cs +++ b/osu.Game/Modes/UI/Playfield.cs @@ -11,23 +11,34 @@ namespace osu.Game.Modes.UI public abstract class Playfield : Container { public HitObjectContainer HitObjects; + private Container content; public virtual void Add(DrawableHitObject h) => HitObjects.Add(h); public override bool Contains(Vector2 screenSpacePos) => true; + protected override Container Content => content; + public Playfield() { - AddInternal(HitObjects = new HitObjectContainer + AddInternal(content = new ScaledContainer() + { + RelativeSizeAxes = Axes.Both, + }); + + Add(HitObjects = new HitObjectContainer { RelativeSizeAxes = Axes.Both, }); } - public class HitObjectContainer : Container + public class ScaledContainer : Container { protected override Vector2 DrawScale => new Vector2(DrawSize.X / 512); + } + public class HitObjectContainer : Container + { public override bool Contains(Vector2 screenSpacePos) => true; } } From 7ab08945e4a0124b38f1efc7522606eb826b9b5e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Dec 2016 00:02:27 +0900 Subject: [PATCH 05/13] Add repeat graphics, fine-tune scale of various elements. --- .../Objects/Drawables/DrawableOsuHitObject.cs | 2 +- .../Objects/Drawables/DrawableSlider.cs | 31 ++++++++-- .../Objects/Drawables/Pieces/SliderBall.cs | 9 ++- .../Objects/Drawables/Pieces/SliderBody.cs | 9 +-- .../Objects/Drawables/Pieces/SliderBouncer.cs | 58 +++++++++++++++++++ osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj | 1 + 6 files changed, 96 insertions(+), 14 deletions(-) create mode 100644 osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBouncer.cs diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableOsuHitObject.cs index dca9ac9b28..e6e948cf6f 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -29,7 +29,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { if (!IsLoaded) return; - Flush(true); + Flush(); UpdateInitialState(); diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs index 34318d3cec..7ffd93e3dc 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs @@ -3,9 +3,12 @@ using System.Collections.Generic; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects.Drawables.Pieces; using OpenTK; +using OpenTK.Graphics; namespace osu.Game.Modes.Osu.Objects.Drawables { @@ -13,13 +16,16 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { private Slider slider; - private DrawableHitCircle startCircle; + private DrawableHitCircle initialCircle; private List components = new List(); + SliderBody body; + + SliderBouncer bouncer1, bouncer2; + public DrawableSlider(Slider s) : base(s) { - SliderBody body; SliderBall ball; slider = s; @@ -35,8 +41,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables Position = s.Position, PathWidth = 36, }, + bouncer1 = new SliderBouncer(slider, false) { Position = slider.Curve.PositionAt(1) }, + bouncer2 = new SliderBouncer(slider, true) { Position = slider.Position }, ball = new SliderBall(slider), - startCircle = new DrawableHitCircle(new HitCircle + initialCircle = new DrawableHitCircle(new HitCircle { StartTime = s.StartTime, Position = s.Position, @@ -49,6 +57,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables components.Add(body); components.Add(ball); + components.Add(bouncer1); + components.Add(bouncer2); } protected override void Update() @@ -63,13 +73,15 @@ namespace osu.Game.Modes.Osu.Objects.Drawables if (repeat % 2 == 1) progress = 1 - progress; + bouncer2.Position = slider.Curve.PositionAt(body.SnakedAmount); + components.ForEach(c => c.UpdateProgress(progress, repeat)); } protected override void CheckJudgement(bool userTriggered) { var j = Judgement as OsuJudgementInfo; - var sc = startCircle.Judgement as OsuJudgementInfo; + var sc = initialCircle.Judgement as OsuJudgementInfo; if (!userTriggered && Time.Current >= HitObject.EndTime) { @@ -78,12 +90,19 @@ namespace osu.Game.Modes.Osu.Objects.Drawables } } + protected override void UpdateInitialState() + { + base.UpdateInitialState(); + body.Alpha = 1; + } + protected override void UpdateState(ArmedState state) { base.UpdateState(state); - Delay(HitObject.Duration); - FadeOut(100); + Delay(HitObject.Duration, true); + body.FadeOut(160); + FadeOut(800); } } diff --git a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBall.cs b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBall.cs index f7765a5057..cb6b6228ef 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBall.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBall.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Framework.Input; +using OpenTK; using OpenTK.Graphics; namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces @@ -30,8 +31,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces Origin = Anchor.Centre, Anchor = Anchor.Centre, Colour = Color4.Orange, - Width = 64, - Height = 64, + Width = 80, + Height = 80, }, new Container { @@ -51,8 +52,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces }, } } - }; + + Scale = new Vector2(0.94f); + } private InputState lastState; diff --git a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs index 354bf80619..e3423e78a0 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs @@ -58,7 +58,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces }, } }, - }; container.Attach(RenderbufferInternalFormat.DepthComponent16); @@ -91,6 +90,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces snakingOut = config.GetBindable(OsuConfig.SnakingOutSliders); } + public double SnakedAmount { get; private set; } + private List currentCurve = new List(); private bool updateSnaking(double p0, double p1) { @@ -123,7 +124,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces public void UpdateProgress(double progress, int repeat) { double start = 0; - double end = snakingIn ? MathHelper.Clamp((Time.Current - (slider.StartTime - DrawableOsuHitObject.TIME_PREEMPT)) / DrawableOsuHitObject.TIME_FADEIN, 0, 1) : 1; + double end = SnakedAmount = snakingIn ? MathHelper.Clamp((Time.Current - (slider.StartTime - DrawableOsuHitObject.TIME_PREEMPT)) / DrawableOsuHitObject.TIME_FADEIN, 0, 1) : 1; if (repeat >= slider.RepeatCount - 1) { @@ -188,12 +189,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { RelativeSizeAxes = Axes.Both, Colour = Color4.White, - Size = new Vector2(0.13f, 1), + Size = new Vector2(0.16f, 1), }, gradientPortion = new Box { RelativeSizeAxes = Axes.Both, - Size = new Vector2(0.85f, 1), + Size = new Vector2(0.82f, 1), }, }, } diff --git a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBouncer.cs b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBouncer.cs new file mode 100644 index 0000000000..f8401e24a5 --- /dev/null +++ b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBouncer.cs @@ -0,0 +1,58 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; + +namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces +{ + public class SliderBouncer : Container, ISliderProgress + { + private readonly Slider slider; + private readonly bool isEnd; + + public SliderBouncer(Slider slider, bool isEnd) + { + this.slider = slider; + this.isEnd = isEnd; + + Masking = true; + AutoSizeAxes = Axes.Both; + BlendingMode = BlendingMode.Additive; + Origin = Anchor.Centre; + + Children = new Drawable[] + { + new Container + { + Masking = true, + AutoSizeAxes = Axes.Both, + + CornerRadius = 16, + Children = new[] + { + new Box + { + Width = 32, + Height = 32, + }, + } + } + }; + } + + public void UpdateProgress(double progress, int repeat) + { + if (Time.Current < slider.StartTime) + Alpha = 0; + + Alpha = repeat + 1 < slider.RepeatCount && repeat % 2 == (isEnd ? 0 : 1) ? 1 : 0; + } + } +} diff --git a/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj index 1f53c706cc..f6b4436951 100644 --- a/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj @@ -52,6 +52,7 @@ + From 27fafe419b91b3b385309975dbb7ffc8e98ccde9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Dec 2016 00:03:02 +0900 Subject: [PATCH 06/13] Add warnings. --- osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs index e3423e78a0..58a3147541 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs @@ -142,6 +142,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces SetRange(start, end); } + // --------------------------------------------- DO NOT MERGE THIS ----------------------------------------------------------------------- public class BodyTexture : BufferedContainer { private Box gradientPortion; @@ -201,5 +202,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces }; } } + // --------------------------------------------- DO NOT MERGE THIS ----------------------------------------------------------------------- } } \ No newline at end of file From 1fff21dc126129f191f4ed802182a65b474793fd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Dec 2016 14:52:34 +0900 Subject: [PATCH 07/13] Make initial circles of sliders follow snaking out. --- .../Objects/Drawables/DrawableHitCircle.cs | 7 +------ .../Objects/Drawables/DrawableSlider.cs | 6 +++++- .../Objects/Drawables/Pieces/SliderBody.cs | 15 ++++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs index b916a7bc74..ebb5057a49 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -131,12 +131,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables FadeOut(TIME_FADEOUT); break; case ArmedState.Miss: - ring.FadeOut(); - circle.FadeOut(); - number.FadeOut(); - glow.FadeOut(); - - FadeOut(800); + FadeOut(TIME_FADEOUT / 5); break; case ArmedState.Hit: const double flash_in = 30; diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs index 7ffd93e3dc..9f11a70a66 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs @@ -73,7 +73,11 @@ namespace osu.Game.Modes.Osu.Objects.Drawables if (repeat % 2 == 1) progress = 1 - progress; - bouncer2.Position = slider.Curve.PositionAt(body.SnakedAmount); + bouncer2.Position = slider.Curve.PositionAt(body.SnakedEnd); + + //todo: we probably want to reconsider this before adding scoring, but it looks and feels nice. + if (initialCircle.Judgement?.Result != HitResult.Hit) + initialCircle.Position = slider.Curve.PositionAt(body.SnakedStart); components.ForEach(c => c.UpdateProgress(progress, repeat)); } diff --git a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs index 58a3147541..c4c1cae7b6 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs @@ -90,7 +90,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces snakingOut = config.GetBindable(OsuConfig.SnakingOutSliders); } - public double SnakedAmount { get; private set; } + public double SnakedEnd { get; private set; } + public double SnakedStart { get; private set; } private List currentCurve = new List(); private bool updateSnaking(double p0, double p1) @@ -123,23 +124,23 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces public void UpdateProgress(double progress, int repeat) { - double start = 0; - double end = SnakedAmount = snakingIn ? MathHelper.Clamp((Time.Current - (slider.StartTime - DrawableOsuHitObject.TIME_PREEMPT)) / DrawableOsuHitObject.TIME_FADEIN, 0, 1) : 1; + SnakedStart = 0; + SnakedEnd = snakingIn ? MathHelper.Clamp((Time.Current - (slider.StartTime - DrawableOsuHitObject.TIME_PREEMPT)) / DrawableOsuHitObject.TIME_FADEIN, 0, 1) : 1; if (repeat >= slider.RepeatCount - 1) { if (Math.Min(repeat, slider.RepeatCount - 1) % 2 == 1) { - start = 0; - end = snakingOut ? progress : 1; + SnakedStart = 0; + SnakedEnd = snakingOut ? progress : 1; } else { - start = snakingOut ? progress : 0; + SnakedStart = snakingOut ? progress : 0; } } - SetRange(start, end); + SetRange(SnakedStart, SnakedEnd); } // --------------------------------------------- DO NOT MERGE THIS ----------------------------------------------------------------------- From 2ba77746c03f19b0213ffca84e53e4d1f22ffadc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Dec 2016 15:45:17 +0900 Subject: [PATCH 08/13] Manually create slider textures rather than relying on draw calls. --- .../Objects/Drawables/Pieces/SliderBody.cs | 122 ++++++------------ 1 file changed, 40 insertions(+), 82 deletions(-) diff --git a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs index c4c1cae7b6..002976532f 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs @@ -6,13 +6,12 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.OpenGL.Textures; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Game.Configuration; using OpenTK; -using OpenTK.Graphics; using OpenTK.Graphics.ES30; namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces @@ -20,7 +19,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces public class SliderBody : Container, ISliderProgress { private Path path; - private BodyTexture pathTexture; private BufferedContainer container; public float PathWidth @@ -29,7 +27,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces set { path.PathWidth = value; - pathTexture.Size = new Vector2(value, 1); } } @@ -43,10 +40,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces Children = new Drawable[] { - pathTexture = new BodyTexture - { - MainColour = s.Colour - }, container = new BufferedContainer { CacheDrawnFrameBuffer = true, @@ -88,6 +81,45 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { snakingIn = config.GetBindable(OsuConfig.SnakingInSliders); snakingOut = config.GetBindable(OsuConfig.SnakingOutSliders); + + int textureWidth = (int)PathWidth * 2; + + //initialise background + var upload = new TextureUpload(textureWidth * 4); + var bytes = upload.Data; + + const float aa_portion = 0.02f; + const float border_portion = 0.18f; + const float gradient_portion = 1 - border_portion; + + const float opacity_at_centre = 0.3f; + const float opacity_at_edge = 0.8f; + + for (int i = 0; i < textureWidth; i++) + { + float progress = (float)i / (textureWidth - 1); + + if (progress <= border_portion) + { + bytes[i * 4] = 255; + bytes[i * 4 + 1] = 255; + bytes[i * 4 + 2] = 255; + bytes[i * 4 + 3] = (byte)(Math.Min(progress / aa_portion, 1) * 255); + } + else + { + progress -= border_portion; + + bytes[i * 4] = (byte)(slider.Colour.R * 255); + bytes[i * 4 + 1] = (byte)(slider.Colour.G * 255); + bytes[i * 4 + 2] = (byte)(slider.Colour.B * 255); + bytes[i * 4 + 3] = (byte)((opacity_at_edge - (opacity_at_edge - opacity_at_centre) * progress / gradient_portion) * (slider.Colour.A * 255)); + } + } + + var texture = new Texture(textureWidth, 1); + texture.SetData(upload); + path.Texture = texture; } public double SnakedEnd { get; private set; } @@ -110,18 +142,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces return true; } - protected override void Update() - { - base.Update(); - - var texture = pathTexture.Texture; - if (texture != null) - { - path.Texture = texture; - pathTexture.Alpha = 0; - } - } - public void UpdateProgress(double progress, int repeat) { SnakedStart = 0; @@ -142,67 +162,5 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces SetRange(SnakedStart, SnakedEnd); } - - // --------------------------------------------- DO NOT MERGE THIS ----------------------------------------------------------------------- - public class BodyTexture : BufferedContainer - { - private Box gradientPortion; - private BufferedContainerDrawNode lastNode; - public Texture Texture => lastNode?.FrameBuffers[0].Texture != null ? new Texture(lastNode.FrameBuffers[0].Texture) : null; - - protected override void ApplyDrawNode(DrawNode node) - { - base.ApplyDrawNode(node); - lastNode = node as BufferedContainerDrawNode; - } - - public Color4 MainColour - { - set - { - gradientPortion.ColourInfo = ColourInfo.GradientHorizontal( - value, - new Color4(value.R, value.G, value.B, value.A * 0.4f) - ); - } - } - - public BodyTexture() - { - Children = new[] - { - new FlowContainer - { - RelativeSizeAxes = Axes.Both, - Direction = FlowDirection.HorizontalOnly, - Masking = true, - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - ColourInfo = ColourInfo.GradientHorizontal( - new Color4(255, 255, 255, 0), - Color4.White - ), - Size = new Vector2(0.02f, 1), - }, - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.White, - Size = new Vector2(0.16f, 1), - }, - gradientPortion = new Box - { - RelativeSizeAxes = Axes.Both, - Size = new Vector2(0.82f, 1), - }, - }, - } - }; - } - } - // --------------------------------------------- DO NOT MERGE THIS ----------------------------------------------------------------------- } } \ No newline at end of file From 41b9a55460fe66256ec362a9e43e1a67bc4f26f3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Dec 2016 16:00:29 +0900 Subject: [PATCH 09/13] Simplify variables for snake start/end. --- .../Objects/Drawables/DrawableSlider.cs | 4 +-- .../Objects/Drawables/Pieces/SliderBody.cs | 25 ++++++++----------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs index 9f11a70a66..9ce624ab42 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs @@ -73,11 +73,11 @@ namespace osu.Game.Modes.Osu.Objects.Drawables if (repeat % 2 == 1) progress = 1 - progress; - bouncer2.Position = slider.Curve.PositionAt(body.SnakedEnd); + bouncer2.Position = slider.Curve.PositionAt(body.SnakedEnd ?? 0); //todo: we probably want to reconsider this before adding scoring, but it looks and feels nice. if (initialCircle.Judgement?.Result != HitResult.Hit) - initialCircle.Position = slider.Curve.PositionAt(body.SnakedStart); + initialCircle.Position = slider.Curve.PositionAt(body.SnakedStart ?? 0); components.ForEach(c => c.UpdateProgress(progress, repeat)); } diff --git a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs index 002976532f..c0bd29bc02 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs @@ -30,8 +30,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces } } - private double? drawnProgressStart; - private double? drawnProgressEnd; + public double? SnakedStart { get; private set; } + public double? SnakedEnd { get; private set; } private Slider slider; public SliderBody(Slider s) @@ -122,16 +122,13 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces path.Texture = texture; } - public double SnakedEnd { get; private set; } - public double SnakedStart { get; private set; } - private List currentCurve = new List(); private bool updateSnaking(double p0, double p1) { - if (drawnProgressStart == p0 && drawnProgressEnd == p1) return false; + if (SnakedStart == p0 && SnakedEnd == p1) return false; - drawnProgressStart = p0; - drawnProgressEnd = p1; + SnakedStart = p0; + SnakedEnd = p1; slider.Curve.GetPathToProgress(currentCurve, p0, p1); @@ -144,23 +141,23 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces public void UpdateProgress(double progress, int repeat) { - SnakedStart = 0; - SnakedEnd = snakingIn ? MathHelper.Clamp((Time.Current - (slider.StartTime - DrawableOsuHitObject.TIME_PREEMPT)) / DrawableOsuHitObject.TIME_FADEIN, 0, 1) : 1; + double start = 0; + double end = snakingIn ? MathHelper.Clamp((Time.Current - (slider.StartTime - DrawableOsuHitObject.TIME_PREEMPT)) / DrawableOsuHitObject.TIME_FADEIN, 0, 1) : 1; if (repeat >= slider.RepeatCount - 1) { if (Math.Min(repeat, slider.RepeatCount - 1) % 2 == 1) { - SnakedStart = 0; - SnakedEnd = snakingOut ? progress : 1; + start = 0; + end = snakingOut ? progress : 1; } else { - SnakedStart = snakingOut ? progress : 0; + start = snakingOut ? progress : 0; } } - SetRange(SnakedStart, SnakedEnd); + SetRange(start, end); } } } \ No newline at end of file From b5e3dcbd1cf14ac77862817e3ab9be965dd16d9a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Dec 2016 16:37:03 +0900 Subject: [PATCH 10/13] Improve visuals of temporary sliderball. --- .../Objects/Drawables/DrawableSlider.cs | 3 -- .../Objects/Drawables/Pieces/SliderBall.cs | 29 +++++++++++-------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs index 9ce624ab42..1cf3564f93 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs @@ -3,12 +3,9 @@ using System.Collections.Generic; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects.Drawables.Pieces; using OpenTK; -using OpenTK.Graphics; namespace osu.Game.Modes.Osu.Objects.Drawables { diff --git a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBall.cs b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBall.cs index cb6b6228ef..ce34ef7c22 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBall.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBall.cs @@ -16,6 +16,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces private readonly Slider slider; private Box follow; + const float width = 70; + public SliderBall(Slider slider) { this.slider = slider; @@ -23,6 +25,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces AutoSizeAxes = Axes.Both; BlendingMode = BlendingMode.Additive; Origin = Anchor.Centre; + BorderThickness = 5; + BorderColour = Color4.Orange; Children = new Drawable[] { @@ -31,8 +35,9 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces Origin = Anchor.Centre, Anchor = Anchor.Centre, Colour = Color4.Orange, - Width = 80, - Height = 80, + Width = width, + Height = width, + Alpha = 0, }, new Container { @@ -40,22 +45,22 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces AutoSizeAxes = Axes.Both, Origin = Anchor.Centre, Anchor = Anchor.Centre, - Colour = Color4.Cyan, - CornerRadius = 32, + BorderThickness = 7, + BorderColour = Color4.White, + Alpha = 1, + CornerRadius = width / 2, Children = new[] { new Box { - - Width = 64, - Height = 64, + Colour = slider.Colour, + Alpha = 0.4f, + Width = width, + Height = width, }, } } }; - - Scale = new Vector2(0.94f); - } private InputState lastState; @@ -88,8 +93,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces tracking = value; - follow.ScaleTo(tracking ? 2.4f : 1, 140, EasingTypes.Out); - follow.FadeTo(tracking ? 0.8f : 0, 140, EasingTypes.Out); + follow.ScaleTo(tracking ? 2.8f : 1, 300, EasingTypes.OutQuint); + follow.FadeTo(tracking ? 0.2f : 0, 300, EasingTypes.OutQuint); } } From 83e7e67cc55490566a20b3b43acfc9c6fa867db1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Dec 2016 17:21:59 +0900 Subject: [PATCH 11/13] Improve repeat point visual. --- .../Objects/Drawables/Pieces/SliderBouncer.cs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBouncer.cs b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBouncer.cs index f8401e24a5..39d09e6d66 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBouncer.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBouncer.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { @@ -16,37 +17,36 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { private readonly Slider slider; private readonly bool isEnd; + private TextAwesome icon; public SliderBouncer(Slider slider, bool isEnd) { this.slider = slider; this.isEnd = isEnd; - Masking = true; AutoSizeAxes = Axes.Both; BlendingMode = BlendingMode.Additive; Origin = Anchor.Centre; Children = new Drawable[] { - new Container - { - Masking = true, - AutoSizeAxes = Axes.Both, - - CornerRadius = 16, - Children = new[] - { - new Box - { - Width = 32, - Height = 32, - }, - } - } + icon = new TextAwesome + { + Icon = FontAwesome.fa_eercast, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextSize = 24, + } }; } + protected override void LoadComplete() + { + base.LoadComplete(); + icon.RotateTo(360, 1000); + icon.Loop(); + } + public void UpdateProgress(double progress, int repeat) { if (Time.Current < slider.StartTime) From 87ad44b9015cfbe33c724d1ab1028b4d19c0872e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Dec 2016 18:18:36 +0900 Subject: [PATCH 12/13] Fix HitObject test case not displaying properly. --- osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs | 4 +++- osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index 1e18ae4117..3c58ef207e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -22,7 +22,7 @@ namespace osu.Desktop.VisualTests.Tests public TestCaseHitObjects() { - var swClock = new StopwatchClock(true) { Rate = 1 }; + var swClock = new StopwatchClock(true) { Rate = 0.2f }; Clock = new FramedClock(swClock); } @@ -52,8 +52,10 @@ namespace osu.Desktop.VisualTests.Tests Origin = Anchor.Centre, Depth = i, State = ArmedState.Hit, + Judgement = new OsuJudgementInfo { Result = HitResult.Hit } }; + approachContainer.Add(d.ApproachCircle.CreateProxy()); Add(d); } diff --git a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs index 352615eeab..9b5c268696 100644 --- a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs @@ -47,7 +47,9 @@ namespace osu.Game.Modes.Objects.Drawables { base.LoadComplete(); - Judgement = CreateJudgementInfo(); + //we may be setting a custom judgement in test cases or what not. + if (Judgement == null) + Judgement = CreateJudgementInfo(); //force application of the state that was set before we loaded. UpdateState(State); From 112b2983acd56da2f6cbc5018cc3f4dd86209eba Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Dec 2016 21:46:06 +0900 Subject: [PATCH 13/13] Make start circle always follow current progress for now, not snaking. --- osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs index 1cf3564f93..e0af180e95 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs @@ -74,7 +74,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables //todo: we probably want to reconsider this before adding scoring, but it looks and feels nice. if (initialCircle.Judgement?.Result != HitResult.Hit) - initialCircle.Position = slider.Curve.PositionAt(body.SnakedStart ?? 0); + initialCircle.Position = slider.Curve.PositionAt(progress); components.ForEach(c => c.UpdateProgress(progress, repeat)); }