1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 06:47:24 +08:00

Merge remote-tracking branch 'upstream/master' into #7146

This commit is contained in:
Dean Herbert 2020-01-09 17:08:12 +08:00
commit ab9603b06a
35 changed files with 400 additions and 355 deletions

View File

@ -54,6 +54,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1230.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1227.1" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.103.0" />
</ItemGroup>
</Project>

View File

@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Catch.Judgements
return 0;
case HitResult.Perfect:
return 0.008;
return 0.01;
}
}

View File

@ -18,17 +18,5 @@ namespace osu.Game.Rulesets.Catch.Judgements
return 30;
}
}
protected override double HealthIncreaseFor(HitResult result)
{
switch (result)
{
default:
return base.HealthIncreaseFor(result);
case HitResult.Perfect:
return 0.007;
}
}
}
}

View File

@ -23,18 +23,6 @@ namespace osu.Game.Rulesets.Catch.Judgements
}
}
protected override double HealthIncreaseFor(HitResult result)
{
switch (result)
{
default:
return -0.02;
case HitResult.Perfect:
return 0.01;
}
}
/// <summary>
/// Whether fruit on the platter should explode or drop.
/// Note that this is only checked if the owning object is also <see cref="IHasComboInformation.LastInCombo" />

View File

@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Catch.Judgements
return 0;
case HitResult.Perfect:
return 0.004;
return 0.02;
}
}
}

View File

@ -15,11 +15,11 @@ namespace osu.Game.Rulesets.Mania.Judgements
{
switch (result)
{
case HitResult.Miss:
default:
return 0;
default:
return 0.040;
case HitResult.Perfect:
return 0.01;
}
}
}

View File

@ -29,32 +29,5 @@ namespace osu.Game.Rulesets.Mania.Judgements
return 300;
}
}
protected override double HealthIncreaseFor(HitResult result)
{
switch (result)
{
case HitResult.Miss:
return -0.125;
case HitResult.Meh:
return 0.005;
case HitResult.Ok:
return 0.010;
case HitResult.Good:
return 0.035;
case HitResult.Great:
return 0.055;
case HitResult.Perfect:
return 0.065;
default:
return 0;
}
}
}
}

View File

@ -1,68 +0,0 @@
// 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.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces
{
public class GlowPiece : CompositeDrawable, IHasAccentColour
{
private const float glow_alpha = 0.7f;
private const float glow_radius = 5;
public GlowPiece()
{
RelativeSizeAxes = Axes.Both;
Masking = true;
InternalChild = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true
};
}
protected override void LoadComplete()
{
base.LoadComplete();
updateGlow();
}
private Color4 accentColour;
public Color4 AccentColour
{
get => accentColour;
set
{
if (accentColour == value)
return;
accentColour = value;
updateGlow();
}
}
private void updateGlow()
{
if (!IsLoaded)
return;
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
Colour = AccentColour.Opacity(glow_alpha),
Radius = glow_radius,
Hollow = true
};
}
}
}

View File

@ -1,85 +0,0 @@
// 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 osuTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces
{
public class LaneGlowPiece : CompositeDrawable, IHasAccentColour
{
private const float total_height = 100;
private const float glow_height = 50;
private const float glow_alpha = 0.4f;
private const float edge_alpha = 0.3f;
public LaneGlowPiece()
{
BypassAutoSizeAxes = Axes.Both;
RelativeSizeAxes = Axes.X;
Height = total_height;
InternalChildren = new[]
{
new Container
{
Name = "Left edge",
RelativeSizeAxes = Axes.Y,
Width = 1,
Children = createGradient(edge_alpha)
},
new Container
{
Name = "Right edge",
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
Width = 1,
Children = createGradient(edge_alpha)
},
new Container
{
Name = "Glow",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
Height = glow_height,
Children = createGradient(glow_alpha)
}
};
}
private Drawable[] createGradient(float alpha) => new Drawable[]
{
new Box
{
Name = "Top",
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
Blending = BlendingParameters.Additive,
Colour = ColourInfo.GradientVertical(Color4.Transparent, Color4.White.Opacity(alpha))
},
new Box
{
Name = "Bottom",
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
Blending = BlendingParameters.Additive,
Colour = ColourInfo.GradientVertical(Color4.White.Opacity(alpha), Color4.Transparent)
}
};
public Color4 AccentColour
{
get => Colour;
set => Colour = value;
}
}
}

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>
<PropertyGroup Label="Project">

