Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SkinnableDrawables for gameplay objects #398

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using osu.Framework.Graphics.Pooling;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Sentakki.Objects;
using osu.Game.Rulesets.Sentakki.Objects.Drawables.Pieces.Slides;
using osu.Game.Rulesets.Sentakki.Skinning.Default.Slides;
using osu.Game.Rulesets.Sentakki.UI;
using osu.Game.Rulesets.Sentakki.UI.Components;
using osu.Game.Tests.Visual;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Sentakki.Objects;
using osu.Game.Rulesets.Sentakki.Objects.Drawables.Pieces.Slides;
using osu.Game.Rulesets.Sentakki.Skinning.Default.Slides;
using osu.Game.Rulesets.Sentakki.UI;
using osu.Game.Rulesets.Sentakki.UI.Components;
using osu.Game.Tests.Visual;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using osu.Framework.Graphics.Pooling;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Sentakki.Objects;
using osu.Game.Rulesets.Sentakki.Objects.Drawables.Pieces.Slides;
using osu.Game.Rulesets.Sentakki.Skinning.Default.Slides;
using osu.Game.Rulesets.Sentakki.UI;
using osu.Game.Rulesets.Sentakki.UI.Components;
using osu.Game.Tests.Visual;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Sentakki.Objects;
using osu.Game.Rulesets.Sentakki.Objects.Drawables;
using osu.Game.Rulesets.Sentakki.Objects.Drawables.Pieces.Slides;
using osu.Game.Rulesets.Sentakki.Skinning.Default.Slides;
using osu.Game.Rulesets.Sentakki.UI;
using osu.Game.Rulesets.Sentakki.UI.Components;
using osu.Game.Tests.Visual;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Sentakki.Objects;
using osu.Game.Rulesets.Sentakki.Objects.Drawables;
using osu.Game.Rulesets.Sentakki.Objects.Drawables.Pieces.Slides;
using osu.Game.Rulesets.Sentakki.Skinning.Default.Slides;
using osu.Game.Rulesets.Sentakki.UI;
using osu.Game.Rulesets.Sentakki.UI.Components;
using osu.Game.Tests.Visual;
Expand Down
3 changes: 2 additions & 1 deletion osu.Game.Rulesets.Sentakki/Mods/SentakkiModHidden.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using osu.Game.Rulesets.Sentakki.Localisation.Mods;
using osu.Game.Rulesets.Sentakki.Objects;
using osu.Game.Rulesets.Sentakki.Objects.Drawables;
using osu.Game.Rulesets.Sentakki.Skinning.Default.TouchHolds;
using osu.Game.Rulesets.Sentakki.UI;
using osu.Game.Rulesets.UI;
using osuTK;
Expand Down Expand Up @@ -59,7 +60,7 @@ protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject,
break;

case DrawableTouchHold th:
th.TouchHoldBody.ProgressPiece.Hide();
((TouchHoldBody)th.TouchHoldBody.Drawable).ProgressPiece.Hide();
break;

case DrawableSlideBody sb:
Expand Down
21 changes: 15 additions & 6 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableHold.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Sentakki.Objects.Drawables.Pieces;
using osu.Game.Rulesets.Sentakki.Skinning;
using osu.Game.Rulesets.Sentakki.Skinning.Default;
using osu.Game.Rulesets.Sentakki.UI;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;

Expand All @@ -22,7 +24,7 @@ public class DrawableHold : DrawableSentakkiLanedHitObject, IKeyBindingHandler<S

private Container<DrawableHoldHead> headContainer = null!;

public HoldBody NoteBody = null!;
public SkinnableDrawable NoteBody = null!;

