1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 23:07:26 +08:00

Merge pull request #361 from peppy/general-hitobject-improvements

General HitObject improvements.
This commit is contained in:
Thomas Müller 2017-02-15 19:49:46 +01:00 committed by GitHub
commit d3335f778b
21 changed files with 191 additions and 101 deletions

@ -1 +1 @@
Subproject commit a766d283f4d628736db784001cc1f11d065cab9d
Subproject commit 659cb2589252f502d2f29c1c1b3878b8f5910d86

View File

@ -49,7 +49,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
return true;
},
},
number = new NumberPiece(),
number = new NumberPiece()
{
Text = h is Spinner ? "S" : (HitObject.ComboIndex + 1).ToString(),
},
ring = new RingPiece(),
flash = new FlashPiece(),
explode = new ExplodePiece
@ -124,6 +127,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
base.UpdateState(state);
ApproachCircle.FadeOut();
glow.Delay(osuObject.Duration);
glow.FadeOut(400);
switch (state)

View File

@ -49,8 +49,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
},
initialCircle = new DrawableHitCircle(new HitCircle
{
//todo: avoid creating this temporary HitCircle.
StartTime = s.StartTime,
Position = s.StackedPosition,
ComboIndex = s.ComboIndex,
Scale = s.Scale,
Colour = s.Colour,
Sample = s.Sample,

View File

@ -3,6 +3,7 @@
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transformations;
using osu.Framework.MathUtils;
using osu.Game.Modes.Objects.Drawables;
@ -18,8 +19,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
private SpinnerDisc disc;
private SpinnerBackground background;
private Container circleContainer;
private DrawableHitCircle circle;
private NumberPiece number;
public DrawableSpinner(Spinner s) : base(s)
{
@ -47,16 +48,23 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
Origin = Anchor.Centre,
DiscColour = s.Colour
},
circleContainer = new Container
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new []
{
circle = new DrawableHitCircle(s)
{
Interactive = false,
Position = Vector2.Zero,
Anchor = Anchor.Centre,
}
}
}
};
circle.ApproachCircle.Colour = Color4.Transparent;
background.Scale = scaleToCircle;
disc.Scale = scaleToCircle;
}
@ -71,6 +79,9 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
disc.ScaleTo(Interpolation.ValueAt(Math.Sqrt(Progress), scaleToCircle, Vector2.One, 0, 1), 100);
if (Progress >= 1)
disc.Complete = true;
if (!userTriggered && Time.Current >= HitObject.EndTime)
{
if (Progress >= 1)
@ -91,6 +102,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
else
{
j.Score = OsuScoreResult.Miss;
if (Time.Current >= HitObject.EndTime)
j.Result = HitResult.Miss;
}
}
@ -109,6 +121,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
base.UpdatePreemptState();
FadeIn(200);
circleContainer.ScaleTo(1, 400, EasingTypes.OutElastic);
background.Delay(TIME_PREEMPT - 100);
background.FadeIn(200);
@ -120,6 +133,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
protected override void UpdateState(ArmedState state)
{
if (!IsLoaded) return;
base.UpdateState(state);
Delay(HitObject.Duration, true);

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Game.Graphics.Sprites;
using osu.Game.Modes.Objects.Drawables;
using OpenTK;
using OpenTK.Graphics;
@ -30,7 +31,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
Children = new Drawable[]
{
line1 = new SpriteText
line1 = new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
@ -38,7 +39,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
Font = @"Venera",
TextSize = 16,
},
line2 = new SpriteText
line2 = new OsuSpriteText
{
Text = judgement.Combo.GetDescription(),
Font = @"Venera",

View File

@ -14,9 +14,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
public class CirclePiece : Container
{
private Sprite disc;
private Triangles triangles;
public Func<bool> Hit;
@ -36,10 +35,11 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
Anchor = Anchor.Centre,
Origin = Anchor.Centre
},
triangles = new Triangles
new TrianglesPiece
{
RelativeSizeAxes = Axes.Both,
BlendingMode = BlendingMode.Additive,
RelativeSizeAxes = Axes.Both
Alpha = 0.5f,
}
};
}

