Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename SkinComponentsContainer -> SkinnableContainer #27932

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void TestLegacyHUDComboCounterHidden([Values] bool withModifiedSkin)
if (withModifiedSkin)
{
AddStep("change component scale", () => Player.ChildrenOfType<LegacyScoreCounter>().First().Scale = new Vector2(2f));
AddStep("update target", () => Player.ChildrenOfType<SkinComponentsContainer>().ForEach(LegacySkin.UpdateDrawableTarget));
AddStep("update target", () => Player.ChildrenOfType<SkinnableContainer>().ForEach(LegacySkin.UpdateDrawableTarget));
AddStep("exit player", () => Player.Exit());
CreateTest();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public CatchLegacySkinTransformer(ISkin skin)

public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
if (lookup is SkinComponentsContainerLookup containerLookup)
if (lookup is SkinnableContainerLookup containerLookup)
{
switch (containerLookup.Target)
{
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents:
case SkinnableContainerLookup.TargetArea.MainHUDComponents:
var components = base.GetDrawableComponent(lookup) as Container;

if (providesComboCounter && components != null)
Expand Down
20 changes: 10 additions & 10 deletions osu.Game.Tests/Skins/SkinDeserialisationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,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[SkinnableContainerLookup.TargetArea.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(9));
}
}

Expand All @@ -114,8 +114,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[SkinnableContainerLookup.TargetArea.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(10));
Assert.That(skin.LayoutInfos[SkinnableContainerLookup.TargetArea.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(PlayerName)));
}
}

Expand All @@ -128,10 +128,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[SkinnableContainerLookup.TargetArea.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(6));
Assert.That(skin.LayoutInfos[SkinnableContainerLookup.TargetArea.SongSelect].AllDrawables.ToArray(), Has.Length.EqualTo(1));

var skinnableInfo = skin.LayoutInfos[SkinComponentsContainerLookup.TargetArea.SongSelect].AllDrawables.First();
var skinnableInfo = skin.LayoutInfos[SkinnableContainerLookup.TargetArea.SongSelect].AllDrawables.First();

Assert.That(skinnableInfo.Type, Is.EqualTo(typeof(SkinnableSprite)));
Assert.That(skinnableInfo.Settings.First().Key, Is.EqualTo("sprite_name"));
Expand All @@ -142,10 +142,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[SkinnableContainerLookup.TargetArea.MainHUDComponents].AllDrawables.ToArray(), Has.Length.EqualTo(8));
Assert.That(skin.LayoutInfos[SkinnableContainerLookup.TargetArea.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(UnstableRateCounter)));
Assert.That(skin.LayoutInfos[SkinnableContainerLookup.TargetArea.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(ColourHitErrorMeter)));
Assert.That(skin.LayoutInfos[SkinnableContainerLookup.TargetArea.MainHUDComponents].AllDrawables.Select(i => i.Type), Contains.Item(typeof(LegacySongProgress)));
}
}

Expand Down
10 changes: 5 additions & 5 deletions osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public partial class TestSceneBeatmapSkinFallbacks : OsuPlayerTestScene
public void TestEmptyLegacyBeatmapSkinFallsBack()
{
CreateSkinTest(TrianglesSkin.CreateInfo(), () => new LegacyBeatmapSkin(new BeatmapInfo(), null));
AddUntilStep("wait for hud load", () => Player.ChildrenOfType<SkinComponentsContainer>().All(c => c.ComponentsLoaded));
AddAssert("hud from default skin", () => AssertComponentsFromExpectedSource(SkinComponentsContainerLookup.TargetArea.MainHUDComponents, skinManager.CurrentSkin.Value));
AddUntilStep("wait for hud load", () => Player.ChildrenOfType<SkinnableContainer>().All(c => c.ComponentsLoaded));
AddAssert("hud from default skin", () => AssertComponentsFromExpectedSource(SkinnableContainerLookup.TargetArea.MainHUDComponents, skinManager.CurrentSkin.Value));
}

protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func<ISkin> getBeatmapSkin)
Expand All @@ -53,17 +53,17 @@ protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func<ISkin> getBeatmapSk
});
}

