Skip to content

Commit

Permalink
Use skinnable drawables in DHOs
Browse files Browse the repository at this point in the history
  • Loading branch information
LumpBloom7 committed Sep 23, 2022
1 parent fd9b985 commit 435a7f8
Show file tree
Hide file tree
Showing 20 changed files with 220 additions and 134 deletions.
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
19 changes: 14 additions & 5 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.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 @@ -21,7 +23,7 @@ public class DrawableHold : DrawableSentakkiLanedHitObject, IKeyBindingHandler<S

private Container<DrawableHoldHead> headContainer;

public HoldBody NoteBody;
public SkinnableDrawable NoteBody;

public override double LifetimeStart
{
Expand Down Expand Up @@ -53,7 +55,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 @@ -71,7 +80,7 @@ protected override void UpdateInitialTransforms()
double animTime = AdjustedAnimationDuration / 2;
NoteBody.FadeInFromZero(animTime).ScaleTo(1, animTime);

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

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

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

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

case ArmedState.Miss:
NoteBody.ScaleTo(0.5f, time_fade_miss, Easing.InCubic)
((HoldBody)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.Skinning;
using osu.Game.Rulesets.Sentakki.Skinning.Default.Slides;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;

Expand All @@ -26,7 +28,7 @@ public class DrawableSlideBody : DrawableSentakkiLanedHitObject
public Container<DrawableSlideCheckpoint> SlideCheckpoints { get; private set; }

public ISlideVisual Slidepath;
public Container<StarPiece> SlideStars;
public Container<SkinnableDrawable> SlideStars;

protected float StarProg;
public virtual float StarProgress
Expand All @@ -51,7 +53,7 @@ public DrawableSlideBody(SlideBody hitObject)

protected virtual void CreateSlideStars()
{
SlideStars.Add(new StarPiece
SlideStars.Add(new ProxyableSkinnableDrawable(new SentakkiSkinComponent(SentakkiSkinComponents.SlideStar), _ => new StarPiece())
{
Alpha = 0,
Scale = Vector2.Zero,
Expand All @@ -78,7 +80,7 @@ private void load()
AddRangeInternal(new Drawable[]
{
(Drawable)Slidepath,
SlideStars = new Container<StarPiece>{
SlideStars = new Container<SkinnableDrawable>{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
Expand Down Expand Up @@ -212,7 +214,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
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using osu.Game.Rulesets.Sentakki.Skinning;
using osu.Game.Rulesets.Sentakki.Skinning.Default.Slides;
using osu.Game.Rulesets.Sentakki.UI;
using osu.Game.Skinning;
using osuTK;

namespace osu.Game.Rulesets.Sentakki.Objects.Drawables
Expand Down Expand Up @@ -36,7 +38,7 @@ public DrawableSlideFan(SlideFan hitObject)
protected override void CreateSlideStars()
{
for (int i = 0; i < 3; ++i)
SlideStars.Add(new StarPiece
SlideStars.Add(new SkinnableDrawable(new SentakkiSkinComponent(SentakkiSkinComponents.SlideStar), _ => new StarPiece())
{
Y = -SentakkiPlayfield.INTERSECTDISTANCE,
Alpha = 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using System.Linq;
using System;
using System.Linq;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Sentakki.Skinning;
using osu.Game.Rulesets.Sentakki.Skinning.Default.Slides;

namespace osu.Game.Rulesets.Sentakki.Objects.Drawables
{
public class DrawableSlideTap : DrawableTap
{
protected override Drawable CreateTapRepresentation() => new SlideTapPiece();
protected override SentakkiSkinComponents TapPieceComponent => SentakkiSkinComponents.SlideStar;
protected override Type fallbackPieceType => typeof(SlideTapPiece);

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

var note = TapVisual as SlideTapPiece;
var note = TapVisual.Drawable as SlideTapPiece;

double spinDuration = 0;

Expand Down
16 changes: 13 additions & 3 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableTap.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
using System;
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.Skinning;
using osu.Game.Rulesets.Sentakki.Skinning.Default;
using osu.Game.Rulesets.Sentakki.UI;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Sentakki.Objects.Drawables
{
public class DrawableTap : DrawableSentakkiLanedHitObject, IKeyBindingHandler<SentakkiAction>
{
protected virtual Drawable CreateTapRepresentation() => new TapPiece();
protected virtual SentakkiSkinComponents TapPieceComponent => SentakkiSkinComponents.Tap;
protected virtual Type fallbackPieceType => typeof(TapPiece);

public override double LifetimeStart
{
Expand All @@ -35,7 +39,7 @@ public override double LifetimeEnd
}
}

public Drawable TapVisual;
public SkinnableDrawable TapVisual;

public DrawableTap() : this(null) { }

Expand All @@ -48,7 +52,13 @@ private void load()
Origin = Anchor.Centre;
Anchor = Anchor.Centre;
AddRangeInternal(new Drawable[] {
TapVisual = CreateTapRepresentation(),
TapVisual = new ProxyableSkinnableDrawable(new SentakkiSkinComponent(TapPieceComponent), _ => (Drawable)Activator.CreateInstance(fallbackPieceType))
{
Scale = new Vector2(0f),
Position = new Vector2(0, -SentakkiPlayfield.NOTESTARTDISTANCE),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
});
}

Expand Down
19 changes: 15 additions & 4 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.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;
public SkinnableDrawable TouchBody;

private SentakkiInputManager sentakkiActionInputManager;
internal SentakkiInputManager SentakkiActionInputManager => sentakkiActionInputManager ??= GetContainingInputManager() as SentakkiInputManager;
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();
((TouchBody)TouchBody.Drawable).BorderContainer.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
24 changes: 15 additions & 9 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableTouchHold.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Sentakki.Configuration;
using osu.Game.Rulesets.Sentakki.Skinning;
using osu.Game.Rulesets.Sentakki.Skinning.Default.TouchHolds;
using osu.Game.Skinning;
using osuTK;
Expand All @@ -28,7 +29,7 @@ public class DrawableTouchHold : DrawableSentakkiHitObject

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

public TouchHoldBody TouchHoldBody;
public SkinnableDrawable TouchHoldBody;

private PausableSkinnableSound holdSample;

Expand All @@ -44,10 +45,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 @@ -100,10 +105,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);
((TouchHoldBody)TouchHoldBody.Drawable).ProgressPiece.TransformBindableTo(((TouchHoldBody)TouchHoldBody.Drawable).ProgressPiece.ProgressBindable, 1, ((IHasDuration)HitObject).Duration);
}
}

Expand Down Expand Up @@ -170,16 +175,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
5 changes: 4 additions & 1 deletion osu.Game.Rulesets.Sentakki/SentakkiRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ private static readonly Lazy<bool> is_development_build

public override string Description => IsDevelopmentBuild ? "sentakki (Dev build)" : "sentakki";
public override string PlayingVerb => "Washing laundry";
public override string ShortName => "Sentakki";

public const string SHORT_NAME = "Sentakki";

public override string ShortName => SHORT_NAME;

public override ScoreProcessor CreateScoreProcessor() => new SentakkiScoreProcessor(this);

Expand Down
8 changes: 1 addition & 7 deletions osu.Game.Rulesets.Sentakki/Skinning/Default/HoldBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,17 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Sentakki.UI;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Sentakki.Skinning.Default
{
public class HoldBody : CompositeDrawable
{
// This will be proxied, so a must.
public override bool RemoveWhenNotAlive => false;

public HoldBody()
{
Scale = Vector2.Zero;
Position = new Vector2(0, -SentakkiPlayfield.NOTESTARTDISTANCE);
Anchor = Anchor.Centre;
Origin = Anchor.BottomCentre;
RelativeSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
new NoteRingPiece(),
Expand Down
Loading

0 comments on commit 435a7f8

Please sign in to comment.