View File

@ -8,6 +8,7 @@ using NUnit.Framework;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.IO.Stores;
using osu.Framework.Testing;
using osu.Game.Audio;
using osu.Game.Skinning;
using osu.Game.Tests.Resources;
@ -15,6 +16,7 @@ using osu.Game.Tests.Visual;
namespace osu.Game.Tests.Gameplay
{
[HeadlessTest]
public class TestSceneStoryboardSamples : OsuTestScene
{
[Test]

View File

@ -0,0 +1,51 @@
// 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 NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Overlays.Notifications;
using osu.Game.Tests.Visual;
namespace osu.Game.Tests.Online
{
[HeadlessTest]
public class TestSceneBeatmapManager : OsuTestScene
{
private BeatmapManager beatmaps;
private ProgressNotification recentNotification;
private static readonly BeatmapSetInfo test_model = new BeatmapSetInfo { OnlineBeatmapSetID = 1 };
[BackgroundDependencyLoader]
private void load(BeatmapManager beatmaps)
{
this.beatmaps = beatmaps;
beatmaps.PostNotification = n => recentNotification = n as ProgressNotification;
}
[Test]
public void TestCancelDownloadFromRequest()
{
AddStep("download beatmap", () => beatmaps.Download(test_model));
AddStep("cancel download from request", () => beatmaps.GetExistingDownload(test_model).Cancel());
AddUntilStep("is removed from download list", () => beatmaps.GetExistingDownload(test_model) == null);
AddAssert("is notification cancelled", () => recentNotification.State == ProgressNotificationState.Cancelled);
}
[Test]
public void TestCancelDownloadFromNotification()
{
AddStep("download beatmap", () => beatmaps.Download(test_model));
AddStep("cancel download from notification", () => recentNotification.Close());
AddUntilStep("is removed from download list", () => beatmaps.GetExistingDownload(test_model) == null);
AddAssert("is notification cancelled", () => recentNotification.State == ProgressNotificationState.Cancelled);
}
}
}

View File

@ -146,6 +146,18 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("player mods applied", () => playerMod2.Applied);
}
[Test]
public void TestModDisplayChanges()
{
var testMod = new TestMod();
AddStep("load player", () => ResetPlayer(true));
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
AddStep("set test mod in loader", () => loader.Mods.Value = new[] { testMod });
AddAssert("test mod is displayed", () => (TestMod)loader.DisplayedMods.Single() == testMod);
}
[Test]
public void TestMutedNotificationMasterVolume() => addVolumeSteps("master volume", () => audioManager.Volume.Value = 0, null, () => audioManager.Volume.IsDefault);
@ -221,6 +233,8 @@ namespace osu.Game.Tests.Visual.Gameplay
public new Task DisposalTask => base.DisposalTask;
public IReadOnlyList<Mod> DisplayedMods => MetadataInfo.Mods.Value;
public TestPlayerLoader(Func<Player> createPlayer)
: base(createPlayer)
{

View File

@ -9,6 +9,7 @@ using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards;
using osu.Game.Overlays;
using osu.Game.Online.Placeholders;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Scoring;
using osu.Game.Screens.Select.Leaderboards;

View File

@ -4,8 +4,10 @@
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Timing;
using osu.Framework.MathUtils;
using osu.Game.Beatmaps;
using osu.Game.Overlays;
using osu.Game.Rulesets.Osu;
namespace osu.Game.Tests.Visual.UserInterface
{
@ -15,22 +17,48 @@ namespace osu.Game.Tests.Visual.UserInterface
[Cached]
private MusicController musicController = new MusicController();
public TestSceneNowPlayingOverlay()
{
Clock = new FramedClock();
private WorkingBeatmap currentBeatmap;
var np = new NowPlayingOverlay
private NowPlayingOverlay nowPlayingOverlay;
[BackgroundDependencyLoader]
private void load()
{
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
nowPlayingOverlay = new NowPlayingOverlay
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre
};
Add(musicController);
Add(np);
Add(nowPlayingOverlay);
}
AddStep(@"show", () => np.Show());
[Test]
public void TestShowHideDisable()
{
AddStep(@"show", () => nowPlayingOverlay.Show());
AddToggleStep(@"toggle beatmap lock", state => Beatmap.Disabled = state);
AddStep(@"show", () => np.Hide());
AddStep(@"hide", () => nowPlayingOverlay.Hide());
}
[Test]
public void TestPrevTrackBehavior()
{
AddStep(@"Play track", () =>
{
musicController.NextTrack();
currentBeatmap = Beatmap.Value;
});
AddStep(@"Seek track to 6 second", () => musicController.SeekTo(6000));
AddUntilStep(@"Wait for current time to update", () => currentBeatmap.Track.CurrentTime > 5000);
AddAssert(@"Check action is restart track", () => musicController.PreviousTrack() == PreviousTrackResult.Restart);
AddUntilStep("Wait for current time to update", () => Precision.AlmostEquals(currentBeatmap.Track.CurrentTime, 0));
AddAssert(@"Check track didn't change", () => currentBeatmap == Beatmap.Value);
AddAssert(@"Check action is not restart", () => musicController.PreviousTrack() != PreviousTrackResult.Restart);
}
}
}

View File

@ -48,11 +48,9 @@ namespace osu.Game.Beatmaps.Drawables
InternalChild = iconContainer = new Container { Size = new Vector2(20f) };
}
public string TooltipText { get; set; }
public ITooltip GetCustomTooltip() => new DifficultyIconTooltip();
public object TooltipContent { get; set; }
public object TooltipContent { get; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)