protected bool AssertComponentsFromExpectedSource(SkinComponentsContainerLookup.TargetArea target, ISkin expectedSource)
protected bool AssertComponentsFromExpectedSource(SkinnableContainerLookup.TargetArea target, ISkin expectedSource)
{
var targetContainer = Player.ChildrenOfType<SkinComponentsContainer>().First(s => s.Lookup.Target == target);
var targetContainer = Player.ChildrenOfType<SkinnableContainer>().First(s => s.Lookup.Target == target);
var actualComponentsContainer = targetContainer.ChildrenOfType<Container>().SingleOrDefault(c => c.Parent == targetContainer);

if (actualComponentsContainer == null)
return false;

var actualInfo = actualComponentsContainer.CreateSerialisedInfo();

var expectedComponentsContainer = expectedSource.GetDrawableComponent(new SkinComponentsContainerLookup(target)) as Container;
var expectedComponentsContainer = expectedSource.GetDrawableComponent(new SkinnableContainerLookup(target)) as Container;
if (expectedComponentsContainer == null)
return false;

Expand Down
12 changes: 6 additions & 6 deletions osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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<SkinComponentsContainer>().First();
private Drawable hideTarget => hudOverlay.ChildrenOfType<SkinnableContainer>().First();
private Drawable keyCounterFlow => hudOverlay.ChildrenOfType<KeyCounterDisplay>().First().ChildrenOfType<FillFlowContainer<KeyCounter>>().Single();

public TestSceneHUDOverlay()
Expand Down Expand Up @@ -241,8 +241,8 @@ public void TestHiddenHUDDoesntBlockComponentUpdates()

createNew();

AddUntilStep("wait for components to be hidden", () => hudOverlay.ChildrenOfType<SkinComponentsContainer>().Single().Alpha == 0);
AddUntilStep("wait for hud load", () => hudOverlay.ChildrenOfType<SkinComponentsContainer>().All(c => c.ComponentsLoaded));
AddUntilStep("wait for components to be hidden", () => hudOverlay.ChildrenOfType<SkinnableContainer>().Single().Alpha == 0);
AddUntilStep("wait for hud load", () => hudOverlay.ChildrenOfType<SkinnableContainer>().All(c => c.ComponentsLoaded));

AddStep("bind on update", () =>
{
Expand All @@ -259,10 +259,10 @@ public void TestHiddenHUDDoesntBlockSkinnableComponentsLoad()

createNew();

AddUntilStep("wait for components to be hidden", () => hudOverlay.ChildrenOfType<SkinComponentsContainer>().Single().Alpha == 0);
AddUntilStep("wait for components to be hidden", () => hudOverlay.ChildrenOfType<SkinnableContainer>().Single().Alpha == 0);

AddStep("reload components", () => hudOverlay.ChildrenOfType<SkinComponentsContainer>().Single().Reload());
AddUntilStep("skinnable components loaded", () => hudOverlay.ChildrenOfType<SkinComponentsContainer>().Single().ComponentsLoaded);
AddStep("reload components", () => hudOverlay.ChildrenOfType<SkinnableContainer>().Single().Reload());
AddUntilStep("skinnable components loaded", () => hudOverlay.ChildrenOfType<SkinnableContainer>().Single().ComponentsLoaded);
}

private void createNew(Action<HUDOverlay>? action = null)
Expand Down
8 changes: 4 additions & 4 deletions osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public partial class TestSceneSkinEditor : PlayerTestScene
[Cached]
public readonly EditorClipboard Clipboard = new EditorClipboard();

private SkinComponentsContainer targetContainer => Player.ChildrenOfType<SkinComponentsContainer>().First();
private SkinnableContainer targetContainer => Player.ChildrenOfType<SkinnableContainer>().First();

[SetUpSteps]
public override void SetUpSteps()
Expand Down Expand Up @@ -67,7 +67,7 @@ public void TestDragSelection()

AddStep("Add big black boxes", () =>
{
var target = Player.ChildrenOfType<SkinComponentsContainer>().First();
var target = Player.ChildrenOfType<SkinnableContainer>().First();
target.Add(box1 = new BigBlackBox
{
Position = new Vector2(-90),
Expand Down Expand Up @@ -192,14 +192,14 @@ public void TestCyclicSelection()
[Test]
public void TestUndoEditHistory()
{
SkinComponentsContainer firstTarget = null!;
SkinnableContainer firstTarget = null!;
TestSkinEditorChangeHandler changeHandler = null!;
byte[] defaultState = null!;
IEnumerable<ISerialisableDrawable> testComponents = null!;

AddStep("Load necessary things", () =>
{
firstTarget = Player.ChildrenOfType<SkinComponentsContainer>().First();
firstTarget = Player.ChildrenOfType<SkinnableContainer>().First();
changeHandler = new TestSkinEditorChangeHandler(firstTarget);

changeHandler.SaveState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 SkinnableContainerLookup(SkinnableContainerLookup.TargetArea.SongSelect));

AddStep("show available components", () => SetContents(_ => new SkinComponentToolbox(skinComponentsContainer, null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public partial class TestSceneSkinnableHUDOverlay : SkinnableTestScene
private IEnumerable<HUDOverlay> hudOverlays => CreatedDrawables.OfType<HUDOverlay>();

// best way to check without exposing.
private Drawable hideTarget => hudOverlay.ChildrenOfType<SkinComponentsContainer>().First();
private Drawable hideTarget => hudOverlay.ChildrenOfType<SkinnableContainer>().First();
private Drawable keyCounterFlow => hudOverlay.ChildrenOfType<KeyCounterDisplay>().First().ChildrenOfType<FillFlowContainer<KeyCounter>>().Single();

public TestSceneSkinnableHUDOverlay()
Expand Down Expand Up @@ -103,7 +103,7 @@ private void createNew(Action<HUDOverlay> action = null)
});
AddUntilStep("HUD overlay loaded", () => hudOverlay.IsAlive);
AddUntilStep("components container loaded",
() => hudOverlay.ChildrenOfType<SkinComponentsContainer>().Any(scc => scc.ComponentsLoaded));
() => hudOverlay.ChildrenOfType<SkinnableContainer>().Any(scc => scc.ComponentsLoaded));
}

protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Overlays/SkinEditor/SkinComponentToolbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public partial class SkinComponentToolbox : EditorSidebarSection
{
public Action<Type>? RequestPlacement;

private readonly SkinComponentsContainer target;
private readonly SkinnableContainer target;

private readonly RulesetInfo? ruleset;

Expand All @@ -35,7 +35,7 @@ public partial class SkinComponentToolbox : EditorSidebarSection
/// </summary>
/// <param name="target">The target. This is mainly used as a dependency source to find candidate components.</param>
/// <param name="ruleset">A ruleset to filter components by. If null, only components which are not ruleset-specific will be included.</param>
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;
Expand Down
20 changes: 10 additions & 10 deletions osu.Game/Overlays/SkinEditor/SkinEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public partial class SkinEditor : VisibilityContainer, ICanAcceptFiles, IKeyBind
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);

private readonly Bindable<SkinComponentsContainerLookup?> selectedTarget = new Bindable<SkinComponentsContainerLookup?>();
private readonly Bindable<SkinnableContainerLookup?> selectedTarget = new Bindable<SkinnableContainerLookup?>();

private bool hasBegunMutating;

Expand Down Expand Up @@ -327,7 +327,7 @@ void loadBlueprintContainer()
}
}

private void targetChanged(ValueChangedEvent<SkinComponentsContainerLookup?> target)
private void targetChanged(ValueChangedEvent<SkinnableContainerLookup?> target)
{
foreach (var toolbox in componentsSidebar.OfType<SkinComponentToolbox>())
toolbox.Expire();
Expand Down Expand Up @@ -357,7 +357,7 @@ private void targetChanged(ValueChangedEvent<SkinComponentsContainerLookup?> tar
{
Children = new Drawable[]
{
new SettingsDropdown<SkinComponentsContainerLookup?>
new SettingsDropdown<SkinnableContainerLookup?>
{
Items = availableTargets.Select(t => t.Lookup).Distinct(),
Current = selectedTarget,
Expand Down Expand Up @@ -466,18 +466,18 @@ private void populateSettings()
settingsSidebar.Add(new SkinSettingsToolbox(component));
}

private IEnumerable<SkinComponentsContainer> availableTargets => targetScreen.ChildrenOfType<SkinComponentsContainer>();
private IEnumerable<SkinnableContainer> availableTargets => targetScreen.ChildrenOfType<SkinnableContainer>();

private SkinComponentsContainer? getFirstTarget() => availableTargets.FirstOrDefault();
private SkinnableContainer? getFirstTarget() => availableTargets.FirstOrDefault();

private SkinComponentsContainer? getTarget(SkinComponentsContainerLookup? target)
private SkinnableContainer? getTarget(SkinnableContainerLookup? 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)
{
Expand Down Expand Up @@ -545,7 +545,7 @@ public void Save(bool userTriggered = true)
if (targetScreen?.IsLoaded != true)
return;

SkinComponentsContainer[] targetContainers = availableTargets.ToArray();
SkinnableContainer[] targetContainers = availableTargets.ToArray();

if (!targetContainers.All(c => c.ComponentsLoaded))
return;
Expand Down Expand Up @@ -590,7 +590,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();
Expand All @@ -614,7 +614,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();
Expand Down
Loading
Loading