mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 04:52:57 +08:00
Merge pull request #225 from peppy/hitobject-improvements
Slider & other hit object improvements.
This commit is contained in:
commit
63da7e5ea4
@ -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);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
@ -64,14 +63,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;
|
||||
@ -138,22 +129,9 @@ 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();
|
||||
circle.FadeOut();
|
||||
number.FadeOut();
|
||||
glow.FadeOut();
|
||||
|
||||
explosion?.Expire();
|
||||
explosion = null;
|
||||
|
||||
Schedule(() => Add(explosion = new HitExplosion((OsuJudgementInfo)Judgement)));
|
||||
|
||||
FadeOut(800);
|
||||
FadeOut(TIME_FADEOUT / 5);
|
||||
break;
|
||||
case ArmedState.Hit:
|
||||
const double flash_in = 30;
|
||||
@ -164,8 +142,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
|
||||
|
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//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)
|
||||
@ -26,7 +29,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
{
|
||||
if (!IsLoaded) return;
|
||||
|
||||
Flush(true);
|
||||
Flush();
|
||||
|
||||
UpdateInitialState();
|
||||
|
||||
|
@ -1,21 +1,11 @@
|
||||
// Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//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
|
||||
{
|
||||
@ -23,12 +13,18 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
{
|
||||
private Slider slider;
|
||||
|
||||
private DrawableHitCircle startCircle;
|
||||
private Container ball;
|
||||
private Body body;
|
||||
private DrawableHitCircle initialCircle;
|
||||
|
||||
private List<ISliderProgress> components = new List<ISliderProgress>();
|
||||
|
||||
SliderBody body;
|
||||
|
||||
SliderBouncer bouncer1, bouncer2;
|
||||
|
||||
public DrawableSlider(Slider s) : base(s)
|
||||
{
|
||||
SliderBall ball;
|
||||
|
||||
slider = s;
|
||||
|
||||
Origin = Anchor.TopLeft;
|
||||
@ -37,12 +33,15 @@ 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(),
|
||||
startCircle = new DrawableHitCircle(new HitCircle
|
||||
bouncer1 = new SliderBouncer(slider, false) { Position = slider.Curve.PositionAt(1) },
|
||||
bouncer2 = new SliderBouncer(slider, true) { Position = slider.Position },
|
||||
ball = new SliderBall(slider),
|
||||
initialCircle = new DrawableHitCircle(new HitCircle
|
||||
{
|
||||
StartTime = s.StartTime,
|
||||
Position = s.Position,
|
||||
@ -52,85 +51,38 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
Depth = -1 //override time-based depth.
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private Bindable<bool> snakingIn;
|
||||
private Bindable<bool> snakingOut;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
snakingIn = config.GetBindable<bool>(OsuConfig.SnakingInSliders);
|
||||
snakingOut = config.GetBindable<bool>(OsuConfig.SnakingOutSliders);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
//force application of the state that was set before we loaded.
|
||||
UpdateState(State);
|
||||
|
||||
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 drawStartProgress = 0;
|
||||
double drawEndProgress = MathHelper.Clamp((Time.Current - slider.StartTime + TIME_PREEMPT) / TIME_FADEIN, 0, 1);
|
||||
|
||||
if (repeat >= slider.RepeatCount - 1)
|
||||
{
|
||||
if (Math.Min(repeat, slider.RepeatCount - 1) % 2 == 1)
|
||||
{
|
||||
drawStartProgress = 0;
|
||||
drawEndProgress = progress;
|
||||
}
|
||||
else
|
||||
{
|
||||
drawStartProgress = progress;
|
||||
drawEndProgress = 1;
|
||||
}
|
||||
}
|
||||
|
||||
body.SetRange(
|
||||
snakingOut ? drawStartProgress : 0,
|
||||
snakingIn ? drawEndProgress : 1);
|
||||
components.Add(body);
|
||||
components.Add(ball);
|
||||
components.Add(bouncer1);
|
||||
components.Add(bouncer2);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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(progress);
|
||||
|
||||
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)
|
||||
{
|
||||
@ -139,180 +91,24 @@ 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(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,
|
||||
},
|
||||
Delay(HitObject.Duration, true);
|
||||
body.FadeOut(160);
|
||||
FadeOut(800);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
private InputState lastState;
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
internal interface ISliderProgress
|
||||
{
|
||||
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<Vector2> currentCurve = new List<Vector2>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
void UpdateProgress(double progress, int repeat);
|
||||
}
|
||||
}
|
@ -8,22 +8,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[]
|
||||
{
|
||||
@ -33,13 +36,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,
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -47,8 +50,35 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
115
osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBall.cs
Normal file
115
osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBall.cs
Normal file
@ -0,0 +1,115 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//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;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class SliderBall : Container, ISliderProgress
|
||||
{
|
||||
private readonly Slider slider;
|
||||
private Box follow;
|
||||
|
||||
const float width = 70;
|
||||
|
||||
public SliderBall(Slider slider)
|
||||
{
|
||||
this.slider = slider;
|
||||
Masking = true;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
BlendingMode = BlendingMode.Additive;
|
||||
Origin = Anchor.Centre;
|
||||
BorderThickness = 5;
|
||||
BorderColour = Color4.Orange;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
follow = new Box
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Colour = Color4.Orange,
|
||||
Width = width,
|
||||
Height = width,
|
||||
Alpha = 0,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Masking = true,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
BorderThickness = 7,
|
||||
BorderColour = Color4.White,
|
||||
Alpha = 1,
|
||||
CornerRadius = width / 2,
|
||||
Children = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = slider.Colour,
|
||||
Alpha = 0.4f,
|
||||
Width = width,
|
||||
Height = width,
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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.8f : 1, 300, EasingTypes.OutQuint);
|
||||
follow.FadeTo(tracking ? 0.2f : 0, 300, EasingTypes.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
163
osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs
Normal file
163
osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBody.cs
Normal file
@ -0,0 +1,163 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//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.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.ES30;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class SliderBody : Container, ISliderProgress
|
||||
{
|
||||
private Path path;
|
||||
private BufferedContainer container;
|
||||
|
||||
public float PathWidth
|
||||
{
|
||||
get { return path.PathWidth; }
|
||||
set
|
||||
{
|
||||
path.PathWidth = value;
|
||||
}
|
||||
}
|
||||
|
||||
public double? SnakedStart { get; private set; }
|
||||
public double? SnakedEnd { get; private set; }
|
||||
|
||||
private Slider slider;
|
||||
public SliderBody(Slider s)
|
||||
{
|
||||
slider = s;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
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<bool> snakingIn;
|
||||
private Bindable<bool> snakingOut;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
snakingIn = config.GetBindable<bool>(OsuConfig.SnakingInSliders);
|
||||
snakingOut = config.GetBindable<bool>(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;
|
||||
}
|
||||
|
||||
private List<Vector2> currentCurve = new List<Vector2>();
|
||||
private bool updateSnaking(double p0, double p1)
|
||||
{
|
||||
if (SnakedStart == p0 && SnakedEnd == p1) return false;
|
||||
|
||||
SnakedStart = p0;
|
||||
SnakedEnd = p1;
|
||||
|
||||
slider.Curve.GetPathToProgress(currentCurve, p0, p1);
|
||||
|
||||
path.ClearVertices();
|
||||
foreach (Vector2 p in currentCurve)
|
||||
path.AddVertex(p - currentCurve[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
58
osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBouncer.cs
Normal file
58
osu.Game.Mode.Osu/Objects/Drawables/Pieces/SliderBouncer.cs
Normal file
@ -0,0 +1,58 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//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;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class SliderBouncer : Container, ISliderProgress
|
||||
{
|
||||
private readonly Slider slider;
|
||||
private readonly bool isEnd;
|
||||
private TextAwesome icon;
|
||||
|
||||
public SliderBouncer(Slider slider, bool isEnd)
|
||||
{
|
||||
this.slider = slider;
|
||||
this.isEnd = isEnd;
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
BlendingMode = BlendingMode.Additive;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
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)
|
||||
Alpha = 0;
|
||||
|
||||
Alpha = repeat + 1 < slider.RepeatCount && repeat % 2 == (isEnd ? 0 : 1) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,8 @@ namespace osu.Game.Modes.Osu.Objects
|
||||
{
|
||||
public Vector2 Position { get; set; }
|
||||
|
||||
public virtual Vector2 EndPosition => Position;
|
||||
|
||||
[Flags]
|
||||
internal enum HitObjectType
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -52,7 +52,10 @@
|
||||
<Compile Include="Objects\Drawables\HitExplosion.cs" />
|
||||
<Compile Include="Objects\Drawables\Pieces\NumberPiece.cs" />
|
||||
<Compile Include="Objects\Drawables\Pieces\RingPiece.cs" />
|
||||
<Compile Include="Objects\Drawables\Pieces\SliderBouncer.cs" />
|
||||
<Compile Include="Objects\Drawables\Pieces\Triangles.cs" />
|
||||
<Compile Include="Objects\Drawables\Pieces\SliderBall.cs" />
|
||||
<Compile Include="Objects\Drawables\Pieces\SliderBody.cs" />
|
||||
<Compile Include="Objects\OsuHitObjectParser.cs" />
|
||||
<Compile Include="Objects\SliderCurve.cs" />
|
||||
<Compile Include="OsuScore.cs" />
|
||||
|
@ -47,7 +47,12 @@ namespace osu.Game.Modes.Objects.Drawables
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -11,23 +11,34 @@ namespace osu.Game.Modes.UI
|
||||
public abstract class Playfield : Container
|
||||
{
|
||||
public HitObjectContainer HitObjects;
|
||||
private Container<Drawable> content;
|
||||
|
||||
public virtual void Add(DrawableHitObject h) => HitObjects.Add(h);
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
protected override Container<Drawable> 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<DrawableHitObject>
|
||||
public class ScaledContainer : Container
|
||||
{
|
||||
protected override Vector2 DrawScale => new Vector2(DrawSize.X / 512);
|
||||
}
|
||||
|
||||
public class HitObjectContainer : Container<DrawableHitObject>
|
||||
{
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user