diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index a3ae103f28..b5e31bc5f5 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -6,6 +6,7 @@ using osu.Framework.GameModes.Testing; using osu.Framework.MathUtils; using osu.Framework.Timing; using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects.Osu; using osu.Game.GameModes.Play; @@ -38,20 +39,27 @@ namespace osu.Desktop.VisualTests.Tests objects.Add(new Circle() { StartTime = time, - Position = new Vector2(RNG.Next(100, 400), RNG.Next(100, 200)) + Position = new Vector2(RNG.Next(0, 512), RNG.Next(0, 384)), + NewCombo = (i + 1) % 4 == 0 }); time += 500; } + var decoder = new ConstructableBeatmapDecoder(); + + Beatmap b = new Beatmap + { + HitObjects = objects + }; + + decoder.Process(b); + Add(new Player { Beatmap = new WorkingBeatmap { - Beatmap = new Beatmap - { - HitObjects = objects - } + Beatmap = b } }); } diff --git a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs index f376d831cf..047d599784 100644 --- a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs @@ -1,13 +1,15 @@ using System; using System.Collections.Generic; using System.IO; +using osu.Game.Beatmaps.Objects; +using OpenTK.Graphics; namespace osu.Game.Beatmaps.Formats { public abstract class BeatmapDecoder { private static Dictionary decoders { get; } = new Dictionary(); - + public static BeatmapDecoder GetDecoder(TextReader stream) { var line = stream.ReadLine().Trim(); @@ -20,7 +22,39 @@ namespace osu.Game.Beatmaps.Formats { decoders[magic] = typeof(T); } - - public abstract Beatmap Decode(TextReader stream); + + public virtual Beatmap Decode(TextReader stream) + { + Beatmap b = ParseFile(stream); + Process(b); + return b; + } + + public virtual Beatmap Process(Beatmap beatmap) + { + ApplyColours(beatmap); + + return beatmap; + } + + protected abstract Beatmap ParseFile(TextReader stream); + + public virtual void ApplyColours(Beatmap b) + { + List colours = b.ComboColors ?? new List() { + new Color4(17, 136, 170, 255), + new Color4(102,136,0, 255), + new Color4(204,102,0, 255), + new Color4(121,9,13, 255), + }; + + int i = 0; + + foreach (HitObject h in b.HitObjects) + { + h.Colour = colours[i]; + if (h.NewCombo) i = (i + 1) % colours.Count; + } + } } } diff --git a/osu.Game/Beatmaps/Formats/ConstructableBeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/ConstructableBeatmapDecoder.cs new file mode 100644 index 0000000000..e1dae7b193 --- /dev/null +++ b/osu.Game/Beatmaps/Formats/ConstructableBeatmapDecoder.cs @@ -0,0 +1,20 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Game.Beatmaps.Formats +{ + public class ConstructableBeatmapDecoder : BeatmapDecoder + { + protected override Beatmap ParseFile(TextReader stream) + { + throw new NotImplementedException(); + } + } +} diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index 7d3b918961..7dce625a8e 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -207,7 +207,7 @@ namespace osu.Game.Beatmaps.Formats }); } - public override Beatmap Decode(TextReader stream) + protected override Beatmap ParseFile(TextReader stream) { var beatmap = new Beatmap { diff --git a/osu.Game/Beatmaps/Objects/HitObject.cs b/osu.Game/Beatmaps/Objects/HitObject.cs index 44cab54fa3..ef6659224f 100644 --- a/osu.Game/Beatmaps/Objects/HitObject.cs +++ b/osu.Game/Beatmaps/Objects/HitObject.cs @@ -4,6 +4,7 @@ using osu.Game.Beatmaps.Objects.Osu; using osu.Game.Beatmaps.Samples; using osu.Game.GameModes.Play; +using OpenTK.Graphics; namespace osu.Game.Beatmaps.Objects { @@ -15,6 +16,10 @@ namespace osu.Game.Beatmaps.Objects public double StartTime; public virtual double EndTime => StartTime; + public bool NewCombo { get; set; } + + public Color4 Colour = new Color4(17, 136, 170, 255); + public double Duration => EndTime - StartTime; public HitSampleInfo Sample; diff --git a/osu.Game/Beatmaps/Objects/Osu/Circle.cs b/osu.Game/Beatmaps/Objects/Osu/Circle.cs index e276132ebc..9b7f92f29e 100644 --- a/osu.Game/Beatmaps/Objects/Osu/Circle.cs +++ b/osu.Game/Beatmaps/Objects/Osu/Circle.cs @@ -7,6 +7,5 @@ namespace osu.Game.Beatmaps.Objects.Osu { public class Circle : OsuBaseHit { - public Color4 Colour = new Color4(17, 136, 170, 255); } } diff --git a/osu.Game/Beatmaps/Objects/Osu/OsuBaseHit.cs b/osu.Game/Beatmaps/Objects/Osu/OsuBaseHit.cs index 2f94c70a0e..e4bb272404 100644 --- a/osu.Game/Beatmaps/Objects/Osu/OsuBaseHit.cs +++ b/osu.Game/Beatmaps/Objects/Osu/OsuBaseHit.cs @@ -10,7 +10,6 @@ namespace osu.Game.Beatmaps.Objects.Osu public abstract class OsuBaseHit : HitObject { public Vector2 Position { get; set; } - public bool NewCombo { get; set; } [Flags] private enum HitObjectType diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index b2a8cee6a5..92679b7d58 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -64,6 +64,7 @@ +