mirror of
https://github.com/ppy/osu.git
synced 2025-02-07 09:02:56 +08:00
- Caches `DrawableRuleset` in editor compose screen for mania playfield adjustment container (because it's used to wrap the blueprint container as well) - Fixes `ManiaModWithPlayfieldCover` performing a no-longer-correct direct cast with a naive-but-working approach.
62 lines
2.0 KiB
C#
62 lines
2.0 KiB
C#
// 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.Bindables;
|
|
using osu.Framework.Graphics;
|
|
using osu.Game.Rulesets.Mania.Skinning;
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
|
using osu.Game.Skinning;
|
|
|
|
namespace osu.Game.Rulesets.Mania.UI.Components
|
|
{
|
|
public partial class HitPositionPaddedContainer : SkinReloadableDrawable
|
|
{
|
|
protected readonly IBindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
|
|
|
public HitPositionPaddedContainer(Drawable child)
|
|
{
|
|
InternalChild = child;
|
|
}
|
|
|
|
internal void Add(Drawable drawable)
|
|
{
|
|
base.AddInternal(drawable);
|
|
}
|
|
|
|
internal void Remove(Drawable drawable, bool disposeImmediately = true)
|
|
{
|
|
base.RemoveInternal(drawable, disposeImmediately);
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(IScrollingInfo scrollingInfo)
|
|
{
|
|
Direction.BindTo(scrollingInfo.Direction);
|
|
Direction.BindValueChanged(onDirectionChanged, true);
|
|
}
|
|
|
|
protected override void SkinChanged(ISkinSource skin)
|
|
{
|
|
base.SkinChanged(skin);
|
|
UpdateHitPosition();
|
|
}
|
|
|
|
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
|
{
|
|
UpdateHitPosition();
|
|
}
|
|
|
|
protected virtual void UpdateHitPosition()
|
|
{
|
|
float hitPosition = CurrentSkin.GetConfig<ManiaSkinConfigurationLookup, float>(
|
|
new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.HitPosition))?.Value
|
|
?? Stage.HIT_TARGET_POSITION;
|
|
|
|
Padding = Direction.Value == ScrollingDirection.Up
|
|
? new MarginPadding { Top = hitPosition }
|
|
: new MarginPadding { Bottom = hitPosition };
|
|
}
|
|
}
|
|
}
|