1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Merge pull request #16760 from peppy/force-relayout-on-score-mode-change

Trigger a re-layout of HUD components when scoring mode is changed
This commit is contained in:
Dan Balasescu 2022-02-03 17:06:38 +09:00 committed by GitHub
commit 46d180eeb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play.HUD;
using osu.Game.Skinning;
@ -83,10 +84,7 @@ namespace osu.Game.Screens.Play
Children = new Drawable[]
{
CreateFailingLayer(),
mainComponents = new SkinnableTargetContainer(SkinnableTarget.MainHUDComponents)
{
RelativeSizeAxes = Axes.Both,
},
mainComponents = new MainComponentsContainer(),
topRightElements = new FillFlowContainer
{
Anchor = Anchor.TopRight,
@ -325,5 +323,29 @@ namespace osu.Game.Screens.Play
break;
}
}
private class MainComponentsContainer : SkinnableTargetContainer
{
private Bindable<ScoringMode> scoringMode;
[Resolved]
private OsuConfigManager config { get; set; }
public MainComponentsContainer()
: base(SkinnableTarget.MainHUDComponents)
{
RelativeSizeAxes = Axes.Both;
}
protected override void LoadComplete()
{
base.LoadComplete();
// When the scoring mode changes, relative positions of elements may change (see DefaultSkin.GetDrawableComponent).
// This is a best effort implementation for cases where users haven't customised layouts.
scoringMode = config.GetBindable<ScoringMode>(OsuSetting.ScoreDisplayMode);
scoringMode.BindValueChanged(val => Reload());
}
}
}
}