View File

@ -21,10 +21,11 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
Children = new Drawable[]
{
new Triangles
new TrianglesPiece
{
BlendingMode = BlendingMode.Additive,
RelativeSizeAxes = Axes.Both
RelativeSizeAxes = Axes.Both,
Alpha = 0.1f,
}
};
}

View File

@ -6,33 +6,54 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
public class NumberPiece : Container
{
private Sprite number;
private SpriteText number;
public string Text
{
get { return number.Text; }
set { number.Text = value; }
}
public NumberPiece()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Children = new Drawable[]
{
new CircularContainer
{
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Glow,
Radius = 60,
Colour = Color4.White.Opacity(0.5f),
},
Children = new[]
{
number = new Sprite
new Box()
}
},
number = new OsuSpriteText
{
Text = @"1",
Font = @"Venera",
UseFullGlyphHeight = false,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
TextSize = 40,
Alpha = 1
}
};
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
number.Texture = textures.Get(@"Play/osu/number");
}
}
}

View File

@ -11,7 +11,7 @@ using OpenTK.Graphics;
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
public class SliderBall : Container, ISliderProgress
public class SliderBall : CircularContainer, ISliderProgress
{
private readonly Slider slider;
private Box follow;
@ -39,7 +39,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
Height = width,
Alpha = 0,
},
new Container
new CircularContainer
{
Masking = true,
AutoSizeAxes = Axes.Both,
@ -48,7 +48,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
BorderThickness = 10,
BorderColour = Color4.White,
Alpha = 1,
CornerRadius = width / 2,
Children = new[]
{
new Box
@ -104,7 +103,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
base.Update();
CornerRadius = DrawWidth / 2;
if (Time.Current < slider.EndTime)
Tracking = canCurrentlyTrack && lastState != null && Contains(lastState.Mouse.NativeState.Position) && lastState.Mouse.HasMainButtonPressed;
}

View File

@ -3,6 +3,7 @@
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
@ -10,6 +11,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
using osu.Framework.Logging;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
@ -27,6 +29,14 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
set { Disc.Colour = value; }
}
Color4 completeColour;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
completeColour = colours.YellowLight.Opacity(0.8f);
}
class SpinnerBorder : Container
{
public SpinnerBorder()
@ -120,6 +130,22 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
}
}
bool complete;
public bool Complete
{
get { return complete; }
set
{
if (value == complete) return;
complete = value;
Disc.FadeColour(completeColour, 200);
updateCompleteTick();
}
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
Tracking = true;
@ -145,6 +171,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
private float currentRotation;
public float RotationAbsolute;
private int completeTick;
private bool updateCompleteTick() => completeTick != (completeTick = (int)(RotationAbsolute / 720));
protected override void Update()
{
base.Update();
@ -162,6 +192,14 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
}
lastAngle = thisAngle;
if (Complete && updateCompleteTick())
{
Disc.Flush(flushType: typeof(TransformAlpha));
Disc.FadeTo(0.75f, 30, EasingTypes.OutExpo);
Disc.Delay(30);
Disc.FadeTo(0.5f, 250, EasingTypes.OutQuint);
}
RotateTo(currentRotation, 100, EasingTypes.OutExpo);
}
}

View File

@ -1,46 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.MathUtils;
using OpenTK;
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
public class Triangles : Container<Triangle>
{
public override bool HandleInput => false;
protected override void LoadComplete()
{
base.LoadComplete();
const float size = 100;
for (int i = 0; i < 10; i++)
{
Add(new Triangle
{
Origin = Anchor.Centre,
RelativePositionAxes = Axes.Both,
Position = new Vector2(RNG.NextSingle(), RNG.NextSingle()),
Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f),
// Scaling height by 0.866 results in equiangular triangles (== 60° and equal side length)
Size = new Vector2(size, 0.866f * size),
Alpha = RNG.NextSingle() * 0.3f,
});
}
}
protected override void Update()
{
base.Update();
foreach (Drawable d in Children)
d.Position -= new Vector2(0, (float)(d.Scale.X * (Time.Elapsed / 2880)));
}
}
}

