From 99574ecad81e3294ea21c963ad139df1b3b3b381 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 24 Aug 2018 17:57:39 +0900 Subject: [PATCH 01/23] Softly handle errors when no beatmap file exists in archive --- osu.Game/Beatmaps/BeatmapManager.cs | 5 ++--- osu.Game/Database/ArchiveModelManager.cs | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 1a2b5eadd9..3a12f26863 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -352,9 +352,8 @@ namespace osu.Game.Beatmaps string mapName = reader.Filenames.FirstOrDefault(f => f.EndsWith(".osu")); if (string.IsNullOrEmpty(mapName)) { - // Todo: This is temporary for debugging purposes - var files = reader.Filenames.ToList(); - throw new InvalidOperationException($"No beatmap files found in this beatmap archive. Files ({files.Count}): {string.Join(", ", files)}"); + Logger.Log($"No beatmap files found in the beatmap archive ({reader.Name}). Skipping."); + return null; } Beatmap beatmap; diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index ac79a8f565..42dd6684d5 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -178,7 +178,8 @@ namespace osu.Game.Database { try { - return Import(CreateModel(archive), archive); + var model = CreateModel(archive); + return model == null ? null : Import(model, archive); } catch (Exception e) { From aeb4d47c06e57485ecb23f249133e804bf82b076 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 24 Aug 2018 18:07:39 +0900 Subject: [PATCH 02/23] Remove skipping part of message --- osu.Game/Beatmaps/BeatmapManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 3a12f26863..d2be36e991 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -352,7 +352,7 @@ namespace osu.Game.Beatmaps string mapName = reader.Filenames.FirstOrDefault(f => f.EndsWith(".osu")); if (string.IsNullOrEmpty(mapName)) { - Logger.Log($"No beatmap files found in the beatmap archive ({reader.Name}). Skipping."); + Logger.Log($"No beatmap files found in the beatmap archive ({reader.Name})."); return null; } From 26dfabc86c1d90c575eaf6d8523fb685708e0f67 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 24 Aug 2018 23:57:44 +0900 Subject: [PATCH 03/23] Aggressively check for valid columns before iterating endlessly --- .../Legacy/DistanceObjectPatternGenerator.cs | 58 +++----------- .../Legacy/EndTimeObjectPatternGenerator.cs | 21 +---- .../Legacy/HitObjectPatternGenerator.cs | 34 ++++---- .../Patterns/Legacy/PatternGenerator.cs | 79 +++++++++++++++++++ .../Beatmaps/Patterns/PatternGenerator.cs | 45 ----------- 5 files changed, 110 insertions(+), 127 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 010cf962cc..37a8062d75 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -173,26 +173,18 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy var pattern = new Pattern(); int usableColumns = TotalColumns - RandomStart - PreviousPattern.ColumnWithObjects; - int nextColumn = Random.Next(RandomStart, TotalColumns); + int nextColumn = GetRandomColumn(); for (int i = 0; i < Math.Min(usableColumns, noteCount); i++) { // Find available column - RunWhile(() => pattern.ColumnHasObject(nextColumn) || PreviousPattern.ColumnHasObject(nextColumn), () => - { - nextColumn = Random.Next(RandomStart, TotalColumns); - }); - + nextColumn = FindAvailableColumn(nextColumn, pattern, PreviousPattern); addToPattern(pattern, nextColumn, startTime, EndTime); } // This is can't be combined with the above loop due to RNG for (int i = 0; i < noteCount - usableColumns; i++) { - RunWhile(() => pattern.ColumnHasObject(nextColumn), () => - { - nextColumn = Random.Next(RandomStart, TotalColumns); - }); - + nextColumn = FindAvailableColumn(nextColumn, pattern); addToPattern(pattern, nextColumn, startTime, EndTime); } @@ -217,23 +209,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); if (convertType.HasFlag(PatternType.ForceNotStack) && PreviousPattern.ColumnWithObjects < TotalColumns) - { - RunWhile(() => PreviousPattern.ColumnHasObject(nextColumn), () => - { - nextColumn = Random.Next(RandomStart, TotalColumns); - }); - } + nextColumn = FindAvailableColumn(nextColumn, PreviousPattern); int lastColumn = nextColumn; for (int i = 0; i < noteCount; i++) { addToPattern(pattern, nextColumn, startTime, startTime); - - RunWhile(() => nextColumn == lastColumn, () => - { - nextColumn = Random.Next(RandomStart, TotalColumns); - }); - + nextColumn = FindAvailableColumn(nextColumn, validation: c => c != lastColumn); lastColumn = nextColumn; startTime += SegmentDuration; } @@ -325,7 +307,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy if (TotalColumns > 2) addToPattern(pattern, nextColumn, startTime, startTime); - nextColumn = Random.Next(RandomStart, TotalColumns); + nextColumn = GetRandomColumn(); startTime += SegmentDuration; } @@ -404,20 +386,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); if (convertType.HasFlag(PatternType.ForceNotStack) && PreviousPattern.ColumnWithObjects < TotalColumns) - { - RunWhile(() => PreviousPattern.ColumnHasObject(nextColumn), () => - { - nextColumn = Random.Next(RandomStart, TotalColumns); - }); - } + nextColumn = FindAvailableColumn(nextColumn, PreviousPattern); for (int i = 0; i < columnRepeat; i++) { - RunWhile(() => pattern.ColumnHasObject(nextColumn), () => - { - nextColumn = Random.Next(RandomStart, TotalColumns); - }); - + nextColumn = FindAvailableColumn(nextColumn, pattern); addToPattern(pattern, nextColumn, startTime, EndTime); startTime += SegmentDuration; } @@ -442,17 +415,12 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy int holdColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); if (convertType.HasFlag(PatternType.ForceNotStack) && PreviousPattern.ColumnWithObjects < TotalColumns) - { - RunWhile(() => PreviousPattern.ColumnHasObject(holdColumn), () => - { - holdColumn = Random.Next(RandomStart, TotalColumns); - }); - } + holdColumn = FindAvailableColumn(holdColumn, PreviousPattern); // Create the hold note addToPattern(pattern, holdColumn, startTime, EndTime); - int nextColumn = Random.Next(RandomStart, TotalColumns); + int nextColumn = GetRandomColumn(); int noteCount; if (ConversionDifficulty > 6.5) noteCount = GetRandomNoteCount(0.63, 0); @@ -473,11 +441,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { for (int j = 0; j < noteCount; j++) { - RunWhile(() => rowPattern.ColumnHasObject(nextColumn) || nextColumn == holdColumn, () => - { - nextColumn = Random.Next(RandomStart, TotalColumns); - }); - + nextColumn = FindAvailableColumn(nextColumn, validation: c => c != holdColumn, patterns: rowPattern); addToPattern(rowPattern, nextColumn, startTime, startTime); } } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs index eae9a0fc3b..775a4145e6 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs @@ -39,34 +39,17 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy addToPattern(pattern, 0, generateHold); break; case 8: - addToPattern(pattern, getNextRandomColumn(RandomStart), generateHold); + addToPattern(pattern, FindAvailableColumn(GetRandomColumn(), PreviousPattern), generateHold); break; default: if (TotalColumns > 0) - addToPattern(pattern, getNextRandomColumn(0), generateHold); + addToPattern(pattern, GetRandomColumn(), generateHold); break; } return pattern; } - /// - /// Picks a random column after a column. - /// - /// The starting column. - /// A random column after . - private int getNextRandomColumn(int start) - { - int nextColumn = Random.Next(start, TotalColumns); - - RunWhile(() => PreviousPattern.ColumnHasObject(nextColumn), () => - { - nextColumn = Random.Next(start, TotalColumns); - }); - - return nextColumn; - } - /// /// Constructs and adds a note to a pattern. /// diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs index b2b9fe2446..da1dd62cf5 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs @@ -231,22 +231,27 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true); for (int i = 0; i < noteCount; i++) { - RunWhile(() => pattern.ColumnHasObject(nextColumn) || PreviousPattern.ColumnHasObject(nextColumn) && !allowStacking, () => - { - if (convertType.HasFlag(PatternType.Gathered)) - { - nextColumn++; - if (nextColumn == TotalColumns) - nextColumn = RandomStart; - } - else - nextColumn = Random.Next(RandomStart, TotalColumns); - }); + nextColumn = allowStacking + ? FindAvailableColumn(nextColumn, nextColumn: getNextColumn, patterns: pattern) + : FindAvailableColumn(nextColumn, nextColumn: getNextColumn, patterns: new[] { pattern, PreviousPattern }); addToPattern(pattern, nextColumn); } return pattern; + + int getNextColumn(int last) + { + if (convertType.HasFlag(PatternType.Gathered)) + { + last++; + if (last == TotalColumns) + last = RandomStart; + } + else + last = GetRandomColumn(); + return last; + } } /// @@ -292,13 +297,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy int noteCount = getRandomNoteCountMirrored(centreProbability, p2, p3, out addToCentre); int columnLimit = (TotalColumns % 2 == 0 ? TotalColumns : TotalColumns - 1) / 2; - int nextColumn = Random.Next(RandomStart, columnLimit); + int nextColumn = GetRandomColumn(upperBound: columnLimit); for (int i = 0; i < noteCount; i++) { - RunWhile(() => pattern.ColumnHasObject(nextColumn), () => - { - nextColumn = Random.Next(RandomStart, columnLimit); - }); + nextColumn = FindAvailableColumn(nextColumn, upperBound: columnLimit, patterns: pattern); // Add normal note addToPattern(pattern, nextColumn); diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs index 55081e5822..7a160ed389 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using JetBrains.Annotations; using osu.Game.Beatmaps; using osu.Game.Rulesets.Mania.MathUtils; using osu.Game.Rulesets.Objects; @@ -90,6 +91,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy } private double? conversionDifficulty; + /// /// A difficulty factor used for various conversion methods from osu!stable. /// @@ -116,5 +118,82 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy return conversionDifficulty.Value; } } + + /// + /// Finds a new column in which a can be placed. + /// This uses to pick the next candidate column. + /// + /// The initial column to test. This may be returned if it is already a valid column. + /// A list of patterns for which the validity of a column should be checked against. + /// A column is not a valid candidate if a occupies the same column in any of the patterns. + /// A column for which there are no s in any of occupying the same column. + /// If there are no valid candidate columns. + protected int FindAvailableColumn(int initialColumn, params Pattern[] patterns) + => FindAvailableColumn(initialColumn, null, patterns: patterns); + + /// + /// Finds a new column in which a can be placed. + /// + /// The initial column to test. This may be returned if it is already a valid column. + /// A function to retrieve the next column. If null, a randomisation scheme will be used. + /// A function to perform additional validation checks to determine if a column is a valid candidate for a . + /// The minimum column index. If null, is used. + /// The maximum column index. If null, is used. + /// A list of patterns for which the validity of a column should be checked against. + /// A column is not a valid candidate if a occupies the same column in any of the patterns. + /// A column which has passed the check and for which there are no + /// s in any of occupying the same column. + /// If there are no valid candidate columns. + protected int FindAvailableColumn(int initialColumn, int? lowerBound = null, int? upperBound = null, Func nextColumn = null, [InstantHandle] Func validation = null, + params Pattern[] patterns) + { + lowerBound = lowerBound ?? RandomStart; + upperBound = upperBound ?? TotalColumns; + nextColumn = nextColumn ?? (_ => GetRandomColumn(lowerBound, upperBound)); + + // Check for the initial column + if (isValid(initialColumn)) + return initialColumn; + + // Ensure that we have at least one free column, so that an endless loop is avoided + bool hasValidColumns = false; + for (int i = lowerBound.Value; i < upperBound.Value; i++) + { + hasValidColumns = isValid(i); + if (hasValidColumns) + break; + } + + if (!hasValidColumns) + throw new NotEnoughColumnsException(); + + // Iterate until a valid column is found. This is a random iteration in the default case. + do + { + initialColumn = nextColumn(initialColumn); + } while (!isValid(initialColumn)); + + return initialColumn; + + bool isValid(int column) => validation?.Invoke(column) != false && !patterns.Any(p => p.ColumnHasObject(column)); + } + + /// + /// Returns a random column index in the range [RandomStart, TotalColumns). + /// + /// The minimum column index. If null, is used. + /// The maximum column index. If null, is used. + protected int GetRandomColumn(int? lowerBound = null, int? upperBound = null) => Random.Next(lowerBound ?? RandomStart, upperBound ?? TotalColumns); + + /// + /// Occurs when mania conversion is stuck in an infinite loop unable to find columns to place new hitobjects in. + /// + public class NotEnoughColumnsException : Exception + { + public NotEnoughColumnsException() + : base("There were not enough columns to complete conversion.") + { + } + } } } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs index e51cbcdc60..a42d57cdd1 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs @@ -3,9 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using JetBrains.Annotations; -using osu.Framework.Logging; using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns @@ -15,14 +12,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns /// internal abstract class PatternGenerator { - /// - /// An arbitrary maximum amount of iterations to perform in . - /// The specific value is not super important - enough such that no false-positives occur. - /// - /// /b/933228 requires at least 23 iterations. - /// - private const int max_rng_iterations = 30; - /// /// The last pattern. /// @@ -53,44 +42,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns TotalColumns = Beatmap.TotalColumns; } - protected void RunWhile([InstantHandle] Func condition, Action action) - { - int iterations = 0; - - while (condition()) - { - if (iterations++ >= max_rng_iterations) - { - // log an error but don't throw. we want to continue execution. - Logger.Error(new ExceededAllowedIterationsException(new StackTrace(0)), - "Conversion encountered errors. The beatmap may not be correctly converted."); - return; - } - - action(); - } - } - /// /// Generates the patterns for , each filled with hit objects. /// /// The s containing the hit objects. public abstract IEnumerable Generate(); - - /// - /// Denotes when a single conversion operation is in an infinitely looping state. - /// - public class ExceededAllowedIterationsException : Exception - { - private readonly string stackTrace; - - public ExceededAllowedIterationsException(StackTrace stackTrace) - { - this.stackTrace = stackTrace.ToString(); - } - - public override string StackTrace => stackTrace; - public override string ToString() => $"{GetType().Name}: {Message}\r\n{StackTrace}"; - } } } From 49913f00f09a0ee4d6e83e93b58e253a70c6b2fc Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sat, 25 Aug 2018 00:07:48 +0900 Subject: [PATCH 04/23] Fix xmldoc --- .../Beatmaps/Patterns/Legacy/PatternGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs index 7a160ed389..05ca1d4365 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs @@ -179,7 +179,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy } /// - /// Returns a random column index in the range [RandomStart, TotalColumns). + /// Returns a random column index in the range [, ). /// /// The minimum column index. If null, is used. /// The maximum column index. If null, is used. From 8204d3292eb607d6c55e21244ed53e13361865a1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 25 Aug 2018 14:50:46 +0900 Subject: [PATCH 05/23] Log to correct file --- osu.Game/Beatmaps/BeatmapManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index d2be36e991..774a80049b 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -352,7 +352,7 @@ namespace osu.Game.Beatmaps string mapName = reader.Filenames.FirstOrDefault(f => f.EndsWith(".osu")); if (string.IsNullOrEmpty(mapName)) { - Logger.Log($"No beatmap files found in the beatmap archive ({reader.Name})."); + Logger.Log($"No beatmap files found in the beatmap archive ({reader.Name}).", LoggingTarget.Database); return null; } From 5c7ff31675aa4e50f43469f7018b4a346984dd98 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 25 Aug 2018 14:51:42 +0900 Subject: [PATCH 06/23] Add note about null return --- osu.Game/Database/ArchiveModelManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 42dd6684d5..326d042c39 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -390,7 +390,7 @@ namespace osu.Game.Database /// Actual expensive population should be done in ; this should just prepare for duplicate checking. /// /// The archive to create the model for. - /// A model populated with minimal information. + /// A model populated with minimal information. Returning a null will abort importing silently. protected abstract TModel CreateModel(ArchiveReader archive); /// From 21d5322899deede2d49e8327d1b13ae0a98e4dfa Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 27 Aug 2018 17:05:58 +0900 Subject: [PATCH 07/23] Update with async changes --- osu.Game/Graphics/Sprites/OsuSpriteText.cs | 2 +- osu.Game/IO/Archives/ArchiveReader.cs | 7 +++++-- osu.Game/Skinning/LegacySkin.cs | 7 +++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/osu.Game/Graphics/Sprites/OsuSpriteText.cs b/osu.Game/Graphics/Sprites/OsuSpriteText.cs index c9389bb9e2..12b816184e 100644 --- a/osu.Game/Graphics/Sprites/OsuSpriteText.cs +++ b/osu.Game/Graphics/Sprites/OsuSpriteText.cs @@ -22,7 +22,7 @@ namespace osu.Game.Graphics.Sprites protected override Drawable CreateFallbackCharacterDrawable() { - var tex = GetTextureForCharacter('?'); + var tex = GetTextureForCharacter('?').Result; if (tex != null) { diff --git a/osu.Game/IO/Archives/ArchiveReader.cs b/osu.Game/IO/Archives/ArchiveReader.cs index 808ce159bb..24a5094586 100644 --- a/osu.Game/IO/Archives/ArchiveReader.cs +++ b/osu.Game/IO/Archives/ArchiveReader.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; +using System.Threading.Tasks; using osu.Framework.IO.Stores; namespace osu.Game.IO.Archives @@ -28,7 +29,9 @@ namespace osu.Game.IO.Archives public abstract IEnumerable Filenames { get; } - public virtual byte[] Get(string name) + public virtual byte[] Get(string name) => GetAsync(name).Result; + + public async Task GetAsync(string name) { using (Stream input = GetStream(name)) { @@ -36,7 +39,7 @@ namespace osu.Game.IO.Archives return null; byte[] buffer = new byte[input.Length]; - input.Read(buffer, 0, buffer.Length); + await input.ReadAsync(buffer, 0, buffer.Length); return buffer; } } diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 45c6ec80aa..f9801c2f92 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -4,6 +4,7 @@ using System; using System.IO; using System.Linq; +using System.Threading.Tasks; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Graphics; @@ -108,10 +109,12 @@ namespace osu.Game.Skinning return path == null ? null : underlyingStore.GetStream(path); } - byte[] IResourceStore.Get(string name) + byte[] IResourceStore.Get(string name) => GetAsync(name).Result; + + public async Task GetAsync(string name) { string path = getPathForFile(name); - return path == null ? null : underlyingStore.Get(path); + return path == null ? null : await underlyingStore.GetAsync(path); } #region IDisposable Support From 1b279d383f4e513c8b401b75402daf6ab3e8e604 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 27 Aug 2018 17:26:44 +0900 Subject: [PATCH 08/23] Use GetAsync on all textures --- osu.Desktop/Overlays/VersionManager.cs | 5 +++-- osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 5 +++-- .../Objects/Drawables/Pieces/DefaultCirclePiece.cs | 5 +++-- osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs | 5 +++-- osu.Game.Rulesets.Taiko/UI/InputDrum.cs | 11 ++++++----- osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs | 5 +++-- osu.Game/Graphics/Backgrounds/Background.cs | 5 +++-- osu.Game/Graphics/Cursor/MenuCursor.cs | 7 ++++--- osu.Game/Overlays/MedalOverlay.cs | 5 +++-- osu.Game/Overlays/MedalSplash/DrawableMedal.cs | 7 ++++--- osu.Game/Overlays/MusicController.cs | 4 ++-- osu.Game/Overlays/Profile/Components/GradeBadge.cs | 5 +++-- osu.Game/Overlays/Profile/Header/BadgeContainer.cs | 5 +++-- osu.Game/Overlays/Profile/ProfileHeader.cs | 5 +++-- .../Overlays/Profile/Sections/Recent/MedalIcon.cs | 5 +++-- .../Screens/Backgrounds/BackgroundScreenBeatmap.cs | 5 +++-- osu.Game/Screens/Menu/OsuLogo.cs | 7 ++++--- osu.Game/Screens/Play/KeyCounter.cs | 7 ++++--- osu.Game/Screens/Ranking/ResultsPageScore.cs | 5 +++-- osu.Game/Screens/Select/Leaderboards/DrawableRank.cs | 9 +++++---- .../Tournament/Components/VisualiserContainer.cs | 5 +++-- osu.Game/Screens/Tournament/Drawings.cs | 4 ++-- osu.Game/Screens/Tournament/Group.cs | 5 +++-- osu.Game/Screens/Tournament/ScrollingTeamContainer.cs | 5 +++-- osu.Game/Users/Avatar.cs | 7 ++++--- osu.Game/Users/Country.cs | 9 +++++---- osu.Game/Users/UserCoverBackground.cs | 5 +++-- osu.Game/osu.Game.csproj | 2 +- 28 files changed, 92 insertions(+), 67 deletions(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 1129969694..740ad7c3be 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -31,7 +32,7 @@ namespace osu.Desktop.Overlays public override bool HandleMouseInput => false; [BackgroundDependencyLoader] - private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config, GameHost host) + private async Task load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config, GameHost host) { notificationOverlay = notification; this.config = config; @@ -86,7 +87,7 @@ namespace osu.Desktop.Overlays { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Texture = textures.Get(@"Menu/dev-build-footer"), + Texture = await textures.GetAsync(@"Menu/dev-build-footer"), }, } } diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index 4327abb96f..99d902d3e4 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -448,9 +449,9 @@ namespace osu.Game.Rulesets.Catch.UI } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { - Texture = textures.Get(@"Play/Catch/fruit-catcher-idle"); + Texture = await textures.GetAsync(@"Play/Catch/fruit-catcher-idle"); } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/DefaultCirclePiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/DefaultCirclePiece.cs index 86b60c3443..c7c81756eb 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/DefaultCirclePiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/DefaultCirclePiece.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -12,7 +13,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces public class DefaultCirclePiece : Container { [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { RelativeSizeAxes = Axes.Both; Children = new Drawable[] @@ -21,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Texture = textures.Get(@"Play/osu/disc"), + Texture = await textures.GetAsync(@"Play/osu/disc"), }, new TrianglesPiece { diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs index abcd1ddbda..4b981dc406 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics; using System.Runtime.InteropServices; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.OpenGL.Buffers; @@ -79,10 +80,10 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; [BackgroundDependencyLoader] - private void load(ShaderManager shaders, TextureStore textures) + private async Task load(ShaderManager shaders, TextureStore textures) { shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE); - texture = textures.Get(@"Cursor/cursortrail"); + texture = await textures.GetAsync(@"Cursor/cursortrail"); Scale = new Vector2(1 / texture.ScaleAdjust); } diff --git a/osu.Game.Rulesets.Taiko/UI/InputDrum.cs b/osu.Game.Rulesets.Taiko/UI/InputDrum.cs index 524535bfde..f525ce0ff3 100644 --- a/osu.Game.Rulesets.Taiko/UI/InputDrum.cs +++ b/osu.Game.Rulesets.Taiko/UI/InputDrum.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Threading.Tasks; using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -130,12 +131,12 @@ namespace osu.Game.Rulesets.Taiko.UI } [BackgroundDependencyLoader] - private void load(TextureStore textures, OsuColour colours) + private async Task load(TextureStore textures, OsuColour colours) { - rim.Texture = textures.Get(@"Play/Taiko/taiko-drum-outer"); - rimHit.Texture = textures.Get(@"Play/Taiko/taiko-drum-outer-hit"); - centre.Texture = textures.Get(@"Play/Taiko/taiko-drum-inner"); - centreHit.Texture = textures.Get(@"Play/Taiko/taiko-drum-inner-hit"); + rim.Texture = await textures.GetAsync(@"Play/Taiko/taiko-drum-outer"); + rimHit.Texture = await textures.GetAsync(@"Play/Taiko/taiko-drum-outer-hit"); + centre.Texture = await textures.GetAsync(@"Play/Taiko/taiko-drum-inner"); + centreHit.Texture = await textures.GetAsync(@"Play/Taiko/taiko-drum-inner-hit"); rimHit.Colour = colours.Blue; centreHit.Colour = colours.Pink; diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs index 883c05f1e4..9bba589f59 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; @@ -23,7 +24,7 @@ namespace osu.Game.Beatmaps.Drawables } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { string resource = null; @@ -41,7 +42,7 @@ namespace osu.Game.Beatmaps.Drawables } if (resource != null) - Texture = textures.Get(resource); + Texture = await textures.GetAsync(resource); } } diff --git a/osu.Game/Graphics/Backgrounds/Background.cs b/osu.Game/Graphics/Backgrounds/Background.cs index d5825a8c42..dcd1db56de 100644 --- a/osu.Game/Graphics/Backgrounds/Background.cs +++ b/osu.Game/Graphics/Backgrounds/Background.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -34,10 +35,10 @@ namespace osu.Game.Graphics.Backgrounds } [BackgroundDependencyLoader] - private void load(LargeTextureStore textures) + private async Task load(LargeTextureStore textures) { if (!string.IsNullOrEmpty(textureName)) - Sprite.Texture = textures.Get(textureName); + Sprite.Texture = await textures.GetAsync(textureName); } } } diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index b55e1aa5dd..92b45ebcb9 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Sprites; using osu.Game.Configuration; using System; +using System.Threading.Tasks; using JetBrains.Annotations; using osu.Framework.Graphics.Textures; using osu.Framework.Input.EventArgs; @@ -132,7 +133,7 @@ namespace osu.Game.Graphics.Cursor } [BackgroundDependencyLoader] - private void load(OsuConfigManager config, TextureStore textures, OsuColour colour) + private async Task load(OsuConfigManager config, TextureStore textures, OsuColour colour) { Children = new Drawable[] { @@ -143,14 +144,14 @@ namespace osu.Game.Graphics.Cursor { new Sprite { - Texture = textures.Get(@"Cursor/menu-cursor"), + Texture = await textures.GetAsync(@"Cursor/menu-cursor"), }, AdditiveLayer = new Sprite { Blending = BlendingMode.Additive, Colour = colour.Pink, Alpha = 0, - Texture = textures.Get(@"Cursor/menu-cursor-additive"), + Texture = await textures.GetAsync(@"Cursor/menu-cursor-additive"), }, } } diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index bd67a718a7..2ff0524880 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -20,6 +20,7 @@ using OpenTK.Input; using osu.Framework.Graphics.Shapes; using System; using System.Linq; +using System.Threading.Tasks; using osu.Framework.Input.States; using osu.Framework.MathUtils; @@ -143,10 +144,10 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(OsuColour colours, TextureStore textures, AudioManager audio) + private async Task load(OsuColour colours, TextureStore textures, AudioManager audio) { getSample = audio.Sample.Get(@"MedalSplash/medal-get"); - innerSpin.Texture = outerSpin.Texture = textures.Get(@"MedalSplash/disc-spin"); + innerSpin.Texture = outerSpin.Texture = await textures.GetAsync(@"MedalSplash/disc-spin"); disc.EdgeEffect = leftStrip.EdgeEffect = rightStrip.EdgeEffect = new EdgeEffectParameters { diff --git a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs index a27278e002..9ced6520df 100644 --- a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs +++ b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Threading.Tasks; using osu.Framework; using OpenTK; using osu.Framework.Allocation; @@ -118,10 +119,10 @@ namespace osu.Game.Overlays.MedalSplash } [BackgroundDependencyLoader] - private void load(OsuColour colours, TextureStore textures) + private async Task load(OsuColour colours, TextureStore textures) { - medalSprite.Texture = textures.Get(medal.ImageUrl); - medalGlow.Texture = textures.Get(@"MedalSplash/medal-glow"); + medalSprite.Texture = await textures.GetAsync(medal.ImageUrl); + medalGlow.Texture = await textures.GetAsync(@"MedalSplash/medal-glow"); description.Colour = colours.BlueLight; } diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 886b5fb95b..42f89a4863 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -454,9 +454,9 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { - sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg4"); + sprite.Texture = beatmap?.Background ?? await textures.GetAsync(@"Backgrounds/bg4"); } } diff --git a/osu.Game/Overlays/Profile/Components/GradeBadge.cs b/osu.Game/Overlays/Profile/Components/GradeBadge.cs index 14a47e8d03..3943a5f86b 100644 --- a/osu.Game/Overlays/Profile/Components/GradeBadge.cs +++ b/osu.Game/Overlays/Profile/Components/GradeBadge.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -42,9 +43,9 @@ namespace osu.Game.Overlays.Profile.Components } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { - badge.Texture = textures.Get($"Grades/{grade}"); + badge.Texture = await textures.GetAsync($"Grades/{grade}"); } } } diff --git a/osu.Game/Overlays/Profile/Header/BadgeContainer.cs b/osu.Game/Overlays/Profile/Header/BadgeContainer.cs index bfade5e45c..f87aefb28a 100644 --- a/osu.Game/Overlays/Profile/Header/BadgeContainer.cs +++ b/osu.Game/Overlays/Profile/Header/BadgeContainer.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -176,13 +177,13 @@ namespace osu.Game.Overlays.Profile.Header } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { Child = new Sprite { FillMode = FillMode.Fit, RelativeSizeAxes = Axes.Both, - Texture = textures.Get(badge.ImageUrl), + Texture = await textures.GetAsync(badge.ImageUrl), }; } diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 9d09836d25..48048d2935 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Threading.Tasks; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -311,9 +312,9 @@ namespace osu.Game.Overlays.Profile } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { - levelBadge.Texture = textures.Get(@"Profile/levelbadge"); + levelBadge.Texture = await textures.GetAsync(@"Profile/levelbadge"); } private User user; diff --git a/osu.Game/Overlays/Profile/Sections/Recent/MedalIcon.cs b/osu.Game/Overlays/Profile/Sections/Recent/MedalIcon.cs index 0d354c728f..2eec75c875 100644 --- a/osu.Game/Overlays/Profile/Sections/Recent/MedalIcon.cs +++ b/osu.Game/Overlays/Profile/Sections/Recent/MedalIcon.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; @@ -30,9 +31,9 @@ namespace osu.Game.Overlays.Profile.Sections.Recent } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { - sprite.Texture = textures.Get(url); + sprite.Texture = await textures.GetAsync(url); } } } diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 78561cecbf..14d4cab870 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; @@ -75,9 +76,9 @@ namespace osu.Game.Screens.Backgrounds } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { - Sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg1"); + Sprite.Texture = beatmap?.Background ?? await textures.GetAsync(@"Backgrounds/bg1"); } } } diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index f0f765a4c9..fde32b31fd 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -253,13 +254,13 @@ namespace osu.Game.Screens.Menu } [BackgroundDependencyLoader] - private void load(TextureStore textures, AudioManager audio) + private async Task load(TextureStore textures, AudioManager audio) { sampleClick = audio.Sample.Get(@"Menu/osu-logo-select"); sampleBeat = audio.Sample.Get(@"Menu/osu-logo-heartbeat"); - logo.Texture = textures.Get(@"Menu/logo"); - ripple.Texture = textures.Get(@"Menu/logo"); + logo.Texture = await textures.GetAsync(@"Menu/logo"); + ripple.Texture = await textures.GetAsync(@"Menu/logo"); } private int lastBeatIndex; diff --git a/osu.Game/Screens/Play/KeyCounter.cs b/osu.Game/Screens/Play/KeyCounter.cs index 2c31e61114..49500a8426 100644 --- a/osu.Game/Screens/Play/KeyCounter.cs +++ b/osu.Game/Screens/Play/KeyCounter.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -61,19 +62,19 @@ namespace osu.Game.Screens.Play } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { Children = new Drawable[] { buttonSprite = new Sprite { - Texture = textures.Get(@"KeyCounter/key-up"), + Texture = await textures.GetAsync(@"KeyCounter/key-up"), Anchor = Anchor.Centre, Origin = Anchor.Centre, }, glowSprite = new Sprite { - Texture = textures.Get(@"KeyCounter/key-glow"), + Texture = await textures.GetAsync(@"KeyCounter/key-glow"), Anchor = Anchor.Centre, Origin = Anchor.Centre, Alpha = 0 diff --git a/osu.Game/Screens/Ranking/ResultsPageScore.cs b/osu.Game/Screens/Ranking/ResultsPageScore.cs index 42d8af07b9..87e53b8182 100644 --- a/osu.Game/Screens/Ranking/ResultsPageScore.cs +++ b/osu.Game/Screens/Ranking/ResultsPageScore.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -368,10 +369,10 @@ namespace osu.Game.Screens.Ranking } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { if (!string.IsNullOrEmpty(user.CoverUrl)) - cover.Texture = textures.Get(user.CoverUrl); + cover.Texture = await textures.GetAsync(user.CoverUrl); } } diff --git a/osu.Game/Screens/Select/Leaderboards/DrawableRank.cs b/osu.Game/Screens/Select/Leaderboards/DrawableRank.cs index 0c4b369f36..f5f9ebbdaf 100644 --- a/osu.Game/Screens/Select/Leaderboards/DrawableRank.cs +++ b/osu.Game/Screens/Select/Leaderboards/DrawableRank.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -35,20 +36,20 @@ namespace osu.Game.Screens.Select.Leaderboards } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { this.textures = textures; - updateTexture(); + await updateTexture(); } - private void updateTexture() => rankSprite.Texture = textures.Get($@"Grades/{Rank.GetDescription()}"); + private async Task updateTexture() => rankSprite.Texture = await textures.GetAsync($@"Grades/{Rank.GetDescription()}"); public void UpdateRank(ScoreRank newRank) { Rank = newRank; if (LoadState >= LoadState.Ready) - updateTexture(); + updateTexture().Wait(); } } } diff --git a/osu.Game/Screens/Tournament/Components/VisualiserContainer.cs b/osu.Game/Screens/Tournament/Components/VisualiserContainer.cs index 1453d4e78f..835b0757e0 100644 --- a/osu.Game/Screens/Tournament/Components/VisualiserContainer.cs +++ b/osu.Game/Screens/Tournament/Components/VisualiserContainer.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Textures; using osu.Framework.MathUtils; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace osu.Game.Screens.Tournament.Components { @@ -75,9 +76,9 @@ namespace osu.Game.Screens.Tournament.Components private int expiredCount; [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { - texture = textures.Get("Drawings/visualiser-line"); + texture = await textures.GetAsync("Drawings/visualiser-line"); } protected override void UpdateAfterChildren() diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 63d29d5cd7..20180a660f 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -53,7 +53,7 @@ namespace osu.Game.Screens.Tournament dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); [BackgroundDependencyLoader] - private void load(TextureStore textures, Storage storage) + private async Task load(TextureStore textures, Storage storage) { this.storage = storage; @@ -87,7 +87,7 @@ namespace osu.Game.Screens.Tournament { RelativeSizeAxes = Axes.Both, FillMode = FillMode.Fill, - Texture = textures.Get(@"Backgrounds/Drawings/background.png") + Texture = await textures.GetAsync(@"Backgrounds/Drawings/background.png") }, new FillFlowContainer { diff --git a/osu.Game/Screens/Tournament/Group.cs b/osu.Game/Screens/Tournament/Group.cs index 6845d8fc48..5128166c15 100644 --- a/osu.Game/Screens/Tournament/Group.cs +++ b/osu.Game/Screens/Tournament/Group.cs @@ -4,6 +4,7 @@ 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; @@ -178,9 +179,9 @@ namespace osu.Game.Screens.Tournament } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { - flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}"); + flagSprite.Texture = await textures.GetAsync($@"Flags/{Team.FlagName}"); } } } diff --git a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs index d1c7e0fced..cc9f805c62 100644 --- a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs +++ b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -372,9 +373,9 @@ namespace osu.Game.Screens.Tournament } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { - flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}"); + flagSprite.Texture = await textures.GetAsync($@"Flags/{Team.FlagName}"); } } } diff --git a/osu.Game/Users/Avatar.cs b/osu.Game/Users/Avatar.cs index 9ba9549164..9aac662a84 100644 --- a/osu.Game/Users/Avatar.cs +++ b/osu.Game/Users/Avatar.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -24,14 +25,14 @@ namespace osu.Game.Users } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { if (textures == null) throw new ArgumentNullException(nameof(textures)); Texture texture = null; - if (user != null && user.Id > 1) texture = textures.Get($@"https://a.ppy.sh/{user.Id}"); - if (texture == null) texture = textures.Get(@"Online/avatar-guest"); + if (user != null && user.Id > 1) texture = await textures.GetAsync($@"https://a.ppy.sh/{user.Id}"); + if (texture == null) texture = await textures.GetAsync(@"Online/avatar-guest"); Add(new Sprite { diff --git a/osu.Game/Users/Country.cs b/osu.Game/Users/Country.cs index 80039eadad..a37ca10f9a 100644 --- a/osu.Game/Users/Country.cs +++ b/osu.Game/Users/Country.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Threading.Tasks; using Newtonsoft.Json; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -44,7 +45,7 @@ namespace osu.Game.Users country = value; if (LoadState >= LoadState.Ready) - sprite.Texture = getFlagTexture(); + sprite.Texture = getFlagTexture().Result; } } @@ -64,15 +65,15 @@ namespace osu.Game.Users } [BackgroundDependencyLoader] - private void load(TextureStore ts) + private async Task load(TextureStore ts) { if (ts == null) throw new ArgumentNullException(nameof(ts)); textures = ts; - sprite.Texture = getFlagTexture(); + sprite.Texture = await getFlagTexture(); } - private Texture getFlagTexture() => textures.Get($@"Flags/{country?.FlagName ?? @"__"}"); + private async Task getFlagTexture() => await textures.GetAsync($@"Flags/{country?.FlagName ?? @"__"}"); } } diff --git a/osu.Game/Users/UserCoverBackground.cs b/osu.Game/Users/UserCoverBackground.cs index 58b92b2750..97d2648e07 100644 --- a/osu.Game/Users/UserCoverBackground.cs +++ b/osu.Game/Users/UserCoverBackground.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; @@ -18,13 +19,13 @@ namespace osu.Game.Users } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private async Task load(TextureStore textures) { if (textures == null) throw new ArgumentNullException(nameof(textures)); if (!string.IsNullOrEmpty(user.CoverUrl)) - Texture = textures.Get(user.CoverUrl); + Texture = await textures.GetAsync(user.CoverUrl); } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 69d242daa9..fce7cb73a2 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -18,7 +18,7 @@ - + From e7a5816d27a63dcabed1a6f6cc7e6fd49ad95a86 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 27 Aug 2018 17:30:16 +0900 Subject: [PATCH 09/23] Use GetAsync for all samples --- osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs | 7 ++++--- osu.Game/Graphics/ScreenshotManager.cs | 4 ++-- osu.Game/Graphics/UserInterface/HoverClickSounds.cs | 5 +++-- osu.Game/Graphics/UserInterface/HoverSounds.cs | 5 +++-- osu.Game/Graphics/UserInterface/OsuCheckbox.cs | 7 ++++--- osu.Game/Graphics/UserInterface/OsuMenu.cs | 7 ++++--- osu.Game/Graphics/UserInterface/OsuSliderBar.cs | 5 +++-- osu.Game/Overlays/MedalOverlay.cs | 2 +- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 7 ++++--- osu.Game/Screens/Menu/Button.cs | 7 ++++--- osu.Game/Screens/Menu/ButtonSystem.cs | 5 +++-- osu.Game/Screens/Menu/Intro.cs | 7 ++++--- osu.Game/Screens/Menu/OsuLogo.cs | 4 ++-- osu.Game/Screens/OsuScreen.cs | 5 +++-- osu.Game/Screens/Play/Player.cs | 4 ++-- osu.Game/Screens/Play/SkipOverlay.cs | 5 +++-- osu.Game/Screens/Select/Carousel/DrawableCarouselItem.cs | 5 +++-- osu.Game/Screens/Select/PlaySongSelect.cs | 4 ++-- osu.Game/Screens/Select/SongSelect.cs | 7 ++++--- 19 files changed, 58 insertions(+), 44 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index d2ab8441eb..effcc696ca 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -37,15 +38,15 @@ namespace osu.Game.Graphics.Containers } [BackgroundDependencyLoader(true)] - private void load(OsuGame osuGame, AudioManager audio, PreviewTrackManager previewTrackManager) + private async Task load(OsuGame osuGame, AudioManager audio, PreviewTrackManager previewTrackManager) { this.previewTrackManager = previewTrackManager; if (osuGame != null) OverlayActivationMode.BindTo(osuGame.OverlayActivationMode); - samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in"); - samplePopOut = audio.Sample.Get(@"UI/overlay-pop-out"); + samplePopIn = await audio.Sample.GetAsync(@"UI/overlay-pop-in"); + samplePopOut = await audio.Sample.GetAsync(@"UI/overlay-pop-out"); StateChanged += onStateChanged; } diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index bc30794298..63b97e3c59 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -42,7 +42,7 @@ namespace osu.Game.Graphics private SampleChannel shutter; [BackgroundDependencyLoader] - private void load(GameHost host, OsuConfigManager config, Storage storage, NotificationOverlay notificationOverlay, AudioManager audio) + private async Task load(GameHost host, OsuConfigManager config, Storage storage, NotificationOverlay notificationOverlay, AudioManager audio) { this.host = host; this.storage = storage.GetStorageForDirectory(@"screenshots"); @@ -51,7 +51,7 @@ namespace osu.Game.Graphics screenshotFormat = config.GetBindable(OsuSetting.ScreenshotFormat); captureMenuCursor = config.GetBindable(OsuSetting.ScreenshotCaptureMenuCursor); - shutter = audio.Sample.Get("UI/shutter"); + shutter = await audio.Sample.GetAsync("UI/shutter"); } public bool OnPressed(GlobalAction action) diff --git a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs index 27a06ba0b7..17924cdbb8 100644 --- a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -28,9 +29,9 @@ namespace osu.Game.Graphics.UserInterface } [BackgroundDependencyLoader] - private void load(AudioManager audio) + private async Task load(AudioManager audio) { - sampleClick = audio.Sample.Get($@"UI/generic-select{SampleSet.GetDescription()}"); + sampleClick = await audio.Sample.GetAsync($@"UI/generic-select{SampleSet.GetDescription()}"); } } } diff --git a/osu.Game/Graphics/UserInterface/HoverSounds.cs b/osu.Game/Graphics/UserInterface/HoverSounds.cs index 821305bc92..b3a83d1cc8 100644 --- a/osu.Game/Graphics/UserInterface/HoverSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverSounds.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.ComponentModel; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -35,9 +36,9 @@ namespace osu.Game.Graphics.UserInterface } [BackgroundDependencyLoader] - private void load(AudioManager audio) + private async Task load(AudioManager audio) { - sampleHover = audio.Sample.Get($@"UI/generic-hover{SampleSet.GetDescription()}"); + sampleHover = await audio.Sample.GetAsync($@"UI/generic-hover{SampleSet.GetDescription()}"); } } diff --git a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs index 68f59bd8cd..d6b4b51851 100644 --- a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -110,10 +111,10 @@ namespace osu.Game.Graphics.UserInterface } [BackgroundDependencyLoader] - private void load(AudioManager audio) + private async Task load(AudioManager audio) { - sampleChecked = audio.Sample.Get(@"UI/check-on"); - sampleUnchecked = audio.Sample.Get(@"UI/check-off"); + sampleChecked = await audio.Sample.GetAsync(@"UI/check-on"); + sampleUnchecked = await audio.Sample.GetAsync(@"UI/check-off"); } } } diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index abb077e94f..b5ebac0c74 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -69,10 +70,10 @@ namespace osu.Game.Graphics.UserInterface } [BackgroundDependencyLoader] - private void load(AudioManager audio) + private async Task load(AudioManager audio) { - sampleHover = audio.Sample.Get(@"UI/generic-hover"); - sampleClick = audio.Sample.Get(@"UI/generic-select"); + sampleHover = await audio.Sample.GetAsync(@"UI/generic-hover"); + sampleClick = await audio.Sample.GetAsync(@"UI/generic-select"); BackgroundColour = Color4.Transparent; BackgroundColourHover = OsuColour.FromHex(@"172023"); diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs index b7b5319e06..cd0b3dcad2 100644 --- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs @@ -3,6 +3,7 @@ using System; using System.Globalization; +using System.Threading.Tasks; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -119,9 +120,9 @@ namespace osu.Game.Graphics.UserInterface } [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuColour colours) + private async Task load(AudioManager audio, OsuColour colours) { - sample = audio.Sample.Get(@"UI/sliderbar-notch"); + sample = await audio.Sample.GetAsync(@"UI/sliderbar-notch"); AccentColour = colours.Pink; } diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index 2ff0524880..038fa936b0 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -146,7 +146,7 @@ namespace osu.Game.Overlays [BackgroundDependencyLoader] private async Task load(OsuColour colours, TextureStore textures, AudioManager audio) { - getSample = audio.Sample.Get(@"MedalSplash/medal-get"); + getSample = await audio.Sample.GetAsync(@"MedalSplash/medal-get"); innerSpin.Texture = outerSpin.Texture = await textures.GetAsync(@"MedalSplash/disc-spin"); disc.EdgeEffect = leftStrip.EdgeEffect = rightStrip.EdgeEffect = new EdgeEffectParameters diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index e83dedaf35..783fcfa090 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -15,6 +15,7 @@ using osu.Game.Rulesets.Mods; using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Graphics.Shapes; @@ -49,7 +50,7 @@ namespace osu.Game.Overlays.Mods protected readonly IBindable Ruleset = new Bindable(); [BackgroundDependencyLoader(true)] - private void load(OsuColour colours, IBindable ruleset, AudioManager audio, Bindable> selectedMods) + private async Task load(OsuColour colours, IBindable ruleset, AudioManager audio, Bindable> selectedMods) { LowMultiplierColour = colours.Red; HighMultiplierColour = colours.Green; @@ -58,8 +59,8 @@ namespace osu.Game.Overlays.Mods Ruleset.BindTo(ruleset); if (selectedMods != null) SelectedMods.BindTo(selectedMods); - sampleOn = audio.Sample.Get(@"UI/check-on"); - sampleOff = audio.Sample.Get(@"UI/check-off"); + sampleOn = await audio.Sample.GetAsync(@"UI/check-on"); + sampleOff = await audio.Sample.GetAsync(@"UI/check-off"); } protected override void LoadComplete() diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index e53905a102..3593568578 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Threading.Tasks; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -179,11 +180,11 @@ namespace osu.Game.Screens.Menu } [BackgroundDependencyLoader] - private void load(AudioManager audio) + private async Task load(AudioManager audio) { - sampleHover = audio.Sample.Get(@"Menu/button-hover"); + sampleHover = await audio.Sample.GetAsync(@"Menu/button-hover"); if (!string.IsNullOrEmpty(sampleName)) - sampleClick = audio.Sample.Get($@"Menu/{sampleName}"); + sampleClick = await audio.Sample.GetAsync($@"Menu/{sampleName}"); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index b9a799328e..4137028527 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -102,10 +103,10 @@ namespace osu.Game.Screens.Menu private OsuGame game; [BackgroundDependencyLoader(true)] - private void load(AudioManager audio, OsuGame game) + private async Task load(AudioManager audio, OsuGame game) { this.game = game; - sampleBack = audio.Sample.Get(@"Menu/button-back-select"); + sampleBack = await audio.Sample.GetAsync(@"Menu/button-back-select"); } public bool OnPressed(GlobalAction action) diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index c1032011f7..5d39d70e26 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -47,7 +48,7 @@ namespace osu.Game.Screens.Menu private WorkingBeatmap introBeatmap; [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game, BindableBeatmap beatmap) + private async Task load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game, BindableBeatmap beatmap) { this.beatmap.BindTo(beatmap); @@ -80,8 +81,8 @@ namespace osu.Game.Screens.Menu introBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); track = introBeatmap.Track; - welcome = audio.Sample.Get(@"welcome"); - seeya = audio.Sample.Get(@"seeya"); + welcome = await audio.Sample.GetAsync(@"welcome"); + seeya = await audio.Sample.GetAsync(@"seeya"); } private const double delay_step_one = 2300; diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index fde32b31fd..c6cfd9ba2d 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -256,8 +256,8 @@ namespace osu.Game.Screens.Menu [BackgroundDependencyLoader] private async Task load(TextureStore textures, AudioManager audio) { - sampleClick = audio.Sample.Get(@"Menu/osu-logo-select"); - sampleBeat = audio.Sample.Get(@"Menu/osu-logo-heartbeat"); + sampleClick = await audio.Sample.GetAsync(@"Menu/osu-logo-select"); + sampleBeat = await audio.Sample.GetAsync(@"Menu/osu-logo-heartbeat"); logo.Texture = await textures.GetAsync(@"Menu/logo"); ripple.Texture = await textures.GetAsync(@"Menu/logo"); diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 4b893f0118..3929e631cf 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Internal; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -80,7 +81,7 @@ namespace osu.Game.Screens private SampleChannel sampleExit; [BackgroundDependencyLoader(true)] - private void load(BindableBeatmap beatmap, OsuGame osu, AudioManager audio, Bindable ruleset) + private async Task load(BindableBeatmap beatmap, OsuGame osu, AudioManager audio, Bindable ruleset) { Beatmap.BindTo(beatmap); Ruleset.BindTo(ruleset); @@ -98,7 +99,7 @@ namespace osu.Game.Screens }; } - sampleExit = audio.Sample.Get(@"UI/screen-back"); + sampleExit = await audio.Sample.GetAsync(@"UI/screen-back"); } public virtual bool OnPressed(GlobalAction action) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 5ad0130fd7..863d12c1c2 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -84,7 +84,7 @@ namespace osu.Game.Screens.Play public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true; [BackgroundDependencyLoader] - private void load(AudioManager audio, APIAccess api, OsuConfigManager config) + private async Task load(AudioManager audio, APIAccess api, OsuConfigManager config) { this.api = api; @@ -92,7 +92,7 @@ namespace osu.Game.Screens.Play if (working is DummyWorkingBeatmap) return; - sampleRestart = audio.Sample.Get(@"Gameplay/restart"); + sampleRestart = await audio.Sample.GetAsync(@"Gameplay/restart"); mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); userAudioOffset = config.GetBindable(OsuSetting.AudioOffset); diff --git a/osu.Game/Screens/Play/SkipOverlay.cs b/osu.Game/Screens/Play/SkipOverlay.cs index 06837c9274..9aaaa6152c 100644 --- a/osu.Game/Screens/Play/SkipOverlay.cs +++ b/osu.Game/Screens/Play/SkipOverlay.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Threading.Tasks; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -224,12 +225,12 @@ namespace osu.Game.Screens.Play } [BackgroundDependencyLoader] - private void load(OsuColour colours, AudioManager audio) + private async Task load(OsuColour colours, AudioManager audio) { colourNormal = colours.Yellow; colourHover = colours.YellowDark; - sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection"); + sampleConfirm = await audio.Sample.GetAsync(@"SongSelect/confirm-selection"); Children = new Drawable[] { diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselItem.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselItem.cs index 8a0052559e..b252f116ac 100644 --- a/osu.Game/Screens/Select/Carousel/DrawableCarouselItem.cs +++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselItem.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -45,7 +46,7 @@ namespace osu.Game.Screens.Select.Carousel private SampleChannel sampleHover; [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuColour colours) + private async Task load(AudioManager audio, OsuColour colours) { InternalChild = borderContainer = new Container { @@ -68,7 +69,7 @@ namespace osu.Game.Screens.Select.Carousel } }; - sampleHover = audio.Sample.Get($@"SongSelect/song-ping-variation-{RNG.Next(1, 5)}"); + sampleHover = await audio.Sample.GetAsync($@"SongSelect/song-ping-variation-{RNG.Next(1, 5)}"); hoverLayer.Colour = colours.Blue.Opacity(0.1f); } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index e914eb365e..cab7bdfe73 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -55,11 +55,11 @@ namespace osu.Game.Screens.Select private readonly Bindable> selectedMods = new Bindable>(new Mod[] { }); [BackgroundDependencyLoader(true)] - private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, Bindable> selectedMods) + private async Task load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, Bindable> selectedMods) { if (selectedMods != null) this.selectedMods.BindTo(selectedMods); - sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection"); + sampleConfirm = await audio.Sample.GetAsync(@"SongSelect/confirm-selection"); Footer.AddButton(@"mods", colours.Yellow, modSelect, Key.F1, float.MaxValue); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index dcc0760262..ef03aff107 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using System.Threading.Tasks; using OpenTK; using OpenTK.Input; using osu.Framework.Allocation; @@ -198,7 +199,7 @@ namespace osu.Game.Screens.Select } [BackgroundDependencyLoader(true)] - private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours) + private async Task load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours) { if (Footer != null) { @@ -218,8 +219,8 @@ namespace osu.Game.Screens.Select dialogOverlay = dialog; - sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty"); - sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand"); + sampleChangeDifficulty = await audio.Sample.GetAsync(@"SongSelect/select-difficulty"); + sampleChangeBeatmap = await audio.Sample.GetAsync(@"SongSelect/select-expand"); Carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSetsEnumerable(); } From da2f04c79c3c6f5bb1b4543a3200e6e8eea65351 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 28 Aug 2018 16:07:52 +0900 Subject: [PATCH 10/23] Update framework once more --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index fce7cb73a2..0633d7913e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -18,7 +18,7 @@ - + From 919e78a89ac6e7cbb8d1e23e175fd489ba7ce106 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 29 Aug 2018 01:42:25 +0900 Subject: [PATCH 11/23] Attempt to fix cross-thread database usage --- osu.Game/Screens/Select/BeatmapCarousel.cs | 50 ++++++++++++---------- osu.Game/Screens/Select/SongSelect.cs | 2 +- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 6e4454a311..7bb0b95b9a 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -64,32 +64,36 @@ namespace osu.Game.Screens.Select public IEnumerable BeatmapSets { - get { return beatmapSets.Select(g => g.BeatmapSet); } - set + get => beatmapSets.Select(g => g.BeatmapSet); + set => loadBeatmapSets(() => value); + } + + public void LoadBeatmapSetsFromManager(BeatmapManager manager) => loadBeatmapSets(manager.GetAllUsableBeatmapSetsEnumerable); + + private void loadBeatmapSets(Func> beatmapSets) + { + CarouselRoot newRoot = new CarouselRoot(this); + + Task.Run(() => { - CarouselRoot newRoot = new CarouselRoot(this); + beatmapSets().Select(createCarouselSet).Where(g => g != null).ForEach(newRoot.AddChild); + newRoot.Filter(activeCriteria); - Task.Run(() => + // preload drawables as the ctor overhead is quite high currently. + var _ = newRoot.Drawables; + }).ContinueWith(_ => Schedule(() => + { + root = newRoot; + scrollableContent.Clear(false); + itemsCache.Invalidate(); + scrollPositionCache.Invalidate(); + + Schedule(() => { - value.Select(createCarouselSet).Where(g => g != null).ForEach(newRoot.AddChild); - newRoot.Filter(activeCriteria); - - // preload drawables as the ctor overhead is quite high currently. - var _ = newRoot.Drawables; - }).ContinueWith(_ => Schedule(() => - { - root = newRoot; - scrollableContent.Clear(false); - itemsCache.Invalidate(); - scrollPositionCache.Invalidate(); - - Schedule(() => - { - BeatmapSetsChanged?.Invoke(); - initialLoadComplete = true; - }); - })); - } + BeatmapSetsChanged?.Invoke(); + initialLoadComplete = true; + }); + })); } private readonly List yPositions = new List(); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index ef03aff107..ac765c46ab 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -222,7 +222,7 @@ namespace osu.Game.Screens.Select sampleChangeDifficulty = await audio.Sample.GetAsync(@"SongSelect/select-difficulty"); sampleChangeBeatmap = await audio.Sample.GetAsync(@"SongSelect/select-expand"); - Carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSetsEnumerable(); + Carousel.LoadBeatmapSetsFromManager(this.beatmaps); } public void Edit(BeatmapInfo beatmap) From 73c764d9831d17b8186771cd0a1d40a2be97a5eb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 29 Aug 2018 03:36:01 +0900 Subject: [PATCH 12/23] Update SpriteIcon --- osu.Game/Graphics/SpriteIcon.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/osu.Game/Graphics/SpriteIcon.cs b/osu.Game/Graphics/SpriteIcon.cs index 6acd20719e..24b3f37505 100644 --- a/osu.Game/Graphics/SpriteIcon.cs +++ b/osu.Game/Graphics/SpriteIcon.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -24,7 +25,7 @@ namespace osu.Game.Graphics private FontStore store; [BackgroundDependencyLoader] - private void load(FontStore store) + private async Task load(FontStore store) { this.store = store; @@ -55,23 +56,23 @@ namespace osu.Game.Graphics }, }; - updateTexture(); + await updateTexture(); } protected override void LoadComplete() { base.LoadComplete(); - updateTexture(); + updateTexture().Wait(); } private FontAwesome loadedIcon; - private void updateTexture() + private async Task updateTexture() { var loadableIcon = icon; if (loadableIcon == loadedIcon) return; - var texture = store?.Get(((char)loadableIcon).ToString()); + var texture = await store.GetAsync(((char)loadableIcon).ToString()); spriteMain.Texture = texture; spriteShadow.Texture = texture; @@ -129,8 +130,8 @@ namespace osu.Game.Graphics if (icon == value) return; icon = value; - if (IsLoaded) - updateTexture(); + if (LoadState == LoadState.Loaded) + updateTexture().Wait(); } } } From 4b54c65d3f5a737c3a1634ee6c88bffcb8b4f937 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 29 Aug 2018 15:11:02 +0900 Subject: [PATCH 13/23] Fix single file component loading not actually working correctly --- osu.Game/OsuGame.cs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 94678a9dde..f4afd23c1b 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -506,22 +506,24 @@ namespace osu.Game // we could avoid the need for scheduling altogether. Schedule(() => { - if (asyncLoadStream != null) + var previousLoadStream = asyncLoadStream; + + //chain with existing load stream + asyncLoadStream = Task.Run(async () => { - //chain with existing load stream - asyncLoadStream = asyncLoadStream.ContinueWith(async t => + if (previousLoadStream != null) + await previousLoadStream; + + try { - try - { - await LoadComponentAsync(d, add); - } - catch (OperationCanceledException) - { - } - }); - } - else - asyncLoadStream = LoadComponentAsync(d, add); + Logger.Log($"{d}...", LoggingTarget.Debug); + await LoadComponentAsync(d, add); + Logger.Log($"{d} ✓", LoggingTarget.Debug); + } + catch (OperationCanceledException) + { + } + }); }); } From 499c5d28ffb09d1047e57d3c16f90227429a82ee Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Aug 2018 18:04:51 -0400 Subject: [PATCH 14/23] Refactored variable names in OsuGame.cs for improved code readability. --- osu.Game/OsuGame.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 94678a9dde..102df75420 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -75,10 +75,10 @@ namespace osu.Game { get { - Screen s = screenStack; - while (s != null && !(s is Intro)) - s = s.ChildScreen; - return s as Intro; + Screen screen = screenStack; + while (screen != null && !(screen is Intro)) + screen = screen.ChildScreen; + return screen as Intro; } } @@ -126,8 +126,8 @@ namespace osu.Game /// Whether the toolbar should also be hidden. public void CloseAllOverlays(bool toolbar = true) { - foreach (var o in overlays) - o.State = Visibility.Hidden; + foreach (var overlay in overlays) + overlay.State = Visibility.Hidden; if (toolbar) Toolbar.State = Visibility.Hidden; } @@ -244,7 +244,7 @@ namespace osu.Game /// The beatmap to show. public void ShowBeatmap(int beatmapId) => beatmapSetOverlay.FetchAndShowBeatmap(beatmapId); - protected void LoadScore(Score s) + protected void LoadScore(Score score) { scoreLoad?.Cancel(); @@ -252,18 +252,18 @@ namespace osu.Game if (menu == null) { - scoreLoad = Schedule(() => LoadScore(s)); + scoreLoad = Schedule(() => LoadScore(score)); return; } if (!menu.IsCurrentScreen) { menu.MakeCurrent(); - this.Delay(500).Schedule(() => LoadScore(s), out scoreLoad); + this.Delay(500).Schedule(() => LoadScore(score), out scoreLoad); return; } - if (s.Beatmap == null) + if (score.Beatmap == null) { notifications.Post(new SimpleNotification { @@ -273,12 +273,12 @@ namespace osu.Game return; } - ruleset.Value = s.Ruleset; + ruleset.Value = score.Ruleset; - Beatmap.Value = BeatmapManager.GetWorkingBeatmap(s.Beatmap); - Beatmap.Value.Mods.Value = s.Mods; + Beatmap.Value = BeatmapManager.GetWorkingBeatmap(score.Beatmap); + Beatmap.Value.Mods.Value = score.Mods; - menu.Push(new PlayerLoader(new ReplayPlayer(s.Replay))); + menu.Push(new PlayerLoader(new ReplayPlayer(score.Replay))); } protected override void Dispose(bool isDisposing) From 20817fdf1dc63cd7a378b8805185dc7a398bd48b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 30 Aug 2018 11:58:30 +0900 Subject: [PATCH 15/23] Avoid using symbol windows can't diplay --- osu.Game/OsuGame.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index f4afd23c1b..78c6fa052b 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -516,9 +516,9 @@ namespace osu.Game try { - Logger.Log($"{d}...", LoggingTarget.Debug); + Logger.Log($"Loading {d}...", LoggingTarget.Debug); await LoadComponentAsync(d, add); - Logger.Log($"{d} ✓", LoggingTarget.Debug); + Logger.Log($"Loaded {d}!", LoggingTarget.Debug); } catch (OperationCanceledException) { From 327bc708d7ed5a12cdafbdae4aa7a662523ae097 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 29 Aug 2018 15:56:24 +0900 Subject: [PATCH 16/23] Fix DirectOverlay performing webrequests on startup --- osu.Game/Overlays/DirectOverlay.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 423211659d..f63d314053 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -240,6 +240,15 @@ namespace osu.Game.Overlays }); } + protected override void PopIn() + { + base.PopIn(); + + // Queries are allowed to be run only on the first pop-in + if (getSetsRequest == null) + Scheduler.AddOnce(updateSearch); + } + private SearchBeatmapSetsRequest getSetsRequest; private readonly Bindable currentQuery = new Bindable(); @@ -251,16 +260,22 @@ namespace osu.Game.Overlays { queryChangedDebounce?.Cancel(); - if (!IsLoaded) return; + if (!IsLoaded) + return; + + if (State == Visibility.Hidden) + return; BeatmapSets = null; ResultAmounts = null; getSetsRequest?.Cancel(); - if (api == null) return; + if (api == null) + return; - if (Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || currentQuery == string.Empty)) return; + if (Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || currentQuery == string.Empty)) + return; previewTrackManager.StopAnyPlaying(this); From b1a3dfedd1f0f809da4365a8a09041d311d55266 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 29 Aug 2018 20:57:48 +0900 Subject: [PATCH 17/23] Reduce async-await pairs --- osu.Game/Beatmaps/BeatmapManager.cs | 6 +++--- osu.Game/Beatmaps/WorkingBeatmap.cs | 12 ++++++------ osu.Game/Graphics/ScreenshotManager.cs | 2 +- osu.Game/Skinning/LegacySkin.cs | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 774a80049b..1adbb4a389 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -319,17 +319,17 @@ namespace osu.Game.Beatmaps /// /// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future. /// - public async Task ImportFromStable() + public Task ImportFromStable() { var stable = GetStableStorage?.Invoke(); if (stable == null) { Logger.Log("No osu!stable installation available!", LoggingTarget.Information, LogLevel.Error); - return; + return Task.CompletedTask; } - await Task.Factory.StartNew(() => Import(stable.GetDirectories("Songs").Select(f => stable.GetFullPath(f)).ToArray()), TaskCreationOptions.LongRunning); + return Task.Factory.StartNew(() => Import(stable.GetDirectories("Songs").Select(f => stable.GetFullPath(f)).ToArray()), TaskCreationOptions.LongRunning); } /// diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 6c906bb1e4..085c591fce 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -67,7 +67,7 @@ namespace osu.Game.Beatmaps public bool BeatmapLoaded => beatmap.IsResultAvailable; public IBeatmap Beatmap => beatmap.Value.Result; - public async Task GetBeatmapAsync() => await beatmap.Value; + public Task GetBeatmapAsync() => beatmap.Value; private readonly AsyncLazy beatmap; private IBeatmap populateBeatmap() @@ -138,14 +138,14 @@ namespace osu.Game.Beatmaps public bool BackgroundLoaded => background.IsResultAvailable; public Texture Background => background.Value.Result; - public async Task GetBackgroundAsync() => await background.Value; + public Task GetBackgroundAsync() => background.Value; private AsyncLazy background; private Texture populateBackground() => GetBackground(); public bool TrackLoaded => track.IsResultAvailable; public Track Track => track.Value.Result; - public async Task GetTrackAsync() => await track.Value; + public Task GetTrackAsync() => track.Value; private AsyncLazy track; private Track populateTrack() @@ -158,21 +158,21 @@ namespace osu.Game.Beatmaps public bool WaveformLoaded => waveform.IsResultAvailable; public Waveform Waveform => waveform.Value.Result; - public async Task GetWaveformAsync() => await waveform.Value; + public Task GetWaveformAsync() => waveform.Value; private readonly AsyncLazy waveform; private Waveform populateWaveform() => GetWaveform(); public bool StoryboardLoaded => storyboard.IsResultAvailable; public Storyboard Storyboard => storyboard.Value.Result; - public async Task GetStoryboardAsync() => await storyboard.Value; + public Task GetStoryboardAsync() => storyboard.Value; private readonly AsyncLazy storyboard; private Storyboard populateStoryboard() => GetStoryboard(); public bool SkinLoaded => skin.IsResultAvailable; public Skin Skin => skin.Value.Result; - public async Task GetSkinAsync() => await skin.Value; + public Task GetSkinAsync() => skin.Value; private readonly AsyncLazy skin; private Skin populateSkin() => GetSkin(); diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index 63b97e3c59..8426dc995b 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -71,7 +71,7 @@ namespace osu.Game.Graphics private volatile int screenShotTasks; - public async Task TakeScreenshotAsync() => await Task.Run(async () => + public Task TakeScreenshotAsync() => Task.Run(async () => { Interlocked.Increment(ref screenShotTasks); diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index f9801c2f92..9c881c6abb 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -111,10 +111,10 @@ namespace osu.Game.Skinning byte[] IResourceStore.Get(string name) => GetAsync(name).Result; - public async Task GetAsync(string name) + public Task GetAsync(string name) { string path = getPathForFile(name); - return path == null ? null : await underlyingStore.GetAsync(path); + return path == null ? Task.FromResult(null) : underlyingStore.GetAsync(path); } #region IDisposable Support From 68a79f895a3e4e5d4473c0b9490b638ec1e09ecc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 30 Aug 2018 13:30:23 +0900 Subject: [PATCH 18/23] Fix mania throwing an exception on start of map --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 4 ++-- osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs | 2 +- osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs | 2 +- osu.Game/Rulesets/UI/Playfield.cs | 14 +++++++------- osu.Game/Rulesets/UI/RulesetContainer.cs | 2 +- .../Rulesets/UI/Scrolling/ScrollingPlayfield.cs | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 6bf63443b5..999f84ed8e 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -26,11 +26,11 @@ namespace osu.Game.Rulesets.Mania.UI throw new ArgumentException("Can't have zero or fewer stages."); GridContainer playfieldGrid; - InternalChild = playfieldGrid = new GridContainer + AddInternal(playfieldGrid = new GridContainer { RelativeSizeAxes = Axes.Both, Content = new[] { new Drawable[stageDefinitions.Count] } - }; + }); var normalColumnAction = ManiaAction.Key1; var specialColumnAction = ManiaAction.Special1; diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs b/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs index 4047e057cb..f3b7d60cf0 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs @@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Osu.Mods const float relax_leniency = 3; - foreach (var drawable in playfield.HitObjects.AliveObjects) + foreach (var drawable in playfield.HitObjectContainer.AliveObjects) { if (!(drawable is DrawableOsuHitObject osuHit)) continue; diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index 703d8764fc..61937a535c 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -61,7 +61,7 @@ namespace osu.Game.Rulesets.Osu.UI public override void PostProcess() { - connectionLayer.HitObjects = HitObjects.Objects.Select(d => d.HitObject).OfType(); + connectionLayer.HitObjects = HitObjectContainer.Objects.Select(d => d.HitObject).OfType(); } private void onNewResult(DrawableHitObject judgedObject, JudgementResult result) diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index da14fb54d6..e090a18eda 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -19,12 +19,12 @@ namespace osu.Game.Rulesets.UI /// /// The contained in this Playfield. /// - public HitObjectContainer HitObjects { get; private set; } + public HitObjectContainer HitObjectContainer { get; private set; } /// /// All the s contained in this and all . /// - public IEnumerable AllHitObjects => HitObjects?.Objects.Concat(NestedPlayfields.SelectMany(p => p.AllHitObjects)) ?? Enumerable.Empty(); + public IEnumerable AllHitObjects => HitObjectContainer?.Objects.Concat(NestedPlayfields.SelectMany(p => p.AllHitObjects)) ?? Enumerable.Empty(); /// /// All s nested inside this . @@ -60,10 +60,10 @@ namespace osu.Game.Rulesets.UI { this.beatmap = beatmap.Value; - HitObjects = CreateHitObjectContainer(); - HitObjects.RelativeSizeAxes = Axes.Both; + HitObjectContainer = CreateHitObjectContainer(); + HitObjectContainer.RelativeSizeAxes = Axes.Both; - Add(HitObjects); + Add(HitObjectContainer); } /// @@ -75,13 +75,13 @@ namespace osu.Game.Rulesets.UI /// Adds a DrawableHitObject to this Playfield. /// /// The DrawableHitObject to add. - public virtual void Add(DrawableHitObject h) => HitObjects.Add(h); + public virtual void Add(DrawableHitObject h) => HitObjectContainer.Add(h); /// /// Remove a DrawableHitObject from this Playfield. /// /// The DrawableHitObject to remove. - public virtual void Remove(DrawableHitObject h) => HitObjects.Remove(h); + public virtual void Remove(DrawableHitObject h) => HitObjectContainer.Remove(h); /// /// Registers a as a nested . diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 64ee680d45..a830803fb1 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -306,7 +306,7 @@ namespace osu.Game.Rulesets.UI Playfield.PostProcess(); foreach (var mod in Mods.OfType()) - mod.ApplyToDrawableHitObjects(Playfield.HitObjects.Objects); + mod.ApplyToDrawableHitObjects(Playfield.HitObjectContainer.Objects); } protected override void Update() diff --git a/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs b/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs index 7146ad8064..ec73c0fb14 100644 --- a/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs +++ b/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs @@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.UI.Scrolling /// /// The container that contains the s. /// - public new ScrollingHitObjectContainer HitObjects => (ScrollingHitObjectContainer)base.HitObjects; + public new ScrollingHitObjectContainer HitObjects => (ScrollingHitObjectContainer)HitObjectContainer; /// /// The direction in which s in this should scroll. From 9fb78852de5d27772c151a495f02964eb606d6e4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 30 Aug 2018 14:45:04 +0900 Subject: [PATCH 19/23] Update framework --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 0633d7913e..5cde8c87d1 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -18,7 +18,7 @@ - + From 3276f0f54d9ae0be4bdb24de5b633bd7c22cc357 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 30 Aug 2018 14:48:06 +0900 Subject: [PATCH 20/23] Update ef/sqlite version --- osu.Desktop/osu.Desktop.csproj | 4 ++-- osu.Game/osu.Game.csproj | 4 ++-- osu.TestProject.props | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 180abd7fec..e2fc4d14f6 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -28,8 +28,8 @@ - - + + diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 5cde8c87d1..2e7877f5ce 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/osu.TestProject.props b/osu.TestProject.props index a73a4f8ce2..58de6ec030 100644 --- a/osu.TestProject.props +++ b/osu.TestProject.props @@ -11,7 +11,7 @@ - + From 03084aa04ba7d09ebe4b9d3eda443769d6d51b3f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 31 Aug 2018 07:04:40 +0900 Subject: [PATCH 21/23] Revert async changes --- osu.Desktop/Overlays/VersionManager.cs | 5 ++--- osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 5 ++--- .../Objects/Drawables/Pieces/DefaultCirclePiece.cs | 5 ++--- osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs | 5 ++--- osu.Game.Rulesets.Taiko/UI/InputDrum.cs | 11 +++++------ osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs | 5 ++--- osu.Game/Graphics/Backgrounds/Background.cs | 5 ++--- .../Containers/OsuFocusedOverlayContainer.cs | 7 +++---- osu.Game/Graphics/Cursor/MenuCursor.cs | 7 +++---- osu.Game/Graphics/ScreenshotManager.cs | 4 ++-- osu.Game/Graphics/SpriteIcon.cs | 13 ++++++------- osu.Game/Graphics/Sprites/OsuSpriteText.cs | 2 +- osu.Game/Graphics/UserInterface/HoverClickSounds.cs | 5 ++--- osu.Game/Graphics/UserInterface/HoverSounds.cs | 5 ++--- osu.Game/Graphics/UserInterface/OsuCheckbox.cs | 7 +++---- osu.Game/Graphics/UserInterface/OsuMenu.cs | 7 +++---- osu.Game/Graphics/UserInterface/OsuSliderBar.cs | 5 ++--- osu.Game/Overlays/MedalOverlay.cs | 7 +++---- osu.Game/Overlays/MedalSplash/DrawableMedal.cs | 7 +++---- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 7 +++---- osu.Game/Overlays/MusicController.cs | 4 ++-- osu.Game/Overlays/Profile/Components/GradeBadge.cs | 5 ++--- osu.Game/Overlays/Profile/Header/BadgeContainer.cs | 5 ++--- osu.Game/Overlays/Profile/ProfileHeader.cs | 5 ++--- .../Overlays/Profile/Sections/Recent/MedalIcon.cs | 5 ++--- .../Screens/Backgrounds/BackgroundScreenBeatmap.cs | 5 ++--- osu.Game/Screens/Menu/Button.cs | 7 +++---- osu.Game/Screens/Menu/ButtonSystem.cs | 5 ++--- osu.Game/Screens/Menu/Intro.cs | 7 +++---- osu.Game/Screens/Menu/OsuLogo.cs | 11 +++++------ osu.Game/Screens/OsuScreen.cs | 5 ++--- osu.Game/Screens/Play/KeyCounter.cs | 7 +++---- osu.Game/Screens/Play/Player.cs | 4 ++-- osu.Game/Screens/Play/SkipOverlay.cs | 5 ++--- osu.Game/Screens/Ranking/ResultsPageScore.cs | 5 ++--- .../Screens/Select/Carousel/DrawableCarouselItem.cs | 5 ++--- .../Screens/Select/Leaderboards/DrawableRank.cs | 12 +++++++----- osu.Game/Screens/Select/PlaySongSelect.cs | 4 ++-- osu.Game/Screens/Select/SongSelect.cs | 7 +++---- .../Tournament/Components/VisualiserContainer.cs | 5 ++--- osu.Game/Screens/Tournament/Drawings.cs | 4 ++-- osu.Game/Screens/Tournament/Group.cs | 5 ++--- .../Screens/Tournament/ScrollingTeamContainer.cs | 5 ++--- osu.Game/Users/Avatar.cs | 7 +++---- osu.Game/Users/Country.cs | 9 ++++----- osu.Game/Users/UserCoverBackground.cs | 5 ++--- 46 files changed, 120 insertions(+), 157 deletions(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 740ad7c3be..1129969694 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.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -32,7 +31,7 @@ namespace osu.Desktop.Overlays public override bool HandleMouseInput => false; [BackgroundDependencyLoader] - private async Task load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config, GameHost host) + private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config, GameHost host) { notificationOverlay = notification; this.config = config; @@ -87,7 +86,7 @@ namespace osu.Desktop.Overlays { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Texture = await textures.GetAsync(@"Menu/dev-build-footer"), + Texture = textures.Get(@"Menu/dev-build-footer"), }, } } diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index 99d902d3e4..4327abb96f 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -3,7 +3,6 @@ using System; using System.Linq; -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -449,9 +448,9 @@ namespace osu.Game.Rulesets.Catch.UI } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { - Texture = await textures.GetAsync(@"Play/Catch/fruit-catcher-idle"); + Texture = textures.Get(@"Play/Catch/fruit-catcher-idle"); } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/DefaultCirclePiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/DefaultCirclePiece.cs index c7c81756eb..86b60c3443 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/DefaultCirclePiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/DefaultCirclePiece.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -13,7 +12,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces public class DefaultCirclePiece : Container { [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { RelativeSizeAxes = Axes.Both; Children = new Drawable[] @@ -22,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Texture = await textures.GetAsync(@"Play/osu/disc"), + Texture = textures.Get(@"Play/osu/disc"), }, new TrianglesPiece { diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs index 4b981dc406..abcd1ddbda 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs @@ -4,7 +4,6 @@ using System; using System.Diagnostics; using System.Runtime.InteropServices; -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.OpenGL.Buffers; @@ -80,10 +79,10 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; [BackgroundDependencyLoader] - private async Task load(ShaderManager shaders, TextureStore textures) + private void load(ShaderManager shaders, TextureStore textures) { shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE); - texture = await textures.GetAsync(@"Cursor/cursortrail"); + texture = textures.Get(@"Cursor/cursortrail"); Scale = new Vector2(1 / texture.ScaleAdjust); } diff --git a/osu.Game.Rulesets.Taiko/UI/InputDrum.cs b/osu.Game.Rulesets.Taiko/UI/InputDrum.cs index f525ce0ff3..524535bfde 100644 --- a/osu.Game.Rulesets.Taiko/UI/InputDrum.cs +++ b/osu.Game.Rulesets.Taiko/UI/InputDrum.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading.Tasks; using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -131,12 +130,12 @@ namespace osu.Game.Rulesets.Taiko.UI } [BackgroundDependencyLoader] - private async Task load(TextureStore textures, OsuColour colours) + private void load(TextureStore textures, OsuColour colours) { - rim.Texture = await textures.GetAsync(@"Play/Taiko/taiko-drum-outer"); - rimHit.Texture = await textures.GetAsync(@"Play/Taiko/taiko-drum-outer-hit"); - centre.Texture = await textures.GetAsync(@"Play/Taiko/taiko-drum-inner"); - centreHit.Texture = await textures.GetAsync(@"Play/Taiko/taiko-drum-inner-hit"); + rim.Texture = textures.Get(@"Play/Taiko/taiko-drum-outer"); + rimHit.Texture = textures.Get(@"Play/Taiko/taiko-drum-outer-hit"); + centre.Texture = textures.Get(@"Play/Taiko/taiko-drum-inner"); + centreHit.Texture = textures.Get(@"Play/Taiko/taiko-drum-inner-hit"); rimHit.Colour = colours.Blue; centreHit.Colour = colours.Pink; diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs index 9bba589f59..883c05f1e4 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; @@ -24,7 +23,7 @@ namespace osu.Game.Beatmaps.Drawables } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { string resource = null; @@ -42,7 +41,7 @@ namespace osu.Game.Beatmaps.Drawables } if (resource != null) - Texture = await textures.GetAsync(resource); + Texture = textures.Get(resource); } } diff --git a/osu.Game/Graphics/Backgrounds/Background.cs b/osu.Game/Graphics/Backgrounds/Background.cs index dcd1db56de..d5825a8c42 100644 --- a/osu.Game/Graphics/Backgrounds/Background.cs +++ b/osu.Game/Graphics/Backgrounds/Background.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -35,10 +34,10 @@ namespace osu.Game.Graphics.Backgrounds } [BackgroundDependencyLoader] - private async Task load(LargeTextureStore textures) + private void load(LargeTextureStore textures) { if (!string.IsNullOrEmpty(textureName)) - Sprite.Texture = await textures.GetAsync(textureName); + Sprite.Texture = textures.Get(textureName); } } } diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index effcc696ca..d2ab8441eb 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -38,15 +37,15 @@ namespace osu.Game.Graphics.Containers } [BackgroundDependencyLoader(true)] - private async Task load(OsuGame osuGame, AudioManager audio, PreviewTrackManager previewTrackManager) + private void load(OsuGame osuGame, AudioManager audio, PreviewTrackManager previewTrackManager) { this.previewTrackManager = previewTrackManager; if (osuGame != null) OverlayActivationMode.BindTo(osuGame.OverlayActivationMode); - samplePopIn = await audio.Sample.GetAsync(@"UI/overlay-pop-in"); - samplePopOut = await audio.Sample.GetAsync(@"UI/overlay-pop-out"); + samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in"); + samplePopOut = audio.Sample.Get(@"UI/overlay-pop-out"); StateChanged += onStateChanged; } diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index 92b45ebcb9..b55e1aa5dd 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Sprites; using osu.Game.Configuration; using System; -using System.Threading.Tasks; using JetBrains.Annotations; using osu.Framework.Graphics.Textures; using osu.Framework.Input.EventArgs; @@ -133,7 +132,7 @@ namespace osu.Game.Graphics.Cursor } [BackgroundDependencyLoader] - private async Task load(OsuConfigManager config, TextureStore textures, OsuColour colour) + private void load(OsuConfigManager config, TextureStore textures, OsuColour colour) { Children = new Drawable[] { @@ -144,14 +143,14 @@ namespace osu.Game.Graphics.Cursor { new Sprite { - Texture = await textures.GetAsync(@"Cursor/menu-cursor"), + Texture = textures.Get(@"Cursor/menu-cursor"), }, AdditiveLayer = new Sprite { Blending = BlendingMode.Additive, Colour = colour.Pink, Alpha = 0, - Texture = await textures.GetAsync(@"Cursor/menu-cursor-additive"), + Texture = textures.Get(@"Cursor/menu-cursor-additive"), }, } } diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index 8426dc995b..be253f65c1 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -42,7 +42,7 @@ namespace osu.Game.Graphics private SampleChannel shutter; [BackgroundDependencyLoader] - private async Task load(GameHost host, OsuConfigManager config, Storage storage, NotificationOverlay notificationOverlay, AudioManager audio) + private void load(GameHost host, OsuConfigManager config, Storage storage, NotificationOverlay notificationOverlay, AudioManager audio) { this.host = host; this.storage = storage.GetStorageForDirectory(@"screenshots"); @@ -51,7 +51,7 @@ namespace osu.Game.Graphics screenshotFormat = config.GetBindable(OsuSetting.ScreenshotFormat); captureMenuCursor = config.GetBindable(OsuSetting.ScreenshotCaptureMenuCursor); - shutter = await audio.Sample.GetAsync("UI/shutter"); + shutter = audio.Sample.Get("UI/shutter"); } public bool OnPressed(GlobalAction action) diff --git a/osu.Game/Graphics/SpriteIcon.cs b/osu.Game/Graphics/SpriteIcon.cs index 24b3f37505..b72ba7e02f 100644 --- a/osu.Game/Graphics/SpriteIcon.cs +++ b/osu.Game/Graphics/SpriteIcon.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -25,7 +24,7 @@ namespace osu.Game.Graphics private FontStore store; [BackgroundDependencyLoader] - private async Task load(FontStore store) + private void load(FontStore store) { this.store = store; @@ -56,23 +55,23 @@ namespace osu.Game.Graphics }, }; - await updateTexture(); + updateTexture(); } protected override void LoadComplete() { base.LoadComplete(); - updateTexture().Wait(); + updateTexture(); } private FontAwesome loadedIcon; - private async Task updateTexture() + private void updateTexture() { var loadableIcon = icon; if (loadableIcon == loadedIcon) return; - var texture = await store.GetAsync(((char)loadableIcon).ToString()); + var texture = store.Get(((char)loadableIcon).ToString()); spriteMain.Texture = texture; spriteShadow.Texture = texture; @@ -131,7 +130,7 @@ namespace osu.Game.Graphics icon = value; if (LoadState == LoadState.Loaded) - updateTexture().Wait(); + updateTexture(); } } } diff --git a/osu.Game/Graphics/Sprites/OsuSpriteText.cs b/osu.Game/Graphics/Sprites/OsuSpriteText.cs index 12b816184e..c9389bb9e2 100644 --- a/osu.Game/Graphics/Sprites/OsuSpriteText.cs +++ b/osu.Game/Graphics/Sprites/OsuSpriteText.cs @@ -22,7 +22,7 @@ namespace osu.Game.Graphics.Sprites protected override Drawable CreateFallbackCharacterDrawable() { - var tex = GetTextureForCharacter('?').Result; + var tex = GetTextureForCharacter('?'); if (tex != null) { diff --git a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs index 17924cdbb8..27a06ba0b7 100644 --- a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -29,9 +28,9 @@ namespace osu.Game.Graphics.UserInterface } [BackgroundDependencyLoader] - private async Task load(AudioManager audio) + private void load(AudioManager audio) { - sampleClick = await audio.Sample.GetAsync($@"UI/generic-select{SampleSet.GetDescription()}"); + sampleClick = audio.Sample.Get($@"UI/generic-select{SampleSet.GetDescription()}"); } } } diff --git a/osu.Game/Graphics/UserInterface/HoverSounds.cs b/osu.Game/Graphics/UserInterface/HoverSounds.cs index b3a83d1cc8..821305bc92 100644 --- a/osu.Game/Graphics/UserInterface/HoverSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverSounds.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.ComponentModel; -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -36,9 +35,9 @@ namespace osu.Game.Graphics.UserInterface } [BackgroundDependencyLoader] - private async Task load(AudioManager audio) + private void load(AudioManager audio) { - sampleHover = await audio.Sample.GetAsync($@"UI/generic-hover{SampleSet.GetDescription()}"); + sampleHover = audio.Sample.Get($@"UI/generic-hover{SampleSet.GetDescription()}"); } } diff --git a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs index d6b4b51851..68f59bd8cd 100644 --- a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -111,10 +110,10 @@ namespace osu.Game.Graphics.UserInterface } [BackgroundDependencyLoader] - private async Task load(AudioManager audio) + private void load(AudioManager audio) { - sampleChecked = await audio.Sample.GetAsync(@"UI/check-on"); - sampleUnchecked = await audio.Sample.GetAsync(@"UI/check-off"); + sampleChecked = audio.Sample.Get(@"UI/check-on"); + sampleUnchecked = audio.Sample.Get(@"UI/check-off"); } } } diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index b5ebac0c74..abb077e94f 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -70,10 +69,10 @@ namespace osu.Game.Graphics.UserInterface } [BackgroundDependencyLoader] - private async Task load(AudioManager audio) + private void load(AudioManager audio) { - sampleHover = await audio.Sample.GetAsync(@"UI/generic-hover"); - sampleClick = await audio.Sample.GetAsync(@"UI/generic-select"); + sampleHover = audio.Sample.Get(@"UI/generic-hover"); + sampleClick = audio.Sample.Get(@"UI/generic-select"); BackgroundColour = Color4.Transparent; BackgroundColourHover = OsuColour.FromHex(@"172023"); diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs index cd0b3dcad2..b7b5319e06 100644 --- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs @@ -3,7 +3,6 @@ using System; using System.Globalization; -using System.Threading.Tasks; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -120,9 +119,9 @@ namespace osu.Game.Graphics.UserInterface } [BackgroundDependencyLoader] - private async Task load(AudioManager audio, OsuColour colours) + private void load(AudioManager audio, OsuColour colours) { - sample = await audio.Sample.GetAsync(@"UI/sliderbar-notch"); + sample = audio.Sample.Get(@"UI/sliderbar-notch"); AccentColour = colours.Pink; } diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index 038fa936b0..bd67a718a7 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -20,7 +20,6 @@ using OpenTK.Input; using osu.Framework.Graphics.Shapes; using System; using System.Linq; -using System.Threading.Tasks; using osu.Framework.Input.States; using osu.Framework.MathUtils; @@ -144,10 +143,10 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private async Task load(OsuColour colours, TextureStore textures, AudioManager audio) + private void load(OsuColour colours, TextureStore textures, AudioManager audio) { - getSample = await audio.Sample.GetAsync(@"MedalSplash/medal-get"); - innerSpin.Texture = outerSpin.Texture = await textures.GetAsync(@"MedalSplash/disc-spin"); + getSample = audio.Sample.Get(@"MedalSplash/medal-get"); + innerSpin.Texture = outerSpin.Texture = textures.Get(@"MedalSplash/disc-spin"); disc.EdgeEffect = leftStrip.EdgeEffect = rightStrip.EdgeEffect = new EdgeEffectParameters { diff --git a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs index 9ced6520df..a27278e002 100644 --- a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs +++ b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading.Tasks; using osu.Framework; using OpenTK; using osu.Framework.Allocation; @@ -119,10 +118,10 @@ namespace osu.Game.Overlays.MedalSplash } [BackgroundDependencyLoader] - private async Task load(OsuColour colours, TextureStore textures) + private void load(OsuColour colours, TextureStore textures) { - medalSprite.Texture = await textures.GetAsync(medal.ImageUrl); - medalGlow.Texture = await textures.GetAsync(@"MedalSplash/medal-glow"); + medalSprite.Texture = textures.Get(medal.ImageUrl); + medalGlow.Texture = textures.Get(@"MedalSplash/medal-glow"); description.Colour = colours.BlueLight; } diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 783fcfa090..e83dedaf35 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -15,7 +15,6 @@ using osu.Game.Rulesets.Mods; using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Graphics.Shapes; @@ -50,7 +49,7 @@ namespace osu.Game.Overlays.Mods protected readonly IBindable Ruleset = new Bindable(); [BackgroundDependencyLoader(true)] - private async Task load(OsuColour colours, IBindable ruleset, AudioManager audio, Bindable> selectedMods) + private void load(OsuColour colours, IBindable ruleset, AudioManager audio, Bindable> selectedMods) { LowMultiplierColour = colours.Red; HighMultiplierColour = colours.Green; @@ -59,8 +58,8 @@ namespace osu.Game.Overlays.Mods Ruleset.BindTo(ruleset); if (selectedMods != null) SelectedMods.BindTo(selectedMods); - sampleOn = await audio.Sample.GetAsync(@"UI/check-on"); - sampleOff = await audio.Sample.GetAsync(@"UI/check-off"); + sampleOn = audio.Sample.Get(@"UI/check-on"); + sampleOff = audio.Sample.Get(@"UI/check-off"); } protected override void LoadComplete() diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 42f89a4863..886b5fb95b 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -454,9 +454,9 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { - sprite.Texture = beatmap?.Background ?? await textures.GetAsync(@"Backgrounds/bg4"); + sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg4"); } } diff --git a/osu.Game/Overlays/Profile/Components/GradeBadge.cs b/osu.Game/Overlays/Profile/Components/GradeBadge.cs index 3943a5f86b..14a47e8d03 100644 --- a/osu.Game/Overlays/Profile/Components/GradeBadge.cs +++ b/osu.Game/Overlays/Profile/Components/GradeBadge.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -43,9 +42,9 @@ namespace osu.Game.Overlays.Profile.Components } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { - badge.Texture = await textures.GetAsync($"Grades/{grade}"); + badge.Texture = textures.Get($"Grades/{grade}"); } } } diff --git a/osu.Game/Overlays/Profile/Header/BadgeContainer.cs b/osu.Game/Overlays/Profile/Header/BadgeContainer.cs index f87aefb28a..bfade5e45c 100644 --- a/osu.Game/Overlays/Profile/Header/BadgeContainer.cs +++ b/osu.Game/Overlays/Profile/Header/BadgeContainer.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -177,13 +176,13 @@ namespace osu.Game.Overlays.Profile.Header } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { Child = new Sprite { FillMode = FillMode.Fit, RelativeSizeAxes = Axes.Both, - Texture = await textures.GetAsync(badge.ImageUrl), + Texture = textures.Get(badge.ImageUrl), }; } diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 48048d2935..9d09836d25 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading.Tasks; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -312,9 +311,9 @@ namespace osu.Game.Overlays.Profile } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { - levelBadge.Texture = await textures.GetAsync(@"Profile/levelbadge"); + levelBadge.Texture = textures.Get(@"Profile/levelbadge"); } private User user; diff --git a/osu.Game/Overlays/Profile/Sections/Recent/MedalIcon.cs b/osu.Game/Overlays/Profile/Sections/Recent/MedalIcon.cs index 2eec75c875..0d354c728f 100644 --- a/osu.Game/Overlays/Profile/Sections/Recent/MedalIcon.cs +++ b/osu.Game/Overlays/Profile/Sections/Recent/MedalIcon.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; @@ -31,9 +30,9 @@ namespace osu.Game.Overlays.Profile.Sections.Recent } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { - sprite.Texture = await textures.GetAsync(url); + sprite.Texture = textures.Get(url); } } } diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 14d4cab870..78561cecbf 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; @@ -76,9 +75,9 @@ namespace osu.Game.Screens.Backgrounds } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { - Sprite.Texture = beatmap?.Background ?? await textures.GetAsync(@"Backgrounds/bg1"); + Sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg1"); } } } diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index 3593568578..e53905a102 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading.Tasks; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -180,11 +179,11 @@ namespace osu.Game.Screens.Menu } [BackgroundDependencyLoader] - private async Task load(AudioManager audio) + private void load(AudioManager audio) { - sampleHover = await audio.Sample.GetAsync(@"Menu/button-hover"); + sampleHover = audio.Sample.Get(@"Menu/button-hover"); if (!string.IsNullOrEmpty(sampleName)) - sampleClick = await audio.Sample.GetAsync($@"Menu/{sampleName}"); + sampleClick = audio.Sample.Get($@"Menu/{sampleName}"); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 4137028527..b9a799328e 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -103,10 +102,10 @@ namespace osu.Game.Screens.Menu private OsuGame game; [BackgroundDependencyLoader(true)] - private async Task load(AudioManager audio, OsuGame game) + private void load(AudioManager audio, OsuGame game) { this.game = game; - sampleBack = await audio.Sample.GetAsync(@"Menu/button-back-select"); + sampleBack = audio.Sample.Get(@"Menu/button-back-select"); } public bool OnPressed(GlobalAction action) diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 5d39d70e26..c1032011f7 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -48,7 +47,7 @@ namespace osu.Game.Screens.Menu private WorkingBeatmap introBeatmap; [BackgroundDependencyLoader] - private async Task load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game, BindableBeatmap beatmap) + private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game, BindableBeatmap beatmap) { this.beatmap.BindTo(beatmap); @@ -81,8 +80,8 @@ namespace osu.Game.Screens.Menu introBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); track = introBeatmap.Track; - welcome = await audio.Sample.GetAsync(@"welcome"); - seeya = await audio.Sample.GetAsync(@"seeya"); + welcome = audio.Sample.Get(@"welcome"); + seeya = audio.Sample.Get(@"seeya"); } private const double delay_step_one = 2300; diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index c6cfd9ba2d..f0f765a4c9 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -254,13 +253,13 @@ namespace osu.Game.Screens.Menu } [BackgroundDependencyLoader] - private async Task load(TextureStore textures, AudioManager audio) + private void load(TextureStore textures, AudioManager audio) { - sampleClick = await audio.Sample.GetAsync(@"Menu/osu-logo-select"); - sampleBeat = await audio.Sample.GetAsync(@"Menu/osu-logo-heartbeat"); + sampleClick = audio.Sample.Get(@"Menu/osu-logo-select"); + sampleBeat = audio.Sample.Get(@"Menu/osu-logo-heartbeat"); - logo.Texture = await textures.GetAsync(@"Menu/logo"); - ripple.Texture = await textures.GetAsync(@"Menu/logo"); + logo.Texture = textures.Get(@"Menu/logo"); + ripple.Texture = textures.Get(@"Menu/logo"); } private int lastBeatIndex; diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 3929e631cf..4b893f0118 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Internal; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -81,7 +80,7 @@ namespace osu.Game.Screens private SampleChannel sampleExit; [BackgroundDependencyLoader(true)] - private async Task load(BindableBeatmap beatmap, OsuGame osu, AudioManager audio, Bindable ruleset) + private void load(BindableBeatmap beatmap, OsuGame osu, AudioManager audio, Bindable ruleset) { Beatmap.BindTo(beatmap); Ruleset.BindTo(ruleset); @@ -99,7 +98,7 @@ namespace osu.Game.Screens }; } - sampleExit = await audio.Sample.GetAsync(@"UI/screen-back"); + sampleExit = audio.Sample.Get(@"UI/screen-back"); } public virtual bool OnPressed(GlobalAction action) diff --git a/osu.Game/Screens/Play/KeyCounter.cs b/osu.Game/Screens/Play/KeyCounter.cs index 49500a8426..2c31e61114 100644 --- a/osu.Game/Screens/Play/KeyCounter.cs +++ b/osu.Game/Screens/Play/KeyCounter.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -62,19 +61,19 @@ namespace osu.Game.Screens.Play } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { Children = new Drawable[] { buttonSprite = new Sprite { - Texture = await textures.GetAsync(@"KeyCounter/key-up"), + Texture = textures.Get(@"KeyCounter/key-up"), Anchor = Anchor.Centre, Origin = Anchor.Centre, }, glowSprite = new Sprite { - Texture = await textures.GetAsync(@"KeyCounter/key-glow"), + Texture = textures.Get(@"KeyCounter/key-glow"), Anchor = Anchor.Centre, Origin = Anchor.Centre, Alpha = 0 diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 863d12c1c2..5ad0130fd7 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -84,7 +84,7 @@ namespace osu.Game.Screens.Play public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true; [BackgroundDependencyLoader] - private async Task load(AudioManager audio, APIAccess api, OsuConfigManager config) + private void load(AudioManager audio, APIAccess api, OsuConfigManager config) { this.api = api; @@ -92,7 +92,7 @@ namespace osu.Game.Screens.Play if (working is DummyWorkingBeatmap) return; - sampleRestart = await audio.Sample.GetAsync(@"Gameplay/restart"); + sampleRestart = audio.Sample.Get(@"Gameplay/restart"); mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); userAudioOffset = config.GetBindable(OsuSetting.AudioOffset); diff --git a/osu.Game/Screens/Play/SkipOverlay.cs b/osu.Game/Screens/Play/SkipOverlay.cs index 9aaaa6152c..06837c9274 100644 --- a/osu.Game/Screens/Play/SkipOverlay.cs +++ b/osu.Game/Screens/Play/SkipOverlay.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading.Tasks; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -225,12 +224,12 @@ namespace osu.Game.Screens.Play } [BackgroundDependencyLoader] - private async Task load(OsuColour colours, AudioManager audio) + private void load(OsuColour colours, AudioManager audio) { colourNormal = colours.Yellow; colourHover = colours.YellowDark; - sampleConfirm = await audio.Sample.GetAsync(@"SongSelect/confirm-selection"); + sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection"); Children = new Drawable[] { diff --git a/osu.Game/Screens/Ranking/ResultsPageScore.cs b/osu.Game/Screens/Ranking/ResultsPageScore.cs index 87e53b8182..42d8af07b9 100644 --- a/osu.Game/Screens/Ranking/ResultsPageScore.cs +++ b/osu.Game/Screens/Ranking/ResultsPageScore.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -369,10 +368,10 @@ namespace osu.Game.Screens.Ranking } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { if (!string.IsNullOrEmpty(user.CoverUrl)) - cover.Texture = await textures.GetAsync(user.CoverUrl); + cover.Texture = textures.Get(user.CoverUrl); } } diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselItem.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselItem.cs index b252f116ac..8a0052559e 100644 --- a/osu.Game/Screens/Select/Carousel/DrawableCarouselItem.cs +++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselItem.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -46,7 +45,7 @@ namespace osu.Game.Screens.Select.Carousel private SampleChannel sampleHover; [BackgroundDependencyLoader] - private async Task load(AudioManager audio, OsuColour colours) + private void load(AudioManager audio, OsuColour colours) { InternalChild = borderContainer = new Container { @@ -69,7 +68,7 @@ namespace osu.Game.Screens.Select.Carousel } }; - sampleHover = await audio.Sample.GetAsync($@"SongSelect/song-ping-variation-{RNG.Next(1, 5)}"); + sampleHover = audio.Sample.Get($@"SongSelect/song-ping-variation-{RNG.Next(1, 5)}"); hoverLayer.Colour = colours.Blue.Opacity(0.1f); } diff --git a/osu.Game/Screens/Select/Leaderboards/DrawableRank.cs b/osu.Game/Screens/Select/Leaderboards/DrawableRank.cs index f5f9ebbdaf..0cf1e60304 100644 --- a/osu.Game/Screens/Select/Leaderboards/DrawableRank.cs +++ b/osu.Game/Screens/Select/Leaderboards/DrawableRank.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -36,20 +35,23 @@ namespace osu.Game.Screens.Select.Leaderboards } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { this.textures = textures; - await updateTexture(); + updateTexture(); } - private async Task updateTexture() => rankSprite.Texture = await textures.GetAsync($@"Grades/{Rank.GetDescription()}"); + private void updateTexture() + { + rankSprite.Texture = textures.Get($@"Grades/{Rank.GetDescription()}"); + } public void UpdateRank(ScoreRank newRank) { Rank = newRank; if (LoadState >= LoadState.Ready) - updateTexture().Wait(); + updateTexture(); } } } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index cab7bdfe73..e914eb365e 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -55,11 +55,11 @@ namespace osu.Game.Screens.Select private readonly Bindable> selectedMods = new Bindable>(new Mod[] { }); [BackgroundDependencyLoader(true)] - private async Task load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, Bindable> selectedMods) + private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, Bindable> selectedMods) { if (selectedMods != null) this.selectedMods.BindTo(selectedMods); - sampleConfirm = await audio.Sample.GetAsync(@"SongSelect/confirm-selection"); + sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection"); Footer.AddButton(@"mods", colours.Yellow, modSelect, Key.F1, float.MaxValue); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index ac765c46ab..efdf55e477 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -3,7 +3,6 @@ using System; using System.Linq; -using System.Threading.Tasks; using OpenTK; using OpenTK.Input; using osu.Framework.Allocation; @@ -199,7 +198,7 @@ namespace osu.Game.Screens.Select } [BackgroundDependencyLoader(true)] - private async Task load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours) + private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours) { if (Footer != null) { @@ -219,8 +218,8 @@ namespace osu.Game.Screens.Select dialogOverlay = dialog; - sampleChangeDifficulty = await audio.Sample.GetAsync(@"SongSelect/select-difficulty"); - sampleChangeBeatmap = await audio.Sample.GetAsync(@"SongSelect/select-expand"); + sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty"); + sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand"); Carousel.LoadBeatmapSetsFromManager(this.beatmaps); } diff --git a/osu.Game/Screens/Tournament/Components/VisualiserContainer.cs b/osu.Game/Screens/Tournament/Components/VisualiserContainer.cs index 835b0757e0..1453d4e78f 100644 --- a/osu.Game/Screens/Tournament/Components/VisualiserContainer.cs +++ b/osu.Game/Screens/Tournament/Components/VisualiserContainer.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics.Textures; using osu.Framework.MathUtils; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; namespace osu.Game.Screens.Tournament.Components { @@ -76,9 +75,9 @@ namespace osu.Game.Screens.Tournament.Components private int expiredCount; [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { - texture = await textures.GetAsync("Drawings/visualiser-line"); + texture = textures.Get("Drawings/visualiser-line"); } protected override void UpdateAfterChildren() diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 20180a660f..63d29d5cd7 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -53,7 +53,7 @@ namespace osu.Game.Screens.Tournament dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); [BackgroundDependencyLoader] - private async Task load(TextureStore textures, Storage storage) + private void load(TextureStore textures, Storage storage) { this.storage = storage; @@ -87,7 +87,7 @@ namespace osu.Game.Screens.Tournament { RelativeSizeAxes = Axes.Both, FillMode = FillMode.Fill, - Texture = await textures.GetAsync(@"Backgrounds/Drawings/background.png") + Texture = textures.Get(@"Backgrounds/Drawings/background.png") }, new FillFlowContainer { diff --git a/osu.Game/Screens/Tournament/Group.cs b/osu.Game/Screens/Tournament/Group.cs index 5128166c15..6845d8fc48 100644 --- a/osu.Game/Screens/Tournament/Group.cs +++ b/osu.Game/Screens/Tournament/Group.cs @@ -4,7 +4,6 @@ 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; @@ -179,9 +178,9 @@ namespace osu.Game.Screens.Tournament } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { - flagSprite.Texture = await textures.GetAsync($@"Flags/{Team.FlagName}"); + flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}"); } } } diff --git a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs index cc9f805c62..d1c7e0fced 100644 --- a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs +++ b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -373,9 +372,9 @@ namespace osu.Game.Screens.Tournament } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { - flagSprite.Texture = await textures.GetAsync($@"Flags/{Team.FlagName}"); + flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}"); } } } diff --git a/osu.Game/Users/Avatar.cs b/osu.Game/Users/Avatar.cs index 9aac662a84..9ba9549164 100644 --- a/osu.Game/Users/Avatar.cs +++ b/osu.Game/Users/Avatar.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -25,14 +24,14 @@ namespace osu.Game.Users } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { if (textures == null) throw new ArgumentNullException(nameof(textures)); Texture texture = null; - if (user != null && user.Id > 1) texture = await textures.GetAsync($@"https://a.ppy.sh/{user.Id}"); - if (texture == null) texture = await textures.GetAsync(@"Online/avatar-guest"); + if (user != null && user.Id > 1) texture = textures.Get($@"https://a.ppy.sh/{user.Id}"); + if (texture == null) texture = textures.Get(@"Online/avatar-guest"); Add(new Sprite { diff --git a/osu.Game/Users/Country.cs b/osu.Game/Users/Country.cs index a37ca10f9a..80039eadad 100644 --- a/osu.Game/Users/Country.cs +++ b/osu.Game/Users/Country.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading.Tasks; using Newtonsoft.Json; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -45,7 +44,7 @@ namespace osu.Game.Users country = value; if (LoadState >= LoadState.Ready) - sprite.Texture = getFlagTexture().Result; + sprite.Texture = getFlagTexture(); } } @@ -65,15 +64,15 @@ namespace osu.Game.Users } [BackgroundDependencyLoader] - private async Task load(TextureStore ts) + private void load(TextureStore ts) { if (ts == null) throw new ArgumentNullException(nameof(ts)); textures = ts; - sprite.Texture = await getFlagTexture(); + sprite.Texture = getFlagTexture(); } - private async Task getFlagTexture() => await textures.GetAsync($@"Flags/{country?.FlagName ?? @"__"}"); + private Texture getFlagTexture() => textures.Get($@"Flags/{country?.FlagName ?? @"__"}"); } } diff --git a/osu.Game/Users/UserCoverBackground.cs b/osu.Game/Users/UserCoverBackground.cs index 97d2648e07..58b92b2750 100644 --- a/osu.Game/Users/UserCoverBackground.cs +++ b/osu.Game/Users/UserCoverBackground.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; @@ -19,13 +18,13 @@ namespace osu.Game.Users } [BackgroundDependencyLoader] - private async Task load(TextureStore textures) + private void load(TextureStore textures) { if (textures == null) throw new ArgumentNullException(nameof(textures)); if (!string.IsNullOrEmpty(user.CoverUrl)) - Texture = await textures.GetAsync(user.CoverUrl); + Texture = textures.Get(user.CoverUrl); } } } From 4c725659363feb890b75d0931245555d3dc47ec1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 31 Aug 2018 19:20:10 +0900 Subject: [PATCH 22/23] Update framework --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2e7877f5ce..61b7888513 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -18,7 +18,7 @@ - + From 62a8245f11577226336b76572fb3a1b915af254e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 1 Sep 2018 10:59:04 +0900 Subject: [PATCH 23/23] Update framework --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 61b7888513..669b775674 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -18,7 +18,7 @@ - +