Merge branch 'master' into fix-unranked-map-lb-placeholder

This commit is contained in:
Joseph Madamba 2019-07-06 12:09:28 -07:00 committed by GitHub
commit 7c0e3a50b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 337 additions and 72 deletions

View File

@ -9,6 +9,7 @@ using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
@ -16,12 +17,13 @@ using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens; using osu.Game.Screens;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osu.Game.Screens.Play.PlayerSettings;
namespace osu.Game.Tests.Visual.Gameplay namespace osu.Game.Tests.Visual.Gameplay
{ {
public class TestScenePlayerLoader : ManualInputManagerTestScene public class TestScenePlayerLoader : ManualInputManagerTestScene
{ {
private PlayerLoader loader; private TestPlayerLoader loader;
private OsuScreenStack stack; private OsuScreenStack stack;
[SetUp] [SetUp]
@ -31,19 +33,29 @@ namespace osu.Game.Tests.Visual.Gameplay
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo); Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
}); });
[Test]
public void TestBlockLoadViaMouseMovement()
{
AddStep("load dummy beatmap", () => stack.Push(loader = new TestPlayerLoader(() => new TestPlayer(false, false))));
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
AddRepeatStep("move mouse", () => InputManager.MoveMouseTo(loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft + (loader.VisualSettings.ScreenSpaceDrawQuad.BottomRight - loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft) * RNG.NextSingle()), 20);
AddAssert("loader still active", () => loader.IsCurrentScreen());
AddUntilStep("loads after idle", () => !loader.IsCurrentScreen());
}
[Test] [Test]
public void TestLoadContinuation() public void TestLoadContinuation()
{ {
Player player = null; Player player = null;
SlowLoadPlayer slowPlayer = null; SlowLoadPlayer slowPlayer = null;
AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => player = new TestPlayer(false, false)))); AddStep("load dummy beatmap", () => stack.Push(loader = new TestPlayerLoader(() => player = new TestPlayer(false, false))));
AddUntilStep("wait for current", () => loader.IsCurrentScreen()); AddUntilStep("wait for current", () => loader.IsCurrentScreen());
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre)); AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen()); AddUntilStep("wait for player to be current", () => player.IsCurrentScreen());
AddStep("load slow dummy beatmap", () => AddStep("load slow dummy beatmap", () =>
{ {
stack.Push(loader = new PlayerLoader(() => slowPlayer = new SlowLoadPlayer(false, false))); stack.Push(loader = new TestPlayerLoader(() => slowPlayer = new SlowLoadPlayer(false, false)));
Scheduler.AddDelayed(() => slowPlayer.AllowLoad.Set(), 5000); Scheduler.AddDelayed(() => slowPlayer.AllowLoad.Set(), 5000);
}); });
@ -61,7 +73,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("load player", () => AddStep("load player", () =>
{ {
Mods.Value = new[] { gameMod = new TestMod() }; Mods.Value = new[] { gameMod = new TestMod() };
stack.Push(loader = new PlayerLoader(() => player = new TestPlayer())); stack.Push(loader = new TestPlayerLoader(() => player = new TestPlayer()));
}); });
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen()); AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
@ -85,6 +97,16 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("player mods applied", () => playerMod2.Applied); AddAssert("player mods applied", () => playerMod2.Applied);
} }
private class TestPlayerLoader : PlayerLoader
{
public new VisualSettings VisualSettings => base.VisualSettings;
public TestPlayerLoader(Func<Player> createPlayer)
: base(createPlayer)
{
}
}
private class TestMod : Mod, IApplicableToScoreProcessor private class TestMod : Mod, IApplicableToScoreProcessor
{ {
public override string Name => string.Empty; public override string Name => string.Empty;

View File

@ -24,6 +24,7 @@ namespace osu.Game.Tests.Visual.Online
typeof(ChangelogListing), typeof(ChangelogListing),
typeof(ChangelogSingleBuild), typeof(ChangelogSingleBuild),
typeof(ChangelogBuild), typeof(ChangelogBuild),
typeof(Comments),
}; };
protected override void LoadComplete() protected override void LoadComplete()

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Tests.Visual.UserInterface namespace osu.Game.Tests.Visual.UserInterface
@ -23,11 +24,12 @@ namespace osu.Game.Tests.Visual.UserInterface
typeof(Button) typeof(Button)
}; };
public TestSceneButtonSystem() private OsuLogo logo;
{ private ButtonSystem buttons;
OsuLogo logo;
ButtonSystem buttons;
[SetUp]
public void SetUp() => Schedule(() =>
{
Children = new Drawable[] Children = new Drawable[]
{ {
new Box new Box
@ -36,13 +38,47 @@ namespace osu.Game.Tests.Visual.UserInterface
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
buttons = new ButtonSystem(), buttons = new ButtonSystem(),
logo = new OsuLogo { RelativePositionAxes = Axes.Both } logo = new OsuLogo
{
RelativePositionAxes = Axes.Both,
Position = new Vector2(0.5f)
}
}; };
buttons.SetOsuLogo(logo); buttons.SetOsuLogo(logo);
});
[Test]
public void TestAllStates()
{
foreach (var s in Enum.GetValues(typeof(ButtonSystemState)).OfType<ButtonSystemState>().Skip(1)) foreach (var s in Enum.GetValues(typeof(ButtonSystemState)).OfType<ButtonSystemState>().Skip(1))
AddStep($"State to {s}", () => buttons.State = s); AddStep($"State to {s}", () => buttons.State = s);
AddStep("Enter mode", performEnterMode);
AddStep("Return to menu", () =>
{
buttons.State = ButtonSystemState.Play;
buttons.FadeIn(MainMenu.FADE_IN_DURATION, Easing.OutQuint);
buttons.MoveTo(new Vector2(0), MainMenu.FADE_IN_DURATION, Easing.OutQuint);
logo.FadeColour(Color4.White, 100, Easing.OutQuint);
logo.FadeIn(100, Easing.OutQuint);
});
}
[Test]
public void TestSmoothExit()
{
AddStep("Enter mode", performEnterMode);
}
private void performEnterMode()
{
buttons.State = ButtonSystemState.EnteringMode;
buttons.FadeOut(MainMenu.FADE_OUT_DURATION, Easing.InSine);
buttons.MoveTo(new Vector2(-800, 0), MainMenu.FADE_OUT_DURATION, Easing.InSine);
logo.FadeOut(300, Easing.InSine)
.ScaleTo(0.2f, 300, Easing.InSine);
} }
} }
} }

View File

@ -82,6 +82,8 @@ namespace osu.Game.Beatmaps
protected override ArchiveDownloadRequest<BeatmapSetInfo> CreateDownloadRequest(BeatmapSetInfo set, bool minimiseDownloadSize) => protected override ArchiveDownloadRequest<BeatmapSetInfo> CreateDownloadRequest(BeatmapSetInfo set, bool minimiseDownloadSize) =>
new DownloadBeatmapSetRequest(set, minimiseDownloadSize); new DownloadBeatmapSetRequest(set, minimiseDownloadSize);
protected override bool ShouldDeleteArchive(string path) => Path.GetExtension(path)?.ToLowerInvariant() == ".osz";
protected override Task Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive, CancellationToken cancellationToken = default) protected override Task Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive, CancellationToken cancellationToken = default)
{ {
if (archive != null) if (archive != null)
@ -176,20 +178,23 @@ namespace osu.Game.Beatmaps
if (beatmapInfo?.BeatmapSet == null || beatmapInfo == DefaultBeatmap?.BeatmapInfo) if (beatmapInfo?.BeatmapSet == null || beatmapInfo == DefaultBeatmap?.BeatmapInfo)
return DefaultBeatmap; return DefaultBeatmap;
var cached = workingCache.FirstOrDefault(w => w.BeatmapInfo?.ID == beatmapInfo.ID); lock (workingCache)
{
var cached = workingCache.FirstOrDefault(w => w.BeatmapInfo?.ID == beatmapInfo.ID);
if (cached != null) if (cached != null)
return cached; return cached;
if (beatmapInfo.Metadata == null) if (beatmapInfo.Metadata == null)
beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata; beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata;
WorkingBeatmap working = new BeatmapManagerWorkingBeatmap(Files.Store, new LargeTextureStore(host?.CreateTextureLoaderStore(Files.Store)), beatmapInfo, audioManager); WorkingBeatmap working = new BeatmapManagerWorkingBeatmap(Files.Store, new LargeTextureStore(host?.CreateTextureLoaderStore(Files.Store)), beatmapInfo, audioManager);
previous?.TransferTo(working); previous?.TransferTo(working);
workingCache.Add(working); workingCache.Add(working);
return working; return working;
}
} }
/// <summary> /// <summary>

View File

@ -35,15 +35,15 @@ namespace osu.Game.Beatmaps.Drawables
protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Func<Drawable> createContentFunc, double timeBeforeLoad) protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Func<Drawable> createContentFunc, double timeBeforeLoad)
=> new DelayedLoadUnloadWrapper(createContentFunc, timeBeforeLoad, UnloadDelay); => new DelayedLoadUnloadWrapper(createContentFunc, timeBeforeLoad, UnloadDelay);
protected override double TransformDuration => 400;
protected override Drawable CreateDrawable(BeatmapInfo model) protected override Drawable CreateDrawable(BeatmapInfo model)
{ {
Drawable drawable = getDrawableForModel(model); var drawable = getDrawableForModel(model);
drawable.RelativeSizeAxes = Axes.Both; drawable.RelativeSizeAxes = Axes.Both;
drawable.Anchor = Anchor.Centre; drawable.Anchor = Anchor.Centre;
drawable.Origin = Anchor.Centre; drawable.Origin = Anchor.Centre;
drawable.FillMode = FillMode.Fill; drawable.FillMode = FillMode.Fill;
drawable.OnLoadComplete += d => d.FadeInFromZero(400);
return drawable; return drawable;
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
@ -114,7 +114,8 @@ namespace osu.Game.Database
lock (imported) lock (imported)
{ {
imported.Add(model); if (model != null)
imported.Add(model);
current++; current++;
notification.Text = $"Imported {current} of {paths.Length} {HumanisedModelName}s"; notification.Text = $"Imported {current} of {paths.Length} {HumanisedModelName}s";
@ -140,7 +141,7 @@ namespace osu.Game.Database
{ {
notification.CompletionText = imported.Count == 1 notification.CompletionText = imported.Count == 1
? $"Imported {imported.First()}!" ? $"Imported {imported.First()}!"
: $"Imported {current} {HumanisedModelName}s!"; : $"Imported {imported.Count} {HumanisedModelName}s!";
if (imported.Count > 0 && PresentImport != null) if (imported.Count > 0 && PresentImport != null)
{ {
@ -176,7 +177,7 @@ namespace osu.Game.Database
// TODO: Add a check to prevent files from storage to be deleted. // TODO: Add a check to prevent files from storage to be deleted.
try try
{ {
if (import != null && File.Exists(path)) if (import != null && File.Exists(path) && ShouldDeleteArchive(path))
File.Delete(path); File.Delete(path);
} }
catch (Exception e) catch (Exception e)
@ -207,7 +208,7 @@ namespace osu.Game.Database
{ {
model = CreateModel(archive); model = CreateModel(archive);
if (model == null) return null; if (model == null) return Task.FromResult<TModel>(null);
model.Hash = computeHash(archive); model.Hash = computeHash(archive);
} }
@ -498,6 +499,18 @@ namespace osu.Game.Database
/// </summary> /// </summary>
protected virtual string ImportFromStablePath => null; protected virtual string ImportFromStablePath => null;
/// <summary>
/// Select paths to import from stable. Default implementation iterates all directories in <see cref="ImportFromStablePath"/>.
/// </summary>
protected virtual IEnumerable<string> GetStableImportPaths(Storage stableStoage) => stableStoage.GetDirectories(ImportFromStablePath);
/// <summary>
/// Whether this specified path should be removed after successful import.
/// </summary>
/// <param name="path">The path for consideration. May be a file or a directory.</param>
/// <returns>Whether to perform deletion.</returns>
protected virtual bool ShouldDeleteArchive(string path) => false;
/// <summary> /// <summary>
/// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future. /// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future.
/// </summary> /// </summary>
@ -518,7 +531,7 @@ namespace osu.Game.Database
return Task.CompletedTask; return Task.CompletedTask;
} }
return Task.Run(async () => await Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray())); return Task.Run(async () => await Import(GetStableImportPaths(GetStableStorage()).Select(f => stable.GetFullPath(f)).ToArray()));
} }
#endregion #endregion

View File

@ -5,8 +5,10 @@ using System;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Screens.Select.Leaderboards; using osu.Game.Screens.Select.Leaderboards;
using osu.Framework.IO.Network;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets.Mods;
using System.Text;
using System.Collections.Generic;
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests
{ {
@ -15,8 +17,9 @@ namespace osu.Game.Online.API.Requests
private readonly BeatmapInfo beatmap; private readonly BeatmapInfo beatmap;
private readonly BeatmapLeaderboardScope scope; private readonly BeatmapLeaderboardScope scope;
private readonly RulesetInfo ruleset; private readonly RulesetInfo ruleset;
private readonly IEnumerable<Mod> mods;
public GetScoresRequest(BeatmapInfo beatmap, RulesetInfo ruleset, BeatmapLeaderboardScope scope = BeatmapLeaderboardScope.Global) public GetScoresRequest(BeatmapInfo beatmap, RulesetInfo ruleset, BeatmapLeaderboardScope scope = BeatmapLeaderboardScope.Global, IEnumerable<Mod> mods = null)
{ {
if (!beatmap.OnlineBeatmapID.HasValue) if (!beatmap.OnlineBeatmapID.HasValue)
throw new InvalidOperationException($"Cannot lookup a beatmap's scores without having a populated {nameof(BeatmapInfo.OnlineBeatmapID)}."); throw new InvalidOperationException($"Cannot lookup a beatmap's scores without having a populated {nameof(BeatmapInfo.OnlineBeatmapID)}.");
@ -27,6 +30,7 @@ namespace osu.Game.Online.API.Requests
this.beatmap = beatmap; this.beatmap = beatmap;
this.scope = scope; this.scope = scope;
this.ruleset = ruleset ?? throw new ArgumentNullException(nameof(ruleset)); this.ruleset = ruleset ?? throw new ArgumentNullException(nameof(ruleset));
this.mods = mods ?? Array.Empty<Mod>();
Success += onSuccess; Success += onSuccess;
} }
@ -40,17 +44,19 @@ namespace osu.Game.Online.API.Requests
} }
} }
protected override WebRequest CreateWebRequest() protected override string Target => $@"beatmaps/{beatmap.OnlineBeatmapID}/scores{createQueryParameters()}";
private string createQueryParameters()
{ {
var req = base.CreateWebRequest(); StringBuilder query = new StringBuilder(@"?");
req.Timeout = 30000; query.Append($@"type={scope.ToString().ToLowerInvariant()}");
req.AddParameter(@"type", scope.ToString().ToLowerInvariant()); query.Append($@"&mode={ruleset.ShortName}");
req.AddParameter(@"mode", ruleset.ShortName);
return req; foreach (var mod in mods)
query.Append($@"&mods[]={mod.Acronym}");
return query.ToString();
} }
protected override string Target => $@"beatmaps/{beatmap.OnlineBeatmapID}/scores";
} }
} }

View File

@ -33,6 +33,8 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty("versions")] [JsonProperty("versions")]
public VersionNavigation Versions { get; set; } public VersionNavigation Versions { get; set; }
public string Url => $"https://osu.ppy.sh/home/changelog/{UpdateStream.Name}/{Version}";
public class VersionNavigation public class VersionNavigation
{ {
[JsonProperty("next")] [JsonProperty("next")]

View File

@ -11,7 +11,7 @@ using osu.Game.Online.API;
namespace osu.Game.Online namespace osu.Game.Online
{ {
/// <summary> /// <summary>
/// A component which tracks a beatmap through potential download/import/deletion. /// A component which tracks a <see cref="TModel"/> through potential download/import/deletion.
/// </summary> /// </summary>
public abstract class DownloadTrackingComposite<TModel, TModelManager> : CompositeDrawable public abstract class DownloadTrackingComposite<TModel, TModelManager> : CompositeDrawable
where TModel : class, IEquatable<TModel> where TModel : class, IEquatable<TModel>
@ -22,7 +22,7 @@ namespace osu.Game.Online
private TModelManager manager; private TModelManager manager;
/// <summary> /// <summary>
/// Holds the current download state of the beatmap, whether is has already been downloaded, is in progress, or is not downloaded. /// Holds the current download state of the <see cref="TModel"/>, whether is has already been downloaded, is in progress, or is not downloaded.
/// </summary> /// </summary>
protected readonly Bindable<DownloadState> State = new Bindable<DownloadState>(); protected readonly Bindable<DownloadState> State = new Bindable<DownloadState>();

View File

@ -387,6 +387,7 @@ namespace osu.Game
BeatmapManager.PresentImport = items => PresentBeatmap(items.First()); BeatmapManager.PresentImport = items => PresentBeatmap(items.First());
ScoreManager.PostNotification = n => notifications?.Post(n); ScoreManager.PostNotification = n => notifications?.Post(n);
ScoreManager.GetStableStorage = GetStorageForStableInstall;
ScoreManager.PresentImport = items => PresentScore(items.First()); ScoreManager.PresentImport = items => PresentScore(items.First());
Container logoContainer; Container logoContainer;

View File

@ -58,7 +58,11 @@ namespace osu.Game.Overlays.Changelog
} }
if (build != null) if (build != null)
Child = new ChangelogBuildWithNavigation(build) { SelectBuild = SelectBuild }; Children = new Drawable[]
{
new ChangelogBuildWithNavigation(build) { SelectBuild = SelectBuild },
new Comments(build)
};
} }
public class ChangelogBuildWithNavigation : ChangelogBuild public class ChangelogBuildWithNavigation : ChangelogBuild

View File

@ -0,0 +1,79 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
using osuTK.Graphics;
namespace osu.Game.Overlays.Changelog
{
public class Comments : CompositeDrawable
{
private readonly APIChangelogBuild build;
public Comments(APIChangelogBuild build)
{
this.build = build;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Padding = new MarginPadding
{
Horizontal = 50,
Vertical = 20,
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
LinkFlowContainer text;
InternalChildren = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = 10,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colours.GreyVioletDarker
},
},
text = new LinkFlowContainer(t =>
{
t.Colour = colours.PinkLighter;
t.Font = OsuFont.Default.With(size: 14);
})
{
Padding = new MarginPadding(20),
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
}
};
text.AddParagraph("Got feedback?", t =>
{
t.Colour = Color4.White;
t.Font = OsuFont.Default.With(italics: true, size: 20);
t.Padding = new MarginPadding { Bottom = 20 };
});
text.AddParagraph("We would love to hear what you think of this update! ");
text.AddIcon(FontAwesome.Regular.GrinHearts);
text.AddParagraph("Please visit the ");
text.AddLink("web version", $"{build.Url}#comments");
text.AddText(" of this changelog to leave any comments.");
}
}
}

View File

@ -7,6 +7,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Scoring;
using osu.Game.Skinning; using osu.Game.Skinning;
namespace osu.Game.Overlays.Settings.Sections.Maintenance namespace osu.Game.Overlays.Settings.Sections.Maintenance
@ -16,14 +17,16 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
protected override string Header => "General"; protected override string Header => "General";
private TriangleButton importBeatmapsButton; private TriangleButton importBeatmapsButton;
private TriangleButton importScoresButton;
private TriangleButton importSkinsButton; private TriangleButton importSkinsButton;
private TriangleButton deleteSkinsButton;
private TriangleButton deleteBeatmapsButton; private TriangleButton deleteBeatmapsButton;
private TriangleButton deleteScoresButton;
private TriangleButton deleteSkinsButton;
private TriangleButton restoreButton; private TriangleButton restoreButton;
private TriangleButton undeleteButton; private TriangleButton undeleteButton;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(BeatmapManager beatmaps, SkinManager skins, DialogOverlay dialogOverlay) private void load(BeatmapManager beatmaps, ScoreManager scores, SkinManager skins, DialogOverlay dialogOverlay)
{ {
if (beatmaps.SupportsImportFromStable) if (beatmaps.SupportsImportFromStable)
{ {
@ -51,6 +54,32 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
} }
}); });
if (scores.SupportsImportFromStable)
{
Add(importScoresButton = new SettingsButton
{
Text = "Import scores from stable",
Action = () =>
{
importScoresButton.Enabled.Value = false;
scores.ImportFromStableAsync().ContinueWith(t => Schedule(() => importScoresButton.Enabled.Value = true));
}
});
}
Add(deleteScoresButton = new DangerousSettingsButton
{
Text = "Delete ALL scores",
Action = () =>
{
dialogOverlay?.Push(new DeleteAllBeatmapsDialog(() =>
{
deleteScoresButton.Enabled.Value = false;
Task.Run(() => scores.Delete(scores.GetAllUsableScores())).ContinueWith(t => Schedule(() => deleteScoresButton.Enabled.Value = true));
}));
}
});
if (skins.SupportsImportFromStable) if (skins.SupportsImportFromStable)
{ {
Add(importSkinsButton = new SettingsButton Add(importSkinsButton = new SettingsButton

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -24,7 +25,7 @@ namespace osu.Game.Scoring
protected override string[] HashableFileTypes => new[] { ".osr" }; protected override string[] HashableFileTypes => new[] { ".osr" };
protected override string ImportFromStablePath => "Replays"; protected override string ImportFromStablePath => Path.Combine("Data", "r");
private readonly RulesetStore rulesets; private readonly RulesetStore rulesets;
private readonly Func<BeatmapManager> beatmaps; private readonly Func<BeatmapManager> beatmaps;
@ -55,6 +56,9 @@ namespace osu.Game.Scoring
} }
} }
protected override IEnumerable<string> GetStableImportPaths(Storage stableStorage)
=> stableStorage.GetFiles(ImportFromStablePath).Where(p => HandledExtensions.Any(ext => Path.GetExtension(p)?.Equals(ext, StringComparison.InvariantCultureIgnoreCase) ?? false));
public Score GetScore(ScoreInfo score) => new LegacyDatabasedScore(score, rulesets, beatmaps(), Files.Store); public Score GetScore(ScoreInfo score) => new LegacyDatabasedScore(score, rulesets, beatmaps(), Files.Store);
public List<ScoreInfo> GetAllUsableScores() => ModelStore.ConsumableItems.Where(s => !s.DeletePending).ToList(); public List<ScoreInfo> GetAllUsableScores() => ModelStore.ConsumableItems.Where(s => !s.DeletePending).ToList();
@ -65,6 +69,6 @@ namespace osu.Game.Scoring
protected override ArchiveDownloadRequest<ScoreInfo> CreateDownloadRequest(ScoreInfo score, bool minimiseDownload) => new DownloadReplayRequest(score); protected override ArchiveDownloadRequest<ScoreInfo> CreateDownloadRequest(ScoreInfo score, bool minimiseDownload) => new DownloadReplayRequest(score);
protected override bool CheckLocalAvailability(ScoreInfo model, IQueryable<ScoreInfo> items) => items.Any(s => s.OnlineScoreID == model.OnlineScoreID); protected override bool CheckLocalAvailability(ScoreInfo model, IQueryable<ScoreInfo> items) => items.Any(s => s.OnlineScoreID == model.OnlineScoreID && s.Files.Any());
} }
} }

View File

@ -332,7 +332,7 @@ namespace osu.Game.Screens.Menu
break; break;
case ButtonSystemState.EnteringMode: case ButtonSystemState.EnteringMode:
logoTrackingContainer.StartTracking(logo, 0, Easing.In); logoTrackingContainer.StartTracking(logo, lastState == ButtonSystemState.Initial ? MainMenu.FADE_OUT_DURATION : 0, Easing.InSine);
break; break;
} }
} }

View File

@ -33,13 +33,18 @@ namespace osu.Game.Screens.Menu
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack(); protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack();
private readonly BindableDouble exitingVolumeFade = new BindableDouble(1);
[Resolved]
private AudioManager audio { get; set; }
private Bindable<bool> menuVoice; private Bindable<bool> menuVoice;
private Bindable<bool> menuMusic; private Bindable<bool> menuMusic;
private Track track; private Track track;
private WorkingBeatmap introBeatmap; private WorkingBeatmap introBeatmap;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game) private void load(OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game)
{ {
menuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice); menuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice);
menuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic); menuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic);
@ -161,7 +166,8 @@ namespace osu.Game.Screens.Menu
else else
fadeOutTime = 500; fadeOutTime = 500;
Scheduler.AddDelayed(this.Exit, fadeOutTime); audio.AddAdjustment(AdjustableProperty.Volume, exitingVolumeFade);
this.TransformBindableTo(exitingVolumeFade, 0, fadeOutTime).OnComplete(_ => this.Exit());
//don't want to fade out completely else we will stop running updates. //don't want to fade out completely else we will stop running updates.
Game.FadeTo(0.01f, fadeOutTime); Game.FadeTo(0.01f, fadeOutTime);

View File

@ -23,7 +23,9 @@ namespace osu.Game.Screens.Menu
{ {
public class MainMenu : OsuScreen public class MainMenu : OsuScreen
{ {
private ButtonSystem buttons; public const float FADE_IN_DURATION = 300;
public const float FADE_OUT_DURATION = 400;
public override bool HideOverlaysOnEnter => buttons == null || buttons.State == ButtonSystemState.Initial; public override bool HideOverlaysOnEnter => buttons == null || buttons.State == ButtonSystemState.Initial;
@ -35,6 +37,8 @@ namespace osu.Game.Screens.Menu
private MenuSideFlashes sideFlashes; private MenuSideFlashes sideFlashes;
private ButtonSystem buttons;
[Resolved] [Resolved]
private GameHost host { get; set; } private GameHost host { get; set; }
@ -141,12 +145,10 @@ namespace osu.Game.Screens.Menu
{ {
buttons.State = ButtonSystemState.TopLevel; buttons.State = ButtonSystemState.TopLevel;
const float length = 300; this.FadeIn(FADE_IN_DURATION, Easing.OutQuint);
this.MoveTo(new Vector2(0, 0), FADE_IN_DURATION, Easing.OutQuint);
this.FadeIn(length, Easing.OutQuint); sideFlashes.Delay(FADE_IN_DURATION).FadeIn(64, Easing.InQuint);
this.MoveTo(new Vector2(0, 0), length, Easing.OutQuint);
sideFlashes.Delay(length).FadeIn(64, Easing.InQuint);
} }
} }
@ -171,12 +173,10 @@ namespace osu.Game.Screens.Menu
{ {
base.OnSuspending(next); base.OnSuspending(next);
const float length = 400;
buttons.State = ButtonSystemState.EnteringMode; buttons.State = ButtonSystemState.EnteringMode;
this.FadeOut(length, Easing.InSine); this.FadeOut(FADE_OUT_DURATION, Easing.InSine);
this.MoveTo(new Vector2(-800, 0), length, Easing.InSine); this.MoveTo(new Vector2(-800, 0), FADE_OUT_DURATION, Easing.InSine);
sideFlashes.FadeOut(64, Easing.OutQuint); sideFlashes.FadeOut(64, Easing.OutQuint);
} }

View File

@ -18,6 +18,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Input;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.HUD;
@ -53,6 +54,8 @@ namespace osu.Game.Screens.Play
private InputManager inputManager; private InputManager inputManager;
private IdleTracker idleTracker;
public PlayerLoader(Func<Player> createPlayer) public PlayerLoader(Func<Player> createPlayer)
{ {
this.createPlayer = createPlayer; this.createPlayer = createPlayer;
@ -93,7 +96,8 @@ namespace osu.Game.Screens.Play
VisualSettings = new VisualSettings(), VisualSettings = new VisualSettings(),
new InputSettings() new InputSettings()
} }
} },
idleTracker = new IdleTracker(750)
}); });
loadNewPlayer(); loadNewPlayer();
@ -193,7 +197,7 @@ namespace osu.Game.Screens.Play
// Here because IsHovered will not update unless we do so. // Here because IsHovered will not update unless we do so.
public override bool HandlePositionalInput => true; public override bool HandlePositionalInput => true;
private bool readyForPush => player.LoadState == LoadState.Ready && IsHovered && GetContainingInputManager()?.DraggedDrawable == null; private bool readyForPush => player.LoadState == LoadState.Ready && (IsHovered || idleTracker.IsIdle.Value) && inputManager?.DraggedDrawable == null;
private void pushWhenLoaded() private void pushWhenLoaded()
{ {

View File

@ -86,11 +86,7 @@ namespace osu.Game.Screens.Play
} }
}, true); }, true);
if (replayAvailability == ReplayAvailability.NotAvailable) button.Enabled.Value = replayAvailability != ReplayAvailability.NotAvailable;
{
button.Enabled.Value = false;
button.Alpha = 0.6f;
}
} }
private enum ReplayAvailability private enum ReplayAvailability

View File

