mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
Fix legacy hit target being layered incorrectly
This commit is contained in:
parent
997ea2f27e
commit
500cb0ccf5
@ -1,6 +1,7 @@
|
||||
// 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 JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -21,15 +22,20 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||
private readonly bool isLastColumn;
|
||||
|
||||
private Container borderLineContainer;
|
||||
[CanBeNull]
|
||||
private readonly LegacyStageBackground stageBackground;
|
||||
|
||||
private Container hitTargetContainer;
|
||||
private Container lightContainer;
|
||||
private Sprite light;
|
||||
private Drawable hitTarget;
|
||||
|
||||
private float hitPosition;
|
||||
|
||||
public LegacyColumnBackground(bool isLastColumn)
|
||||
public LegacyColumnBackground(bool isLastColumn, [CanBeNull] LegacyStageBackground stageBackground)
|
||||
{
|
||||
this.isLastColumn = isLastColumn;
|
||||
this.stageBackground = stageBackground;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
@ -47,6 +53,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
bool hasLeftLine = leftLineWidth > 0;
|
||||
bool hasRightLine = rightLineWidth > 0 && skin.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value >= 2.4m
|
||||
|| isLastColumn;
|
||||
bool hasHitTarget = Column.Index == 0 || stageBackground == null;
|
||||
|
||||
hitPosition = GetColumnSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.HitPosition)?.Value
|
||||
?? Stage.HIT_TARGET_POSITION;
|
||||
@ -63,18 +70,29 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
Color4 lightColour = GetColumnSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.ColumnLightColour)?.Value
|
||||
?? Color4.White;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
Drawable background;
|
||||
|
||||
InternalChildren = new[]
|
||||
{
|
||||
new Box
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = backgroundColour
|
||||
},
|
||||
borderLineContainer = new Container
|
||||
hitTargetContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
// In legacy skins, the hit target takes on the full stage size and is sandwiched between the column background and the column light.
|
||||
// To simulate this effect in lazer's hierarchy, the hit target is added to the first column's background and manually extended to the full size of the stage.
|
||||
// Adding to the first columns allows depth issues to be resolved - if it were added to the last column, the previous column lights would appear below it.
|
||||
// This still means that the hit target will appear below the next column backgrounds, but that's a much easier problem to solve by proxying the backgrounds below.
|
||||
hitTarget = new LegacyHitTarget
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Alpha = hasHitTarget ? 1 : 0
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
@ -113,6 +131,9 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
}
|
||||
};
|
||||
|
||||
// Resolve depth issues with the hit target appearing under the next column backgrounds by proxying to the stage background (always below the columns).
|
||||
stageBackground?.AddColumnBackground(background.CreateProxy());
|
||||
|
||||
direction.BindTo(scrollingInfo.Direction);
|
||||
direction.BindValueChanged(onDirectionChanged, true);
|
||||
}
|
||||
@ -124,17 +145,23 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
lightContainer.Anchor = Anchor.TopCentre;
|
||||
lightContainer.Scale = new Vector2(1, -1);
|
||||
|
||||
borderLineContainer.Padding = new MarginPadding { Top = hitPosition };
|
||||
hitTargetContainer.Padding = new MarginPadding { Top = hitPosition };
|
||||
}
|
||||
else
|
||||
{
|
||||
lightContainer.Anchor = Anchor.BottomCentre;
|
||||
lightContainer.Scale = Vector2.One;
|
||||
|
||||
borderLineContainer.Padding = new MarginPadding { Bottom = hitPosition };
|
||||
hitTargetContainer.Padding = new MarginPadding { Bottom = hitPosition };
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
hitTarget.Width = stageBackground?.DrawWidth ?? DrawWidth;
|
||||
}
|
||||
|
||||
public bool OnPressed(ManiaAction action)
|
||||
{
|
||||
if (action == Column.Action.Value)
|
||||
|
@ -20,11 +20,6 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
|
||||
private Container directionContainer;
|
||||
|
||||
public LegacyHitTarget()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
||||
{
|
||||
|
@ -14,6 +14,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
{
|
||||
private Drawable leftSprite;
|
||||
private Drawable rightSprite;
|
||||
private Container columnBackgroundContainer;
|
||||
|
||||
public LegacyStageBackground()
|
||||
{
|
||||
@ -44,7 +45,8 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
Origin = Anchor.TopLeft,
|
||||
X = -0.05f,
|
||||
Texture = skin.GetTexture(rightImage)
|
||||
}
|
||||
},
|
||||
columnBackgroundContainer = new Container { RelativeSizeAxes = Axes.Both }
|
||||
};
|
||||
}
|
||||
|
||||
@ -58,5 +60,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
if (rightSprite?.Height > 0)
|
||||
rightSprite.Scale = new Vector2(1, DrawHeight / rightSprite.Height);
|
||||
}
|
||||
|
||||
public void AddColumnBackground(Drawable background) => columnBackgroundContainer.Add(background);
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
/// </summary>
|
||||
private Lazy<bool> hasKeyTexture;
|
||||
|
||||
private LegacyStageBackground stageBackground;
|
||||
|
||||
public ManiaLegacySkinTransformer(ISkinSource source, IBeatmap beatmap)
|
||||
: base(source)
|
||||
{
|
||||
@ -88,10 +90,11 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
switch (maniaComponent.Component)
|
||||
{
|
||||
case ManiaSkinComponents.ColumnBackground:
|
||||
return new LegacyColumnBackground(maniaComponent.TargetColumn == beatmap.TotalColumns - 1);
|
||||
return new LegacyColumnBackground(maniaComponent.TargetColumn == beatmap.TotalColumns - 1, stageBackground);
|
||||
|
||||
case ManiaSkinComponents.HitTarget:
|
||||
return new LegacyHitTarget();
|
||||
// Created within the column background, but should not fall back. See comments in LegacyColumnBackground.
|
||||
return Drawable.Empty();
|
||||
|
||||
case ManiaSkinComponents.KeyArea:
|
||||
return new LegacyKeyArea();
|
||||
@ -112,7 +115,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
return new LegacyHitExplosion();
|
||||
|
||||
case ManiaSkinComponents.StageBackground:
|
||||
return new LegacyStageBackground();
|
||||
return stageBackground = new LegacyStageBackground();
|
||||
|
||||
case ManiaSkinComponents.StageForeground:
|
||||
return new LegacyStageForeground();
|
||||
|
Loading…
Reference in New Issue
Block a user