From a166d03ede7c3027b4d24698024f953b56906cd4 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 21 Sep 2018 14:43:17 +0900 Subject: [PATCH] Remove duplicate implementation of the Osu playfield layer --- .../Edit/OsuHitObjectComposer.cs | 17 +------ osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs | 42 +++++++--------- osu.Game.Rulesets.Osu/UI/PlayfieldLayer.cs | 49 +++++++++++++++++++ osu.Game.Rulesets.Osu/UI/ScalingContainer.cs | 29 ----------- 4 files changed, 67 insertions(+), 70 deletions(-) create mode 100644 osu.Game.Rulesets.Osu/UI/PlayfieldLayer.cs delete mode 100644 osu.Game.Rulesets.Osu/UI/ScalingContainer.cs 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 @@ namespace osu.Game.Rulesets.Osu.Edit 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 @@ namespace osu.Game.Rulesets.Osu.Edit 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 @@ 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 - { - 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); - } - } -}