View File

@ -0,0 +1,26 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Game.Graphics.Backgrounds;
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
public class TrianglesPiece : Triangles
{
protected override bool ExpireOffScreenTriangles => false;
protected override bool CreateNewTriangles => false;
protected override float SpawnRatio => 0.5f;
public TrianglesPiece()
{
TriangleScale = 1.2f;
}
protected override void Update()
{
if (IsPresent)
base.Update();
}
}
}

View File

@ -15,8 +15,14 @@ namespace osu.Game.Modes.Osu.Objects
{
List<OsuHitObject> output = new List<OsuHitObject>();
int combo = 0;
foreach (HitObject h in beatmap.HitObjects)
{
if (h.NewCombo) combo = 0;
h.ComboIndex = combo++;
output.Add(h as OsuHitObject);
}
UpdateStacking(output, beatmap.BeatmapInfo?.StackLeniency ?? 0.7f);

View File

@ -62,7 +62,7 @@
<Compile Include="Objects\Drawables\Pieces\RingPiece.cs" />
<Compile Include="Objects\Drawables\Pieces\SliderBouncer.cs" />
<Compile Include="Objects\Drawables\Pieces\SpinnerDisc.cs" />
<Compile Include="Objects\Drawables\Pieces\Triangles.cs" />
<Compile Include="Objects\Drawables\Pieces\TrianglesPiece.cs" />
<Compile Include="Objects\Drawables\Pieces\SliderBall.cs" />
<Compile Include="Objects\Drawables\Pieces\SliderBody.cs" />
<Compile Include="Objects\OsuHitObjectParser.cs" />

View File

@ -2,12 +2,10 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.MathUtils;
using OpenTK;
using OpenTK.Graphics;
@ -22,6 +20,21 @@ namespace osu.Game.Graphics.Backgrounds
public Color4 ColourLight = Color4.White;
public Color4 ColourDark = Color4.Black;
/// <summary>
/// Whether we want to expire triangles as they exit our draw area completely.
/// </summary>
protected virtual bool ExpireOffScreenTriangles => true;
/// <summary>
/// Whether we should create new triangles as others expire.
/// </summary>
protected virtual bool CreateNewTriangles => true;
/// <summary>
/// The amount of triangles we want compared to the default distribution.
/// </summary>
protected virtual float SpawnRatio => 1;
private float triangleScale = 1;
public float TriangleScale
@ -29,9 +42,11 @@ namespace osu.Game.Graphics.Backgrounds
get { return triangleScale; }
set
{
float change = value / triangleScale;
triangleScale = value;
Children.ForEach(t => t.ScaleTo(triangleScale));
if (change != 1)
Children.ForEach(t => t.Scale *= change);
}
}
@ -42,20 +57,20 @@ namespace osu.Game.Graphics.Backgrounds
addTriangle(true);
}
private int aimTriangleCount => (int)(DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale));
private int aimTriangleCount => (int)(DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale) * SpawnRatio);
protected override void Update()
{
base.Update();
foreach (Drawable d in Children)
foreach (var t in Children)
{
d.Position -= new Vector2(0, (float)(d.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 950)) / triangleScale);
if (d.DrawPosition.Y + d.DrawSize.Y * d.Scale.Y < 0)
d.Expire();
t.Position -= new Vector2(0, (float)(t.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 950)) / triangleScale);
if (ExpireOffScreenTriangles && t.DrawPosition.Y + t.DrawSize.Y * t.Scale.Y < 0)
t.Expire();
}
while (Children.Count() < aimTriangleCount)
while (CreateNewTriangles && Children.Count() < aimTriangleCount)
addTriangle(false);
}
@ -77,8 +92,8 @@ namespace osu.Game.Graphics.Backgrounds
RelativePositionAxes = Axes.Both,
Scale = new Vector2(scale),
EdgeSmoothness = new Vector2(1),
// Scaling height by 0.866 results in equiangular triangles (== 60° and equal side length)
Colour = GetTriangleShade(),
// Scaling height by 0.866 results in equiangular triangles (== 60° and equal side length)
Size = new Vector2(size, 0.866f * size),
Depth = scale,
};
@ -89,8 +104,8 @@ namespace osu.Game.Graphics.Backgrounds
private void addTriangle(bool randomY)
{
var sprite = CreateTriangle();
var triangleHeight = sprite.DrawHeight / DrawHeight;
sprite.Position = new Vector2(RNG.NextSingle(), randomY ? (RNG.NextSingle() * (1 + triangleHeight) - triangleHeight) : 1);
float triangleHeight = (sprite.DrawHeight / DrawHeight);
sprite.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() * (1 + triangleHeight) - triangleHeight : 1);
Add(sprite);
}
}