View File

@ -92,8 +92,6 @@ namespace osu.Game.Database
notification.CancelRequested += () =>
{
request.Cancel();
currentDownloads.Remove(request);
notification.State = ProgressNotificationState.Cancelled;
return true;
};
@ -109,11 +107,11 @@ namespace osu.Game.Database
{
DownloadFailed?.Invoke(request);
if (error is OperationCanceledException) return;
notification.State = ProgressNotificationState.Cancelled;
Logger.Error(error, $"{HumanisedModelName.Titleize()} download failed!");
currentDownloads.Remove(request);
notification.State = ProgressNotificationState.Cancelled;
if (!(error is OperationCanceledException))
Logger.Error(error, $"{HumanisedModelName.Titleize()} download failed!");
}
}

View File

@ -29,8 +29,33 @@ namespace osu.Game.Graphics.Backgrounds
/// </summary>
private const float edge_smoothness = 1;
public Color4 ColourLight = Color4.White;
public Color4 ColourDark = Color4.Black;
private Color4 colourLight = Color4.White;
public Color4 ColourLight
{
get => colourLight;
set
{
if (colourLight == value) return;
colourLight = value;
updateColours();
}
}
private Color4 colourDark = Color4.Black;
public Color4 ColourDark
{
get => colourDark;
set
{
if (colourDark == value) return;
colourDark = value;
updateColours();
}
}
/// <summary>
/// Whether we want to expire triangles as they exit our draw area completely.
@ -151,7 +176,8 @@ namespace osu.Game.Graphics.Backgrounds
TriangleParticle particle = CreateTriangle();
particle.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() : 1);
particle.Colour = CreateTriangleShade();
particle.ColourShade = RNG.NextSingle();
particle.Colour = CreateTriangleShade(particle.ColourShade);
return particle;
}
@ -177,7 +203,17 @@ namespace osu.Game.Graphics.Backgrounds
/// Creates a shade of colour for the triangles.
/// </summary>
/// <returns>The colour.</returns>
protected virtual Color4 CreateTriangleShade() => Interpolation.ValueAt(RNG.NextSingle(), ColourDark, ColourLight, 0, 1);
protected virtual Color4 CreateTriangleShade(float shade) => Interpolation.ValueAt(shade, colourDark, colourLight, 0, 1);
private void updateColours()
{
for (int i = 0; i < parts.Count; i++)
{
TriangleParticle newParticle = parts[i];
newParticle.Colour = CreateTriangleShade(newParticle.ColourShade);
parts[i] = newParticle;
}
}
protected override DrawNode CreateDrawNode() => new TrianglesDrawNode(this);
@ -264,6 +300,12 @@ namespace osu.Game.Graphics.Backgrounds
/// </summary>
public Vector2 Position;
/// <summary>
/// The colour shade of the triangle.
/// This is needed for colour recalculation of visible triangles when <see cref="ColourDark"/> or <see cref="ColourLight"/> is changed.
/// </summary>
public float ColourShade;
/// <summary>
/// The colour of the triangle.
/// </summary>

View File

@ -123,8 +123,6 @@ namespace osu.Game.Graphics.Containers
Masking = true;
Child = box = new Box { RelativeSizeAxes = Axes.Both };
ResizeTo(1);
}
[BackgroundDependencyLoader]

View File

@ -32,6 +32,7 @@ namespace osu.Game.Input.Bindings
new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.R }, GlobalAction.ResetInputSettings),
new KeyBinding(new[] { InputKey.Control, InputKey.T }, GlobalAction.ToggleToolbar),
new KeyBinding(new[] { InputKey.Control, InputKey.O }, GlobalAction.ToggleSettings),
new KeyBinding(new[] { InputKey.Control, InputKey.D }, GlobalAction.ToggleDirect),
new KeyBinding(InputKey.Escape, GlobalAction.Back),
new KeyBinding(InputKey.ExtraMouseButton1, GlobalAction.Back),

View File

@ -14,7 +14,7 @@ namespace osu.Game.Online.API
/// <typeparam name="T">Type of the response (used for deserialisation).</typeparam>
public abstract class APIRequest<T> : APIRequest
{
protected override WebRequest CreateWebRequest() => new JsonWebRequest<T>(Uri);
protected override WebRequest CreateWebRequest() => new OsuJsonWebRequest<T>(Uri);
public T Result => ((JsonWebRequest<T>)WebRequest).ResponseObject;
@ -30,6 +30,16 @@ namespace osu.Game.Online.API
/// This will be scheduled to the API's internal scheduler (run on update thread automatically).
/// </summary>
public new event APISuccessHandler<T> Success;
private class OsuJsonWebRequest<U> : JsonWebRequest<U>
{
public OsuJsonWebRequest(string uri)
: base(uri)
{
}
protected override string UserAgent => "osu!";
}
}
/// <summary>
@ -39,7 +49,7 @@ namespace osu.Game.Online.API
{
protected abstract string Target { get; }
protected virtual WebRequest CreateWebRequest() => new WebRequest(Uri);
protected virtual WebRequest CreateWebRequest() => new OsuWebRequest(Uri);
protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}";
@ -152,6 +162,16 @@ namespace osu.Game.Online.API
[JsonProperty("error")]
public string ErrorMessage { get; set; }
}
private class OsuWebRequest : WebRequest
{
public OsuWebRequest(string uri)
: base(uri)
{
}
protected override string UserAgent => "osu!";
}
}
public class APIException : InvalidOperationException

View File

@ -15,6 +15,7 @@ using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.Placeholders;
using osuTK;
using osuTK.Graphics;
@ -151,7 +152,7 @@ namespace osu.Game.Online.Leaderboards
break;
case PlaceholderState.NotLoggedIn:
replacePlaceholder(new MessagePlaceholder(@"Please sign in to view online leaderboards!"));
replacePlaceholder(new LoginPlaceholder());
break;
case PlaceholderState.NotSupporter:

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers;
using osu.Game.Online.Placeholders;
using osuTK;
namespace osu.Game.Online.Leaderboards

View File

@ -0,0 +1,46 @@
// 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.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Overlays;
namespace osu.Game.Online.Placeholders
{
public sealed class LoginPlaceholder : Placeholder
{
[Resolved(CanBeNull = true)]
private LoginOverlay login { get; set; }
public LoginPlaceholder()
{
AddIcon(FontAwesome.Solid.UserLock, cp =>
{
cp.Font = cp.Font.With(size: TEXT_SIZE);
cp.Padding = new MarginPadding { Right = 10 };
});
AddText(@"Please sign in to view online leaderboards!");
}
protected override bool OnMouseDown(MouseDownEvent e)
{
this.ScaleTo(0.8f, 4000, Easing.OutQuint);
return base.OnMouseDown(e);
}
protected override bool OnMouseUp(MouseUpEvent e)
{
this.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(e);
}
protected override bool OnClick(ClickEvent e)
{
login?.Show();
return base.OnClick(e);
}
}
}

View File

@ -4,7 +4,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Online.Leaderboards
namespace osu.Game.Online.Placeholders
{
public class MessagePlaceholder : Placeholder
{

View File

@ -5,7 +5,7 @@ using System;
using osu.Framework.Graphics;
using osu.Game.Graphics.Containers;
namespace osu.Game.Online.Leaderboards
namespace osu.Game.Online.Placeholders
{
public abstract class Placeholder : OsuTextFlowContainer, IEquatable<Placeholder>
{

View File

@ -196,7 +196,7 @@ namespace osu.Game.Overlays.AccountCreation
return;
}
api.Login(emailTextBox.Text, passwordTextBox.Text);
api.Login(usernameTextBox.Text, passwordTextBox.Text);
});
});
}

View File

