Skip to content

Commit

Permalink
Merge pull request #361 from peppy/general-hitobject-improvements
Browse files Browse the repository at this point in the history
General HitObject improvements.
  • Loading branch information
Tom94 committed Feb 15, 2017
2 parents 7fc0358 + 25f65a9 commit d3335f7
Show file tree
Hide file tree
Showing 21 changed files with 191 additions and 101 deletions.
2 changes: 1 addition & 1 deletion osu-framework
Submodule osu-framework updated 71 files
+0 −1 osu.Framework/Audio/AdjustableAudioComponent.cs
+0 −2 osu.Framework/Audio/AudioCollectionManager.cs
+8 −9 osu.Framework/Audio/AudioManager.cs
+0 −2 osu.Framework/Audio/Sample/AudioSample.cs
+0 −1 osu.Framework/Audio/Track/TrackManager.cs
+0 −2 osu.Framework/BaseGame.cs
+0 −1 osu.Framework/Caching/Cached.cs
+32 −0 osu.Framework/Extensions/Color4Extensions/Color4Extensions.cs
+1 −2 osu.Framework/GameModes/Testing/TestBrowser.cs
+0 −4 osu.Framework/Graphics/Colour/SRGBColour.cs
+2 −3 osu.Framework/Graphics/Containers/BufferedContainer.cs
+1 −3 osu.Framework/Graphics/Containers/Container.cs
+0 −1 osu.Framework/Graphics/Containers/FocusedOverlayContainer.cs
+5 −5 osu.Framework/Graphics/Containers/OverlayContainer.cs
+0 −1 osu.Framework/Graphics/DrawInfo.cs
+0 −1 osu.Framework/Graphics/Drawable.cs
+3 −3 osu.Framework/Graphics/Drawable_Interaction.cs
+0 −2 osu.Framework/Graphics/Drawable_TransformationHelpers.cs
+1 −2 osu.Framework/Graphics/Line/Path.cs
+0 −2 osu.Framework/Graphics/OpenGL/Textures/TextureGL.cs
+0 −2 osu.Framework/Graphics/OpenGL/Textures/TextureGLAtlasWhite.cs
+0 −2 osu.Framework/Graphics/OpenGL/Textures/TextureGLSingle.cs
+0 −2 osu.Framework/Graphics/Performance/FpsDisplay.cs
+0 −2 osu.Framework/Graphics/Performance/FrameStatisticsDisplay.cs
+0 −3 osu.Framework/Graphics/Performance/PerformanceOverlay.cs
+3 −6 osu.Framework/Graphics/Primitives/MarginPadding.cs
+1 −5 osu.Framework/Graphics/Primitives/Quad.cs
+4 −3 osu.Framework/Graphics/Shaders/ShaderManager.cs
+0 −1 osu.Framework/Graphics/Shaders/UniformBase.cs
+10 −8 osu.Framework/Graphics/Sprites/SpriteText.cs
+0 −2 osu.Framework/Graphics/Textures/RawTexture.cs
+0 −2 osu.Framework/Graphics/Textures/Texture.cs
+0 −2 osu.Framework/Graphics/Transformations/Transform.cs
+0 −1 osu.Framework/Graphics/Transformations/TransformColour.cs
+0 −1 osu.Framework/Graphics/Transformations/TransformFloat.cs
+0 −2 osu.Framework/Graphics/Transformations/TransformPosition.cs
+0 −1 osu.Framework/Graphics/Transformations/TransformPositionX.cs
+0 −1 osu.Framework/Graphics/Transformations/TransformPositionY.cs
+0 −2 osu.Framework/Graphics/Transformations/TransformRotation.cs
+0 −2 osu.Framework/Graphics/Transformations/TransformScale.cs
+0 −2 osu.Framework/Graphics/Transformations/TransformSize.cs
+0 −1 osu.Framework/Graphics/Transformations/TransformVector.cs
+0 −1 osu.Framework/Graphics/UserInterface/BasicCheckBox.cs
+0 −5 osu.Framework/Graphics/UserInterface/BasicSliderBar.cs
+1 −2 osu.Framework/Graphics/UserInterface/Button.cs
+1 −2 osu.Framework/Graphics/UserInterface/DropDownHeader.cs
+0 −1 osu.Framework/Graphics/UserInterface/DropDownMenu.cs
+1 −4 osu.Framework/Graphics/UserInterface/DropDownMenuItem.cs
+0 −6 osu.Framework/Graphics/UserInterface/PasswordTextBox.cs
+2 −2 osu.Framework/Graphics/UserInterface/TextBox.cs
+0 −1 osu.Framework/Graphics/Visualisation/DrawVisualiser.cs
+0 −2 osu.Framework/Graphics/Visualisation/InfoOverlay.cs
+0 −1 osu.Framework/Graphics/Visualisation/LogOverlay.cs
+1 −2 osu.Framework/Graphics/Visualisation/VisualisedDrawable.cs
+1 −1 osu.Framework/IO/File/FileSafety.cs
+2 −2 osu.Framework/IO/Network/WebRequest.cs
+2 −3 osu.Framework/IO/Stores/GlyphStore.cs
+2 −1 osu.Framework/IO/Stores/OnlineStore.cs
+0 −4 osu.Framework/IStateful.cs
+0 −4 osu.Framework/Input/InputManager.cs
+0 −2 osu.Framework/Input/MouseState.cs
+0 −1 osu.Framework/Input/UserInputManager.cs
+0 −2 osu.Framework/Lists/SortedList.cs
+0 −1 osu.Framework/MathUtils/Interpolation.cs
+0 −4 osu.Framework/Platform/BasicGameHost.cs
+0 −1 osu.Framework/Platform/BasicGameWindow.cs
+0 −6 osu.Framework/Platform/Clipboard.cs
+0 −1 osu.Framework/Platform/IpcMessage.cs
+0 −2 osu.Framework/Statistics/FrameStatistics.cs
+0 −1 osu.Framework/Statistics/PerformanceMonitor.cs
+4 −4 osu.Framework/Threading/SleepScheduler.cs
7 changes: 6 additions & 1 deletion osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ public DrawableHitCircle(OsuHitObject h) : base(h)
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
Expand Down Expand Up @@ -124,6 +127,8 @@ protected override void UpdateState(ArmedState state)
base.UpdateState(state);

