mirror of
https://github.com/ppy/osu.git
synced 2026-05-19 23:40:44 +08:00
Simplify default layout initialisation
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osuTK;
|
||||
|
||||
@@ -17,34 +17,21 @@ namespace osu.Game.Skinning
|
||||
|
||||
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
|
||||
{
|
||||
switch (lookup)
|
||||
if (lookup is SkinComponentsContainerLookup containerLookup
|
||||
&& containerLookup.Target == SkinComponentsContainerLookup.TargetArea.MainHUDComponents
|
||||
&& containerLookup.Ruleset != null)
|
||||
{
|
||||
case SkinComponentsContainerLookup containerLookup:
|
||||
switch (containerLookup.Target)
|
||||
return base.GetDrawableComponent(lookup) ?? new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new ArgonComboCounter
|
||||
{
|
||||
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents when containerLookup.Ruleset != null:
|
||||
var rulesetHUDComponents = Skin.GetDrawableComponent(lookup);
|
||||
|
||||
rulesetHUDComponents ??= new DefaultSkinComponentsContainer(container =>
|
||||
{
|
||||
var combo = container.OfType<ArgonComboCounter>().FirstOrDefault();
|
||||
|
||||
if (combo != null)
|
||||
{
|
||||
combo.Anchor = Anchor.BottomLeft;
|
||||
combo.Origin = Anchor.BottomLeft;
|
||||
combo.Position = new Vector2(36, -66);
|
||||
combo.Scale = new Vector2(1.3f);
|
||||
}
|
||||
})
|
||||
{
|
||||
new ArgonComboCounter(),
|
||||
};
|
||||
|
||||
return rulesetHUDComponents;
|
||||
}
|
||||
|
||||
break;
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Position = new Vector2(36, -66),
|
||||
Scale = new Vector2(1.3f),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return base.GetDrawableComponent(lookup);
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Rulesets.Objects.Legacy;
|
||||
using osuTK;
|
||||
using static osu.Game.Skinning.SkinConfiguration;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
@@ -25,33 +24,15 @@ namespace osu.Game.Skinning
|
||||
|
||||
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
|
||||
{
|
||||
switch (lookup)
|
||||
if (lookup is SkinComponentsContainerLookup containerLookup
|
||||
&& containerLookup.Target == SkinComponentsContainerLookup.TargetArea.MainHUDComponents
|
||||
&& containerLookup.Ruleset != null)
|
||||
{
|
||||
case SkinComponentsContainerLookup containerLookup:
|
||||
switch (containerLookup.Target)
|
||||
{
|
||||
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents when containerLookup.Ruleset != null:
|
||||
var rulesetHUDComponents = base.GetDrawableComponent(lookup);
|
||||
|
||||
rulesetHUDComponents ??= new DefaultSkinComponentsContainer(container =>
|
||||
{
|
||||
var combo = container.OfType<LegacyComboCounter>().FirstOrDefault();
|
||||
|
||||
if (combo != null)
|
||||
{
|
||||
combo.Anchor = Anchor.BottomLeft;
|
||||
combo.Origin = Anchor.BottomLeft;
|
||||
combo.Scale = new Vector2(1.28f);
|
||||
}
|
||||
})
|
||||
{
|
||||
new LegacyComboCounter()
|
||||
};
|
||||
|
||||
return rulesetHUDComponents;
|
||||
}
|
||||
|
||||
break;
|
||||
return base.GetDrawableComponent(lookup) ?? new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new LegacyComboCounter(),
|
||||
};
|
||||
}
|
||||
|
||||
return base.GetDrawableComponent(lookup);
|
||||
|
||||
Reference in New Issue
Block a user