mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 17:37:23 +09:00
Merge pull request #6275 from smoogipoo/comboinformation-bindables
Add bindable versions of IHasComboInformation properties
This commit is contained in:
commit
12b027f2c3
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Rulesets.Catch.Beatmaps;
|
using osu.Game.Rulesets.Catch.Beatmaps;
|
||||||
@ -37,9 +38,21 @@ namespace osu.Game.Rulesets.Catch.Objects
|
|||||||
|
|
||||||
public int ComboOffset { get; set; }
|
public int ComboOffset { get; set; }
|
||||||
|
|
||||||
public int IndexInCurrentCombo { get; set; }
|
public Bindable<int> IndexInCurrentComboBindable { get; } = new Bindable<int>();
|
||||||
|
|
||||||
public int ComboIndex { get; set; }
|
public int IndexInCurrentCombo
|
||||||
|
{
|
||||||
|
get => IndexInCurrentComboBindable.Value;
|
||||||
|
set => IndexInCurrentComboBindable.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bindable<int> ComboIndexBindable { get; } = new Bindable<int>();
|
||||||
|
|
||||||
|
public int ComboIndex
|
||||||
|
{
|
||||||
|
get => ComboIndexBindable.Value;
|
||||||
|
set => ComboIndexBindable.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Difference between the distance to the next object
|
/// Difference between the distance to the next object
|
||||||
@ -48,10 +61,16 @@ namespace osu.Game.Rulesets.Catch.Objects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float DistanceToHyperDash { get; set; }
|
public float DistanceToHyperDash { get; set; }
|
||||||
|
|
||||||
|
public Bindable<bool> LastInComboBindable { get; } = new Bindable<bool>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The next fruit starts a new combo. Used for explodey.
|
/// The next fruit starts a new combo. Used for explodey.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool LastInCombo { get; set; }
|
public virtual bool LastInCombo
|
||||||
|
{
|
||||||
|
get => LastInComboBindable.Value;
|
||||||
|
set => LastInComboBindable.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
public float Scale { get; set; } = 1;
|
public float Scale { get; set; } = 1;
|
||||||
|
|
||||||
|
26
osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleComboChange.cs
Normal file
26
osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleComboChange.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// 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.Bindables;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
|
{
|
||||||
|
public class TestSceneHitCircleComboChange : TestSceneHitCircle
|
||||||
|
{
|
||||||
|
private readonly Bindable<int> comboIndex = new Bindable<int>();
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
Scheduler.AddDelayed(() => comboIndex.Value++, 250, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override TestDrawableHitCircle CreateDrawableHitCircle(HitCircle circle, bool auto)
|
||||||
|
{
|
||||||
|
circle.ComboIndexBindable.BindTo(comboIndex);
|
||||||
|
circle.IndexInCurrentComboBindable.BindTo(comboIndex);
|
||||||
|
return base.CreateDrawableHitCircle(circle, auto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -297,11 +297,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
slider.ApplyDefaults(cpi, new BeatmapDifficulty { CircleSize = circleSize, SliderTickRate = 3 });
|
slider.ApplyDefaults(cpi, new BeatmapDifficulty { CircleSize = circleSize, SliderTickRate = 3 });
|
||||||
|
|
||||||
var drawable = new DrawableSlider(slider)
|
var drawable = CreateDrawableSlider(slider);
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Depth = depthIndex++
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var mod in Mods.Value.OfType<IApplicableToDrawableHitObjects>())
|
foreach (var mod in Mods.Value.OfType<IApplicableToDrawableHitObjects>())
|
||||||
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
||||||
@ -311,6 +307,12 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
return drawable;
|
return drawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual DrawableSlider CreateDrawableSlider(Slider slider) => new DrawableSlider(slider)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Depth = depthIndex++
|
||||||
|
};
|
||||||
|
|
||||||
private float judgementOffsetDirection = 1;
|
private float judgementOffsetDirection = 1;
|
||||||
|
|
||||||
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
||||||
|
28
osu.Game.Rulesets.Osu.Tests/TestSceneSliderComboChange.cs
Normal file
28
osu.Game.Rulesets.Osu.Tests/TestSceneSliderComboChange.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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.Bindables;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
|
{
|
||||||
|
public class TestSceneSliderComboChange : TestSceneSlider
|
||||||
|
{
|
||||||
|
private readonly Bindable<int> comboIndex = new Bindable<int>();
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
Scheduler.AddDelayed(() => comboIndex.Value++, 250, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DrawableSlider CreateDrawableSlider(Slider slider)
|
||||||
|
{
|
||||||
|
slider.ComboIndexBindable.BindTo(comboIndex);
|
||||||
|
slider.IndexInCurrentComboBindable.BindTo(comboIndex);
|
||||||
|
|
||||||
|
return base.CreateDrawableSlider(slider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -59,7 +59,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CirclePiece = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.HitCircle), _ => new MainCirclePiece(HitObject.IndexInCurrentCombo)),
|
CirclePiece = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.HitCircle), _ => new MainCirclePiece()),
|
||||||
ApproachCircle = new ApproachCircle
|
ApproachCircle = new ApproachCircle
|
||||||
{
|
{
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
private readonly NumberPiece number;
|
private readonly NumberPiece number;
|
||||||
private readonly GlowPiece glow;
|
private readonly GlowPiece glow;
|
||||||
|
|
||||||
public MainCirclePiece(int index)
|
public MainCirclePiece()
|
||||||
{
|
{
|
||||||
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
||||||
|
|
||||||
@ -31,10 +31,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
{
|
{
|
||||||
glow = new GlowPiece(),
|
glow = new GlowPiece(),
|
||||||
circle = new CirclePiece(),
|
circle = new CirclePiece(),
|
||||||
number = new NumberPiece
|
number = new NumberPiece(),
|
||||||
{
|
|
||||||
Text = (index + 1).ToString(),
|
|
||||||
},
|
|
||||||
ring = new RingPiece(),
|
ring = new RingPiece(),
|
||||||
flash = new FlashPiece(),
|
flash = new FlashPiece(),
|
||||||
explode = new ExplodePiece(),
|
explode = new ExplodePiece(),
|
||||||
@ -42,12 +39,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly IBindable<ArmedState> state = new Bindable<ArmedState>();
|
private readonly IBindable<ArmedState> state = new Bindable<ArmedState>();
|
||||||
|
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
|
||||||
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
|
private readonly IBindable<int> indexInCurrentCombo = new Bindable<int>();
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(DrawableHitObject drawableObject)
|
private void load(DrawableHitObject drawableObject)
|
||||||
{
|
{
|
||||||
|
OsuHitObject osuObject = (OsuHitObject)drawableObject.HitObject;
|
||||||
|
|
||||||
state.BindTo(drawableObject.State);
|
state.BindTo(drawableObject.State);
|
||||||
state.BindValueChanged(updateState, true);
|
state.BindValueChanged(updateState, true);
|
||||||
|
|
||||||
@ -58,6 +57,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
glow.Colour = colour.NewValue;
|
glow.Colour = colour.NewValue;
|
||||||
circle.Colour = colour.NewValue;
|
circle.Colour = colour.NewValue;
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
indexInCurrentCombo.BindTo(osuObject.IndexInCurrentComboBindable);
|
||||||
|
indexInCurrentCombo.BindValueChanged(index => number.Text = (index.NewValue + 1).ToString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateState(ValueChangedEvent<ArmedState> state)
|
private void updateState(ValueChangedEvent<ArmedState> state)
|
||||||
|
@ -58,13 +58,37 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
|
|
||||||
public virtual bool NewCombo { get; set; }
|
public virtual bool NewCombo { get; set; }
|
||||||
|
|
||||||
public int ComboOffset { get; set; }
|
public readonly Bindable<int> ComboOffsetBindable = new Bindable<int>();
|
||||||
|
|
||||||
public virtual int IndexInCurrentCombo { get; set; }
|
public int ComboOffset
|
||||||
|
{
|
||||||
|
get => ComboOffsetBindable.Value;
|
||||||
|
set => ComboOffsetBindable.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual int ComboIndex { get; set; }
|
public Bindable<int> IndexInCurrentComboBindable { get; } = new Bindable<int>();
|
||||||
|
|
||||||
public bool LastInCombo { get; set; }
|
public virtual int IndexInCurrentCombo
|
||||||
|
{
|
||||||
|
get => IndexInCurrentComboBindable.Value;
|
||||||
|
set => IndexInCurrentComboBindable.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bindable<int> ComboIndexBindable { get; } = new Bindable<int>();
|
||||||
|
|
||||||
|
public virtual int ComboIndex
|
||||||
|
{
|
||||||
|
get => ComboIndexBindable.Value;
|
||||||
|
set => ComboIndexBindable.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bindable<bool> LastInComboBindable { get; } = new Bindable<bool>();
|
||||||
|
|
||||||
|
public bool LastInCombo
|
||||||
|
{
|
||||||
|
get => LastInComboBindable.Value;
|
||||||
|
set => LastInComboBindable.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||||
{
|
{
|
||||||
|
@ -33,28 +33,6 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
|
|
||||||
public Vector2 StackedPositionAt(double t) => StackedPosition + this.CurvePositionAt(t);
|
public Vector2 StackedPositionAt(double t) => StackedPosition + this.CurvePositionAt(t);
|
||||||
|
|
||||||
public override int ComboIndex
|
|
||||||
{
|
|
||||||
get => base.ComboIndex;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
base.ComboIndex = value;
|
|
||||||
foreach (var n in NestedHitObjects.OfType<IHasComboInformation>())
|
|
||||||
n.ComboIndex = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int IndexInCurrentCombo
|
|
||||||
{
|
|
||||||
get => base.IndexInCurrentCombo;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
base.IndexInCurrentCombo = value;
|
|
||||||
foreach (var n in NestedHitObjects.OfType<IHasComboInformation>())
|
|
||||||
n.IndexInCurrentCombo = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public readonly Bindable<SliderPath> PathBindable = new Bindable<SliderPath>();
|
public readonly Bindable<SliderPath> PathBindable = new Bindable<SliderPath>();
|
||||||
|
|
||||||
public SliderPath Path
|
public SliderPath Path
|
||||||
@ -192,8 +170,6 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
Position = Position,
|
Position = Position,
|
||||||
Samples = getNodeSamples(0),
|
Samples = getNodeSamples(0),
|
||||||
SampleControlPoint = SampleControlPoint,
|
SampleControlPoint = SampleControlPoint,
|
||||||
IndexInCurrentCombo = IndexInCurrentCombo,
|
|
||||||
ComboIndex = ComboIndex,
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -205,8 +181,6 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
{
|
{
|
||||||
StartTime = e.Time,
|
StartTime = e.Time,
|
||||||
Position = EndPosition,
|
Position = EndPosition,
|
||||||
IndexInCurrentCombo = IndexInCurrentCombo,
|
|
||||||
ComboIndex = ComboIndex,
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ using osu.Framework.Graphics.Sprites;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -25,13 +24,16 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly IBindable<ArmedState> state = new Bindable<ArmedState>();
|
private readonly IBindable<ArmedState> state = new Bindable<ArmedState>();
|
||||||
|
|
||||||
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
|
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
|
||||||
|
private readonly IBindable<int> indexInCurrentCombo = new Bindable<int>();
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(DrawableHitObject drawableObject, ISkinSource skin)
|
private void load(DrawableHitObject drawableObject, ISkinSource skin)
|
||||||
{
|
{
|
||||||
|
OsuHitObject osuObject = (OsuHitObject)drawableObject.HitObject;
|
||||||
|
|
||||||
Sprite hitCircleSprite;
|
Sprite hitCircleSprite;
|
||||||
|
SkinnableSpriteText hitCircleText;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -42,14 +44,11 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
},
|
},
|
||||||
new SkinnableSpriteText(new OsuSkinComponent(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText
|
hitCircleText = new SkinnableSpriteText(new OsuSkinComponent(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText
|
||||||
{
|
{
|
||||||
Font = OsuFont.Numeric.With(size: 40),
|
Font = OsuFont.Numeric.With(size: 40),
|
||||||
UseFullGlyphHeight = false,
|
UseFullGlyphHeight = false,
|
||||||
}, confineMode: ConfineMode.NoScaling)
|
}, confineMode: ConfineMode.NoScaling),
|
||||||
{
|
|
||||||
Text = (((IHasComboInformation)drawableObject.HitObject).IndexInCurrentCombo + 1).ToString()
|
|
||||||
},
|
|
||||||
new Sprite
|
new Sprite
|
||||||
{
|
{
|
||||||
Texture = skin.GetTexture("hitcircleoverlay"),
|
Texture = skin.GetTexture("hitcircleoverlay"),
|
||||||
@ -63,6 +62,9 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
|
|
||||||
accentColour.BindTo(drawableObject.AccentColour);
|
accentColour.BindTo(drawableObject.AccentColour);
|
||||||
accentColour.BindValueChanged(colour => hitCircleSprite.Colour = colour.NewValue, true);
|
accentColour.BindValueChanged(colour => hitCircleSprite.Colour = colour.NewValue, true);
|
||||||
|
|
||||||
|
indexInCurrentCombo.BindTo(osuObject.IndexInCurrentComboBindable);
|
||||||
|
indexInCurrentCombo.BindValueChanged(index => hitCircleText.Text = (index.NewValue + 1).ToString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateState(ValueChangedEvent<ArmedState> state)
|
private void updateState(ValueChangedEvent<ArmedState> state)
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
@ -45,25 +44,6 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public virtual void PostProcess()
|
public virtual void PostProcess()
|
||||||
{
|
{
|
||||||
void updateNestedCombo(HitObject obj, int comboIndex, int indexInCurrentCombo)
|
|
||||||
{
|
|
||||||
if (obj is IHasComboInformation objectComboInfo)
|
|
||||||
{
|
|
||||||
objectComboInfo.ComboIndex = comboIndex;
|
|
||||||
objectComboInfo.IndexInCurrentCombo = indexInCurrentCombo;
|
|
||||||
foreach (var nestedObject in obj.NestedHitObjects)
|
|
||||||
updateNestedCombo(nestedObject, comboIndex, indexInCurrentCombo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var hitObject in Beatmap.HitObjects)
|
|
||||||
{
|
|
||||||
if (hitObject is IHasComboInformation objectComboInfo)
|
|
||||||
{
|
|
||||||
foreach (var nested in hitObject.NestedHitObjects)
|
|
||||||
updateNestedCombo(nested, objectComboInfo.ComboIndex, objectComboInfo.IndexInCurrentCombo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public JudgementResult Result { get; private set; }
|
public JudgementResult Result { get; private set; }
|
||||||
|
|
||||||
|
private Bindable<int> comboIndexBindable;
|
||||||
|
|
||||||
public override bool RemoveWhenNotAlive => false;
|
public override bool RemoveWhenNotAlive => false;
|
||||||
public override bool RemoveCompletedTransforms => false;
|
public override bool RemoveCompletedTransforms => false;
|
||||||
protected override bool RequiresChildrenUpdate => true;
|
protected override bool RequiresChildrenUpdate => true;
|
||||||
@ -122,6 +124,13 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
|
if (HitObject is IHasComboInformation combo)
|
||||||
|
{
|
||||||
|
comboIndexBindable = combo.ComboIndexBindable.GetBoundCopy();
|
||||||
|
comboIndexBindable.BindValueChanged(_ => updateAccentColour());
|
||||||
|
}
|
||||||
|
|
||||||
updateState(ArmedState.Idle, true);
|
updateState(ArmedState.Idle, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,12 +253,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
{
|
{
|
||||||
base.SkinChanged(skin, allowFallback);
|
base.SkinChanged(skin, allowFallback);
|
||||||
|
|
||||||
if (HitObject is IHasComboInformation combo)
|
updateAccentColour();
|
||||||
{
|
|
||||||
var comboColours = skin.GetConfig<GlobalSkinConfiguration, List<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value;
|
|
||||||
|
|
||||||
AccentColour.Value = comboColours?.Count > 0 ? comboColours[combo.ComboIndex % comboColours.Count] : Color4.White;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplySkin(skin, allowFallback);
|
ApplySkin(skin, allowFallback);
|
||||||
|
|
||||||
@ -257,6 +261,15 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
updateState(State.Value, true);
|
updateState(State.Value, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateAccentColour()
|
||||||
|
{
|
||||||
|
if (HitObject is IHasComboInformation combo)
|
||||||
|
{
|
||||||
|
var comboColours = CurrentSkin.GetConfig<GlobalSkinConfiguration, List<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value;
|
||||||
|
AccentColour.Value = comboColours?.Count > 0 ? comboColours[combo.ComboIndex % comboColours.Count] : Color4.White;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when a change is made to the skin.
|
/// Called when a change is made to the skin.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
@ -82,6 +83,15 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
|
|
||||||
CreateNestedHitObjects();
|
CreateNestedHitObjects();
|
||||||
|
|
||||||
|
if (this is IHasComboInformation hasCombo)
|
||||||
|
{
|
||||||
|
foreach (var n in NestedHitObjects.OfType<IHasComboInformation>())
|
||||||
|
{
|
||||||
|
n.ComboIndexBindable.BindTo(hasCombo.ComboIndexBindable);
|
||||||
|
n.IndexInCurrentComboBindable.BindTo(hasCombo.IndexInCurrentComboBindable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nestedHitObjects.Sort((h1, h2) => h1.StartTime.CompareTo(h2.StartTime));
|
nestedHitObjects.Sort((h1, h2) => h1.StartTime.CompareTo(h2.StartTime));
|
||||||
|
|
||||||
foreach (var h in nestedHitObjects)
|
foreach (var h in nestedHitObjects)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Objects.Types
|
namespace osu.Game.Rulesets.Objects.Types
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -8,16 +10,22 @@ namespace osu.Game.Rulesets.Objects.Types
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IHasComboInformation : IHasCombo
|
public interface IHasComboInformation : IHasCombo
|
||||||
{
|
{
|
||||||
|
Bindable<int> IndexInCurrentComboBindable { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The offset of this hitobject in the current combo.
|
/// The offset of this hitobject in the current combo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int IndexInCurrentCombo { get; set; }
|
int IndexInCurrentCombo { get; set; }
|
||||||
|
|
||||||
|
Bindable<int> ComboIndexBindable { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The offset of this combo in relation to the beatmap.
|
/// The offset of this combo in relation to the beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int ComboIndex { get; set; }
|
int ComboIndex { get; set; }
|
||||||
|
|
||||||
|
Bindable<bool> LastInComboBindable { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether this is the last object in the current combo.
|
/// Whether this is the last object in the current combo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -12,13 +12,17 @@ namespace osu.Game.Skinning
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class SkinReloadableDrawable : CompositeDrawable
|
public abstract class SkinReloadableDrawable : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The current skin source.
|
||||||
|
/// </summary>
|
||||||
|
protected ISkinSource CurrentSkin { get; private set; }
|
||||||
|
|
||||||
private readonly Func<ISkinSource, bool> allowFallback;
|
private readonly Func<ISkinSource, bool> allowFallback;
|
||||||
private ISkinSource skin;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether fallback to default skin should be allowed if the custom skin is missing this resource.
|
/// Whether fallback to default skin should be allowed if the custom skin is missing this resource.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool allowDefaultFallback => allowFallback == null || allowFallback.Invoke(skin);
|
private bool allowDefaultFallback => allowFallback == null || allowFallback.Invoke(CurrentSkin);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="SkinReloadableDrawable"/>
|
/// Create a new <see cref="SkinReloadableDrawable"/>
|
||||||
@ -32,19 +36,19 @@ namespace osu.Game.Skinning
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(ISkinSource source)
|
private void load(ISkinSource source)
|
||||||
{
|
{
|
||||||
skin = source;
|
CurrentSkin = source;
|
||||||
skin.SourceChanged += onChange;
|
CurrentSkin.SourceChanged += onChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onChange() =>
|
private void onChange() =>
|
||||||
// schedule required to avoid calls after disposed.
|
// schedule required to avoid calls after disposed.
|
||||||
// note that this has the side-effect of components only performing a skin change when they are alive.
|
// note that this has the side-effect of components only performing a skin change when they are alive.
|
||||||
Scheduler.AddOnce(() => SkinChanged(skin, allowDefaultFallback));
|
Scheduler.AddOnce(() => SkinChanged(CurrentSkin, allowDefaultFallback));
|
||||||
|
|
||||||
protected override void LoadAsyncComplete()
|
protected override void LoadAsyncComplete()
|
||||||
{
|
{
|
||||||
base.LoadAsyncComplete();
|
base.LoadAsyncComplete();
|
||||||
SkinChanged(skin, allowDefaultFallback);
|
SkinChanged(CurrentSkin, allowDefaultFallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -60,8 +64,8 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
if (skin != null)
|
if (CurrentSkin != null)
|
||||||
skin.SourceChanged -= onChange;
|
CurrentSkin.SourceChanged -= onChange;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user