1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 21:02:54 +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.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<Mod> 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<Drawable> { mainComponents, KeyCounter, topRightElements };
hideTargets = new List<Drawable> { 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> 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;
}

View File

@ -1,6 +1,8 @@
// 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.Game.Rulesets;
namespace osu.Game.Skinning
{
/// <summary>
@ -13,9 +15,14 @@ namespace osu.Game.Skinning
/// </summary>
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;
}
/// <summary>