public override double LifetimeStart
{
Expand Down Expand Up @@ -54,7 +56,14 @@ private void load()
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
AddRangeInternal(new Drawable[]{
NoteBody = new HoldBody(),
NoteBody = new ProxyableSkinnableDrawable(new SentakkiSkinComponent(SentakkiSkinComponents.Hold), _=> new HoldBody())
{
Scale = Vector2.Zero,
Position = new Vector2(0, -SentakkiPlayfield.NOTESTARTDISTANCE),
Anchor = Anchor.Centre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.None,
},
headContainer = new Container<DrawableHoldHead> { RelativeSizeAxes = Axes.Both },
});
}
Expand All @@ -72,7 +81,7 @@ protected override void UpdateInitialTransforms()
double animTime = AdjustedAnimationDuration / 2;
NoteBody.FadeInFromZero(animTime).ScaleTo(1, animTime);

NoteBody.FadeColour(AccentColour.Value);
NoteBody.Drawable.FadeColour(AccentColour.Value);

using (BeginDelayedSequence(animTime, true))
{
Expand All @@ -90,7 +99,7 @@ protected override void UpdateInitialTransforms()
.ResizeHeightTo(0, stretchTime);

if (HoldStartTime == null && !Auto)
NoteBody.Delay(animTime).FadeColour(Color4.Gray, 100);
NoteBody.Drawable.Delay(animTime).FadeColour(Color4.Gray, 100);
}
}

Expand Down Expand Up @@ -133,7 +142,7 @@ protected override void UpdateHitStateTransforms(ArmedState state)
break;

case ArmedState.Miss:
NoteBody.ScaleTo(0.5f, time_fade_miss, Easing.InCubic)
NoteBody.Drawable.ScaleTo(0.5f, time_fade_miss, Easing.InCubic)
.FadeColour(Color4.Red, time_fade_miss, Easing.OutQuint)
.MoveToOffset(new Vector2(0, -100), time_fade_miss, Easing.OutCubic)
.FadeOut(time_fade_miss);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Sentakki.Objects.Drawables.Pieces.Slides;
using osu.Game.Rulesets.Sentakki.Skinning;
using osu.Game.Rulesets.Sentakki.Skinning.Default.Slides;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;

Expand All @@ -27,7 +29,7 @@ public class DrawableSlideBody : DrawableSentakkiLanedHitObject

public SlideVisual Slidepath { get; private set; } = null!;

public Container<StarPiece> SlideStars { get; private set; } = null!;
public Container<SkinnableDrawable> SlideStars { get; private set; } = null!;

