mirror of
https://github.com/ppy/osu
synced 2024-12-27 09:23:15 +00:00
Remove duplicate implementation of the Osu playfield layer
This commit is contained in:
parent
368ceec47c
commit
a166d03ede
@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
new HitObjectCompositionTool<Spinner>()
|
||||
};
|
||||
|
||||
protected override Container CreateLayerContainer() => new LayerContainer();
|
||||
protected override Container CreateLayerContainer() => new PlayfieldLayer { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
public override HitObjectMask CreateMaskFor(DrawableHitObject hitObject)
|
||||
{
|
||||
@ -46,20 +46,5 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
return base.CreateMaskFor(hitObject);
|
||||
}
|
||||
|
||||
private class LayerContainer : Container
|
||||
{
|
||||
protected override Container<Drawable> Content => content;
|
||||
private readonly Container content;
|
||||
|
||||
public LayerContainer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
FillMode = FillMode.Fit;
|
||||
FillAspectRatio = 4f / 3;
|
||||
|
||||
Child = content = new ScalingContainer(OsuPlayfield.BASE_SIZE.X) { RelativeSizeAxes = Axes.Both };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,35 +27,27 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
InternalChild = new Container
|
||||
InternalChild = new PlayfieldLayer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
FillMode = FillMode.Fit,
|
||||
FillAspectRatio = 4f / 3,
|
||||
Child = new ScalingContainer(BASE_SIZE.X)
|
||||
Children = new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
connectionLayer = new FollowPointRenderer
|
||||
{
|
||||
connectionLayer = new FollowPointRenderer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = 2,
|
||||
},
|
||||
judgementLayer = new JudgementContainer<DrawableOsuJudgement>
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = 1,
|
||||
},
|
||||
HitObjectContainer,
|
||||
approachCircles = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = -1,
|
||||
},
|
||||
}
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = 2,
|
||||
},
|
||||
judgementLayer = new JudgementContainer<DrawableOsuJudgement>
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = 1,
|
||||
},
|
||||
HitObjectContainer,
|
||||
approachCircles = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = -1,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
49
osu.Game.Rulesets.Osu/UI/PlayfieldLayer.cs
Normal file
49
osu.Game.Rulesets.Osu/UI/PlayfieldLayer.cs
Normal file
@ -0,0 +1,49 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
public class PlayfieldLayer : Container
|
||||
{
|
||||
protected override Container<Drawable> Content => content;
|
||||
private readonly Container content;
|
||||
|
||||
public PlayfieldLayer()
|
||||
{
|
||||
InternalChild = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
FillMode = FillMode.Fit,
|
||||
FillAspectRatio = 4f / 3,
|
||||
Child = content = new ScalingContainer(OsuPlayfield.BASE_SIZE.X) { RelativeSizeAxes = Axes.Both }
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="Container"/> which scales its content relative to a target width.
|
||||
/// </summary>
|
||||
private class ScalingContainer : Container
|
||||
{
|
||||
private readonly float targetWidth;
|
||||
|
||||
public ScalingContainer(float targetWidth)
|
||||
{
|
||||
this.targetWidth = targetWidth;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Scale = new Vector2(Parent.ChildSize.X / targetWidth);
|
||||
Size = Vector2.Divide(Vector2.One, Scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="Container"/> which scales its content relative to a target width.
|
||||
/// </summary>
|
||||
public class ScalingContainer : Container
|
||||
{
|
||||
private readonly float targetWidth;
|
||||
|
||||
public ScalingContainer(float targetWidth)
|
||||
{
|
||||
this.targetWidth = targetWidth;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Scale = new Vector2(Parent.ChildSize.X / targetWidth);
|
||||
Size = Vector2.Divide(Vector2.One, Scale);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user