Skip to content

Commit

Permalink
Merge branch 'master' into legacy-tick-not-so-legacy-after-all
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo authored Oct 4, 2023
2 parents d711967 + 844a3b6 commit 854b797
Show file tree
Hide file tree
Showing 18 changed files with 658 additions and 96 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#nullable disable

using System;
using System.Collections.Generic;
using System.Diagnostics;
using JetBrains.Annotations;
using osu.Framework.Allocation;
Expand Down Expand Up @@ -34,6 +35,11 @@ public partial class DrawableHitCircle : DrawableOsuHitObject, IHasApproachCircl
public HitReceptor HitArea { get; private set; }
public SkinnableDrawable CirclePiece { get; private set; }

protected override IEnumerable<Drawable> DimmablePieces => new[]
{
CirclePiece,
};

Drawable IHasApproachCircle.ApproachCircle => ApproachCircle;

private Container scaleContainer;
Expand Down Expand Up @@ -191,7 +197,7 @@ protected override void UpdateInitialTransforms()

CirclePiece.FadeInFromZero(HitObject.TimeFadeIn);

ApproachCircle.FadeIn(Math.Min(HitObject.TimeFadeIn * 2, HitObject.TimePreempt));
ApproachCircle.FadeTo(0.9f, Math.Min(HitObject.TimeFadeIn * 2, HitObject.TimePreempt));
ApproachCircle.ScaleTo(1f, HitObject.TimePreempt);
ApproachCircle.Expire(true);
}
Expand Down
17 changes: 8 additions & 9 deletions osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#nullable disable

using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
Expand Down Expand Up @@ -71,20 +73,17 @@ protected override void OnFree()
ScaleBindable.UnbindFrom(HitObject.ScaleBindable);
}

protected virtual IEnumerable<Drawable> DimmablePieces => Enumerable.Empty<Drawable>();

protected override void UpdateInitialTransforms()
{
base.UpdateInitialTransforms();

// Dim should only be applied at a top level, as it will be implicitly applied to nested objects.
if (ParentHitObject == null)
foreach (var piece in DimmablePieces)
{
// Of note, no one noticed this was missing for years, but it definitely feels like it should still exist.
// For now this is applied across all skins, and matches stable.
// For simplicity, dim colour is applied to the DrawableHitObject itself.
// We may need to make a nested container setup if this even causes a usage conflict (ie. with a mod).
this.FadeColour(new Color4(195, 195, 195, 255));
using (BeginDelayedSequence(InitialLifetimeOffset - OsuHitWindows.MISS_WINDOW))
this.FadeColour(Color4.White, 100);
piece.FadeColour(new Color4(195, 195, 195, 255));
using (piece.BeginDelayedSequence(InitialLifetimeOffset - OsuHitWindows.MISS_WINDOW))
piece.FadeColour(Color4.White, 100);
}
}

Expand Down
8 changes: 8 additions & 0 deletions osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#nullable disable

using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
Expand Down Expand Up @@ -35,6 +36,13 @@ public partial class DrawableSlider : DrawableOsuHitObject

private ShakeContainer shakeContainer;

protected override IEnumerable<Drawable> DimmablePieces => new Drawable[]
{
HeadCircle,
TailCircle,
Body,
};

/// <summary>
/// A target container which can be used to add top level elements to the slider's display.
/// Intended to be used for proxy purposes only.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public partial class DrawableSliderRepeat : DrawableOsuHitObject, ITrackSnaking

public SkinnableDrawable CirclePiece { get; private set; }

public ReverseArrowPiece Arrow { get; private set; }
public SkinnableDrawable Arrow { get; private set; }

private Drawable scaleContainer;

Expand Down Expand Up @@ -65,7 +65,11 @@ private void load()
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
Arrow = new ReverseArrowPiece(),
Arrow = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.ReverseArrow), _ => new DefaultReverseArrow())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
}
});