private float starProgress;
public virtual float StarProgress
Expand Down Expand Up @@ -65,7 +67,7 @@ private void load()
AddRangeInternal(new Drawable[]
{
Slidepath = new SlideVisual(),
SlideStars = new Container<StarPiece>{
SlideStars = new Container<SkinnableDrawable>{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
Expand All @@ -77,7 +79,7 @@ private void load()
});

for (int i = 0; i < 3; ++i)
SlideStars.Add(new StarPiece
SlideStars.Add(new ProxyableSkinnableDrawable(new SentakkiSkinComponent(SentakkiSkinComponents.SlideStar), _ => new StarPiece())
{
Alpha = 0,
Scale = Vector2.Zero,
Expand Down Expand Up @@ -220,7 +222,7 @@ protected override void UpdateHitStateTransforms(ArmedState state)
foreach (var star in SlideStars)
star.FadeOut(200);

this.FadeOut(200).Expire();
this.Delay(200).Expire();
}

break;
Expand Down
19 changes: 14 additions & 5 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideTap.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
using System.Linq;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Sentakki.Objects.Drawables.Pieces.Slides;
using osu.Game.Rulesets.Sentakki.Skinning;
using osu.Game.Rulesets.Sentakki.Skinning.Default.Slides;
using osu.Game.Rulesets.Sentakki.UI;
using osuTK;

namespace osu.Game.Rulesets.Sentakki.Objects.Drawables
{
public class DrawableSlideTap : DrawableTap
{
protected override Drawable CreateTapRepresentation() => new SlideTapPiece();
protected override Drawable CreateTapVisual() => new SlideTapPiece()
{
Scale = new Vector2(0f),
Position = new Vector2(0, -SentakkiPlayfield.NOTESTARTDISTANCE),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};

public DrawableSlideTap() : this(null) { }
public DrawableSlideTap(SlideTap? hitObject)
Expand All @@ -16,17 +25,17 @@ protected override void UpdateInitialTransforms()
{
base.UpdateInitialTransforms();

var note = (SlideTapPiece)TapVisual;
var note = (ISlideTapPiece)TapVisual;

double spinDuration = 0;

if (ParentHitObject is DrawableSlide slide)
{
spinDuration = ((Slide)slide.HitObject).SlideInfoList.FirstOrDefault().Duration;
if (slide.SlideBodies.Count > 1)
note.SecondStar.Alpha = 1;
note.Stars[1].Alpha = 1;
else
note.SecondStar.Alpha = 0;
note.Stars[1].Alpha = 0;
}

note.Stars.Spin(spinDuration, RotationDirection.Counterclockwise, 0).Loop();
Expand Down
14 changes: 11 additions & 3 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableTap.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Sentakki.Objects.Drawables.Pieces;
using osu.Game.Rulesets.Sentakki.Skinning;
using osu.Game.Rulesets.Sentakki.Skinning.Default;
using osu.Game.Rulesets.Sentakki.UI;
using osuTK;
using osuTK.Graphics;
Expand All @@ -14,7 +16,13 @@ namespace osu.Game.Rulesets.Sentakki.Objects.Drawables
{
public class DrawableTap : DrawableSentakkiLanedHitObject, IKeyBindingHandler<SentakkiAction>
{
protected virtual Drawable CreateTapRepresentation() => new TapPiece();
protected virtual Drawable CreateTapVisual() => new ProxyableSkinnableDrawable(new SentakkiSkinComponent(SentakkiSkinComponents.Tap), _ => new TapPiece())
{
Scale = new Vector2(0f),
Position = new Vector2(0, -SentakkiPlayfield.NOTESTARTDISTANCE),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};

public override double LifetimeStart
{
Expand Down Expand Up @@ -48,7 +56,7 @@ private void load()
Origin = Anchor.Centre;
Anchor = Anchor.Centre;
AddRangeInternal(new Drawable[] {
TapVisual = CreateTapRepresentation(),
TapVisual = CreateTapVisual()
});
}

Expand Down
21 changes: 16 additions & 5 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Sentakki.Configuration;
using osu.Game.Rulesets.Sentakki.Objects.Drawables.Pieces.Touches;
using osu.Game.Rulesets.Sentakki.Skinning;
using osu.Game.Rulesets.Sentakki.Skinning.Default.Touches;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;

Expand All @@ -24,7 +26,7 @@ public class DrawableTouch : DrawableSentakkiHitObject
// Similar to IsHovered for mouse, this tracks whether a pointer (touch or mouse) is interacting with this drawable
// Interaction == (IsHovered && ActionPressed) || (OnTouch && TouchPointerInBounds)
public bool[] PointInteractionState = new bool[11];
public TouchBody TouchBody = null!;
public SkinnableDrawable TouchBody = null!;

private SentakkiInputManager sentakkiActionInputManager = null!;
internal SentakkiInputManager SentakkiActionInputManager => sentakkiActionInputManager ??= (SentakkiInputManager)GetContainingInputManager();
Expand All @@ -42,7 +44,14 @@ private void load(SentakkiRulesetConfigManager? sentakkiConfigs)
Origin = Anchor.Centre;
Anchor = Anchor.Centre;
AddRangeInternal(new Drawable[]{
TouchBody = new TouchBody(),
TouchBody = new SkinnableDrawable(new SentakkiSkinComponent(SentakkiSkinComponents.Touch), _ => new TouchBody())
{
Size = new Vector2(130),
Alpha = 0,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.None,
},
});

trackedKeys.BindValueChanged(x =>
Expand Down Expand Up @@ -80,7 +89,7 @@ protected override void UpdateInitialTransforms()
using (BeginDelayedSequence(AdjustedAnimationDuration, true))
{
TouchBody.ResizeTo(90, moveTo, Easing.InCirc);
TouchBody.BorderContainer.Delay(moveTo).FadeIn();
((ITouchPiece)TouchBody.Drawable).TouchBorder.Delay(moveTo).FadeIn();
}
}

Expand Down Expand Up @@ -124,9 +133,11 @@ protected override void UpdateHitStateTransforms(ArmedState state)
break;

case ArmedState.Miss:
this.ScaleTo(0.5f, time_fade_miss, Easing.InCubic)
TouchBody.ScaleTo(0.5f, time_fade_miss, Easing.InCubic)
.FadeColour(Color4.Red, time_fade_miss, Easing.OutQuint)
.FadeOut(time_fade_miss);

this.Delay(time_fade_miss).Expire();
break;
}
}
Expand Down
26 changes: 16 additions & 10 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableTouchHold.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Sentakki.Configuration;
using osu.Game.Rulesets.Sentakki.Objects.Drawables.Pieces.TouchHolds;
using osu.Game.Rulesets.Sentakki.Skinning;
using osu.Game.Rulesets.Sentakki.Skinning.Default.TouchHolds;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;
Expand All @@ -30,7 +31,7 @@ public class DrawableTouchHold : DrawableSentakkiHitObject

public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => TouchHoldBody.ReceivePositionalInputAt(screenSpacePos);

public TouchHoldBody TouchHoldBody = null!;
public SkinnableDrawable TouchHoldBody = null!;

private PausableSkinnableSound holdSample = null!;

Expand All @@ -46,10 +47,14 @@ private void load(SentakkiRulesetConfigManager? sentakkiConfigs)
Colour = Color4.SlateGray;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Scale = new Vector2(0f);
Alpha = 0;

AddRangeInternal(new Drawable[] {
TouchHoldBody = new TouchHoldBody(),
TouchHoldBody = new SkinnableDrawable(new SentakkiSkinComponent(SentakkiSkinComponents.TouchHold), _=> new TouchHoldBody())
{
Size = new Vector2(110),
Scale = new Vector2(0f),
Alpha = 0,
},
holdSample = new PausableSkinnableSound
{
Volume = { Value = 0 },
Expand Down Expand Up @@ -102,10 +107,10 @@ protected override void UpdateInitialTransforms()
{
base.UpdateInitialTransforms();
double fadeIn = AdjustedAnimationDuration;
this.FadeInFromZero(fadeIn).ScaleTo(1, fadeIn);
TouchHoldBody.FadeInFromZero(fadeIn).ScaleTo(1, fadeIn);
using (BeginDelayedSequence(fadeIn, true))
{
TouchHoldBody.ProgressPiece.TransformBindableTo(TouchHoldBody.ProgressPiece.ProgressBindable, 1, ((IHasDuration)HitObject).Duration);
((ITouchHoldPiece)TouchHoldBody.Drawable).TransformTo(nameof(ITouchHoldPiece.Progress), 1.0, ((IHasDuration)HitObject).Duration);
}
}

Expand Down Expand Up @@ -172,16 +177,17 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
protected override void UpdateHitStateTransforms(ArmedState state)
{
base.UpdateHitStateTransforms(state);
const double time_fade_hit = 100, time_fade_miss = 400;
const double time_fade_miss = 400;

switch (state)
{
case ArmedState.Hit:
this.Delay(time_fade_hit).Expire();
Expire();
break;

case ArmedState.Miss:
this.ScaleTo(.0f, time_fade_miss).FadeOut(time_fade_miss).Expire();
TouchHoldBody.ScaleTo(.0f, time_fade_miss).FadeOut(time_fade_miss).Expire();
this.Delay(time_fade_miss).Expire();
break;
}
}
Expand Down
Loading