From defa350aa71cf07ffcee310fbfbde9dbc1c1c187 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 28 Apr 2021 18:06:59 +0900 Subject: [PATCH] Set defaults on SkinnableHUDComponent to cancel out relative size default Specifying locally on each HUD component looks to make more sense. --- .../Gameplay/TestSceneSkinnableHUDOverlay.cs | 26 ------------------- .../Play/HUD/SkinnableAccuracyCounter.cs | 2 ++ .../Screens/Play/HUD/SkinnableComboCounter.cs | 2 ++ .../Screens/Play/HUD/SkinnableHUDComponent.cs | 6 ++++- .../Play/HUD/SkinnableHealthDisplay.cs | 3 +++ .../Screens/Play/HUD/SkinnableScoreCounter.cs | 2 ++ 6 files changed, 14 insertions(+), 27 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs index 4f8a78368e..5c3d3c03bf 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs @@ -36,32 +36,6 @@ namespace osu.Game.Tests.Visual.Gameplay [Resolved] private OsuConfigManager config { get; set; } - protected override void LoadComplete() - { - base.LoadComplete(); - - Add(new Container - { - RelativeSizeAxes = Axes.Both, - Width = 0.3f, - Children = new Drawable[] - { - new Box - { - Colour = Color4.Black, - RelativeSizeAxes = Axes.Both, - Alpha = 0.9f, - }, - new FillFlowContainer - { - RelativeSizeAxes = Axes.Both, - Direction = FillDirection.Vertical, - Children = createSkinSourceComponents(), - }, - } - }); - } - [Test] public void TestComboCounterIncrementing() { diff --git a/osu.Game/Screens/Play/HUD/SkinnableAccuracyCounter.cs b/osu.Game/Screens/Play/HUD/SkinnableAccuracyCounter.cs index ebb3bcd148..33132adf23 100644 --- a/osu.Game/Screens/Play/HUD/SkinnableAccuracyCounter.cs +++ b/osu.Game/Screens/Play/HUD/SkinnableAccuracyCounter.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Bindables; +using osu.Framework.Graphics; using osu.Game.Skinning; namespace osu.Game.Screens.Play.HUD @@ -14,6 +15,7 @@ namespace osu.Game.Screens.Play.HUD : base(new HUDSkinComponent(HUDSkinComponents.AccuracyCounter), _ => new DefaultAccuracyCounter()) { CentreComponent = false; + AutoSizeAxes = Axes.Both; } private IAccuracyCounter skinnedCounter; diff --git a/osu.Game/Screens/Play/HUD/SkinnableComboCounter.cs b/osu.Game/Screens/Play/HUD/SkinnableComboCounter.cs index 629bb467bc..8785eccfc3 100644 --- a/osu.Game/Screens/Play/HUD/SkinnableComboCounter.cs +++ b/osu.Game/Screens/Play/HUD/SkinnableComboCounter.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Bindables; +using osu.Framework.Graphics; using osu.Game.Skinning; namespace osu.Game.Screens.Play.HUD @@ -14,6 +15,7 @@ namespace osu.Game.Screens.Play.HUD : base(new HUDSkinComponent(HUDSkinComponents.ComboCounter), skinComponent => new DefaultComboCounter()) { CentreComponent = false; + AutoSizeAxes = Axes.Both; } private IComboCounter skinnedCounter; diff --git a/osu.Game/Screens/Play/HUD/SkinnableHUDComponent.cs b/osu.Game/Screens/Play/HUD/SkinnableHUDComponent.cs index f5333c940f..7d23611718 100644 --- a/osu.Game/Screens/Play/HUD/SkinnableHUDComponent.cs +++ b/osu.Game/Screens/Play/HUD/SkinnableHUDComponent.cs @@ -46,8 +46,11 @@ namespace osu.Game.Screens.Play.HUD SkinRotation.BindValueChanged(rotation => Rotation = rotation.NewValue); SkinAnchor.BindValueChanged(anchor => { Anchor = anchor.NewValue; }); + // reset everything and require each component to specify what they want, + // as if they were just drawables. maybe we want to change SkinnableDrawable to not default + // to RelativeSizeAxes.Both... RelativeSizeAxes = Axes.None; - AutoSizeAxes = Axes.Both; + AutoSizeAxes = Axes.None; } protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source) @@ -58,6 +61,7 @@ namespace osu.Game.Screens.Play.HUD SkinPositionY.Value = Position.Y; SkinRotation.Value = Rotation; SkinAnchor.Value = Anchor; + return base.OnInvalidate(invalidation, source); } } diff --git a/osu.Game/Screens/Play/HUD/SkinnableHealthDisplay.cs b/osu.Game/Screens/Play/HUD/SkinnableHealthDisplay.cs index f8a8696dae..ceac147b63 100644 --- a/osu.Game/Screens/Play/HUD/SkinnableHealthDisplay.cs +++ b/osu.Game/Screens/Play/HUD/SkinnableHealthDisplay.cs @@ -3,6 +3,7 @@ using System; using osu.Framework.Bindables; +using osu.Framework.Graphics; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Scoring; using osu.Game.Skinning; @@ -35,6 +36,8 @@ namespace osu.Game.Screens.Play.HUD : base(new HUDSkinComponent(HUDSkinComponents.HealthDisplay), _ => new DefaultHealthDisplay()) { CentreComponent = false; + AutoSizeAxes = Axes.Y; + RelativeSizeAxes = Axes.X; } private IHealthDisplay skinnedCounter; diff --git a/osu.Game/Screens/Play/HUD/SkinnableScoreCounter.cs b/osu.Game/Screens/Play/HUD/SkinnableScoreCounter.cs index 9165b2c7f0..c47baf95ff 100644 --- a/osu.Game/Screens/Play/HUD/SkinnableScoreCounter.cs +++ b/osu.Game/Screens/Play/HUD/SkinnableScoreCounter.cs @@ -4,6 +4,7 @@ using System; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Graphics; using osu.Game.Configuration; using osu.Game.Rulesets.Scoring; using osu.Game.Skinning; @@ -22,6 +23,7 @@ namespace osu.Game.Screens.Play.HUD : base(new HUDSkinComponent(HUDSkinComponents.ScoreCounter), _ => new DefaultScoreCounter()) { CentreComponent = false; + AutoSizeAxes = Axes.Both; } [BackgroundDependencyLoader]