View File

@ -24,6 +24,8 @@ namespace osu.Game.Modes.Objects
public HitSampleInfo Sample;
public int ComboIndex;
public virtual void SetDefaultsFromBeatmap(Beatmap beatmap) { }
}
}

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
@ -118,7 +119,7 @@ namespace osu.Game.Overlays.Notifications
RelativeSizeAxes = Axes.Both,
});
Content.Add(textDrawable = new SpriteText
Content.Add(textDrawable = new OsuSpriteText
{
TextSize = 16,
Colour = OsuColour.Gray(128),

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Notifications
{
@ -52,7 +53,7 @@ namespace osu.Game.Overlays.Notifications
}
});
Content.Add(textDrawable = new SpriteText
Content.Add(textDrawable = new OsuSpriteText
{
TextSize = 16,
Colour = OsuColour.Gray(128),

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Audio.Sample;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Pause
{
@ -224,7 +225,7 @@ namespace osu.Game.Overlays.Pause
}
}
},
spriteText = new SpriteText
spriteText = new OsuSpriteText
{
Text = Text,
Anchor = Anchor.Centre,

View File

@ -13,6 +13,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transformations;
using System.Threading.Tasks;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Pause
{
@ -39,14 +40,14 @@ namespace osu.Game.Overlays.Pause
retryCounterContainer.Children = new Drawable[]
{
new SpriteText
new OsuSpriteText
{
Text = "You've retried ",
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f),
TextSize = 18
},
new SpriteText
new OsuSpriteText
{
Text = String.Format("{0:n0}", value),
Font = @"Exo2.0-Bold",
@ -54,7 +55,7 @@ namespace osu.Game.Overlays.Pause
ShadowColour = new Color4(0, 0, 0, 0.25f),
TextSize = 18
},
new SpriteText
new OsuSpriteText
{
Text = $" time{((value == 1) ? "" : "s")} in this session",
Shadow = true,
@ -119,7 +120,7 @@ namespace osu.Game.Overlays.Pause
Anchor = Anchor.TopCentre,
Children = new Drawable[]
{
new SpriteText
new OsuSpriteText
{
Text = @"paused",
Font = @"Exo2.0-Medium",
@ -131,7 +132,7 @@ namespace osu.Game.Overlays.Pause
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f)
},
new SpriteText
new OsuSpriteText
{
Text = @"you're not going to do what i think you're going to do, are ya?",
Origin = Anchor.TopCentre,

View File

@ -12,6 +12,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Select
{
@ -127,7 +128,7 @@ namespace osu.Game.Screens.Select
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
text = new SpriteText
text = new OsuSpriteText
{
Margin = new MarginPadding(5),
TextSize = 14,
@ -213,7 +214,7 @@ namespace osu.Game.Screens.Select
Anchor = Anchor.TopRight,
Children = new Drawable[]
{
sortLabel = new SpriteText
sortLabel = new OsuSpriteText
{
Font = @"Exo2.0-Bold",
Text = "Sort results by",