From 865c5c06766d76110aeb118dee47d74d1cb3637b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 10 Jun 2021 15:47:03 +0900 Subject: [PATCH] Use `[Resolved]` to simplify bindable resolution --- .../Skinning/Legacy/LegacyCatcherNew.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyCatcherNew.cs b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyCatcherNew.cs index 0a7d877627..2bf8b28aa2 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyCatcherNew.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyCatcherNew.cs @@ -19,7 +19,8 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy { public class LegacyCatcherNew : CompositeDrawable, ICatcherSprite { - public Bindable CurrentState { get; } = new Bindable(); + [Resolved] + private Bindable currentState { get; set; } public Texture CurrentTexture => (currentDrawable as TextureAnimation)?.CurrentFrame ?? (currentDrawable as Sprite)?.Texture; @@ -33,7 +34,7 @@ public LegacyCatcherNew() } [BackgroundDependencyLoader] - private void load(ISkinSource skin, Bindable currentState) + private void load(ISkinSource skin) { foreach (var state in Enum.GetValues(typeof(CatcherAnimationState)).Cast()) { @@ -53,15 +54,13 @@ private void load(ISkinSource skin, Bindable currentState Drawable getDrawableFor(CatcherAnimationState state) => skin.GetAnimation(@$"fruit-catcher-{state.ToString().ToLowerInvariant()}", true, true, true) ?? skin.GetAnimation(@"fruit-catcher-idle", true, true, true); - - CurrentState.BindTo(currentState); } protected override void LoadComplete() { base.LoadComplete(); - CurrentState.BindValueChanged(state => + currentState.BindValueChanged(state => { currentDrawable.Alpha = 0; currentDrawable = drawables[state.NewValue];