From 4cc6664dc758bef146f85107d11d015580408626 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Feb 2023 19:20:06 +0900 Subject: [PATCH] Add optional ruleset identifier to `SkinComponentsContainerLookup` --- osu.Game/Screens/Play/HUDOverlay.cs | 18 ++++++++++-------- .../Skinning/SkinComponentsContainerLookup.cs | 9 ++++++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index e41afd7722..37a96dc96c 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Linq; +using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.EnumExtensions; @@ -26,6 +27,7 @@ using osu.Game.Screens.Play.HUD.JudgementCounter; using osu.Game.Skinning; using osuTK; using osu.Game.Localisation; +using osu.Game.Rulesets; namespace osu.Game.Screens.Play { @@ -100,6 +102,8 @@ namespace osu.Game.Screens.Play public HUDOverlay(DrawableRuleset drawableRuleset, IReadOnlyList mods, bool alwaysShowLeaderboard = true) { + SkinComponentsContainer rulesetComponents; + this.drawableRuleset = drawableRuleset; this.mods = mods; @@ -110,10 +114,8 @@ namespace osu.Game.Screens.Play CreateFailingLayer(), //Needs to be initialized before skinnable drawables. tally = new JudgementTally(), - mainComponents = new MainComponentsContainer - { - AlwaysPresent = true, - }, + mainComponents = new HUDComponentsContainer { AlwaysPresent = true, }, + rulesetComponents = new HUDComponentsContainer(drawableRuleset.Ruleset) { AlwaysPresent = true, }, topRightElements = new FillFlowContainer { Anchor = Anchor.TopRight, @@ -155,7 +157,7 @@ namespace osu.Game.Screens.Play clicksPerSecondCalculator = new ClicksPerSecondCalculator(), }; - hideTargets = new List { mainComponents, KeyCounter, topRightElements }; + hideTargets = new List { mainComponents, rulesetComponents, KeyCounter, topRightElements }; if (!alwaysShowLeaderboard) hideTargets.Add(LeaderboardFlow); @@ -390,15 +392,15 @@ namespace osu.Game.Screens.Play } } - private partial class MainComponentsContainer : SkinComponentsContainer + private partial class HUDComponentsContainer : SkinComponentsContainer { private Bindable scoringMode; [Resolved] private OsuConfigManager config { get; set; } - public MainComponentsContainer() - : base(new SkinComponentsContainerLookup(SkinComponentsContainerLookup.TargetArea.MainHUDComponents)) + public HUDComponentsContainer([CanBeNull] Ruleset ruleset = null) + : base(new SkinComponentsContainerLookup(SkinComponentsContainerLookup.TargetArea.MainHUDComponents, ruleset)) { RelativeSizeAxes = Axes.Both; } diff --git a/osu.Game/Skinning/SkinComponentsContainerLookup.cs b/osu.Game/Skinning/SkinComponentsContainerLookup.cs index b0b87f18b5..90384d7a4d 100644 --- a/osu.Game/Skinning/SkinComponentsContainerLookup.cs +++ b/osu.Game/Skinning/SkinComponentsContainerLookup.cs @@ -1,6 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Game.Rulesets; + namespace osu.Game.Skinning { /// @@ -13,9 +15,14 @@ namespace osu.Game.Skinning /// public readonly TargetArea Target; - public SkinComponentsContainerLookup(TargetArea target) + public readonly Ruleset? Ruleset; + + public string GetSerialisableIdentifier() => Ruleset?.ShortName ?? "global"; + + public SkinComponentsContainerLookup(TargetArea target, Ruleset? ruleset = null) { Target = target; + Ruleset = ruleset; } ///