From a504c73f33fd340f35a018448fc657fb916d3612 Mon Sep 17 00:00:00 2001 From: Damnae Date: Thu, 9 Feb 2017 15:09:48 +0100 Subject: [PATCH 01/13] Load beatmap data from an optional osb file. --- .../Beatmaps/IO/LegacyFilesystemReader.cs | 7 ++++++ osu.Game/Beatmaps/Formats/BeatmapDecoder.cs | 25 ++++++++++++++++++- .../Formats/ConstructableBeatmapDecoder.cs | 2 +- osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs | 16 +----------- osu.Game/Beatmaps/IO/ArchiveReader.cs | 4 +++ osu.Game/Beatmaps/IO/OszArchiveReader.cs | 10 +++++++- osu.Game/Beatmaps/WorkingBeatmap.cs | 19 +++++++++++--- osu.Game/Database/BeatmapDatabase.cs | 5 ++-- osu.Game/Database/BeatmapSetInfo.cs | 2 ++ osu.Game/Screens/Play/Player.cs | 2 +- 10 files changed, 68 insertions(+), 24 deletions(-) diff --git a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs index 9b699a3d76..420141e9a1 100644 --- a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs +++ b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs @@ -21,6 +21,7 @@ namespace osu.Desktop.Beatmaps.IO private string basePath { get; set; } private string[] beatmaps { get; set; } + private string storyboard { get; set; } private Beatmap firstMap { get; set; } public LegacyFilesystemReader(string path) @@ -29,6 +30,7 @@ namespace osu.Desktop.Beatmaps.IO beatmaps = Directory.GetFiles(basePath, @"*.osu").Select(f => Path.GetFileName(f)).ToArray(); if (beatmaps.Length == 0) throw new FileNotFoundException(@"This directory contains no beatmaps"); + storyboard = Directory.GetFiles(basePath, @"*.osb").Select(f => Path.GetFileName(f)).FirstOrDefault(); using (var stream = new StreamReader(GetStream(beatmaps[0]))) { var decoder = BeatmapDecoder.GetDecoder(stream); @@ -41,6 +43,11 @@ namespace osu.Desktop.Beatmaps.IO return beatmaps; } + public override string ReadStoryboard() + { + return storyboard; + } + public override Stream GetStream(string name) { return File.OpenRead(Path.Combine(basePath, name)); diff --git a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs index ba99b206b5..4846cf376d 100644 --- a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs @@ -7,6 +7,8 @@ using System.IO; using osu.Game.Modes.Objects; using OpenTK.Graphics; using osu.Game.Graphics; +using osu.Game.Beatmaps.Timing; +using osu.Game.Database; namespace osu.Game.Beatmaps.Formats { @@ -34,6 +36,11 @@ namespace osu.Game.Beatmaps.Formats return b; } + public virtual void Decode(TextReader stream, Beatmap beatmap) + { + ParseFile(stream, beatmap); + } + public virtual Beatmap Process(Beatmap beatmap) { ApplyColours(beatmap); @@ -41,7 +48,23 @@ namespace osu.Game.Beatmaps.Formats return beatmap; } - protected abstract Beatmap ParseFile(TextReader stream); + protected virtual Beatmap ParseFile(TextReader stream) + { + var beatmap = new Beatmap + { + HitObjects = new List(), + ControlPoints = new List(), + ComboColors = new List(), + BeatmapInfo = new BeatmapInfo + { + Metadata = new BeatmapMetadata(), + BaseDifficulty = new BaseDifficulty(), + }, + }; + ParseFile(stream, beatmap); + return beatmap; + } + protected abstract void ParseFile(TextReader stream, Beatmap beatmap); public virtual void ApplyColours(Beatmap b) { diff --git a/osu.Game/Beatmaps/Formats/ConstructableBeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/ConstructableBeatmapDecoder.cs index 6f81cae00f..f80c673e89 100644 --- a/osu.Game/Beatmaps/Formats/ConstructableBeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/ConstructableBeatmapDecoder.cs @@ -12,7 +12,7 @@ namespace osu.Game.Beatmaps.Formats { public class ConstructableBeatmapDecoder : BeatmapDecoder { - protected override Beatmap ParseFile(TextReader stream) + protected override void ParseFile(TextReader stream, Beatmap beatmap) { throw new NotImplementedException(); } diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index 29bb7ca32b..c32c3fe2f1 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -233,20 +233,8 @@ namespace osu.Game.Beatmaps.Formats }); } - protected override Beatmap ParseFile(TextReader stream) + protected override void ParseFile(TextReader stream, Beatmap beatmap) { - var beatmap = new Beatmap - { - HitObjects = new List(), - ControlPoints = new List(), - ComboColors = new List(), - BeatmapInfo = new BeatmapInfo - { - Metadata = new BeatmapMetadata(), - BaseDifficulty = new BaseDifficulty(), - }, - }; - HitObjectParser parser = null; var section = Section.None; @@ -309,8 +297,6 @@ namespace osu.Game.Beatmaps.Formats break; } } - - return beatmap; } } } diff --git a/osu.Game/Beatmaps/IO/ArchiveReader.cs b/osu.Game/Beatmaps/IO/ArchiveReader.cs index 8ae495a1fe..a944e7589a 100644 --- a/osu.Game/Beatmaps/IO/ArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/ArchiveReader.cs @@ -44,6 +44,10 @@ namespace osu.Game.Beatmaps.IO /// public abstract string[] ReadBeatmaps(); /// + /// Gets the storyboard file name. + /// + public abstract string ReadStoryboard(); + /// /// Opens a stream for reading a specific file from this archive. /// public abstract Stream GetStream(string name); diff --git a/osu.Game/Beatmaps/IO/OszArchiveReader.cs b/osu.Game/Beatmaps/IO/OszArchiveReader.cs index 4b35805373..f9b7fb2cf8 100644 --- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs @@ -26,8 +26,9 @@ namespace osu.Game.Beatmaps.IO private Stream archiveStream; private ZipFile archive; private string[] beatmaps; + private string storyboard; private Beatmap firstMap; - + public OszArchiveReader(Stream archiveStream) { this.archiveStream = archiveStream; @@ -36,6 +37,8 @@ namespace osu.Game.Beatmaps.IO .Select(e => e.FileName).ToArray(); if (beatmaps.Length == 0) throw new FileNotFoundException(@"This directory contains no beatmaps"); + storyboard = archive.Entries.Where(e => e.FileName.EndsWith(@".osb")) + .Select(e => e.FileName).FirstOrDefault(); using (var stream = new StreamReader(GetStream(beatmaps[0]))) { var decoder = BeatmapDecoder.GetDecoder(stream); @@ -48,6 +51,11 @@ namespace osu.Game.Beatmaps.IO return beatmaps; } + public override string ReadStoryboard() + { + return storyboard; + } + public override Stream GetStream(string name) { ZipEntry entry = archive.Entries.SingleOrDefault(e => e.FileName == name); diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 019674c3ad..674ab76802 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -18,6 +18,8 @@ namespace osu.Game.Beatmaps public readonly BeatmapSetInfo BeatmapSetInfo; private readonly BeatmapDatabase database; + public readonly bool WithStoryboard; + private ArchiveReader getReader() => database?.GetReader(BeatmapSetInfo); private Texture background; @@ -58,8 +60,18 @@ namespace osu.Game.Beatmaps try { using (var reader = getReader()) - using (var stream = new StreamReader(reader.GetStream(BeatmapInfo.Path))) - beatmap = BeatmapDecoder.GetDecoder(stream)?.Decode(stream); + { + BeatmapDecoder decoder; + using (var stream = new StreamReader(reader.GetStream(BeatmapInfo.Path))) + { + decoder = BeatmapDecoder.GetDecoder(stream); + beatmap = decoder?.Decode(stream); + } + + if (WithStoryboard && beatmap != null && BeatmapSetInfo.StoryboardFile != null) + using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile))) + decoder?.Decode(stream, beatmap); + } } catch { } @@ -103,11 +115,12 @@ namespace osu.Game.Beatmaps this.beatmap = beatmap; } - public WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, BeatmapDatabase database) + public WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, BeatmapDatabase database, bool withStoryboard = false) { BeatmapInfo = beatmapInfo; BeatmapSetInfo = beatmapSetInfo; this.database = database; + this.WithStoryboard = withStoryboard; } private bool isDisposed; diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index dff76479e8..1b678b2148 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -137,6 +137,7 @@ namespace osu.Game.Database beatmapSet.Beatmaps.Add(beatmap.BeatmapInfo); } } + beatmapSet.StoryboardFile = reader.ReadStoryboard(); } Import(new[] { beatmapSet }); @@ -169,7 +170,7 @@ namespace osu.Game.Database return Query().FirstOrDefault(s => s.OnlineBeatmapSetID == id); } - public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null) + public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null, bool withStoryboard = false) { var beatmapSetInfo = Query().FirstOrDefault(s => s.ID == beatmapInfo.BeatmapSetInfoID); @@ -182,7 +183,7 @@ namespace osu.Game.Database if (beatmapInfo.Metadata == null) beatmapInfo.Metadata = beatmapSetInfo.Metadata; - var working = new WorkingBeatmap(beatmapInfo, beatmapSetInfo, this); + var working = new WorkingBeatmap(beatmapInfo, beatmapSetInfo, this, withStoryboard); previous?.TransferTo(working); diff --git a/osu.Game/Database/BeatmapSetInfo.cs b/osu.Game/Database/BeatmapSetInfo.cs index f556c3546a..a9c3f03a49 100644 --- a/osu.Game/Database/BeatmapSetInfo.cs +++ b/osu.Game/Database/BeatmapSetInfo.cs @@ -27,6 +27,8 @@ namespace osu.Game.Database public string Hash { get; set; } public string Path { get; set; } + + public string StoryboardFile { get; set; } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index a9584a1f10..36ea7c5b49 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -74,7 +74,7 @@ namespace osu.Game.Screens.Play try { if (Beatmap == null) - Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo); + Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true); } catch { From 77ee161be8afa156dc8c95d22ed3c0111cad94bf Mon Sep 17 00:00:00 2001 From: Damnae Date: Fri, 10 Feb 2017 06:16:23 +0100 Subject: [PATCH 02/13] Add follow points. --- .../Objects/Drawables/FollowPoint.cs | 64 +++++++++++++++++ osu.Game.Modes.Osu/UI/OsuPlayfield.cs | 71 ++++++++++++++++++- osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 1 + osu.Game/Modes/UI/HitRenderer.cs | 1 + osu.Game/Modes/UI/Playfield.cs | 6 +- 5 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs diff --git a/osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs b/osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs new file mode 100644 index 0000000000..22ffead4d9 --- /dev/null +++ b/osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs @@ -0,0 +1,64 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Framework.Graphics.Transformations; + +namespace osu.Game.Modes.Osu.Objects.Drawables +{ + public class FollowPoint : Container + { + private Sprite followPoint; + + public double StartTime; + public double EndTime; + public Vector2 EndPosition; + + public FollowPoint() + { + Origin = Anchor.Centre; + Alpha = 0; + + Children = new Drawable[] + { + followPoint = new Sprite + { + Size = new Vector2(12f), + Origin = Anchor.Centre, + BlendingMode = BlendingMode.Additive, + Alpha = 0.5f + }, + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + DelayReset(); + + Delay(StartTime); + FadeIn(DrawableOsuHitObject.TIME_FADEIN); + ScaleTo(1.5f); + ScaleTo(1, DrawableOsuHitObject.TIME_FADEIN, EasingTypes.Out); + MoveTo(EndPosition, DrawableOsuHitObject.TIME_FADEIN, EasingTypes.Out); + + Delay(EndTime - StartTime); + FadeOut(DrawableOsuHitObject.TIME_FADEIN); + + Delay(DrawableOsuHitObject.TIME_FADEIN); + Expire(true); + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + followPoint.Texture = textures.Get(@"Play/osu/ring-glow"); + } + } +} \ No newline at end of file diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index 49c6869189..1be73a0452 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -1,13 +1,16 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects.Drawables; using osu.Game.Modes.UI; -using OpenTK; +using System; +using System.Collections.Generic; +using System.Linq; namespace osu.Game.Modes.Osu.UI { @@ -15,6 +18,7 @@ namespace osu.Game.Modes.Osu.UI { private Container approachCircles; private Container judgementLayer; + private Container followPointsLayer; public override Vector2 Size { @@ -36,11 +40,16 @@ namespace osu.Game.Modes.Osu.UI Add(new Drawable[] { - judgementLayer = new Container + followPointsLayer = new Container { RelativeSizeAxes = Axes.Both, Depth = 1, }, + judgementLayer = new Container + { + RelativeSizeAxes = Axes.Both, + Depth = 0, + }, approachCircles = new Container { RelativeSizeAxes = Axes.Both, @@ -63,11 +72,69 @@ namespace osu.Game.Modes.Osu.UI base.Add(h); } + public override void PostProcess() + { + AddFollowPoints(); + } + private void judgement(DrawableHitObject h, JudgementInfo j) { HitExplosion explosion = new HitExplosion((OsuJudgementInfo)j, (OsuHitObject)h.HitObject); judgementLayer.Add(explosion); } + + public void AddFollowPoints(int startIndex = 0, int endIndex = -1) + { + var followLineDistance = 32; + var followLinePreEmpt = 800; + + var hitObjects = new List(HitObjects.Children + .Select(d => (OsuHitObject)d.HitObject) + .OrderBy(h => h.StartTime)); + + if (endIndex < 0) + endIndex = hitObjects.Count - 1; + + for (int i = startIndex + 1; i <= endIndex; i++) + { + var prevHitObject = hitObjects[i - 1]; + var currHitObject = hitObjects[i]; + + if (prevHitObject.StartTime > currHitObject.StartTime) + throw new Exception(); + + if (!currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner)) + { + Vector2 startPosition = prevHitObject.EndPosition; + Vector2 endPosition = currHitObject.Position; + double startTime = prevHitObject.EndTime; + double endTime = currHitObject.StartTime; + + Vector2 distanceVector = endPosition - startPosition; + int distance = (int)distanceVector.Length; + float rotation = (float)Math.Atan2(distanceVector.Y, distanceVector.X); + double duration = endTime - startTime; + + for (int d = (int)(followLineDistance * 1.5); d < distance - followLineDistance; d += followLineDistance) + { + float fraction = ((float)d / distance); + Vector2 pointStartPosition = startPosition + (fraction - 0.1f) * distanceVector; + Vector2 pointEndPosition = startPosition + fraction * distanceVector; + double fadeOutTime = startTime + fraction * duration; + double fadeInTime = fadeOutTime - followLinePreEmpt; + + followPointsLayer.Add(new FollowPoint() + { + StartTime = fadeInTime, + EndTime = fadeOutTime, + Position = pointStartPosition, + EndPosition = pointEndPosition, + Rotation = rotation, + }); + } + } + } + } } } \ No newline at end of file diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index a9a346f563..88d25cb8f4 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -47,6 +47,7 @@ + diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index aa2af83cb4..14d9599be6 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -83,6 +83,7 @@ namespace osu.Game.Modes.UI Playfield.Add(drawableObject); } + Playfield.PostProcess(); } private void onJudgement(DrawableHitObject o, JudgementInfo j) => TriggerOnJudgement(j); diff --git a/osu.Game/Modes/UI/Playfield.cs b/osu.Game/Modes/UI/Playfield.cs index 748c71a8b3..91eddce73c 100644 --- a/osu.Game/Modes/UI/Playfield.cs +++ b/osu.Game/Modes/UI/Playfield.cs @@ -1,10 +1,10 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Modes.Objects.Drawables; -using OpenTK; namespace osu.Game.Modes.UI { @@ -32,6 +32,10 @@ namespace osu.Game.Modes.UI }); } + public virtual void PostProcess() + { + } + public class ScaledContainer : Container { protected override Vector2 DrawScale => new Vector2(DrawSize.X / 512); From 4e6b6ab794c54d5e3f50382c60f5ddeeb0b76c00 Mon Sep 17 00:00:00 2001 From: Damnae Date: Fri, 10 Feb 2017 08:10:24 +0100 Subject: [PATCH 03/13] Abstract follow points into a separate class. --- .../{ => Connections}/FollowPoint.cs | 2 +- .../Connections/FollowPointConnection.cs | 65 +++++++++++++++++++ .../Connections/HitObjectConnection.cs | 14 ++++ osu.Game.Modes.Osu/UI/OsuPlayfield.cs | 63 ++---------------- osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 4 +- 5 files changed, 87 insertions(+), 61 deletions(-) rename osu.Game.Modes.Osu/Objects/Drawables/{ => Connections}/FollowPoint.cs (93%) create mode 100644 osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs create mode 100644 osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs diff --git a/osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs similarity index 93% rename from osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs rename to osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs index 22ffead4d9..b0b63d17b9 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs @@ -9,7 +9,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Transformations; -namespace osu.Game.Modes.Osu.Objects.Drawables +namespace osu.Game.Modes.Osu.Objects.Drawables.Connections { public class FollowPoint : Container { diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs new file mode 100644 index 0000000000..78c875d874 --- /dev/null +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs @@ -0,0 +1,65 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Game.Modes.Objects.Drawables; +using osu.Game.Modes.Osu.Objects.Drawables.Connections; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace osu.Game.Modes.Osu.Objects.Drawables +{ + public class FollowPointConnection : HitObjectConnection + { + public int PointDistance = 32; + public int PreEmpt = 800; + + public override void AddConnections(IEnumerable drawableHitObjects, int startIndex = 0, int endIndex = -1) + { + var hitObjects = new List(drawableHitObjects + .Select(d => (OsuHitObject)d.HitObject) + .OrderBy(h => h.StartTime)); + + if (endIndex < 0) + endIndex = hitObjects.Count - 1; + + for (int i = startIndex + 1; i <= endIndex; i++) + { + var prevHitObject = hitObjects[i - 1]; + var currHitObject = hitObjects[i]; + + if (!currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner)) + { + Vector2 startPosition = prevHitObject.EndPosition; + Vector2 endPosition = currHitObject.Position; + double startTime = prevHitObject.EndTime; + double endTime = currHitObject.StartTime; + + Vector2 distanceVector = endPosition - startPosition; + int distance = (int)distanceVector.Length; + float rotation = (float)Math.Atan2(distanceVector.Y, distanceVector.X); + double duration = endTime - startTime; + + for (int d = (int)(PointDistance * 1.5); d < distance - PointDistance; d += PointDistance) + { + float fraction = ((float)d / distance); + Vector2 pointStartPosition = startPosition + (fraction - 0.1f) * distanceVector; + Vector2 pointEndPosition = startPosition + fraction * distanceVector; + double fadeOutTime = startTime + fraction * duration; + double fadeInTime = fadeOutTime - PreEmpt; + + Add(new FollowPoint() + { + StartTime = fadeInTime, + EndTime = fadeOutTime, + Position = pointStartPosition, + EndPosition = pointEndPosition, + Rotation = rotation, + }); + } + } + } + } + } +} diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs new file mode 100644 index 0000000000..d8c91f23df --- /dev/null +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Containers; +using osu.Game.Modes.Objects.Drawables; +using System.Collections.Generic; + +namespace osu.Game.Modes.Osu.Objects.Drawables.Connections +{ + public abstract class HitObjectConnection : Container + { + public abstract void AddConnections(IEnumerable drawableHitObjects, int startIndex = 0, int endIndex = -1); + } +} diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index 1be73a0452..ef7b36b0bd 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -7,10 +7,8 @@ using osu.Framework.Graphics.Containers; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects.Drawables; +using osu.Game.Modes.Osu.Objects.Drawables.Connections; using osu.Game.Modes.UI; -using System; -using System.Collections.Generic; -using System.Linq; namespace osu.Game.Modes.Osu.UI { @@ -18,7 +16,7 @@ namespace osu.Game.Modes.Osu.UI { private Container approachCircles; private Container judgementLayer; - private Container followPointsLayer; + private HitObjectConnection hitObjectConnection; public override Vector2 Size { @@ -40,7 +38,7 @@ namespace osu.Game.Modes.Osu.UI Add(new Drawable[] { - followPointsLayer = new Container + hitObjectConnection = new FollowPointConnection { RelativeSizeAxes = Axes.Both, Depth = 1, @@ -74,7 +72,7 @@ namespace osu.Game.Modes.Osu.UI public override void PostProcess() { - AddFollowPoints(); + hitObjectConnection.AddConnections(HitObjects.Children); } private void judgement(DrawableHitObject h, JudgementInfo j) @@ -83,58 +81,5 @@ namespace osu.Game.Modes.Osu.UI judgementLayer.Add(explosion); } - - public void AddFollowPoints(int startIndex = 0, int endIndex = -1) - { - var followLineDistance = 32; - var followLinePreEmpt = 800; - - var hitObjects = new List(HitObjects.Children - .Select(d => (OsuHitObject)d.HitObject) - .OrderBy(h => h.StartTime)); - - if (endIndex < 0) - endIndex = hitObjects.Count - 1; - - for (int i = startIndex + 1; i <= endIndex; i++) - { - var prevHitObject = hitObjects[i - 1]; - var currHitObject = hitObjects[i]; - - if (prevHitObject.StartTime > currHitObject.StartTime) - throw new Exception(); - - if (!currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner)) - { - Vector2 startPosition = prevHitObject.EndPosition; - Vector2 endPosition = currHitObject.Position; - double startTime = prevHitObject.EndTime; - double endTime = currHitObject.StartTime; - - Vector2 distanceVector = endPosition - startPosition; - int distance = (int)distanceVector.Length; - float rotation = (float)Math.Atan2(distanceVector.Y, distanceVector.X); - double duration = endTime - startTime; - - for (int d = (int)(followLineDistance * 1.5); d < distance - followLineDistance; d += followLineDistance) - { - float fraction = ((float)d / distance); - Vector2 pointStartPosition = startPosition + (fraction - 0.1f) * distanceVector; - Vector2 pointEndPosition = startPosition + fraction * distanceVector; - double fadeOutTime = startTime + fraction * duration; - double fadeInTime = fadeOutTime - followLinePreEmpt; - - followPointsLayer.Add(new FollowPoint() - { - StartTime = fadeInTime, - EndTime = fadeOutTime, - Position = pointStartPosition, - EndPosition = pointEndPosition, - Rotation = rotation, - }); - } - } - } - } } } \ No newline at end of file diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index 88d25cb8f4..567eec593c 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -44,10 +44,12 @@ + + - + From 6f37c028681e95560e7830076eb548601995f2c3 Mon Sep 17 00:00:00 2001 From: Damnae Date: Fri, 10 Feb 2017 10:02:37 +0100 Subject: [PATCH 04/13] Fix followpoints needing a DelayReset. --- .../Objects/Drawables/Connections/FollowPoint.cs | 2 -- osu.Game/Screens/Play/Player.cs | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs index b0b63d17b9..72a5358efb 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs @@ -40,8 +40,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Connections { base.LoadComplete(); - DelayReset(); - Delay(StartTime); FadeIn(DrawableOsuHitObject.TIME_FADEIN); ScaleTo(1.5f); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index a9584a1f10..a1effa242a 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -237,11 +237,10 @@ namespace osu.Game.Screens.Play { base.LoadComplete(); - Delay(250, true); + Content.Delay(250); Content.FadeIn(250); - Delay(500, true); - + Delay(500); Schedule(() => { sourceClock.Start(); From ec64455573557c1da2e61b019a034c933d8a7f8e Mon Sep 17 00:00:00 2001 From: Damnae Date: Fri, 10 Feb 2017 10:24:31 +0100 Subject: [PATCH 05/13] Add xml-doc. --- .../Objects/Drawables/Connections/FollowPointConnection.cs | 7 +++++++ .../Objects/Drawables/Connections/HitObjectConnection.cs | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs index 78c875d874..60ae997a77 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs @@ -12,7 +12,14 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { public class FollowPointConnection : HitObjectConnection { + /// + /// Determines how much space there is between points. + /// public int PointDistance = 32; + + /// + /// Follow points to the next hitobject start appearing for this many milliseconds before an hitobject's end time. + /// public int PreEmpt = 800; public override void AddConnections(IEnumerable drawableHitObjects, int startIndex = 0, int endIndex = -1) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs index d8c91f23df..3ef4b4aa29 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs @@ -9,6 +9,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Connections { public abstract class HitObjectConnection : Container { + /// + /// Create drawables inside this container, connecting hitobjects visually, for example with follow points. + /// + /// The drawables hit objects to create connections for + /// Start index into the drawableHitObjects enumeration. + /// End index into the drawableHitObjects enumeration. Use -1 to draw connections until the end. public abstract void AddConnections(IEnumerable drawableHitObjects, int startIndex = 0, int endIndex = -1); } } From 2d155f6a5c0c86f6eb929b750a1c07902a029bb9 Mon Sep 17 00:00:00 2001 From: Damnae Date: Fri, 10 Feb 2017 10:48:25 +0100 Subject: [PATCH 06/13] Bring back the delay to what it was before. --- osu.Game/Screens/Play/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index a1effa242a..6eda0ec9ca 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -240,7 +240,7 @@ namespace osu.Game.Screens.Play Content.Delay(250); Content.FadeIn(250); - Delay(500); + Delay(750); Schedule(() => { sourceClock.Start(); From 4162ef72d44ea4c9bebec180db0b67546b520652 Mon Sep 17 00:00:00 2001 From: Damnae Date: Sun, 12 Feb 2017 06:02:45 +0100 Subject: [PATCH 07/13] Remove start/end index. --- .../Objects/Drawables/Connections/FollowPointConnection.cs | 7 ++----- .../Objects/Drawables/Connections/HitObjectConnection.cs | 4 +--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs index 60ae997a77..3af77e41f8 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs @@ -22,16 +22,13 @@ namespace osu.Game.Modes.Osu.Objects.Drawables /// public int PreEmpt = 800; - public override void AddConnections(IEnumerable drawableHitObjects, int startIndex = 0, int endIndex = -1) + public override void AddConnections(IEnumerable drawableHitObjects) { var hitObjects = new List(drawableHitObjects .Select(d => (OsuHitObject)d.HitObject) .OrderBy(h => h.StartTime)); - if (endIndex < 0) - endIndex = hitObjects.Count - 1; - - for (int i = startIndex + 1; i <= endIndex; i++) + for (int i = 1; i <= hitObjects.Count - 1; i++) { var prevHitObject = hitObjects[i - 1]; var currHitObject = hitObjects[i]; diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs index 3ef4b4aa29..e2131504cf 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs @@ -13,8 +13,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Connections /// Create drawables inside this container, connecting hitobjects visually, for example with follow points. /// /// The drawables hit objects to create connections for - /// Start index into the drawableHitObjects enumeration. - /// End index into the drawableHitObjects enumeration. Use -1 to draw connections until the end. - public abstract void AddConnections(IEnumerable drawableHitObjects, int startIndex = 0, int endIndex = -1); + public abstract void AddConnections(IEnumerable drawableHitObjects); } } From d7be9539d1a18cec2ec45b10871e4853461cb80c Mon Sep 17 00:00:00 2001 From: Damnae Date: Sun, 12 Feb 2017 07:29:36 +0100 Subject: [PATCH 08/13] Create connections from HitObjects instead of DrawableHitObjects. --- ...ectConnection.cs => ConnectionRenderer.cs} | 11 ++++++----- ...ntConnection.cs => FollowPointRenderer.cs} | 19 ++++++------------- osu.Game.Modes.Osu/UI/OsuPlayfield.cs | 13 ++++++++----- osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 4 ++-- 4 files changed, 22 insertions(+), 25 deletions(-) rename osu.Game.Modes.Osu/Objects/Drawables/Connections/{HitObjectConnection.cs => ConnectionRenderer.cs} (52%) rename osu.Game.Modes.Osu/Objects/Drawables/Connections/{FollowPointConnection.cs => FollowPointRenderer.cs} (75%) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs similarity index 52% rename from osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs rename to osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs index e2131504cf..d35a731feb 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs @@ -2,17 +2,18 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics.Containers; -using osu.Game.Modes.Objects.Drawables; +using osu.Game.Modes.Objects; using System.Collections.Generic; namespace osu.Game.Modes.Osu.Objects.Drawables.Connections { - public abstract class HitObjectConnection : Container + public abstract class ConnectionRenderer : Container + where T : HitObject { /// - /// Create drawables inside this container, connecting hitobjects visually, for example with follow points. + /// Create drawables inside this container, connecting hit objects visually, for example with follow points. /// - /// The drawables hit objects to create connections for - public abstract void AddConnections(IEnumerable drawableHitObjects); + /// Hit objects to create connections for + public abstract void AddConnections(IEnumerable hitObjects); } } diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs similarity index 75% rename from osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs rename to osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs index 3af77e41f8..469ce390d0 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs @@ -2,15 +2,13 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects.Drawables.Connections; using System; using System.Collections.Generic; -using System.Linq; namespace osu.Game.Modes.Osu.Objects.Drawables { - public class FollowPointConnection : HitObjectConnection + public class FollowPointRenderer : ConnectionRenderer { /// /// Determines how much space there is between points. @@ -22,18 +20,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables /// public int PreEmpt = 800; - public override void AddConnections(IEnumerable drawableHitObjects) + public override void AddConnections(IEnumerable hitObjects) { - var hitObjects = new List(drawableHitObjects - .Select(d => (OsuHitObject)d.HitObject) - .OrderBy(h => h.StartTime)); - - for (int i = 1; i <= hitObjects.Count - 1; i++) + OsuHitObject prevHitObject = null; + foreach (var currHitObject in hitObjects) { - var prevHitObject = hitObjects[i - 1]; - var currHitObject = hitObjects[i]; - - if (!currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner)) + if (prevHitObject != null && !currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner)) { Vector2 startPosition = prevHitObject.EndPosition; Vector2 endPosition = currHitObject.Position; @@ -63,6 +55,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables }); } } + prevHitObject = currHitObject; } } } diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index ef7b36b0bd..f2fafc8883 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -9,6 +9,7 @@ using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects.Drawables; using osu.Game.Modes.Osu.Objects.Drawables.Connections; using osu.Game.Modes.UI; +using System.Linq; namespace osu.Game.Modes.Osu.UI { @@ -16,7 +17,7 @@ namespace osu.Game.Modes.Osu.UI { private Container approachCircles; private Container judgementLayer; - private HitObjectConnection hitObjectConnection; + private ConnectionRenderer connectionLayer; public override Vector2 Size { @@ -38,15 +39,15 @@ namespace osu.Game.Modes.Osu.UI Add(new Drawable[] { - hitObjectConnection = new FollowPointConnection + connectionLayer = new FollowPointRenderer { RelativeSizeAxes = Axes.Both, - Depth = 1, + Depth = 2, }, judgementLayer = new Container { RelativeSizeAxes = Axes.Both, - Depth = 0, + Depth = 1, }, approachCircles = new Container { @@ -72,7 +73,9 @@ namespace osu.Game.Modes.Osu.UI public override void PostProcess() { - hitObjectConnection.AddConnections(HitObjects.Children); + connectionLayer.AddConnections(HitObjects.Children + .Select(d => (OsuHitObject)d.HitObject) + .OrderBy(h => h.StartTime)); } private void judgement(DrawableHitObject h, JudgementInfo j) diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index 567eec593c..d8c381a648 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -44,8 +44,8 @@ - - + + From de2791e179322aa97aad4f8f9da193add759b5ff Mon Sep 17 00:00:00 2001 From: Damnae Date: Sun, 12 Feb 2017 08:19:52 +0100 Subject: [PATCH 09/13] Better looking follow points. --- .../Drawables/Connections/FollowPoint.cs | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs index 72a5358efb..bc24186e14 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs @@ -2,36 +2,47 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using osu.Framework.Allocation; +using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Transformations; +using osu.Game.Graphics; namespace osu.Game.Modes.Osu.Objects.Drawables.Connections { public class FollowPoint : Container { - private Sprite followPoint; - public double StartTime; public double EndTime; public Vector2 EndPosition; + const float width = 8; + public FollowPoint() { Origin = Anchor.Centre; Alpha = 0; + Masking = true; + AutoSizeAxes = Axes.Both; + CornerRadius = width / 2; + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Colour = Color4.White.Opacity(0.2f), + Radius = 4, + }; + Children = new Drawable[] { - followPoint = new Sprite + new Box { - Size = new Vector2(12f), - Origin = Anchor.Centre, + Size = new Vector2(width), BlendingMode = BlendingMode.Additive, - Alpha = 0.5f + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Alpha = 0.5f, }, }; } @@ -52,11 +63,5 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Connections Delay(DrawableOsuHitObject.TIME_FADEIN); Expire(true); } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - followPoint.Texture = textures.Get(@"Play/osu/ring-glow"); - } } } \ No newline at end of file From daa14bfec8be065464c8f22ecdf7e845b7282f53 Mon Sep 17 00:00:00 2001 From: Damnae Date: Sun, 12 Feb 2017 08:31:43 +0100 Subject: [PATCH 10/13] Replace AddConnections by a HitObjects property. --- .../Connections/ConnectionRenderer.cs | 8 ++-- .../Connections/FollowPointRenderer.cs | 43 +++++++++++++++++-- osu.Game.Modes.Osu/UI/OsuPlayfield.cs | 4 +- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs index d35a731feb..a680c847ac 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs @@ -7,13 +7,15 @@ using System.Collections.Generic; namespace osu.Game.Modes.Osu.Objects.Drawables.Connections { + /// + /// Connects hit objects visually, for example with follow points. + /// public abstract class ConnectionRenderer : Container where T : HitObject { /// - /// Create drawables inside this container, connecting hit objects visually, for example with follow points. + /// Hit objects to create connections for /// - /// Hit objects to create connections for - public abstract void AddConnections(IEnumerable hitObjects); + public abstract IEnumerable HitObjects { get; set; } } } diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs index 469ce390d0..b57f0881bc 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs @@ -10,18 +10,53 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { public class FollowPointRenderer : ConnectionRenderer { + private int pointDistance = 32; /// /// Determines how much space there is between points. /// - public int PointDistance = 32; + public int PointDistance + { + get { return pointDistance; } + set + { + if (pointDistance == value) return; + pointDistance = value; + update(); + } + } + private int preEmpt = 800; /// /// Follow points to the next hitobject start appearing for this many milliseconds before an hitobject's end time. /// - public int PreEmpt = 800; - - public override void AddConnections(IEnumerable hitObjects) + public int PreEmpt { + get { return preEmpt; } + set + { + if (preEmpt == value) return; + preEmpt = value; + update(); + } + } + + private IEnumerable hitObjects; + public override IEnumerable HitObjects + { + get { return hitObjects; } + set + { + hitObjects = value; + update(); + } + } + + private void update() + { + Clear(); + if (hitObjects == null) + return; + OsuHitObject prevHitObject = null; foreach (var currHitObject in hitObjects) { diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index f2fafc8883..b6daffbb8b 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -73,9 +73,9 @@ namespace osu.Game.Modes.Osu.UI public override void PostProcess() { - connectionLayer.AddConnections(HitObjects.Children + connectionLayer.HitObjects = HitObjects.Children .Select(d => (OsuHitObject)d.HitObject) - .OrderBy(h => h.StartTime)); + .OrderBy(h => h.StartTime); } private void judgement(DrawableHitObject h, JudgementInfo j) From aaaf7163e0208419171d808deffbf62d5a29d4d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 13 Feb 2017 08:02:14 +0100 Subject: [PATCH 11/13] Update framework. --- osu-framework | 2 +- osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs | 2 +- osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs | 2 +- osu.Game/Beatmaps/Drawables/BeatmapPanel.cs | 6 +++--- osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs | 4 ++-- osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs | 2 +- osu.Game/Online/Chat/Drawables/ChannelDisplay.cs | 2 +- osu.Game/Overlays/NotificationManager.cs | 2 +- osu.Game/Overlays/Notifications/NotificationSection.cs | 2 +- osu.Game/Overlays/Options/OptionDropDown.cs | 2 +- osu.Game/Overlays/Options/OptionSlider.cs | 2 +- osu.Game/Overlays/Options/OptionsSection.cs | 2 +- osu.Game/Overlays/Options/OptionsSubsection.cs | 4 ++-- osu.Game/Overlays/Options/Sections/General/LoginOptions.cs | 2 +- osu.Game/Overlays/Options/Sidebar.cs | 2 +- osu.Game/Overlays/OptionsOverlay.cs | 6 +++--- osu.Game/Overlays/Pause/PauseOverlay.cs | 4 ++-- osu.Game/Overlays/Toolbar/Toolbar.cs | 4 ++-- osu.Game/Overlays/Toolbar/ToolbarButton.cs | 4 ++-- osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 2 +- osu.Game/Screens/GameModeWhiteBox.cs | 2 +- osu.Game/Screens/Menu/Button.cs | 2 +- osu.Game/Screens/Menu/ButtonSystem.cs | 2 +- osu.Game/Screens/Play/KeyCounterCollection.cs | 2 +- osu.Game/Screens/Ranking/Results.cs | 2 +- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 4 ++-- osu.Game/Screens/Select/FilterControl.cs | 6 +++--- osu.Game/Screens/Select/Footer.cs | 4 ++-- 28 files changed, 41 insertions(+), 41 deletions(-) diff --git a/osu-framework b/osu-framework index eae237f6a7..4d7f9b8a3a 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit eae237f6a7e2a6e7d7c621b2382bb08de2b470b8 +Subproject commit 4d7f9b8a3afd32183a31d62143d522d43d8c01ca diff --git a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs index 0e83010caf..54f3957014 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs @@ -71,7 +71,7 @@ namespace osu.Desktop.VisualTests.Tests Add(flow = new FlowContainer { RelativeSizeAxes = Axes.Both, - Direction = FlowDirection.VerticalOnly + Direction = FlowDirections.Vertical }); SpriteText loading; diff --git a/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs b/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs index 96360a6291..1a92436d74 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs @@ -24,7 +24,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables AutoSizeAxes = Axes.Both; Origin = Anchor.Centre; - Direction = FlowDirection.VerticalOnly; + Direction = FlowDirections.Vertical; Spacing = new Vector2(0, 2); Position = (h?.StackedEndPosition ?? Vector2.Zero) + judgement.PositionOffset; diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index 1ee9e3e4c2..a6ad0a6457 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -77,7 +77,7 @@ namespace osu.Game.Beatmaps.Drawables new FlowContainer { Padding = new MarginPadding(5), - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, AutoSizeAxes = Axes.Both, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, @@ -93,13 +93,13 @@ namespace osu.Game.Beatmaps.Drawables { Padding = new MarginPadding { Left = 5 }, Spacing = new Vector2(0, 5), - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, AutoSizeAxes = Axes.Both, Children = new Drawable[] { new FlowContainer { - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, AutoSizeAxes = Axes.Both, Spacing = new Vector2(4, 0), Children = new[] diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index 3b79d1bf1d..a0a7549caf 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -39,7 +39,7 @@ namespace osu.Game.Beatmaps.Drawables }, new FlowContainer { - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, Padding = new MarginPadding { Top = 5, Left = 18, Right = 10, Bottom = 10 }, AutoSizeAxes = Axes.Both, Children = new[] @@ -113,7 +113,7 @@ namespace osu.Game.Beatmaps.Drawables new FlowContainer { Depth = -1, - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, RelativeSizeAxes = Axes.Both, // This makes the gradient not be perfectly horizontal, but diagonal at a ~40° angle Shear = new Vector2(0.8f, 0), diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs index 1b51177c09..bbc8bd3e47 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs @@ -22,7 +22,7 @@ namespace osu.Game.Graphics.UserInterface { new FlowContainer { - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Children = new Drawable[] diff --git a/osu.Game/Online/Chat/Drawables/ChannelDisplay.cs b/osu.Game/Online/Chat/Drawables/ChannelDisplay.cs index 131dc50699..08630a25aa 100644 --- a/osu.Game/Online/Chat/Drawables/ChannelDisplay.cs +++ b/osu.Game/Online/Chat/Drawables/ChannelDisplay.cs @@ -42,7 +42,7 @@ namespace osu.Game.Online.Chat.Drawables { flow = new FlowContainer { - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Spacing = new Vector2(1, 1) diff --git a/osu.Game/Overlays/NotificationManager.cs b/osu.Game/Overlays/NotificationManager.cs index ecfa3daa38..cb2025c576 100644 --- a/osu.Game/Overlays/NotificationManager.cs +++ b/osu.Game/Overlays/NotificationManager.cs @@ -45,7 +45,7 @@ namespace osu.Game.Overlays { sections = new FlowContainer { - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Children = new [] diff --git a/osu.Game/Overlays/Notifications/NotificationSection.cs b/osu.Game/Overlays/Notifications/NotificationSection.cs index ec286302b8..0f74df18de 100644 --- a/osu.Game/Overlays/Notifications/NotificationSection.cs +++ b/osu.Game/Overlays/Notifications/NotificationSection.cs @@ -60,7 +60,7 @@ namespace osu.Game.Overlays.Notifications { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - Direction = FlowDirection.VerticalOnly; + Direction = FlowDirections.Vertical; Padding = new MarginPadding { diff --git a/osu.Game/Overlays/Options/OptionDropDown.cs b/osu.Game/Overlays/Options/OptionDropDown.cs index b9d676109e..ff1e6ae103 100644 --- a/osu.Game/Overlays/Options/OptionDropDown.cs +++ b/osu.Game/Overlays/Options/OptionDropDown.cs @@ -86,7 +86,7 @@ namespace osu.Game.Overlays.Options { Items = new KeyValuePair[0]; - Direction = FlowDirection.VerticalOnly; + Direction = FlowDirections.Vertical; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Children = new Drawable[] diff --git a/osu.Game/Overlays/Options/OptionSlider.cs b/osu.Game/Overlays/Options/OptionSlider.cs index e90da5f047..6a41cb9612 100644 --- a/osu.Game/Overlays/Options/OptionSlider.cs +++ b/osu.Game/Overlays/Options/OptionSlider.cs @@ -35,7 +35,7 @@ namespace osu.Game.Overlays.Options public OptionSlider() { - Direction = FlowDirection.VerticalOnly; + Direction = FlowDirections.Vertical; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Padding = new MarginPadding { Right = 5 }; diff --git a/osu.Game/Overlays/Options/OptionsSection.cs b/osu.Game/Overlays/Options/OptionsSection.cs index a1cff0188c..61cfa868ec 100644 --- a/osu.Game/Overlays/Options/OptionsSection.cs +++ b/osu.Game/Overlays/Options/OptionsSection.cs @@ -61,7 +61,7 @@ namespace osu.Game.Overlays.Options FlowContent = new FlowContainer { Margin = new MarginPadding { Top = header_size + header_margin }, - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, Spacing = new Vector2(0, 30), AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, diff --git a/osu.Game/Overlays/Options/OptionsSubsection.cs b/osu.Game/Overlays/Options/OptionsSubsection.cs index aa17ac7e52..37cb6d01c1 100644 --- a/osu.Game/Overlays/Options/OptionsSubsection.cs +++ b/osu.Game/Overlays/Options/OptionsSubsection.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Options { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - Direction = FlowDirection.VerticalOnly; + Direction = FlowDirections.Vertical; AddInternal(new Drawable[] { new OsuSpriteText @@ -32,7 +32,7 @@ namespace osu.Game.Overlays.Options }, content = new FlowContainer { - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Spacing = new Vector2(0, 5), diff --git a/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs b/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs index 08777c97a7..aca9b02f48 100644 --- a/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs +++ b/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs @@ -101,7 +101,7 @@ namespace osu.Game.Overlays.Options.Sections.General private void load(APIAccess api, OsuConfigManager config) { this.api = api; - Direction = FlowDirection.VerticalOnly; + Direction = FlowDirections.Vertical; AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; Spacing = new Vector2(0, 5); diff --git a/osu.Game/Overlays/Options/Sidebar.cs b/osu.Game/Overlays/Options/Sidebar.cs index 57865b84a7..f3fe3e1683 100644 --- a/osu.Game/Overlays/Options/Sidebar.cs +++ b/osu.Game/Overlays/Options/Sidebar.cs @@ -42,7 +42,7 @@ namespace osu.Game.Overlays.Options Anchor = Anchor.CentreLeft, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, - Direction = FlowDirection.VerticalOnly + Direction = FlowDirections.Vertical } } }, diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index a93bbc10d3..68786b00e8 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -82,7 +82,7 @@ namespace osu.Game.Overlays { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, Children = new Drawable[] { @@ -103,7 +103,7 @@ namespace osu.Game.Overlays { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, Children = sections, } } @@ -141,7 +141,7 @@ namespace osu.Game.Overlays foreach (OptionsSection section in sections) { - float distance = Math.Abs(scrollContainer.GetChildYInContent(section) - currentScroll); + float distance = Math.Abs(scrollContainer.GetChildPosInContent(section) - currentScroll); if (distance < bestDistance) { bestDistance = distance; diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 43365a610d..65eb5154a6 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -104,7 +104,7 @@ namespace osu.Game.Overlays.Pause { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, Spacing = new Vector2(0f, 50f), Origin = Anchor.Centre, Anchor = Anchor.Centre, @@ -113,7 +113,7 @@ namespace osu.Game.Overlays.Pause new FlowContainer { AutoSizeAxes = Axes.Both, - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, Spacing = new Vector2(0f, 20f), Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index dc8b8d1e9a..7a112ae070 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -43,7 +43,7 @@ namespace osu.Game.Overlays.Toolbar new ToolbarBackground(), new FlowContainer { - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, Children = new Drawable[] @@ -63,7 +63,7 @@ namespace osu.Game.Overlays.Toolbar { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, Children = new Drawable[] diff --git a/osu.Game/Overlays/Toolbar/ToolbarButton.cs b/osu.Game/Overlays/Toolbar/ToolbarButton.cs index 67b0039971..1b8e68151c 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarButton.cs @@ -84,7 +84,7 @@ namespace osu.Game.Overlays.Toolbar }, Flow = new FlowContainer { - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Padding = new MarginPadding { Left = Toolbar.HEIGHT / 2, Right = Toolbar.HEIGHT / 2 }, @@ -107,7 +107,7 @@ namespace osu.Game.Overlays.Toolbar }, tooltipContainer = new FlowContainer { - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, RelativeSizeAxes = Axes.Both, //stops us being considered in parent's autosize Anchor = (TooltipAnchor & Anchor.x0) > 0 ? Anchor.BottomLeft : Anchor.BottomRight, Origin = TooltipAnchor, diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 0ef56435e6..af543ae559 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -38,7 +38,7 @@ namespace osu.Game.Overlays.Toolbar { RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Padding = new MarginPadding { Left = 10, Right = 10 }, diff --git a/osu.Game/Screens/GameModeWhiteBox.cs b/osu.Game/Screens/GameModeWhiteBox.cs index 0cda73f225..b72a352ef9 100644 --- a/osu.Game/Screens/GameModeWhiteBox.cs +++ b/osu.Game/Screens/GameModeWhiteBox.cs @@ -126,7 +126,7 @@ namespace osu.Game.Screens }, childModeButtons = new FlowContainer { - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, RelativeSizeAxes = Axes.Both, diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index 7e1db73205..14d957733a 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -114,7 +114,7 @@ namespace osu.Game.Screens.Menu new OsuSpriteText { Shadow = true, - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, Anchor = Anchor.Centre, Origin = Anchor.Centre, TextSize = 16, diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 6d720569df..9a84a79333 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -81,7 +81,7 @@ namespace osu.Game.Screens.Menu }, buttonFlow = new FlowContainerWithOrigin { - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, Anchor = Anchor.Centre, AutoSizeAxes = Axes.Both, Spacing = new Vector2(-WEDGE_WIDTH, 0), diff --git a/osu.Game/Screens/Play/KeyCounterCollection.cs b/osu.Game/Screens/Play/KeyCounterCollection.cs index 709f34fac4..8e7f7558d7 100644 --- a/osu.Game/Screens/Play/KeyCounterCollection.cs +++ b/osu.Game/Screens/Play/KeyCounterCollection.cs @@ -12,7 +12,7 @@ namespace osu.Game.Screens.Play { public KeyCounterCollection() { - Direction = FlowDirection.HorizontalOnly; + Direction = FlowDirections.Horizontal; AutoSizeAxes = Axes.Both; } diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 363b386b42..5e61f381e9 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -69,7 +69,7 @@ namespace osu.Game.Screens.Ranking new FlowContainer { AutoSizeAxes = Axes.Both, - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, Children = new Drawable[] { new OsuSpriteText diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index ebee3090c1..390d175bd4 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -127,7 +127,7 @@ namespace osu.Game.Screens.Select { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 20 }, AutoSizeAxes = Axes.Both, Children = new Drawable[] @@ -149,7 +149,7 @@ namespace osu.Game.Screens.Select new FlowContainer { Margin = new MarginPadding { Top = 10 }, - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, AutoSizeAxes = Axes.Both, Children = new [] { diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index c3f0eb9b6d..512fa22b3a 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -43,7 +43,7 @@ namespace osu.Game.Screens.Select Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Width = 0.4f, // TODO: InnerWidth property or something - Direction = FlowDirection.VerticalOnly, + Direction = FlowDirections.Vertical, Children = new Drawable[] { searchTextBox = new SearchTextBox { RelativeSizeAxes = Axes.X }, @@ -175,7 +175,7 @@ namespace osu.Game.Screens.Select new FlowContainer { AutoSizeAxes = Axes.Both, - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, Spacing = new Vector2(10, 0), Children = new Drawable[] { @@ -207,7 +207,7 @@ namespace osu.Game.Screens.Select new FlowContainer { AutoSizeAxes = Axes.Both, - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, Spacing = new Vector2(10, 0), Origin = Anchor.TopRight, Anchor = Anchor.TopRight, diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index 1ef970b7f0..55fb36f144 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -94,14 +94,14 @@ namespace osu.Game.Screens.Select Position = new Vector2(BackButton.SIZE_EXTENDED.X + padding, 0), RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, Spacing = new Vector2(padding, 0), Children = new Drawable[] { buttons = new FlowContainer { - Direction = FlowDirection.HorizontalOnly, + Direction = FlowDirections.Horizontal, Spacing = new Vector2(0.2f, 0), AutoSizeAxes = Axes.Both, } From 11643d2e0954d25fed7881a22a08ee41416decbe Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 Feb 2017 18:30:47 +0900 Subject: [PATCH 12/13] Remove unnecessary methods and local variables. --- .../Beatmaps/IO/LegacyFilesystemReader.cs | 20 ++++--------------- .../Beatmaps/IO/OszArchiveReaderTest.cs | 2 +- osu.Game/Beatmaps/IO/ArchiveReader.cs | 15 ++++++++------ osu.Game/Beatmaps/IO/OszArchiveReader.cs | 20 ++++--------------- osu.Game/Beatmaps/WorkingBeatmap.cs | 1 + osu.Game/Database/BeatmapDatabase.cs | 4 ++-- 6 files changed, 21 insertions(+), 41 deletions(-) diff --git a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs index 420141e9a1..132f14ddb5 100644 --- a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs +++ b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs @@ -20,34 +20,22 @@ namespace osu.Desktop.Beatmaps.IO public static void Register() => AddReader((storage, path) => Directory.Exists(path)); private string basePath { get; set; } - private string[] beatmaps { get; set; } - private string storyboard { get; set; } private Beatmap firstMap { get; set; } public LegacyFilesystemReader(string path) { basePath = path; - beatmaps = Directory.GetFiles(basePath, @"*.osu").Select(f => Path.GetFileName(f)).ToArray(); - if (beatmaps.Length == 0) + BeatmapFilenames = Directory.GetFiles(basePath, @"*.osu").Select(f => Path.GetFileName(f)).ToArray(); + if (BeatmapFilenames.Length == 0) throw new FileNotFoundException(@"This directory contains no beatmaps"); - storyboard = Directory.GetFiles(basePath, @"*.osb").Select(f => Path.GetFileName(f)).FirstOrDefault(); - using (var stream = new StreamReader(GetStream(beatmaps[0]))) + StoryboardFilename = Directory.GetFiles(basePath, @"*.osb").Select(f => Path.GetFileName(f)).FirstOrDefault(); + using (var stream = new StreamReader(GetStream(BeatmapFilenames[0]))) { var decoder = BeatmapDecoder.GetDecoder(stream); firstMap = decoder.Decode(stream); } } - public override string[] ReadBeatmaps() - { - return beatmaps; - } - - public override string ReadStoryboard() - { - return storyboard; - } - public override Stream GetStream(string name) { return File.OpenRead(Path.Combine(basePath, name)); diff --git a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs index a09d0c2f86..037c0185b8 100644 --- a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs @@ -39,7 +39,7 @@ namespace osu.Game.Tests.Beatmaps.IO "Soleily - Renatus (MMzz) [Muzukashii].osu", "Soleily - Renatus (MMzz) [Oni].osu" }; - var maps = reader.ReadBeatmaps(); + var maps = reader.BeatmapFilenames; foreach (var map in expected) Assert.Contains(map, maps); } diff --git a/osu.Game/Beatmaps/IO/ArchiveReader.cs b/osu.Game/Beatmaps/IO/ArchiveReader.cs index a944e7589a..cb5f936939 100644 --- a/osu.Game/Beatmaps/IO/ArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/ArchiveReader.cs @@ -19,7 +19,7 @@ namespace osu.Game.Beatmaps.IO } private static List readers { get; } = new List(); - + public static ArchiveReader GetReader(BasicStorage storage, string path) { foreach (var reader in readers) @@ -29,24 +29,27 @@ namespace osu.Game.Beatmaps.IO } throw new IOException(@"Unknown file format"); } - + protected static void AddReader(Func test) where T : ArchiveReader { readers.Add(new Reader { Test = test, Type = typeof(T) }); } - + /// /// Reads the beatmap metadata from this archive. /// public abstract BeatmapMetadata ReadMetadata(); + /// /// Gets a list of beatmap file names. /// - public abstract string[] ReadBeatmaps(); + public string[] BeatmapFilenames { get; protected set; } + /// - /// Gets the storyboard file name. + /// The storyboard filename. Null if no storyboard is present. /// - public abstract string ReadStoryboard(); + public string StoryboardFilename { get; protected set; } + /// /// Opens a stream for reading a specific file from this archive. /// diff --git a/osu.Game/Beatmaps/IO/OszArchiveReader.cs b/osu.Game/Beatmaps/IO/OszArchiveReader.cs index f9b7fb2cf8..273e0c1fb9 100644 --- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs @@ -25,37 +25,25 @@ namespace osu.Game.Beatmaps.IO private Stream archiveStream; private ZipFile archive; - private string[] beatmaps; - private string storyboard; private Beatmap firstMap; public OszArchiveReader(Stream archiveStream) { this.archiveStream = archiveStream; archive = ZipFile.Read(archiveStream); - beatmaps = archive.Entries.Where(e => e.FileName.EndsWith(@".osu")) + BeatmapFilenames = archive.Entries.Where(e => e.FileName.EndsWith(@".osu")) .Select(e => e.FileName).ToArray(); - if (beatmaps.Length == 0) + if (BeatmapFilenames.Length == 0) throw new FileNotFoundException(@"This directory contains no beatmaps"); - storyboard = archive.Entries.Where(e => e.FileName.EndsWith(@".osb")) + StoryboardFilename = archive.Entries.Where(e => e.FileName.EndsWith(@".osb")) .Select(e => e.FileName).FirstOrDefault(); - using (var stream = new StreamReader(GetStream(beatmaps[0]))) + using (var stream = new StreamReader(GetStream(BeatmapFilenames[0]))) { var decoder = BeatmapDecoder.GetDecoder(stream); firstMap = decoder.Decode(stream); } } - public override string[] ReadBeatmaps() - { - return beatmaps; - } - - public override string ReadStoryboard() - { - return storyboard; - } - public override Stream GetStream(string name) { ZipEntry entry = archive.Entries.SingleOrDefault(e => e.FileName == name); diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 7f1cf236ac..62223ec879 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -68,6 +68,7 @@ namespace osu.Game.Beatmaps beatmap = decoder?.Decode(stream); } + if (WithStoryboard && beatmap != null && BeatmapSetInfo.StoryboardFile != null) using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile))) decoder?.Decode(stream, beatmap); diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index a81c1fe552..9c7e70f8eb 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -125,7 +125,7 @@ namespace osu.Game.Database using (var reader = ArchiveReader.GetReader(storage, path)) { - string[] mapNames = reader.ReadBeatmaps(); + string[] mapNames = reader.BeatmapFilenames; foreach (var name in mapNames) { using (var stream = new StreamReader(reader.GetStream(name))) @@ -139,7 +139,7 @@ namespace osu.Game.Database beatmapSet.Beatmaps.Add(beatmap.BeatmapInfo); } - beatmapSet.StoryboardFile = reader.ReadStoryboard(); + beatmapSet.StoryboardFile = reader.StoryboardFilename; } } From 3caa6ee5d2af976c1c2a93e03adeec1190948fef Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 Feb 2017 08:33:42 +0900 Subject: [PATCH 13/13] Update framework. --- osu-framework | 2 +- osu-resources | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu-framework b/osu-framework index 4d7f9b8a3a..1cd7a165ec 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 4d7f9b8a3afd32183a31d62143d522d43d8c01ca +Subproject commit 1cd7a165ec42cd1eeb4eee06b5a4a6cdd8c280da diff --git a/osu-resources b/osu-resources index 2a3dd3f3dd..51f2b9b37f 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit 2a3dd3f3dd68fe52b779d0fdded3ce444897efee +Subproject commit 51f2b9b37f38cd349a3dd728a78f8fffcb3a54f5