1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 05:22:54 +08:00

Merge branch 'master' into osu-mod-icon-fallbacks

This commit is contained in:
Shivam 2021-01-25 15:00:48 +01:00
commit 331a7d0590
15 changed files with 183 additions and 33 deletions

View File

@ -25,7 +25,7 @@
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="System.IO.Packaging" Version="5.0.0" />
<PackageReference Include="ppy.squirrel.windows" Version="1.9.0.4" />
<PackageReference Include="ppy.squirrel.windows" Version="1.9.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />

View File

@ -1,6 +1,7 @@
// 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.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.Taiko.Mods
@ -8,5 +9,16 @@ namespace osu.Game.Rulesets.Taiko.Mods
public class TaikoModEasy : ModEasy
{
public override string Description => @"Beats move slower, and less accuracy required!";
/// <summary>
/// Multiplier factor added to the scrolling speed.
/// </summary>
private const double slider_multiplier = 0.8;
public override void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
base.ApplyToDifficulty(difficulty);
difficulty.SliderMultiplier *= slider_multiplier;
}
}
}

View File

@ -1,6 +1,7 @@
// 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.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.Taiko.Mods
@ -9,5 +10,21 @@ namespace osu.Game.Rulesets.Taiko.Mods
{
public override double ScoreMultiplier => 1.06;
public override bool Ranked => true;
/// <summary>
/// Multiplier factor added to the scrolling speed.
/// </summary>
/// <remarks>
/// This factor is made up of two parts: the base part (1.4) and the aspect ratio adjustment (4/3).
/// Stable applies the latter by dividing the width of the user's display by the width of a display with the same height, but 4:3 aspect ratio.
/// TODO: Revisit if taiko playfield ever changes away from a hard-coded 16:9 (see https://github.com/ppy/osu/issues/5685).
/// </remarks>
private const double slider_multiplier = 1.4 * 4 / 3;
public override void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
base.ApplyToDifficulty(difficulty);
difficulty.SliderMultiplier *= slider_multiplier;
}
}
}

View File

@ -0,0 +1,62 @@
// 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 System;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Framework.Testing;
using osu.Game.Screens.OnlinePlay;
using osu.Game.Tests.Visual;
namespace osu.Game.Tests.NonVisual
{
[HeadlessTest]
public class OngoingOperationTrackerTest : OsuTestScene
{
private OngoingOperationTracker tracker;
private IBindable<bool> operationInProgress;
[SetUpSteps]
public void SetUp()
{
AddStep("create tracker", () => Child = tracker = new OngoingOperationTracker());
AddStep("bind to operation status", () => operationInProgress = tracker.InProgress.GetBoundCopy());
}
[Test]
public void TestOperationTracking()
{
IDisposable firstOperation = null;
IDisposable secondOperation = null;
AddStep("begin first operation", () => firstOperation = tracker.BeginOperation());
AddAssert("first operation in progress", () => operationInProgress.Value);
AddStep("cannot start another operation",
() => Assert.Throws<InvalidOperationException>(() => tracker.BeginOperation()));
AddStep("end first operation", () => firstOperation.Dispose());
AddAssert("first operation is ended", () => !operationInProgress.Value);
AddStep("start second operation", () => secondOperation = tracker.BeginOperation());
AddAssert("second operation in progress", () => operationInProgress.Value);
AddStep("dispose first operation again", () => firstOperation.Dispose());
AddAssert("second operation still in progress", () => operationInProgress.Value);
AddStep("dispose second operation", () => secondOperation.Dispose());
AddAssert("second operation is ended", () => !operationInProgress.Value);
}
[Test]
public void TestOperationDisposalAfterTracker()
{
IDisposable operation = null;
AddStep("begin operation", () => operation = tracker.BeginOperation());
AddStep("dispose tracker", () => tracker.Expire());
AddStep("end operation", () => operation.Dispose());
AddAssert("operation is ended", () => !operationInProgress.Value);
}
}
}

View File

