1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 20:47:26 +08:00

Merge pull request #1 from ppy/master

Merging new changes from ppy/osu
This commit is contained in:
Jesse Myers 2021-01-15 21:07:12 -05:00 committed by GitHub
commit 12bc9ce196
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 185 additions and 34 deletions

View File

@ -1,9 +1,11 @@
// 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.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Mods;
@ -34,7 +36,7 @@ namespace osu.Game.Rulesets.Osu.Tests
[TestCase(true)]
public void TestLongSpinner(bool autoplay)
{
AddStep("Very short spinner", () => SetContents(() => testSingle(5, autoplay, 2000)));
AddStep("Very long spinner", () => SetContents(() => testSingle(5, autoplay, 4000)));
AddUntilStep("Wait for completion", () => drawableSpinner.Result.HasResult);
AddUntilStep("Check correct progress", () => drawableSpinner.Progress == (autoplay ? 1 : 0));
}
@ -55,7 +57,11 @@ namespace osu.Game.Rulesets.Osu.Tests
var spinner = new Spinner
{
StartTime = Time.Current + delay,
EndTime = Time.Current + delay + length
EndTime = Time.Current + delay + length,
Samples = new List<HitSampleInfo>
{
new HitSampleInfo("hitnormal")
}
};
spinner.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = circleSize });

View File

@ -104,7 +104,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
if (Attributes.ApproachRate > 10.33)
approachRateFactor += 0.4 * (Attributes.ApproachRate - 10.33);
else if (Attributes.ApproachRate < 8.0)
approachRateFactor += 0.1 * (8.0 - Attributes.ApproachRate);
approachRateFactor += 0.01 * (8.0 - Attributes.ApproachRate);
aimValue *= 1.0 + Math.Min(approachRateFactor, approachRateFactor * (totalHits / 1000.0));

View File

@ -143,6 +143,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
RoomManager =
{
TimeBetweenListingPolls = { Value = 1 },
TimeBetweenSelectionPolls = { Value = 1 }
}
};

View File

@ -260,17 +260,10 @@ namespace osu.Game.Beatmaps
}
catch (BeatmapInvalidForRulesetException e)
{
// Conversion has failed for the given ruleset, so return the difficulty in the beatmap's default ruleset.
// Ensure the beatmap's default ruleset isn't the one already being converted to.
// This shouldn't happen as it means something went seriously wrong, but if it does an endless loop should be avoided.
if (rulesetInfo.Equals(beatmapInfo.Ruleset))
{
Logger.Error(e, $"Failed to convert {beatmapInfo.OnlineBeatmapID} to the beatmap's default ruleset ({beatmapInfo.Ruleset}).");
return new StarDifficulty();
}
return GetAsync(new DifficultyCacheLookup(key.Beatmap, key.Beatmap.Ruleset, key.OrderedMods)).Result;
return new StarDifficulty();
}
catch
{

View File

@ -73,7 +73,7 @@ namespace osu.Game.Graphics.UserInterface
TooltipText = "Downloading...";
break;
case DownloadState.Downloaded:
case DownloadState.Importing:
background.FadeColour(colours.Yellow, 500, Easing.InOutExpo);
TooltipText = "Importing";
break;

View File

@ -7,7 +7,7 @@ namespace osu.Game.Online
{
NotDownloaded,
Downloading,
Downloaded,
Importing,
LocallyAvailable
}
}

View File