Expand Down
74 changes: 65 additions & 9 deletions osu.Game.Rulesets.Osu/Skinning/Argon/ArgonReverseArrow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osuTK;
Expand All @@ -17,12 +19,17 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
{
public partial class ArgonReverseArrow : CompositeDrawable
{
[Resolved]
private DrawableHitObject drawableObject { get; set; } = null!;

private Bindable<Color4> accentColour = null!;

private SpriteIcon icon = null!;
private Container main = null!;
private Sprite side = null!;

[BackgroundDependencyLoader]
private void load(DrawableHitObject hitObject)
private void load(TextureStore textures)
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Expand All @@ -31,24 +38,73 @@ private void load(DrawableHitObject hitObject)

InternalChildren = new Drawable[]
{
new Circle
main = new Container
{
Size = new Vector2(40, 20),
Colour = Color4.White,
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
new Circle
{
Size = new Vector2(40, 20),
Colour = Color4.White,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
icon = new SpriteIcon
{
Icon = FontAwesome.Solid.AngleDoubleRight,
Size = new Vector2(16),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
}
},
icon = new SpriteIcon
side = new Sprite
{
Icon = FontAwesome.Solid.AngleDoubleRight,
Size = new Vector2(16),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
Texture = textures.Get("Gameplay/osu/repeat-edge-piece"),
Size = new Vector2(ArgonMainCirclePiece.OUTER_GRADIENT_SIZE),
}
};

accentColour = hitObject.AccentColour.GetBoundCopy();
accentColour = drawableObject.AccentColour.GetBoundCopy();
accentColour.BindValueChanged(accent => icon.Colour = accent.NewValue.Darken(4), true);

drawableObject.ApplyCustomUpdateState += updateStateTransforms;
}

private void updateStateTransforms(DrawableHitObject hitObject, ArmedState state)
{
const float move_distance = -12;
const double move_out_duration = 35;
const double move_in_duration = 250;
const double total = 300;

switch (state)
{
case ArmedState.Idle:
main.ScaleTo(1.3f, move_out_duration, Easing.Out)
.Then()
.ScaleTo(1f, move_in_duration, Easing.Out)
.Loop(total - (move_in_duration + move_out_duration));
side
.MoveToX(move_distance, move_out_duration, Easing.Out)
.Then()
.MoveToX(0, move_in_duration, Easing.Out)
.Loop(total - (move_in_duration + move_out_duration));
break;
}
}

protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);

if (drawableObject.IsNotNull())
drawableObject.ApplyCustomUpdateState -= updateStateTransforms;
}
}
}
69 changes: 69 additions & 0 deletions osu.Game.Rulesets.Osu/Skinning/Default/DefaultReverseArrow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osuTK;

namespace osu.Game.Rulesets.Osu.Skinning.Default
{
public partial class DefaultReverseArrow : CompositeDrawable
{
[Resolved]
private DrawableHitObject drawableObject { get; set; } = null!;

public DefaultReverseArrow()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;

Size = OsuHitObject.OBJECT_DIMENSIONS;

InternalChild = new SpriteIcon
{
RelativeSizeAxes = Axes.Both,
Blending = BlendingParameters.Additive,
Icon = FontAwesome.Solid.ChevronRight,
Size = new Vector2(0.35f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};
}

[BackgroundDependencyLoader]
private void load()
{
drawableObject.ApplyCustomUpdateState += updateStateTransforms;
}

private void updateStateTransforms(DrawableHitObject hitObject, ArmedState state)
{
const double move_out_duration = 35;
const double move_in_duration = 250;
const double total = 300;

switch (state)
{
case ArmedState.Idle:
InternalChild.ScaleTo(1.3f, move_out_duration, Easing.Out)
.Then()
.ScaleTo(1f, move_in_duration, Easing.Out)
.Loop(total - (move_in_duration + move_out_duration));
break;
}
}

protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);

if (drawableObject.IsNotNull())
drawableObject.ApplyCustomUpdateState -= updateStateTransforms;
}
}
}
51 changes: 0 additions & 51 deletions osu.Game.Rulesets.Osu/Skinning/Default/ReverseArrowPiece.cs

This file was deleted.

Loading

0 comments on commit 854b797

Please sign in to comment.