@ -16,6 +16,7 @@ using osu.Framework.Graphics.Shapes;
using System.Linq;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Chat;
using osu.Framework.Allocation;
namespace osu.Game.Overlays.Comments
{
@ -28,10 +29,16 @@ namespace osu.Game.Overlays.Comments
private readonly BindableBool childrenExpanded = new BindableBool(true);
private readonly FillFlowContainer childCommentsVisibilityContainer;
private FillFlowContainer childCommentsVisibilityContainer;
private readonly Comment comment;
public DrawableComment(Comment comment)
{
this.comment = comment;
}
[BackgroundDependencyLoader]
private void load()
{
LinkFlowContainer username;
FillFlowContainer childCommentsContainer;
@ -41,8 +48,6 @@ namespace osu.Game.Overlays.Comments
GridContainer content;
VotePill votePill;
this.comment = comment;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
InternalChild = new FillFlowContainer

View File

@ -41,105 +41,114 @@ namespace osu.Game.Overlays
private SampleChannel getSample;
private readonly Container content;
public MedalOverlay(Medal medal)
{
this.medal = medal;
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
Child = content = new Container
{
background = new Box
Alpha = 0,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(60),
},
outerSpin = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(DISC_SIZE + 500),
Alpha = 0f,
},
backgroundStrip = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
Height = border_width,
Alpha = 0f,
Children = new[]
background = new Box
{
new Container
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(60),
},
outerSpin = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(DISC_SIZE + 500),
Alpha = 0f,
},
backgroundStrip = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
Height = border_width,
Alpha = 0f,
Children = new[]
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.CentreRight,
Width = 0.5f,
Padding = new MarginPadding { Right = DISC_SIZE / 2 },
Children = new[]
new Container
{
leftStrip = new BackgroundStrip(0f, 1f)
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.CentreRight,
Width = 0.5f,
Padding = new MarginPadding { Right = DISC_SIZE / 2 },
Children = new[]
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
leftStrip = new BackgroundStrip(0f, 1f)
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
},
},
},
new Container
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.CentreLeft,
Width = 0.5f,
Padding = new MarginPadding { Left = DISC_SIZE / 2 },
Children = new[]
{
rightStrip = new BackgroundStrip(1f, 0f),
},
},
},
new Container
},
particleContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Alpha = 0f,
},
disc = new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Alpha = 0f,
Masking = true,
AlwaysPresent = true,
BorderColour = Color4.White,
BorderThickness = border_width,
Size = new Vector2(DISC_SIZE),
Scale = new Vector2(0.8f),
Children = new Drawable[]
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.CentreLeft,
Width = 0.5f,
Padding = new MarginPadding { Left = DISC_SIZE / 2 },
Children = new[]
new Box
{
rightStrip = new BackgroundStrip(1f, 0f),
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"05262f"),
},
new Triangles
{
RelativeSizeAxes = Axes.Both,
TriangleScale = 2,
ColourDark = OsuColour.FromHex(@"04222b"),
ColourLight = OsuColour.FromHex(@"052933"),
},
innerSpin = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(1.05f),
Alpha = 0.25f,
},
},
},
},
particleContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Alpha = 0f,
},
disc = new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Alpha = 0f,
Masking = true,
AlwaysPresent = true,
BorderColour = Color4.White,
BorderThickness = border_width,
Size = new Vector2(DISC_SIZE),
Scale = new Vector2(0.8f),
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"05262f"),
},
new Triangles
{
RelativeSizeAxes = Axes.Both,
TriangleScale = 2,
ColourDark = OsuColour.FromHex(@"04222b"),
ColourLight = OsuColour.FromHex(@"052933"),
},
innerSpin = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(1.05f),
Alpha = 0.25f,
},
},
},
}
};
Show();
}
[BackgroundDependencyLoader]
@ -154,19 +163,22 @@ namespace osu.Game.Overlays
Colour = colours.Blue.Opacity(0.5f),
Radius = 50,
};
disc.Add(drawableMedal = new DrawableMedal(medal)
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Both,
});
}
protected override void LoadComplete()
{
base.LoadComplete();
Show();
LoadComponentAsync(drawableMedal = new DrawableMedal(medal)
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Both,
}, loaded =>
{
disc.Add(loaded);
startAnimation();
});
}
protected override void Update()
@ -190,11 +202,10 @@ namespace osu.Game.Overlays
private const double initial_duration = 400;
private const double step_duration = 900;
protected override void PopIn()
private void startAnimation()
{
base.PopIn();
content.Show();
this.FadeIn(200);
background.FlashColour(Color4.White.Opacity(0.25f), 400);
getSample.Play();

View File

@ -51,7 +51,7 @@ namespace osu.Game.Overlays.MedalSplash
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(0.81f),
Scale = new Vector2(0.41f),
},
medalGlow = new Sprite
{

View File

@ -27,6 +27,11 @@ namespace osu.Game.Overlays
public IBindableList<BeatmapSetInfo> BeatmapSets => beatmapSets;
/// <summary>
/// Point in time after which the current track will be restarted on triggering a "previous track" action.
/// </summary>
private const double restart_cutoff_point = 5000;
private readonly BindableList<BeatmapSetInfo> beatmapSets = new BindableList<BeatmapSetInfo>();
public bool IsUserPaused { get; private set; }
@ -151,11 +156,19 @@ namespace osu.Game.Overlays
}
/// <summary>
/// Play the previous track.
/// Play the previous track or restart the current track if it's current time below <see cref="restart_cutoff_point"/>
/// </summary>
/// <returns>Whether the operation was successful.</returns>
public bool PrevTrack()
/// <returns>The <see cref="PreviousTrackResult"/> that indicate the decided action</returns>
public PreviousTrackResult PreviousTrack()
{
var currentTrackPosition = current?.Track.CurrentTime;
if (currentTrackPosition >= restart_cutoff_point)
{
SeekTo(0);
return PreviousTrackResult.Restart;
}
queuedDirection = TrackChangeDirection.Prev;
var playable = BeatmapSets.TakeWhile(i => i.ID != current.BeatmapSetInfo.ID).LastOrDefault() ?? BeatmapSets.LastOrDefault();
@ -166,10 +179,10 @@ namespace osu.Game.Overlays
working.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value);
beatmap.Value.Track.Restart();
return true;
return PreviousTrackResult.Previous;
}
return false;
return PreviousTrackResult.None;
}
/// <summary>
@ -296,8 +309,16 @@ namespace osu.Game.Overlays
return true;
case GlobalAction.MusicPrev:
if (PrevTrack())
onScreenDisplay?.Display(new MusicControllerToast("Previous track"));
switch (PreviousTrack())
{
case PreviousTrackResult.Restart:
onScreenDisplay?.Display(new MusicControllerToast("Restart track"));
break;
case PreviousTrackResult.Previous:
onScreenDisplay?.Display(new MusicControllerToast("Previous track"));
break;
}
return true;
}
@ -322,4 +343,11 @@ namespace osu.Game.Overlays
Next,
Prev
}
public enum PreviousTrackResult
{
None,
Restart,
Previous
}
}