@ -106,7 +106,7 @@ namespace osu.Game.Online
{
if (attachedRequest.Progress == 1)
{
State.Value = DownloadState.Downloaded;
State.Value = DownloadState.Importing;
Progress.Value = 1;
}
else
@ -125,7 +125,7 @@ namespace osu.Game.Online
}
}
private void onRequestSuccess(string _) => Schedule(() => State.Value = DownloadState.Downloaded);
private void onRequestSuccess(string _) => Schedule(() => State.Value = DownloadState.Importing);
private void onRequestProgress(float progress) => Schedule(() => Progress.Value = progress);

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Threading.Tasks;
using osu.Game.Online.Rooms;
namespace osu.Game.Online.Multiplayer
{
@ -47,6 +48,13 @@ namespace osu.Game.Online.Multiplayer
/// <param name="state">The new state of the user.</param>
Task UserStateChanged(int userId, MultiplayerUserState state);
/// <summary>
/// Signals that a user in this room changed their beatmap availability state.
/// </summary>
/// <param name="userId">The ID of the user whose beatmap availability state has changed.</param>
/// <param name="beatmapAvailability">The new beatmap availability state of the user.</param>
Task UserBeatmapAvailabilityChanged(int userId, BeatmapAvailability beatmapAvailability);
/// <summary>
/// Signals that a match is to be started. This will *only* be sent to clients which are to begin loading at this point.
/// </summary>

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Threading.Tasks;
using osu.Game.Online.Rooms;
namespace osu.Game.Online.Multiplayer
{
@ -40,6 +41,12 @@ namespace osu.Game.Online.Multiplayer
/// <exception cref="NotJoinedRoomException">If the user is not in a room.</exception>
Task ChangeState(MultiplayerUserState newState);
/// <summary>
/// Change the local user's availability state of the current beatmap set in joined room.
/// </summary>
/// <param name="newBeatmapAvailability">The proposed new beatmap availability state.</param>
Task ChangeBeatmapAvailability(BeatmapAvailability newBeatmapAvailability);
/// <summary>
/// As the host of a room, start the match.
/// </summary>

View File

@ -14,6 +14,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Logging;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
namespace osu.Game.Online.Multiplayer
{
@ -173,6 +174,14 @@ namespace osu.Game.Online.Multiplayer
return connection.InvokeAsync(nameof(IMultiplayerServer.ChangeState), newState);
}
public override Task ChangeBeatmapAvailability(BeatmapAvailability newBeatmapAvailability)
{
if (!isConnected.Value)
return Task.CompletedTask;
return connection.InvokeAsync(nameof(IMultiplayerServer.ChangeBeatmapAvailability), newBeatmapAvailability);
}
public override Task StartMatch()
{
if (!isConnected.Value)

View File

@ -5,6 +5,7 @@
using System;
using Newtonsoft.Json;
using osu.Game.Online.Rooms;
using osu.Game.Users;
namespace osu.Game.Online.Multiplayer
@ -16,6 +17,11 @@ namespace osu.Game.Online.Multiplayer
public MultiplayerUserState State { get; set; } = MultiplayerUserState.Idle;
/// <summary>
/// The availability state of the current beatmap.
/// </summary>
public BeatmapAvailability BeatmapAvailability { get; set; } = BeatmapAvailability.LocallyAvailable();
public User? User { get; set; }
[JsonConstructor]

View File

@ -52,6 +52,7 @@ namespace osu.Game.Online.Multiplayer
/// <summary>
/// Whether the <see cref="StatefulMultiplayerClient"/> is currently connected.
/// This is NOT thread safe and usage should be scheduled.
/// </summary>
public abstract IBindable<bool> IsConnected { get; }
@ -227,6 +228,8 @@ namespace osu.Game.Online.Multiplayer
public abstract Task ChangeState(MultiplayerUserState newState);
public abstract Task ChangeBeatmapAvailability(BeatmapAvailability newBeatmapAvailability);
public abstract Task StartMatch();
Task IMultiplayerClient.RoomStateChanged(MultiplayerRoomState state)
@ -354,6 +357,27 @@ namespace osu.Game.Online.Multiplayer
return Task.CompletedTask;
}
Task IMultiplayerClient.UserBeatmapAvailabilityChanged(int userId, BeatmapAvailability beatmapAvailability)
{
if (Room == null)
return Task.CompletedTask;
Scheduler.Add(() =>
{
var user = Room?.Users.SingleOrDefault(u => u.UserID == userId);
// errors here are not critical - beatmap availability state is mostly for display.
if (user == null)
return;
user.BeatmapAvailability = beatmapAvailability;
RoomUpdated?.Invoke();
}, false);
return Task.CompletedTask;
}
Task IMultiplayerClient.LoadRequested()
{
if (Room == null)

View File

@ -0,0 +1,40 @@
// 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 Newtonsoft.Json;
namespace osu.Game.Online.Rooms
{
/// <summary>
/// The local availability information about a certain beatmap for the client.
/// </summary>
public class BeatmapAvailability : IEquatable<BeatmapAvailability>
{
/// <summary>
/// The beatmap's availability state.
/// </summary>
public readonly DownloadState State;
/// <summary>
/// The beatmap's downloading progress, null when not in <see cref="DownloadState.Downloading"/> state.
/// </summary>
public readonly double? DownloadProgress;
[JsonConstructor]
private BeatmapAvailability(DownloadState state, double? downloadProgress = null)
{
State = state;
DownloadProgress = downloadProgress;
}
public static BeatmapAvailability NotDownloaded() => new BeatmapAvailability(DownloadState.NotDownloaded);
public static BeatmapAvailability Downloading(double progress) => new BeatmapAvailability(DownloadState.Downloading, progress);
public static BeatmapAvailability Importing() => new BeatmapAvailability(DownloadState.Importing);
public static BeatmapAvailability LocallyAvailable() => new BeatmapAvailability(DownloadState.LocallyAvailable);
public bool Equals(BeatmapAvailability other) => other != null && State == other.State && DownloadProgress == other.DownloadProgress;
public override string ToString() => $"{string.Join(", ", State, $"{DownloadProgress:0.00%}")}";
}
}

View File

@ -57,7 +57,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
switch (State.Value)
{
case DownloadState.Downloading:
case DownloadState.Downloaded:
case DownloadState.Importing:
shakeContainer.Shake();
break;

View File

@ -50,7 +50,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
progressBar.ResizeHeightTo(4, 400, Easing.OutQuint);
break;
case DownloadState.Downloaded:
case DownloadState.Importing:
progressBar.FadeIn(400, Easing.OutQuint);
progressBar.ResizeHeightTo(4, 400, Easing.OutQuint);

View File

@ -126,7 +126,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
};
break;
case DownloadState.Downloaded:
case DownloadState.Importing:
textSprites.Children = new Drawable[]
{
new OsuSpriteText

View File

@ -287,7 +287,7 @@ namespace osu.Game.Overlays.BeatmapSet
break;
case DownloadState.Downloading:
case DownloadState.Downloaded:
case DownloadState.Importing:
// temporary to avoid showing two buttons for maps with novideo. will be fixed in new beatmap overlay design.
downloadButtonsContainer.Child = new HeaderDownloadButton(BeatmapSet.Value);
break;

View File

@ -37,6 +37,8 @@ namespace osu.Game.Rulesets.Judgements
{
JudgementText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = Result.GetDescription().ToUpperInvariant(),
Colour = colours.ForHitResult(Result),
Font = OsuFont.Numeric.With(size: 20),

View File

@ -138,6 +138,15 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
scrollToTrackTime();
}
protected override bool OnScroll(ScrollEvent e)
{
// if this is not a precision scroll event, let the editor handle the seek itself (for snapping support)
if (!e.AltPressed && !e.IsPrecise)
return false;
return base.OnScroll(e);
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -47,9 +48,11 @@ namespace osu.Game.Screens.OnlinePlay.Components
pollReq.Success += result =>
{
var rooms = new List<Room>(roomManager.Rooms);
// existing rooms need to be ordered by their position because the received of NotifyRoomsReceives expects to be able to sort them based on this order.
var rooms = new List<Room>(roomManager.Rooms.OrderBy(r => r.Position.Value));
int index = rooms.FindIndex(r => r.RoomID.Value == result.RoomID.Value);
if (index < 0)
return;

View File

@ -34,8 +34,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
base.LoadComplete();
isConnected.BindValueChanged(_ => updateState());
operationInProgress.BindValueChanged(_ => updateState(), true);
isConnected.BindValueChanged(_ => Scheduler.AddOnce(updateState));
operationInProgress.BindValueChanged(_ => Scheduler.AddOnce(updateState), true);
}
private void updateState() => Enabled.Value = isConnected.Value && !operationInProgress.Value;

View File

@ -33,6 +33,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
if (!this.IsCurrentScreen())
{
multiplayerRoomManager.TimeBetweenListingPolls.Value = 0;
multiplayerRoomManager.TimeBetweenSelectionPolls.Value = 0;
}
else
{
@ -40,16 +41,18 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
case LoungeSubScreen _:
multiplayerRoomManager.TimeBetweenListingPolls.Value = isIdle ? 120000 : 15000;
multiplayerRoomManager.TimeBetweenSelectionPolls.Value = isIdle ? 120000 : 15000;
break;
// Don't poll inside the match or anywhere else.
default:
multiplayerRoomManager.TimeBetweenListingPolls.Value = 0;
multiplayerRoomManager.TimeBetweenSelectionPolls.Value = 0;
break;
}
}
Logger.Log($"Polling adjusted (listing: {multiplayerRoomManager.TimeBetweenListingPolls.Value})");
Logger.Log($"Polling adjusted (listing: {multiplayerRoomManager.TimeBetweenListingPolls.Value}, selection: {multiplayerRoomManager.TimeBetweenSelectionPolls.Value})");
}
protected override Room CreateNewRoom()

View File

@ -77,14 +77,14 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
});
isConnected = client.IsConnected.GetBoundCopy();
isConnected.BindValueChanged(connected =>
isConnected.BindValueChanged(connected => Schedule(() =>
{
if (!connected.NewValue)
{
// messaging to the user about this disconnect will be provided by the MultiplayerMatchSubScreen.
failAndBail();
}
}, true);
}), true);
Debug.Assert(client.Room != null);
}