@ -1,6 +1,8 @@
// 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 System;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Tournament.Components;
@ -16,5 +18,23 @@ namespace osu.Game.Tournament.Tests.Screens
Add(new TourneyVideo("main") { RelativeSizeAxes = Axes.Both });
Add(new ScheduleScreen());
}
[Test]
public void TestCurrentMatchTime()
{
setMatchDate(TimeSpan.FromDays(-1));
setMatchDate(TimeSpan.FromSeconds(5));
setMatchDate(TimeSpan.FromMinutes(4));
setMatchDate(TimeSpan.FromHours(3));
}
private void setMatchDate(TimeSpan relativeTime)
// Humanizer cannot handle negative timespans.
=> AddStep($"start time is {relativeTime}", () =>
{
var match = CreateSampleMatch();
match.Date.Value = DateTimeOffset.Now + relativeTime;
Ladder.CurrentMatch.Value = match;
});
}
}

View File

@ -192,12 +192,7 @@ namespace osu.Game.Tournament.Screens.Schedule
Origin = Anchor.CentreLeft,
Children = new Drawable[]
{
new TournamentSpriteText
{
Text = "Starting ",
Font = OsuFont.Torus.With(size: 24, weight: FontWeight.Regular)
},
new DrawableDate(match.NewValue.Date.Value)
new ScheduleMatchDate(match.NewValue.Date.Value)
{
Font = OsuFont.Torus.With(size: 24, weight: FontWeight.Regular)
}
@ -251,6 +246,18 @@ namespace osu.Game.Tournament.Screens.Schedule
}
}
public class ScheduleMatchDate : DrawableDate
{
public ScheduleMatchDate(DateTimeOffset date, float textSize = OsuFont.DEFAULT_FONT_SIZE, bool italic = true)
: base(date, textSize, italic)
{
}
protected override string Format() => Date < DateTimeOffset.Now
? $"Started {base.Format()}"
: $"Starting {base.Format()}";
}
public class ScheduleContainer : Container
{
protected override Container<Drawable> Content => content;

View File

@ -50,15 +50,7 @@ namespace osu.Game.Beatmaps
IBeatmap IBeatmap.Clone() => Clone();
public Beatmap<T> Clone()
{
var clone = (Beatmap<T>)MemberwiseClone();
clone.ControlPointInfo = ControlPointInfo.CreateCopy();
// todo: deep clone other elements as required.
return clone;
}
public Beatmap<T> Clone() => (Beatmap<T>)MemberwiseClone();
}
public class Beatmap : Beatmap<HitObject>

View File

@ -24,7 +24,7 @@ namespace osu.Game.Beatmaps
/// <summary>
/// The control points in this beatmap.
/// </summary>
ControlPointInfo ControlPointInfo { get; }
ControlPointInfo ControlPointInfo { get; set; }
/// <summary>
/// The breaks in this beatmap.

View File

