From 4f491519848cc9afab5babcaa56fd28171ffdc11 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 1 May 2017 21:29:57 +0800 Subject: [PATCH 01/11] Make metadata a member of WorkingBeatmap. --- osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs | 2 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 7 +++++-- osu.Game/Database/BeatmapDatabase.cs | 4 +++- osu.Game/Database/DatabaseWorkingBeatmap.cs | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs index 5e3f5b5133..b45574b761 100644 --- a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs @@ -10,7 +10,7 @@ namespace osu.Desktop.VisualTests.Beatmaps public class TestWorkingBeatmap : WorkingBeatmap { public TestWorkingBeatmap(Beatmap beatmap) - : base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet) + : base(beatmap.BeatmapInfo) { this.beatmap = beatmap; } diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 589557b088..09a6ea7065 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -18,14 +18,17 @@ namespace osu.Game.Beatmaps public readonly BeatmapSetInfo BeatmapSetInfo; + public readonly BeatmapMetadata Metadata; + public readonly Bindable> Mods = new Bindable>(new Mod[] { }); public readonly bool WithStoryboard; - protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false) + protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo = null, BeatmapMetadata metadata = null, bool withStoryboard = false) { BeatmapInfo = beatmapInfo; - BeatmapSetInfo = beatmapSetInfo; + BeatmapSetInfo = beatmapSetInfo ?? beatmapInfo?.BeatmapSet; + Metadata = metadata ?? beatmapInfo?.Metadata ?? BeatmapSetInfo?.Metadata; WithStoryboard = withStoryboard; Mods.ValueChanged += mods => applyRateAdjustments(); diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 0e814dea82..6f4559bc52 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -274,6 +274,8 @@ namespace osu.Game.Database if (beatmapSetInfo == null) throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database."); + beatmapInfo.BeatmapSet = beatmapSetInfo; + //we need metadata GetChildren(beatmapSetInfo); //we also need a ruleset @@ -282,7 +284,7 @@ namespace osu.Game.Database if (beatmapInfo.Metadata == null) beatmapInfo.Metadata = beatmapSetInfo.Metadata; - WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, beatmapSetInfo, withStoryboard); + WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard: withStoryboard); previous?.TransferTo(working); diff --git a/osu.Game/Database/DatabaseWorkingBeatmap.cs b/osu.Game/Database/DatabaseWorkingBeatmap.cs index 9fb3bed1e7..d3d5220e7f 100644 --- a/osu.Game/Database/DatabaseWorkingBeatmap.cs +++ b/osu.Game/Database/DatabaseWorkingBeatmap.cs @@ -14,8 +14,8 @@ namespace osu.Game.Database { private readonly BeatmapDatabase database; - public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false) - : base(beatmapInfo, beatmapSetInfo, withStoryboard) + public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo = null, BeatmapMetadata metadata = null, bool withStoryboard = false) + : base(beatmapInfo, beatmapSetInfo, metadata, withStoryboard) { this.database = database; } From 146d57953d6f109f1114f8c51378fe6d9c0fb7f5 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 6 May 2017 14:03:08 +0800 Subject: [PATCH 02/11] Use metadata field of WorkingBeatmap. --- osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs | 6 ++---- osu.Game/Database/DatabaseWorkingBeatmap.cs | 6 +++--- osu.Game/Overlays/MusicController.cs | 2 +- osu.Game/Screens/Menu/MainMenu.cs | 16 +++++++--------- osu.Game/Screens/Select/BeatmapDeleteDialog.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 2 +- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index db14a48af1..8431e5f812 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -51,14 +51,12 @@ namespace osu.Game.Beatmaps.Drawables title = new OsuSpriteText { Font = @"Exo2.0-BoldItalic", - Text = beatmap.BeatmapSetInfo.Metadata.Title, TextSize = 22, Shadow = true, }, artist = new OsuSpriteText { Font = @"Exo2.0-SemiBoldItalic", - Text = beatmap.BeatmapSetInfo.Metadata.Artist, TextSize = 17, Shadow = true, }, @@ -81,8 +79,8 @@ namespace osu.Game.Beatmaps.Drawables [BackgroundDependencyLoader] private void load(LocalisationEngine localisation) { - title.Current = localisation.GetUnicodePreference(beatmap.BeatmapSetInfo.Metadata.TitleUnicode, beatmap.BeatmapSetInfo.Metadata.Title); - artist.Current = localisation.GetUnicodePreference(beatmap.BeatmapSetInfo.Metadata.ArtistUnicode, beatmap.BeatmapSetInfo.Metadata.Artist); + title.Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title); + artist.Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist); } private class PanelBackground : BufferedContainer diff --git a/osu.Game/Database/DatabaseWorkingBeatmap.cs b/osu.Game/Database/DatabaseWorkingBeatmap.cs index d3d5220e7f..1c160a14e4 100644 --- a/osu.Game/Database/DatabaseWorkingBeatmap.cs +++ b/osu.Game/Database/DatabaseWorkingBeatmap.cs @@ -51,13 +51,13 @@ namespace osu.Game.Database protected override Texture GetBackground() { - if (BeatmapInfo?.Metadata?.BackgroundFile == null) + if (Metadata?.BackgroundFile == null) return null; try { using (var reader = getReader()) - return new TextureStore(new RawTextureLoaderStore(reader), false).Get(BeatmapInfo.Metadata.BackgroundFile); + return new TextureStore(new RawTextureLoaderStore(reader), false).Get(Metadata.BackgroundFile); } catch { return null; } } @@ -66,7 +66,7 @@ namespace osu.Game.Database { try { - var trackData = getReader()?.GetStream(BeatmapInfo.Metadata.AudioFile); + var trackData = getReader()?.GetStream(Metadata.AudioFile); return trackData == null ? null : new TrackBass(trackData); } catch { return null; } diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 91d35db3bb..e3edaa0ca7 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -315,7 +315,7 @@ namespace osu.Game.Overlays } else { - BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; + BeatmapMetadata metadata = beatmap.Metadata; title.Current = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title); artist.Current = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist); } diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index a23efcd9d4..ed6a263b4c 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -65,7 +65,6 @@ namespace osu.Game.Screens.Menu private Bindable menuMusic; private TrackManager trackManager; - private WorkingBeatmap song; [BackgroundDependencyLoader] private void load(OsuGame game, OsuConfigManager config, BeatmapDatabase beatmaps) @@ -79,8 +78,7 @@ namespace osu.Game.Screens.Menu List choosableBeatmapSets = beatmaps.Query().ToList(); if (choosableBeatmapSets.Count > 0) { - song = beatmaps.GetWorkingBeatmap(beatmaps.GetWithChildren(choosableBeatmapSets[RNG.Next(0, choosableBeatmapSets.Count - 1)].ID).Beatmaps[0]); - Beatmap = song; + Beatmap = beatmaps.GetWorkingBeatmap(beatmaps.GetWithChildren(choosableBeatmapSets[RNG.Next(0, choosableBeatmapSets.Count - 1)].ID).Beatmaps[0]); } } @@ -106,15 +104,15 @@ namespace osu.Game.Screens.Menu { base.OnEntering(last); buttons.FadeInFromZero(500); - if (last is Intro && song != null) + if (last is Intro && Beatmap != null) { Task.Run(() => { - trackManager.SetExclusive(song.Track); - song.Track.Seek(song.Beatmap.Metadata.PreviewTime); - if (song.Beatmap.Metadata.PreviewTime == -1) - song.Track.Seek(song.Track.Length * 0.4f); - song.Track.Start(); + trackManager.SetExclusive(Beatmap.Track); + Beatmap.Track.Seek(Beatmap.Metadata.PreviewTime); + if (Beatmap.Metadata.PreviewTime == -1) + Beatmap.Track.Seek(Beatmap.Track.Length * 0.4f); + Beatmap.Track.Start(); }); } } diff --git a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs index e6e9a86124..ac35f0e254 100644 --- a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs +++ b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Select Icon = FontAwesome.fa_trash_o; HeaderText = @"Confirm deletion of"; - BodyText = $@"{beatmap.Beatmap?.Metadata?.Artist} - {beatmap.Beatmap?.Metadata?.Title}"; + BodyText = $@"{beatmap?.Metadata?.Artist} - {beatmap?.Metadata?.Title}"; Buttons = new PopupDialogButton[] { new PopupDialogOkButton diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 7d0648ac11..4d7904123c 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -343,7 +343,7 @@ namespace osu.Game.Screens.Select { trackManager.SetExclusive(track); if (preview) - track.Seek(Beatmap.Beatmap.Metadata.PreviewTime); + track.Seek(Beatmap.Metadata.PreviewTime); track.Start(); } } From 767cfaaac39bcf02e62c66825678e21f30b4cff2 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 6 May 2017 15:37:53 +0800 Subject: [PATCH 03/11] Access database recursively. --- .../Beatmaps/IO/ImportBeatmapTest.cs | 7 +++--- osu.Game/Database/BeatmapDatabase.cs | 17 +++----------- osu.Game/Database/Database.cs | 4 ++-- osu.Game/Screens/Menu/MainMenu.cs | 22 ++++++++++--------- osu.Game/Screens/Select/BeatmapCarousel.cs | 6 ++--- osu.Game/Screens/Select/SongSelect.cs | 2 +- 6 files changed, 23 insertions(+), 35 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index b39db30fe8..cba150f91d 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -118,7 +118,7 @@ namespace osu.Game.Tests.Beatmaps.IO Action waitAction = () => { while (!(resultSets = host.Dependencies.Get() - .Query().Where(s => s.OnlineBeatmapSetID == 241526)).Any()) + .GetAllWithChildren(s => s.OnlineBeatmapSetID == 241526)).Any()) Thread.Sleep(50); }; @@ -135,15 +135,14 @@ namespace osu.Game.Tests.Beatmaps.IO waitAction = () => { while ((resultBeatmaps = host.Dependencies.Get() - .Query().Where(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) + .GetAllWithChildren(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) Thread.Sleep(50); }; Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), @"Beatmaps did not import to the database in allocated time"); - //fetch children and check we can load from the post-storage path... - var set = host.Dependencies.Get().GetChildren(resultSets.First()); + var set = resultSets.First(); Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(), $@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count})."); diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 6f4559bc52..811a067116 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -36,14 +36,12 @@ namespace osu.Game.Database private void deletePending() { - foreach (var b in Query().Where(b => b.DeletePending)) + foreach (var b in GetAllWithChildren(b => b.DeletePending)) { try { Storage.Delete(b.Path); - GetChildren(b, true); - foreach (var i in b.Beatmaps) { if (i.Metadata != null) Connection.Delete(i.Metadata); @@ -269,20 +267,11 @@ namespace osu.Game.Database public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null, bool withStoryboard = false) { - var beatmapSetInfo = Query().FirstOrDefault(s => s.ID == beatmapInfo.BeatmapSetInfoID); - - if (beatmapSetInfo == null) + if (beatmapInfo.BeatmapSet == null) throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database."); - beatmapInfo.BeatmapSet = beatmapSetInfo; - - //we need metadata - GetChildren(beatmapSetInfo); - //we also need a ruleset - GetChildren(beatmapInfo); - if (beatmapInfo.Metadata == null) - beatmapInfo.Metadata = beatmapSetInfo.Metadata; + beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata; WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard: withStoryboard); diff --git a/osu.Game/Database/Database.cs b/osu.Game/Database/Database.cs index 23851b3b2e..9b49583875 100644 --- a/osu.Game/Database/Database.cs +++ b/osu.Game/Database/Database.cs @@ -48,9 +48,9 @@ namespace osu.Game.Database return Connection.Table(); } - public T GetWithChildren(object id) where T : class + public T GetWithChildren(object id, bool recursive = false) where T : class { - return Connection.GetWithChildren(id); + return Connection.GetWithChildren(id, recursive); } public List GetAllWithChildren(Expression> filter = null, bool recursive = true) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index ed6a263b4c..f8b8882d3d 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -1,13 +1,16 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; +using OpenTK; +using OpenTK.Input; using osu.Framework.Allocation; using osu.Framework.Audio.Track; using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Framework.Input; using osu.Framework.MathUtils; using osu.Framework.Screens; -using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Database; using osu.Game.Graphics.Containers; @@ -16,14 +19,8 @@ using osu.Game.Screens.Charts; using osu.Game.Screens.Direct; using osu.Game.Screens.Edit; using osu.Game.Screens.Multiplayer; -using OpenTK; using osu.Game.Screens.Select; using osu.Game.Screens.Tournament; -using osu.Framework.Input; -using OpenTK.Input; -using System.Threading.Tasks; -using System.Collections.Generic; -using System.Linq; namespace osu.Game.Screens.Menu { @@ -75,10 +72,15 @@ namespace osu.Game.Screens.Menu if (!menuMusic) { trackManager = game.Audio.Track; - List choosableBeatmapSets = beatmaps.Query().ToList(); - if (choosableBeatmapSets.Count > 0) + + var query = beatmaps.Query().Where(b => !b.DeletePending); + int count = query.Count(); + + if (count > 0) { - Beatmap = beatmaps.GetWorkingBeatmap(beatmaps.GetWithChildren(choosableBeatmapSets[RNG.Next(0, choosableBeatmapSets.Count - 1)].ID).Beatmaps[0]); + var beatmap = query.ElementAt(RNG.Next(0, count - 1)); + beatmaps.GetChildren(beatmap, true); + Beatmap = beatmaps.GetWorkingBeatmap(beatmap.Beatmaps[0]); } } diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index d05dd43b63..fbdaa948cc 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -220,13 +220,11 @@ namespace osu.Game.Screens.Select private BeatmapGroup createGroup(BeatmapSetInfo beatmapSet) { - database.GetChildren(beatmapSet); - beatmapSet.Beatmaps.ForEach(b => + foreach(var b in beatmapSet.Beatmaps) { - database.GetChildren(b); if (b.Metadata == null) b.Metadata = beatmapSet.Metadata; - }); + } return new BeatmapGroup(beatmapSet, database) { diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 4d7904123c..51b67bdbef 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -183,7 +183,7 @@ namespace osu.Game.Screens.Select initialAddSetsTask = new CancellationTokenSource(); carousel.BeatmapsChanged = beatmapsLoaded; - carousel.Beatmaps = database.Query().Where(b => !b.DeletePending); + carousel.Beatmaps = database.GetAllWithChildren(b => !b.DeletePending); } private void beatmapsLoaded() From f37c857af8566c6366866f4d30acb72e028b2f46 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 6 May 2017 16:06:38 +0800 Subject: [PATCH 04/11] CI fixes. --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 4 ++-- osu.Game/Screens/Select/BeatmapDeleteDialog.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index cba150f91d..e259f700b1 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -118,7 +118,7 @@ namespace osu.Game.Tests.Beatmaps.IO Action waitAction = () => { while (!(resultSets = host.Dependencies.Get() - .GetAllWithChildren(s => s.OnlineBeatmapSetID == 241526)).Any()) + .Query().Where(s => s.OnlineBeatmapSetID == 241526)).Any()) Thread.Sleep(50); }; @@ -142,7 +142,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), @"Beatmaps did not import to the database in allocated time"); - var set = resultSets.First(); + var set = host.Dependencies.Get().GetChildren(resultSets.First(), true); Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(), $@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count})."); diff --git a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs index ac35f0e254..0890625eb9 100644 --- a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs +++ b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Select Icon = FontAwesome.fa_trash_o; HeaderText = @"Confirm deletion of"; - BodyText = $@"{beatmap?.Metadata?.Artist} - {beatmap?.Metadata?.Title}"; + BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}"; Buttons = new PopupDialogButton[] { new PopupDialogOkButton From 4c26a02e99bc59bfde504b54537fb1afd04065db Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 8 May 2017 16:42:53 +0800 Subject: [PATCH 05/11] Remove unnecessary arguments in WorkingBeatmap's constructor. --- osu.Game/Beatmaps/WorkingBeatmap.cs | 6 +++--- osu.Game/Database/BeatmapDatabase.cs | 2 +- osu.Game/Database/DatabaseWorkingBeatmap.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 09a6ea7065..0e8d8a9546 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -24,11 +24,11 @@ namespace osu.Game.Beatmaps public readonly bool WithStoryboard; - protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo = null, BeatmapMetadata metadata = null, bool withStoryboard = false) + protected WorkingBeatmap(BeatmapInfo beatmapInfo, bool withStoryboard = false) { BeatmapInfo = beatmapInfo; - BeatmapSetInfo = beatmapSetInfo ?? beatmapInfo?.BeatmapSet; - Metadata = metadata ?? beatmapInfo?.Metadata ?? BeatmapSetInfo?.Metadata; + BeatmapSetInfo = beatmapInfo.BeatmapSet; + Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo.Metadata; WithStoryboard = withStoryboard; Mods.ValueChanged += mods => applyRateAdjustments(); diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 811a067116..760b7ae353 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -273,7 +273,7 @@ namespace osu.Game.Database if (beatmapInfo.Metadata == null) beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata; - WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard: withStoryboard); + WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard); previous?.TransferTo(working); diff --git a/osu.Game/Database/DatabaseWorkingBeatmap.cs b/osu.Game/Database/DatabaseWorkingBeatmap.cs index 1c160a14e4..c56d6cea51 100644 --- a/osu.Game/Database/DatabaseWorkingBeatmap.cs +++ b/osu.Game/Database/DatabaseWorkingBeatmap.cs @@ -14,8 +14,8 @@ namespace osu.Game.Database { private readonly BeatmapDatabase database; - public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo = null, BeatmapMetadata metadata = null, bool withStoryboard = false) - : base(beatmapInfo, beatmapSetInfo, metadata, withStoryboard) + public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, bool withStoryboard = false) + : base(beatmapInfo, withStoryboard) { this.database = database; } From e1ed785cbfde15a4b9f2345745c199d7e7b3adb2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 9 May 2017 21:00:40 +0900 Subject: [PATCH 06/11] Update framework. --- osu-framework | 2 +- osu.Game/Graphics/Cursor/CursorTrail.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu-framework b/osu-framework index cebdfb1bbb..1c95c94fab 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit cebdfb1bbb260e5aaca0a01e06d7128b3d1faae4 +Subproject commit 1c95c94fab6852620cd82eb0899ca0132ac82667 diff --git a/osu.Game/Graphics/Cursor/CursorTrail.cs b/osu.Game/Graphics/Cursor/CursorTrail.cs index 1bc1dea04f..11475a0f19 100644 --- a/osu.Game/Graphics/Cursor/CursorTrail.cs +++ b/osu.Game/Graphics/Cursor/CursorTrail.cs @@ -78,7 +78,7 @@ namespace osu.Game.Graphics.Cursor [BackgroundDependencyLoader] private void load(ShaderManager shaders, TextureStore textures) { - shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.Texture); + shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE); texture = textures.Get(@"Cursor/cursortrail"); Scale = new Vector2(1 / texture.ScaleAdjust); } From cdd71b496d18e7755d8a8b0557a2ae25ff277cab Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 9 May 2017 21:08:53 +0900 Subject: [PATCH 07/11] Fix unnecessary newline. --- osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index 97c65b799b..4234140be6 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -78,8 +78,7 @@ namespace osu.Desktop.VisualTests.Tests new DrawableHoldNote(new HoldNote { StartTime = 5000, - Duration = 1000, - + Duration = 1000 }) { AccentColour = Color4.Red From 2e7812956a2af8614a3b7bc29a12565282e2cec2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 10 May 2017 14:15:11 +0900 Subject: [PATCH 08/11] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 1c95c94fab..3dd870dc42 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 1c95c94fab6852620cd82eb0899ca0132ac82667 +Subproject commit 3dd870dc42474978c0465d4276641431eba16c91 From 3b533de8acb5c3cf9c84abe8dbe67320f74ae6a6 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 10 May 2017 17:29:54 +0900 Subject: [PATCH 09/11] Add xmldoc to HitWindows.cs. --- .../Judgements/HitWindows.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs index 7428f34882..2a0ce88506 100644 --- a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs +++ b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs @@ -119,10 +119,17 @@ namespace osu.Game.Rulesets.Mania.Judgements /// public double Miss = miss_mid; + /// + /// Constructs default hit windows. + /// public HitWindows() { } + /// + /// Constructs hit windows by fitting a parameter to a 2-part piecewise linear function for each hit window. + /// + /// The parameter. public HitWindows(double difficulty) { Perfect = BeatmapDifficulty.DifficultyRange(difficulty, perfect_max, perfect_mid, perfect_min); @@ -133,6 +140,11 @@ namespace osu.Game.Rulesets.Mania.Judgements Miss = BeatmapDifficulty.DifficultyRange(difficulty, miss_max, miss_mid, miss_min); } + /// + /// Constructs new hit windows which have been multiplied by a value. + /// + /// The original hit windows. + /// The value to multiply each hit window by. public static HitWindows operator *(HitWindows windows, double value) { return new HitWindows @@ -146,6 +158,11 @@ namespace osu.Game.Rulesets.Mania.Judgements }; } + /// + /// Constructs new hit windows which have been divided by a value. + /// + /// The original hit windows. + /// The value to divide each hit window by. public static HitWindows operator /(HitWindows windows, double value) { return new HitWindows From 46149044093b83aeb81a44b70296ea215fa6f6f0 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 10 May 2017 17:38:59 +0900 Subject: [PATCH 10/11] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index cd37a9cad9..a1a62c14a5 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit cd37a9cad9aaede267152cf3753cd31fe697cec4 +Subproject commit a1a62c14a51654c933c5b077c725d566f167145b From cdf827df8ea19c902a74453959bd43657e4b3e0a Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 13:11:36 +0900 Subject: [PATCH 11/11] CI fixes. --- .../Tests/TestCaseManiaHitObjects.cs | 5 ----- .../Objects/Drawables/DrawableHoldNote.cs | 11 ++++------- .../Objects/Drawables/DrawableManiaHitObject.cs | 3 +-- .../Objects/Drawables/DrawableNote.cs | 7 ++----- .../Objects/Drawables/Pieces/BodyPiece.cs | 3 +-- .../Objects/Drawables/Pieces/NotePiece.cs | 2 +- 6 files changed, 9 insertions(+), 22 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index 4234140be6..3ad83beb73 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -6,11 +6,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Testing; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using OpenTK.Graphics; using OpenTK; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index b6943a95ce..61dc2638a6 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -1,21 +1,18 @@ // 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.Rulesets.Objects.Drawables; using osu.Framework.Graphics; -using osu.Framework.Allocation; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using OpenTK.Graphics; -using osu.Framework.Graphics.Containers; namespace osu.Game.Rulesets.Mania.Objects.Drawables { public class DrawableHoldNote : DrawableManiaHitObject { - private NotePiece headPiece; - private BodyPiece bodyPiece; - private NotePiece tailPiece; + private readonly NotePiece headPiece; + private readonly BodyPiece bodyPiece; + private readonly NotePiece tailPiece; public DrawableHoldNote(HoldNote hitObject) : base(hitObject) @@ -52,7 +49,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public override Color4 AccentColour { - get { return AccentColour; } + get { return base.AccentColour; } set { if (base.AccentColour == value) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index f33a6fe699..29e4137bba 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -18,7 +17,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly Container glowContainer; - public DrawableManiaHitObject(TObject hitObject) + protected DrawableManiaHitObject(TObject hitObject) : base(hitObject) { HitObject = hitObject; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 57990f2738..bc194b7703 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -2,10 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; -using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using osu.Game.Rulesets.Objects.Drawables; @@ -13,7 +10,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { public class DrawableNote : DrawableManiaHitObject { - private NotePiece headPiece; + private readonly NotePiece headPiece; public DrawableNote(Note hitObject) : base(hitObject) @@ -30,7 +27,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public override Color4 AccentColour { - get { return AccentColour; } + get { return base.AccentColour; } set { if (base.AccentColour == value) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs index ac2b7df06f..ce61a7a86f 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.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.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -15,7 +14,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces /// internal class BodyPiece : Container, IHasAccentColour { - private Box box; + private readonly Box box; public BodyPiece() { diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs index 2584682833..e01199e929 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces private const float head_height = 10; private const float head_colour_height = 6; - private Box colouredBox; + private readonly Box colouredBox; public NotePiece() {