1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 20:07:24 +08:00
osu-lazer/osu.Game/Screens/Play/HUD/SkinnableComboCounter.cs
Dean Herbert 6a6718ebab Allow bypassing origin/anchor setting of skinnable components
It makes little sense to set these when using RelativeSizeAxes.Both
2020-10-14 19:16:34 +09:00

60 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.Bindables;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Skinning;
using osuTK.Graphics;
namespace osu.Game.Screens.Play.HUD
{
public class SkinnableComboCounter : SkinnableDrawable, IComboCounter
{
public SkinnableComboCounter()
: base(new HUDSkinComponent(HUDSkinComponents.ComboCounter), createDefault)
{
CentreComponent = false;
}
private IComboCounter skinnedCounter;
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
{
// todo: unnecessary?
if (skinnedCounter != null)
{
Current.UnbindFrom(skinnedCounter.Current);
}
base.SkinChanged(skin, allowFallback);
// temporary layout code, will eventually be replaced by the skin layout system.
if (Drawable is SimpleComboCounter)
{
Drawable.BypassAutoSizeAxes = Axes.X;
Drawable.Anchor = Anchor.TopRight;
Drawable.Origin = Anchor.TopLeft;
Drawable.Margin = new MarginPadding { Top = 5, Left = 20 };
}
else
{
Drawable.BypassAutoSizeAxes = Axes.X;
Drawable.Anchor = Anchor.BottomLeft;
Drawable.Origin = Anchor.BottomLeft;
Drawable.Margin = new MarginPadding { Top = 5, Left = 20 };
}
skinnedCounter = (IComboCounter)Drawable;
Current.BindTo(skinnedCounter.Current);
}
private static Drawable createDefault(ISkinComponent skinComponent) => new SimpleComboCounter();
public Bindable<int> Current { get; } = new Bindable<int>();
public void UpdateCombo(int combo, Color4? hitObjectColour = null) => Current.Value = combo;
}
}