diff --git a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs index bec7d1fe26..ad92ea15d4 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs @@ -32,7 +32,7 @@ public OsuHitObjectComposer(Ruleset ruleset) new HitObjectCompositionTool() }; - 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 @@ public override HitObjectMask CreateMaskFor(DrawableHitObject hitObject) return base.CreateMaskFor(hitObject); } - - private class LayerContainer : Container - { - protected override Container 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 }; - } - } } } diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index d3a4008691..9b3a6a7131 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -27,35 +27,27 @@ public OsuPlayfield() 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 - { - RelativeSizeAxes = Axes.Both, - Depth = 1, - }, - HitObjectContainer, - approachCircles = new Container - { - RelativeSizeAxes = Axes.Both, - Depth = -1, - }, - } + RelativeSizeAxes = Axes.Both, + Depth = 2, + }, + judgementLayer = new JudgementContainer + { + RelativeSizeAxes = Axes.Both, + Depth = 1, + }, + HitObjectContainer, + approachCircles = new Container + { + RelativeSizeAxes = Axes.Both, + Depth = -1, + }, } }; } diff --git a/osu.Game.Rulesets.Osu/UI/PlayfieldLayer.cs b/osu.Game.Rulesets.Osu/UI/PlayfieldLayer.cs new file mode 100644 index 0000000000..4d1eea27c9 --- /dev/null +++ b/osu.Game.Rulesets.Osu/UI/PlayfieldLayer.cs @@ -0,0 +1,49 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// 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 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 } + }; + } + + /// + /// A which scales its content relative to a target width. + /// + 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); + } + } + } +} diff --git a/osu.Game.Rulesets.Osu/UI/ScalingContainer.cs b/osu.Game.Rulesets.Osu/UI/ScalingContainer.cs deleted file mode 100644 index 0a9bec67fb..0000000000 --- a/osu.Game.Rulesets.Osu/UI/ScalingContainer.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// 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 -{ - /// - /// A which scales its content relative to a target width. - /// - 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); - } - } -}