1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 18:52:55 +08:00

Add optional ruleset identifier to SkinComponentsContainerLookup

This commit is contained in:
Dean Herbert 2023-02-16 19:20:06 +09:00
parent 1a63ca9ece
commit 4cc6664dc7
2 changed files with 18 additions and 9 deletions

View File

@ -6,6 +6,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Extensions.EnumExtensions;
@ -26,6 +27,7 @@ using osu.Game.Screens.Play.HUD.JudgementCounter;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
using osu.Game.Localisation; using osu.Game.Localisation;
using osu.Game.Rulesets;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
@ -100,6 +102,8 @@ namespace osu.Game.Screens.Play
public HUDOverlay(DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods, bool alwaysShowLeaderboard = true) public HUDOverlay(DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods, bool alwaysShowLeaderboard = true)
{ {
SkinComponentsContainer rulesetComponents;
this.drawableRuleset = drawableRuleset; this.drawableRuleset = drawableRuleset;
this.mods = mods; this.mods = mods;
@ -110,10 +114,8 @@ namespace osu.Game.Screens.Play
CreateFailingLayer(), CreateFailingLayer(),
//Needs to be initialized before skinnable drawables. //Needs to be initialized before skinnable drawables.
tally = new JudgementTally(), tally = new JudgementTally(),
mainComponents = new MainComponentsContainer mainComponents = new HUDComponentsContainer { AlwaysPresent = true, },
{ rulesetComponents = new HUDComponentsContainer(drawableRuleset.Ruleset) { AlwaysPresent = true, },
AlwaysPresent = true,
},
topRightElements = new FillFlowContainer topRightElements = new FillFlowContainer
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
@ -155,7 +157,7 @@ namespace osu.Game.Screens.Play
clicksPerSecondCalculator = new ClicksPerSecondCalculator(), clicksPerSecondCalculator = new ClicksPerSecondCalculator(),
}; };
hideTargets = new List<Drawable> { mainComponents, KeyCounter, topRightElements }; hideTargets = new List<Drawable> { mainComponents, rulesetComponents, KeyCounter, topRightElements };
if (!alwaysShowLeaderboard) if (!alwaysShowLeaderboard)
hideTargets.Add(LeaderboardFlow); 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> scoringMode; private Bindable<ScoringMode> scoringMode;
[Resolved] [Resolved]
private OsuConfigManager config { get; set; } private OsuConfigManager config { get; set; }
public MainComponentsContainer() public HUDComponentsContainer([CanBeNull] Ruleset ruleset = null)
: base(new SkinComponentsContainerLookup(SkinComponentsContainerLookup.TargetArea.MainHUDComponents)) : base(new SkinComponentsContainerLookup(SkinComponentsContainerLookup.TargetArea.MainHUDComponents, ruleset))
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
} }

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
/// <summary> /// <summary>
@ -13,9 +15,14 @@ namespace osu.Game.Skinning
/// </summary> /// </summary>
public readonly TargetArea Target; 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; Target = target;
Ruleset = ruleset;
} }
/// <summary> /// <summary>