From 9de18d45a5bd4e464ce644717a1c89b0622f5839 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 22 May 2017 10:00:11 +0900 Subject: [PATCH 1/4] Use bitshifted notation. --- .../Beatmaps/Patterns/Legacy/PatternType.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs index d4957d41a9..d645882511 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs @@ -15,51 +15,51 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy /// /// Keep the same as last row. /// - ForceStack = 1, + ForceStack = 1 << 0, /// /// Keep different from last row. /// - ForceNotStack = 2, + ForceNotStack = 1 << 1, /// /// Keep as single note at its original position. /// - KeepSingle = 4, + KeepSingle = 1 << 2, /// /// Use a lower random value. /// - LowProbability = 8, + LowProbability = 1 << 3, /// /// Reserved. /// - Alternate = 16, + Alternate = 1 << 4, /// /// Ignore the repeat count. /// - ForceSigSlider = 32, + ForceSigSlider = 1 << 5, /// /// Convert slider to circle. /// - ForceNotSlider = 64, + ForceNotSlider = 1 << 6, /// /// Notes gathered together. /// - Gathered = 128, - Mirror = 256, + Gathered = 1 << 7, + Mirror = 1 << 8, /// /// Change 0 -> 6. /// - Reverse = 512, + Reverse = 1 << 9, /// /// 1 -> 5 -> 1 -> 5 like reverse. /// - Cycle = 1024, + Cycle = 1 << 10, /// /// Next note will be at column + 1. /// - Stair = 2048, + Stair = 1 << 11, /// /// Next note will be at column - 1. /// - ReverseStair = 4096 + ReverseStair = 1 << 12 } } From 8c260e3364be8034d8babfb33185b0fe35d3551f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 22 May 2017 10:04:25 +0900 Subject: [PATCH 2/4] Renamings + refactorings to Pattern. --- .../Beatmaps/Patterns/Pattern.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs index cbde1f0f53..331b92f8a4 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs @@ -21,16 +21,16 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns public IEnumerable HitObjects => hitObjects; /// - /// Whether this pattern already contains a hit object in a code. + /// Check whether a column of this patterns contains a hit object. /// /// The column index. - /// Whether this pattern already contains a hit object in - public bool IsFilled(int column) => hitObjects.Exists(h => h.Column == column); + /// Whether the column with index contains a hit object. + public bool ColumnHasObject(int column) => hitObjects.Exists(h => h.Column == column); /// /// Amount of columns taken up by hit objects in this pattern. /// - public int ColumnsFilled => HitObjects.GroupBy(h => h.Column).Count(); + public int ColumnWithObjects => HitObjects.GroupBy(h => h.Column).Count(); /// /// Adds a hit object to this pattern. @@ -42,10 +42,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns /// Copies hit object from another pattern to this one. /// /// The other pattern. - public void Add(Pattern other) - { - other.HitObjects.ForEach(Add); - } + public void Add(Pattern other) => hitObjects.AddRange(other.HitObjects); /// /// Clears this pattern, removing all hit objects. From 0a0139adedb34bbc3ad1e0f4015f06f65fe3f8e0 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 22 May 2017 10:12:33 +0900 Subject: [PATCH 3/4] Remove the concept of beatmap events, rename BreakEvent -> BreakPeriod. --- .../Patterns/Legacy/PatternGenerator.cs | 2 +- osu.Game/Beatmaps/Beatmap.cs | 11 +++++-- osu.Game/Beatmaps/Events/BackgroundEvent.cs | 13 -------- osu.Game/Beatmaps/Events/Event.cs | 13 -------- osu.Game/Beatmaps/Events/EventInfo.cs | 33 ------------------- osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs | 11 ++----- .../BreakEvent.cs => Timing/BreakPeriod.cs} | 13 +++++--- osu.Game/osu.Game.csproj | 5 +-- 8 files changed, 21 insertions(+), 80 deletions(-) delete mode 100644 osu.Game/Beatmaps/Events/BackgroundEvent.cs delete mode 100644 osu.Game/Beatmaps/Events/Event.cs delete mode 100644 osu.Game/Beatmaps/Events/EventInfo.cs rename osu.Game/Beatmaps/{Events/BreakEvent.cs => Timing/BreakPeriod.cs} (70%) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs index ad07c03b96..e6e3f1d07f 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs @@ -90,7 +90,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy HitObject firstObject = Beatmap.HitObjects.FirstOrDefault(); double drainTime = (lastObject?.StartTime ?? 0) - (firstObject?.StartTime ?? 0); - drainTime -= Beatmap.EventInfo.TotalBreakTime; + drainTime -= Beatmap.TotalBreakTime; if (drainTime == 0) drainTime = 10000; diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index a64002e0b0..608b2fcd19 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -2,11 +2,11 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; -using osu.Game.Beatmaps.Events; using osu.Game.Beatmaps.Timing; using osu.Game.Database; using osu.Game.Rulesets.Objects; using System.Collections.Generic; +using System.Linq; namespace osu.Game.Beatmaps { @@ -18,7 +18,7 @@ namespace osu.Game.Beatmaps { public BeatmapInfo BeatmapInfo; public TimingInfo TimingInfo = new TimingInfo(); - public EventInfo EventInfo = new EventInfo(); + public List Breaks = new List(); public readonly List ComboColors = new List { new Color4(17, 136, 170, 255), @@ -34,6 +34,11 @@ namespace osu.Game.Beatmaps /// public List HitObjects; + /// + /// Total amount of break time in the beatmap. + /// + public double TotalBreakTime => Breaks.Sum(b => b.Duration); + /// /// Constructs a new beatmap. /// @@ -42,7 +47,7 @@ namespace osu.Game.Beatmaps { BeatmapInfo = original?.BeatmapInfo ?? BeatmapInfo; TimingInfo = original?.TimingInfo ?? TimingInfo; - EventInfo = original?.EventInfo ?? EventInfo; + Breaks = original?.Breaks ?? Breaks; ComboColors = original?.ComboColors ?? ComboColors; } } diff --git a/osu.Game/Beatmaps/Events/BackgroundEvent.cs b/osu.Game/Beatmaps/Events/BackgroundEvent.cs deleted file mode 100644 index 215373bd3b..0000000000 --- a/osu.Game/Beatmaps/Events/BackgroundEvent.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -namespace osu.Game.Beatmaps.Events -{ - public class BackgroundEvent : Event - { - /// - /// The file name. - /// - public string Filename; - } -} diff --git a/osu.Game/Beatmaps/Events/Event.cs b/osu.Game/Beatmaps/Events/Event.cs deleted file mode 100644 index 3af3909462..0000000000 --- a/osu.Game/Beatmaps/Events/Event.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -namespace osu.Game.Beatmaps.Events -{ - public abstract class Event - { - /// - /// The event start time. - /// - public double StartTime; - } -} diff --git a/osu.Game/Beatmaps/Events/EventInfo.cs b/osu.Game/Beatmaps/Events/EventInfo.cs deleted file mode 100644 index 3ba3d5ba03..0000000000 --- a/osu.Game/Beatmaps/Events/EventInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System.Collections.Generic; -using System.Linq; - -namespace osu.Game.Beatmaps.Events -{ - public class EventInfo - { - /// - /// All the background events. - /// - public readonly List Backgrounds = new List(); - - /// - /// All the break events. - /// - public readonly List Breaks = new List(); - - /// - /// Total duration of all breaks. - /// - public double TotalBreakTime => Breaks.Sum(b => b.Duration); - - /// - /// Retrieves the active background at a time. - /// - /// The time to retrieve the background at. - /// The background. - public BackgroundEvent BackgroundAt(double time) => Backgrounds.FirstOrDefault(b => b.StartTime <= time); - } -} diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index 772c0e9c07..04208337c7 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -5,7 +5,6 @@ using System; using System.Globalization; using System.IO; using OpenTK.Graphics; -using osu.Game.Beatmaps.Events; using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Legacy; using osu.Game.Rulesets.Objects.Legacy; @@ -217,18 +216,12 @@ namespace osu.Game.Beatmaps.Formats case EventType.Background: string filename = split[2].Trim('"'); - beatmap.EventInfo.Backgrounds.Add(new BackgroundEvent - { - StartTime = double.Parse(split[1], NumberFormatInfo.InvariantInfo), - Filename = filename - }); - if (type == EventType.Background) beatmap.BeatmapInfo.Metadata.BackgroundFile = filename; break; case EventType.Break: - var breakEvent = new BreakEvent + var breakEvent = new BreakPeriod { StartTime = double.Parse(split[1], NumberFormatInfo.InvariantInfo), EndTime = double.Parse(split[2], NumberFormatInfo.InvariantInfo) @@ -237,7 +230,7 @@ namespace osu.Game.Beatmaps.Formats if (!breakEvent.HasEffect) return; - beatmap.EventInfo.Breaks.Add(breakEvent); + beatmap.Breaks.Add(breakEvent); break; } } diff --git a/osu.Game/Beatmaps/Events/BreakEvent.cs b/osu.Game/Beatmaps/Timing/BreakPeriod.cs similarity index 70% rename from osu.Game/Beatmaps/Events/BreakEvent.cs rename to osu.Game/Beatmaps/Timing/BreakPeriod.cs index 78e33f2fbb..fb307b7144 100644 --- a/osu.Game/Beatmaps/Events/BreakEvent.cs +++ b/osu.Game/Beatmaps/Timing/BreakPeriod.cs @@ -1,27 +1,32 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Beatmaps.Events +namespace osu.Game.Beatmaps.Timing { - public class BreakEvent : Event + public class BreakPeriod { /// /// The minimum duration required for a break to have any effect. /// private const double min_break_duration = 650; + /// + /// The break start time. + /// + public double StartTime; + /// /// The break end time. /// public double EndTime; /// - /// The duration of the break. + /// The break duration. /// public double Duration => EndTime - StartTime; /// - /// Whether the break has any effect. Breaks that are too short are culled before they reach the EventInfo. + /// Whether the break has any effect. Breaks that are too short are culled before they are added to the beatmap. /// public bool HasEffect => Duration >= min_break_duration; } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index acc6fd4abe..1631311ef6 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -74,10 +74,6 @@ - - - - @@ -91,6 +87,7 @@ + From 4ce3a7806690b7672080253bc13caaf7e9fe3813 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 22 May 2017 10:18:42 +0900 Subject: [PATCH 4/4] Update Pattern.cs --- osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs index 331b92f8a4..15d31406e9 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Pattern.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Rulesets.Mania.Objects; namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns