mirror of https://github.com/ppy/osu
Merge branch 'master' into player-test-flexibility
This commit is contained in:
commit
aca99c2c42
|
@ -20,6 +20,13 @@ public class CatchModHardRock : ModHardRock, IApplicableToHitObject
|
||||||
|
|
||||||
public void ApplyToHitObject(HitObject hitObject)
|
public void ApplyToHitObject(HitObject hitObject)
|
||||||
{
|
{
|
||||||
|
if (hitObject is JuiceStream stream)
|
||||||
|
{
|
||||||
|
lastPosition = stream.EndX;
|
||||||
|
lastStartTime = stream.EndTime;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(hitObject is Fruit))
|
if (!(hitObject is Fruit))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -70,7 +77,7 @@ public void ApplyToHitObject(HitObject hitObject)
|
||||||
private void applyRandomOffset(ref float position, double maxOffset)
|
private void applyRandomOffset(ref float position, double maxOffset)
|
||||||
{
|
{
|
||||||
bool right = RNG.NextBool();
|
bool right = RNG.NextBool();
|
||||||
float rand = Math.Min(20, (float)RNG.NextDouble(0, maxOffset)) / CatchPlayfield.BASE_WIDTH;
|
float rand = Math.Min(20, (float)RNG.NextDouble(0, Math.Max(0, maxOffset))) / CatchPlayfield.BASE_WIDTH;
|
||||||
|
|
||||||
if (right)
|
if (right)
|
||||||
{
|
{
|
||||||
|
|
|
@ -242,6 +242,61 @@ public void TestImportThenDeleteThenImportWithOnlineIDMismatch(bool set)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestImportWithDuplicateBeatmapIDs()
|
||||||
|
{
|
||||||
|
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
||||||
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportWithDuplicateBeatmapID"))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var osu = loadOsu(host);
|
||||||
|
|
||||||
|
var metadata = new BeatmapMetadata
|
||||||
|
{
|
||||||
|
Artist = "SomeArtist",
|
||||||
|
AuthorString = "SomeAuthor"
|
||||||
|
};
|
||||||
|
|
||||||
|
var difficulty = new BeatmapDifficulty();
|
||||||
|
|
||||||
|
var toImport = new BeatmapSetInfo
|
||||||
|
{
|
||||||
|
OnlineBeatmapSetID = 1,
|
||||||
|
Metadata = metadata,
|
||||||
|
Beatmaps = new List<BeatmapInfo>
|
||||||
|
{
|
||||||
|
new BeatmapInfo
|
||||||
|
{
|
||||||
|
OnlineBeatmapID = 2,
|
||||||
|
Metadata = metadata,
|
||||||
|
BaseDifficulty = difficulty
|
||||||
|
},
|
||||||
|
new BeatmapInfo
|
||||||
|
{
|
||||||
|
OnlineBeatmapID = 2,
|
||||||
|
Metadata = metadata,
|
||||||
|
Status = BeatmapSetOnlineStatus.Loved,
|
||||||
|
BaseDifficulty = difficulty
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var manager = osu.Dependencies.Get<BeatmapManager>();
|
||||||
|
|
||||||
|
var imported = manager.Import(toImport);
|
||||||
|
|
||||||
|
Assert.NotNull(imported);
|
||||||
|
Assert.AreEqual(null, imported.Beatmaps[0].OnlineBeatmapID);
|
||||||
|
Assert.AreEqual(null, imported.Beatmaps[1].OnlineBeatmapID);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
host.Exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[NonParallelizable]
|
[NonParallelizable]
|
||||||
[Ignore("Binding IPC on Appveyor isn't working (port in use). Need to figure out why")]
|
[Ignore("Binding IPC on Appveyor isn't working (port in use). Need to figure out why")]
|
||||||
|
|
|
@ -105,11 +105,14 @@ protected override void Populate(BeatmapSetInfo beatmapSet, ArchiveReader archiv
|
||||||
validateOnlineIds(beatmapSet);
|
validateOnlineIds(beatmapSet);
|
||||||
|
|
||||||
foreach (BeatmapInfo b in beatmapSet.Beatmaps)
|
foreach (BeatmapInfo b in beatmapSet.Beatmaps)
|
||||||
fetchAndPopulateOnlineValues(b, beatmapSet.Beatmaps);
|
fetchAndPopulateOnlineValues(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PreImport(BeatmapSetInfo beatmapSet)
|
protected override void PreImport(BeatmapSetInfo beatmapSet)
|
||||||
{
|
{
|
||||||
|
if (beatmapSet.Beatmaps.Any(b => b.BaseDifficulty == null))
|
||||||
|
throw new InvalidOperationException($"Cannot import {nameof(BeatmapInfo)} with null {nameof(BeatmapInfo.BaseDifficulty)}.");
|
||||||
|
|
||||||
// check if a set already exists with the same online id, delete if it does.
|
// check if a set already exists with the same online id, delete if it does.
|
||||||
if (beatmapSet.OnlineBeatmapSetID != null)
|
if (beatmapSet.OnlineBeatmapSetID != null)
|
||||||
{
|
{
|
||||||
|
@ -382,7 +385,7 @@ private List<BeatmapInfo> createBeatmapDifficulties(ArchiveReader reader)
|
||||||
/// <param name="otherBeatmaps">The other beatmaps contained within this set.</param>
|
/// <param name="otherBeatmaps">The other beatmaps contained within this set.</param>
|
||||||
/// <param name="force">Whether to re-query if the provided beatmap already has populated values.</param>
|
/// <param name="force">Whether to re-query if the provided beatmap already has populated values.</param>
|
||||||
/// <returns>True if population was successful.</returns>
|
/// <returns>True if population was successful.</returns>
|
||||||
private bool fetchAndPopulateOnlineValues(BeatmapInfo beatmap, IEnumerable<BeatmapInfo> otherBeatmaps, bool force = false)
|
private bool fetchAndPopulateOnlineValues(BeatmapInfo beatmap, bool force = false)
|
||||||
{
|
{
|
||||||
if (api?.State != APIState.Online)
|
if (api?.State != APIState.Online)
|
||||||
return false;
|
return false;
|
||||||
|
@ -405,13 +408,6 @@ private bool fetchAndPopulateOnlineValues(BeatmapInfo beatmap, IEnumerable<Beatm
|
||||||
|
|
||||||
beatmap.Status = res.Status;
|
beatmap.Status = res.Status;
|
||||||
beatmap.BeatmapSet.Status = res.BeatmapSet.Status;
|
beatmap.BeatmapSet.Status = res.BeatmapSet.Status;
|
||||||
|
|
||||||
if (otherBeatmaps.Any(b => b.OnlineBeatmapID == res.OnlineBeatmapID))
|
|
||||||
{
|
|
||||||
Logger.Log("Another beatmap in the same set already mapped to this ID. We'll skip adding it this time.", LoggingTarget.Database);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID;
|
beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID;
|
||||||
beatmap.OnlineBeatmapID = res.OnlineBeatmapID;
|
beatmap.OnlineBeatmapID = res.OnlineBeatmapID;
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace osu.Game.Screens
|
||||||
public class BackgroundScreenStack : ScreenStack
|
public class BackgroundScreenStack : ScreenStack
|
||||||
{
|
{
|
||||||
public BackgroundScreenStack()
|
public BackgroundScreenStack()
|
||||||
|
: base(false)
|
||||||
{
|
{
|
||||||
Scale = new Vector2(1.06f);
|
Scale = new Vector2(1.06f);
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// 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.Threading;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
@ -26,7 +27,24 @@ public class BackgroundScreenBeatmap : BlurrableBackgroundScreen
|
||||||
|
|
||||||
protected virtual UserDimContainer CreateFadeContainer() => new UserDimContainer { RelativeSizeAxes = Axes.Both };
|
protected virtual UserDimContainer CreateFadeContainer() => new UserDimContainer { RelativeSizeAxes = Axes.Both };
|
||||||
|
|
||||||
public virtual WorkingBeatmap Beatmap
|
public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null)
|
||||||
|
{
|
||||||
|
Beatmap = beatmap;
|
||||||
|
InternalChild = fadeContainer = CreateFadeContainer();
|
||||||
|
fadeContainer.EnableUserDim.BindTo(EnableUserDim);
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
var background = new BeatmapBackground(beatmap);
|
||||||
|
LoadComponent(background);
|
||||||
|
switchBackground(background);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CancellationTokenSource cancellationSource;
|
||||||
|
|
||||||
|
public WorkingBeatmap Beatmap
|
||||||
{
|
{
|
||||||
get => beatmap;
|
get => beatmap;
|
||||||
set
|
set
|
||||||
|
@ -38,54 +56,52 @@ public virtual WorkingBeatmap Beatmap
|
||||||
|
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
LoadComponentAsync(new BeatmapBackground(beatmap), b => Schedule(() =>
|
if ((Background as BeatmapBackground)?.Beatmap == beatmap)
|
||||||
{
|
return;
|
||||||
float newDepth = 0;
|
|
||||||
if (Background != null)
|
|
||||||
{
|
|
||||||
newDepth = Background.Depth + 1;
|
|
||||||
Background.FinishTransforms();
|
|
||||||
Background.FadeOut(250);
|
|
||||||
Background.Expire();
|
|
||||||
}
|
|
||||||
|
|
||||||
b.Depth = newDepth;
|
cancellationSource?.Cancel();
|
||||||
fadeContainer.Add(Background = b);
|
LoadComponentAsync(new BeatmapBackground(beatmap), switchBackground, (cancellationSource = new CancellationTokenSource()).Token);
|
||||||
Background.BlurSigma = BlurTarget;
|
|
||||||
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null)
|
private void switchBackground(BeatmapBackground b)
|
||||||
{
|
{
|
||||||
Beatmap = beatmap;
|
float newDepth = 0;
|
||||||
InternalChild = fadeContainer = CreateFadeContainer();
|
if (Background != null)
|
||||||
fadeContainer.EnableUserDim.BindTo(EnableUserDim);
|
{
|
||||||
|
newDepth = Background.Depth + 1;
|
||||||
|
Background.FinishTransforms();
|
||||||
|
Background.FadeOut(250);
|
||||||
|
Background.Expire();
|
||||||
|
}
|
||||||
|
|
||||||
|
b.Depth = newDepth;
|
||||||
|
fadeContainer.Add(Background = b);
|
||||||
|
Background.BlurSigma = BlurTarget;
|
||||||
|
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(BackgroundScreen other)
|
public override bool Equals(BackgroundScreen other)
|
||||||
{
|
{
|
||||||
var otherBeatmapBackground = other as BackgroundScreenBeatmap;
|
if (!(other is BackgroundScreenBeatmap otherBeatmapBackground)) return false;
|
||||||
if (otherBeatmapBackground == null) return false;
|
|
||||||
|
|
||||||
return base.Equals(other) && beatmap == otherBeatmapBackground.Beatmap;
|
return base.Equals(other) && beatmap == otherBeatmapBackground.Beatmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class BeatmapBackground : Background
|
protected class BeatmapBackground : Background
|
||||||
{
|
{
|
||||||
private readonly WorkingBeatmap beatmap;
|
public readonly WorkingBeatmap Beatmap;
|
||||||
|
|
||||||
public BeatmapBackground(WorkingBeatmap beatmap)
|
public BeatmapBackground(WorkingBeatmap beatmap)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
Beatmap = beatmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textures)
|
private void load(TextureStore textures)
|
||||||
{
|
{
|
||||||
Sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg1");
|
Sprite.Texture = Beatmap?.Background ?? textures.Get(@"Backgrounds/bg1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ private void load(IAPIProvider api, SkinManager skinManager)
|
||||||
|
|
||||||
currentDisplay = RNG.Next(0, background_count);
|
currentDisplay = RNG.Next(0, background_count);
|
||||||
|
|
||||||
Next();
|
display(createBackground());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void display(Background newBackground)
|
private void display(Background newBackground)
|
||||||
|
@ -51,19 +51,21 @@ private void display(Background newBackground)
|
||||||
public void Next()
|
public void Next()
|
||||||
{
|
{
|
||||||
nextTask?.Cancel();
|
nextTask?.Cancel();
|
||||||
nextTask = Scheduler.AddDelayed(() =>
|
nextTask = Scheduler.AddDelayed(() => { LoadComponentAsync(createBackground(), display); }, 100);
|
||||||
{
|
}
|
||||||
Background background;
|
|
||||||
|
|
||||||
if (user.Value?.IsSupporter ?? false)
|
private Background createBackground()
|
||||||
background = new SkinnedBackground(skin.Value, backgroundName);
|
{
|
||||||
else
|
Background background;
|
||||||
background = new Background(backgroundName);
|
|
||||||
|
|
||||||
background.Depth = currentDisplay;
|
if (user.Value?.IsSupporter ?? false)
|
||||||
|
background = new SkinnedBackground(skin.Value, backgroundName);
|
||||||
|
else
|
||||||
|
background = new Background(backgroundName);
|
||||||
|
|
||||||
LoadComponentAsync(background, display);
|
background.Depth = currentDisplay;
|
||||||
}, 100);
|
|
||||||
|
return background;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SkinnedBackground : Background
|
private class SkinnedBackground : Background
|
||||||
|
|
|
@ -14,7 +14,7 @@ public abstract class BlurrableBackgroundScreen : BackgroundScreen
|
||||||
|
|
||||||
protected Vector2 BlurTarget;
|
protected Vector2 BlurTarget;
|
||||||
|
|
||||||
public TransformSequence<Background> BlurTo(Vector2 sigma, double duration, Easing easing = Easing.None)
|
public TransformSequence<Background> BlurTo(Vector2 sigma, double duration = 0, Easing easing = Easing.None)
|
||||||
{
|
{
|
||||||
BlurTarget = sigma;
|
BlurTarget = sigma;
|
||||||
return Background?.BlurTo(BlurTarget, duration, easing);
|
return Background?.BlurTo(BlurTarget, duration, easing);
|
||||||
|
|
|
@ -40,7 +40,9 @@ public class MainMenu : OsuScreen
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private GameHost host { get; set; }
|
private GameHost host { get; set; }
|
||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault();
|
private BackgroundScreenDefault background;
|
||||||
|
|
||||||
|
protected override BackgroundScreen CreateBackground() => background;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuGame game = null)
|
private void load(OsuGame game = null)
|
||||||
|
@ -89,6 +91,7 @@ private void load(OsuGame game = null)
|
||||||
buttons.OnDirect = game.ToggleDirect;
|
buttons.OnDirect = game.ToggleDirect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LoadComponentAsync(background = new BackgroundScreenDefault());
|
||||||
preloadSongSelect();
|
preloadSongSelect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ public override void OnResuming(IScreen last)
|
||||||
/// Called when background elements require updates, usually due to a user changing a setting.
|
/// Called when background elements require updates, usually due to a user changing a setting.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userChange"></param>
|
/// <param name="userChange"></param>
|
||||||
protected virtual void UpdateBackgroundElements()
|
protected void UpdateBackgroundElements()
|
||||||
{
|
{
|
||||||
if (!this.IsCurrentScreen()) return;
|
if (!this.IsCurrentScreen()) return;
|
||||||
|
|
||||||
|
|
|
@ -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 osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
@ -61,7 +61,12 @@ public abstract class SongSelect : OsuScreen
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly Container FooterPanels;
|
protected readonly Container FooterPanels;
|
||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
|
protected override BackgroundScreen CreateBackground()
|
||||||
|
{
|
||||||
|
var background = new BackgroundScreenBeatmap();
|
||||||
|
background.BlurTo(background_blur);
|
||||||
|
return background;
|
||||||
|
}
|
||||||
|
|
||||||
protected readonly BeatmapCarousel Carousel;
|
protected readonly BeatmapCarousel Carousel;
|
||||||
private readonly BeatmapInfoWedge beatmapInfoWedge;
|
private readonly BeatmapInfoWedge beatmapInfoWedge;
|
||||||
|
|
Loading…
Reference in New Issue