View File

@ -23,7 +23,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
private StatefulMultiplayerClient multiplayerClient { get; set; }
public readonly Bindable<double> TimeBetweenListingPolls = new Bindable<double>();
public readonly Bindable<double> TimeBetweenSelectionPolls = new Bindable<double>();
private readonly IBindable<bool> isConnected = new Bindable<bool>();
private readonly Bindable<bool> allowPolling = new Bindable<bool>();
@ -34,10 +34,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
base.LoadComplete();
isConnected.BindTo(multiplayerClient.IsConnected);
isConnected.BindValueChanged(_ => Schedule(updatePolling));
JoinedRoom.BindValueChanged(_ => updatePolling());
updatePolling();
isConnected.BindValueChanged(_ => Scheduler.AddOnce(updatePolling));
JoinedRoom.BindValueChanged(_ => Scheduler.AddOnce(updatePolling), true);
}
public override void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
@ -119,6 +117,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
TimeBetweenPolls = { BindTarget = TimeBetweenListingPolls },
AllowPolling = { BindTarget = allowPolling }
},
new MultiplayerSelectionPollingComponent
{
TimeBetweenPolls = { BindTarget = TimeBetweenSelectionPolls },
AllowPolling = { BindTarget = allowPolling }
}
};
private class MultiplayerListingPollingComponent : ListingPollingComponent
@ -141,5 +144,26 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
protected override Task Poll() => !AllowPolling.Value ? Task.CompletedTask : base.Poll();
}
private class MultiplayerSelectionPollingComponent : SelectionPollingComponent
{
public readonly IBindable<bool> AllowPolling = new Bindable<bool>();
protected override void LoadComplete()
{
base.LoadComplete();
AllowPolling.BindValueChanged(allowPolling =>
{
if (!allowPolling.NewValue)
return;
if (IsLoaded)
PollImmediately();
});
}
protected override Task Poll() => !AllowPolling.Value ? Task.CompletedTask : base.Poll();
}
}
}

