1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-14 07:24:04 +08:00

Compare commits

...

17 Commits

13 changed files with 108 additions and 19 deletions
+2
View File
@@ -111,6 +111,8 @@ namespace osu.Desktop.Overlays
private class UpdateCompleteNotification : SimpleNotification
{
public override bool IsImportant => true;
public UpdateCompleteNotification(string version, Action<string> openUrl = null)
{
Text = $"You are now running osu!lazer {version}.\nClick to see what's new!";
+14 -1
View File
@@ -45,6 +45,11 @@ namespace osu.Game.Beatmaps
/// </summary>
public event Action<DownloadBeatmapSetRequest> BeatmapDownloadBegan;
/// <summary>
/// Fired when a beatmap load is requested (into the interactive game UI).
/// </summary>
public Action<BeatmapSetInfo> PresentBeatmap;
/// <summary>
/// A default representation of a WorkingBeatmap to use when no beatmap is available.
/// </summary>
@@ -163,12 +168,20 @@ namespace osu.Game.Beatmaps
Task.Factory.StartNew(() =>
{
BeatmapSetInfo importedBeatmap;
// This gets scheduled back to the update thread, but we want the import to run in the background.
using (var stream = new MemoryStream(data))
using (var archive = new ZipArchiveReader(stream, beatmapSetInfo.ToString()))
Import(archive);
importedBeatmap = Import(archive);
downloadNotification.CompletionClickAction = () =>
{
PresentBeatmap?.Invoke(importedBeatmap);
return true;
};
downloadNotification.State = ProgressNotificationState.Completed;
currentDownloads.Remove(request);
}, TaskCreationOptions.LongRunning);
};
+6 -1
View File
@@ -116,7 +116,7 @@ namespace osu.Game.Database
/// <param name="paths">One or more archive locations on disk.</param>
public void Import(params string[] paths)
{
var notification = new ProgressNotification
var notification = new ImportNotification
{
Text = "Import is initialising...",
Progress = 0,
@@ -407,5 +407,10 @@ namespace osu.Game.Database
return new LegacyFilesystemReader(path);
throw new InvalidFormatException($"{path} is not a valid archive");
}
private class ImportNotification : ProgressNotification
{
public override bool IsImportant => true;
}
}
}
+38
View File
@@ -24,6 +24,7 @@ using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Platform;
using osu.Framework.Threading;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Rulesets.Scoring;
using osu.Game.Overlays.Notifications;
@@ -34,6 +35,7 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Skinning;
using OpenTK.Graphics;
using osu.Game.Overlays.Volume;
using osu.Game.Screens.Select;
namespace osu.Game
{
@@ -179,6 +181,41 @@ namespace osu.Game
/// <param name="setId">The set to display.</param>
public void ShowBeatmapSet(int setId) => beatmapSetOverlay.FetchAndShowBeatmapSet(setId);
/// <summary>
/// Present a beatmap at song select.
/// </summary>
/// <param name="beatmap">The beatmap to select.</param>
public void PresentBeatmap(BeatmapSetInfo beatmap)
{
CloseAllOverlays(false);
void setBeatmap()
{
if (Beatmap.Disabled)
{
Schedule(setBeatmap);
return;
}
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(beatmap.Beatmaps.First());
}
switch (currentScreen)
{
case SongSelect _:
break;
default:
// navigate to song select if we are not already there.
var menu = (MainMenu)intro.ChildScreen;
menu.MakeCurrent();
menu.LoadToSolo();
break;
}
setBeatmap();
}
/// <summary>
/// Show a user's profile as an overlay.
/// </summary>
@@ -245,6 +282,7 @@ namespace osu.Game
BeatmapManager.PostNotification = n => notifications?.Post(n);
BeatmapManager.GetStableStorage = GetStorageForStableInstall;
BeatmapManager.PresentBeatmap = PresentBeatmap;
AddRange(new Drawable[]
{
+6 -1
View File
@@ -44,6 +44,8 @@ namespace osu.Game.Overlays.Mods
private void rulesetChanged(RulesetInfo newRuleset)
{
if (newRuleset == null) return;
var instance = newRuleset.CreateInstance();
foreach (ModSection section in ModSectionsContainer.Children)
@@ -173,7 +175,10 @@ namespace osu.Game.Overlays.Mods
refreshSelectedMods();
}
private void refreshSelectedMods() => SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
private void refreshSelectedMods()
{
SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
}
public ModSelectOverlay()
{
+2 -1
View File
@@ -128,7 +128,8 @@ namespace osu.Game.Overlays
var section = sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)));
section?.Add(notification, notification.DisplayOnTop ? -runningDepth : runningDepth);
State = Visibility.Visible;
if (notification.IsImportant)
State = Visibility.Visible;
updateCounts();
});
@@ -23,6 +23,11 @@ namespace osu.Game.Overlays.Notifications
/// </summary>
public event Action Closed;
/// <summary>
/// Whether this notification should forcefully display itself.
/// </summary>
public virtual bool IsImportant => false;
/// <summary>
/// Run on user activating the notification. Return true to close.
/// </summary>
+1 -1
View File
@@ -11,7 +11,7 @@ using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Mods
{
public class ModAutoplay<T> : ModAutoplay, IApplicableToRulesetContainer<T>
public abstract class ModAutoplay<T> : ModAutoplay, IApplicableToRulesetContainer<T>
where T : HitObject
{
protected virtual Score CreateReplayScore(Beatmap<T> beatmap) => new Score { Replay = new Replay() };
+5 -1
View File
@@ -55,7 +55,7 @@ namespace osu.Game.Screens.Menu
OnChart = delegate { Push(new ChartListing()); },
OnDirect = delegate { Push(new OnlineListing()); },
OnEdit = delegate { Push(new Editor()); },
OnSolo = delegate { Push(consumeSongSelect()); },
OnSolo = onSolo,
OnMulti = delegate { Push(new Multiplayer()); },
OnExit = Exit,
}
@@ -85,6 +85,10 @@ namespace osu.Game.Screens.Menu
LoadComponentAsync(songSelect = new PlaySongSelect());
}
public void LoadToSolo() => Schedule(onSolo);
private void onSolo() => Push(consumeSongSelect());
private Screen consumeSongSelect()
{
var s = songSelect;
@@ -47,7 +47,7 @@ namespace osu.Game.Screens.Select.Leaderboards
{
Rank = newRank;
if (IsLoaded)
if (LoadState >= LoadState.Ready)
updateTexture();
}
}
+2 -2
View File
@@ -84,10 +84,10 @@ namespace osu.Game.Screens.Select
protected override void UpdateBeatmap(WorkingBeatmap beatmap)
{
base.UpdateBeatmap(beatmap);
beatmap.Mods.BindTo(SelectedMods);
base.UpdateBeatmap(beatmap);
BeatmapDetails.Beatmap = beatmap;
if (beatmap.Track != null)
+25 -9
View File
@@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using OpenTK;
using OpenTK.Input;
using osu.Framework.Allocation;
@@ -20,6 +21,7 @@ using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Menu;
@@ -70,7 +72,14 @@ namespace osu.Game.Screens.Select
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
{
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs(this);
dependencies.CacheAs(Ruleset);
dependencies.CacheAs<IBindable<RulesetInfo>>(Ruleset);
return dependencies;
}
protected SongSelect()
{
@@ -189,9 +198,9 @@ namespace osu.Game.Screens.Select
[BackgroundDependencyLoader(true)]
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours)
{
dependencies.CacheAs(this);
dependencies.CacheAs(Ruleset);
dependencies.CacheAs<IBindable<RulesetInfo>>(Ruleset);
// manual binding to parent ruleset to allow for delayed load in the incoming direction.
base.Ruleset.ValueChanged += r => updateSelectedBeatmap(beatmapNoDebounce);
Ruleset.ValueChanged += r => base.Ruleset.Value = r;
if (Footer != null)
{
@@ -277,7 +286,7 @@ namespace osu.Game.Screens.Select
// If selecting new beatmap without bypassing filters failed, there's possibly a ruleset mismatch
if (beatmap?.BeatmapInfo?.Ruleset != null && beatmap.BeatmapInfo.Ruleset != Ruleset.Value)
{
Ruleset.Value = beatmap.BeatmapInfo.Ruleset;
base.Ruleset.Value = beatmap.BeatmapInfo.Ruleset;
Carousel.SelectBeatmap(beatmap.BeatmapInfo);
}
}
@@ -295,18 +304,25 @@ namespace osu.Game.Screens.Select
void performLoad()
{
WorkingBeatmap working = Beatmap.Value;
bool preview = false;
// We may be arriving here due to another component changing the bindable Beatmap.
// In these cases, the other component has already loaded the beatmap, so we don't need to do so again.
if (beatmap?.Equals(Beatmap.Value.BeatmapInfo) != true)
{
bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value?.BeatmapInfo.BeatmapSetInfoID;
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value);
ensurePlayingSelected(preview);
preview = beatmap?.BeatmapSetInfoID != Beatmap.Value?.BeatmapInfo.BeatmapSetInfoID;
working = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value);
}
working.Mods.Value = Enumerable.Empty<Mod>();
Beatmap.Value = working;
Ruleset.Value = ruleset;
ensurePlayingSelected(preview);
UpdateBeatmap(Beatmap.Value);
}
+1 -1
View File
@@ -43,7 +43,7 @@ namespace osu.Game.Users
country = value;
if (IsLoaded)
if (LoadState >= LoadState.Ready)
sprite.Texture = getFlagTexture();
}
}