ApproachCircle.FadeOut();

glow.Delay(osuObject.Duration);
glow.FadeOut(400);

switch (state)
Expand Down
2 changes: 2 additions & 0 deletions osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ public DrawableSlider(Slider s) : base(s)
},
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,
Expand Down
31 changes: 23 additions & 8 deletions osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,8 +19,8 @@ public class DrawableSpinner : DrawableOsuHitObject

private SpinnerDisc disc;
private SpinnerBackground background;
private Container circleContainer;
private DrawableHitCircle circle;
private NumberPiece number;

public DrawableSpinner(Spinner s) : base(s)
{
Expand Down Expand Up @@ -47,16 +48,23 @@ public DrawableSpinner(Spinner s) : base(s)
Origin = Anchor.Centre,
DiscColour = s.Colour
},
circle = new DrawableHitCircle(s)
circleContainer = new Container
{
Interactive = false,
Position = Vector2.Zero,
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;
}
Expand All @@ -71,6 +79,9 @@ protected override void CheckJudgement(bool userTriggered)

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)
Expand All @@ -91,7 +102,8 @@ protected override void CheckJudgement(bool userTriggered)
else
{
j.Score = OsuScoreResult.Miss;
j.Result = HitResult.Miss;
if (Time.Current >= HitObject.EndTime)
j.Result = HitResult.Miss;
}
}
}
Expand All @@ -109,6 +121,7 @@ protected override void UpdatePreemptState()
base.UpdatePreemptState();

FadeIn(200);
circleContainer.ScaleTo(1, 400, EasingTypes.OutElastic);

background.Delay(TIME_PREEMPT - 100);
background.FadeIn(200);
Expand All @@ -120,12 +133,14 @@ protected override void UpdatePreemptState()

