From fd53d102646fd3e26250ca5c69c5bab54c156714 Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Mon, 6 Mar 2017 23:56:08 +0100 Subject: [PATCH 01/26] Refactor ArchiveReader for extensibility --- .../Beatmaps/IO/LegacyFilesystemReader.cs | 2 +- osu.Game/Beatmaps/IO/ArchiveReader.cs | 24 ++---------- osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs | 39 +++++++++++++++++++ osu.Game/Beatmaps/IO/OszArchiveReader.cs | 2 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 4 +- osu.Game/Database/BeatmapDatabase.cs | 10 ++--- osu.Game/osu.Game.csproj | 3 +- 7 files changed, 54 insertions(+), 30 deletions(-) create mode 100644 osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs diff --git a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs index b8bfb63a08..632a33f670 100644 --- a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs +++ b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs @@ -13,7 +13,7 @@ namespace osu.Desktop.Beatmaps.IO /// /// Reads an extracted legacy beatmap from disk. /// - public class LegacyFilesystemReader : ArchiveReader + public class LegacyFilesystemReader : BeatmapArchiveReader { public static void Register() => AddReader((storage, path) => Directory.Exists(path)); diff --git a/osu.Game/Beatmaps/IO/ArchiveReader.cs b/osu.Game/Beatmaps/IO/ArchiveReader.cs index bbf4de20f5..ba84402782 100644 --- a/osu.Game/Beatmaps/IO/ArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/ArchiveReader.cs @@ -6,23 +6,22 @@ using System.Collections.Generic; using System.IO; using osu.Framework.IO.Stores; using osu.Framework.Platform; -using osu.Game.Database; namespace osu.Game.Beatmaps.IO { public abstract class ArchiveReader : IDisposable, IResourceStore { - private class Reader + protected class Reader { public Func Test { get; set; } public Type Type { get; set; } } - private static List readers { get; } = new List(); + protected static List Readers { get; } = new List(); public static ArchiveReader GetReader(Storage storage, string path) { - foreach (var reader in readers) + foreach (var reader in Readers) { if (reader.Test(storage, path)) return (ArchiveReader)Activator.CreateInstance(reader.Type, storage.GetStream(path)); @@ -32,24 +31,9 @@ namespace osu.Game.Beatmaps.IO protected static void AddReader(Func test) where T : ArchiveReader { - readers.Add(new Reader { Test = test, Type = typeof(T) }); + 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 string[] BeatmapFilenames { get; protected set; } - - /// - /// The storyboard filename. Null if no storyboard is present. - /// - public string StoryboardFilename { get; protected set; } - /// /// Opens a stream for reading a specific file from this archive. /// diff --git a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs new file mode 100644 index 0000000000..8cff2c121f --- /dev/null +++ b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs @@ -0,0 +1,39 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.IO; +using osu.Framework.Platform; +using osu.Game.Database; + +namespace osu.Game.Beatmaps.IO +{ + public abstract class BeatmapArchiveReader : ArchiveReader + { + + public static BeatmapArchiveReader GetBeatmapArchiveReader(Storage storage, string path) + { + foreach (var reader in Readers) + { + if (reader.Test(storage, path)) + return (BeatmapArchiveReader)Activator.CreateInstance(reader.Type, storage.GetStream(path)); + } + throw new IOException(@"Unknown file format"); + } + + /// + /// Reads the beatmap metadata from this archive. + /// + public abstract BeatmapMetadata ReadMetadata(); + + /// + /// Gets a list of beatmap file names. + /// + public string[] BeatmapFilenames { get; protected set; } + + /// + /// The storyboard filename. Null if no storyboard is present. + /// + public string StoryboardFilename { get; protected set; } + } +} \ No newline at end of file diff --git a/osu.Game/Beatmaps/IO/OszArchiveReader.cs b/osu.Game/Beatmaps/IO/OszArchiveReader.cs index 8a1d071cfc..802fe7784b 100644 --- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs @@ -9,7 +9,7 @@ using osu.Game.Database; namespace osu.Game.Beatmaps.IO { - public sealed class OszArchiveReader : ArchiveReader + public sealed class OszArchiveReader : BeatmapArchiveReader { public static void Register() { diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 9393c2b0e9..4254652765 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -19,7 +19,7 @@ namespace osu.Game.Beatmaps public readonly bool WithStoryboard; - protected abstract ArchiveReader GetReader(); + protected abstract BeatmapArchiveReader GetReader(); protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false) { @@ -87,7 +87,7 @@ namespace osu.Game.Beatmaps set { lock (beatmapLock) beatmap = value; } } - private ArchiveReader trackReader; + private BeatmapArchiveReader trackReader; private Track track; private object trackLock = new object(); public Track Track diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 03f904b7e8..1be0757e00 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -176,7 +176,7 @@ namespace osu.Game.Database BeatmapMetadata metadata; - using (var reader = ArchiveReader.GetReader(storage, path)) + using (var reader = BeatmapArchiveReader.GetBeatmapArchiveReader(storage, path)) metadata = reader.ReadMetadata(); if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader @@ -216,7 +216,7 @@ namespace osu.Game.Database Metadata = metadata }; - using (var reader = ArchiveReader.GetReader(storage, path)) + using (var reader = BeatmapArchiveReader.GetBeatmapArchiveReader(storage, path)) { string[] mapNames = reader.BeatmapFilenames; foreach (var name in mapNames) @@ -261,12 +261,12 @@ namespace osu.Game.Database BeatmapSetRemoved?.Invoke(beatmapSet); } - public ArchiveReader GetReader(BeatmapSetInfo beatmapSet) + public BeatmapArchiveReader GetReader(BeatmapSetInfo beatmapSet) { if (string.IsNullOrEmpty(beatmapSet.Path)) return null; - return ArchiveReader.GetReader(storage, beatmapSet.Path); + return BeatmapArchiveReader.GetBeatmapArchiveReader(storage, beatmapSet.Path); } public BeatmapSetInfo GetBeatmapSet(int id) @@ -348,7 +348,7 @@ namespace osu.Game.Database this.database = database; } - protected override ArchiveReader GetReader() => database?.GetReader(BeatmapSetInfo); + protected override BeatmapArchiveReader GetReader() => database?.GetReader(BeatmapSetInfo); } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index f38c2f7ba0..10d82396a7 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -223,7 +223,7 @@ - + @@ -311,6 +311,7 @@ + From a29748915177fe68d68b65b91fc2fe77216422b8 Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Tue, 7 Mar 2017 00:03:04 +0100 Subject: [PATCH 02/26] Fix test --- osu.Desktop.VisualTests/Tests/TestCasePlayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index 1bb8144fc4..e284ea1c47 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -99,7 +99,7 @@ namespace osu.Desktop.VisualTests.Tests Beatmap = beatmap; } - protected override ArchiveReader GetReader() => null; + protected override BeatmapArchiveReader GetReader() => null; } } } From aee7b05bae19495e18837e6a734ae16e56dc37ff Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Tue, 7 Mar 2017 00:10:33 +0100 Subject: [PATCH 03/26] ArchiveManager decoupling --- osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs index 8cff2c121f..9134b9b2ae 100644 --- a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs @@ -3,6 +3,7 @@ using System; using System.IO; +using osu.Framework.Logging; using osu.Framework.Platform; using osu.Game.Database; @@ -13,12 +14,15 @@ namespace osu.Game.Beatmaps.IO public static BeatmapArchiveReader GetBeatmapArchiveReader(Storage storage, string path) { - foreach (var reader in Readers) + try { - if (reader.Test(storage, path)) - return (BeatmapArchiveReader)Activator.CreateInstance(reader.Type, storage.GetStream(path)); + return (BeatmapArchiveReader)GetReader(storage, path); + } + catch (InvalidCastException e) + { + Logger.Error(e, "A tricky ArchiveReader instance passed the test to be a BeatmapArhiveReader, but it's really not"); + throw e; } - throw new IOException(@"Unknown file format"); } /// From 2c7a9d2f77b997e1bdeeb52de2d017d9a63f7159 Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Tue, 7 Mar 2017 08:47:50 +0100 Subject: [PATCH 04/26] Remove unnecessary using --- osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs index 9134b9b2ae..409345e0c6 100644 --- a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.IO; using osu.Framework.Logging; using osu.Framework.Platform; using osu.Game.Database; From 9f40a888ec378a5dce0321206d59164e4e27b2a1 Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Wed, 8 Mar 2017 21:55:38 +0100 Subject: [PATCH 05/26] Update BeatmapArchiveReader's test --- osu.Game/Beatmaps/IO/OszArchiveReader.cs | 2 +- osu.Game/Database/BeatmapDatabase.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/IO/OszArchiveReader.cs b/osu.Game/Beatmaps/IO/OszArchiveReader.cs index 802fe7784b..c7953245a7 100644 --- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs @@ -16,7 +16,7 @@ namespace osu.Game.Beatmaps.IO AddReader((storage, path) => { using (var stream = storage.GetStream(path)) - return ZipFile.IsZipFile(stream, false); + return (Path.GetExtension(path) == ".osz") && ZipFile.IsZipFile(stream, false); }); OsuLegacyDecoder.Register(); } diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index c5b3130a77..d50d00c6b3 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -186,7 +186,7 @@ namespace osu.Game.Database { hash = input.GetMd5Hash(); input.Seek(0, SeekOrigin.Begin); - path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash); + path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash+".osz"); if (!storage.Exists(path)) using (var output = storage.GetStream(path, FileAccess.Write)) input.CopyTo(output); From f969c3b7b3344852b4656211baeec70a8b81300a Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Thu, 9 Mar 2017 21:00:13 +0100 Subject: [PATCH 06/26] Fix test --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index ae936f3f49..69434505ce 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -106,7 +106,7 @@ namespace osu.Game.Tests.Beatmaps.IO private string prepareTempCopy(string path) { - var temp = Path.GetTempFileName(); + var temp = Path.GetTempPath()+Guid.NewGuid()+".osz"; return new FileInfo(path).CopyTo(temp, true).FullName; } From faecaa297aefbe655580c6bb3b7d4ca6e3d43483 Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Thu, 9 Mar 2017 21:07:21 +0100 Subject: [PATCH 07/26] Fix warnings --- osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs | 2 +- osu.Game/Beatmaps/IO/OszArchiveReader.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs index 409345e0c6..a1a7149f2e 100644 --- a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs @@ -20,7 +20,7 @@ namespace osu.Game.Beatmaps.IO catch (InvalidCastException e) { Logger.Error(e, "A tricky ArchiveReader instance passed the test to be a BeatmapArhiveReader, but it's really not"); - throw e; + throw; } } diff --git a/osu.Game/Beatmaps/IO/OszArchiveReader.cs b/osu.Game/Beatmaps/IO/OszArchiveReader.cs index c7953245a7..bf5174f7f9 100644 --- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs @@ -16,7 +16,7 @@ namespace osu.Game.Beatmaps.IO AddReader((storage, path) => { using (var stream = storage.GetStream(path)) - return (Path.GetExtension(path) == ".osz") && ZipFile.IsZipFile(stream, false); + return Path.GetExtension(path) == ".osz" && ZipFile.IsZipFile(stream, false); }); OsuLegacyDecoder.Register(); } From 64aab090d52227a820711db9a76b68995b6ed6cc Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sun, 12 Mar 2017 18:03:13 +0900 Subject: [PATCH 08/26] Instantiate HitRenderer with WorkingBeatmap. --- .../Tests/TestCaseGamefield.cs | 28 +++++++++++++++++-- osu.Game.Modes.Catch/CatchRuleset.cs | 2 +- osu.Game.Modes.Catch/UI/CatchHitRenderer.cs | 2 +- osu.Game.Modes.Mania/ManiaRuleset.cs | 2 +- osu.Game.Modes.Mania/UI/ManiaHitRenderer.cs | 2 +- osu.Game.Modes.Osu/OsuRuleset.cs | 2 +- osu.Game.Modes.Osu/UI/OsuHitRenderer.cs | 2 +- osu.Game.Modes.Taiko/TaikoRuleset.cs | 2 +- osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs | 2 +- osu.Game/Modes/Ruleset.cs | 2 +- osu.Game/Modes/UI/HitRenderer.cs | 4 +-- osu.Game/Screens/Play/Player.cs | 2 +- 12 files changed, 37 insertions(+), 15 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs index ede430478e..767fb0dffb 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs @@ -8,6 +8,8 @@ using osu.Framework.MathUtils; using osu.Framework.Screens.Testing; using osu.Framework.Timing; using osu.Game.Beatmaps; +using osu.Game.Beatmaps.IO; +using osu.Game.Database; using osu.Game.Modes.Catch.UI; using osu.Game.Modes.Mania.UI; using osu.Game.Modes.Objects; @@ -41,10 +43,19 @@ namespace osu.Desktop.VisualTests.Tests time += RNG.Next(50, 500); } - Beatmap beatmap = new Beatmap + WorkingBeatmap beatmap = new TestWorkingBeatmap(new Beatmap { - HitObjects = objects - }; + HitObjects = objects, + BeatmapInfo = new BeatmapInfo + { + Metadata = new BeatmapMetadata + { + Artist = @"Unknown", + Title = @"Sample Beatmap", + Author = @"peppy", + } + } + }); Add(new Drawable[] { @@ -83,5 +94,16 @@ namespace osu.Desktop.VisualTests.Tests } }); } + + private class TestWorkingBeatmap : WorkingBeatmap + { + public TestWorkingBeatmap(Beatmap beatmap) + : base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet) + { + Beatmap = beatmap; + } + + protected override ArchiveReader GetReader() => null; + } } } diff --git a/osu.Game.Modes.Catch/CatchRuleset.cs b/osu.Game.Modes.Catch/CatchRuleset.cs index 2cdd35cf3a..31599bbc44 100644 --- a/osu.Game.Modes.Catch/CatchRuleset.cs +++ b/osu.Game.Modes.Catch/CatchRuleset.cs @@ -15,7 +15,7 @@ namespace osu.Game.Modes.Catch { public class CatchRuleset : Ruleset { - public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new CatchHitRenderer(beatmap); + public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap) => new CatchHitRenderer(beatmap); public override IEnumerable GetModsFor(ModType type) { diff --git a/osu.Game.Modes.Catch/UI/CatchHitRenderer.cs b/osu.Game.Modes.Catch/UI/CatchHitRenderer.cs index 1537227d8f..a8b2d48760 100644 --- a/osu.Game.Modes.Catch/UI/CatchHitRenderer.cs +++ b/osu.Game.Modes.Catch/UI/CatchHitRenderer.cs @@ -11,7 +11,7 @@ namespace osu.Game.Modes.Catch.UI { public class CatchHitRenderer : HitRenderer { - public CatchHitRenderer(Beatmap beatmap) + public CatchHitRenderer(WorkingBeatmap beatmap) : base(beatmap) { } diff --git a/osu.Game.Modes.Mania/ManiaRuleset.cs b/osu.Game.Modes.Mania/ManiaRuleset.cs index 0aef44cd7b..015df0c961 100644 --- a/osu.Game.Modes.Mania/ManiaRuleset.cs +++ b/osu.Game.Modes.Mania/ManiaRuleset.cs @@ -14,7 +14,7 @@ namespace osu.Game.Modes.Mania { public class ManiaRuleset : Ruleset { - public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new ManiaHitRenderer(beatmap); + public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap) => new ManiaHitRenderer(beatmap); public override IEnumerable GetModsFor(ModType type) { diff --git a/osu.Game.Modes.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Modes.Mania/UI/ManiaHitRenderer.cs index 911742b222..d29a088225 100644 --- a/osu.Game.Modes.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Modes.Mania/UI/ManiaHitRenderer.cs @@ -13,7 +13,7 @@ namespace osu.Game.Modes.Mania.UI { private readonly int columns; - public ManiaHitRenderer(Beatmap beatmap, int columns = 5) + public ManiaHitRenderer(WorkingBeatmap beatmap, int columns = 5) : base(beatmap) { this.columns = columns; diff --git a/osu.Game.Modes.Osu/OsuRuleset.cs b/osu.Game.Modes.Osu/OsuRuleset.cs index a61bda5bb3..1b06d704f1 100644 --- a/osu.Game.Modes.Osu/OsuRuleset.cs +++ b/osu.Game.Modes.Osu/OsuRuleset.cs @@ -17,7 +17,7 @@ namespace osu.Game.Modes.Osu { public class OsuRuleset : Ruleset { - public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new OsuHitRenderer(beatmap); + public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap) => new OsuHitRenderer(beatmap); public override IEnumerable GetBeatmapStatistics(WorkingBeatmap beatmap) => new[] { diff --git a/osu.Game.Modes.Osu/UI/OsuHitRenderer.cs b/osu.Game.Modes.Osu/UI/OsuHitRenderer.cs index 8b7606e61e..414bfd2afa 100644 --- a/osu.Game.Modes.Osu/UI/OsuHitRenderer.cs +++ b/osu.Game.Modes.Osu/UI/OsuHitRenderer.cs @@ -12,7 +12,7 @@ namespace osu.Game.Modes.Osu.UI { public class OsuHitRenderer : HitRenderer { - public OsuHitRenderer(Beatmap beatmap) + public OsuHitRenderer(WorkingBeatmap beatmap) : base(beatmap) { } diff --git a/osu.Game.Modes.Taiko/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index 3765862229..e8a8dcdd64 100644 --- a/osu.Game.Modes.Taiko/TaikoRuleset.cs +++ b/osu.Game.Modes.Taiko/TaikoRuleset.cs @@ -15,7 +15,7 @@ namespace osu.Game.Modes.Taiko { public class TaikoRuleset : Ruleset { - public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new TaikoHitRenderer(beatmap); + public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap) => new TaikoHitRenderer(beatmap); public override IEnumerable GetModsFor(ModType type) { diff --git a/osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs b/osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs index dc0276aacc..fb5e38d4dc 100644 --- a/osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs +++ b/osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs @@ -11,7 +11,7 @@ namespace osu.Game.Modes.Taiko.UI { public class TaikoHitRenderer : HitRenderer { - public TaikoHitRenderer(Beatmap beatmap) + public TaikoHitRenderer(WorkingBeatmap beatmap) : base(beatmap) { } diff --git a/osu.Game/Modes/Ruleset.cs b/osu.Game/Modes/Ruleset.cs index 54137b2402..1dcd452541 100644 --- a/osu.Game/Modes/Ruleset.cs +++ b/osu.Game/Modes/Ruleset.cs @@ -31,7 +31,7 @@ namespace osu.Game.Modes public abstract ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0); - public abstract HitRenderer CreateHitRendererWith(Beatmap beatmap); + public abstract HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap); public abstract HitObjectParser CreateHitObjectParser(); diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index e08570522f..27d2cf693f 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -55,9 +55,9 @@ namespace osu.Game.Modes.UI private Container content; - protected HitRenderer(Beatmap beatmap) + protected HitRenderer(WorkingBeatmap beatmap) { - Beatmap = CreateBeatmapConverter().Convert(beatmap); + Beatmap = CreateBeatmapConverter().Convert(beatmap.Beatmap); RelativeSizeAxes = Axes.Both; diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 1a71543786..71ac67601a 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -128,7 +128,7 @@ namespace osu.Game.Screens.Play OnQuit = Exit }; - hitRenderer = ruleset.CreateHitRendererWith(beatmap); + hitRenderer = ruleset.CreateHitRendererWith(Beatmap); if (ReplayInputHandler != null) { From c0e29652a6d8e5f5d40c0b6cb3ddae905ddbd64d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sun, 12 Mar 2017 22:13:43 +0900 Subject: [PATCH 09/26] Initial attempt at making mods apply better. --- .../Tests/TestCaseReplay.cs | 13 ++++--- osu.Game.Modes.Catch/CatchRuleset.cs | 2 + osu.Game.Modes.Catch/{ => Mods}/CatchMod.cs | 4 +- .../osu.Game.Modes.Catch.csproj | 6 ++- osu.Game.Modes.Mania/ManiaRuleset.cs | 2 + osu.Game.Modes.Mania/{ => Mods}/ManiaMod.cs | 5 ++- .../osu.Game.Modes.Mania.csproj | 2 +- osu.Game.Modes.Osu/Mods/IApplyableOsuMod.cs | 13 +++++++ osu.Game.Modes.Osu/{ => Mods}/OsuMod.cs | 22 +++++++++-- osu.Game.Modes.Osu/OsuAutoReplay.cs | 18 ++++----- osu.Game.Modes.Osu/OsuRuleset.cs | 9 +---- osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 3 +- osu.Game.Modes.Taiko/{ => Mods}/TaikoMod.cs | 4 +- osu.Game.Modes.Taiko/TaikoRuleset.cs | 2 + .../osu.Game.Modes.Taiko.csproj | 2 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 7 ++-- osu.Game/Modes/Mods/IApplyableMod.cs | 15 ++++++++ osu.Game/Modes/{ => Mods}/Mod.cs | 38 +++++++++---------- osu.Game/Modes/Mods/ModType.cs | 13 +++++++ osu.Game/Modes/Ruleset.cs | 3 +- osu.Game/Modes/UI/HitRenderer.cs | 30 +++++++++++---- osu.Game/Overlays/Mods/AssistedSection.cs | 2 +- .../Mods/DifficultyIncreaseSection.cs | 2 +- .../Mods/DifficultyReductionSection.cs | 2 +- osu.Game/Overlays/Mods/ModButton.cs | 6 +-- osu.Game/Overlays/Mods/ModSection.cs | 4 +- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 9 +++-- osu.Game/Screens/Play/Player.cs | 9 +---- osu.Game/osu.Game.csproj | 4 +- 29 files changed, 167 insertions(+), 84 deletions(-) rename osu.Game.Modes.Catch/{ => Mods}/CatchMod.cs (91%) rename osu.Game.Modes.Mania/{ => Mods}/ManiaMod.cs (94%) create mode 100644 osu.Game.Modes.Osu/Mods/IApplyableOsuMod.cs rename osu.Game.Modes.Osu/{ => Mods}/OsuMod.cs (83%) rename osu.Game.Modes.Taiko/{ => Mods}/TaikoMod.cs (91%) create mode 100644 osu.Game/Modes/Mods/IApplyableMod.cs rename osu.Game/Modes/{ => Mods}/Mod.cs (87%) create mode 100644 osu.Game/Modes/Mods/ModType.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs index f39da70a16..b5a45f237a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs @@ -1,12 +1,15 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.IO; using osu.Framework.Input.Handlers; using osu.Game.Beatmaps; using osu.Game.Modes; +using osu.Game.Modes.Mods; +using osu.Game.Modes.Osu; +using osu.Game.Modes.Osu.Mods; using osu.Game.Screens.Play; +using System; +using System.IO; namespace osu.Desktop.VisualTests.Tests { @@ -22,9 +25,9 @@ namespace osu.Desktop.VisualTests.Tests protected override Player CreatePlayer(WorkingBeatmap beatmap) { - var player = base.CreatePlayer(beatmap); - player.ReplayInputHandler = Ruleset.GetRuleset(beatmap.PlayMode).CreateAutoplayScore(beatmap.Beatmap)?.Replay?.GetInputHandler(); - return player; + beatmap.Mods.Value = new Mod[] { new OsuModAutoplay() }; + + return base.CreatePlayer(beatmap); } } } diff --git a/osu.Game.Modes.Catch/CatchRuleset.cs b/osu.Game.Modes.Catch/CatchRuleset.cs index 31599bbc44..d989db8ddf 100644 --- a/osu.Game.Modes.Catch/CatchRuleset.cs +++ b/osu.Game.Modes.Catch/CatchRuleset.cs @@ -5,7 +5,9 @@ using OpenTK.Input; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Modes.Catch.Beatmaps; +using osu.Game.Modes.Catch.Mods; using osu.Game.Modes.Catch.UI; +using osu.Game.Modes.Mods; using osu.Game.Modes.Objects; using osu.Game.Modes.UI; using osu.Game.Screens.Play; diff --git a/osu.Game.Modes.Catch/CatchMod.cs b/osu.Game.Modes.Catch/Mods/CatchMod.cs similarity index 91% rename from osu.Game.Modes.Catch/CatchMod.cs rename to osu.Game.Modes.Catch/Mods/CatchMod.cs index 07d6d3469e..97e4e58a5d 100644 --- a/osu.Game.Modes.Catch/CatchMod.cs +++ b/osu.Game.Modes.Catch/Mods/CatchMod.cs @@ -1,7 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Modes.Catch +using osu.Game.Modes.Mods; + +namespace osu.Game.Modes.Catch.Mods { public class CatchModNoFail : ModNoFail { diff --git a/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj b/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj index 10abb312fc..5b815d667c 100644 --- a/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj +++ b/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj @@ -58,7 +58,7 @@ - + @@ -76,6 +76,10 @@ {C92A607B-1FDD-4954-9F92-03FF547D9080} osu.Game.Modes.Osu + + {F167E17A-7DE6-4AF5-B920-A5112296C695} + osu.Game.Modes.Taiko + {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D} osu.Game diff --git a/osu.Game.Modes.Mania/ManiaRuleset.cs b/osu.Game.Modes.Mania/ManiaRuleset.cs index 015df0c961..0d548eacff 100644 --- a/osu.Game.Modes.Mania/ManiaRuleset.cs +++ b/osu.Game.Modes.Mania/ManiaRuleset.cs @@ -4,7 +4,9 @@ using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Modes.Mania.Beatmaps; +using osu.Game.Modes.Mania.Mods; using osu.Game.Modes.Mania.UI; +using osu.Game.Modes.Mods; using osu.Game.Modes.Objects; using osu.Game.Modes.UI; using osu.Game.Screens.Play; diff --git a/osu.Game.Modes.Mania/ManiaMod.cs b/osu.Game.Modes.Mania/Mods/ManiaMod.cs similarity index 94% rename from osu.Game.Modes.Mania/ManiaMod.cs rename to osu.Game.Modes.Mania/Mods/ManiaMod.cs index d52db2977c..b330680550 100644 --- a/osu.Game.Modes.Mania/ManiaMod.cs +++ b/osu.Game.Modes.Mania/Mods/ManiaMod.cs @@ -1,10 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Game.Graphics; +using osu.Game.Modes.Mods; +using System; -namespace osu.Game.Modes.Mania +namespace osu.Game.Modes.Mania.Mods { public class ManiaModNoFail : ModNoFail { diff --git a/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj b/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj index 66e46f9e48..c6db2d257f 100644 --- a/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj +++ b/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj @@ -58,7 +58,7 @@ - + diff --git a/osu.Game.Modes.Osu/Mods/IApplyableOsuMod.cs b/osu.Game.Modes.Osu/Mods/IApplyableOsuMod.cs new file mode 100644 index 0000000000..e30c2eb0a5 --- /dev/null +++ b/osu.Game.Modes.Osu/Mods/IApplyableOsuMod.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Modes.Mods; +using osu.Game.Modes.Osu.Objects; +using osu.Game.Modes.UI; + +namespace osu.Game.Modes.Osu.Mods +{ + internal interface IApplyableOsuMod : IApplyableMod> + { + } +} diff --git a/osu.Game.Modes.Osu/OsuMod.cs b/osu.Game.Modes.Osu/Mods/OsuMod.cs similarity index 83% rename from osu.Game.Modes.Osu/OsuMod.cs rename to osu.Game.Modes.Osu/Mods/OsuMod.cs index 3290eed61a..f7d318a9d4 100644 --- a/osu.Game.Modes.Osu/OsuMod.cs +++ b/osu.Game.Modes.Osu/Mods/OsuMod.cs @@ -1,11 +1,14 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Graphics; +using osu.Game.Modes.Mods; +using osu.Game.Modes.Osu.Objects; +using osu.Game.Modes.UI; using System; using System.Linq; -using osu.Game.Graphics; -namespace osu.Game.Modes.Osu +namespace osu.Game.Modes.Osu.Mods { public class OsuModNoFail : ModNoFail { @@ -85,9 +88,22 @@ namespace osu.Game.Modes.Osu public override Type[] IncompatibleMods => new[] { typeof(OsuModSpunOut), typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail), typeof(ModAutoplay) }; } - public class OsuModAutoplay : ModAutoplay + public class OsuModAutoplay : ModAutoplay, IApplyableOsuMod { public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray(); + + public void Apply(HitRenderer hitRenderer) + { + Attach(hitRenderer, new Score + { + Replay = new OsuAutoReplay(hitRenderer.Beatmap) + }); + } + + public void Revert(HitRenderer hitRenderer) + { + Detach(hitRenderer); + } } public class OsuModTarget : Mod diff --git a/osu.Game.Modes.Osu/OsuAutoReplay.cs b/osu.Game.Modes.Osu/OsuAutoReplay.cs index 953f131797..3de6106030 100644 --- a/osu.Game.Modes.Osu/OsuAutoReplay.cs +++ b/osu.Game.Modes.Osu/OsuAutoReplay.cs @@ -1,14 +1,14 @@ // 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 OpenTK; +using osu.Framework.Graphics.Transforms; +using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Modes.Osu.Objects; -using OpenTK; -using System; -using osu.Framework.Graphics.Transforms; using osu.Game.Modes.Osu.Objects.Drawables; -using osu.Framework.MathUtils; +using System; +using System.Collections.Generic; using System.Diagnostics; namespace osu.Game.Modes.Osu @@ -19,9 +19,9 @@ namespace osu.Game.Modes.Osu private const float spin_radius = 50; - private Beatmap beatmap; + private Beatmap beatmap; - public OsuAutoReplay(Beatmap beatmap) + public OsuAutoReplay(Beatmap beatmap) { this.beatmap = beatmap; @@ -86,7 +86,7 @@ namespace osu.Game.Modes.Osu for (int i = 0; i < beatmap.HitObjects.Count; i++) { - OsuHitObject h = (OsuHitObject)beatmap.HitObjects[i]; + OsuHitObject h = beatmap.HitObjects[i]; //if (h.EndTime < InputManager.ReplayStartTime) //{ @@ -98,7 +98,7 @@ namespace osu.Game.Modes.Osu if (DelayedMovements && i > 0) { - OsuHitObject last = (OsuHitObject)beatmap.HitObjects[i - 1]; + OsuHitObject last = beatmap.HitObjects[i - 1]; //Make the cursor stay at a hitObject as long as possible (mainly for autopilot). if (h.StartTime - h.HitWindowFor(OsuScoreResult.Miss) > last.EndTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50) diff --git a/osu.Game.Modes.Osu/OsuRuleset.cs b/osu.Game.Modes.Osu/OsuRuleset.cs index 1b06d704f1..c9d1fa136c 100644 --- a/osu.Game.Modes.Osu/OsuRuleset.cs +++ b/osu.Game.Modes.Osu/OsuRuleset.cs @@ -4,8 +4,10 @@ using OpenTK.Input; using osu.Game.Beatmaps; using osu.Game.Graphics; +using osu.Game.Modes.Mods; using osu.Game.Modes.Objects; using osu.Game.Modes.Osu.Beatmaps; +using osu.Game.Modes.Osu.Mods; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.UI; using osu.Game.Modes.UI; @@ -101,13 +103,6 @@ namespace osu.Game.Modes.Osu public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new OsuDifficultyCalculator(beatmap); - public override Score CreateAutoplayScore(Beatmap beatmap) - { - var score = CreateScoreProcessor().GetScore(); - score.Replay = new OsuAutoReplay(beatmap); - return score; - } - protected override PlayMode PlayMode => PlayMode.Osu; public override string Description => "osu!"; diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index c214c881d8..341accbdff 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -44,6 +44,7 @@ + @@ -84,7 +85,7 @@ - + diff --git a/osu.Game.Modes.Taiko/TaikoMod.cs b/osu.Game.Modes.Taiko/Mods/TaikoMod.cs similarity index 91% rename from osu.Game.Modes.Taiko/TaikoMod.cs rename to osu.Game.Modes.Taiko/Mods/TaikoMod.cs index 62db875991..c929ebffdd 100644 --- a/osu.Game.Modes.Taiko/TaikoMod.cs +++ b/osu.Game.Modes.Taiko/Mods/TaikoMod.cs @@ -1,7 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Modes.Taiko +using osu.Game.Modes.Mods; + +namespace osu.Game.Modes.Taiko.Mods { public class TaikoModNoFail : ModNoFail { diff --git a/osu.Game.Modes.Taiko/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index e8a8dcdd64..8f67ce9e9e 100644 --- a/osu.Game.Modes.Taiko/TaikoRuleset.cs +++ b/osu.Game.Modes.Taiko/TaikoRuleset.cs @@ -4,8 +4,10 @@ using OpenTK.Input; using osu.Game.Beatmaps; using osu.Game.Graphics; +using osu.Game.Modes.Mods; using osu.Game.Modes.Objects; using osu.Game.Modes.Taiko.Beatmaps; +using osu.Game.Modes.Taiko.Mods; using osu.Game.Modes.Taiko.UI; using osu.Game.Modes.UI; using osu.Game.Screens.Play; diff --git a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj index 0089e84532..5e99d2ba65 100644 --- a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj +++ b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj @@ -56,7 +56,7 @@ - + diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 1d4047ea45..16db4fc2a6 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -1,9 +1,6 @@ // Copyright (c) 2007-2017 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 osu.Framework.Audio.Track; using osu.Framework.Configuration; using osu.Framework.Graphics.Textures; @@ -11,6 +8,10 @@ using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.IO; using osu.Game.Database; using osu.Game.Modes; +using osu.Game.Modes.Mods; +using System; +using System.Collections.Generic; +using System.IO; namespace osu.Game.Beatmaps { diff --git a/osu.Game/Modes/Mods/IApplyableMod.cs b/osu.Game/Modes/Mods/IApplyableMod.cs new file mode 100644 index 0000000000..6e21aa1095 --- /dev/null +++ b/osu.Game/Modes/Mods/IApplyableMod.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + + +using osu.Game.Modes.UI; + +namespace osu.Game.Modes.Mods +{ + public interface IApplyableMod + where TRenderer : HitRenderer + { + void Apply(TRenderer hitRenderer); + void Revert(TRenderer hitRenderer); + } +} diff --git a/osu.Game/Modes/Mod.cs b/osu.Game/Modes/Mods/Mod.cs similarity index 87% rename from osu.Game/Modes/Mod.cs rename to osu.Game/Modes/Mods/Mod.cs index 167421c23d..870b9d3fc1 100644 --- a/osu.Game/Modes/Mod.cs +++ b/osu.Game/Modes/Mods/Mod.cs @@ -1,11 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Game.Graphics; -using osu.Game.Screens.Play; +using osu.Game.Modes.UI; +using System; -namespace osu.Game.Modes +namespace osu.Game.Modes.Mods { /// /// The base class for gameplay modifiers. @@ -41,12 +41,6 @@ namespace osu.Game.Modes /// The mods this mod cannot be enabled with. /// public virtual Type[] IncompatibleMods => new Type[] { }; - - /// - /// Direct access to the Player before load has run. - /// - /// - public virtual void PlayerLoading(Player player) { } } public class MultiMod : Mod @@ -152,10 +146,23 @@ namespace osu.Game.Modes public override double ScoreMultiplier => 0; public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail) }; - public override void PlayerLoading(Player player) + /// + /// Attaches a replay score to a HitRenderer. + /// + /// The HitRenderer to attach the score to. + /// The score to attach. + protected void Attach(HitRenderer hitRenderer, Score score) { - base.PlayerLoading(player); - player.ReplayInputHandler = Ruleset.GetRuleset(player.Beatmap.PlayMode).CreateAutoplayScore(player.Beatmap.Beatmap)?.Replay?.GetInputHandler(); + hitRenderer.InputManager.ReplayInputHandler = score?.Replay?.GetInputHandler(); + } + + /// + /// Detaches the active replay score from a HitRenderer. + /// + /// The HitRenderer to detach the score from. + protected void Detach(HitRenderer hitRenderer) + { + hitRenderer.InputManager.ReplayInputHandler = null; } } @@ -170,11 +177,4 @@ namespace osu.Game.Modes public override string Name => "Cinema"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_cinema; } - - public enum ModType - { - DifficultyReduction, - DifficultyIncrease, - Special, - } } diff --git a/osu.Game/Modes/Mods/ModType.cs b/osu.Game/Modes/Mods/ModType.cs new file mode 100644 index 0000000000..f7d3aea5e2 --- /dev/null +++ b/osu.Game/Modes/Mods/ModType.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + + +namespace osu.Game.Modes.Mods +{ + public enum ModType + { + DifficultyReduction, + DifficultyIncrease, + Special, + } +} diff --git a/osu.Game/Modes/Ruleset.cs b/osu.Game/Modes/Ruleset.cs index 1dcd452541..ab8dda8a2a 100644 --- a/osu.Game/Modes/Ruleset.cs +++ b/osu.Game/Modes/Ruleset.cs @@ -3,6 +3,7 @@ using osu.Game.Beatmaps; using osu.Game.Graphics; +using osu.Game.Modes.Mods; using osu.Game.Modes.Objects; using osu.Game.Modes.UI; using osu.Game.Screens.Play; @@ -49,8 +50,6 @@ namespace osu.Game.Modes public abstract IEnumerable CreateGameplayKeys(); - public virtual Score CreateAutoplayScore(Beatmap beatmap) => null; - public static Ruleset GetRuleset(PlayMode mode) { Type type; diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index 27d2cf693f..6bdcd15872 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -1,11 +1,11 @@ // 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.Game.Beatmaps; +using osu.Game.Modes.Mods; using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; using osu.Game.Screens.Play; @@ -22,11 +22,6 @@ namespace osu.Game.Modes.UI internal readonly PlayerInputManager InputManager = new PlayerInputManager(); - /// - /// A function to convert coordinates from gamefield to screen space. - /// - public abstract Func MapPlayfieldToScreenSpace { get; } - /// /// Whether all the HitObjects have been judged. /// @@ -44,14 +39,14 @@ namespace osu.Game.Modes.UI public abstract class HitRenderer : HitRenderer where TObject : HitObject { - public override Func MapPlayfieldToScreenSpace => Playfield.ScaledContent.ToScreenSpace; + public Beatmap Beatmap; + public IEnumerable DrawableObjects => Playfield.HitObjects.Children; protected override Container Content => content; protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue); protected Playfield Playfield; - protected Beatmap Beatmap; private Container content; @@ -59,6 +54,8 @@ namespace osu.Game.Modes.UI { Beatmap = CreateBeatmapConverter().Convert(beatmap.Beatmap); + applyMods(beatmap.Mods.Value); + RelativeSizeAxes = Axes.Both; InputManager.Add(content = new Container @@ -78,6 +75,9 @@ namespace osu.Game.Modes.UI private void load() { loadObjects(); + + if (InputManager?.ReplayInputHandler != null) + InputManager.ReplayInputHandler.ToScreenSpace = Playfield.ScaledContent.ToScreenSpace; } private void loadObjects() @@ -97,6 +97,20 @@ namespace osu.Game.Modes.UI Playfield.PostProcess(); } + private void applyMods(IEnumerable mods) + { + if (mods == null) + return; + + foreach (var mod in mods) + { + var applyable = mod as IApplyableMod>; + + if (applyable != null) + applyable.Apply(this); + } + } + private void onJudgement(DrawableHitObject o, JudgementInfo j) => TriggerOnJudgement(j); protected abstract DrawableHitObject GetVisualRepresentation(TObject h); diff --git a/osu.Game/Overlays/Mods/AssistedSection.cs b/osu.Game/Overlays/Mods/AssistedSection.cs index 0bb1bc9dff..a1ec7a3fdc 100644 --- a/osu.Game/Overlays/Mods/AssistedSection.cs +++ b/osu.Game/Overlays/Mods/AssistedSection.cs @@ -4,7 +4,7 @@ using OpenTK.Input; using osu.Framework.Allocation; using osu.Game.Graphics; -using osu.Game.Modes; +using osu.Game.Modes.Mods; namespace osu.Game.Overlays.Mods { diff --git a/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs b/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs index 4dfb0ba6c2..13df5aabfb 100644 --- a/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs +++ b/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs @@ -4,7 +4,7 @@ using OpenTK.Input; using osu.Framework.Allocation; using osu.Game.Graphics; -using osu.Game.Modes; +using osu.Game.Modes.Mods; namespace osu.Game.Overlays.Mods { diff --git a/osu.Game/Overlays/Mods/DifficultyReductionSection.cs b/osu.Game/Overlays/Mods/DifficultyReductionSection.cs index d92fb541c3..f8ac4551ef 100644 --- a/osu.Game/Overlays/Mods/DifficultyReductionSection.cs +++ b/osu.Game/Overlays/Mods/DifficultyReductionSection.cs @@ -4,7 +4,7 @@ using OpenTK.Input; using osu.Framework.Allocation; using osu.Game.Graphics; -using osu.Game.Modes; +using osu.Game.Modes.Mods; namespace osu.Game.Overlays.Mods { diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 6e3bafbada..acd5f37092 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -1,8 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Linq; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; @@ -15,8 +13,10 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transforms; using osu.Framework.Input; using osu.Game.Graphics.Sprites; -using osu.Game.Modes; +using osu.Game.Modes.Mods; using osu.Game.Modes.UI; +using System; +using System.Linq; namespace osu.Game.Overlays.Mods { diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index c07114919e..489af21ef4 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; @@ -10,7 +9,8 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Input; using osu.Game.Graphics.Sprites; -using osu.Game.Modes; +using osu.Game.Modes.Mods; +using System; namespace osu.Game.Overlays.Mods { diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 1be1b9a351..3a685be7fa 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -1,11 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Collections.Generic; -using System.Linq; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -13,11 +11,14 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transforms; -using osu.Framework.Allocation; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Sprites; using osu.Game.Modes; +using osu.Game.Modes.Mods; +using System; +using System.Collections.Generic; +using System.Linq; namespace osu.Game.Overlays.Mods { diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 71ac67601a..1a3a5b7036 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -7,7 +7,6 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Track; using osu.Framework.Configuration; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transforms; @@ -69,8 +68,6 @@ namespace osu.Game.Screens.Play return; } - Beatmap.Mods.Value.ForEach(m => m.PlayerLoading(this)); - dimLevel = config.GetBindable(OsuConfig.DimLevel); mouseWheelDisabled = config.GetBindable(OsuConfig.MouseDisableWheel); @@ -131,10 +128,7 @@ namespace osu.Game.Screens.Play hitRenderer = ruleset.CreateHitRendererWith(Beatmap); if (ReplayInputHandler != null) - { - ReplayInputHandler.ToScreenSpace = hitRenderer.MapPlayfieldToScreenSpace; hitRenderer.InputManager.ReplayInputHandler = ReplayInputHandler; - } hudOverlay.BindHitRenderer(hitRenderer); @@ -305,7 +299,8 @@ namespace osu.Game.Screens.Play { if (pauseOverlay == null) return false; - if (ReplayInputHandler != null) return false; + if (hitRenderer.InputManager.ReplayInputHandler != null) + return false; if (pauseOverlay.State != Visibility.Visible && !canPause) return true; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 3d4a763cb8..46cb593d20 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -91,6 +91,8 @@ + + @@ -306,7 +308,7 @@ - + From 7d129ebd6dd969d415b600b05e817f8f75b1696c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sun, 12 Mar 2017 22:38:50 +0900 Subject: [PATCH 10/26] Attempt to fix things. --- .../Tests/TestCaseReplay.cs | 2 -- osu.Game.Modes.Osu/Mods/IApplyableOsuMod.cs | 13 ----------- osu.Game.Modes.Osu/Mods/OsuMod.cs | 2 +- osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 1 - osu.Game/Modes/Mods/IApplyableMod.cs | 22 +++++++++++++++---- osu.Game/Modes/UI/HitRenderer.cs | 5 ++--- 6 files changed, 21 insertions(+), 24 deletions(-) delete mode 100644 osu.Game.Modes.Osu/Mods/IApplyableOsuMod.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs index b5a45f237a..c36fc0a47d 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs @@ -3,9 +3,7 @@ using osu.Framework.Input.Handlers; using osu.Game.Beatmaps; -using osu.Game.Modes; using osu.Game.Modes.Mods; -using osu.Game.Modes.Osu; using osu.Game.Modes.Osu.Mods; using osu.Game.Screens.Play; using System; diff --git a/osu.Game.Modes.Osu/Mods/IApplyableOsuMod.cs b/osu.Game.Modes.Osu/Mods/IApplyableOsuMod.cs deleted file mode 100644 index e30c2eb0a5..0000000000 --- a/osu.Game.Modes.Osu/Mods/IApplyableOsuMod.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 - -using osu.Game.Modes.Mods; -using osu.Game.Modes.Osu.Objects; -using osu.Game.Modes.UI; - -namespace osu.Game.Modes.Osu.Mods -{ - internal interface IApplyableOsuMod : IApplyableMod> - { - } -} diff --git a/osu.Game.Modes.Osu/Mods/OsuMod.cs b/osu.Game.Modes.Osu/Mods/OsuMod.cs index f7d318a9d4..98b87a9bb5 100644 --- a/osu.Game.Modes.Osu/Mods/OsuMod.cs +++ b/osu.Game.Modes.Osu/Mods/OsuMod.cs @@ -88,7 +88,7 @@ namespace osu.Game.Modes.Osu.Mods public override Type[] IncompatibleMods => new[] { typeof(OsuModSpunOut), typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail), typeof(ModAutoplay) }; } - public class OsuModAutoplay : ModAutoplay, IApplyableOsuMod + public class OsuModAutoplay : ModAutoplay, IApplyableMod { public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray(); diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index 341accbdff..017d435983 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -44,7 +44,6 @@ - diff --git a/osu.Game/Modes/Mods/IApplyableMod.cs b/osu.Game/Modes/Mods/IApplyableMod.cs index 6e21aa1095..abbc3ea893 100644 --- a/osu.Game/Modes/Mods/IApplyableMod.cs +++ b/osu.Game/Modes/Mods/IApplyableMod.cs @@ -2,14 +2,28 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Modes.Objects; using osu.Game.Modes.UI; namespace osu.Game.Modes.Mods { - public interface IApplyableMod - where TRenderer : HitRenderer + /// + /// An interface for mods that are applied to a HitRenderer. + /// + /// The type of HitObject the HitRenderer contains. + public interface IApplyableMod + where TObject : HitObject { - void Apply(TRenderer hitRenderer); - void Revert(TRenderer hitRenderer); + /// + /// Applies the mod to a HitRenderer. + /// + /// The HitRenderer to apply the mod to. + void Apply(HitRenderer hitRenderer); + + /// + /// Reverts any changes applied to a HitRenderer through . + /// + /// The HitRenderer to revert from. + void Revert(HitRenderer hitRenderer); } } diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index 6bdcd15872..f124dd24ed 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -104,10 +104,9 @@ namespace osu.Game.Modes.UI foreach (var mod in mods) { - var applyable = mod as IApplyableMod>; + var applyable = mod as IApplyableMod; - if (applyable != null) - applyable.Apply(this); + applyable?.Apply(this); } } From 35ddca78f53e4bcd8c3ff625e74e11e96c771751 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 13 Mar 2017 14:50:55 +0900 Subject: [PATCH 11/26] Remove old, unused hit object converters (will be re-implemented through IBeatmapConverter). --- .../Objects/CatchConverter.cs | 40 ---------------- .../osu.Game.Modes.Catch.csproj | 1 - .../Objects/ManiaConverter.cs | 48 ------------------- .../osu.Game.Modes.Mania.csproj | 1 - .../Objects/TaikoConverter.cs | 39 --------------- .../osu.Game.Modes.Taiko.csproj | 1 - osu.Game/Modes/Objects/HitObjectConverter.cs | 25 ---------- osu.Game/osu.Game.csproj | 1 - 8 files changed, 156 deletions(-) delete mode 100644 osu.Game.Modes.Catch/Objects/CatchConverter.cs delete mode 100644 osu.Game.Modes.Mania/Objects/ManiaConverter.cs delete mode 100644 osu.Game.Modes.Taiko/Objects/TaikoConverter.cs delete mode 100644 osu.Game/Modes/Objects/HitObjectConverter.cs diff --git a/osu.Game.Modes.Catch/Objects/CatchConverter.cs b/osu.Game.Modes.Catch/Objects/CatchConverter.cs deleted file mode 100644 index 31ddc73f61..0000000000 --- a/osu.Game.Modes.Catch/Objects/CatchConverter.cs +++ /dev/null @@ -1,40 +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 osu.Game.Modes.Objects; -using osu.Game.Modes.Osu.Objects; -using osu.Game.Beatmaps; - -namespace osu.Game.Modes.Catch.Objects -{ - internal class CatchConverter : HitObjectConverter - { - public override List Convert(Beatmap beatmap) - { - List output = new List(); - - foreach (HitObject i in beatmap.HitObjects) - { - CatchBaseHit h = i as CatchBaseHit; - - if (h == null) - { - OsuHitObject o = i as OsuHitObject; - - if (o == null) throw new HitObjectConvertException(@"Catch", i); - - h = new Fruit - { - StartTime = o.StartTime, - Position = o.Position.X, - }; - } - - output.Add(h); - } - - return output; - } - } -} diff --git a/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj b/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj index 10abb312fc..4646d0cd6c 100644 --- a/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj +++ b/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj @@ -50,7 +50,6 @@ - diff --git a/osu.Game.Modes.Mania/Objects/ManiaConverter.cs b/osu.Game.Modes.Mania/Objects/ManiaConverter.cs deleted file mode 100644 index 7e1183c0e3..0000000000 --- a/osu.Game.Modes.Mania/Objects/ManiaConverter.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Collections.Generic; -using osu.Game.Modes.Objects; -using osu.Game.Modes.Osu.Objects; -using osu.Game.Beatmaps; - -namespace osu.Game.Modes.Mania.Objects -{ - internal class ManiaConverter : HitObjectConverter - { - private readonly int columns; - - public ManiaConverter(int columns) - { - this.columns = columns; - } - - public override List Convert(Beatmap beatmap) - { - List output = new List(); - - foreach (HitObject i in beatmap.HitObjects) - { - ManiaBaseHit h = i as ManiaBaseHit; - - if (h == null) - { - OsuHitObject o = i as OsuHitObject; - - if (o == null) throw new HitObjectConvertException(@"Mania", i); - - h = new Note - { - StartTime = o.StartTime, - Column = (int)Math.Round(o.Position.X / 512 * columns) - }; - } - - output.Add(h); - } - - return output; - } - } -} diff --git a/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj b/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj index 66e46f9e48..88bf879bcc 100644 --- a/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj +++ b/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj @@ -52,7 +52,6 @@ - diff --git a/osu.Game.Modes.Taiko/Objects/TaikoConverter.cs b/osu.Game.Modes.Taiko/Objects/TaikoConverter.cs deleted file mode 100644 index 3a0e07e390..0000000000 --- a/osu.Game.Modes.Taiko/Objects/TaikoConverter.cs +++ /dev/null @@ -1,39 +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 osu.Game.Modes.Objects; -using osu.Game.Modes.Osu.Objects; -using osu.Game.Beatmaps; - -namespace osu.Game.Modes.Taiko.Objects -{ - internal class TaikoConverter : HitObjectConverter - { - public override List Convert(Beatmap beatmap) - { - List output = new List(); - - foreach (HitObject i in beatmap.HitObjects) - { - TaikoBaseHit h = i as TaikoBaseHit; - - if (h == null) - { - OsuHitObject o = i as OsuHitObject; - - if (o == null) throw new HitObjectConvertException(@"Taiko", i); - - h = new TaikoBaseHit - { - StartTime = o.StartTime, - }; - } - - output.Add(h); - } - - return output; - } - } -} diff --git a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj index 0089e84532..2cc45682ef 100644 --- a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj +++ b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj @@ -51,7 +51,6 @@ - diff --git a/osu.Game/Modes/Objects/HitObjectConverter.cs b/osu.Game/Modes/Objects/HitObjectConverter.cs deleted file mode 100644 index d7c6113af1..0000000000 --- a/osu.Game/Modes/Objects/HitObjectConverter.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Game.Beatmaps; -using System; -using System.Collections.Generic; - -namespace osu.Game.Modes.Objects -{ - public abstract class HitObjectConverter - where T : HitObject - { - public abstract List Convert(Beatmap beatmap); - } - - public class HitObjectConvertException : Exception - { - public HitObject Input { get; } - public HitObjectConvertException(string modeName, HitObject input) - : base($@"Can't convert from {input.GetType().Name} to {modeName} HitObject!") - { - Input = input; - } - } -} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 3d4a763cb8..cc1b6a2832 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -114,7 +114,6 @@ - From caa6e9c82b3d60f1f1ac4c7f560676e427b62816 Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Mon, 13 Mar 2017 11:29:24 +0100 Subject: [PATCH 12/26] General improvements --- osu.Desktop/OsuGameDesktop.cs | 5 +++-- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 3 ++- osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs | 3 ++- osu.Game/Beatmaps/IO/OszArchiveReader.cs | 2 +- osu.Game/Database/BeatmapDatabase.cs | 2 +- osu.Game/{Beatmaps => }/IO/ArchiveReader.cs | 0 osu.Game/osu.Game.csproj | 2 +- 7 files changed, 10 insertions(+), 7 deletions(-) rename osu.Game/{Beatmaps => }/IO/ArchiveReader.cs (100%) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 3b827f2809..a05925654d 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -12,6 +12,7 @@ using System.Drawing; using System.IO; using System.Threading.Tasks; using osu.Game.Screens.Menu; +using osu.Game.Beatmaps.IO; namespace osu.Desktop { @@ -57,7 +58,7 @@ namespace osu.Desktop var dropData = (object[])e.Data.GetData(DataFormats.FileDrop); var filePaths = dropData.Select(f => f.ToString()).ToArray(); - if (filePaths.All(f => Path.GetExtension(f) == @".osz")) + if (filePaths.All(f => Path.GetExtension(f) == BeatmapArchiveReader.OszExtension)) Task.Run(() => BeatmapDatabase.Import(filePaths)); else if (filePaths.All(f => Path.GetExtension(f) == @".osr")) Task.Run(() => @@ -67,7 +68,7 @@ namespace osu.Desktop }); } - private static readonly string[] allowed_extensions = { @".osz", @".osr" }; + private static readonly string[] allowed_extensions = { BeatmapArchiveReader.OszExtension, @".osr" }; private void dragEnter(DragEventArgs e) { diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 69434505ce..5239286b56 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -17,6 +17,7 @@ using osu.Game.Modes.Catch; using osu.Game.Modes.Mania; using osu.Game.Modes.Osu; using osu.Game.Modes.Taiko; +using osu.Game.Beatmaps.IO; namespace osu.Game.Tests.Beatmaps.IO { @@ -106,7 +107,7 @@ namespace osu.Game.Tests.Beatmaps.IO private string prepareTempCopy(string path) { - var temp = Path.GetTempPath()+Guid.NewGuid()+".osz"; + var temp = Path.GetTempPath() + Guid.NewGuid() + BeatmapArchiveReader.OszExtension; return new FileInfo(path).CopyTo(temp, true).FullName; } diff --git a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs index a1a7149f2e..d274d45694 100644 --- a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs @@ -10,6 +10,7 @@ namespace osu.Game.Beatmaps.IO { public abstract class BeatmapArchiveReader : ArchiveReader { + public const string OszExtension = @".osz"; public static BeatmapArchiveReader GetBeatmapArchiveReader(Storage storage, string path) { @@ -19,7 +20,7 @@ namespace osu.Game.Beatmaps.IO } catch (InvalidCastException e) { - Logger.Error(e, "A tricky ArchiveReader instance passed the test to be a BeatmapArhiveReader, but it's really not"); + Logger.Error(e, "A tricky " + $@"{nameof(ArchiveReader)}" + " instance passed the test to be a " + $@"{nameof(BeatmapArchiveReader)}" + ", but it's really not"); throw; } } diff --git a/osu.Game/Beatmaps/IO/OszArchiveReader.cs b/osu.Game/Beatmaps/IO/OszArchiveReader.cs index bf5174f7f9..60d379db61 100644 --- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs @@ -16,7 +16,7 @@ namespace osu.Game.Beatmaps.IO AddReader((storage, path) => { using (var stream = storage.GetStream(path)) - return Path.GetExtension(path) == ".osz" && ZipFile.IsZipFile(stream, false); + return Path.GetExtension(path) == OszExtension && ZipFile.IsZipFile(stream, false); }); OsuLegacyDecoder.Register(); } diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index d50d00c6b3..c7b02acae1 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -186,7 +186,7 @@ namespace osu.Game.Database { hash = input.GetMd5Hash(); input.Seek(0, SeekOrigin.Begin); - path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash+".osz"); + path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash + BeatmapArchiveReader.OszExtension); if (!storage.Exists(path)) using (var output = storage.GetStream(path, FileAccess.Write)) input.CopyTo(output); diff --git a/osu.Game/Beatmaps/IO/ArchiveReader.cs b/osu.Game/IO/ArchiveReader.cs similarity index 100% rename from osu.Game/Beatmaps/IO/ArchiveReader.cs rename to osu.Game/IO/ArchiveReader.cs diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index d81cb2daff..8ae8c3d88e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -327,7 +327,7 @@ - + From c84a9d56f5051aca638bcd57b956d2a470da5b16 Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Mon, 13 Mar 2017 11:36:21 +0100 Subject: [PATCH 13/26] Fix namespace, comply with naming rules --- osu.Desktop/OsuGameDesktop.cs | 4 ++-- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 2 +- osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs | 3 ++- osu.Game/Beatmaps/IO/OszArchiveReader.cs | 2 +- osu.Game/Database/BeatmapDatabase.cs | 2 +- osu.Game/IO/ArchiveReader.cs | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index a05925654d..a09f9860cb 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -58,7 +58,7 @@ namespace osu.Desktop var dropData = (object[])e.Data.GetData(DataFormats.FileDrop); var filePaths = dropData.Select(f => f.ToString()).ToArray(); - if (filePaths.All(f => Path.GetExtension(f) == BeatmapArchiveReader.OszExtension)) + if (filePaths.All(f => Path.GetExtension(f) == BeatmapArchiveReader.OSZ_EXTENSION)) Task.Run(() => BeatmapDatabase.Import(filePaths)); else if (filePaths.All(f => Path.GetExtension(f) == @".osr")) Task.Run(() => @@ -68,7 +68,7 @@ namespace osu.Desktop }); } - private static readonly string[] allowed_extensions = { BeatmapArchiveReader.OszExtension, @".osr" }; + private static readonly string[] allowed_extensions = { BeatmapArchiveReader.OSZ_EXTENSION, @".osr" }; private void dragEnter(DragEventArgs e) { diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 5239286b56..a6ab6a989b 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -107,7 +107,7 @@ namespace osu.Game.Tests.Beatmaps.IO private string prepareTempCopy(string path) { - var temp = Path.GetTempPath() + Guid.NewGuid() + BeatmapArchiveReader.OszExtension; + var temp = Path.GetTempPath() + Guid.NewGuid() + BeatmapArchiveReader.OSZ_EXTENSION; return new FileInfo(path).CopyTo(temp, true).FullName; } diff --git a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs index d274d45694..0fab05df49 100644 --- a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs @@ -5,12 +5,13 @@ using System; using osu.Framework.Logging; using osu.Framework.Platform; using osu.Game.Database; +using osu.Game.IO; namespace osu.Game.Beatmaps.IO { public abstract class BeatmapArchiveReader : ArchiveReader { - public const string OszExtension = @".osz"; + public const string OSZ_EXTENSION = @".osz"; public static BeatmapArchiveReader GetBeatmapArchiveReader(Storage storage, string path) { diff --git a/osu.Game/Beatmaps/IO/OszArchiveReader.cs b/osu.Game/Beatmaps/IO/OszArchiveReader.cs index 60d379db61..8c3e4d702c 100644 --- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs @@ -16,7 +16,7 @@ namespace osu.Game.Beatmaps.IO AddReader((storage, path) => { using (var stream = storage.GetStream(path)) - return Path.GetExtension(path) == OszExtension && ZipFile.IsZipFile(stream, false); + return Path.GetExtension(path) == OSZ_EXTENSION && ZipFile.IsZipFile(stream, false); }); OsuLegacyDecoder.Register(); } diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index c7b02acae1..a9fe30a5e9 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -186,7 +186,7 @@ namespace osu.Game.Database { hash = input.GetMd5Hash(); input.Seek(0, SeekOrigin.Begin); - path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash + BeatmapArchiveReader.OszExtension); + path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash + BeatmapArchiveReader.OSZ_EXTENSION); if (!storage.Exists(path)) using (var output = storage.GetStream(path, FileAccess.Write)) input.CopyTo(output); diff --git a/osu.Game/IO/ArchiveReader.cs b/osu.Game/IO/ArchiveReader.cs index ba84402782..8eaecdeabc 100644 --- a/osu.Game/IO/ArchiveReader.cs +++ b/osu.Game/IO/ArchiveReader.cs @@ -7,7 +7,7 @@ using System.IO; using osu.Framework.IO.Stores; using osu.Framework.Platform; -namespace osu.Game.Beatmaps.IO +namespace osu.Game.IO { public abstract class ArchiveReader : IDisposable, IResourceStore { From 842f9384390ebdb47dbae95d748348bfb7fec1ac Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 13 Mar 2017 21:05:09 +0900 Subject: [PATCH 14/26] General fixes. --- .../osu.Game.Modes.Catch.csproj | 4 ---- .../Beatmaps/ManiaBeatmapConverter.cs | 1 - osu.Game.Modes.Osu/Mods/OsuMod.cs | 18 ++++---------- osu.Game/Modes/Mods/IApplyableMod.cs | 6 ----- osu.Game/Modes/Mods/Mod.cs | 24 +++++++------------ osu.Game/Modes/Mods/ModType.cs | 1 - 6 files changed, 14 insertions(+), 40 deletions(-) diff --git a/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj b/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj index 5b815d667c..a8595babe8 100644 --- a/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj +++ b/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj @@ -76,10 +76,6 @@ {C92A607B-1FDD-4954-9F92-03FF547D9080} osu.Game.Modes.Osu - - {F167E17A-7DE6-4AF5-B920-A5112296C695} - osu.Game.Modes.Taiko - {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D} osu.Game diff --git a/osu.Game.Modes.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Modes.Mania/Beatmaps/ManiaBeatmapConverter.cs index 0f42da4ac8..3ff210c1cc 100644 --- a/osu.Game.Modes.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Modes.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - using osu.Game.Beatmaps; using osu.Game.Modes.Mania.Objects; using System.Collections.Generic; diff --git a/osu.Game.Modes.Osu/Mods/OsuMod.cs b/osu.Game.Modes.Osu/Mods/OsuMod.cs index 98b87a9bb5..e80975aed1 100644 --- a/osu.Game.Modes.Osu/Mods/OsuMod.cs +++ b/osu.Game.Modes.Osu/Mods/OsuMod.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 osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Modes.Mods; using osu.Game.Modes.Osu.Objects; -using osu.Game.Modes.UI; using System; using System.Linq; @@ -88,22 +88,14 @@ namespace osu.Game.Modes.Osu.Mods public override Type[] IncompatibleMods => new[] { typeof(OsuModSpunOut), typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail), typeof(ModAutoplay) }; } - public class OsuModAutoplay : ModAutoplay, IApplyableMod + public class OsuModAutoplay : ModAutoplay { public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray(); - public void Apply(HitRenderer hitRenderer) + protected override Score CreateReplayScore(Beatmap beatmap) => new Score { - Attach(hitRenderer, new Score - { - Replay = new OsuAutoReplay(hitRenderer.Beatmap) - }); - } - - public void Revert(HitRenderer hitRenderer) - { - Detach(hitRenderer); - } + Replay = new OsuAutoReplay(beatmap) + }; } public class OsuModTarget : Mod diff --git a/osu.Game/Modes/Mods/IApplyableMod.cs b/osu.Game/Modes/Mods/IApplyableMod.cs index abbc3ea893..5db952a4db 100644 --- a/osu.Game/Modes/Mods/IApplyableMod.cs +++ b/osu.Game/Modes/Mods/IApplyableMod.cs @@ -19,11 +19,5 @@ namespace osu.Game.Modes.Mods /// /// The HitRenderer to apply the mod to. void Apply(HitRenderer hitRenderer); - - /// - /// Reverts any changes applied to a HitRenderer through . - /// - /// The HitRenderer to revert from. - void Revert(HitRenderer hitRenderer); } } diff --git a/osu.Game/Modes/Mods/Mod.cs b/osu.Game/Modes/Mods/Mod.cs index 870b9d3fc1..40940e9690 100644 --- a/osu.Game/Modes/Mods/Mod.cs +++ b/osu.Game/Modes/Mods/Mod.cs @@ -1,7 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Beatmaps; using osu.Game.Graphics; +using osu.Game.Modes.Objects; using osu.Game.Modes.UI; using System; @@ -145,24 +147,16 @@ namespace osu.Game.Modes.Mods public override string Description => "Watch a perfect automated play through the song"; public override double ScoreMultiplier => 0; public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail) }; + } - /// - /// Attaches a replay score to a HitRenderer. - /// - /// The HitRenderer to attach the score to. - /// The score to attach. - protected void Attach(HitRenderer hitRenderer, Score score) - { - hitRenderer.InputManager.ReplayInputHandler = score?.Replay?.GetInputHandler(); - } + public abstract class ModAutoplay : ModAutoplay, IApplyableMod + where T : HitObject + { + protected abstract Score CreateReplayScore(Beatmap beatmap); - /// - /// Detaches the active replay score from a HitRenderer. - /// - /// The HitRenderer to detach the score from. - protected void Detach(HitRenderer hitRenderer) + public void Apply(HitRenderer hitRenderer) { - hitRenderer.InputManager.ReplayInputHandler = null; + hitRenderer.InputManager.ReplayInputHandler = CreateReplayScore(hitRenderer.Beatmap)?.Replay?.GetInputHandler(); } } diff --git a/osu.Game/Modes/Mods/ModType.cs b/osu.Game/Modes/Mods/ModType.cs index f7d3aea5e2..b1d0e781e1 100644 --- a/osu.Game/Modes/Mods/ModType.cs +++ b/osu.Game/Modes/Mods/ModType.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - namespace osu.Game.Modes.Mods { public enum ModType From 980807d91e3f6843d254ad2860cdec43cfb595ba Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 Mar 2017 22:33:31 +0900 Subject: [PATCH 15/26] Fix post-merge issues. --- osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs index 767fb0dffb..83dbe6898f 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs @@ -103,7 +103,7 @@ namespace osu.Desktop.VisualTests.Tests Beatmap = beatmap; } - protected override ArchiveReader GetReader() => null; + protected override BeatmapArchiveReader GetReader() => null; } } } From db104d04d3e38544517116310f38e4ec7ae19ce3 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 03:15:53 +0800 Subject: [PATCH 16/26] Use AutoGenerateBindingRedirects instead of explicit app.config. --- osu.Desktop.Deploy/App.config | 12 ----------- osu.Desktop.Tests/app.config | 16 --------------- osu.Desktop.Tests/osu.Desktop.Tests.csproj | 1 - osu.Desktop.VisualTests/app.config | 16 --------------- .../osu.Desktop.VisualTests.csproj | 2 +- osu.Desktop/app.config | 20 ------------------- osu.Desktop/osu.Desktop.csproj | 2 +- osu.Game.Modes.Mania/app.config | 16 --------------- .../osu.Game.Modes.Mania.csproj | 1 - osu.Game.Modes.Osu/app.config | 16 --------------- osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 1 - osu.Game.Tests/app.config | 16 --------------- osu.Game.Tests/osu.Game.Tests.csproj | 1 - osu.Game/app.config | 16 --------------- osu.Game/osu.Game.csproj | 1 - 15 files changed, 2 insertions(+), 135 deletions(-) delete mode 100644 osu.Desktop.Tests/app.config delete mode 100644 osu.Desktop.VisualTests/app.config delete mode 100644 osu.Desktop/app.config delete mode 100644 osu.Game.Modes.Mania/app.config delete mode 100644 osu.Game.Modes.Osu/app.config delete mode 100644 osu.Game.Tests/app.config delete mode 100644 osu.Game/app.config diff --git a/osu.Desktop.Deploy/App.config b/osu.Desktop.Deploy/App.config index bd464a0453..d1da144f50 100644 --- a/osu.Desktop.Deploy/App.config +++ b/osu.Desktop.Deploy/App.config @@ -21,16 +21,4 @@ Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/maste - - - - - - - - - - - - \ No newline at end of file diff --git a/osu.Desktop.Tests/app.config b/osu.Desktop.Tests/app.config deleted file mode 100644 index 855da39b10..0000000000 --- a/osu.Desktop.Tests/app.config +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/osu.Desktop.Tests/osu.Desktop.Tests.csproj b/osu.Desktop.Tests/osu.Desktop.Tests.csproj index 07495311e0..e89308bbb9 100644 --- a/osu.Desktop.Tests/osu.Desktop.Tests.csproj +++ b/osu.Desktop.Tests/osu.Desktop.Tests.csproj @@ -100,7 +100,6 @@ osu.licenseheader - diff --git a/osu.Desktop.VisualTests/app.config b/osu.Desktop.VisualTests/app.config deleted file mode 100644 index 855da39b10..0000000000 --- a/osu.Desktop.VisualTests/app.config +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index bea56b5cd0..81ee7185bb 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -23,6 +23,7 @@ false LocalIntranet v4.5 + true publish\ true Disk @@ -114,7 +115,6 @@ osu.licenseheader - diff --git a/osu.Desktop/app.config b/osu.Desktop/app.config deleted file mode 100644 index 1ff0a7f133..0000000000 --- a/osu.Desktop/app.config +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 7e85f09d8c..48e0db1d99 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -23,6 +23,7 @@ false LocalIntranet v4.5 + true publish\ true Disk @@ -153,7 +154,6 @@ osu.licenseheader - diff --git a/osu.Game.Modes.Mania/app.config b/osu.Game.Modes.Mania/app.config deleted file mode 100644 index 855da39b10..0000000000 --- a/osu.Game.Modes.Mania/app.config +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj b/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj index 88bf879bcc..2e281f54bb 100644 --- a/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj +++ b/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj @@ -81,7 +81,6 @@ osu.licenseheader - diff --git a/osu.Game.Modes.Osu/app.config b/osu.Game.Modes.Osu/app.config deleted file mode 100644 index 88af66254d..0000000000 --- a/osu.Game.Modes.Osu/app.config +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index c214c881d8..47f94b1026 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -100,7 +100,6 @@ osu.licenseheader - diff --git a/osu.Game.Tests/app.config b/osu.Game.Tests/app.config deleted file mode 100644 index 855da39b10..0000000000 --- a/osu.Game.Tests/app.config +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/osu.Game.Tests/osu.Game.Tests.csproj b/osu.Game.Tests/osu.Game.Tests.csproj index 96682dd1ce..d01aa77e02 100644 --- a/osu.Game.Tests/osu.Game.Tests.csproj +++ b/osu.Game.Tests/osu.Game.Tests.csproj @@ -52,7 +52,6 @@ osu.licenseheader - diff --git a/osu.Game/app.config b/osu.Game/app.config deleted file mode 100644 index 855da39b10..0000000000 --- a/osu.Game/app.config +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 74f98bbc0e..6c060328a4 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -342,7 +342,6 @@ osu.licenseheader - From 14a22f032f55f6d9efaa06187b7a36f6c8105c5a Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 04:35:43 +0800 Subject: [PATCH 17/26] Fix beatmap panel removal. --- osu.Game/Screens/Select/CarouselContainer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index e7fba05036..6a5bb2dc94 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -57,6 +57,7 @@ namespace osu.Game.Screens.Select public void RemoveGroup(BeatmapGroup group) { groups.Remove(group); + panels.Remove(group.Header); foreach (var p in group.BeatmapPanels) panels.Remove(p); From 3913a0a9ee688551e9a5d7154d6e0948c178988c Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 04:59:44 +0800 Subject: [PATCH 18/26] Fix removal of the last one beatmap. --- osu.Game/Overlays/MusicController.cs | 20 +++++++++++++------- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 12 +++++++++--- osu.Game/Screens/Select/PlaySongSelect.cs | 7 +++---- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 1b4692f50e..5c9adb6b20 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -210,7 +210,7 @@ namespace osu.Game.Overlays } } }; - + this.beatmaps = beatmaps; trackManager = osuGame.Audio.Track; preferUnicode = config.GetBindable(OsuConfig.ShowUnicode); @@ -247,6 +247,8 @@ namespace osu.Game.Overlays if (current.Track.HasCompleted && !current.Track.Looping) next(); } + else + playButton.Icon = FontAwesome.fa_play_circle_o; } private void preferUnicode_changed(object sender, EventArgs e) @@ -337,12 +339,16 @@ namespace osu.Game.Overlays Task.Run(() => { if (beatmap?.Beatmap == null) - //todo: we may need to display some default text here (currently in the constructor). - return; - - BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; - title.Text = unicodeString(metadata.Title, metadata.TitleUnicode); - artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode); + { + title.Text = @"Nothing to play"; + artist.Text = @"Nothing to play"; + } + else + { + BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; + title.Text = unicodeString(metadata.Title, metadata.TitleUnicode); + artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode); + } }); MusicControllerBackground newBackground; diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index bc3b16079c..eac12f7370 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -16,7 +16,6 @@ using osu.Game.Database; using osu.Framework.Graphics.Colour; using osu.Game.Beatmaps.Drawables; using System.Linq; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.MathUtils; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; @@ -56,8 +55,15 @@ namespace osu.Game.Screens.Select public void UpdateBeatmap(WorkingBeatmap beatmap) { if (beatmap?.BeatmapInfo == null) + { + FadeOut(250); + beatmapInfoContainer?.FadeOut(250); + beatmapInfoContainer?.Expire(); + beatmapInfoContainer = null; return; + } + FadeIn(250); var lastContainer = beatmapInfoContainer; float newDepth = lastContainer?.Depth + 1 ?? 0; @@ -84,7 +90,7 @@ namespace osu.Game.Screens.Select })); //get statistics fromt he current ruleset. - Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).GetBeatmapStatistics(beatmap).ForEach(s => labels.Add(new InfoLabel(s))); + labels.AddRange(Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s))); } (beatmapInfoContainer = new BufferedContainer @@ -191,7 +197,7 @@ namespace osu.Game.Screens.Select private string getBPMRange(Beatmap beatmap) { - double bpmMax = beatmap.BPMMaximum; + double bpmMax = beatmap.BPMMaximum; double bpmMin = beatmap.BPMMinimum; if (Precision.AlmostEquals(bpmMin, bpmMax)) return Math.Round(bpmMin) + "bpm"; diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 86f9bc30cf..09ba794122 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -326,8 +326,7 @@ namespace osu.Game.Screens.Select backgroundModeBeatmap.FadeTo(1, 250); } - if (beatmap != null) - beatmapInfoWedge.UpdateBeatmap(beatmap); + beatmapInfoWedge.UpdateBeatmap(beatmap); } /// @@ -337,11 +336,11 @@ namespace osu.Game.Screens.Select { base.OnBeatmapChanged(beatmap); - beatmap.Mods.BindTo(modSelect.SelectedMods); + beatmap?.Mods.BindTo(modSelect.SelectedMods); //todo: change background in selectionChanged instead; support per-difficulty backgrounds. changeBackground(beatmap); - carousel.SelectBeatmap(beatmap.BeatmapInfo); + carousel.SelectBeatmap(beatmap?.BeatmapInfo); } /// From e1bd168c1609c2289551c7b2c38a47abf6c99af5 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 07:22:46 +0800 Subject: [PATCH 19/26] Remaining GameMode -> Screen. --- osu.Desktop/OsuGameDesktop.cs | 4 ++-- osu.Game/OsuGame.cs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index a09f9860cb..478919272e 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -31,9 +31,9 @@ namespace osu.Desktop base.LoadComplete(); versionManager.LoadAsync(this); - ModeChanged += m => + ScreenChanged += s => { - if (!versionManager.IsAlive && m is Intro) + if (!versionManager.IsAlive && s is Intro) Add(versionManager); }; } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 79ffcfcadf..8aa3a63d26 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -258,13 +258,13 @@ namespace osu.Game return false; } - public event Action ModeChanged; + public event Action ScreenChanged; private Container mainContent; private Container overlayContent; - private void modeChanged(Screen newScreen) + private void screenChanged(Screen newScreen) { //central game mode change logic. if ((newScreen as OsuScreen)?.ShowOverlays != true) @@ -281,7 +281,7 @@ namespace osu.Game if (newScreen is MainMenu) Cursor.FadeIn(100); - ModeChanged?.Invoke(newScreen); + ScreenChanged?.Invoke(newScreen); if (newScreen == null) Exit(); @@ -315,12 +315,12 @@ namespace osu.Game newScreen.ModePushed += screenAdded; newScreen.Exited += screenRemoved; - modeChanged(newScreen); + screenChanged(newScreen); } private void screenRemoved(Screen newScreen) { - modeChanged(newScreen); + screenChanged(newScreen); } } } From ba10c3a8db89f6325b717cf2ea06192aefac6e65 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 Mar 2017 11:46:34 +0900 Subject: [PATCH 20/26] Revert "Merge pull request #441 from tacchinotacchi/archive-reader" This reverts commit 6f20473e65960e059727dee5dc075fc356d07c1b, reversing changes made to c76a495d3d4269931ec5f2bd830ba619747e5b3e. --- .../Tests/TestCasePlayer.cs | 2 +- .../Beatmaps/IO/LegacyFilesystemReader.cs | 2 +- osu.Desktop/OsuGameDesktop.cs | 5 +-- .../Beatmaps/IO/ImportBeatmapTest.cs | 3 +- osu.Game/{ => Beatmaps}/IO/ArchiveReader.cs | 26 ++++++++--- osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs | 44 ------------------- osu.Game/Beatmaps/IO/OszArchiveReader.cs | 4 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 4 +- osu.Game/Database/BeatmapDatabase.cs | 12 ++--- osu.Game/osu.Game.csproj | 3 +- 10 files changed, 37 insertions(+), 68 deletions(-) rename osu.Game/{ => Beatmaps}/IO/ArchiveReader.cs (65%) delete mode 100644 osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index 0b876ed171..ee58d934a4 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -110,7 +110,7 @@ namespace osu.Desktop.VisualTests.Tests Beatmap = beatmap; } - protected override BeatmapArchiveReader GetReader() => null; + protected override ArchiveReader GetReader() => null; } } } diff --git a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs index 19aa9ca4a6..0ef448cafe 100644 --- a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs +++ b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs @@ -13,7 +13,7 @@ namespace osu.Desktop.Beatmaps.IO /// /// Reads an extracted legacy beatmap from disk. /// - public class LegacyFilesystemReader : BeatmapArchiveReader + public class LegacyFilesystemReader : ArchiveReader { public static void Register() => AddReader((storage, path) => Directory.Exists(path)); diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 478919272e..27f58c27e1 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -12,7 +12,6 @@ using System.Drawing; using System.IO; using System.Threading.Tasks; using osu.Game.Screens.Menu; -using osu.Game.Beatmaps.IO; namespace osu.Desktop { @@ -58,7 +57,7 @@ namespace osu.Desktop var dropData = (object[])e.Data.GetData(DataFormats.FileDrop); var filePaths = dropData.Select(f => f.ToString()).ToArray(); - if (filePaths.All(f => Path.GetExtension(f) == BeatmapArchiveReader.OSZ_EXTENSION)) + if (filePaths.All(f => Path.GetExtension(f) == @".osz")) Task.Run(() => BeatmapDatabase.Import(filePaths)); else if (filePaths.All(f => Path.GetExtension(f) == @".osr")) Task.Run(() => @@ -68,7 +67,7 @@ namespace osu.Desktop }); } - private static readonly string[] allowed_extensions = { BeatmapArchiveReader.OSZ_EXTENSION, @".osr" }; + private static readonly string[] allowed_extensions = { @".osz", @".osr" }; private void dragEnter(DragEventArgs e) { diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index a6ab6a989b..ae936f3f49 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -17,7 +17,6 @@ using osu.Game.Modes.Catch; using osu.Game.Modes.Mania; using osu.Game.Modes.Osu; using osu.Game.Modes.Taiko; -using osu.Game.Beatmaps.IO; namespace osu.Game.Tests.Beatmaps.IO { @@ -107,7 +106,7 @@ namespace osu.Game.Tests.Beatmaps.IO private string prepareTempCopy(string path) { - var temp = Path.GetTempPath() + Guid.NewGuid() + BeatmapArchiveReader.OSZ_EXTENSION; + var temp = Path.GetTempFileName(); return new FileInfo(path).CopyTo(temp, true).FullName; } diff --git a/osu.Game/IO/ArchiveReader.cs b/osu.Game/Beatmaps/IO/ArchiveReader.cs similarity index 65% rename from osu.Game/IO/ArchiveReader.cs rename to osu.Game/Beatmaps/IO/ArchiveReader.cs index 8eaecdeabc..bbf4de20f5 100644 --- a/osu.Game/IO/ArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/ArchiveReader.cs @@ -6,22 +6,23 @@ using System.Collections.Generic; using System.IO; using osu.Framework.IO.Stores; using osu.Framework.Platform; +using osu.Game.Database; -namespace osu.Game.IO +namespace osu.Game.Beatmaps.IO { public abstract class ArchiveReader : IDisposable, IResourceStore { - protected class Reader + private class Reader { public Func Test { get; set; } public Type Type { get; set; } } - protected static List Readers { get; } = new List(); + private static List readers { get; } = new List(); public static ArchiveReader GetReader(Storage storage, string path) { - foreach (var reader in Readers) + foreach (var reader in readers) { if (reader.Test(storage, path)) return (ArchiveReader)Activator.CreateInstance(reader.Type, storage.GetStream(path)); @@ -31,9 +32,24 @@ namespace osu.Game.IO protected static void AddReader(Func test) where T : ArchiveReader { - Readers.Add(new Reader { Test = test, Type = typeof(T) }); + 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 string[] BeatmapFilenames { get; protected set; } + + /// + /// The storyboard filename. Null if no storyboard is present. + /// + public string StoryboardFilename { get; protected set; } + /// /// Opens a stream for reading a specific file from this archive. /// diff --git a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs deleted file mode 100644 index 0fab05df49..0000000000 --- a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using osu.Framework.Logging; -using osu.Framework.Platform; -using osu.Game.Database; -using osu.Game.IO; - -namespace osu.Game.Beatmaps.IO -{ - public abstract class BeatmapArchiveReader : ArchiveReader - { - public const string OSZ_EXTENSION = @".osz"; - - public static BeatmapArchiveReader GetBeatmapArchiveReader(Storage storage, string path) - { - try - { - return (BeatmapArchiveReader)GetReader(storage, path); - } - catch (InvalidCastException e) - { - Logger.Error(e, "A tricky " + $@"{nameof(ArchiveReader)}" + " instance passed the test to be a " + $@"{nameof(BeatmapArchiveReader)}" + ", but it's really not"); - throw; - } - } - - /// - /// Reads the beatmap metadata from this archive. - /// - public abstract BeatmapMetadata ReadMetadata(); - - /// - /// Gets a list of beatmap file names. - /// - public string[] BeatmapFilenames { get; protected set; } - - /// - /// The storyboard filename. Null if no storyboard is present. - /// - public string StoryboardFilename { get; protected set; } - } -} \ No newline at end of file diff --git a/osu.Game/Beatmaps/IO/OszArchiveReader.cs b/osu.Game/Beatmaps/IO/OszArchiveReader.cs index 8c3e4d702c..8a1d071cfc 100644 --- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs @@ -9,14 +9,14 @@ using osu.Game.Database; namespace osu.Game.Beatmaps.IO { - public sealed class OszArchiveReader : BeatmapArchiveReader + public sealed class OszArchiveReader : ArchiveReader { public static void Register() { AddReader((storage, path) => { using (var stream = storage.GetStream(path)) - return Path.GetExtension(path) == OSZ_EXTENSION && ZipFile.IsZipFile(stream, false); + return ZipFile.IsZipFile(stream, false); }); OsuLegacyDecoder.Register(); } diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 545fc9f398..1d4047ea45 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -32,7 +32,7 @@ namespace osu.Game.Beatmaps public readonly bool WithStoryboard; - protected abstract BeatmapArchiveReader GetReader(); + protected abstract ArchiveReader GetReader(); protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false) { @@ -100,7 +100,7 @@ namespace osu.Game.Beatmaps set { lock (beatmapLock) beatmap = value; } } - private BeatmapArchiveReader trackReader; + private ArchiveReader trackReader; private Track track; private object trackLock = new object(); public Track Track diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index a9fe30a5e9..871251b882 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -177,7 +177,7 @@ namespace osu.Game.Database BeatmapMetadata metadata; - using (var reader = BeatmapArchiveReader.GetBeatmapArchiveReader(storage, path)) + using (var reader = ArchiveReader.GetReader(storage, path)) metadata = reader.ReadMetadata(); if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader @@ -186,7 +186,7 @@ namespace osu.Game.Database { hash = input.GetMd5Hash(); input.Seek(0, SeekOrigin.Begin); - path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash + BeatmapArchiveReader.OSZ_EXTENSION); + path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash); if (!storage.Exists(path)) using (var output = storage.GetStream(path, FileAccess.Write)) input.CopyTo(output); @@ -216,7 +216,7 @@ namespace osu.Game.Database Metadata = metadata }; - using (var archive = BeatmapArchiveReader.GetBeatmapArchiveReader(storage, path)) + using (var archive = ArchiveReader.GetReader(storage, path)) { string[] mapNames = archive.BeatmapFilenames; foreach (var name in mapNames) @@ -268,12 +268,12 @@ namespace osu.Game.Database BeatmapSetRemoved?.Invoke(beatmapSet); } - public BeatmapArchiveReader GetReader(BeatmapSetInfo beatmapSet) + public ArchiveReader GetReader(BeatmapSetInfo beatmapSet) { if (string.IsNullOrEmpty(beatmapSet.Path)) return null; - return BeatmapArchiveReader.GetBeatmapArchiveReader(storage, beatmapSet.Path); + return ArchiveReader.GetReader(storage, beatmapSet.Path); } public BeatmapSetInfo GetBeatmapSet(int id) @@ -354,7 +354,7 @@ namespace osu.Game.Database this.database = database; } - protected override BeatmapArchiveReader GetReader() => database?.GetReader(BeatmapSetInfo); + protected override ArchiveReader GetReader() => database?.GetReader(BeatmapSetInfo); } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 6c060328a4..4a8f41b1ac 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -238,7 +238,7 @@ - + @@ -326,7 +326,6 @@ - From 4fa037c0b227ca914a4519480282daab36eac371 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 Mar 2017 19:11:57 +0900 Subject: [PATCH 21/26] Update framework. --- osu-framework | 2 +- osu.Game/Modes/LegacyReplay.cs | 26 ++++++++------------- osu.Game/Screens/Play/PlayerInputManager.cs | 8 +++---- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/osu-framework b/osu-framework index a50dd75b11..e52af1e5ad 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit a50dd75b114da963c75e6a5314099d99140035b8 +Subproject commit e52af1e5ada07468512e19c86b6dcd5a23fe3707 diff --git a/osu.Game/Modes/LegacyReplay.cs b/osu.Game/Modes/LegacyReplay.cs index 9ab6c587a9..4b77550cbc 100644 --- a/osu.Game/Modes/LegacyReplay.cs +++ b/osu.Game/Modes/LegacyReplay.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IO; +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Input; using osu.Framework.MathUtils; using osu.Game.Input.Handlers; @@ -95,24 +96,17 @@ namespace osu.Game.Modes public override List GetPendingStates() { + var buttons = new HashSet(); + if (CurrentFrame?.MouseLeft ?? false) + buttons.Add(MouseButton.Left); + if (CurrentFrame?.MouseRight ?? false) + buttons.Add(MouseButton.Right); + return new List { new InputState { - Mouse = new ReplayMouseState( - ToScreenSpace(position ?? Vector2.Zero), - new List - { - new MouseState.ButtonState(MouseButton.Left) - { - State = CurrentFrame?.MouseLeft ?? false - }, - new MouseState.ButtonState(MouseButton.Right) - { - State = CurrentFrame?.MouseRight ?? false - }, - } - ), + Mouse = new ReplayMouseState(ToScreenSpace(position ?? Vector2.Zero), buttons), Keyboard = new ReplayKeyboardState(new List()) } }; @@ -171,10 +165,10 @@ namespace osu.Game.Modes private class ReplayMouseState : MouseState { - public ReplayMouseState(Vector2 position, List list) + public ReplayMouseState(Vector2 position, IEnumerable list) { Position = position; - ButtonStates = list; + list.ForEach(b => PressedButtons.Add(b)); } } diff --git a/osu.Game/Screens/Play/PlayerInputManager.cs b/osu.Game/Screens/Play/PlayerInputManager.cs index a16c1ba9c6..3eab30c50d 100644 --- a/osu.Game/Screens/Play/PlayerInputManager.cs +++ b/osu.Game/Screens/Play/PlayerInputManager.cs @@ -70,14 +70,14 @@ namespace osu.Game.Screens.Play { if (mouseDisabled.Value) { - mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = false; - mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = false; + mouse.PressedButtons.Remove(MouseButton.Left); + mouse.PressedButtons.Remove(MouseButton.Right); } if (leftViaKeyboard) - mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true; + mouse.PressedButtons.Add(MouseButton.Left); if (rightViaKeyboard) - mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true; + mouse.PressedButtons.Add(MouseButton.Right); } } From 9eaec6945f5f057fbf3d57d8c77646c9faf1e58c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 Mar 2017 12:02:06 +0900 Subject: [PATCH 22/26] Update resources. --- osu-resources | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-resources b/osu-resources index 39657fc606..4f9ed4e703 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit 39657fc6066ea3a141ac71cabf67ec9ebf24975c +Subproject commit 4f9ed4e703777ede98737c7e2af31efa4694c395 From bc5912eab5374f37f28fcda45a93c4acb8933207 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 14 Mar 2017 12:32:31 +0900 Subject: [PATCH 23/26] Applyable -> Applicable. --- osu.Game/Modes/Mods/{IApplyableMod.cs => IApplicableMod.cs} | 2 +- osu.Game/Modes/Mods/Mod.cs | 2 +- osu.Game/Modes/UI/HitRenderer.cs | 2 +- osu.Game/osu.Game.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename osu.Game/Modes/Mods/{IApplyableMod.cs => IApplicableMod.cs} (91%) diff --git a/osu.Game/Modes/Mods/IApplyableMod.cs b/osu.Game/Modes/Mods/IApplicableMod.cs similarity index 91% rename from osu.Game/Modes/Mods/IApplyableMod.cs rename to osu.Game/Modes/Mods/IApplicableMod.cs index 5db952a4db..25d0f8d701 100644 --- a/osu.Game/Modes/Mods/IApplyableMod.cs +++ b/osu.Game/Modes/Mods/IApplicableMod.cs @@ -11,7 +11,7 @@ namespace osu.Game.Modes.Mods /// An interface for mods that are applied to a HitRenderer. /// /// The type of HitObject the HitRenderer contains. - public interface IApplyableMod + public interface IApplicableMod where TObject : HitObject { /// diff --git a/osu.Game/Modes/Mods/Mod.cs b/osu.Game/Modes/Mods/Mod.cs index 40940e9690..6a720a3574 100644 --- a/osu.Game/Modes/Mods/Mod.cs +++ b/osu.Game/Modes/Mods/Mod.cs @@ -149,7 +149,7 @@ namespace osu.Game.Modes.Mods public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail) }; } - public abstract class ModAutoplay : ModAutoplay, IApplyableMod + public abstract class ModAutoplay : ModAutoplay, IApplicableMod where T : HitObject { protected abstract Score CreateReplayScore(Beatmap beatmap); diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index f124dd24ed..b7775a8f96 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -104,7 +104,7 @@ namespace osu.Game.Modes.UI foreach (var mod in mods) { - var applyable = mod as IApplyableMod; + var applyable = mod as IApplicableMod; applyable?.Apply(this); } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 0ae1e049c8..df74ca6b5e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -91,7 +91,7 @@ - + From 6ebd88060adaea9dd4fa1dc864be91d642de5bdb Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 14 Mar 2017 12:38:30 +0900 Subject: [PATCH 24/26] Simplify foreach. --- osu.Game/Modes/UI/HitRenderer.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index b7775a8f96..5b007e5ad3 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -102,12 +102,8 @@ namespace osu.Game.Modes.UI if (mods == null) return; - foreach (var mod in mods) - { - var applyable = mod as IApplicableMod; - - applyable?.Apply(this); - } + foreach (var mod in mods.OfType>()) + mod?.Apply(this); } private void onJudgement(DrawableHitObject o, JudgementInfo j) => TriggerOnJudgement(j); From a502ff2c87660f0f4047983f1b863459f7bb5e97 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 14 Mar 2017 12:47:29 +0900 Subject: [PATCH 25/26] Fix post-merge issues. --- osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs index 83dbe6898f..767fb0dffb 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs @@ -103,7 +103,7 @@ namespace osu.Desktop.VisualTests.Tests Beatmap = beatmap; } - protected override BeatmapArchiveReader GetReader() => null; + protected override ArchiveReader GetReader() => null; } } } From db8cbba8d5e1d1d9d5cd5d1f1d52eb6c85b7b7a9 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 14 Mar 2017 12:52:12 +0900 Subject: [PATCH 26/26] Okay resharper u da boss. --- osu.Game/Modes/UI/HitRenderer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index 5b007e5ad3..e466dd2b8c 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -103,7 +103,7 @@ namespace osu.Game.Modes.UI return; foreach (var mod in mods.OfType>()) - mod?.Apply(this); + mod.Apply(this); } private void onJudgement(DrawableHitObject o, JudgementInfo j) => TriggerOnJudgement(j);