@ -41,6 +41,8 @@ namespace osu.Game.Screens.Select
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
OnFilter = (tab, mods) => OnFilter = (tab, mods) =>
{ {
Leaderboard.FilterMods = mods;
switch (tab) switch (tab)
{ {
case BeatmapDetailTab.Details: case BeatmapDetailTab.Details:

View File

@ -12,7 +12,7 @@ namespace osu.Game.Screens.Select
public ImportFromStablePopup(Action importFromStable) public ImportFromStablePopup(Action importFromStable)
{ {
HeaderText = @"You have no beatmaps!"; HeaderText = @"You have no beatmaps!";
BodyText = "An existing copy of osu! was found, though.\nWould you like to import your beatmaps (and skins)?"; BodyText = "An existing copy of osu! was found, though.\nWould you like to import your beatmaps, skins and scores?";
Icon = FontAwesome.Solid.Plane; Icon = FontAwesome.Solid.Plane;

View File

@ -11,6 +11,7 @@ using osu.Game.Online.API;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Online.Leaderboards; using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring; using osu.Game.Scoring;
namespace osu.Game.Screens.Select.Leaderboards namespace osu.Game.Screens.Select.Leaderboards
@ -36,12 +37,34 @@ namespace osu.Game.Screens.Select.Leaderboards
} }
} }
private bool filterMods;
/// <summary>
/// Whether to apply the game's currently selected mods as a filter when retrieving scores.
/// </summary>
public bool FilterMods
{
get => filterMods;
set
{
if (value == filterMods)
return;
filterMods = value;
UpdateScores();
}
}
[Resolved] [Resolved]
private ScoreManager scoreManager { get; set; } private ScoreManager scoreManager { get; set; }
[Resolved] [Resolved]
private IBindable<RulesetInfo> ruleset { get; set; } private IBindable<RulesetInfo> ruleset { get; set; }
[Resolved]
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
[Resolved] [Resolved]
private IAPIProvider api { get; set; } private IAPIProvider api { get; set; }
@ -49,16 +72,36 @@ namespace osu.Game.Screens.Select.Leaderboards
private void load() private void load()
{ {
ruleset.ValueChanged += _ => UpdateScores(); ruleset.ValueChanged += _ => UpdateScores();
mods.ValueChanged += _ =>
{
if (filterMods)
UpdateScores();
};
} }
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback) protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
{ {
if (Scope == BeatmapLeaderboardScope.Local) if (Scope == BeatmapLeaderboardScope.Local)
{ {
Scores = scoreManager var scores = scoreManager
.QueryScores(s => !s.DeletePending && s.Beatmap.ID == Beatmap.ID && s.Ruleset.ID == ruleset.Value.ID) .QueryScores(s => !s.DeletePending && s.Beatmap.ID == Beatmap.ID && s.Ruleset.ID == ruleset.Value.ID);
.OrderByDescending(s => s.TotalScore).ToArray();
if (filterMods && !mods.Value.Any())
{
// we need to filter out all scores that have any mods to get all local nomod scores
scores = scores.Where(s => !s.Mods.Any());
}
else if (filterMods)
{
// otherwise find all the scores that have *any* of the currently selected mods (similar to how web applies mod filters)
// we're creating and using a string list representation of selected mods so that it can be translated into the DB query itself
var selectedMods = mods.Value.Select(m => m.Acronym);
scores = scores.Where(s => s.Mods.Any(m => selectedMods.Contains(m.Acronym)));
}
Scores = scores.OrderByDescending(s => s.TotalScore).ToArray();
PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores; PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
return null; return null;
} }
@ -84,13 +127,21 @@ namespace osu.Game.Screens.Select.Leaderboards
return null; return null;
} }
if (Scope != BeatmapLeaderboardScope.Global && !api.LocalUser.Value.IsSupporter) if (!api.LocalUser.Value.IsSupporter && (Scope != BeatmapLeaderboardScope.Global || filterMods))
{ {
PlaceholderState = PlaceholderState.NotSupporter; PlaceholderState = PlaceholderState.NotSupporter;
return null; return null;
} }
var req = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope); IReadOnlyList<Mod> requestMods = null;
if (filterMods && !mods.Value.Any())
// add nomod for the request
requestMods = new Mod[] { new ModNoMod() };
else if (filterMods)
requestMods = mods.Value;
var req = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope, requestMods);
req.Success += r => scoresCallback?.Invoke(r.Scores); req.Success += r => scoresCallback?.Invoke(r.Scores);

View File

@ -35,6 +35,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Game.Scoring;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
@ -215,7 +216,7 @@ namespace osu.Game.Screens.Select
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins) private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins, ScoreManager scores)
{ {
mods.BindTo(Mods); mods.BindTo(Mods);
@ -252,7 +253,7 @@ namespace osu.Game.Screens.Select
if (!beatmaps.GetAllUsableBeatmapSets().Any() && beatmaps.StableInstallationAvailable) if (!beatmaps.GetAllUsableBeatmapSets().Any() && beatmaps.StableInstallationAvailable)
dialogOverlay.Push(new ImportFromStablePopup(() => dialogOverlay.Push(new ImportFromStablePopup(() =>
{ {
Task.Run(beatmaps.ImportFromStableAsync); Task.Run(beatmaps.ImportFromStableAsync).ContinueWith(_ => scores.ImportFromStableAsync(), TaskContinuationOptions.OnlyOnRanToCompletion);
Task.Run(skins.ImportFromStableAsync); Task.Run(skins.ImportFromStableAsync);
})); }));
}); });

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Threading; using System.Threading;
@ -54,6 +55,8 @@ namespace osu.Game.Skinning
}; };
} }
protected override bool ShouldDeleteArchive(string path) => Path.GetExtension(path)?.ToLowerInvariant() == ".osk";
/// <summary> /// <summary>
/// Returns a list of all usable <see cref="SkinInfo"/>s. Includes the special default skin plus all skins from <see cref="GetAllUserSkins"/>. /// Returns a list of all usable <see cref="SkinInfo"/>s. Includes the special default skin plus all skins from <see cref="GetAllUserSkins"/>.
/// </summary> /// </summary>