protected override void UpdateState(ArmedState state)
{
if (!IsLoaded) return;

base.UpdateState(state);

Delay(HitObject.Duration, true);

FadeOut(160);

switch (state)
{
case ArmedState.Hit:
Expand Down
5 changes: 3 additions & 2 deletions osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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;
Expand All @@ -30,15 +31,15 @@ public HitExplosion(OsuJudgementInfo judgement, OsuHitObject h = null)

Children = new Drawable[]
{
line1 = new SpriteText
line1 = new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = judgement.Score.GetDescription(),
Font = @"Venera",
TextSize = 16,
},
line2 = new SpriteText
line2 = new OsuSpriteText
{
Text = judgement.Combo.GetDescription(),
Font = @"Venera",
Expand Down
8 changes: 4 additions & 4 deletions osu.Game.Modes.Osu/Objects/Drawables/Pieces/CirclePiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -36,10 +35,11 @@ public CirclePiece()
Anchor = Anchor.Centre,
Origin = Anchor.Centre
},
triangles = new Triangles
new TrianglesPiece
{
RelativeSizeAxes = Axes.Both,
BlendingMode = BlendingMode.Additive,
RelativeSizeAxes = Axes.Both
Alpha = 0.5f,
}
};
}
Expand Down
5 changes: 3 additions & 2 deletions osu.Game.Modes.Osu/Objects/Drawables/Pieces/ExplodePiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ public ExplodePiece()

Children = new Drawable[]
{
new Triangles
new TrianglesPiece
{
BlendingMode = BlendingMode.Additive,
RelativeSizeAxes = Axes.Both
RelativeSizeAxes = Axes.Both,
Alpha = 0.1f,
}
};
}
Expand Down
39 changes: 30 additions & 9 deletions osu.Game.Modes.Osu/Objects/Drawables/Pieces/NumberPiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,54 @@
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[]
Children = new Drawable[]
{
number = new Sprite
new CircularContainer
{
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Glow,
Radius = 60,
Colour = Color4.White.Opacity(0.5f),
},
Children = new[]
{
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");
}
}
}
9 changes: 4 additions & 5 deletions osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

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;
Expand Down Expand Up @@ -39,7 +39,7 @@ public SliderBall(Slider slider)
Height = width,
Alpha = 0,
},
new Container
new CircularContainer
{
Masking = true,
AutoSizeAxes = Axes.Both,
Expand All @@ -48,7 +48,6 @@ public SliderBall(Slider slider)
BorderThickness = 10,
BorderColour = Color4.White,
Alpha = 1,
CornerRadius = width / 2,
Children = new[]
{
new Box
Expand Down Expand Up @@ -104,8 +103,8 @@ protected override void Update()
{
base.Update();

CornerRadius = DrawWidth / 2;
Tracking = canCurrentlyTrack && lastState != null && Contains(lastState.Mouse.NativeState.Position) && lastState.Mouse.HasMainButtonPressed;
if (Time.Current < slider.EndTime)
Tracking = canCurrentlyTrack && lastState != null && Contains(lastState.Mouse.NativeState.Position) && lastState.Mouse.HasMainButtonPressed;
}

public void UpdateProgress(double progress, int repeat)
Expand Down
38 changes: 38 additions & 0 deletions osu.Game.Modes.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
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;

Expand All @@ -27,6 +29,14 @@ public SRGBColour DiscColour
set { Disc.Colour = value; }
}

Color4 completeColour;

[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
completeColour = colours.YellowLight.Opacity(0.8f);
}

class SpinnerBorder : Container
{
public SpinnerBorder()
Expand Down Expand Up @@ -120,6 +130,22 @@ public bool Tracking
}
}

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;
Expand All @@ -145,6 +171,10 @@ protected override bool OnMouseMove(InputState state)
private float currentRotation;
public float RotationAbsolute;

private int completeTick;

private bool updateCompleteTick() => completeTick != (completeTick = (int)(RotationAbsolute / 720));

protected override void Update()
{
base.Update();
Expand All @@ -162,6 +192,14 @@ protected override void Update()
}
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);
}
}
Expand Down

0 comments on commit d3335f7

Please sign in to comment.