From 41756520b1ff322ae8a28858becdee362279309e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 22 Aug 2024 17:14:35 +0900 Subject: [PATCH 1/8] Rename `SkinComponentsContainer` to `SkinnableContainer` --- .../TestSceneCatchPlayerLegacySkin.cs | 2 +- .../Gameplay/TestSceneBeatmapSkinFallbacks.cs | 4 ++-- .../Visual/Gameplay/TestSceneHUDOverlay.cs | 12 ++++++------ .../Gameplay/TestScenePauseInputHandling.cs | 2 +- .../Visual/Gameplay/TestSceneSkinEditor.cs | 16 ++++++++-------- .../TestSceneSkinEditorComponentsList.cs | 2 +- .../Gameplay/TestSceneSkinnableHUDOverlay.cs | 4 ++-- .../Navigation/TestSceneSkinEditorNavigation.cs | 4 ++-- .../Overlays/SkinEditor/SkinComponentToolbox.cs | 4 ++-- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 14 +++++++------- osu.Game/Screens/Play/HUDOverlay.cs | 10 +++++----- osu.Game/Screens/Select/SongSelect.cs | 2 +- osu.Game/Skinning/Skin.cs | 4 ++-- osu.Game/Skinning/SkinLayoutInfo.cs | 4 ++-- ...ponentsContainer.cs => SkinnableContainer.cs} | 6 +++--- .../Tests/Visual/LegacySkinPlayerTestScene.cs | 4 ++-- 16 files changed, 47 insertions(+), 47 deletions(-) rename osu.Game/Skinning/{SkinComponentsContainer.cs => SkinnableContainer.cs} (94%) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatchPlayerLegacySkin.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatchPlayerLegacySkin.cs index 7812e02a6363..792caf6de69e 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatchPlayerLegacySkin.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatchPlayerLegacySkin.cs @@ -23,7 +23,7 @@ public void TestLegacyHUDComboCounterNotExistent([Values] bool withModifiedSkin) if (withModifiedSkin) { AddStep("change component scale", () => Player.ChildrenOfType().First().Scale = new Vector2(2f)); - AddStep("update target", () => Player.ChildrenOfType().ForEach(LegacySkin.UpdateDrawableTarget)); + AddStep("update target", () => Player.ChildrenOfType().ForEach(LegacySkin.UpdateDrawableTarget)); AddStep("exit player", () => Player.Exit()); CreateTest(); } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs index a2ce62105ecf..c9b9b97580ac 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs @@ -37,7 +37,7 @@ public partial class TestSceneBeatmapSkinFallbacks : OsuPlayerTestScene public void TestEmptyLegacyBeatmapSkinFallsBack() { CreateSkinTest(TrianglesSkin.CreateInfo(), () => new LegacyBeatmapSkin(new BeatmapInfo(), null)); - AddUntilStep("wait for hud load", () => Player.ChildrenOfType().All(c => c.ComponentsLoaded)); + AddUntilStep("wait for hud load", () => Player.ChildrenOfType().All(c => c.ComponentsLoaded)); AddAssert("hud from default skin", () => AssertComponentsFromExpectedSource(SkinComponentsContainerLookup.TargetArea.MainHUDComponents, skinManager.CurrentSkin.Value)); } @@ -55,7 +55,7 @@ protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func getBeatmapSk protected bool AssertComponentsFromExpectedSource(SkinComponentsContainerLookup.TargetArea target, ISkin expectedSource) { - var targetContainer = Player.ChildrenOfType().First(s => s.Lookup.Target == target); + var targetContainer = Player.ChildrenOfType().First(s => s.Lookup.Target == target); var actualComponentsContainer = targetContainer.ChildrenOfType().SingleOrDefault(c => c.Parent == targetContainer); if (actualComponentsContainer == null) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs index 91f22a291c43..d51c9b3f8836 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs @@ -43,7 +43,7 @@ public partial class TestSceneHUDOverlay : OsuManualInputManagerTestScene private readonly IGameplayClock gameplayClock = new GameplayClockContainer(new TrackVirtual(60000), false, false); // best way to check without exposing. - private Drawable hideTarget => hudOverlay.ChildrenOfType().First(); + private Drawable hideTarget => hudOverlay.ChildrenOfType().First(); private Drawable keyCounterContent => hudOverlay.ChildrenOfType().First().ChildrenOfType().Skip(1).First(); public TestSceneHUDOverlay() @@ -242,8 +242,8 @@ public void TestHiddenHUDDoesntBlockComponentUpdates() createNew(); - AddUntilStep("wait for components to be hidden", () => hudOverlay.ChildrenOfType().Single().Alpha == 0); - AddUntilStep("wait for hud load", () => hudOverlay.ChildrenOfType().All(c => c.ComponentsLoaded)); + AddUntilStep("wait for components to be hidden", () => hudOverlay.ChildrenOfType().Single().Alpha == 0); + AddUntilStep("wait for hud load", () => hudOverlay.ChildrenOfType().All(c => c.ComponentsLoaded)); AddStep("bind on update", () => { @@ -260,10 +260,10 @@ public void TestHiddenHUDDoesntBlockSkinnableComponentsLoad() createNew(); - AddUntilStep("wait for components to be hidden", () => hudOverlay.ChildrenOfType().Single().Alpha == 0); + AddUntilStep("wait for components to be hidden", () => hudOverlay.ChildrenOfType().Single().Alpha == 0); - AddStep("reload components", () => hudOverlay.ChildrenOfType().Single().Reload()); - AddUntilStep("skinnable components loaded", () => hudOverlay.ChildrenOfType().Single().ComponentsLoaded); + AddStep("reload components", () => hudOverlay.ChildrenOfType().Single().Reload()); + AddUntilStep("skinnable components loaded", () => hudOverlay.ChildrenOfType().Single().ComponentsLoaded); } private void createNew(Action? action = null) diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePauseInputHandling.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePauseInputHandling.cs index bc66947ccd2b..2c58e648310d 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePauseInputHandling.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePauseInputHandling.cs @@ -286,7 +286,7 @@ private void loadPlayer(Func createRuleset) AddStep("set ruleset", () => currentRuleset = createRuleset()); AddStep("load player", LoadPlayer); AddUntilStep("player loaded", () => Player.IsLoaded && Player.Alpha == 1); - AddUntilStep("wait for hud", () => Player.HUDOverlay.ChildrenOfType().All(s => s.ComponentsLoaded)); + AddUntilStep("wait for hud", () => Player.HUDOverlay.ChildrenOfType().All(s => s.ComponentsLoaded)); AddStep("seek to gameplay", () => Player.GameplayClockContainer.Seek(0)); AddUntilStep("wait for seek to finish", () => Player.DrawableRuleset.FrameStableClock.CurrentTime, () => Is.EqualTo(0).Within(500)); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs index 7466442674cf..cc514cc2fabc 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs @@ -46,7 +46,7 @@ public partial class TestSceneSkinEditor : PlayerTestScene [Resolved] private SkinManager skins { get; set; } = null!; - private SkinComponentsContainer targetContainer => Player.ChildrenOfType().First(); + private SkinnableContainer targetContainer => Player.ChildrenOfType().First(); [SetUpSteps] public override void SetUpSteps() @@ -75,7 +75,7 @@ public void TestDragSelection() AddStep("Add big black boxes", () => { - var target = Player.ChildrenOfType().First(); + var target = Player.ChildrenOfType().First(); target.Add(box1 = new BigBlackBox { Position = new Vector2(-90), @@ -200,14 +200,14 @@ public void TestCyclicSelection() [Test] public void TestUndoEditHistory() { - SkinComponentsContainer firstTarget = null!; + SkinnableContainer firstTarget = null!; TestSkinEditorChangeHandler changeHandler = null!; byte[] defaultState = null!; IEnumerable testComponents = null!; AddStep("Load necessary things", () => { - firstTarget = Player.ChildrenOfType().First(); + firstTarget = Player.ChildrenOfType().First(); changeHandler = new TestSkinEditorChangeHandler(firstTarget); changeHandler.SaveState(); @@ -377,11 +377,11 @@ public void TestCopyPaste() () => Is.EqualTo(3)); } - private SkinComponentsContainer globalHUDTarget => Player.ChildrenOfType() - .Single(c => c.Lookup.Target == SkinComponentsContainerLookup.TargetArea.MainHUDComponents && c.Lookup.Ruleset == null); + private SkinnableContainer globalHUDTarget => Player.ChildrenOfType() + .Single(c => c.Lookup.Target == SkinComponentsContainerLookup.TargetArea.MainHUDComponents && c.Lookup.Ruleset == null); - private SkinComponentsContainer rulesetHUDTarget => Player.ChildrenOfType() - .Single(c => c.Lookup.Target == SkinComponentsContainerLookup.TargetArea.MainHUDComponents && c.Lookup.Ruleset != null); + private SkinnableContainer rulesetHUDTarget => Player.ChildrenOfType() + .Single(c => c.Lookup.Target == SkinComponentsContainerLookup.TargetArea.MainHUDComponents && c.Lookup.Ruleset != null); [Test] public void TestMigrationArgon() diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs index b7b2a6c1750d..42dcfe12e9f4 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs @@ -20,7 +20,7 @@ public partial class TestSceneSkinEditorComponentsList : SkinnableTestScene [Test] public void TestToggleEditor() { - var skinComponentsContainer = new SkinComponentsContainer(new SkinComponentsContainerLookup(SkinComponentsContainerLookup.TargetArea.SongSelect)); + var skinComponentsContainer = new SkinnableContainer(new SkinComponentsContainerLookup(SkinComponentsContainerLookup.TargetArea.SongSelect)); AddStep("show available components", () => SetContents(_ => new SkinComponentToolbox(skinComponentsContainer, null) { diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs index d1e224a91052..fcaa2996e1fd 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs @@ -45,7 +45,7 @@ public partial class TestSceneSkinnableHUDOverlay : SkinnableTestScene private IEnumerable hudOverlays => CreatedDrawables.OfType(); // best way to check without exposing. - private Drawable hideTarget => hudOverlay.ChildrenOfType().First(); + private Drawable hideTarget => hudOverlay.ChildrenOfType().First(); private Drawable keyCounterFlow => hudOverlay.ChildrenOfType().First().ChildrenOfType>().Single(); public TestSceneSkinnableHUDOverlay() @@ -101,7 +101,7 @@ private void createNew(Action action = null) }); AddUntilStep("HUD overlay loaded", () => hudOverlay.IsAlive); AddUntilStep("components container loaded", - () => hudOverlay.ChildrenOfType().Any(scc => scc.ComponentsLoaded)); + () => hudOverlay.ChildrenOfType().Any(scc => scc.ComponentsLoaded)); } protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset(); diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs index 38fb2846aaab..5267a57a054c 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs @@ -336,13 +336,13 @@ public void TestSkinSavesOnChange() }); AddStep("change to triangles skin", () => Game.Dependencies.Get().SetSkinFromConfiguration(SkinInfo.TRIANGLES_SKIN.ToString())); - AddUntilStep("components loaded", () => Game.ChildrenOfType().All(c => c.ComponentsLoaded)); + AddUntilStep("components loaded", () => Game.ChildrenOfType().All(c => c.ComponentsLoaded)); // sort of implicitly relies on song select not being skinnable. // TODO: revisit if the above ever changes AddUntilStep("skin changed", () => !skinEditor.ChildrenOfType().Any()); AddStep("change back to modified skin", () => Game.Dependencies.Get().SetSkinFromConfiguration(editedSkinId.ToString())); - AddUntilStep("components loaded", () => Game.ChildrenOfType().All(c => c.ComponentsLoaded)); + AddUntilStep("components loaded", () => Game.ChildrenOfType().All(c => c.ComponentsLoaded)); AddUntilStep("changes saved", () => skinEditor.ChildrenOfType().Any()); } diff --git a/osu.Game/Overlays/SkinEditor/SkinComponentToolbox.cs b/osu.Game/Overlays/SkinEditor/SkinComponentToolbox.cs index a476fc1a6d00..85becc1a2306 100644 --- a/osu.Game/Overlays/SkinEditor/SkinComponentToolbox.cs +++ b/osu.Game/Overlays/SkinEditor/SkinComponentToolbox.cs @@ -24,7 +24,7 @@ public partial class SkinComponentToolbox : EditorSidebarSection { public Action? RequestPlacement; - private readonly SkinComponentsContainer target; + private readonly SkinnableContainer target; private readonly RulesetInfo? ruleset; @@ -35,7 +35,7 @@ public partial class SkinComponentToolbox : EditorSidebarSection /// /// The target. This is mainly used as a dependency source to find candidate components. /// A ruleset to filter components by. If null, only components which are not ruleset-specific will be included. - public SkinComponentToolbox(SkinComponentsContainer target, RulesetInfo? ruleset) + public SkinComponentToolbox(SkinnableContainer target, RulesetInfo? ruleset) : base(ruleset == null ? SkinEditorStrings.Components : LocalisableString.Interpolate($"{SkinEditorStrings.Components} ({ruleset.Name})")) { this.target = target; diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index 03acf1e68c6c..78ddce03c7c4 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -472,18 +472,18 @@ private void populateSettings() settingsSidebar.Add(new SkinSettingsToolbox(component)); } - private IEnumerable availableTargets => targetScreen.ChildrenOfType(); + private IEnumerable availableTargets => targetScreen.ChildrenOfType(); - private SkinComponentsContainer? getFirstTarget() => availableTargets.FirstOrDefault(); + private SkinnableContainer? getFirstTarget() => availableTargets.FirstOrDefault(); - private SkinComponentsContainer? getTarget(SkinComponentsContainerLookup? target) + private SkinnableContainer? getTarget(SkinComponentsContainerLookup? target) { return availableTargets.FirstOrDefault(c => c.Lookup.Equals(target)); } private void revert() { - SkinComponentsContainer[] targetContainers = availableTargets.ToArray(); + SkinnableContainer[] targetContainers = availableTargets.ToArray(); foreach (var t in targetContainers) { @@ -555,7 +555,7 @@ private void save(Skin skin, bool userTriggered = true) if (targetScreen?.IsLoaded != true) return; - SkinComponentsContainer[] targetContainers = availableTargets.ToArray(); + SkinnableContainer[] targetContainers = availableTargets.ToArray(); if (!targetContainers.All(c => c.ComponentsLoaded)) return; @@ -600,7 +600,7 @@ public void DeleteItems(ISerialisableDrawable[] items) public void BringSelectionToFront() { - if (getTarget(selectedTarget.Value) is not SkinComponentsContainer target) + if (getTarget(selectedTarget.Value) is not SkinnableContainer target) return; changeHandler?.BeginChange(); @@ -624,7 +624,7 @@ public void BringSelectionToFront() public void SendSelectionToBack() { - if (getTarget(selectedTarget.Value) is not SkinComponentsContainer target) + if (getTarget(selectedTarget.Value) is not SkinnableContainer target) return; changeHandler?.BeginChange(); diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index ef3bb7c04a0f..73fda6261612 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -95,10 +95,10 @@ protected override bool ShouldBeConsideredForInput(Drawable child) private readonly BindableBool holdingForHUD = new BindableBool(); - private readonly SkinComponentsContainer mainComponents; + private readonly SkinnableContainer mainComponents; [CanBeNull] - private readonly SkinComponentsContainer rulesetComponents; + private readonly SkinnableContainer rulesetComponents; /// /// A flow which sits at the left side of the screen to house leaderboard (and related) components. @@ -132,7 +132,7 @@ public HUDOverlay([CanBeNull] DrawableRuleset drawableRuleset, IReadOnlyList e) } } - private partial class HUDComponentsContainer : SkinComponentsContainer + private partial class HUDComponentsContainer : SkinnableContainer { private Bindable scoringMode; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 2ee5a6f3cbf2..a4a73513386b 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -321,7 +321,7 @@ private void load(AudioManager audio, OsuColour colours, ManageCollectionsDialog } } }, - new SkinComponentsContainer(new SkinComponentsContainerLookup(SkinComponentsContainerLookup.TargetArea.SongSelect)) + new SkinnableContainer(new SkinComponentsContainerLookup(SkinComponentsContainerLookup.TargetArea.SongSelect)) { RelativeSizeAxes = Axes.Both, }, diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index 3a83815f0eaf..7c205b528994 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -162,7 +162,7 @@ protected virtual void ParseConfigurationStream(Stream stream) /// Remove all stored customisations for the provided target. /// /// The target container to reset. - public void ResetDrawableTarget(SkinComponentsContainer targetContainer) + public void ResetDrawableTarget(SkinnableContainer targetContainer) { LayoutInfos.Remove(targetContainer.Lookup.Target); } @@ -171,7 +171,7 @@ public void ResetDrawableTarget(SkinComponentsContainer targetContainer) /// Update serialised information for the provided target. /// /// The target container to serialise to this skin. - public void UpdateDrawableTarget(SkinComponentsContainer targetContainer) + public void UpdateDrawableTarget(SkinnableContainer targetContainer) { if (!LayoutInfos.TryGetValue(targetContainer.Lookup.Target, out var layoutInfo)) layoutInfos[targetContainer.Lookup.Target] = layoutInfo = new SkinLayoutInfo(); diff --git a/osu.Game/Skinning/SkinLayoutInfo.cs b/osu.Game/Skinning/SkinLayoutInfo.cs index 22c876e5ad46..bf6c69362145 100644 --- a/osu.Game/Skinning/SkinLayoutInfo.cs +++ b/osu.Game/Skinning/SkinLayoutInfo.cs @@ -11,8 +11,8 @@ namespace osu.Game.Skinning { /// - /// A serialisable model describing layout of a . - /// May contain multiple configurations for different rulesets, each of which should manifest their own as required. + /// A serialisable model describing layout of a . + /// May contain multiple configurations for different rulesets, each of which should manifest their own as required. /// [Serializable] public class SkinLayoutInfo diff --git a/osu.Game/Skinning/SkinComponentsContainer.cs b/osu.Game/Skinning/SkinnableContainer.cs similarity index 94% rename from osu.Game/Skinning/SkinComponentsContainer.cs rename to osu.Game/Skinning/SkinnableContainer.cs index 02ba43fd39cc..d2d4fac76654 100644 --- a/osu.Game/Skinning/SkinComponentsContainer.cs +++ b/osu.Game/Skinning/SkinnableContainer.cs @@ -16,10 +16,10 @@ namespace osu.Game.Skinning /// /// /// This is currently used as a means of serialising skin layouts to files. - /// Currently, one json file in a skin will represent one , containing + /// Currently, one json file in a skin will represent one , containing /// the output of . /// - public partial class SkinComponentsContainer : SkinReloadableDrawable, ISerialisableDrawableContainer + public partial class SkinnableContainer : SkinReloadableDrawable, ISerialisableDrawableContainer { private Container? content; @@ -38,7 +38,7 @@ public partial class SkinComponentsContainer : SkinReloadableDrawable, ISerialis private CancellationTokenSource? cancellationSource; - public SkinComponentsContainer(SkinComponentsContainerLookup lookup) + public SkinnableContainer(SkinComponentsContainerLookup lookup) { Lookup = lookup; } diff --git a/osu.Game/Tests/Visual/LegacySkinPlayerTestScene.cs b/osu.Game/Tests/Visual/LegacySkinPlayerTestScene.cs index 2e254f5b95c3..0e1776be8e0f 100644 --- a/osu.Game/Tests/Visual/LegacySkinPlayerTestScene.cs +++ b/osu.Game/Tests/Visual/LegacySkinPlayerTestScene.cs @@ -45,13 +45,13 @@ public override void TearDownSteps() private void addResetTargetsStep() { - AddStep("reset targets", () => this.ChildrenOfType().ForEach(t => + AddStep("reset targets", () => this.ChildrenOfType().ForEach(t => { LegacySkin.ResetDrawableTarget(t); t.Reload(); })); - AddUntilStep("wait for components to load", () => this.ChildrenOfType().All(t => t.ComponentsLoaded)); + AddUntilStep("wait for components to load", () => this.ChildrenOfType().All(t => t.ComponentsLoaded)); } public partial class SkinProvidingPlayer : TestPlayer From f37cab0c6ec1c50fdbd5f5c7312ca0679b662388 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 22 Aug 2024 18:39:36 +0900 Subject: [PATCH 2/8] Rename `SkinComponentsContainerLookup` to `GlobalSkinnableContainerLookup` --- .../Legacy/CatchLegacySkinTransformer.cs | 4 ++-- .../Argon/ManiaArgonSkinTransformer.cs | 4 ++-- .../Legacy/ManiaLegacySkinTransformer.cs | 4 ++-- .../Legacy/OsuLegacySkinTransformer.cs | 4 ++-- .../Skins/SkinDeserialisationTest.cs | 20 +++++++++---------- .../Gameplay/TestSceneBeatmapSkinFallbacks.cs | 6 +++--- .../Visual/Gameplay/TestSceneSkinEditor.cs | 4 ++-- .../TestSceneSkinEditorComponentsList.cs | 2 +- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 8 ++++---- osu.Game/Screens/Play/HUDOverlay.cs | 6 +++--- osu.Game/Screens/Select/SongSelect.cs | 2 +- osu.Game/Skinning/ArgonSkin.cs | 6 +++--- ...p.cs => GlobalSkinnableContainerLookup.cs} | 14 ++++++------- osu.Game/Skinning/LegacyBeatmapSkin.cs | 4 ++-- osu.Game/Skinning/LegacySkin.cs | 4 ++-- osu.Game/Skinning/Skin.cs | 16 +++++++-------- osu.Game/Skinning/SkinnableContainer.cs | 4 ++-- osu.Game/Skinning/TrianglesSkin.cs | 6 +++--- 18 files changed, 59 insertions(+), 59 deletions(-) rename osu.Game/Skinning/{SkinComponentsContainerLookup.cs => GlobalSkinnableContainerLookup.cs} (79%) diff --git a/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs b/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs index f3626eb55de0..ab0420554ee9 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs @@ -30,7 +30,7 @@ public CatchLegacySkinTransformer(ISkin skin) { switch (lookup) { - case SkinComponentsContainerLookup containerLookup: + case GlobalSkinnableContainerLookup containerLookup: // Only handle per ruleset defaults here. if (containerLookup.Ruleset == null) return base.GetDrawableComponent(lookup); @@ -46,7 +46,7 @@ public CatchLegacySkinTransformer(ISkin skin) // Our own ruleset components default. switch (containerLookup.Target) { - case SkinComponentsContainerLookup.TargetArea.MainHUDComponents: + case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: // todo: remove CatchSkinComponents.CatchComboCounter and refactor LegacyCatchComboCounter to be added here instead. return new DefaultSkinComponentsContainer(container => { diff --git a/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs b/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs index dbd690f89096..f80cb3a88ad7 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs @@ -28,7 +28,7 @@ public ManiaArgonSkinTransformer(ISkin skin, IBeatmap beatmap) { switch (lookup) { - case SkinComponentsContainerLookup containerLookup: + case GlobalSkinnableContainerLookup containerLookup: // Only handle per ruleset defaults here. if (containerLookup.Ruleset == null) return base.GetDrawableComponent(lookup); @@ -39,7 +39,7 @@ public ManiaArgonSkinTransformer(ISkin skin, IBeatmap beatmap) switch (containerLookup.Target) { - case SkinComponentsContainerLookup.TargetArea.MainHUDComponents: + case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: return new DefaultSkinComponentsContainer(container => { var combo = container.ChildrenOfType().FirstOrDefault(); diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs index c25b77610aba..20017a78a297 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs @@ -80,7 +80,7 @@ public override Drawable GetDrawableComponent(ISkinComponentLookup lookup) { switch (lookup) { - case SkinComponentsContainerLookup containerLookup: + case GlobalSkinnableContainerLookup containerLookup: // Modifications for global components. if (containerLookup.Ruleset == null) return base.GetDrawableComponent(lookup); @@ -95,7 +95,7 @@ public override Drawable GetDrawableComponent(ISkinComponentLookup lookup) switch (containerLookup.Target) { - case SkinComponentsContainerLookup.TargetArea.MainHUDComponents: + case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: return new DefaultSkinComponentsContainer(container => { var combo = container.ChildrenOfType().FirstOrDefault(); diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs index 457c191583d4..6609a84be4d2 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs @@ -44,7 +44,7 @@ public OsuLegacySkinTransformer(ISkin skin) { switch (lookup) { - case SkinComponentsContainerLookup containerLookup: + case GlobalSkinnableContainerLookup containerLookup: // Only handle per ruleset defaults here. if (containerLookup.Ruleset == null) return base.GetDrawableComponent(lookup); @@ -60,7 +60,7 @@ public OsuLegacySkinTransformer(ISkin skin) // Our own ruleset components default. switch (containerLookup.Target) { - case SkinComponentsContainerLookup.TargetArea.MainHUDComponents: + case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: return new DefaultSkinComponentsContainer(container => { var keyCounter = container.OfType().FirstOrDefault(); diff --git a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs index 534d47d617bd..ad01a057ad43 100644 --- a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs +++ b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs @@ -107,7 +107,7 @@ public void TestDeserialiseModifiedDefault() var skin = new TestSkin(new SkinInfo(), null, storage); Assert.That(skin.LayoutInfos, Has.Count.EqualTo(2)); - Assert.That(skin.LayoutInfos[SkinComponentsContainerLookup.TargetArea.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(9)); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(9)); } } @@ -120,8 +120,8 @@ public void TestDeserialiseModifiedArgon() var skin = new TestSkin(new SkinInfo(), null, storage); Assert.That(skin.LayoutInfos, Has.Count.EqualTo(2)); - Assert.That(skin.LayoutInfos[SkinComponentsContainerLookup.TargetArea.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(10)); - Assert.That(skin.LayoutInfos[SkinComponentsContainerLookup.TargetArea.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(PlayerName))); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(10)); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(PlayerName))); } } @@ -134,10 +134,10 @@ public void TestDeserialiseModifiedClassic() var skin = new TestSkin(new SkinInfo(), null, storage); Assert.That(skin.LayoutInfos, Has.Count.EqualTo(2)); - Assert.That(skin.LayoutInfos[SkinComponentsContainerLookup.TargetArea.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(6)); - Assert.That(skin.LayoutInfos[SkinComponentsContainerLookup.TargetArea.SongSelect].AllDrawables.ToArray(), Has.Length.EqualTo(1)); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(6)); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.SongSelect].AllDrawables.ToArray(), Has.Length.EqualTo(1)); - var skinnableInfo = skin.LayoutInfos[SkinComponentsContainerLookup.TargetArea.SongSelect].AllDrawables.First(); + var skinnableInfo = skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.SongSelect].AllDrawables.First(); Assert.That(skinnableInfo.Type, Is.EqualTo(typeof(SkinnableSprite))); Assert.That(skinnableInfo.Settings.First().Key, Is.EqualTo("sprite_name")); @@ -148,10 +148,10 @@ public void TestDeserialiseModifiedClassic() using (var storage = new ZipArchiveReader(stream)) { var skin = new TestSkin(new SkinInfo(), null, storage); - Assert.That(skin.LayoutInfos[SkinComponentsContainerLookup.TargetArea.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(8)); - Assert.That(skin.LayoutInfos[SkinComponentsContainerLookup.TargetArea.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(UnstableRateCounter))); - Assert.That(skin.LayoutInfos[SkinComponentsContainerLookup.TargetArea.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(ColourHitErrorMeter))); - Assert.That(skin.LayoutInfos[SkinComponentsContainerLookup.TargetArea.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(LegacySongProgress))); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(8)); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(UnstableRateCounter))); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(ColourHitErrorMeter))); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(LegacySongProgress))); } } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs index c9b9b97580ac..1061f493d46d 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs @@ -38,7 +38,7 @@ public void TestEmptyLegacyBeatmapSkinFallsBack() { CreateSkinTest(TrianglesSkin.CreateInfo(), () => new LegacyBeatmapSkin(new BeatmapInfo(), null)); AddUntilStep("wait for hud load", () => Player.ChildrenOfType().All(c => c.ComponentsLoaded)); - AddAssert("hud from default skin", () => AssertComponentsFromExpectedSource(SkinComponentsContainerLookup.TargetArea.MainHUDComponents, skinManager.CurrentSkin.Value)); + AddAssert("hud from default skin", () => AssertComponentsFromExpectedSource(GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents, skinManager.CurrentSkin.Value)); } protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func getBeatmapSkin) @@ -53,7 +53,7 @@ protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func getBeatmapSk }); } - protected bool AssertComponentsFromExpectedSource(SkinComponentsContainerLookup.TargetArea target, ISkin expectedSource) + protected bool AssertComponentsFromExpectedSource(GlobalSkinnableContainerLookup.GlobalSkinnableContainers target, ISkin expectedSource) { var targetContainer = Player.ChildrenOfType().First(s => s.Lookup.Target == target); var actualComponentsContainer = targetContainer.ChildrenOfType().SingleOrDefault(c => c.Parent == targetContainer); @@ -63,7 +63,7 @@ protected bool AssertComponentsFromExpectedSource(SkinComponentsContainerLookup. var actualInfo = actualComponentsContainer.CreateSerialisedInfo(); - var expectedComponentsContainer = expectedSource.GetDrawableComponent(new SkinComponentsContainerLookup(target)) as Container; + var expectedComponentsContainer = expectedSource.GetDrawableComponent(new GlobalSkinnableContainerLookup(target)) as Container; if (expectedComponentsContainer == null) return false; diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs index cc514cc2fabc..9e53f86e3340 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs @@ -378,10 +378,10 @@ public void TestCopyPaste() } private SkinnableContainer globalHUDTarget => Player.ChildrenOfType() - .Single(c => c.Lookup.Target == SkinComponentsContainerLookup.TargetArea.MainHUDComponents && c.Lookup.Ruleset == null); + .Single(c => c.Lookup.Target == GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents && c.Lookup.Ruleset == null); private SkinnableContainer rulesetHUDTarget => Player.ChildrenOfType() - .Single(c => c.Lookup.Target == SkinComponentsContainerLookup.TargetArea.MainHUDComponents && c.Lookup.Ruleset != null); + .Single(c => c.Lookup.Target == GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents && c.Lookup.Ruleset != null); [Test] public void TestMigrationArgon() diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs index 42dcfe12e9f4..e4b6358600bf 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs @@ -20,7 +20,7 @@ public partial class TestSceneSkinEditorComponentsList : SkinnableTestScene [Test] public void TestToggleEditor() { - var skinComponentsContainer = new SkinnableContainer(new SkinComponentsContainerLookup(SkinComponentsContainerLookup.TargetArea.SongSelect)); + var skinComponentsContainer = new SkinnableContainer(new GlobalSkinnableContainerLookup(GlobalSkinnableContainerLookup.GlobalSkinnableContainers.SongSelect)); AddStep("show available components", () => SetContents(_ => new SkinComponentToolbox(skinComponentsContainer, null) { diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index 78ddce03c7c4..d1e9676de7fe 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -72,7 +72,7 @@ public partial class SkinEditor : VisibilityContainer, ICanAcceptFiles, IKeyBind [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); - private readonly Bindable selectedTarget = new Bindable(); + private readonly Bindable selectedTarget = new Bindable(); private bool hasBegunMutating; @@ -330,7 +330,7 @@ void loadBlueprintContainer() } } - private void targetChanged(ValueChangedEvent target) + private void targetChanged(ValueChangedEvent target) { foreach (var toolbox in componentsSidebar.OfType()) toolbox.Expire(); @@ -360,7 +360,7 @@ private void targetChanged(ValueChangedEvent tar { Children = new Drawable[] { - new SettingsDropdown + new SettingsDropdown { Items = availableTargets.Select(t => t.Lookup).Distinct(), Current = selectedTarget, @@ -476,7 +476,7 @@ private void populateSettings() private SkinnableContainer? getFirstTarget() => availableTargets.FirstOrDefault(); - private SkinnableContainer? getTarget(SkinComponentsContainerLookup? target) + private SkinnableContainer? getTarget(GlobalSkinnableContainerLookup? target) { return availableTargets.FirstOrDefault(c => c.Lookup.Equals(target)); } diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 73fda6261612..7bddef534c61 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -109,7 +109,7 @@ protected override bool ShouldBeConsideredForInput(Drawable child) private readonly List hideTargets; /// - /// The container for skin components attached to + /// The container for skin components attached to /// internal readonly Drawable PlayfieldSkinLayer; @@ -132,7 +132,7 @@ public HUDOverlay([CanBeNull] DrawableRuleset drawableRuleset, IReadOnlyList { // do stuff when we need to. @@ -111,7 +111,7 @@ public ArgonSkin(SkinInfo skin, IStorageResourceProvider resources) return songSelectComponents; - case SkinComponentsContainerLookup.TargetArea.MainHUDComponents: + case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: if (containerLookup.Ruleset != null) { return new Container diff --git a/osu.Game/Skinning/SkinComponentsContainerLookup.cs b/osu.Game/Skinning/GlobalSkinnableContainerLookup.cs similarity index 79% rename from osu.Game/Skinning/SkinComponentsContainerLookup.cs rename to osu.Game/Skinning/GlobalSkinnableContainerLookup.cs index 34358c3f0693..384b4aa23c1c 100644 --- a/osu.Game/Skinning/SkinComponentsContainerLookup.cs +++ b/osu.Game/Skinning/GlobalSkinnableContainerLookup.cs @@ -9,14 +9,14 @@ namespace osu.Game.Skinning { /// - /// Represents a lookup of a collection of elements that make up a particular skinnable of the game. + /// Represents a lookup of a collection of elements that make up a particular skinnable of the game. /// - public class SkinComponentsContainerLookup : ISkinComponentLookup, IEquatable + public class GlobalSkinnableContainerLookup : ISkinComponentLookup, IEquatable { /// /// The target area / layer of the game for which skin components will be returned. /// - public readonly TargetArea Target; + public readonly GlobalSkinnableContainers Target; /// /// The ruleset for which skin components should be returned. @@ -24,7 +24,7 @@ public class SkinComponentsContainerLookup : ISkinComponentLookup, IEquatable public readonly RulesetInfo? Ruleset; - public SkinComponentsContainerLookup(TargetArea target, RulesetInfo? ruleset = null) + public GlobalSkinnableContainerLookup(GlobalSkinnableContainers target, RulesetInfo? ruleset = null) { Target = target; Ruleset = ruleset; @@ -37,7 +37,7 @@ public override string ToString() return $"{Target.GetDescription()} (\"{Ruleset.Name}\" only)"; } - public bool Equals(SkinComponentsContainerLookup? other) + public bool Equals(GlobalSkinnableContainerLookup? other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; @@ -51,7 +51,7 @@ public override bool Equals(object? obj) if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != GetType()) return false; - return Equals((SkinComponentsContainerLookup)obj); + return Equals((GlobalSkinnableContainerLookup)obj); } public override int GetHashCode() @@ -62,7 +62,7 @@ public override int GetHashCode() /// /// Represents a particular area or part of a game screen whose layout can be customised using the skin editor. /// - public enum TargetArea + public enum GlobalSkinnableContainers { [Description("HUD")] MainHUDComponents, diff --git a/osu.Game/Skinning/LegacyBeatmapSkin.cs b/osu.Game/Skinning/LegacyBeatmapSkin.cs index 9cd072b60754..54e259a807e4 100644 --- a/osu.Game/Skinning/LegacyBeatmapSkin.cs +++ b/osu.Game/Skinning/LegacyBeatmapSkin.cs @@ -50,11 +50,11 @@ private static IResourceStore createRealmBackedStore(BeatmapInfo beatmap public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup) { - if (lookup is SkinComponentsContainerLookup containerLookup) + if (lookup is GlobalSkinnableContainerLookup containerLookup) { switch (containerLookup.Target) { - case SkinComponentsContainerLookup.TargetArea.MainHUDComponents: + case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: // this should exist in LegacySkin instead, but there isn't a fallback skin for LegacySkins yet. // therefore keep the check here until fallback default legacy skin is supported. if (!this.HasFont(LegacyFont.Score)) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index bbca0178d514..d9da208a7b1f 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -358,13 +358,13 @@ protected override void ParseConfigurationStream(Stream stream) { switch (lookup) { - case SkinComponentsContainerLookup containerLookup: + case GlobalSkinnableContainerLookup containerLookup: if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer c) return c; switch (containerLookup.Target) { - case SkinComponentsContainerLookup.TargetArea.MainHUDComponents: + case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: if (containerLookup.Ruleset != null) { return new DefaultSkinComponentsContainer(container => diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index 7c205b528994..581c47402f1e 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -43,10 +43,10 @@ public abstract class Skin : IDisposable, ISkin public SkinConfiguration Configuration { get; set; } - public IDictionary LayoutInfos => layoutInfos; + public IDictionary LayoutInfos => layoutInfos; - private readonly Dictionary layoutInfos = - new Dictionary(); + private readonly Dictionary layoutInfos = + new Dictionary(); public abstract ISample? GetSample(ISampleInfo sampleInfo); @@ -123,7 +123,7 @@ protected Skin(SkinInfo skin, IStorageResourceProvider? resources, IResourceStor } // skininfo files may be null for default skin. - foreach (SkinComponentsContainerLookup.TargetArea skinnableTarget in Enum.GetValues()) + foreach (GlobalSkinnableContainerLookup.GlobalSkinnableContainers skinnableTarget in Enum.GetValues()) { string filename = $"{skinnableTarget}.json"; @@ -187,7 +187,7 @@ public void UpdateDrawableTarget(SkinnableContainer targetContainer) case SkinnableSprite.SpriteComponentLookup sprite: return this.GetAnimation(sprite.LookupName, false, false, maxSize: sprite.MaxSize); - case SkinComponentsContainerLookup containerLookup: + case GlobalSkinnableContainerLookup containerLookup: // It is important to return null if the user has not configured this yet. // This allows skin transformers the opportunity to provide default components. @@ -206,7 +206,7 @@ public void UpdateDrawableTarget(SkinnableContainer targetContainer) #region Deserialisation & Migration - private SkinLayoutInfo? parseLayoutInfo(string jsonContent, SkinComponentsContainerLookup.TargetArea target) + private SkinLayoutInfo? parseLayoutInfo(string jsonContent, GlobalSkinnableContainerLookup.GlobalSkinnableContainers target) { SkinLayoutInfo? layout = null; @@ -245,7 +245,7 @@ public void UpdateDrawableTarget(SkinnableContainer targetContainer) return layout; } - private void applyMigration(SkinLayoutInfo layout, SkinComponentsContainerLookup.TargetArea target, int version) + private void applyMigration(SkinLayoutInfo layout, GlobalSkinnableContainerLookup.GlobalSkinnableContainers target, int version) { switch (version) { @@ -253,7 +253,7 @@ private void applyMigration(SkinLayoutInfo layout, SkinComponentsContainerLookup { // Combo counters were moved out of the global HUD components into per-ruleset. // This is to allow some rulesets to customise further (ie. mania and catch moving the combo to within their play area). - if (target != SkinComponentsContainerLookup.TargetArea.MainHUDComponents || + if (target != GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents || !layout.TryGetDrawableInfo(null, out var globalHUDComponents) || resources == null) break; diff --git a/osu.Game/Skinning/SkinnableContainer.cs b/osu.Game/Skinning/SkinnableContainer.cs index d2d4fac76654..c58992c5410f 100644 --- a/osu.Game/Skinning/SkinnableContainer.cs +++ b/osu.Game/Skinning/SkinnableContainer.cs @@ -26,7 +26,7 @@ public partial class SkinnableContainer : SkinReloadableDrawable, ISerialisableD /// /// The lookup criteria which will be used to retrieve components from the active skin. /// - public SkinComponentsContainerLookup Lookup { get; } + public GlobalSkinnableContainerLookup Lookup { get; } public IBindableList Components => components; @@ -38,7 +38,7 @@ public partial class SkinnableContainer : SkinReloadableDrawable, ISerialisableD private CancellationTokenSource? cancellationSource; - public SkinnableContainer(SkinComponentsContainerLookup lookup) + public SkinnableContainer(GlobalSkinnableContainerLookup lookup) { Lookup = lookup; } diff --git a/osu.Game/Skinning/TrianglesSkin.cs b/osu.Game/Skinning/TrianglesSkin.cs index 7971aee794b3..8e694b4c3f9a 100644 --- a/osu.Game/Skinning/TrianglesSkin.cs +++ b/osu.Game/Skinning/TrianglesSkin.cs @@ -66,7 +66,7 @@ public TrianglesSkin(SkinInfo skin, IStorageResourceProvider resources) switch (lookup) { - case SkinComponentsContainerLookup containerLookup: + case GlobalSkinnableContainerLookup containerLookup: if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer c) return c; @@ -76,7 +76,7 @@ public TrianglesSkin(SkinInfo skin, IStorageResourceProvider resources) switch (containerLookup.Target) { - case SkinComponentsContainerLookup.TargetArea.SongSelect: + case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.SongSelect: var songSelectComponents = new DefaultSkinComponentsContainer(_ => { // do stuff when we need to. @@ -84,7 +84,7 @@ public TrianglesSkin(SkinInfo skin, IStorageResourceProvider resources) return songSelectComponents; - case SkinComponentsContainerLookup.TargetArea.MainHUDComponents: + case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: var skinnableTargetWrapper = new DefaultSkinComponentsContainer(container => { var score = container.OfType().FirstOrDefault(); From 36b4013fa64857c23c70ab8f591bc2cc6b18c44f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 22 Aug 2024 18:42:38 +0900 Subject: [PATCH 3/8] Rename `GameplaySkinComponentLookup` -> `SkinComponentLookup` --- .../CatchSkinComponentLookup.cs | 2 +- .../ManiaSkinComponentLookup.cs | 2 +- .../Argon/ManiaArgonSkinTransformer.cs | 2 +- .../Legacy/ManiaLegacySkinTransformer.cs | 2 +- .../OsuSkinComponentLookup.cs | 2 +- .../Skinning/Argon/OsuArgonSkinTransformer.cs | 2 +- .../Default/OsuTrianglesSkinTransformer.cs | 2 +- .../Argon/TaikoArgonSkinTransformer.cs | 2 +- .../Legacy/TaikoLegacySkinTransformer.cs | 2 +- .../TaikoSkinComponentLookup.cs | 2 +- .../Rulesets/Judgements/DrawableJudgement.cs | 2 +- .../Skinning/GameplaySkinComponentLookup.cs | 28 ------------------- osu.Game/Skinning/ISkinComponentLookup.cs | 2 +- osu.Game/Skinning/LegacySkin.cs | 2 +- osu.Game/Skinning/SkinComponentLookup.cs | 22 +++++++++++++++ 15 files changed, 35 insertions(+), 41 deletions(-) delete mode 100644 osu.Game/Skinning/GameplaySkinComponentLookup.cs create mode 100644 osu.Game/Skinning/SkinComponentLookup.cs diff --git a/osu.Game.Rulesets.Catch/CatchSkinComponentLookup.cs b/osu.Game.Rulesets.Catch/CatchSkinComponentLookup.cs index 596b102ac575..7f91d2990b5c 100644 --- a/osu.Game.Rulesets.Catch/CatchSkinComponentLookup.cs +++ b/osu.Game.Rulesets.Catch/CatchSkinComponentLookup.cs @@ -5,7 +5,7 @@ namespace osu.Game.Rulesets.Catch { - public class CatchSkinComponentLookup : GameplaySkinComponentLookup + public class CatchSkinComponentLookup : SkinComponentLookup { public CatchSkinComponentLookup(CatchSkinComponents component) : base(component) diff --git a/osu.Game.Rulesets.Mania/ManiaSkinComponentLookup.cs b/osu.Game.Rulesets.Mania/ManiaSkinComponentLookup.cs index 046d1c5b3490..f3613eff992f 100644 --- a/osu.Game.Rulesets.Mania/ManiaSkinComponentLookup.cs +++ b/osu.Game.Rulesets.Mania/ManiaSkinComponentLookup.cs @@ -5,7 +5,7 @@ namespace osu.Game.Rulesets.Mania { - public class ManiaSkinComponentLookup : GameplaySkinComponentLookup + public class ManiaSkinComponentLookup : SkinComponentLookup { /// /// Creates a new . diff --git a/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs b/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs index f80cb3a88ad7..d13f0ca21bf9 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs @@ -59,7 +59,7 @@ public ManiaArgonSkinTransformer(ISkin skin, IBeatmap beatmap) return null; - case GameplaySkinComponentLookup resultComponent: + case SkinComponentLookup resultComponent: // This should eventually be moved to a skin setting, when supported. if (Skin is ArgonProSkin && resultComponent.Component >= HitResult.Great) return Drawable.Empty(); diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs index 20017a78a297..c9fb55e9cedd 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs @@ -114,7 +114,7 @@ public override Drawable GetDrawableComponent(ISkinComponentLookup lookup) return null; - case GameplaySkinComponentLookup resultComponent: + case SkinComponentLookup resultComponent: return getResult(resultComponent.Component); case ManiaSkinComponentLookup maniaComponent: diff --git a/osu.Game.Rulesets.Osu/OsuSkinComponentLookup.cs b/osu.Game.Rulesets.Osu/OsuSkinComponentLookup.cs index 3b3653e1ba1c..86a68c799f51 100644 --- a/osu.Game.Rulesets.Osu/OsuSkinComponentLookup.cs +++ b/osu.Game.Rulesets.Osu/OsuSkinComponentLookup.cs @@ -5,7 +5,7 @@ namespace osu.Game.Rulesets.Osu { - public class OsuSkinComponentLookup : GameplaySkinComponentLookup + public class OsuSkinComponentLookup : SkinComponentLookup { public OsuSkinComponentLookup(OsuSkinComponents component) : base(component) diff --git a/osu.Game.Rulesets.Osu/Skinning/Argon/OsuArgonSkinTransformer.cs b/osu.Game.Rulesets.Osu/Skinning/Argon/OsuArgonSkinTransformer.cs index ec63e1194d3b..9f6f65c2068d 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Argon/OsuArgonSkinTransformer.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Argon/OsuArgonSkinTransformer.cs @@ -18,7 +18,7 @@ public OsuArgonSkinTransformer(ISkin skin) { switch (lookup) { - case GameplaySkinComponentLookup resultComponent: + case SkinComponentLookup resultComponent: HitResult result = resultComponent.Component; // This should eventually be moved to a skin setting, when supported. diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/OsuTrianglesSkinTransformer.cs b/osu.Game.Rulesets.Osu/Skinning/Default/OsuTrianglesSkinTransformer.cs index 7a4c768aa25f..ef8cb12286e9 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/OsuTrianglesSkinTransformer.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/OsuTrianglesSkinTransformer.cs @@ -18,7 +18,7 @@ public OsuTrianglesSkinTransformer(ISkin skin) { switch (lookup) { - case GameplaySkinComponentLookup resultComponent: + case SkinComponentLookup resultComponent: HitResult result = resultComponent.Component; switch (result) diff --git a/osu.Game.Rulesets.Taiko/Skinning/Argon/TaikoArgonSkinTransformer.cs b/osu.Game.Rulesets.Taiko/Skinning/Argon/TaikoArgonSkinTransformer.cs index 973b4a91ff25..bfc9e8648dc2 100644 --- a/osu.Game.Rulesets.Taiko/Skinning/Argon/TaikoArgonSkinTransformer.cs +++ b/osu.Game.Rulesets.Taiko/Skinning/Argon/TaikoArgonSkinTransformer.cs @@ -18,7 +18,7 @@ public TaikoArgonSkinTransformer(ISkin skin) { switch (lookup) { - case GameplaySkinComponentLookup resultComponent: + case SkinComponentLookup resultComponent: // This should eventually be moved to a skin setting, when supported. if (Skin is ArgonProSkin && resultComponent.Component >= HitResult.Great) return Drawable.Empty(); diff --git a/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacySkinTransformer.cs b/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacySkinTransformer.cs index 894b91e9cebf..5bdb824f1c1c 100644 --- a/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacySkinTransformer.cs @@ -29,7 +29,7 @@ public TaikoLegacySkinTransformer(ISkin skin) public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup) { - if (lookup is GameplaySkinComponentLookup) + if (lookup is SkinComponentLookup) { // if a taiko skin is providing explosion sprites, hide the judgements completely if (hasExplosion.Value) diff --git a/osu.Game.Rulesets.Taiko/TaikoSkinComponentLookup.cs b/osu.Game.Rulesets.Taiko/TaikoSkinComponentLookup.cs index 8841c3d3cade..2fa4d3c9cb1b 100644 --- a/osu.Game.Rulesets.Taiko/TaikoSkinComponentLookup.cs +++ b/osu.Game.Rulesets.Taiko/TaikoSkinComponentLookup.cs @@ -5,7 +5,7 @@ namespace osu.Game.Rulesets.Taiko { - public class TaikoSkinComponentLookup : GameplaySkinComponentLookup + public class TaikoSkinComponentLookup : SkinComponentLookup { public TaikoSkinComponentLookup(TaikoSkinComponents component) : base(component) diff --git a/osu.Game/Rulesets/Judgements/DrawableJudgement.cs b/osu.Game/Rulesets/Judgements/DrawableJudgement.cs index 8c326ecf4946..3e70f52ee7ce 100644 --- a/osu.Game/Rulesets/Judgements/DrawableJudgement.cs +++ b/osu.Game/Rulesets/Judgements/DrawableJudgement.cs @@ -163,7 +163,7 @@ private void prepareDrawables() if (JudgementBody != null) RemoveInternal(JudgementBody, true); - AddInternal(JudgementBody = new SkinnableDrawable(new GameplaySkinComponentLookup(type), _ => + AddInternal(JudgementBody = new SkinnableDrawable(new SkinComponentLookup(type), _ => CreateDefaultJudgement(type), confineMode: ConfineMode.NoScaling)); JudgementBody.OnSkinChanged += () => diff --git a/osu.Game/Skinning/GameplaySkinComponentLookup.cs b/osu.Game/Skinning/GameplaySkinComponentLookup.cs deleted file mode 100644 index c317a17e2137..000000000000 --- a/osu.Game/Skinning/GameplaySkinComponentLookup.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using osu.Game.Rulesets.Judgements; -using osu.Game.Rulesets.Scoring; - -namespace osu.Game.Skinning -{ - /// - /// A lookup type intended for use for skinnable gameplay components (not HUD level components). - /// - /// - /// The most common usage of this class is for ruleset-specific skinning implementations, but it can also be used directly - /// (see 's usage for ) where ruleset-agnostic elements are required. - /// - /// An enum lookup type. - public class GameplaySkinComponentLookup : ISkinComponentLookup - where T : Enum - { - public readonly T Component; - - public GameplaySkinComponentLookup(T component) - { - Component = component; - } - } -} diff --git a/osu.Game/Skinning/ISkinComponentLookup.cs b/osu.Game/Skinning/ISkinComponentLookup.cs index 25ee086707ca..af2b512331b3 100644 --- a/osu.Game/Skinning/ISkinComponentLookup.cs +++ b/osu.Game/Skinning/ISkinComponentLookup.cs @@ -12,7 +12,7 @@ namespace osu.Game.Skinning /// to scope particular lookup variations. Using this, a ruleset or skin implementation could make its own lookup /// type to scope away from more global contexts. /// - /// More commonly, a ruleset could make use of to do a simple lookup based on + /// More commonly, a ruleset could make use of to do a simple lookup based on /// a provided enum. /// public interface ISkinComponentLookup diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index d9da208a7b1f..078bef9d0dcb 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -426,7 +426,7 @@ protected override void ParseConfigurationStream(Stream stream) return null; - case GameplaySkinComponentLookup resultComponent: + case SkinComponentLookup resultComponent: // kind of wasteful that we throw this away, but should do for now. if (getJudgementAnimation(resultComponent.Component) != null) diff --git a/osu.Game/Skinning/SkinComponentLookup.cs b/osu.Game/Skinning/SkinComponentLookup.cs new file mode 100644 index 000000000000..4da6bb0c087f --- /dev/null +++ b/osu.Game/Skinning/SkinComponentLookup.cs @@ -0,0 +1,22 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; + +namespace osu.Game.Skinning +{ + /// + /// A lookup type intended for use for skinnable components. + /// + /// An enum lookup type. + public class SkinComponentLookup : ISkinComponentLookup + where T : Enum + { + public readonly T Component; + + public SkinComponentLookup(T component) + { + Component = component; + } + } +} From 9a21174582a53c5e77fd423c678002b2b0b0e9a9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 22 Aug 2024 18:45:44 +0900 Subject: [PATCH 4/8] Move `GlobalSkinnableContainers` to global scope --- .../Legacy/CatchLegacySkinTransformer.cs | 2 +- .../Argon/ManiaArgonSkinTransformer.cs | 2 +- .../Legacy/ManiaLegacySkinTransformer.cs | 2 +- .../Legacy/OsuLegacySkinTransformer.cs | 2 +- .../Skins/SkinDeserialisationTest.cs | 20 ++++++++--------- .../Gameplay/TestSceneBeatmapSkinFallbacks.cs | 4 ++-- .../Visual/Gameplay/TestSceneSkinEditor.cs | 4 ++-- .../TestSceneSkinEditorComponentsList.cs | 2 +- osu.Game/Screens/Play/HUDOverlay.cs | 6 ++--- osu.Game/Screens/Select/SongSelect.cs | 2 +- osu.Game/Skinning/ArgonSkin.cs | 4 ++-- .../GlobalSkinnableContainerLookup.cs | 16 -------------- .../Skinning/GlobalSkinnableContainers.cs | 22 +++++++++++++++++++ osu.Game/Skinning/LegacyBeatmapSkin.cs | 2 +- osu.Game/Skinning/LegacySkin.cs | 2 +- osu.Game/Skinning/Skin.cs | 14 ++++++------ osu.Game/Skinning/TrianglesSkin.cs | 4 ++-- 17 files changed, 58 insertions(+), 52 deletions(-) create mode 100644 osu.Game/Skinning/GlobalSkinnableContainers.cs diff --git a/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs b/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs index ab0420554ee9..61ef1de2b9f1 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs @@ -46,7 +46,7 @@ public CatchLegacySkinTransformer(ISkin skin) // Our own ruleset components default. switch (containerLookup.Target) { - case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: + case GlobalSkinnableContainers.MainHUDComponents: // todo: remove CatchSkinComponents.CatchComboCounter and refactor LegacyCatchComboCounter to be added here instead. return new DefaultSkinComponentsContainer(container => { diff --git a/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs b/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs index d13f0ca21bf9..4d9798b26474 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs @@ -39,7 +39,7 @@ public ManiaArgonSkinTransformer(ISkin skin, IBeatmap beatmap) switch (containerLookup.Target) { - case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: + case GlobalSkinnableContainers.MainHUDComponents: return new DefaultSkinComponentsContainer(container => { var combo = container.ChildrenOfType().FirstOrDefault(); diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs index c9fb55e9cedd..2a79d58f224a 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs @@ -95,7 +95,7 @@ public override Drawable GetDrawableComponent(ISkinComponentLookup lookup) switch (containerLookup.Target) { - case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: + case GlobalSkinnableContainers.MainHUDComponents: return new DefaultSkinComponentsContainer(container => { var combo = container.ChildrenOfType().FirstOrDefault(); diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs index 6609a84be4d2..12dac186943d 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs @@ -60,7 +60,7 @@ public OsuLegacySkinTransformer(ISkin skin) // Our own ruleset components default. switch (containerLookup.Target) { - case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: + case GlobalSkinnableContainers.MainHUDComponents: return new DefaultSkinComponentsContainer(container => { var keyCounter = container.OfType().FirstOrDefault(); diff --git a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs index ad01a057ad43..82b46ee75f71 100644 --- a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs +++ b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs @@ -107,7 +107,7 @@ public void TestDeserialiseModifiedDefault() var skin = new TestSkin(new SkinInfo(), null, storage); Assert.That(skin.LayoutInfos, Has.Count.EqualTo(2)); - Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(9)); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainers.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(9)); } } @@ -120,8 +120,8 @@ public void TestDeserialiseModifiedArgon() var skin = new TestSkin(new SkinInfo(), null, storage); Assert.That(skin.LayoutInfos, Has.Count.EqualTo(2)); - Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(10)); - Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(PlayerName))); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainers.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(10)); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainers.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(PlayerName))); } } @@ -134,10 +134,10 @@ public void TestDeserialiseModifiedClassic() var skin = new TestSkin(new SkinInfo(), null, storage); Assert.That(skin.LayoutInfos, Has.Count.EqualTo(2)); - Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(6)); - Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.SongSelect].AllDrawables.ToArray(), Has.Length.EqualTo(1)); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainers.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(6)); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainers.SongSelect].AllDrawables.ToArray(), Has.Length.EqualTo(1)); - var skinnableInfo = skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.SongSelect].AllDrawables.First(); + var skinnableInfo = skin.LayoutInfos[GlobalSkinnableContainers.SongSelect].AllDrawables.First(); Assert.That(skinnableInfo.Type, Is.EqualTo(typeof(SkinnableSprite))); Assert.That(skinnableInfo.Settings.First().Key, Is.EqualTo("sprite_name")); @@ -148,10 +148,10 @@ public void TestDeserialiseModifiedClassic() using (var storage = new ZipArchiveReader(stream)) { var skin = new TestSkin(new SkinInfo(), null, storage); - Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(8)); - Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(UnstableRateCounter))); - Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(ColourHitErrorMeter))); - Assert.That(skin.LayoutInfos[GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(LegacySongProgress))); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainers.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(8)); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainers.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(UnstableRateCounter))); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainers.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(ColourHitErrorMeter))); + Assert.That(skin.LayoutInfos[GlobalSkinnableContainers.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(LegacySongProgress))); } } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs index 1061f493d46d..5230cea7a583 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs @@ -38,7 +38,7 @@ public void TestEmptyLegacyBeatmapSkinFallsBack() { CreateSkinTest(TrianglesSkin.CreateInfo(), () => new LegacyBeatmapSkin(new BeatmapInfo(), null)); AddUntilStep("wait for hud load", () => Player.ChildrenOfType().All(c => c.ComponentsLoaded)); - AddAssert("hud from default skin", () => AssertComponentsFromExpectedSource(GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents, skinManager.CurrentSkin.Value)); + AddAssert("hud from default skin", () => AssertComponentsFromExpectedSource(GlobalSkinnableContainers.MainHUDComponents, skinManager.CurrentSkin.Value)); } protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func getBeatmapSkin) @@ -53,7 +53,7 @@ protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func getBeatmapSk }); } - protected bool AssertComponentsFromExpectedSource(GlobalSkinnableContainerLookup.GlobalSkinnableContainers target, ISkin expectedSource) + protected bool AssertComponentsFromExpectedSource(GlobalSkinnableContainers target, ISkin expectedSource) { var targetContainer = Player.ChildrenOfType().First(s => s.Lookup.Target == target); var actualComponentsContainer = targetContainer.ChildrenOfType().SingleOrDefault(c => c.Parent == targetContainer); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs index 9e53f86e3340..2a2bff218a3d 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs @@ -378,10 +378,10 @@ public void TestCopyPaste() } private SkinnableContainer globalHUDTarget => Player.ChildrenOfType() - .Single(c => c.Lookup.Target == GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents && c.Lookup.Ruleset == null); + .Single(c => c.Lookup.Target == GlobalSkinnableContainers.MainHUDComponents && c.Lookup.Ruleset == null); private SkinnableContainer rulesetHUDTarget => Player.ChildrenOfType() - .Single(c => c.Lookup.Target == GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents && c.Lookup.Ruleset != null); + .Single(c => c.Lookup.Target == GlobalSkinnableContainers.MainHUDComponents && c.Lookup.Ruleset != null); [Test] public void TestMigrationArgon() diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs index e4b6358600bf..b5fe6633b625 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs @@ -20,7 +20,7 @@ public partial class TestSceneSkinEditorComponentsList : SkinnableTestScene [Test] public void TestToggleEditor() { - var skinComponentsContainer = new SkinnableContainer(new GlobalSkinnableContainerLookup(GlobalSkinnableContainerLookup.GlobalSkinnableContainers.SongSelect)); + var skinComponentsContainer = new SkinnableContainer(new GlobalSkinnableContainerLookup(GlobalSkinnableContainers.SongSelect)); AddStep("show available components", () => SetContents(_ => new SkinComponentToolbox(skinComponentsContainer, null) { diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 7bddef534c61..ac1b9ce34fa8 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -109,7 +109,7 @@ protected override bool ShouldBeConsideredForInput(Drawable child) private readonly List hideTargets; /// - /// The container for skin components attached to + /// The container for skin components attached to /// internal readonly Drawable PlayfieldSkinLayer; @@ -132,7 +132,7 @@ public HUDOverlay([CanBeNull] DrawableRuleset drawableRuleset, IReadOnlyList { // do stuff when we need to. @@ -111,7 +111,7 @@ public ArgonSkin(SkinInfo skin, IStorageResourceProvider resources) return songSelectComponents; - case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: + case GlobalSkinnableContainers.MainHUDComponents: if (containerLookup.Ruleset != null) { return new Container diff --git a/osu.Game/Skinning/GlobalSkinnableContainerLookup.cs b/osu.Game/Skinning/GlobalSkinnableContainerLookup.cs index 384b4aa23c1c..cac8c3bb2fc9 100644 --- a/osu.Game/Skinning/GlobalSkinnableContainerLookup.cs +++ b/osu.Game/Skinning/GlobalSkinnableContainerLookup.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.ComponentModel; using osu.Framework.Extensions; using osu.Game.Rulesets; @@ -58,20 +57,5 @@ public override int GetHashCode() { return HashCode.Combine((int)Target, Ruleset); } - - /// - /// Represents a particular area or part of a game screen whose layout can be customised using the skin editor. - /// - public enum GlobalSkinnableContainers - { - [Description("HUD")] - MainHUDComponents, - - [Description("Song select")] - SongSelect, - - [Description("Playfield")] - Playfield - } } } diff --git a/osu.Game/Skinning/GlobalSkinnableContainers.cs b/osu.Game/Skinning/GlobalSkinnableContainers.cs new file mode 100644 index 000000000000..02f915895f37 --- /dev/null +++ b/osu.Game/Skinning/GlobalSkinnableContainers.cs @@ -0,0 +1,22 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.ComponentModel; + +namespace osu.Game.Skinning +{ + /// + /// Represents a particular area or part of a game screen whose layout can be customised using the skin editor. + /// + public enum GlobalSkinnableContainers + { + [Description("HUD")] + MainHUDComponents, + + [Description("Song select")] + SongSelect, + + [Description("Playfield")] + Playfield + } +} diff --git a/osu.Game/Skinning/LegacyBeatmapSkin.cs b/osu.Game/Skinning/LegacyBeatmapSkin.cs index 54e259a807e4..81dc79b25fe5 100644 --- a/osu.Game/Skinning/LegacyBeatmapSkin.cs +++ b/osu.Game/Skinning/LegacyBeatmapSkin.cs @@ -54,7 +54,7 @@ private static IResourceStore createRealmBackedStore(BeatmapInfo beatmap { switch (containerLookup.Target) { - case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: + case GlobalSkinnableContainers.MainHUDComponents: // this should exist in LegacySkin instead, but there isn't a fallback skin for LegacySkins yet. // therefore keep the check here until fallback default legacy skin is supported. if (!this.HasFont(LegacyFont.Score)) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 078bef9d0dcb..0085bf62ac33 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -364,7 +364,7 @@ protected override void ParseConfigurationStream(Stream stream) switch (containerLookup.Target) { - case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: + case GlobalSkinnableContainers.MainHUDComponents: if (containerLookup.Ruleset != null) { return new DefaultSkinComponentsContainer(container => diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index 581c47402f1e..449a30c022bc 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -43,10 +43,10 @@ public abstract class Skin : IDisposable, ISkin public SkinConfiguration Configuration { get; set; } - public IDictionary LayoutInfos => layoutInfos; + public IDictionary LayoutInfos => layoutInfos; - private readonly Dictionary layoutInfos = - new Dictionary(); + private readonly Dictionary layoutInfos = + new Dictionary(); public abstract ISample? GetSample(ISampleInfo sampleInfo); @@ -123,7 +123,7 @@ protected Skin(SkinInfo skin, IStorageResourceProvider? resources, IResourceStor } // skininfo files may be null for default skin. - foreach (GlobalSkinnableContainerLookup.GlobalSkinnableContainers skinnableTarget in Enum.GetValues()) + foreach (GlobalSkinnableContainers skinnableTarget in Enum.GetValues()) { string filename = $"{skinnableTarget}.json"; @@ -206,7 +206,7 @@ public void UpdateDrawableTarget(SkinnableContainer targetContainer) #region Deserialisation & Migration - private SkinLayoutInfo? parseLayoutInfo(string jsonContent, GlobalSkinnableContainerLookup.GlobalSkinnableContainers target) + private SkinLayoutInfo? parseLayoutInfo(string jsonContent, GlobalSkinnableContainers target) { SkinLayoutInfo? layout = null; @@ -245,7 +245,7 @@ public void UpdateDrawableTarget(SkinnableContainer targetContainer) return layout; } - private void applyMigration(SkinLayoutInfo layout, GlobalSkinnableContainerLookup.GlobalSkinnableContainers target, int version) + private void applyMigration(SkinLayoutInfo layout, GlobalSkinnableContainers target, int version) { switch (version) { @@ -253,7 +253,7 @@ private void applyMigration(SkinLayoutInfo layout, GlobalSkinnableContainerLooku { // Combo counters were moved out of the global HUD components into per-ruleset. // This is to allow some rulesets to customise further (ie. mania and catch moving the combo to within their play area). - if (target != GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents || + if (target != GlobalSkinnableContainers.MainHUDComponents || !layout.TryGetDrawableInfo(null, out var globalHUDComponents) || resources == null) break; diff --git a/osu.Game/Skinning/TrianglesSkin.cs b/osu.Game/Skinning/TrianglesSkin.cs index 8e694b4c3f9a..b0cb54a6f979 100644 --- a/osu.Game/Skinning/TrianglesSkin.cs +++ b/osu.Game/Skinning/TrianglesSkin.cs @@ -76,7 +76,7 @@ public TrianglesSkin(SkinInfo skin, IStorageResourceProvider resources) switch (containerLookup.Target) { - case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.SongSelect: + case GlobalSkinnableContainers.SongSelect: var songSelectComponents = new DefaultSkinComponentsContainer(_ => { // do stuff when we need to. @@ -84,7 +84,7 @@ public TrianglesSkin(SkinInfo skin, IStorageResourceProvider resources) return songSelectComponents; - case GlobalSkinnableContainerLookup.GlobalSkinnableContainers.MainHUDComponents: + case GlobalSkinnableContainers.MainHUDComponents: var skinnableTargetWrapper = new DefaultSkinComponentsContainer(container => { var score = container.OfType().FirstOrDefault(); From b57b8168a62c8ab481b4f2d790cf6a0213f08b89 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 22 Aug 2024 19:00:15 +0900 Subject: [PATCH 5/8] Rename `Target` lookup to `Component` --- .../Skinning/Legacy/CatchLegacySkinTransformer.cs | 2 +- .../Skinning/Argon/ManiaArgonSkinTransformer.cs | 2 +- .../Skinning/Legacy/ManiaLegacySkinTransformer.cs | 2 +- .../Skinning/Legacy/OsuLegacySkinTransformer.cs | 2 +- .../Gameplay/TestSceneBeatmapSkinFallbacks.cs | 2 +- .../Visual/Gameplay/TestSceneSkinEditor.cs | 4 ++-- osu.Game/Skinning/ArgonSkin.cs | 2 +- .../Skinning/GlobalSkinnableContainerLookup.cs | 14 +++++++------- osu.Game/Skinning/LegacyBeatmapSkin.cs | 2 +- osu.Game/Skinning/LegacySkin.cs | 2 +- osu.Game/Skinning/Skin.cs | 8 ++++---- osu.Game/Skinning/TrianglesSkin.cs | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs b/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs index 61ef1de2b9f1..a62a71200147 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs @@ -44,7 +44,7 @@ public CatchLegacySkinTransformer(ISkin skin) return null; // Our own ruleset components default. - switch (containerLookup.Target) + switch (containerLookup.Component) { case GlobalSkinnableContainers.MainHUDComponents: // todo: remove CatchSkinComponents.CatchComboCounter and refactor LegacyCatchComboCounter to be added here instead. diff --git a/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs b/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs index 4d9798b26474..2c361df8b1c3 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs @@ -37,7 +37,7 @@ public ManiaArgonSkinTransformer(ISkin skin, IBeatmap beatmap) if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d) return d; - switch (containerLookup.Target) + switch (containerLookup.Component) { case GlobalSkinnableContainers.MainHUDComponents: return new DefaultSkinComponentsContainer(container => diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs index 2a79d58f224a..895f5a7cc153 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs @@ -93,7 +93,7 @@ public override Drawable GetDrawableComponent(ISkinComponentLookup lookup) if (!IsProvidingLegacyResources) return null; - switch (containerLookup.Target) + switch (containerLookup.Component) { case GlobalSkinnableContainers.MainHUDComponents: return new DefaultSkinComponentsContainer(container => diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs index 12dac186943d..26708f668697 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs @@ -58,7 +58,7 @@ public OsuLegacySkinTransformer(ISkin skin) return null; // Our own ruleset components default. - switch (containerLookup.Target) + switch (containerLookup.Component) { case GlobalSkinnableContainers.MainHUDComponents: return new DefaultSkinComponentsContainer(container => diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs index 5230cea7a583..9a4f084d104b 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs @@ -55,7 +55,7 @@ protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func getBeatmapSk protected bool AssertComponentsFromExpectedSource(GlobalSkinnableContainers target, ISkin expectedSource) { - var targetContainer = Player.ChildrenOfType().First(s => s.Lookup.Target == target); + var targetContainer = Player.ChildrenOfType().First(s => s.Lookup.Component == target); var actualComponentsContainer = targetContainer.ChildrenOfType().SingleOrDefault(c => c.Parent == targetContainer); if (actualComponentsContainer == null) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs index 2a2bff218a3d..4dca8c90017c 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs @@ -378,10 +378,10 @@ public void TestCopyPaste() } private SkinnableContainer globalHUDTarget => Player.ChildrenOfType() - .Single(c => c.Lookup.Target == GlobalSkinnableContainers.MainHUDComponents && c.Lookup.Ruleset == null); + .Single(c => c.Lookup.Component == GlobalSkinnableContainers.MainHUDComponents && c.Lookup.Ruleset == null); private SkinnableContainer rulesetHUDTarget => Player.ChildrenOfType() - .Single(c => c.Lookup.Target == GlobalSkinnableContainers.MainHUDComponents && c.Lookup.Ruleset != null); + .Single(c => c.Lookup.Component == GlobalSkinnableContainers.MainHUDComponents && c.Lookup.Ruleset != null); [Test] public void TestMigrationArgon() diff --git a/osu.Game/Skinning/ArgonSkin.cs b/osu.Game/Skinning/ArgonSkin.cs index 74ab3d885e58..2489013c1ea8 100644 --- a/osu.Game/Skinning/ArgonSkin.cs +++ b/osu.Game/Skinning/ArgonSkin.cs @@ -101,7 +101,7 @@ public ArgonSkin(SkinInfo skin, IStorageResourceProvider resources) if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer c) return c; - switch (containerLookup.Target) + switch (containerLookup.Component) { case GlobalSkinnableContainers.SongSelect: var songSelectComponents = new DefaultSkinComponentsContainer(_ => diff --git a/osu.Game/Skinning/GlobalSkinnableContainerLookup.cs b/osu.Game/Skinning/GlobalSkinnableContainerLookup.cs index cac8c3bb2fc9..524d99197af7 100644 --- a/osu.Game/Skinning/GlobalSkinnableContainerLookup.cs +++ b/osu.Game/Skinning/GlobalSkinnableContainerLookup.cs @@ -15,7 +15,7 @@ public class GlobalSkinnableContainerLookup : ISkinComponentLookup, IEquatable /// The target area / layer of the game for which skin components will be returned. /// - public readonly GlobalSkinnableContainers Target; + public readonly GlobalSkinnableContainers Component; /// /// The ruleset for which skin components should be returned. @@ -23,17 +23,17 @@ public class GlobalSkinnableContainerLookup : ISkinComponentLookup, IEquatable public readonly RulesetInfo? Ruleset; - public GlobalSkinnableContainerLookup(GlobalSkinnableContainers target, RulesetInfo? ruleset = null) + public GlobalSkinnableContainerLookup(GlobalSkinnableContainers component, RulesetInfo? ruleset = null) { - Target = target; + Component = component; Ruleset = ruleset; } public override string ToString() { - if (Ruleset == null) return Target.GetDescription(); + if (Ruleset == null) return Component.GetDescription(); - return $"{Target.GetDescription()} (\"{Ruleset.Name}\" only)"; + return $"{Component.GetDescription()} (\"{Ruleset.Name}\" only)"; } public bool Equals(GlobalSkinnableContainerLookup? other) @@ -41,7 +41,7 @@ public bool Equals(GlobalSkinnableContainerLookup? other) if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; - return Target == other.Target && (ReferenceEquals(Ruleset, other.Ruleset) || Ruleset?.Equals(other.Ruleset) == true); + return Component == other.Component && (ReferenceEquals(Ruleset, other.Ruleset) || Ruleset?.Equals(other.Ruleset) == true); } public override bool Equals(object? obj) @@ -55,7 +55,7 @@ public override bool Equals(object? obj) public override int GetHashCode() { - return HashCode.Combine((int)Target, Ruleset); + return HashCode.Combine((int)Component, Ruleset); } } } diff --git a/osu.Game/Skinning/LegacyBeatmapSkin.cs b/osu.Game/Skinning/LegacyBeatmapSkin.cs index 81dc79b25fe5..c8a93f418f35 100644 --- a/osu.Game/Skinning/LegacyBeatmapSkin.cs +++ b/osu.Game/Skinning/LegacyBeatmapSkin.cs @@ -52,7 +52,7 @@ private static IResourceStore createRealmBackedStore(BeatmapInfo beatmap { if (lookup is GlobalSkinnableContainerLookup containerLookup) { - switch (containerLookup.Target) + switch (containerLookup.Component) { case GlobalSkinnableContainers.MainHUDComponents: // this should exist in LegacySkin instead, but there isn't a fallback skin for LegacySkins yet. diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 0085bf62ac33..16d9cf391cef 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -362,7 +362,7 @@ protected override void ParseConfigurationStream(Stream stream) if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer c) return c; - switch (containerLookup.Target) + switch (containerLookup.Component) { case GlobalSkinnableContainers.MainHUDComponents: if (containerLookup.Ruleset != null) diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index 449a30c022bc..04a7fd53f769 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -164,7 +164,7 @@ protected virtual void ParseConfigurationStream(Stream stream) /// The target container to reset. public void ResetDrawableTarget(SkinnableContainer targetContainer) { - LayoutInfos.Remove(targetContainer.Lookup.Target); + LayoutInfos.Remove(targetContainer.Lookup.Component); } /// @@ -173,8 +173,8 @@ public void ResetDrawableTarget(SkinnableContainer targetContainer) /// The target container to serialise to this skin. public void UpdateDrawableTarget(SkinnableContainer targetContainer) { - if (!LayoutInfos.TryGetValue(targetContainer.Lookup.Target, out var layoutInfo)) - layoutInfos[targetContainer.Lookup.Target] = layoutInfo = new SkinLayoutInfo(); + if (!LayoutInfos.TryGetValue(targetContainer.Lookup.Component, out var layoutInfo)) + layoutInfos[targetContainer.Lookup.Component] = layoutInfo = new SkinLayoutInfo(); layoutInfo.Update(targetContainer.Lookup.Ruleset, ((ISerialisableDrawableContainer)targetContainer).CreateSerialisedInfo().ToArray()); } @@ -191,7 +191,7 @@ public void UpdateDrawableTarget(SkinnableContainer targetContainer) // It is important to return null if the user has not configured this yet. // This allows skin transformers the opportunity to provide default components. - if (!LayoutInfos.TryGetValue(containerLookup.Target, out var layoutInfo)) return null; + if (!LayoutInfos.TryGetValue(containerLookup.Component, out var layoutInfo)) return null; if (!layoutInfo.TryGetDrawableInfo(containerLookup.Ruleset, out var drawableInfos)) return null; return new UserConfiguredLayoutContainer diff --git a/osu.Game/Skinning/TrianglesSkin.cs b/osu.Game/Skinning/TrianglesSkin.cs index b0cb54a6f979..c0d327a082d8 100644 --- a/osu.Game/Skinning/TrianglesSkin.cs +++ b/osu.Game/Skinning/TrianglesSkin.cs @@ -74,7 +74,7 @@ public TrianglesSkin(SkinInfo skin, IStorageResourceProvider resources) if (containerLookup.Ruleset != null) return null; - switch (containerLookup.Target) + switch (containerLookup.Component) { case GlobalSkinnableContainers.SongSelect: var songSelectComponents = new DefaultSkinComponentsContainer(_ => From 1435fe24ae8076baa494652439785ab318009ea3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 22 Aug 2024 17:14:35 +0900 Subject: [PATCH 6/8] Remove requirement of `base` calls to ensure user skin container layouts are retrieved --- .../Legacy/CatchLegacySkinTransformer.cs | 4 --- .../Legacy/ManiaLegacySkinTransformer.cs | 4 --- .../Legacy/OsuLegacySkinTransformer.cs | 4 --- osu.Game/Skinning/Skin.cs | 27 +++++++++++-------- osu.Game/Skinning/SkinnableContainer.cs | 5 +++- osu.Game/Skinning/UserSkinComponentLookup.cs | 18 +++++++++++++ 6 files changed, 38 insertions(+), 24 deletions(-) create mode 100644 osu.Game/Skinning/UserSkinComponentLookup.cs diff --git a/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs b/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs index a62a71200147..e64dcd4e7599 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs @@ -35,10 +35,6 @@ public CatchLegacySkinTransformer(ISkin skin) if (containerLookup.Ruleset == null) return base.GetDrawableComponent(lookup); - // Skin has configuration. - if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d) - return d; - // we don't have enough assets to display these components (this is especially the case on a "beatmap" skin). if (!IsProvidingLegacyResources) return null; diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs index 895f5a7cc153..3372cb70db68 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs @@ -85,10 +85,6 @@ public override Drawable GetDrawableComponent(ISkinComponentLookup lookup) if (containerLookup.Ruleset == null) return base.GetDrawableComponent(lookup); - // Skin has configuration. - if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d) - return d; - // we don't have enough assets to display these components (this is especially the case on a "beatmap" skin). if (!IsProvidingLegacyResources) return null; diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs index 26708f668697..afccdcc3ac23 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs @@ -49,10 +49,6 @@ public OsuLegacySkinTransformer(ISkin skin) if (containerLookup.Ruleset == null) return base.GetDrawableComponent(lookup); - // Skin has configuration. - if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d) - return d; - // we don't have enough assets to display these components (this is especially the case on a "beatmap" skin). if (!IsProvidingLegacyResources) return null; diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index 04a7fd53f769..694aaf882a50 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -187,18 +187,23 @@ public void UpdateDrawableTarget(SkinnableContainer targetContainer) case SkinnableSprite.SpriteComponentLookup sprite: return this.GetAnimation(sprite.LookupName, false, false, maxSize: sprite.MaxSize); - case GlobalSkinnableContainerLookup containerLookup: - - // It is important to return null if the user has not configured this yet. - // This allows skin transformers the opportunity to provide default components. - if (!LayoutInfos.TryGetValue(containerLookup.Component, out var layoutInfo)) return null; - if (!layoutInfo.TryGetDrawableInfo(containerLookup.Ruleset, out var drawableInfos)) return null; - - return new UserConfiguredLayoutContainer + case UserSkinComponentLookup userLookup: + switch (userLookup.Component) { - RelativeSizeAxes = Axes.Both, - ChildrenEnumerable = drawableInfos.Select(i => i.CreateInstance()) - }; + case GlobalSkinnableContainerLookup containerLookup: + // It is important to return null if the user has not configured this yet. + // This allows skin transformers the opportunity to provide default components. + if (!LayoutInfos.TryGetValue(containerLookup.Component, out var layoutInfo)) return null; + if (!layoutInfo.TryGetDrawableInfo(containerLookup.Ruleset, out var drawableInfos)) return null; + + return new UserConfiguredLayoutContainer + { + RelativeSizeAxes = Axes.Both, + ChildrenEnumerable = drawableInfos.Select(i => i.CreateInstance()) + }; + } + + break; } return null; diff --git a/osu.Game/Skinning/SkinnableContainer.cs b/osu.Game/Skinning/SkinnableContainer.cs index c58992c5410f..aad95ca779c2 100644 --- a/osu.Game/Skinning/SkinnableContainer.cs +++ b/osu.Game/Skinning/SkinnableContainer.cs @@ -43,7 +43,10 @@ public SkinnableContainer(GlobalSkinnableContainerLookup lookup) Lookup = lookup; } - public void Reload() => Reload(CurrentSkin.GetDrawableComponent(Lookup) as Container); + public void Reload() => Reload(( + CurrentSkin.GetDrawableComponent(new UserSkinComponentLookup(Lookup)) + ?? CurrentSkin.GetDrawableComponent(Lookup)) + as Container); public void Reload(Container? componentsContainer) { diff --git a/osu.Game/Skinning/UserSkinComponentLookup.cs b/osu.Game/Skinning/UserSkinComponentLookup.cs new file mode 100644 index 000000000000..1ecdc96b38c9 --- /dev/null +++ b/osu.Game/Skinning/UserSkinComponentLookup.cs @@ -0,0 +1,18 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +namespace osu.Game.Skinning +{ + /// + /// A lookup class which is only for internal use, and explicitly to get a user-level configuration. + /// + internal class UserSkinComponentLookup : ISkinComponentLookup + { + public readonly ISkinComponentLookup Component; + + public UserSkinComponentLookup(ISkinComponentLookup component) + { + Component = component; + } + } +} From 46d55d5e61356b8e7a1771e9e9c72fb014713324 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 22 Aug 2024 20:13:24 +0900 Subject: [PATCH 7/8] Remove remaining early `base` lookup calls which were missed --- .../Skinning/Argon/ManiaArgonSkinTransformer.cs | 4 ---- osu.Game/Skinning/ArgonSkin.cs | 4 ---- osu.Game/Skinning/LegacySkin.cs | 3 --- osu.Game/Skinning/Skin.cs | 3 ++- osu.Game/Skinning/TrianglesSkin.cs | 3 --- .../Skinning/UserConfiguredLayoutContainer.cs | 15 --------------- 6 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 osu.Game/Skinning/UserConfiguredLayoutContainer.cs diff --git a/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs b/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs index 2c361df8b1c3..8707246402c2 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs @@ -33,10 +33,6 @@ public ManiaArgonSkinTransformer(ISkin skin, IBeatmap beatmap) if (containerLookup.Ruleset == null) return base.GetDrawableComponent(lookup); - // Skin has configuration. - if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d) - return d; - switch (containerLookup.Component) { case GlobalSkinnableContainers.MainHUDComponents: diff --git a/osu.Game/Skinning/ArgonSkin.cs b/osu.Game/Skinning/ArgonSkin.cs index 2489013c1ea8..6baba02d296d 100644 --- a/osu.Game/Skinning/ArgonSkin.cs +++ b/osu.Game/Skinning/ArgonSkin.cs @@ -97,10 +97,6 @@ public ArgonSkin(SkinInfo skin, IStorageResourceProvider resources) switch (lookup) { case GlobalSkinnableContainerLookup containerLookup: - - if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer c) - return c; - switch (containerLookup.Component) { case GlobalSkinnableContainers.SongSelect: diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 16d9cf391cef..8706f24e618b 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -359,9 +359,6 @@ protected override void ParseConfigurationStream(Stream stream) switch (lookup) { case GlobalSkinnableContainerLookup containerLookup: - if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer c) - return c; - switch (containerLookup.Component) { case GlobalSkinnableContainers.MainHUDComponents: diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index 694aaf882a50..4c7dda50a992 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -14,6 +14,7 @@ using osu.Framework.Bindables; using osu.Framework.Extensions.TypeExtensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Textures; using osu.Framework.IO.Stores; using osu.Framework.Logging; @@ -196,7 +197,7 @@ public void UpdateDrawableTarget(SkinnableContainer targetContainer) if (!LayoutInfos.TryGetValue(containerLookup.Component, out var layoutInfo)) return null; if (!layoutInfo.TryGetDrawableInfo(containerLookup.Ruleset, out var drawableInfos)) return null; - return new UserConfiguredLayoutContainer + return new Container { RelativeSizeAxes = Axes.Both, ChildrenEnumerable = drawableInfos.Select(i => i.CreateInstance()) diff --git a/osu.Game/Skinning/TrianglesSkin.cs b/osu.Game/Skinning/TrianglesSkin.cs index c0d327a082d8..ca0653ee12de 100644 --- a/osu.Game/Skinning/TrianglesSkin.cs +++ b/osu.Game/Skinning/TrianglesSkin.cs @@ -67,9 +67,6 @@ public TrianglesSkin(SkinInfo skin, IStorageResourceProvider resources) switch (lookup) { case GlobalSkinnableContainerLookup containerLookup: - if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer c) - return c; - // Only handle global level defaults for now. if (containerLookup.Ruleset != null) return null; diff --git a/osu.Game/Skinning/UserConfiguredLayoutContainer.cs b/osu.Game/Skinning/UserConfiguredLayoutContainer.cs deleted file mode 100644 index 1b5a27b53be4..000000000000 --- a/osu.Game/Skinning/UserConfiguredLayoutContainer.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Graphics.Containers; - -namespace osu.Game.Skinning -{ - /// - /// This signifies that a call resolved a configuration created - /// by a user in their skin. Generally this should be given priority over any local defaults or overrides. - /// - public partial class UserConfiguredLayoutContainer : Container - { - } -} From 48cfd77ee8d0ef359db019855ce6653103b23cef Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 23 Aug 2024 14:48:50 +0900 Subject: [PATCH 8/8] `Component` -> `Lookup` --- .../Skinning/Legacy/CatchLegacySkinTransformer.cs | 2 +- .../Skinning/Argon/ManiaArgonSkinTransformer.cs | 2 +- .../Skinning/Legacy/ManiaLegacySkinTransformer.cs | 2 +- .../Skinning/Legacy/OsuLegacySkinTransformer.cs | 2 +- .../Gameplay/TestSceneBeatmapSkinFallbacks.cs | 2 +- .../Visual/Gameplay/TestSceneSkinEditor.cs | 4 ++-- osu.Game/Skinning/ArgonSkin.cs | 2 +- .../Skinning/GlobalSkinnableContainerLookup.cs | 14 +++++++------- osu.Game/Skinning/LegacyBeatmapSkin.cs | 2 +- osu.Game/Skinning/LegacySkin.cs | 2 +- osu.Game/Skinning/Skin.cs | 8 ++++---- osu.Game/Skinning/TrianglesSkin.cs | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs b/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs index e64dcd4e7599..69efb7fbca84 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs @@ -40,7 +40,7 @@ public CatchLegacySkinTransformer(ISkin skin) return null; // Our own ruleset components default. - switch (containerLookup.Component) + switch (containerLookup.Lookup) { case GlobalSkinnableContainers.MainHUDComponents: // todo: remove CatchSkinComponents.CatchComboCounter and refactor LegacyCatchComboCounter to be added here instead. diff --git a/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs b/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs index 8707246402c2..afccb2e56829 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Argon/ManiaArgonSkinTransformer.cs @@ -33,7 +33,7 @@ public ManiaArgonSkinTransformer(ISkin skin, IBeatmap beatmap) if (containerLookup.Ruleset == null) return base.GetDrawableComponent(lookup); - switch (containerLookup.Component) + switch (containerLookup.Lookup) { case GlobalSkinnableContainers.MainHUDComponents: return new DefaultSkinComponentsContainer(container => diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs index 3372cb70db68..cb42b2b62aba 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/ManiaLegacySkinTransformer.cs @@ -89,7 +89,7 @@ public override Drawable GetDrawableComponent(ISkinComponentLookup lookup) if (!IsProvidingLegacyResources) return null; - switch (containerLookup.Component) + switch (containerLookup.Lookup) { case GlobalSkinnableContainers.MainHUDComponents: return new DefaultSkinComponentsContainer(container => diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs index afccdcc3ac23..636a9ecb21b1 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs @@ -54,7 +54,7 @@ public OsuLegacySkinTransformer(ISkin skin) return null; // Our own ruleset components default. - switch (containerLookup.Component) + switch (containerLookup.Lookup) { case GlobalSkinnableContainers.MainHUDComponents: return new DefaultSkinComponentsContainer(container => diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs index 9a4f084d104b..5ec32f318cee 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs @@ -55,7 +55,7 @@ protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func getBeatmapSk protected bool AssertComponentsFromExpectedSource(GlobalSkinnableContainers target, ISkin expectedSource) { - var targetContainer = Player.ChildrenOfType().First(s => s.Lookup.Component == target); + var targetContainer = Player.ChildrenOfType().First(s => s.Lookup.Lookup == target); var actualComponentsContainer = targetContainer.ChildrenOfType().SingleOrDefault(c => c.Parent == targetContainer); if (actualComponentsContainer == null) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs index 4dca8c90017c..3a7bc0530010 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs @@ -378,10 +378,10 @@ public void TestCopyPaste() } private SkinnableContainer globalHUDTarget => Player.ChildrenOfType() - .Single(c => c.Lookup.Component == GlobalSkinnableContainers.MainHUDComponents && c.Lookup.Ruleset == null); + .Single(c => c.Lookup.Lookup == GlobalSkinnableContainers.MainHUDComponents && c.Lookup.Ruleset == null); private SkinnableContainer rulesetHUDTarget => Player.ChildrenOfType() - .Single(c => c.Lookup.Component == GlobalSkinnableContainers.MainHUDComponents && c.Lookup.Ruleset != null); + .Single(c => c.Lookup.Lookup == GlobalSkinnableContainers.MainHUDComponents && c.Lookup.Ruleset != null); [Test] public void TestMigrationArgon() diff --git a/osu.Game/Skinning/ArgonSkin.cs b/osu.Game/Skinning/ArgonSkin.cs index 6baba02d296d..771d10d73b0e 100644 --- a/osu.Game/Skinning/ArgonSkin.cs +++ b/osu.Game/Skinning/ArgonSkin.cs @@ -97,7 +97,7 @@ public ArgonSkin(SkinInfo skin, IStorageResourceProvider resources) switch (lookup) { case GlobalSkinnableContainerLookup containerLookup: - switch (containerLookup.Component) + switch (containerLookup.Lookup) { case GlobalSkinnableContainers.SongSelect: var songSelectComponents = new DefaultSkinComponentsContainer(_ => diff --git a/osu.Game/Skinning/GlobalSkinnableContainerLookup.cs b/osu.Game/Skinning/GlobalSkinnableContainerLookup.cs index 524d99197af7..6d78981f0a67 100644 --- a/osu.Game/Skinning/GlobalSkinnableContainerLookup.cs +++ b/osu.Game/Skinning/GlobalSkinnableContainerLookup.cs @@ -15,7 +15,7 @@ public class GlobalSkinnableContainerLookup : ISkinComponentLookup, IEquatable /// The target area / layer of the game for which skin components will be returned. /// - public readonly GlobalSkinnableContainers Component; + public readonly GlobalSkinnableContainers Lookup; /// /// The ruleset for which skin components should be returned. @@ -23,17 +23,17 @@ public class GlobalSkinnableContainerLookup : ISkinComponentLookup, IEquatable public readonly RulesetInfo? Ruleset; - public GlobalSkinnableContainerLookup(GlobalSkinnableContainers component, RulesetInfo? ruleset = null) + public GlobalSkinnableContainerLookup(GlobalSkinnableContainers lookup, RulesetInfo? ruleset = null) { - Component = component; + Lookup = lookup; Ruleset = ruleset; } public override string ToString() { - if (Ruleset == null) return Component.GetDescription(); + if (Ruleset == null) return Lookup.GetDescription(); - return $"{Component.GetDescription()} (\"{Ruleset.Name}\" only)"; + return $"{Lookup.GetDescription()} (\"{Ruleset.Name}\" only)"; } public bool Equals(GlobalSkinnableContainerLookup? other) @@ -41,7 +41,7 @@ public bool Equals(GlobalSkinnableContainerLookup? other) if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; - return Component == other.Component && (ReferenceEquals(Ruleset, other.Ruleset) || Ruleset?.Equals(other.Ruleset) == true); + return Lookup == other.Lookup && (ReferenceEquals(Ruleset, other.Ruleset) || Ruleset?.Equals(other.Ruleset) == true); } public override bool Equals(object? obj) @@ -55,7 +55,7 @@ public override bool Equals(object? obj) public override int GetHashCode() { - return HashCode.Combine((int)Component, Ruleset); + return HashCode.Combine((int)Lookup, Ruleset); } } } diff --git a/osu.Game/Skinning/LegacyBeatmapSkin.cs b/osu.Game/Skinning/LegacyBeatmapSkin.cs index c8a93f418f35..656c0e046f59 100644 --- a/osu.Game/Skinning/LegacyBeatmapSkin.cs +++ b/osu.Game/Skinning/LegacyBeatmapSkin.cs @@ -52,7 +52,7 @@ private static IResourceStore createRealmBackedStore(BeatmapInfo beatmap { if (lookup is GlobalSkinnableContainerLookup containerLookup) { - switch (containerLookup.Component) + switch (containerLookup.Lookup) { case GlobalSkinnableContainers.MainHUDComponents: // this should exist in LegacySkin instead, but there isn't a fallback skin for LegacySkins yet. diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 8706f24e618b..6faadfba9b54 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -359,7 +359,7 @@ protected override void ParseConfigurationStream(Stream stream) switch (lookup) { case GlobalSkinnableContainerLookup containerLookup: - switch (containerLookup.Component) + switch (containerLookup.Lookup) { case GlobalSkinnableContainers.MainHUDComponents: if (containerLookup.Ruleset != null) diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index 4c7dda50a992..2382253036a9 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -165,7 +165,7 @@ protected virtual void ParseConfigurationStream(Stream stream) /// The target container to reset. public void ResetDrawableTarget(SkinnableContainer targetContainer) { - LayoutInfos.Remove(targetContainer.Lookup.Component); + LayoutInfos.Remove(targetContainer.Lookup.Lookup); } /// @@ -174,8 +174,8 @@ public void ResetDrawableTarget(SkinnableContainer targetContainer) /// The target container to serialise to this skin. public void UpdateDrawableTarget(SkinnableContainer targetContainer) { - if (!LayoutInfos.TryGetValue(targetContainer.Lookup.Component, out var layoutInfo)) - layoutInfos[targetContainer.Lookup.Component] = layoutInfo = new SkinLayoutInfo(); + if (!LayoutInfos.TryGetValue(targetContainer.Lookup.Lookup, out var layoutInfo)) + layoutInfos[targetContainer.Lookup.Lookup] = layoutInfo = new SkinLayoutInfo(); layoutInfo.Update(targetContainer.Lookup.Ruleset, ((ISerialisableDrawableContainer)targetContainer).CreateSerialisedInfo().ToArray()); } @@ -194,7 +194,7 @@ public void UpdateDrawableTarget(SkinnableContainer targetContainer) case GlobalSkinnableContainerLookup containerLookup: // It is important to return null if the user has not configured this yet. // This allows skin transformers the opportunity to provide default components. - if (!LayoutInfos.TryGetValue(containerLookup.Component, out var layoutInfo)) return null; + if (!LayoutInfos.TryGetValue(containerLookup.Lookup, out var layoutInfo)) return null; if (!layoutInfo.TryGetDrawableInfo(containerLookup.Ruleset, out var drawableInfos)) return null; return new Container diff --git a/osu.Game/Skinning/TrianglesSkin.cs b/osu.Game/Skinning/TrianglesSkin.cs index ca0653ee12de..d562fd325675 100644 --- a/osu.Game/Skinning/TrianglesSkin.cs +++ b/osu.Game/Skinning/TrianglesSkin.cs @@ -71,7 +71,7 @@ public TrianglesSkin(SkinInfo skin, IStorageResourceProvider resources) if (containerLookup.Ruleset != null) return null; - switch (containerLookup.Component) + switch (containerLookup.Lookup) { case GlobalSkinnableContainers.SongSelect: var songSelectComponents = new DefaultSkinComponentsContainer(_ =>