@ -216,9 +216,9 @@ namespace osu.Game.Overlays.Mods
},
new Drawable[]
{
// Footer
new Container
{
Name = "Footer content",
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Origin = Anchor.TopCentre,
@ -237,10 +237,9 @@ namespace osu.Game.Overlays.Mods
Anchor = Anchor.BottomCentre,
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
RelativePositionAxes = Axes.X,
Width = content_width,
Spacing = new Vector2(footer_button_spacing, footer_button_spacing / 2),
LayoutDuration = 100,
LayoutEasing = Easing.OutQuint,
Padding = new MarginPadding
{
Vertical = 15,
@ -354,7 +353,7 @@ namespace osu.Game.Overlays.Mods
{
base.PopOut();
footerContainer.MoveToX(footerContainer.DrawSize.X, WaveContainer.DISAPPEAR_DURATION, Easing.InSine);
footerContainer.MoveToX(content_width, WaveContainer.DISAPPEAR_DURATION, Easing.InSine);
footerContainer.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.InSine);
foreach (var section in ModSectionsContainer.Children)

View File

@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mods
{
}
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
public virtual void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
const float ratio = 1.4f;
difficulty.CircleSize = Math.Min(difficulty.CircleSize * 1.3f, 10.0f); // CS uses a custom 1.3 ratio.

View File

@ -131,6 +131,10 @@ namespace osu.Game.Screens.Edit
try
{
playableBeatmap = Beatmap.Value.GetPlayableBeatmap(Beatmap.Value.BeatmapInfo.Ruleset);
// clone these locally for now to avoid incurring overhead on GetPlayableBeatmap usages.
// eventually we will want to improve how/where this is done as there are issues with *not* cloning it in all cases.
playableBeatmap.ControlPointInfo = playableBeatmap.ControlPointInfo.CreateCopy();
}
catch (Exception e)
{

View File

@ -74,7 +74,11 @@ namespace osu.Game.Screens.Edit
public BeatmapMetadata Metadata => PlayableBeatmap.Metadata;
public ControlPointInfo ControlPointInfo => PlayableBeatmap.ControlPointInfo;
public ControlPointInfo ControlPointInfo
{
get => PlayableBeatmap.ControlPointInfo;
set => PlayableBeatmap.ControlPointInfo = value;
}
public List<BreakPeriod> Breaks => PlayableBeatmap.Breaks;

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -43,17 +42,46 @@ namespace osu.Game.Screens.OnlinePlay
leasedInProgress = inProgress.BeginLease(true);
leasedInProgress.Value = true;
// for extra safety, marshal the end of operation back to the update thread if necessary.
return new InvokeOnDisposal(() => Scheduler.Add(endOperation, false));
return new OngoingOperation(this, leasedInProgress);
}
private void endOperation()
private void endOperationWithKnownLease(LeasedBindable<bool> lease)
{
if (leasedInProgress == null)
throw new InvalidOperationException("Cannot end operation multiple times.");
if (lease != leasedInProgress)
return;
leasedInProgress.Return();
// for extra safety, marshal the end of operation back to the update thread if necessary.
Scheduler.Add(() =>
{
leasedInProgress?.Return();
leasedInProgress = null;
}, false);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
// base call does an UnbindAllBindables().
// clean up the leased reference here so that it doesn't get returned twice.
leasedInProgress = null;
}
private class OngoingOperation : IDisposable
{
private readonly OngoingOperationTracker tracker;
private readonly LeasedBindable<bool> lease;
public OngoingOperation(OngoingOperationTracker tracker, LeasedBindable<bool> lease)
{
this.tracker = tracker;
this.lease = lease;
}
public void Dispose()
{
tracker.endOperationWithKnownLease(lease);
}
}
}
}

View File

@ -29,7 +29,11 @@ namespace osu.Game.Screens.Play
public BeatmapMetadata Metadata => PlayableBeatmap.Metadata;
public ControlPointInfo ControlPointInfo => PlayableBeatmap.ControlPointInfo;
public ControlPointInfo ControlPointInfo
{
get => PlayableBeatmap.ControlPointInfo;
set => PlayableBeatmap.ControlPointInfo = value;
}
public List<BreakPeriod> Breaks => PlayableBeatmap.Breaks;

View File

@ -53,8 +53,6 @@ namespace osu.Game.Screens.Play.HUD
[BackgroundDependencyLoader]
private void load(OsuConfigManager config, IAPIProvider api)
{
streamingClient.OnNewFrames += handleIncomingFrames;
foreach (var userId in playingUsers)
{
streamingClient.WatchUser(userId);
@ -90,6 +88,9 @@ namespace osu.Game.Screens.Play.HUD
playingUsers.BindTo(multiplayerClient.CurrentMatchPlayingUserIds);
playingUsers.BindCollectionChanged(usersChanged);
// this leaderboard should be guaranteed to be completely loaded before the gameplay starts (is a prerequisite in MultiplayerPlayer).
streamingClient.OnNewFrames += handleIncomingFrames;
}
private void usersChanged(object sender, NotifyCollectionChangedEventArgs e)