mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 09:03:01 +08:00
Update framework and add "Async" suffix to asynchronous methods
This commit is contained in:
parent
c3ab467e24
commit
2689de0c0c
@ -1 +1 @@
|
|||||||
Subproject commit 56535b834cf2329e5abc8ecf698d19ece9ef7b07
|
Subproject commit 24d94c2c3c625b614ffb19f2d1297bdfd1169f6b
|
@ -21,7 +21,7 @@ namespace osu.Desktop.VisualTests
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
(new BackgroundScreenDefault() { Depth = 10 }).Preload(this, AddInternal);
|
(new BackgroundScreenDefault() { Depth = 10 }).LoadAsync(this, AddInternal);
|
||||||
|
|
||||||
// Have to construct this here, rather than in the constructor, because
|
// Have to construct this here, rather than in the constructor, because
|
||||||
// we depend on some dependencies to be loaded within OsuGameBase.load().
|
// we depend on some dependencies to be loaded within OsuGameBase.load().
|
||||||
|
@ -34,7 +34,7 @@ namespace osu.Desktop
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
versionManager.Preload(this);
|
versionManager.LoadAsync(this);
|
||||||
ModeChanged += m =>
|
ModeChanged += m =>
|
||||||
{
|
{
|
||||||
if (!versionManager.IsAlive && m is Intro)
|
if (!versionManager.IsAlive && m is Intro)
|
||||||
|
@ -104,7 +104,7 @@ namespace osu.Desktop.Overlays
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (IsDeployedBuild)
|
if (IsDeployedBuild)
|
||||||
updateChecker();
|
checkForUpdateAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -119,7 +119,7 @@ namespace osu.Desktop.Overlays
|
|||||||
updateManager?.Dispose();
|
updateManager?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void updateChecker(bool useDeltaPatching = true, UpdateProgressNotification notification = null)
|
private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null)
|
||||||
{
|
{
|
||||||
//should we schedule a retry on completion of this check?
|
//should we schedule a retry on completion of this check?
|
||||||
bool scheduleRetry = true;
|
bool scheduleRetry = true;
|
||||||
@ -165,7 +165,7 @@ namespace osu.Desktop.Overlays
|
|||||||
{
|
{
|
||||||
//could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959)
|
//could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959)
|
||||||
//try again without deltas.
|
//try again without deltas.
|
||||||
updateChecker(false, notification);
|
checkForUpdateAsync(false, notification);
|
||||||
scheduleRetry = false;
|
scheduleRetry = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ namespace osu.Desktop.Overlays
|
|||||||
if (scheduleRetry)
|
if (scheduleRetry)
|
||||||
{
|
{
|
||||||
//check again in 30 minutes.
|
//check again in 30 minutes.
|
||||||
Scheduler.AddDelayed(() => updateChecker(), 60000 * 30);
|
Scheduler.AddDelayed(() => checkForUpdateAsync(), 60000 * 30);
|
||||||
if (notification != null)
|
if (notification != null)
|
||||||
notification.State = ProgressNotificationState.Cancelled;
|
notification.State = ProgressNotificationState.Cancelled;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ namespace osu.Desktop
|
|||||||
foreach (var file in args)
|
foreach (var file in args)
|
||||||
{
|
{
|
||||||
Console.WriteLine(@"Importing {0}", file);
|
Console.WriteLine(@"Importing {0}", file);
|
||||||
if (!importer.Import(Path.GetFullPath(file)).Wait(3000))
|
if (!importer.ImportAsync(Path.GetFullPath(file)).Wait(3000))
|
||||||
throw new TimeoutException(@"IPC took too long to send");
|
throw new TimeoutException(@"IPC took too long to send");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
var osu = loadOsu(host);
|
var osu = loadOsu(host);
|
||||||
|
|
||||||
var importer = new BeatmapImporter(client);
|
var importer = new BeatmapImporter(client);
|
||||||
if (!importer.Import(osz_path).Wait(1000))
|
if (!importer.ImportAsync(osz_path).Wait(1000))
|
||||||
Assert.Fail(@"IPC took too long to send");
|
Assert.Fail(@"IPC took too long to send");
|
||||||
|
|
||||||
ensureLoaded(osu, 10000);
|
ensureLoaded(osu, 10000);
|
||||||
|
@ -162,7 +162,7 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
FillMode = FillMode.Fill,
|
FillMode = FillMode.Fill,
|
||||||
}.Preload(game, (bg) =>
|
}.LoadAsync(game, (bg) =>
|
||||||
{
|
{
|
||||||
Add(bg);
|
Add(bg);
|
||||||
ForceRedraw();
|
ForceRedraw();
|
||||||
|
@ -21,13 +21,13 @@ namespace osu.Game.IPC
|
|||||||
channel.MessageReceived += messageReceived;
|
channel.MessageReceived += messageReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Import(string path)
|
public async Task ImportAsync(string path)
|
||||||
{
|
{
|
||||||
if (beatmaps != null)
|
if (beatmaps != null)
|
||||||
beatmaps.Import(path);
|
beatmaps.Import(path);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await channel.SendMessage(new BeatmapImportMessage { Path = path });
|
await channel.SendMessageAsync(new BeatmapImportMessage { Path = path });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ namespace osu.Game.IPC
|
|||||||
{
|
{
|
||||||
Debug.Assert(beatmaps != null);
|
Debug.Assert(beatmaps != null);
|
||||||
|
|
||||||
Import(msg.Path);
|
ImportAsync(msg.Path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ namespace osu.Game
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
(screenStack = new Loader()).Preload(this, d =>
|
(screenStack = new Loader()).LoadAsync(this, d =>
|
||||||
{
|
{
|
||||||
screenStack.ModePushed += screenAdded;
|
screenStack.ModePushed += screenAdded;
|
||||||
screenStack.Exited += screenRemoved;
|
screenStack.Exited += screenRemoved;
|
||||||
@ -124,22 +124,22 @@ namespace osu.Game
|
|||||||
});
|
});
|
||||||
|
|
||||||
//overlay elements
|
//overlay elements
|
||||||
(chat = new ChatOverlay { Depth = 0 }).Preload(this, overlayContent.Add);
|
(chat = new ChatOverlay { Depth = 0 }).LoadAsync(this, overlayContent.Add);
|
||||||
(options = new OptionsOverlay { Depth = -1 }).Preload(this, overlayContent.Add);
|
(options = new OptionsOverlay { Depth = -1 }).LoadAsync(this, overlayContent.Add);
|
||||||
(musicController = new MusicController()
|
(musicController = new MusicController()
|
||||||
{
|
{
|
||||||
Depth = -2,
|
Depth = -2,
|
||||||
Position = new Vector2(0, Toolbar.HEIGHT),
|
Position = new Vector2(0, Toolbar.HEIGHT),
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
}).Preload(this, overlayContent.Add);
|
}).LoadAsync(this, overlayContent.Add);
|
||||||
|
|
||||||
(notificationManager = new NotificationManager
|
(notificationManager = new NotificationManager
|
||||||
{
|
{
|
||||||
Depth = -2,
|
Depth = -2,
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
}).Preload(this, overlayContent.Add);
|
}).LoadAsync(this, overlayContent.Add);
|
||||||
|
|
||||||
Logger.NewEntry += entry =>
|
Logger.NewEntry += entry =>
|
||||||
{
|
{
|
||||||
@ -160,7 +160,7 @@ namespace osu.Game
|
|||||||
Depth = -3,
|
Depth = -3,
|
||||||
OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); },
|
OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); },
|
||||||
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
|
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
|
||||||
}).Preload(this, t =>
|
}).LoadAsync(this, t =>
|
||||||
{
|
{
|
||||||
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
|
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
|
||||||
PlayMode.TriggerChange();
|
PlayMode.TriggerChange();
|
||||||
|
@ -322,10 +322,10 @@ namespace osu.Game.Overlays
|
|||||||
updateDisplay(current, isNext ? TransformDirection.Next : TransformDirection.Prev);
|
updateDisplay(current, isNext ? TransformDirection.Next : TransformDirection.Prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PerformLoad(Framework.Game game)
|
protected override void Load(Framework.Game game)
|
||||||
{
|
{
|
||||||
this.game = game;
|
this.game = game;
|
||||||
base.PerformLoad(game);
|
base.Load(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
Action pendingBeatmapSwitch;
|
Action pendingBeatmapSwitch;
|
||||||
@ -349,7 +349,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
MusicControllerBackground newBackground;
|
MusicControllerBackground newBackground;
|
||||||
|
|
||||||
(newBackground = new MusicControllerBackground(beatmap)).Preload(game, delegate
|
(newBackground = new MusicControllerBackground(beatmap)).LoadAsync(game, delegate
|
||||||
{
|
{
|
||||||
|
|
||||||
dragContainer.Add(newBackground);
|
dragContainer.Add(newBackground);
|
||||||
|
@ -102,7 +102,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
|
|
||||||
newSprite.FillMode = FillMode.Fit;
|
newSprite.FillMode = FillMode.Fit;
|
||||||
|
|
||||||
newSprite.Preload(game, s =>
|
newSprite.LoadAsync(game, s =>
|
||||||
{
|
{
|
||||||
Sprite?.FadeOut();
|
Sprite?.FadeOut();
|
||||||
Sprite?.Expire();
|
Sprite?.Expire();
|
||||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Screens
|
|||||||
// once it's done.
|
// once it's done.
|
||||||
if (screen.LoadState == LoadState.NotLoaded)
|
if (screen.LoadState == LoadState.NotLoaded)
|
||||||
{
|
{
|
||||||
screen.Preload(game, d => Push((BackgroundScreen)d));
|
screen.LoadAsync(game, d => Push((BackgroundScreen)d));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
else
|
else
|
||||||
newBackground = new BeatmapBackground(beatmap);
|
newBackground = new BeatmapBackground(beatmap);
|
||||||
|
|
||||||
newBackground.Preload(Game, delegate
|
newBackground.LoadAsync(Game, delegate
|
||||||
{
|
{
|
||||||
float newDepth = 0;
|
float newDepth = 0;
|
||||||
if (background != null)
|
if (background != null)
|
||||||
|
@ -20,9 +20,9 @@ namespace osu.Game.Screens
|
|||||||
private void load(OsuGame game)
|
private void load(OsuGame game)
|
||||||
{
|
{
|
||||||
if (game.IsDeployedBuild)
|
if (game.IsDeployedBuild)
|
||||||
new Disclaimer().Preload(game, d => Push((Screen)d));
|
new Disclaimer().LoadAsync(game, d => Push((Screen)d));
|
||||||
else
|
else
|
||||||
new Intro().Preload(game, d => Push((Screen)d));
|
new Intro().LoadAsync(game, d => Push((Screen)d));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuGame game, OsuColour colours)
|
private void load(OsuGame game, OsuColour colours)
|
||||||
{
|
{
|
||||||
(intro = new Intro()).Preload(game);
|
(intro = new Intro()).LoadAsync(game);
|
||||||
|
|
||||||
iconColour = colours.Yellow;
|
iconColour = colours.Yellow;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
bgm.Start();
|
bgm.Start();
|
||||||
|
|
||||||
(mainMenu = new MainMenu()).Preload(Game);
|
(mainMenu = new MainMenu()).LoadAsync(Game);
|
||||||
|
|
||||||
Scheduler.AddDelayed(delegate
|
Scheduler.AddDelayed(delegate
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuGame game)
|
private void load(OsuGame game)
|
||||||
{
|
{
|
||||||
background.Preload(game);
|
background.LoadAsync(game);
|
||||||
|
|
||||||
buttons.OnSettings = game.ToggleOptions;
|
buttons.OnSettings = game.ToggleOptions;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
var newPlayer = new Player();
|
var newPlayer = new Player();
|
||||||
|
|
||||||
newPlayer.Preload(Game, delegate
|
newPlayer.LoadAsync(Game, delegate
|
||||||
{
|
{
|
||||||
newPlayer.RestartCount = RestartCount + 1;
|
newPlayer.RestartCount = RestartCount + 1;
|
||||||
ValidForResume = false;
|
ValidForResume = false;
|
||||||
|
@ -57,7 +57,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
});
|
});
|
||||||
|
|
||||||
player.Preload(Game);
|
player.LoadAsync(Game);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnEntering(Screen last)
|
protected override void OnEntering(Screen last)
|
||||||
|
@ -179,7 +179,7 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}).Preload(game, delegate (Drawable d)
|
}).LoadAsync(game, delegate (Drawable d)
|
||||||
{
|
{
|
||||||
FadeIn(250);
|
FadeIn(250);
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap,
|
BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap,
|
||||||
PreferredPlayMode = playMode.Value
|
PreferredPlayMode = playMode.Value
|
||||||
})).Preload(Game, l => Push(player));
|
})).LoadAsync(Game, l => Push(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -340,7 +340,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
//for the time being, let's completely load the difficulty panels in the background.
|
//for the time being, let's completely load the difficulty panels in the background.
|
||||||
//this likely won't scale so well, but allows us to completely async the loading flow.
|
//this likely won't scale so well, but allows us to completely async the loading flow.
|
||||||
Task.WhenAll(group.BeatmapPanels.Select(panel => panel.Preload(game))).ContinueWith(task => Schedule(delegate
|
Task.WhenAll(group.BeatmapPanels.Select(panel => panel.LoadAsync(game))).ContinueWith(task => Schedule(delegate
|
||||||
{
|
{
|
||||||
beatmapGroups.Add(group);
|
beatmapGroups.Add(group);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user