diff --git a/osu-framework b/osu-framework index 56535b834c..06f9c47ef5 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 56535b834cf2329e5abc8ecf698d19ece9ef7b07 +Subproject commit 06f9c47ef5d007b39faf8169170d16ece672b981 diff --git a/osu.Desktop.Deploy/Properties/AssemblyInfo.cs b/osu.Desktop.Deploy/Properties/AssemblyInfo.cs index c71d82df00..e0c1ad1a43 100644 --- a/osu.Desktop.Deploy/Properties/AssemblyInfo.cs +++ b/osu.Desktop.Deploy/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/osu.Desktop.VisualTests/Benchmark.cs b/osu.Desktop.VisualTests/Benchmark.cs index eaceea02b1..8c8cffaf3f 100644 --- a/osu.Desktop.VisualTests/Benchmark.cs +++ b/osu.Desktop.VisualTests/Benchmark.cs @@ -2,20 +2,9 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using osu.Framework; using osu.Framework.Allocation; -using osu.Framework.Desktop.Platform; using osu.Framework.Screens.Testing; using osu.Game; -using osu.Game.Modes; -using osu.Game.Modes.Catch; -using osu.Game.Modes.Mania; -using osu.Game.Modes.Osu; -using osu.Game.Modes.Taiko; namespace osu.Desktop.VisualTests { diff --git a/osu.Desktop.VisualTests/Program.cs b/osu.Desktop.VisualTests/Program.cs index 0532049690..6d51e9162d 100644 --- a/osu.Desktop.VisualTests/Program.cs +++ b/osu.Desktop.VisualTests/Program.cs @@ -3,7 +3,6 @@ using System; using osu.Framework.Desktop; -using osu.Framework.Desktop.Platform; using osu.Framework.Platform; using osu.Game.Modes; using osu.Game.Modes.Catch; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs index 4e27788d67..9b9e33431f 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs @@ -1,22 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using osu.Framework; using osu.Framework.Screens.Testing; -using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Framework.Threading; -using osu.Game; -using osu.Game.Online.API; -using osu.Game.Online.API.Requests; -using osu.Game.Online.Chat; -using OpenTK; -using osu.Framework.Allocation; -using osu.Game.Online.Chat.Drawables; using osu.Game.Overlays; namespace osu.Desktop.VisualTests.Tests diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs index 70abd6d8c4..9259f2ea78 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs @@ -7,15 +7,11 @@ using osu.Framework.Graphics; using osu.Framework.MathUtils; using osu.Framework.Timing; using osu.Game.Beatmaps; -using osu.Game.Modes.Catch; using osu.Game.Modes.Catch.UI; -using osu.Game.Modes.Mania; using osu.Game.Modes.Mania.UI; using osu.Game.Modes.Objects; -using osu.Game.Modes.Osu; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.UI; -using osu.Game.Modes.Taiko; using osu.Game.Modes.Taiko.UI; using OpenTK; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index 7a46ea5ded..f77025cb06 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -2,21 +2,17 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; -using osu.Framework; using osu.Framework.Screens.Testing; using osu.Framework.Graphics; using osu.Framework.Timing; using OpenTK; -using osu.Framework.Allocation; using osu.Framework.Configuration; -using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects.Drawables; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; -using osu.Game.Modes; using OpenTK.Graphics; namespace osu.Desktop.VisualTests.Tests diff --git a/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs index c33a4001de..537bfc8dab 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs @@ -3,9 +3,7 @@ using osu.Framework.Screens.Testing; using osu.Framework.Graphics; -using osu.Game.Graphics.UserInterface; using OpenTK.Input; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; using osu.Framework.Configuration; using OpenTK; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs index e3457939f2..78174a8f64 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs @@ -5,11 +5,9 @@ using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Screens.Testing; using osu.Framework.MathUtils; -using osu.Framework.Timing; using osu.Game.Overlays; using System.Linq; using osu.Game.Overlays.Notifications; -using osu.Game.Screens.Backgrounds; namespace osu.Desktop.VisualTests.Tests { diff --git a/osu.Desktop.VisualTests/Tests/TestCaseOptions.cs b/osu.Desktop.VisualTests/Tests/TestCaseOptions.cs index 92a10cc649..6afd9ba86d 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseOptions.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseOptions.cs @@ -2,11 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Screens.Testing; -using osu.Framework.Graphics; -using osu.Game.Graphics.UserInterface; -using OpenTK.Input; using osu.Game.Overlays; -using osu.Framework.Graphics.Containers; namespace osu.Desktop.VisualTests.Tests { diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index 9d94189885..990b8b3775 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -1,16 +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 OpenTK.Graphics; using osu.Framework.Logging; -using osu.Framework.Graphics; using osu.Game.Overlays.Pause; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Colour; using osu.Framework.Screens.Testing; -using osu.Framework.Graphics.UserInterface; namespace osu.Desktop.VisualTests.Tests { diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index 2c4729b05a..7533a1a1e6 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -4,12 +4,11 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Screens.Testing; -using osu.Framework.MathUtils; -using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Formats; using OpenTK; using osu.Framework.Graphics.Sprites; +using osu.Game.Beatmaps.IO; using osu.Game.Database; using osu.Game.Modes; using osu.Game.Modes.Objects; @@ -74,7 +73,7 @@ namespace osu.Desktop.VisualTests.Tests decoder.Process(b); - beatmap = new WorkingBeatmap(b); + beatmap = new TestWorkingBeatmap(b); } Add(new Box @@ -92,5 +91,16 @@ namespace osu.Desktop.VisualTests.Tests Beatmap = beatmap }); } + + class TestWorkingBeatmap : WorkingBeatmap + { + public TestWorkingBeatmap(Beatmap beatmap) + : base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet) + { + Beatmap = beatmap; + } + + protected override ArchiveReader GetReader() => null; + } } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index d4ac16b86f..c5f7c81585 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -7,17 +7,11 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.MathUtils; using osu.Game.Graphics.UserInterface; -using osu.Game.Modes; -using osu.Game.Modes.Catch; using osu.Game.Modes.Catch.UI; -using osu.Game.Modes.Mania; using osu.Game.Modes.Mania.UI; -using osu.Game.Modes.Osu; using osu.Game.Modes.Osu.UI; -using osu.Game.Modes.Taiko; using osu.Game.Modes.Taiko.UI; using osu.Game.Modes.UI; -using osu.Game.Screens.Play; using OpenTK; using OpenTK.Graphics; using osu.Framework.Graphics.Primitives; @@ -164,7 +158,7 @@ namespace osu.Desktop.VisualTests.Tests AddButton(@"Alter stars", delegate { - stars.Count = RNG.NextSingle() * (stars.MaxStars + 1); + stars.Count = RNG.NextSingle() * (stars.StarCount + 1); starsLabel.Text = stars.Count.ToString("0.00"); }); diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs b/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs index 33ae728fd7..ff65ac619e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs @@ -2,12 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Screens.Testing; -using osu.Framework.Graphics.Colour; -using osu.Framework.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using osu.Game.Screens.Menu; using osu.Game.Screens.Play; -using OpenTK.Graphics; namespace osu.Desktop.VisualTests.Tests { diff --git a/osu.Desktop.VisualTests/VisualTestGame.cs b/osu.Desktop.VisualTests/VisualTestGame.cs index 81b00d4ab2..3128824da2 100644 --- a/osu.Desktop.VisualTests/VisualTestGame.cs +++ b/osu.Desktop.VisualTests/VisualTestGame.cs @@ -1,16 +1,8 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework; using osu.Framework.Screens.Testing; -using osu.Framework.Graphics.Cursor; -using osu.Game.Database; using osu.Game; -using osu.Framework.Desktop.Platform; -using System.Reflection; -using System.IO; -using System.Collections.Generic; -using osu.Framework.Allocation; using osu.Game.Screens.Backgrounds; namespace osu.Desktop.VisualTests @@ -21,7 +13,7 @@ namespace osu.Desktop.VisualTests { base.LoadComplete(); - (new BackgroundScreenDefault() { Depth = 10 }).Preload(this, AddInternal); + (new BackgroundScreenDefault() { Depth = 10 }).LoadAsync(this, AddInternal); // Have to construct this here, rather than in the constructor, because // we depend on some dependencies to be loaded within OsuGameBase.load(). diff --git a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs index 132f14ddb5..b8bfb63a08 100644 --- a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs +++ b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs @@ -1,9 +1,7 @@ // 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 System.Collections.Generic; using System.Linq; using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.IO; diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index c3adb8f81f..d9b9c31617 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -2,15 +2,10 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Game; -using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; using osu.Framework.Platform; using osu.Framework.Desktop.Platform; -using osu.Game.Database; using osu.Desktop.Overlays; using System.Reflection; using System.Drawing; @@ -34,7 +29,7 @@ namespace osu.Desktop { base.LoadComplete(); - versionManager.Preload(this); + versionManager.LoadAsync(this); ModeChanged += m => { if (!versionManager.IsAlive && m is Intro) @@ -61,7 +56,7 @@ namespace osu.Desktop // this method will only be executed if e.Effect in dragEnter gets set to something other that None. var dropData = e.Data.GetData(DataFormats.FileDrop) as object[]; var filePaths = dropData.Select(f => f.ToString()).ToArray(); - ImportBeatmaps(filePaths); + ImportBeatmapsAsync(filePaths); } private void dragEnter(DragEventArgs e) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index c3f31414de..bdc8bc7e1a 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.ComponentModel; using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -19,7 +18,6 @@ using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; using System.Net.Http; -using osu.Framework.Logging; namespace osu.Desktop.Overlays { @@ -104,7 +102,7 @@ namespace osu.Desktop.Overlays }; if (IsDeployedBuild) - updateChecker(); + checkForUpdateAsync(); } protected override void LoadComplete() @@ -119,7 +117,7 @@ namespace osu.Desktop.Overlays updateManager?.Dispose(); } - private async void updateChecker(bool useDeltaPatching = true, UpdateProgressNotification notification = null) + private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null) { //should we schedule a retry on completion of this check? bool scheduleRetry = true; @@ -165,7 +163,7 @@ namespace osu.Desktop.Overlays { //could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959) //try again without deltas. - updateChecker(false, notification); + checkForUpdateAsync(false, notification); scheduleRetry = false; } } @@ -180,7 +178,7 @@ namespace osu.Desktop.Overlays if (scheduleRetry) { //check again in 30 minutes. - Scheduler.AddDelayed(() => updateChecker(), 60000 * 30); + Scheduler.AddDelayed(() => checkForUpdateAsync(), 60000 * 30); if (notification != null) notification.State = ProgressNotificationState.Cancelled; } diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index 3023cbfc39..23de1ddbba 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -35,7 +35,7 @@ namespace osu.Desktop foreach (var file in args) { Console.WriteLine(@"Importing {0}", file); - if (!importer.Import(Path.GetFullPath(file)).Wait(3000)) + if (!importer.ImportAsync(Path.GetFullPath(file)).Wait(3000)) throw new TimeoutException(@"IPC took too long to send"); } } diff --git a/osu.Desktop/Properties/AssemblyInfo.cs b/osu.Desktop/Properties/AssemblyInfo.cs index 17329d8ac0..eacfc996d5 100644 --- a/osu.Desktop/Properties/AssemblyInfo.cs +++ b/osu.Desktop/Properties/AssemblyInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/osu.Game.Modes.Catch/CatchDifficultyCalculator.cs b/osu.Game.Modes.Catch/CatchDifficultyCalculator.cs index 47fe1774bd..ccc4097d59 100644 --- a/osu.Game.Modes.Catch/CatchDifficultyCalculator.cs +++ b/osu.Game.Modes.Catch/CatchDifficultyCalculator.cs @@ -19,7 +19,7 @@ namespace osu.Game.Modes.Catch protected override HitObjectConverter Converter => new CatchConverter(); - protected override double ComputeDifficulty(Dictionary categoryDifficulty) + protected override double CalculateInternal(Dictionary categoryDifficulty) { return 0; } diff --git a/osu.Game.Modes.Catch/CatchRuleset.cs b/osu.Game.Modes.Catch/CatchRuleset.cs index 48a84617da..fd778d1ce6 100644 --- a/osu.Game.Modes.Catch/CatchRuleset.cs +++ b/osu.Game.Modes.Catch/CatchRuleset.cs @@ -7,7 +7,6 @@ using osu.Game.Modes.Objects; using osu.Game.Modes.Osu.UI; using osu.Game.Modes.UI; using osu.Game.Beatmaps; -using System; namespace osu.Game.Modes.Catch { diff --git a/osu.Game.Modes.Catch/Properties/AssemblyInfo.cs b/osu.Game.Modes.Catch/Properties/AssemblyInfo.cs index 39475be046..07a088e1e9 100644 --- a/osu.Game.Modes.Catch/Properties/AssemblyInfo.cs +++ b/osu.Game.Modes.Catch/Properties/AssemblyInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/osu.Game.Modes.Mania/ManiaDifficultyCalculator.cs b/osu.Game.Modes.Mania/ManiaDifficultyCalculator.cs index 5075c44db6..975b78c215 100644 --- a/osu.Game.Modes.Mania/ManiaDifficultyCalculator.cs +++ b/osu.Game.Modes.Mania/ManiaDifficultyCalculator.cs @@ -22,7 +22,7 @@ namespace osu.Game.Modes.Mania protected override HitObjectConverter Converter => new ManiaConverter(columns); - protected override double ComputeDifficulty(Dictionary categoryDifficulty) + protected override double CalculateInternal(Dictionary categoryDifficulty) { return 0; } diff --git a/osu.Game.Modes.Mania/ManiaRuleset.cs b/osu.Game.Modes.Mania/ManiaRuleset.cs index 28c298be95..bbf22086c0 100644 --- a/osu.Game.Modes.Mania/ManiaRuleset.cs +++ b/osu.Game.Modes.Mania/ManiaRuleset.cs @@ -7,7 +7,6 @@ using osu.Game.Modes.Objects; using osu.Game.Modes.Osu.UI; using osu.Game.Modes.UI; using osu.Game.Beatmaps; -using System; namespace osu.Game.Modes.Mania { diff --git a/osu.Game.Modes.Mania/Properties/AssemblyInfo.cs b/osu.Game.Modes.Mania/Properties/AssemblyInfo.cs index c7c7296d60..6cfa3c42b3 100644 --- a/osu.Game.Modes.Mania/Properties/AssemblyInfo.cs +++ b/osu.Game.Modes.Mania/Properties/AssemblyInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/ApproachCircle.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/ApproachCircle.cs index f1ab062848..b0b1e81fca 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/ApproachCircle.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/ApproachCircle.cs @@ -1,14 +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.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Framework.Input; -using OpenTK; namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/NumberPiece.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/NumberPiece.cs index bb18e32475..02116fc157 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/NumberPiece.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/NumberPiece.cs @@ -1,14 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using OpenTK; using OpenTK.Graphics; namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/RingPiece.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/RingPiece.cs index 3a98973b15..3e172cdc09 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/RingPiece.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/RingPiece.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 osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; using OpenTK; using OpenTK.Graphics; diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBall.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBall.cs index 88bf49b644..1e81b17b06 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBall.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBall.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Framework.Input; -using OpenTK; using OpenTK.Graphics; namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBouncer.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBouncer.cs index e13f8626a5..1a78e5d85f 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBouncer.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBouncer.cs @@ -1,14 +1,8 @@ // 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 System.Text; -using System.Threading.Tasks; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs index 31da815bbe..405105936d 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Framework.Input; -using osu.Framework.Logging; using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/TrianglesPiece.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/TrianglesPiece.cs index 57e00be1cf..33ed93e625 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/TrianglesPiece.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/TrianglesPiece.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 osu.Game.Graphics.Backgrounds; namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces diff --git a/osu.Game.Modes.Osu/Objects/HitCircle.cs b/osu.Game.Modes.Osu/Objects/HitCircle.cs index 0eaf5abdff..80f9317d96 100644 --- a/osu.Game.Modes.Osu/Objects/HitCircle.cs +++ b/osu.Game.Modes.Osu/Objects/HitCircle.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; namespace osu.Game.Modes.Osu.Objects { diff --git a/osu.Game.Modes.Osu/Objects/OsuHitObject.cs b/osu.Game.Modes.Osu/Objects/OsuHitObject.cs index f454ebc470..cbf9a3de9c 100644 --- a/osu.Game.Modes.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Modes.Osu/Objects/OsuHitObject.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Game.Beatmaps.Samples; using osu.Game.Modes.Objects; using OpenTK; using osu.Game.Beatmaps; diff --git a/osu.Game.Modes.Osu/Objects/OsuHitObjectParser.cs b/osu.Game.Modes.Osu/Objects/OsuHitObjectParser.cs index b4dc494ad4..e8818db1d5 100644 --- a/osu.Game.Modes.Osu/Objects/OsuHitObjectParser.cs +++ b/osu.Game.Modes.Osu/Objects/OsuHitObjectParser.cs @@ -4,9 +4,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using osu.Game.Beatmaps.Samples; using osu.Game.Modes.Objects; using OpenTK; diff --git a/osu.Game.Modes.Osu/Objects/SliderCurve.cs b/osu.Game.Modes.Osu/Objects/SliderCurve.cs index e60e58da9a..e582cca580 100644 --- a/osu.Game.Modes.Osu/Objects/SliderCurve.cs +++ b/osu.Game.Modes.Osu/Objects/SliderCurve.cs @@ -29,26 +29,21 @@ namespace osu.Game.Modes.Osu.Objects case CurveTypes.Linear: return subControlPoints; case CurveTypes.PerfectCurve: - // If we have a different amount than 3 control points, use bezier for perfect curves. - if (ControlPoints.Count != 3) - return new BezierApproximator(subControlPoints).CreateBezier(); - else - { - Debug.Assert(subControlPoints.Count == 3); + //we can only use CircularArc iff we have exactly three control points and no dissection. + if (ControlPoints.Count != 3 || subControlPoints.Count != 3) + break; - // Here we have exactly 3 control points. Attempt to fit a circular arc. - List subpath = new CircularArcApproximator(subControlPoints[0], subControlPoints[1], subControlPoints[2]).CreateArc(); + // Here we have exactly 3 control points. Attempt to fit a circular arc. + List subpath = new CircularArcApproximator(subControlPoints[0], subControlPoints[1], subControlPoints[2]).CreateArc(); - if (subpath.Count == 0) - // For some reason a circular arc could not be fit to the 3 given points. Fall back - // to a numerically stable bezier approximation. - subpath = new BezierApproximator(subControlPoints).CreateBezier(); + // If for some reason a circular arc could not be fit to the 3 given points, fall back to a numerically stable bezier approximation. + if (subpath.Count == 0) + break; - return subpath; - } - default: - return new BezierApproximator(subControlPoints).CreateBezier(); + return subpath; } + + return new BezierApproximator(subControlPoints).CreateBezier(); } private void calculatePath() @@ -181,7 +176,7 @@ namespace osu.Game.Modes.Osu.Objects path.Clear(); int i = 0; - for (; i < calculatedPath.Count && cumulativeLength[i] < d0; ++i); + for (; i < calculatedPath.Count && cumulativeLength[i] < d0; ++i) ; path.Add(interpolateVertices(i, d0) + Offset); diff --git a/osu.Game.Modes.Osu/Objects/SliderTick.cs b/osu.Game.Modes.Osu/Objects/SliderTick.cs index 392b1f99ca..d9b8c03c3c 100644 --- a/osu.Game.Modes.Osu/Objects/SliderTick.cs +++ b/osu.Game.Modes.Osu/Objects/SliderTick.cs @@ -1,6 +1,4 @@ -using OpenTK; - -namespace osu.Game.Modes.Osu.Objects +namespace osu.Game.Modes.Osu.Objects { public class SliderTick : OsuHitObject { diff --git a/osu.Game.Modes.Osu/Objects/Spinner.cs b/osu.Game.Modes.Osu/Objects/Spinner.cs index 095705eb1f..8a9b5bbbe3 100644 --- a/osu.Game.Modes.Osu/Objects/Spinner.cs +++ b/osu.Game.Modes.Osu/Objects/Spinner.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; namespace osu.Game.Modes.Osu.Objects { diff --git a/osu.Game.Modes.Osu/OsuDifficultyCalculator.cs b/osu.Game.Modes.Osu/OsuDifficultyCalculator.cs index 24648b1726..9e2a311021 100644 --- a/osu.Game.Modes.Osu/OsuDifficultyCalculator.cs +++ b/osu.Game.Modes.Osu/OsuDifficultyCalculator.cs @@ -34,7 +34,7 @@ namespace osu.Game.Modes.Osu ((Slider)h).Curve.Calculate(); } - protected override double ComputeDifficulty(Dictionary categoryDifficulty) + protected override double CalculateInternal(Dictionary categoryDifficulty) { // Fill our custom DifficultyHitObject class, that carries additional information DifficultyHitObjects.Clear(); diff --git a/osu.Game.Modes.Osu/OsuScore.cs b/osu.Game.Modes.Osu/OsuScore.cs index 2a3c9a866f..ce651e0809 100644 --- a/osu.Game.Modes.Osu/OsuScore.cs +++ b/osu.Game.Modes.Osu/OsuScore.cs @@ -1,11 +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.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Game.Modes.Osu { diff --git a/osu.Game.Modes.Osu/Properties/AssemblyInfo.cs b/osu.Game.Modes.Osu/Properties/AssemblyInfo.cs index 2991947d85..61e6ae6f7a 100644 --- a/osu.Game.Modes.Osu/Properties/AssemblyInfo.cs +++ b/osu.Game.Modes.Osu/Properties/AssemblyInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/osu.Game.Modes.Osu/UI/OsuComboCounter.cs b/osu.Game.Modes.Osu/UI/OsuComboCounter.cs index b6770b6f21..5ba5537b59 100644 --- a/osu.Game.Modes.Osu/UI/OsuComboCounter.cs +++ b/osu.Game.Modes.Osu/UI/OsuComboCounter.cs @@ -3,7 +3,6 @@ using osu.Game.Modes.UI; using OpenTK; -using osu.Framework.Graphics.Primitives; namespace osu.Game.Modes.Osu.UI { diff --git a/osu.Game.Modes.Taiko/Properties/AssemblyInfo.cs b/osu.Game.Modes.Taiko/Properties/AssemblyInfo.cs index c4b0fffae7..61eca30b5f 100644 --- a/osu.Game.Modes.Taiko/Properties/AssemblyInfo.cs +++ b/osu.Game.Modes.Taiko/Properties/AssemblyInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/osu.Game.Modes.Taiko/TaikoDifficultyCalculator.cs b/osu.Game.Modes.Taiko/TaikoDifficultyCalculator.cs index 69b86a86af..5067cef2b3 100644 --- a/osu.Game.Modes.Taiko/TaikoDifficultyCalculator.cs +++ b/osu.Game.Modes.Taiko/TaikoDifficultyCalculator.cs @@ -19,7 +19,7 @@ namespace osu.Game.Modes.Taiko protected override HitObjectConverter Converter => new TaikoConverter(); - protected override double ComputeDifficulty(Dictionary categoryDifficulty) + protected override double CalculateInternal(Dictionary categoryDifficulty) { return 0; } diff --git a/osu.Game.Modes.Taiko/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index 01e1598e20..6141838880 100644 --- a/osu.Game.Modes.Taiko/TaikoRuleset.cs +++ b/osu.Game.Modes.Taiko/TaikoRuleset.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 osu.Game.Graphics; using osu.Game.Modes.Objects; using osu.Game.Modes.Osu.UI; diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 8c892c0725..8de1a0f918 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Threading; using NUnit.Framework; @@ -16,7 +15,6 @@ using osu.Game.Modes.Catch; using osu.Game.Modes.Mania; using osu.Game.Modes.Osu; using osu.Game.Modes.Taiko; -using osu.Game.Screens.Play; namespace osu.Game.Tests.Beatmaps.IO { @@ -58,10 +56,10 @@ namespace osu.Game.Tests.Beatmaps.IO var osu = loadOsu(host); var importer = new BeatmapImporter(client); - if (!importer.Import(osz_path).Wait(1000)) + if (!importer.ImportAsync(osz_path).Wait(1000)) Assert.Fail(@"IPC took too long to send"); - ensureLoaded(osu, 10000); + ensureLoaded(osu); } } @@ -79,23 +77,23 @@ namespace osu.Game.Tests.Beatmaps.IO return osu; } - private void ensureLoaded(OsuGameBase osu, int timeout = 100) + private void ensureLoaded(OsuGameBase osu, int timeout = 10000) { IEnumerable resultSets = null; Action waitAction = () => { while ((resultSets = osu.Dependencies.Get() - .Query().Where(s => s.OnlineBeatmapSetID == 241526)).Count() != 1) - Thread.Sleep(1); + .Query().Where(s => s.OnlineBeatmapSetID == 241526)).Count() == 0) + Thread.Sleep(50); }; Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), - @"BeatmapSet did not import to the database"); + $@"BeatmapSet did not import to the database in allocated time."); //ensure we were stored to beatmap database backing... - Assert.IsTrue(resultSets.Count() == 1); + Assert.IsTrue(resultSets.Count() == 1, $@"Incorrect result count found ({resultSets.Count()} but should be 1)."); IEnumerable resultBeatmaps = null; @@ -104,23 +102,24 @@ namespace osu.Game.Tests.Beatmaps.IO { while ((resultBeatmaps = osu.Dependencies.Get() .Query().Where(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) - Thread.Sleep(1); + Thread.Sleep(50); }; Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), - @"Beatmaps did not import to the database"); + @"Beatmaps did not import to the database in allocated time"); //fetch children and check we can load from the post-storage path... var set = osu.Dependencies.Get().GetChildren(resultSets.First()); - Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count()); + Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(), + $@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count})."); foreach (BeatmapInfo b in resultBeatmaps) Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineBeatmapID == b.OnlineBeatmapID)); Assert.IsTrue(set.Beatmaps.Count > 0); - var beatmap = osu.Dependencies.Get().GetBeatmap(set.Beatmaps.First(b => b.Mode == PlayMode.Osu)); + var beatmap = osu.Dependencies.Get().GetWorkingBeatmap(set.Beatmaps.First(b => b.Mode == PlayMode.Osu))?.Beatmap; Assert.IsTrue(beatmap.HitObjects.Count > 0); } diff --git a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs index 3d706a8026..faa83518ba 100644 --- a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.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 System.IO; using NUnit.Framework; using osu.Game.Beatmaps.IO; diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index a55e9fa80d..d92e340e72 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -7,6 +7,7 @@ using OpenTK.Graphics; using osu.Game.Beatmaps.Timing; using osu.Game.Database; using osu.Game.Modes.Objects; +using osu.Game.Modes; namespace osu.Game.Beatmaps { @@ -57,5 +58,7 @@ namespace osu.Game.Beatmaps return timingPoint ?? ControlPoint.Default; } + + public double CalculateStarDifficulty() => Ruleset.GetRuleset(BeatmapInfo.Mode).CreateDifficultyCalculator(this).Calculate(); } } diff --git a/osu.Game/Beatmaps/DifficultyCalculator.cs b/osu.Game/Beatmaps/DifficultyCalculator.cs index 14b6ce3e96..8214496363 100644 --- a/osu.Game/Beatmaps/DifficultyCalculator.cs +++ b/osu.Game/Beatmaps/DifficultyCalculator.cs @@ -14,7 +14,7 @@ namespace osu.Game.Beatmaps protected double TimeRate = 1; - protected abstract double ComputeDifficulty(Dictionary categoryDifficulty); + protected abstract double CalculateInternal(Dictionary categoryDifficulty); private void loadTiming() { @@ -23,10 +23,10 @@ namespace osu.Game.Beatmaps TimeRate = audioRate / 100.0; } - public double GetDifficulty(Dictionary categoryDifficulty = null) + public double Calculate(Dictionary categoryDifficulty = null) { loadTiming(); - double difficulty = ComputeDifficulty(categoryDifficulty); + double difficulty = CalculateInternal(categoryDifficulty); return difficulty; } } diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index 14aff0e7ba..36c042ac30 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Linq; using osu.Framework; using osu.Framework.Graphics; -using osu.Framework.Graphics.Transformations; using osu.Game.Database; namespace osu.Game.Beatmaps.Drawables @@ -60,16 +59,21 @@ namespace osu.Game.Beatmaps.Drawables } } - public BeatmapGroup(WorkingBeatmap beatmap) + public BeatmapGroup(BeatmapSetInfo beatmapSet, BeatmapDatabase database) { + BeatmapSet = beatmapSet; + WorkingBeatmap beatmap = database.GetWorkingBeatmap(BeatmapSet.Beatmaps.FirstOrDefault()); + foreach (var b in BeatmapSet.Beatmaps) + b.StarDifficulty = (float)database.GetWorkingBeatmap(b).Beatmap.CalculateStarDifficulty(); + Header = new BeatmapSetHeader(beatmap) { GainedSelection = headerGainedSelection, RelativeSizeAxes = Axes.X, }; - - BeatmapSet = beatmap.BeatmapSetInfo; - BeatmapPanels = beatmap.BeatmapSetInfo.Beatmaps.Select(b => new BeatmapPanel(b) + + BeatmapSet.Beatmaps = BeatmapSet.Beatmaps.OrderBy(b => b.StarDifficulty).ToList(); + BeatmapPanels = BeatmapSet.Beatmaps.Select(b => new BeatmapPanel(b) { Alpha = 0, GainedSelection = panelGainedSelection, diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index a6ad0a6457..214712af72 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -26,6 +26,7 @@ namespace osu.Game.Beatmaps.Drawables public Action GainedSelection; public Action StartRequested; private Triangles triangles; + private StarCounter starCounter; protected override void Selected() { @@ -56,6 +57,14 @@ namespace osu.Game.Beatmaps.Drawables return base.OnClick(state); } + protected override void ApplyState(PanelSelectedState last = PanelSelectedState.Hidden) + { + base.ApplyState(last); + + if (last == PanelSelectedState.Hidden && State != last) + starCounter.ReplayAnimation(); + } + public BeatmapPanel(BeatmapInfo beatmap) { Beatmap = beatmap; @@ -92,7 +101,6 @@ namespace osu.Game.Beatmaps.Drawables new FlowContainer { Padding = new MarginPadding { Left = 5 }, - Spacing = new Vector2(0, 5), Direction = FlowDirections.Vertical, AutoSizeAxes = Axes.Both, Children = new Drawable[] @@ -130,7 +138,11 @@ namespace osu.Game.Beatmaps.Drawables }, } }, - new StarCounter { Count = beatmap.StarDifficulty, StarSize = 8 } + starCounter = new StarCounter + { + Count = beatmap.StarDifficulty, + Scale = new Vector2(0.8f), + } } } } diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index a0a7549caf..8681259272 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Configuration; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; @@ -162,7 +161,7 @@ namespace osu.Game.Beatmaps.Drawables Anchor = Anchor.Centre, Origin = Anchor.Centre, FillMode = FillMode.Fill, - }.Preload(game, (bg) => + }.LoadAsync(game, (bg) => { Add(bg); ForceRedraw(); diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs index d3a5106b0e..e0e390fcb1 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs @@ -1,10 +1,8 @@ // 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.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Game.Database; using osu.Game.Graphics; diff --git a/osu.Game/Beatmaps/Drawables/Panel.cs b/osu.Game/Beatmaps/Drawables/Panel.cs index 2e5f5f248b..ec3c2a291f 100644 --- a/osu.Game/Beatmaps/Drawables/Panel.cs +++ b/osu.Game/Beatmaps/Drawables/Panel.cs @@ -50,10 +50,10 @@ namespace osu.Game.Beatmaps.Drawables protected override void LoadComplete() { base.LoadComplete(); - applyState(); + ApplyState(); } - private void applyState() + protected virtual void ApplyState(PanelSelectedState last = PanelSelectedState.Hidden) { switch (state) { @@ -81,9 +81,10 @@ namespace osu.Game.Beatmaps.Drawables set { if (state == value) return; - state = value; - applyState(); + var last = state; + state = value; + ApplyState(last); } } diff --git a/osu.Game/Beatmaps/Events/EventType.cs b/osu.Game/Beatmaps/Events/EventType.cs index 23a5cf684c..0d4be693f0 100644 --- a/osu.Game/Beatmaps/Events/EventType.cs +++ b/osu.Game/Beatmaps/Events/EventType.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; namespace osu.Game.Beatmaps.Events { public enum EventType diff --git a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs index 4846cf376d..7f55b3be1b 100644 --- a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.IO; using osu.Game.Modes.Objects; using OpenTK.Graphics; -using osu.Game.Graphics; using osu.Game.Beatmaps.Timing; using osu.Game.Database; diff --git a/osu.Game/Beatmaps/Formats/ConstructableBeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/ConstructableBeatmapDecoder.cs index f80c673e89..3e7dbb4d1b 100644 --- a/osu.Game/Beatmaps/Formats/ConstructableBeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/ConstructableBeatmapDecoder.cs @@ -2,11 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Game.Beatmaps.Formats { diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index c32c3fe2f1..aa2e2fbc75 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -2,17 +2,14 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections.Generic; using System.Globalization; using System.IO; using OpenTK.Graphics; -using osu.Game.Database; using osu.Game.Beatmaps.Events; using osu.Game.Beatmaps.Samples; using osu.Game.Beatmaps.Timing; using osu.Game.Modes; using osu.Game.Modes.Objects; -using osu.Game.Screens.Play; namespace osu.Game.Beatmaps.Formats { diff --git a/osu.Game/Beatmaps/IO/OszArchiveReader.cs b/osu.Game/Beatmaps/IO/OszArchiveReader.cs index 273e0c1fb9..8a1d071cfc 100644 --- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs @@ -1,10 +1,8 @@ // 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 System.Linq; -using System.Security.Cryptography; using Ionic.Zip; using osu.Game.Beatmaps.Formats; using osu.Game.Database; diff --git a/osu.Game/Beatmaps/Timing/TimingChange.cs b/osu.Game/Beatmaps/Timing/TimingChange.cs index 10a68bb540..74e855e157 100644 --- a/osu.Game/Beatmaps/Timing/TimingChange.cs +++ b/osu.Game/Beatmaps/Timing/TimingChange.cs @@ -5,8 +5,6 @@ namespace osu.Game.Beatmaps.Timing { class TimingChange : ControlPoint { - public double BeatLength; - public TimingChange(double beatLength) { BeatLength = beatLength; diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index c6bc4eeeb8..9393c2b0e9 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -11,16 +11,22 @@ using osu.Game.Database; namespace osu.Game.Beatmaps { - public class WorkingBeatmap : IDisposable + public abstract class WorkingBeatmap : IDisposable { public readonly BeatmapInfo BeatmapInfo; public readonly BeatmapSetInfo BeatmapSetInfo; - private readonly BeatmapDatabase database; public readonly bool WithStoryboard; - private ArchiveReader getReader() => database?.GetReader(BeatmapSetInfo); + protected abstract ArchiveReader GetReader(); + + protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false) + { + BeatmapInfo = beatmapInfo; + BeatmapSetInfo = beatmapSetInfo; + WithStoryboard = withStoryboard; + } private Texture background; private object backgroundLock = new object(); @@ -36,7 +42,7 @@ namespace osu.Game.Beatmaps try { - using (var reader = getReader()) + using (var reader = GetReader()) background = new TextureStore(new RawTextureLoaderStore(reader), false).Get(BeatmapInfo.Metadata.BackgroundFile); } catch { } @@ -59,7 +65,7 @@ namespace osu.Game.Beatmaps try { - using (var reader = getReader()) + using (var reader = GetReader()) { BeatmapDecoder decoder; using (var stream = new StreamReader(reader.GetStream(BeatmapInfo.Path))) @@ -95,7 +101,7 @@ namespace osu.Game.Beatmaps try { //store a reference to the reader as we may continue accessing the stream in the background. - trackReader = getReader(); + trackReader = GetReader(); var trackData = trackReader?.GetStream(BeatmapInfo.Metadata.AudioFile); if (trackData != null) track = new TrackBass(trackData); @@ -110,21 +116,6 @@ namespace osu.Game.Beatmaps public bool TrackLoaded => track != null; - public WorkingBeatmap(Beatmap beatmap) - { - this.beatmap = beatmap; - BeatmapInfo = beatmap.BeatmapInfo; - BeatmapSetInfo = beatmap.BeatmapInfo.BeatmapSet; - } - - public WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, BeatmapDatabase database, bool withStoryboard = false) - { - BeatmapInfo = beatmapInfo; - BeatmapSetInfo = beatmapSetInfo; - this.database = database; - this.WithStoryboard = withStoryboard; - } - private bool isDisposed; protected virtual void Dispose(bool disposing) diff --git a/osu.Game/Configuration/ConfineMouseMode.cs b/osu.Game/Configuration/ConfineMouseMode.cs index 31a37fda7f..527f26cf6b 100644 --- a/osu.Game/Configuration/ConfineMouseMode.cs +++ b/osu.Game/Configuration/ConfineMouseMode.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; namespace osu.Game.Configuration { public enum ConfineMouseMode diff --git a/osu.Game/Configuration/ProgressBarType.cs b/osu.Game/Configuration/ProgressBarType.cs index 8c971b7f18..a768b9f129 100644 --- a/osu.Game/Configuration/ProgressBarType.cs +++ b/osu.Game/Configuration/ProgressBarType.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 System.ComponentModel; namespace osu.Game.Configuration diff --git a/osu.Game/Configuration/RankingType.cs b/osu.Game/Configuration/RankingType.cs index 852904315e..ff504ba292 100644 --- a/osu.Game/Configuration/RankingType.cs +++ b/osu.Game/Configuration/RankingType.cs @@ -1,11 +1,10 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using System.ComponentModel; namespace osu.Game.Configuration -{ +{ public enum RankingType { Local, diff --git a/osu.Game/Configuration/ReleaseStream.cs b/osu.Game/Configuration/ReleaseStream.cs index cbab5d3ff2..b258ab2f37 100644 --- a/osu.Game/Configuration/ReleaseStream.cs +++ b/osu.Game/Configuration/ReleaseStream.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; namespace osu.Game.Configuration { public enum ReleaseStream diff --git a/osu.Game/Configuration/ScoreMeterType.cs b/osu.Game/Configuration/ScoreMeterType.cs index 596a63b1ef..8926f3ad81 100644 --- a/osu.Game/Configuration/ScoreMeterType.cs +++ b/osu.Game/Configuration/ScoreMeterType.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; namespace osu.Game.Configuration { public enum ScoreMeterType diff --git a/osu.Game/Configuration/ScreenshotFormat.cs b/osu.Game/Configuration/ScreenshotFormat.cs index c1a45d3479..1a1a3f8920 100644 --- a/osu.Game/Configuration/ScreenshotFormat.cs +++ b/osu.Game/Configuration/ScreenshotFormat.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 System.ComponentModel; namespace osu.Game.Configuration diff --git a/osu.Game/Database/BaseDifficulty.cs b/osu.Game/Database/BaseDifficulty.cs index 6baba3dedd..83f6e2fdd5 100644 --- a/osu.Game/Database/BaseDifficulty.cs +++ b/osu.Game/Database/BaseDifficulty.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 SQLite.Net.Attributes; namespace osu.Game.Database diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 566131acdd..ff58031c57 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -2,13 +2,12 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Security.Cryptography; +using osu.Framework.Logging; using osu.Framework.Platform; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Formats; @@ -24,6 +23,7 @@ namespace osu.Game.Database private SQLiteConnection connection { get; set; } private Storage storage; public event Action BeatmapSetAdded; + public event Action BeatmapSetRemoved; private BeatmapImporter ipc; @@ -39,16 +39,37 @@ namespace osu.Game.Database try { connection = prepareConnection(); + deletePending(); } - catch + catch (Exception e) { - Console.WriteLine(@"Failed to initialise the beatmap database! Trying again with a clean database..."); + Logger.Error(e, @"Failed to initialise the beatmap database! Trying again with a clean database..."); storage.DeleteDatabase(@"beatmaps"); connection = prepareConnection(); } } } + private void deletePending() + { + foreach (var b in Query().Where(b => b.DeletePending)) + { + try + { + storage.Delete(b.Path); + connection.Delete(b); + } + catch (Exception e) + { + Logger.Error(e, $@"Could not delete beatmap {b.ToString()}"); + } + } + + //this is required because sqlite migrations don't work, initially inserting nulls into this field. + //see https://github.com/praeclarum/sqlite-net/issues/326 + connection.Query("UPDATE BeatmapSetInfo SET DeletePending = 0 WHERE DeletePending IS NULL"); + } + private SQLiteConnection prepareConnection() { var conn = storage.GetDatabase(@"beatmaps"); @@ -98,10 +119,6 @@ namespace osu.Game.Database using (var reader = ArchiveReader.GetReader(storage, path)) metadata = reader.ReadMetadata(); - if (metadata.OnlineBeatmapSetID.HasValue && - connection.Table().Count(b => b.OnlineBeatmapSetID == metadata.OnlineBeatmapSetID) != 0) - return; // TODO: Update this beatmap instead - if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader { using (var md5 = MD5.Create()) @@ -110,10 +127,26 @@ namespace osu.Game.Database hash = BitConverter.ToString(md5.ComputeHash(input)).Replace("-", "").ToLowerInvariant(); input.Seek(0, SeekOrigin.Begin); path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash); - using (var output = storage.GetStream(path, FileAccess.Write)) - input.CopyTo(output); + if (!storage.Exists(path)) + using (var output = storage.GetStream(path, FileAccess.Write)) + input.CopyTo(output); } } + + var existing = connection.Table().FirstOrDefault(b => b.Hash == hash); + + if (existing != null) + { + if (existing.DeletePending) + { + existing.DeletePending = false; + Update(existing, false); + BeatmapSetAdded?.Invoke(existing); + } + + return; + } + var beatmapSet = new BeatmapSetInfo { OnlineBeatmapSetID = metadata.OnlineBeatmapSetID, @@ -148,15 +181,26 @@ namespace osu.Game.Database public void Import(IEnumerable beatmapSets) { - connection.BeginTransaction(); - - foreach (var s in beatmapSets) + lock (connection) { - connection.InsertWithChildren(s, true); - BeatmapSetAdded?.Invoke(s); - } + connection.BeginTransaction(); - connection.Commit(); + foreach (var s in beatmapSets) + { + connection.InsertWithChildren(s, true); + BeatmapSetAdded?.Invoke(s); + } + + connection.Commit(); + } + } + + public void Delete(BeatmapSetInfo beatmapSet) + { + beatmapSet.DeletePending = true; + Update(beatmapSet, false); + + BeatmapSetRemoved?.Invoke(beatmapSet); } public ArchiveReader GetReader(BeatmapSetInfo beatmapSet) @@ -185,19 +229,13 @@ namespace osu.Game.Database if (beatmapInfo.Metadata == null) beatmapInfo.Metadata = beatmapSetInfo.Metadata; - var working = new WorkingBeatmap(beatmapInfo, beatmapSetInfo, this, withStoryboard); + WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, beatmapSetInfo, withStoryboard); previous?.TransferTo(working); return working; } - public Beatmap GetBeatmap(BeatmapInfo beatmapInfo) - { - using (WorkingBeatmap data = GetWorkingBeatmap(beatmapInfo)) - return data.Beatmap; - } - public TableQuery Query() where T : class { return connection.Table(); @@ -239,5 +277,20 @@ namespace osu.Game.Database else connection.Update(record); } + + public bool Exists(BeatmapSetInfo beatmapSet) => storage.Exists(beatmapSet.Path); + + private class DatabaseWorkingBeatmap : WorkingBeatmap + { + private readonly BeatmapDatabase database; + + public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false) + : base(beatmapInfo, beatmapSetInfo, withStoryboard) + { + this.database = database; + } + + protected override ArchiveReader GetReader() => database?.GetReader(BeatmapSetInfo); + } } } diff --git a/osu.Game/Database/BeatmapInfo.cs b/osu.Game/Database/BeatmapInfo.cs index ec797d518e..c97b6653e0 100644 --- a/osu.Game/Database/BeatmapInfo.cs +++ b/osu.Game/Database/BeatmapInfo.cs @@ -5,7 +5,6 @@ using System; using System.Linq; using osu.Game.Beatmaps.Samples; using osu.Game.Modes; -using osu.Game.Screens.Play; using SQLite.Net.Attributes; using SQLiteNetExtensions.Attributes; using osu.Game.Beatmaps; @@ -74,7 +73,6 @@ namespace osu.Game.Database // Metadata public string Version { get; set; } - //todo: background threaded computation of this private float starDifficulty = -1; public float StarDifficulty { @@ -86,12 +84,6 @@ namespace osu.Game.Database set { starDifficulty = value; } } - internal void ComputeDifficulty(BeatmapDatabase database) - { - WorkingBeatmap wb = new WorkingBeatmap(this, BeatmapSet, database); - StarDifficulty = (float)Ruleset.GetRuleset(Mode).CreateDifficultyCalculator(wb.Beatmap).GetDifficulty(); - } - public bool Equals(BeatmapInfo other) { return ID == other?.ID; diff --git a/osu.Game/Database/BeatmapSetInfo.cs b/osu.Game/Database/BeatmapSetInfo.cs index a9c3f03a49..e4e9c35963 100644 --- a/osu.Game/Database/BeatmapSetInfo.cs +++ b/osu.Game/Database/BeatmapSetInfo.cs @@ -1,8 +1,8 @@ // 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.ComponentModel; using SQLite.Net.Attributes; using SQLiteNetExtensions.Attributes; @@ -24,6 +24,8 @@ namespace osu.Game.Database [OneToMany(CascadeOperations = CascadeOperation.All)] public List Beatmaps { get; set; } + public bool DeletePending { get; set; } + public string Hash { get; set; } public string Path { get; set; } diff --git a/osu.Game/Graphics/Backgrounds/Background.cs b/osu.Game/Graphics/Backgrounds/Background.cs index 5ff63ead2a..c35006f416 100644 --- a/osu.Game/Graphics/Backgrounds/Background.cs +++ b/osu.Game/Graphics/Backgrounds/Background.cs @@ -1,13 +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.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using OpenTK; using OpenTK.Graphics; namespace osu.Game.Graphics.Backgrounds diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index bc54fd8fdc..24f8f3076d 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -5,7 +5,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using osu.Framework.Input; using OpenTK; -using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics.Transformations; using osu.Game.Configuration; diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index 6995a7ab82..5d9745b8a2 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -2,9 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Diagnostics; using OpenTK.Graphics; -using osu.Framework.Graphics.Colour; namespace osu.Game.Graphics { diff --git a/osu.Game/Graphics/TextAwesome.cs b/osu.Game/Graphics/TextAwesome.cs index 07df1e1c94..03769e6f6b 100644 --- a/osu.Game/Graphics/TextAwesome.cs +++ b/osu.Game/Graphics/TextAwesome.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics.Sprites; -using OpenTK; namespace osu.Game.Graphics { diff --git a/osu.Game/Graphics/UserInterface/BackButton.cs b/osu.Game/Graphics/UserInterface/BackButton.cs index fa66527195..2b4b9cdb04 100644 --- a/osu.Game/Graphics/UserInterface/BackButton.cs +++ b/osu.Game/Graphics/UserInterface/BackButton.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Graphics; -using osu.Game.Graphics.Sprites; namespace osu.Game.Graphics.UserInterface { @@ -22,7 +21,7 @@ namespace osu.Game.Graphics.UserInterface private void load(AudioManager audio, OsuColour colours) { ActivationSound = audio.Sample.Get(@"Menu/menuback"); - Colour = colours.Pink; + BackgroundColour = colours.Pink; HoverColour = colours.PinkDark; } } diff --git a/osu.Game/Graphics/UserInterface/LoadingAnimation.cs b/osu.Game/Graphics/UserInterface/LoadingAnimation.cs index 42d23f40f8..61ec859b44 100644 --- a/osu.Game/Graphics/UserInterface/LoadingAnimation.cs +++ b/osu.Game/Graphics/UserInterface/LoadingAnimation.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 osu.Framework.Graphics.Sprites; namespace osu.Game.Graphics.UserInterface diff --git a/osu.Game/Graphics/UserInterface/OsuButton.cs b/osu.Game/Graphics/UserInterface/OsuButton.cs index 31f66407ce..4cb827661a 100644 --- a/osu.Game/Graphics/UserInterface/OsuButton.cs +++ b/osu.Game/Graphics/UserInterface/OsuButton.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.Allocation; using osu.Framework.Graphics; @@ -11,7 +10,6 @@ using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Sprites; -using osu.Game.Overlays; namespace osu.Game.Graphics.UserInterface { diff --git a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs index b05d005a1b..a2469afb53 100644 --- a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs @@ -2,21 +2,16 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Transformations; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Game.Graphics.Sprites; -using osu.Game.Overlays; -using OpenTK; using OpenTK.Graphics; namespace osu.Game.Graphics.UserInterface diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownHeader.cs b/osu.Game/Graphics/UserInterface/OsuDropDownHeader.cs index 56b883321a..3fc83afb52 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDownHeader.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropDownHeader.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK.Graphics; diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs index 3cbc1c8674..5bb2414bb3 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs @@ -1,11 +1,8 @@ // 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.ComponentModel; using System.Linq; -using System.Reflection; using osu.Framework.Graphics.Transformations; using osu.Framework.Graphics.UserInterface; using OpenTK; diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs index bbc8bd3e47..c2eb1fbc69 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK.Graphics; diff --git a/osu.Game/Graphics/UserInterface/PercentageCounter.cs b/osu.Game/Graphics/UserInterface/PercentageCounter.cs index 6b48dff26e..b0ccf63fcb 100644 --- a/osu.Game/Graphics/UserInterface/PercentageCounter.cs +++ b/osu.Game/Graphics/UserInterface/PercentageCounter.cs @@ -1,15 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Transformations; -using osu.Framework.Timing; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Game.Graphics.UserInterface { diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs index e81c8e945b..2cc1521a24 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -4,12 +4,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Transformations; using osu.Framework.MathUtils; -using osu.Framework.Timing; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Game.Graphics.UserInterface { diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index 528f443025..3c2e9c5cbc 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -2,26 +2,19 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using osu.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transformations; using osu.Framework.MathUtils; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using osu.Framework.Allocation; namespace osu.Game.Graphics.UserInterface { public class StarCounter : Container { - private readonly Container starContainer; - private readonly List stars = new List(); + private readonly Container stars; - private double transformStartTime = 0; + private double transformStartTime; /// /// Maximum amount of stars displayed. @@ -29,37 +22,20 @@ namespace osu.Game.Graphics.UserInterface /// /// This does not limit the counter value, but the amount of stars displayed. /// - public int MaxStars - { - get; - protected set; - } + public int StarCount { get; } private double animationDelay => 80; - private double scalingDuration => 500; + private double scalingDuration => 1000; private EasingTypes scalingEasing => EasingTypes.OutElasticHalf; - private float minStarScale => 0.3f; + private float minStarScale => 0.4f; private double fadingDuration => 100; private float minStarAlpha => 0.5f; - public float StarSize = 20; - public float StarSpacing = 4; + private const float star_size = 20; + private float star_spacing = 4; - public float VisibleValue - { - get - { - double elapsedTime = Time.Current - transformStartTime; - double expectedElapsedTime = Math.Abs(prevCount - count) * animationDelay; - if (elapsedTime >= expectedElapsedTime) - return count; - return Interpolation.ValueAt(elapsedTime, prevCount, count, 0, expectedElapsedTime); - } - } - - private float prevCount; private float count; /// @@ -74,119 +50,121 @@ namespace osu.Game.Graphics.UserInterface set { - if (IsLoaded) - { - prevCount = VisibleValue; - transformCount(prevCount, value); - } + if (count == value) return; + if (IsLoaded) + transformCount(value); count = value; } } - /// - /// Shows a float count as stars (up to 10). Used as star difficulty display. - /// - public StarCounter() : this(10) - { - AutoSizeAxes = Axes.Both; - } - /// /// Shows a float count as stars. Used as star difficulty display. /// - /// Maximum amount of stars to display. - public StarCounter(int maxstars) + /// Maximum amount of stars to display. + public StarCounter(int starCount = 10) { - MaxStars = Math.Max(maxstars, 0); + StarCount = Math.Max(starCount, 0); + + AutoSizeAxes = Axes.Both; Children = new Drawable[] { - starContainer = new Container + stars = new FlowContainer { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Direction = FlowDirections.Horizontal, + Spacing = new Vector2(star_spacing), } }; - starContainer.Width = MaxStars * StarSize + Math.Max(MaxStars - 1, 0) * StarSpacing; - starContainer.Height = StarSize; - - for (int i = 0; i < MaxStars; i++) + for (int i = 0; i < StarCount; i++) { - TextAwesome star = new TextAwesome + stars.Add(new Star { - Icon = FontAwesome.fa_star, - Anchor = Anchor.CentreLeft, - Origin = Anchor.Centre, - TextSize = StarSize, - Scale = new Vector2(minStarScale), Alpha = minStarAlpha, - Position = new Vector2((StarSize + StarSpacing) * i + (StarSize + StarSpacing) / 2, 0), - }; - - //todo: user Container once we have it. - stars.Add(star); - starContainer.Add(star); + }); } } protected override void LoadComplete() { base.LoadComplete(); + // Animate initial state from zero. - transformCount(0, Count); + ReplayAnimation(); } public void ResetCount() { - Count = 0; + count = 0; StopAnimation(); } + public void ReplayAnimation() + { + var t = count; + ResetCount(); + Count = t; + } + public void StopAnimation() { - prevCount = count; - transformStartTime = Time.Current; - - for (int i = 0; i < MaxStars; i++) - transformStarQuick(i, count); + int i = 0; + foreach (var star in stars.Children) + { + star.ClearTransformations(true); + star.FadeTo(i < count ? 1.0f : minStarAlpha); + star.Icon.ScaleTo(getStarScale(i, count)); + i++; + } } private float getStarScale(int i, float value) { if (value <= i) return minStarScale; - if (i + 1 <= value) - return 1.0f; - return Interpolation.ValueAt(value, minStarScale, 1.0f, i, i + 1); + + return i + 1 <= value ? 1.0f : Interpolation.ValueAt(value, minStarScale, 1.0f, i, i + 1); } - private void transformStar(int i, float value) + private void transformCount(float newValue) { - stars[i].FadeTo(i < value ? 1.0f : minStarAlpha, fadingDuration); - stars[i].ScaleTo(getStarScale(i, value), scalingDuration, scalingEasing); - } - - private void transformStarQuick(int i, float value) - { - stars[i].FadeTo(i < value ? 1.0f : minStarAlpha); - stars[i].ScaleTo(getStarScale(i, value)); - } - - private void transformCount(float currentValue, float newValue) - { - for (int i = 0; i < MaxStars; i++) + int i = 0; + foreach (var star in stars.Children) { - stars[i].ClearTransformations(); - if (currentValue <= newValue) - stars[i].Delay(Math.Max(i - currentValue, 0) * animationDelay); + star.ClearTransformations(true); + if (count <= newValue) + star.Delay(Math.Max(i - count, 0) * animationDelay, true); else - stars[i].Delay(Math.Max(currentValue - 1 - i, 0) * animationDelay); - transformStar(i, newValue); - stars[i].DelayReset(); + star.Delay(Math.Max(count - 1 - i, 0) * animationDelay, true); + + star.FadeTo(i < newValue ? 1.0f : minStarAlpha, fadingDuration); + star.Icon.ScaleTo(getStarScale(i, newValue), scalingDuration, scalingEasing); + star.DelayReset(); + + i++; + } + } + + class Star : Container + { + public TextAwesome Icon; + public Star() + { + Size = new Vector2(star_size); + + Children = new[] + { + Icon = new TextAwesome + { + TextSize = star_size, + Icon = FontAwesome.fa_star, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + } + }; } - transformStartTime = Time.Current; } } } diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 294d8533e4..cae2431898 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -35,7 +35,7 @@ namespace osu.Game.Graphics.UserInterface private Container c1; private Container c2; - public Color4 Colour + public Color4 BackgroundColour { set { diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs index 5f14e27441..8701cbb718 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs @@ -2,8 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input; diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControlReceptor.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeControlReceptor.cs index 0ba18d7a72..2a04e1c527 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControlReceptor.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControlReceptor.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input; using OpenTK.Input; -using OpenTK; namespace osu.Game.Graphics.UserInterface.Volume { diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs index 1caa2f7949..666bf95be5 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.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.Framework; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/IPC/BeatmapImporter.cs b/osu.Game/IPC/BeatmapImporter.cs index 73c47a1b97..b6ce4d1e35 100644 --- a/osu.Game/IPC/BeatmapImporter.cs +++ b/osu.Game/IPC/BeatmapImporter.cs @@ -21,13 +21,13 @@ namespace osu.Game.IPC channel.MessageReceived += messageReceived; } - public async Task Import(string path) + public async Task ImportAsync(string path) { if (beatmaps != null) beatmaps.Import(path); else { - await channel.SendMessage(new BeatmapImportMessage { Path = path }); + await channel.SendMessageAsync(new BeatmapImportMessage { Path = path }); } } @@ -35,7 +35,7 @@ namespace osu.Game.IPC { Debug.Assert(beatmaps != null); - Import(msg.Path); + ImportAsync(msg.Path); } } diff --git a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs index 173176d8b4..ca1967904a 100644 --- a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs @@ -4,12 +4,10 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Diagnostics; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; -using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps.Samples; using OpenTK; using Container = osu.Framework.Graphics.Containers.Container; diff --git a/osu.Game/Modes/Objects/Drawables/IDrawableHitObjectWithProxiedApproach.cs b/osu.Game/Modes/Objects/Drawables/IDrawableHitObjectWithProxiedApproach.cs index 9abd2f8592..33a1f51414 100644 --- a/osu.Game/Modes/Objects/Drawables/IDrawableHitObjectWithProxiedApproach.cs +++ b/osu.Game/Modes/Objects/Drawables/IDrawableHitObjectWithProxiedApproach.cs @@ -1,11 +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.Linq; -using System.Text; -using System.Threading.Tasks; using osu.Framework.Graphics; namespace osu.Game.Modes.Objects.Drawables diff --git a/osu.Game/Modes/Objects/HitObject.cs b/osu.Game/Modes/Objects/HitObject.cs index cdc5f1655d..eda6bc7e2a 100644 --- a/osu.Game/Modes/Objects/HitObject.cs +++ b/osu.Game/Modes/Objects/HitObject.cs @@ -4,7 +4,6 @@ using osu.Game.Beatmaps; using osu.Game.Beatmaps.Samples; using OpenTK.Graphics; -using osu.Game.Graphics; namespace osu.Game.Modes.Objects { diff --git a/osu.Game/Modes/Objects/HitObjectParser.cs b/osu.Game/Modes/Objects/HitObjectParser.cs index 724e516de1..4020c1c069 100644 --- a/osu.Game/Modes/Objects/HitObjectParser.cs +++ b/osu.Game/Modes/Objects/HitObjectParser.cs @@ -1,11 +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.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Game.Modes.Objects { diff --git a/osu.Game/Modes/Score.cs b/osu.Game/Modes/Score.cs index 3ee157068c..df1b65872f 100644 --- a/osu.Game/Modes/Score.cs +++ b/osu.Game/Modes/Score.cs @@ -1,11 +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.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Game.Modes { diff --git a/osu.Game/Modes/ScoreProcesssor.cs b/osu.Game/Modes/ScoreProcesssor.cs index 36baf36693..eb4514f40d 100644 --- a/osu.Game/Modes/ScoreProcesssor.cs +++ b/osu.Game/Modes/ScoreProcesssor.cs @@ -3,9 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using osu.Framework.Configuration; using osu.Game.Modes.Objects.Drawables; diff --git a/osu.Game/Online/API/IOnlineComponent.cs b/osu.Game/Online/API/IOnlineComponent.cs index 620e46640b..a4d25613b8 100644 --- a/osu.Game/Online/API/IOnlineComponent.cs +++ b/osu.Game/Online/API/IOnlineComponent.cs @@ -1,11 +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.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Game.Online.API { diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs index 2445f3101a..0ee7e0e030 100644 --- a/osu.Game/Online/API/OAuth.cs +++ b/osu.Game/Online/API/OAuth.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 System.Diagnostics; using osu.Framework.IO.Network; diff --git a/osu.Game/Online/API/SecurePassword.cs b/osu.Game/Online/API/SecurePassword.cs index ed40f7ec18..e3e46ba6dc 100644 --- a/osu.Game/Online/API/SecurePassword.cs +++ b/osu.Game/Online/API/SecurePassword.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 System.Diagnostics; using System.Security; using osu.Framework.Extensions; diff --git a/osu.Game/Online/Chat/Drawables/ChatLine.cs b/osu.Game/Online/Chat/Drawables/ChatLine.cs index 7c6b079eb0..c55dcc6620 100644 --- a/osu.Game/Online/Chat/Drawables/ChatLine.cs +++ b/osu.Game/Online/Chat/Drawables/ChatLine.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.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; diff --git a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs index 5b8d034e9d..84d15967e4 100644 --- a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs +++ b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs @@ -7,10 +7,8 @@ using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; -using osu.Framework.MathUtils; using osu.Framework.Threading; using osu.Game.Graphics.Sprites; -using OpenTK; namespace osu.Game.Online.Chat.Drawables { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 1a0f08ffb8..49f1353ab7 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -25,6 +25,7 @@ using OpenTK; using System.Linq; using osu.Framework.Graphics.Primitives; using System.Collections.Generic; +using System.Threading.Tasks; using osu.Game.Overlays.Notifications; namespace osu.Game @@ -81,7 +82,7 @@ namespace osu.Game if (args?.Length > 0) { var paths = args.Where(a => !a.StartsWith(@"-")); - ImportBeatmaps(paths); + ImportBeatmapsAsync(paths); } Dependencies.Cache(this); @@ -89,9 +90,9 @@ namespace osu.Game PlayMode = LocalConfig.GetBindable(OsuConfig.PlayMode); } - public void ImportBeatmaps(IEnumerable paths) + protected async void ImportBeatmapsAsync(IEnumerable paths) { - Schedule(delegate { Dependencies.Get().Import(paths); }); + await Task.Run(() => BeatmapDatabase.Import(paths)); } protected override void LoadComplete() @@ -116,7 +117,7 @@ namespace osu.Game } }); - (screenStack = new Loader()).Preload(this, d => + (screenStack = new Loader()).LoadAsync(this, d => { screenStack.ModePushed += screenAdded; screenStack.Exited += screenRemoved; @@ -124,22 +125,22 @@ namespace osu.Game }); //overlay elements - (chat = new ChatOverlay { Depth = 0 }).Preload(this, overlayContent.Add); - (options = new OptionsOverlay { Depth = -1 }).Preload(this, overlayContent.Add); + (chat = new ChatOverlay { Depth = 0 }).LoadAsync(this, overlayContent.Add); + (options = new OptionsOverlay { Depth = -1 }).LoadAsync(this, overlayContent.Add); (musicController = new MusicController() { Depth = -2, Position = new Vector2(0, Toolbar.HEIGHT), Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - }).Preload(this, overlayContent.Add); + }).LoadAsync(this, overlayContent.Add); (notificationManager = new NotificationManager { Depth = -2, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - }).Preload(this, overlayContent.Add); + }).LoadAsync(this, overlayContent.Add); Logger.NewEntry += entry => { @@ -160,7 +161,7 @@ namespace osu.Game Depth = -3, OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); }, OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; }, - }).Preload(this, t => + }).LoadAsync(this, t => { PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); }; PlayMode.TriggerChange(); diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index ca11d3659f..1c34743567 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.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.Framework; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -24,6 +23,8 @@ namespace osu.Game { protected OsuConfigManager LocalConfig; + protected BeatmapDatabase BeatmapDatabase; + protected override string MainResourceFile => @"osu.Game.Resources.dll"; public APIAccess API; @@ -41,7 +42,7 @@ namespace osu.Game { Dependencies.Cache(this); Dependencies.Cache(LocalConfig); - Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host)); + Dependencies.Cache(BeatmapDatabase = new BeatmapDatabase(Host.Storage, Host)); Dependencies.Cache(new OsuColour()); //this completely overrides the framework default. will need to change once we make a proper FontStore. diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index e0e43fbe64..6b7963ed1b 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -12,7 +12,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Framework.Threading; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Online.API; using osu.Game.Online.API.Requests; diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index 22c61cd372..178cea0a88 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Game.Graphics; using osu.Game.Overlays.Options.Sections.General; -using OpenTK; using OpenTK.Graphics; namespace osu.Game.Overlays diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 03575a10f0..aa6b3c6247 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using OpenTK; using OpenTK.Graphics; -using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Track; @@ -23,7 +22,6 @@ using osu.Game.Configuration; using osu.Game.Database; using osu.Game.Graphics; using osu.Framework.Graphics.Primitives; -using osu.Framework.Threading; using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays @@ -256,14 +254,16 @@ namespace osu.Game.Overlays { progress.IsEnabled = (beatmapSource.Value != null); if (beatmapSource.Value == current) return; - bool audioEquals = current?.BeatmapInfo.AudioEquals(beatmapSource.Value.BeatmapInfo) ?? false; + bool audioEquals = current?.BeatmapInfo?.AudioEquals(beatmapSource?.Value?.BeatmapInfo) ?? false; current = beatmapSource.Value; updateDisplay(current, audioEquals ? TransformDirection.None : TransformDirection.Next); - appendToHistory(current.BeatmapInfo); + appendToHistory(current?.BeatmapInfo); } private void appendToHistory(BeatmapInfo beatmap) { + if (beatmap == null) return; + if (playHistoryIndex >= 0) { if (beatmap.AudioEquals(playHistory[playHistoryIndex])) @@ -322,10 +322,10 @@ namespace osu.Game.Overlays updateDisplay(current, isNext ? TransformDirection.Next : TransformDirection.Prev); } - protected override void PerformLoad(Framework.Game game) + protected override void Load(Framework.Game game) { this.game = game; - base.PerformLoad(game); + base.Load(game); } Action pendingBeatmapSwitch; @@ -349,7 +349,7 @@ namespace osu.Game.Overlays MusicControllerBackground newBackground; - (newBackground = new MusicControllerBackground(beatmap)).Preload(game, delegate + (newBackground = new MusicControllerBackground(beatmap)).LoadAsync(game, delegate { dragContainer.Add(newBackground); diff --git a/osu.Game/Overlays/Notifications/ProgressCompletionNotification.cs b/osu.Game/Overlays/Notifications/ProgressCompletionNotification.cs index 61525ed019..492a948143 100644 --- a/osu.Game/Overlays/Notifications/ProgressCompletionNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressCompletionNotification.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Game.Graphics; using osu.Framework.Graphics.Colour; -using OpenTK.Graphics; namespace osu.Game.Overlays.Notifications diff --git a/osu.Game/Overlays/Notifications/ProgressNotification.cs b/osu.Game/Overlays/Notifications/ProgressNotification.cs index 28a0d8a0af..47fa2de33f 100644 --- a/osu.Game/Overlays/Notifications/ProgressNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressNotification.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Overlays/Options/OptionEnumDropDown.cs b/osu.Game/Overlays/Options/OptionEnumDropDown.cs index 044e704d3a..50d1d36b4c 100644 --- a/osu.Game/Overlays/Options/OptionEnumDropDown.cs +++ b/osu.Game/Overlays/Options/OptionEnumDropDown.cs @@ -2,14 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.Configuration; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; using System.Reflection; using System.ComponentModel; using System.Collections.Generic; diff --git a/osu.Game/Overlays/Options/OptionLabel.cs b/osu.Game/Overlays/Options/OptionLabel.cs index 81bed0cb31..bfe59eb035 100644 --- a/osu.Game/Overlays/Options/OptionLabel.cs +++ b/osu.Game/Overlays/Options/OptionLabel.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; -using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Overlays/Options/OptionSlider.cs b/osu.Game/Overlays/Options/OptionSlider.cs index 32ce420e7e..0e5d9f915c 100644 --- a/osu.Game/Overlays/Options/OptionSlider.cs +++ b/osu.Game/Overlays/Options/OptionSlider.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 OpenTK.Graphics; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Overlays/Options/OptionsSubsection.cs b/osu.Game/Overlays/Options/OptionsSubsection.cs index 37cb6d01c1..4d8be559a7 100644 --- a/osu.Game/Overlays/Options/OptionsSubsection.cs +++ b/osu.Game/Overlays/Options/OptionsSubsection.cs @@ -5,7 +5,6 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Sprites; using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Options diff --git a/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs b/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs index 6866ee513f..34f42aac43 100644 --- a/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs +++ b/osu.Game/Overlays/Options/Sections/General/LoginOptions.cs @@ -5,7 +5,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Configuration; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Overlays/Options/Sidebar.cs b/osu.Game/Overlays/Options/Sidebar.cs index ffc3d04756..33906a064c 100644 --- a/osu.Game/Overlays/Options/Sidebar.cs +++ b/osu.Game/Overlays/Options/Sidebar.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 osu.Framework.Graphics; @@ -10,7 +9,6 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Framework.Input; using osu.Framework.Threading; -using osu.Game.Graphics; using osu.Game.Overlays.Toolbar; namespace osu.Game.Overlays.Options diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index 68786b00e8..ab3d561e00 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -1,20 +1,14 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Diagnostics; using System.Linq; -using OpenTK; using OpenTK.Graphics; -using OpenTK.Input; -using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; -using osu.Framework.Input; -using osu.Game.Configuration; using osu.Game.Overlays.Options; using System; using osu.Game.Graphics; diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index a915fe91dd..675b6e6646 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -12,7 +12,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transformations; -using System.Threading.Tasks; using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Pause diff --git a/osu.Game/Overlays/Toolbar/ToolbarHomeButton.cs b/osu.Game/Overlays/Toolbar/ToolbarHomeButton.cs index 438aec6e0b..4dca6b7a16 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarHomeButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarHomeButton.cs @@ -1,9 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Allocation; using osu.Game.Graphics; -using osu.Game.Screens.Menu; namespace osu.Game.Overlays.Toolbar { diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index d8ad235cec..6ef737c25f 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -9,11 +9,9 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; -using osu.Game.Graphics.Backgrounds; using osu.Game.Modes; using OpenTK; using OpenTK.Graphics; -using osu.Game.Graphics; namespace osu.Game.Overlays.Toolbar { diff --git a/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs b/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs index 428cc206b7..c4a9c51349 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs @@ -1,22 +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.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using osu.Framework; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; -using osu.Game.Configuration; -using osu.Game.Online.API; -using OpenTK; -using OpenTK.Graphics; using osu.Game.Graphics; namespace osu.Game.Overlays.Toolbar diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs index 921c2d26df..e3f20d26a4 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs @@ -102,7 +102,7 @@ namespace osu.Game.Overlays.Toolbar newSprite.FillMode = FillMode.Fit; - newSprite.Preload(game, s => + newSprite.LoadAsync(game, s => { Sprite?.FadeOut(); Sprite?.Expire(); @@ -120,7 +120,6 @@ namespace osu.Game.Overlays.Toolbar public class OnlineSprite : Sprite { private readonly string url; - private readonly int userId; public OnlineSprite(string url) { diff --git a/osu.Game/Properties/AssemblyInfo.cs b/osu.Game/Properties/AssemblyInfo.cs index 76b7899b0e..f6bbc91854 100644 --- a/osu.Game/Properties/AssemblyInfo.cs +++ b/osu.Game/Properties/AssemblyInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/osu.Game/Screens/BackgroundScreen.cs b/osu.Game/Screens/BackgroundScreen.cs index 5b79158946..fb934551e1 100644 --- a/osu.Game/Screens/BackgroundScreen.cs +++ b/osu.Game/Screens/BackgroundScreen.cs @@ -3,7 +3,6 @@ using System; using System.Threading; -using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Screens; using osu.Framework.Graphics; @@ -43,7 +42,7 @@ namespace osu.Game.Screens // once it's done. if (screen.LoadState == LoadState.NotLoaded) { - screen.Preload(game, d => Push((BackgroundScreen)d)); + screen.LoadAsync(game, d => Push((BackgroundScreen)d)); return true; } diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index f0c5c47797..2856d52113 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -36,7 +36,7 @@ namespace osu.Game.Screens.Backgrounds else newBackground = new BeatmapBackground(beatmap); - newBackground.Preload(Game, delegate + newBackground.LoadAsync(Game, delegate { float newDepth = 0; if (background != null) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index d4781146c3..005efb77a2 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.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.Framework; using osu.Framework.Allocation; using osu.Game.Graphics.Backgrounds; diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index 33094b7098..a3c7be8453 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -20,9 +20,9 @@ namespace osu.Game.Screens private void load(OsuGame game) { if (game.IsDeployedBuild) - new Disclaimer().Preload(game, d => Push((Screen)d)); + new Disclaimer().LoadAsync(game, d => Push((Screen)d)); else - new Intro().Preload(game, d => Push((Screen)d)); + new Intro().LoadAsync(game, d => Push((Screen)d)); } } } diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index a203638478..0118a7fd41 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -7,7 +7,6 @@ using System.Linq; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; -using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index c5c00d5037..56074dbdfd 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -1,11 +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.Linq; -using System.Text; -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -93,7 +88,7 @@ namespace osu.Game.Screens.Menu [BackgroundDependencyLoader] private void load(OsuGame game, OsuColour colours) { - (intro = new Intro()).Preload(game); + (intro = new Intro()).LoadAsync(game); iconColour = colours.Yellow; } diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index c69dfff7db..6d513c1286 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -77,7 +77,7 @@ namespace osu.Game.Screens.Menu { bgm.Start(); - (mainMenu = new MainMenu()).Preload(Game); + (mainMenu = new MainMenu()).LoadAsync(Game); Scheduler.AddDelayed(delegate { diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 1a6310ea4e..c0ccbd044e 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -56,7 +56,7 @@ namespace osu.Game.Screens.Menu [BackgroundDependencyLoader] private void load(OsuGame game) { - background.Preload(game); + background.LoadAsync(game); buttons.OnSettings = game.ToggleOptions; } diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 2035ec17ce..a3b852e7a4 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -2,18 +2,15 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Transformations; using osu.Framework.Input; -using osu.Framework.MathUtils; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; using OpenTK; diff --git a/osu.Game/Screens/Play/FailDialog.cs b/osu.Game/Screens/Play/FailDialog.cs index 622dd0a44a..018cd72a9d 100644 --- a/osu.Game/Screens/Play/FailDialog.cs +++ b/osu.Game/Screens/Play/FailDialog.cs @@ -3,11 +3,7 @@ using osu.Framework.Screens; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Transformations; using osu.Game.Graphics.Sprites; -using osu.Game.Modes; using osu.Game.Screens.Backgrounds; using OpenTK; using OpenTK.Graphics; diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 2359dcdcfa..35154b2f45 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -20,7 +20,6 @@ using osu.Game.Overlays.Pause; using osu.Framework.Configuration; using System; using System.Linq; -using osu.Game.Beatmaps; using OpenTK.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transformations; @@ -229,7 +228,7 @@ namespace osu.Game.Screens.Play var newPlayer = new Player(); - newPlayer.Preload(Game, delegate + newPlayer.LoadAsync(Game, delegate { newPlayer.RestartCount = RestartCount + 1; ValidForResume = false; @@ -313,6 +312,9 @@ namespace osu.Game.Screens.Play } else { + FadeOut(250); + Content.ScaleTo(0.7f, 750, EasingTypes.InQuint); + dimLevel.ValueChanged -= dimChanged; Background?.FadeTo(1f, 200); return base.OnExiting(next); diff --git a/osu.Game/Screens/Play/PlayerInputManager.cs b/osu.Game/Screens/Play/PlayerInputManager.cs index 20fd4deed3..181cd68da9 100644 --- a/osu.Game/Screens/Play/PlayerInputManager.cs +++ b/osu.Game/Screens/Play/PlayerInputManager.cs @@ -7,7 +7,6 @@ using osu.Framework.Configuration; using osu.Framework.Input; using osu.Framework.Platform; using osu.Game.Configuration; -using System; using System.Linq; namespace osu.Game.Screens.Play diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 294eecd5fa..87d6a82404 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -1,11 +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.Linq; -using System.Text; -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -14,7 +9,6 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Framework.Screens; using osu.Game.Beatmaps; -using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Screens.Backgrounds; @@ -57,7 +51,7 @@ namespace osu.Game.Screens.Play Origin = Anchor.Centre, }); - player.Preload(Game); + player.LoadAsync(Game); } protected override void OnEntering(Screen last) @@ -86,6 +80,8 @@ namespace osu.Game.Screens.Play Schedule(() => { + if (!IsCurrentScreen) return; + if (!Push(player)) Exit(); }); @@ -95,6 +91,12 @@ namespace osu.Game.Screens.Play { Content.ScaleTo(0.7f, 150, EasingTypes.InQuint); FadeOut(150); + + //OsuScreens are currently never finalised due to the Bindable bindings. + //can be removed once we solve that one. + if (player != null && player.LoadState != LoadState.Alive) + player.Dispose(); + return base.OnExiting(next); } diff --git a/osu.Game/Screens/Play/SkipButton.cs b/osu.Game/Screens/Play/SkipButton.cs index fab2210757..f57bbd4cb0 100644 --- a/osu.Game/Screens/Play/SkipButton.cs +++ b/osu.Game/Screens/Play/SkipButton.cs @@ -13,8 +13,6 @@ namespace osu.Game.Screens.Play { public class SkipButton : TwoLayerButton { - private readonly double skipDestination; - public SkipButton() { Text = @"Skip"; @@ -27,7 +25,7 @@ namespace osu.Game.Screens.Play private void load(AudioManager audio, OsuColour colours) { ActivationSound = audio.Sample.Get(@"Menu/menuhit"); - Colour = colours.Yellow; + BackgroundColour = colours.Yellow; HoverColour = colours.YellowDark; } diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 119bc49e1a..9f5e1f8e5f 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -4,7 +4,6 @@ using osu.Framework.Screens; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Game.Graphics.Sprites; using osu.Game.Modes; diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index eb93b4ac1a..7856d0b031 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using osu.Framework; using osu.Framework.Allocation; using OpenTK; using OpenTK.Graphics; @@ -19,7 +18,6 @@ using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.MathUtils; using osu.Game.Graphics; -using osu.Game.Beatmaps.Timing; using osu.Game.Graphics.Sprites; using osu.Game.Modes; @@ -179,7 +177,7 @@ namespace osu.Game.Screens.Select } }, } - }).Preload(game, delegate (Drawable d) + }).LoadAsync(game, delegate (Drawable d) { FadeIn(250); diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 86cfc89763..bd477f7fdd 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using osu.Framework.Caching; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transformations; @@ -10,7 +9,6 @@ using osu.Game.Database; using System; using System.Collections.Generic; using System.Linq; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Lists; using osu.Game.Beatmaps.Drawables; using osu.Framework.Timing; @@ -97,6 +95,15 @@ namespace osu.Game.Screens.Select computeYPositions(); } + public void RemoveGroup(BeatmapGroup group) + { + groups.Remove(group); + scrollableContent.Remove(group.Header); + scrollableContent.Remove(group.BeatmapPanels); + + computeYPositions(); + } + private void movePanel(Panel panel, bool advance, bool animated, ref float currentY) { yPositions.Add(currentY); @@ -278,6 +285,12 @@ namespace osu.Game.Screens.Select if (direction == 0) return base.OnKeyDown(state, args); + SelectNext(direction, skipDifficulties); + return true; + } + + public void SelectNext(int direction = 1, bool skipDifficulties = true) + { if (!skipDifficulties) { int i = SelectedGroup.BeatmapPanels.IndexOf(SelectedPanel) + direction; @@ -286,7 +299,7 @@ namespace osu.Game.Screens.Select { //changing difficulty panel, not set. SelectGroup(SelectedGroup, SelectedGroup.BeatmapPanels[i]); - return true; + return; } } @@ -299,11 +312,9 @@ namespace osu.Game.Screens.Select if (groups[index].State != BeatmapGroupState.Hidden) { SelectBeatmap(groups[index].BeatmapPanels.First().Beatmap); - return true; + return; } } while (index != startIndex); - - return true; } public void SelectRandom() diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 83c4a97e6a..ff8bf24ec6 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -18,7 +18,6 @@ using osu.Game.Modes; using osu.Game.Screens.Backgrounds; using OpenTK; using osu.Game.Screens.Play; -using osu.Framework; using osu.Framework.Audio.Sample; using osu.Framework.Graphics.Transformations; using osu.Game.Beatmaps.Drawables; @@ -27,7 +26,6 @@ using osu.Game.Graphics; using osu.Framework.Input; using OpenTK.Input; using System.Collections.Generic; -using osu.Framework.Graphics.Containers; using osu.Framework.Threading; namespace osu.Game.Screens.Select @@ -122,7 +120,7 @@ namespace osu.Game.Screens.Select { BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap, PreferredPlayMode = playMode.Value - })).Preload(Game, l => Push(player)); + })).LoadAsync(Game, l => Push(player)); } } }; @@ -140,7 +138,8 @@ namespace osu.Game.Screens.Select if (database == null) database = beatmaps; - database.BeatmapSetAdded += onDatabaseOnBeatmapSetAdded; + database.BeatmapSetAdded += onBeatmapSetAdded; + database.BeatmapSetRemoved += onBeatmapSetRemoved; trackManager = audio.Track; @@ -186,10 +185,9 @@ namespace osu.Game.Screens.Select }, 250); } - private void onDatabaseOnBeatmapSetAdded(BeatmapSetInfo s) - { - Schedule(() => addBeatmapSet(s, Game, true)); - } + private void onBeatmapSetAdded(BeatmapSetInfo s) => Schedule(() => addBeatmapSet(s, Game, true)); + + private void onBeatmapSetRemoved(BeatmapSetInfo s) => Schedule(() => removeBeatmapSet(s)); protected override void OnEntering(Screen last) { @@ -248,7 +246,8 @@ namespace osu.Game.Screens.Select if (playMode != null) playMode.ValueChanged -= playMode_ValueChanged; - database.BeatmapSetAdded -= onDatabaseOnBeatmapSetAdded; + database.BeatmapSetAdded -= onBeatmapSetAdded; + database.BeatmapSetRemoved -= onBeatmapSetRemoved; initialAddSetsTask.Cancel(); } @@ -280,7 +279,7 @@ namespace osu.Game.Screens.Select //todo: change background in selectionChanged instead; support per-difficulty backgrounds. changeBackground(beatmap); - carousel.SelectBeatmap(beatmap.BeatmapInfo); + carousel.SelectBeatmap(beatmap?.BeatmapInfo); } /// @@ -326,13 +325,7 @@ namespace osu.Game.Screens.Select if (b.Metadata == null) b.Metadata = beatmapSet.Metadata; }); - foreach (var b in beatmapSet.Beatmaps) - b.ComputeDifficulty(database); - beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.StarDifficulty).ToList(); - - var beatmap = new WorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault(), beatmapSet, database); - - var group = new BeatmapGroup(beatmap) + var group = new BeatmapGroup(beatmapSet, database) { SelectionChanged = selectionChanged, StartRequested = b => footer.StartButton.TriggerClick() @@ -340,7 +333,7 @@ namespace osu.Game.Screens.Select //for the time being, let's completely load the difficulty panels in the background. //this likely won't scale so well, but allows us to completely async the loading flow. - Task.WhenAll(group.BeatmapPanels.Select(panel => panel.Preload(game))).ContinueWith(task => Schedule(delegate + Task.WhenAll(group.BeatmapPanels.Select(panel => panel.LoadAsync(game))).ContinueWith(task => Schedule(delegate { beatmapGroups.Add(group); @@ -357,9 +350,24 @@ namespace osu.Game.Screens.Select })); } + private void removeBeatmapSet(BeatmapSetInfo beatmapSet) + { + var group = beatmapGroups.Find(b => b.BeatmapSet.ID == beatmapSet.ID); + if (group == null) return; + + if (carousel.SelectedGroup == group) + carousel.SelectNext(); + + beatmapGroups.Remove(group); + carousel.RemoveGroup(group); + + if (beatmapGroups.Count == 0) + Beatmap = null; + } + private void addBeatmapSets(Framework.Game game, CancellationToken token) { - foreach (var beatmapSet in database.Query()) + foreach (var beatmapSet in database.Query().Where(b => !b.DeletePending)) { if (token.IsCancellationRequested) return; addBeatmapSet(beatmapSet, game); @@ -373,6 +381,13 @@ namespace osu.Game.Screens.Select case Key.Enter: footer.StartButton.TriggerClick(); return true; + case Key.Delete: + if (Beatmap != null) + { + Beatmap.Dispose(); + database.Delete(Beatmap.BeatmapSetInfo); + } + return true; } return base.OnKeyDown(state, args); diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Screens/Select/SearchTextBox.cs index aeb9db75db..bb1edfd0d7 100644 --- a/osu.Game/Screens/Select/SearchTextBox.cs +++ b/osu.Game/Screens/Select/SearchTextBox.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.Linq; -using OpenTK.Graphics; using OpenTK.Input; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; @@ -52,6 +49,15 @@ namespace osu.Game.Screens.Select } } + if (state.Keyboard.ShiftPressed) + { + switch (args.Key) + { + case Key.Delete: + return false; + } + } + return base.OnKeyDown(state, args); } } diff --git a/osu.Game/Users/User.cs b/osu.Game/Users/User.cs index c931e9b2c1..5928d6106c 100644 --- a/osu.Game/Users/User.cs +++ b/osu.Game/Users/User.cs @@ -1,11 +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.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Game.Users {