View File

@ -137,7 +137,7 @@ namespace osu.Game.Overlays
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Action = () => musicController.PrevTrack(),
Action = () => musicController.PreviousTrack(),
Icon = FontAwesome.Solid.StepBackward,
},
playButton = new MusicIconButton

View File

@ -44,7 +44,7 @@ namespace osu.Game.Screens.Play
private LogoTrackingContainer content;
private BeatmapMetadataDisplay info;
protected BeatmapMetadataDisplay MetadataInfo;
private bool hideOverlays;
public override bool HideOverlaysOnEnter => hideOverlays;
@ -96,7 +96,7 @@ namespace osu.Game.Screens.Play
RelativeSizeAxes = Axes.Both,
}).WithChildren(new Drawable[]
{
info = new BeatmapMetadataDisplay(Beatmap.Value, Mods.Value, content.LogoFacade)
MetadataInfo = new BeatmapMetadataDisplay(Beatmap.Value, Mods, content.LogoFacade)
{
Alpha = 0,
Anchor = Anchor.Centre,
@ -138,7 +138,7 @@ namespace osu.Game.Screens.Play
contentIn();
info.Delay(750).FadeIn(500);
MetadataInfo.Delay(750).FadeIn(500);
this.Delay(1800).Schedule(pushWhenLoaded);
if (!muteWarningShownOnce.Value)
@ -158,7 +158,7 @@ namespace osu.Game.Screens.Play
contentIn();
info.Loading = true;
MetadataInfo.Loading = true;
//we will only be resumed if the player has requested a re-run (see ValidForResume setting above)
loadNewPlayer();
@ -174,7 +174,7 @@ namespace osu.Game.Screens.Play
player.RestartCount = restartCount;
player.RestartRequested = restartRequested;
LoadTask = LoadComponentAsync(player, _ => info.Loading = false);
LoadTask = LoadComponentAsync(player, _ => MetadataInfo.Loading = false);
}
private void contentIn()
@ -350,7 +350,7 @@ namespace osu.Game.Screens.Play
}
}
private class BeatmapMetadataDisplay : Container
protected class BeatmapMetadataDisplay : Container
{
private class MetadataLine : Container
{
@ -379,11 +379,13 @@ namespace osu.Game.Screens.Play
}
private readonly WorkingBeatmap beatmap;
private readonly IReadOnlyList<Mod> mods;
private readonly Bindable<IReadOnlyList<Mod>> mods;
private readonly Drawable facade;
private LoadingAnimation loading;
private Sprite backgroundSprite;
public IBindable<IReadOnlyList<Mod>> Mods => mods;
public bool Loading
{
set
@ -401,11 +403,13 @@ namespace osu.Game.Screens.Play
}
}
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods, Drawable facade)
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, Bindable<IReadOnlyList<Mod>> mods, Drawable facade)
{
this.beatmap = beatmap;
this.mods = mods;
this.facade = facade;
this.mods = new Bindable<IReadOnlyList<Mod>>();
this.mods.BindTo(mods);
}
[BackgroundDependencyLoader]
@ -492,7 +496,7 @@ namespace osu.Game.Screens.Play
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = 20 },
Current = { Value = mods }
Current = mods
}
},
}

View File

@ -23,7 +23,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1230.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.1227.1" />
<PackageReference Include="ppy.osu.Framework" Version="2020.103.0" />
<PackageReference Include="Sentry" Version="1.2.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.12.0" />

View File

@ -74,7 +74,7 @@
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1230.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.1227.1" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.103.0" />
</ItemGroup>
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
<ItemGroup Label="Transitive Dependencies">
@ -82,7 +82,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Framework" Version="2019.1227.1" />
<PackageReference Include="ppy.osu.Framework" Version="2020.103.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />