From 1fb846e61d3ccdaeb54024ed567e001de36131df Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 7 Mar 2017 15:43:44 +0900 Subject: [PATCH] Make playfield scaling optional. --- osu.Game.Modes.Osu/UI/OsuPlayfield.cs | 4 ++-- osu.Game/Modes/UI/Playfield.cs | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index 41abb4736f..cda90d30c7 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -32,7 +32,7 @@ namespace osu.Game.Modes.Osu.UI } } - public OsuPlayfield() + public OsuPlayfield() : base(512) { Anchor = Anchor.Centre; Origin = Anchor.Centre; @@ -83,7 +83,7 @@ namespace osu.Game.Modes.Osu.UI public override void PostProcess() { connectionLayer.HitObjects = HitObjects.Children - .Select(d => (OsuHitObject)d.HitObject) + .Select(d => d.HitObject) .OrderBy(h => h.StartTime); } diff --git a/osu.Game/Modes/UI/Playfield.cs b/osu.Game/Modes/UI/Playfield.cs index 502e072603..7f892661c0 100644 --- a/osu.Game/Modes/UI/Playfield.cs +++ b/osu.Game/Modes/UI/Playfield.cs @@ -2,12 +2,12 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; -using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; using osu.Game.Screens.Play; +using OpenTK; namespace osu.Game.Modes.UI { @@ -18,22 +18,21 @@ namespace osu.Game.Modes.UI public virtual void Add(DrawableHitObject h) => HitObjects.Add(h); - public class HitObjectContainer : Container - where U : Drawable - { - public override bool Contains(Vector2 screenSpacePos) => true; - } - private Container scaledContent; public override bool Contains(Vector2 screenSpacePos) => true; protected override Container Content { get; } - public Playfield() + /// + /// A container for keeping track of DrawableHitObjects. + /// + /// Whether we want our internal coordinate system to be scaled to a specified width. + protected Playfield(float? customWidth = null) { AddInternal(scaledContent = new ScaledContainer { + CustomWidth = customWidth, RelativeSizeAxes = Axes.Both, Children = new[] { @@ -71,14 +70,16 @@ namespace osu.Game.Modes.UI { } - public class ScaledContainer : Container + private class ScaledContainer : Container { - protected override Vector2 DrawScale => new Vector2(DrawSize.X / 512); + public float? CustomWidth; + + protected override Vector2 DrawScale => CustomWidth.HasValue ? new Vector2(DrawSize.X / CustomWidth.Value) : base.DrawScale; public override bool Contains(Vector2 screenSpacePos) => true; } - public class HitObjectContainer : Container + public class HitObjectContainer : Container where U : Drawable { public override bool Contains(Vector2 screenSpacePos) => true; }