View File

@ -63,7 +63,7 @@ namespace osu.Game.Screens.Ranking
scores.Download(Model.Value);
break;
case DownloadState.Downloaded:
case DownloadState.Importing:
case DownloadState.Downloading:
shakeContainer.Shake();
break;

View File

@ -500,7 +500,7 @@ namespace osu.Game.Screens.Select
if (beatmap != null)
{
if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID)
if (beatmap.BeatmapSetInfoID == previous?.BeatmapInfo.BeatmapSetInfoID)
sampleChangeDifficulty.Play();
else
sampleChangeBeatmap.Play();

View File

@ -378,8 +378,10 @@ namespace osu.Game.Skinning
// kind of wasteful that we throw this away, but should do for now.
if (createDrawable() != null)
{
if (Configuration.LegacyVersion > 1)
return new LegacyJudgementPieceNew(resultComponent.Component, createDrawable, getParticleTexture(resultComponent.Component));
var particle = getParticleTexture(resultComponent.Component);
if (particle != null)
return new LegacyJudgementPieceNew(resultComponent.Component, createDrawable, particle);
else
return new LegacyJudgementPieceOld(resultComponent.Component, createDrawable);
}

View File

@ -10,6 +10,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Online.API;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
using osu.Game.Users;
namespace osu.Game.Tests.Visual.Multiplayer
@ -77,6 +78,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
});
}
public void ChangeUserBeatmapAvailability(int userId, BeatmapAvailability newBeatmapAvailability)
{
Debug.Assert(Room != null);
((IMultiplayerClient)this).UserBeatmapAvailabilityChanged(userId, newBeatmapAvailability);
}
protected override Task<MultiplayerRoom> JoinRoom(long roomId)
{
var user = new MultiplayerRoomUser(api.LocalUser.Value.Id) { User = api.LocalUser.Value };
@ -108,6 +116,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
return Task.CompletedTask;
}
public override Task ChangeBeatmapAvailability(BeatmapAvailability newBeatmapAvailability)
{
ChangeUserBeatmapAvailability(api.LocalUser.Value.Id, newBeatmapAvailability);
return Task.CompletedTask;
}
public override Task StartMatch()
{
Debug.Assert(Room != null);