1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-18 02:47:19 +08:00

Merge branch 'master' into fix-dho-state-overwrite

This commit is contained in:
Dan Balasescu 2021-08-10 17:40:36 +09:00 committed by GitHub
commit 9cda5235a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 162 additions and 34 deletions

View File

@ -4,7 +4,7 @@
# osu!
[![Build status](https://ci.appveyor.com/api/projects/status/u2p01nx7l6og8buh?svg=true)](https://ci.appveyor.com/project/peppy/osu)
[![Build status](https://github.com/ppy/osu/actions/workflows/ci.yml/badge.svg?branch=master&event=push)](https://github.com/ppy/osu/actions/workflows/ci.yml)
[![GitHub release](https://img.shields.io/github/release/ppy/osu.svg)](https://github.com/ppy/osu/releases/latest)
[![CodeFactor](https://www.codefactor.io/repository/github/ppy/osu/badge)](https://www.codefactor.io/repository/github/ppy/osu)
[![dev chat](https://discordapp.com/api/guilds/188630481301012481/widget.png?style=shield)](https://discord.gg/ppy)

View File

@ -51,8 +51,8 @@
<Reference Include="Java.Interop" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.803.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.805.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.808.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.809.0" />
</ItemGroup>
<ItemGroup Label="Transitive Dependencies">
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->

View File

@ -3,9 +3,9 @@
using System;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Utils;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Skinning.Default;
using osu.Game.Utils;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
Color4 outerColour = AccentColour.Darken(0.1f);
Color4 innerColour = lighten(AccentColour, 0.5f);
return Interpolation.ValueAt(position / realGradientPortion, outerColour, innerColour, 0, 1);
return LegacyUtils.InterpolateNonLinear(position / realGradientPortion, outerColour, innerColour, 0, 1);
}
/// <summary>

View File

@ -24,6 +24,8 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
AddRepeatStep("add some users", () => Client.AddUser(new User { Id = id++ }), 5);
checkPlayingUserCount(0);
AddAssert("playlist item is available", () => Client.CurrentMatchPlayingItem.Value != null);
changeState(3, MultiplayerUserState.WaitingForLoad);
checkPlayingUserCount(3);
@ -41,6 +43,8 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
AddStep("leave room", () => Client.LeaveRoom());
checkPlayingUserCount(0);
AddAssert("playlist item is null", () => Client.CurrentMatchPlayingItem.Value == null);
}
[Test]

View File

@ -12,6 +12,7 @@ using osu.Game.Rulesets.UI;
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
using osu.Game.Screens.Play;
using osu.Game.Tests.Beatmaps.IO;
using osu.Game.Users;
namespace osu.Game.Tests.Visual.Multiplayer
{
@ -47,8 +48,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
AddStep("start players silently", () =>
{
Client.CurrentMatchPlayingUserIds.Add(PLAYER_1_ID);
Client.CurrentMatchPlayingUserIds.Add(PLAYER_2_ID);
OnlinePlayDependencies.Client.AddUser(new User { Id = PLAYER_1_ID }, true);
OnlinePlayDependencies.Client.AddUser(new User { Id = PLAYER_2_ID }, true);
playingUserIds.Add(PLAYER_1_ID);
playingUserIds.Add(PLAYER_2_ID);
});
@ -264,7 +266,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
foreach (int id in userIds)
{
Client.CurrentMatchPlayingUserIds.Add(id);
OnlinePlayDependencies.Client.AddUser(new User { Id = id }, true);
SpectatorClient.StartPlay(id, beatmapId ?? importedBeatmapId);
playingUserIds.Add(id);
}

View File

@ -20,6 +20,7 @@ using osu.Game.Scoring;
using osu.Game.Screens.Play.HUD;
using osu.Game.Tests.Visual.OnlinePlay;
using osu.Game.Tests.Visual.Spectator;
using osu.Game.Users;
namespace osu.Game.Tests.Visual.Multiplayer
{
@ -53,10 +54,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
var playable = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value);
foreach (var user in users)
{
SpectatorClient.StartPlay(user, Beatmap.Value.BeatmapInfo.OnlineBeatmapID ?? 0);
// Todo: This is REALLY bad.
Client.CurrentMatchPlayingUserIds.AddRange(users);
OnlinePlayDependencies.Client.AddUser(new User { Id = user }, true);
}
Children = new Drawable[]
{

View File

@ -288,7 +288,7 @@ namespace osu.Game.Graphics.UserInterface
},
};
AddInternal(new HoverSounds());
AddInternal(new HoverClickSounds());
}
[BackgroundDependencyLoader]

View File

@ -1,6 +1,9 @@
// 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.Audio;
using osu.Framework.Audio.Sample;
using osuTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -13,6 +16,12 @@ namespace osu.Game.Graphics.UserInterface
{
public class OsuMenu : Menu
{
private Sample sampleOpen;
private Sample sampleClose;
// todo: this shouldn't be required after https://github.com/ppy/osu-framework/issues/4519 is fixed.
private bool wasOpened;
public OsuMenu(Direction direction, bool topLevelMenu = false)
: base(direction, topLevelMenu)
{
@ -22,8 +31,30 @@ namespace osu.Game.Graphics.UserInterface
ItemsContainer.Padding = new MarginPadding(5);
}
protected override void AnimateOpen() => this.FadeIn(300, Easing.OutQuint);
protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint);
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleOpen = audio.Samples.Get(@"UI/dropdown-open");
sampleClose = audio.Samples.Get(@"UI/dropdown-close");
}
protected override void AnimateOpen()
{
if (!TopLevelMenu && !wasOpened)
sampleOpen?.Play();
this.FadeIn(300, Easing.OutQuint);
wasOpened = true;
}
protected override void AnimateClose()
{
if (!TopLevelMenu && wasOpened)
sampleClose?.Play();
this.FadeOut(300, Easing.OutQuint);
wasOpened = false;
}
protected override void UpdateSize(Vector2 newSize)
{

View File

@ -62,7 +62,9 @@ namespace osu.Game.Online.Multiplayer
/// <summary>
/// The users in the joined <see cref="Room"/> which are participating in the current gameplay loop.
/// </summary>
public readonly BindableList<int> CurrentMatchPlayingUserIds = new BindableList<int>();
public IBindableList<int> CurrentMatchPlayingUserIds => PlayingUserIds;
protected readonly BindableList<int> PlayingUserIds = new BindableList<int>();
public readonly Bindable<PlaylistItem?> CurrentMatchPlayingItem = new Bindable<PlaylistItem?>();
@ -179,7 +181,8 @@ namespace osu.Game.Online.Multiplayer
{
APIRoom = null;
Room = null;
CurrentMatchPlayingUserIds.Clear();
CurrentMatchPlayingItem.Value = null;
PlayingUserIds.Clear();
RoomUpdated?.Invoke();
});
@ -376,7 +379,7 @@ namespace osu.Game.Online.Multiplayer
return;
Room.Users.Remove(user);
CurrentMatchPlayingUserIds.Remove(user.UserID);
PlayingUserIds.Remove(user.UserID);
RoomUpdated?.Invoke();
}, false);
@ -659,16 +662,16 @@ namespace osu.Game.Online.Multiplayer
/// <param name="state">The new state of the user.</param>
private void updateUserPlayingState(int userId, MultiplayerUserState state)
{
bool wasPlaying = CurrentMatchPlayingUserIds.Contains(userId);
bool wasPlaying = PlayingUserIds.Contains(userId);
bool isPlaying = state >= MultiplayerUserState.WaitingForLoad && state <= MultiplayerUserState.FinishedPlay;
if (isPlaying == wasPlaying)
return;
if (isPlaying)
CurrentMatchPlayingUserIds.Add(userId);
PlayingUserIds.Add(userId);
else
CurrentMatchPlayingUserIds.Remove(userId);
PlayingUserIds.Remove(userId);
}
private Task scheduleAsync(Action action, CancellationToken cancellationToken = default)

View File

@ -79,8 +79,6 @@ namespace osu.Game.Overlays.News.Sidebar
private readonly SpriteIcon icon;
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();
public DropdownHeader(int month, int year)
{
var date = new DateTime(year, month, 1);

View File

@ -5,6 +5,8 @@ using System;
using System.Collections.Generic;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions;
@ -44,6 +46,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
public event Action<SelectionState> StateChanged;
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();
private readonly Box selectionBox;
[Resolved(canBeNull: true)]
@ -62,6 +66,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
private SelectionState state;
private Sample sampleSelect;
private Sample sampleJoin;
public SelectionState State
{
get => state;
@ -125,7 +132,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load(OsuColour colours, AudioManager audio)
{
float stripWidth = side_strip_width * (Room.Category.Value == RoomCategory.Spotlight ? 2 : 1);
@ -221,6 +228,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
},
},
};
sampleSelect = audio.Samples.Get($@"UI/{HoverSampleSet.Default.GetDescription()}-select");
sampleJoin = audio.Samples.Get($@"UI/{HoverSampleSet.Submit.GetDescription()}-select");
}
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
@ -273,22 +283,25 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{
}
protected override bool ShouldBeConsideredForInput(Drawable child) => state == SelectionState.Selected;
protected override bool ShouldBeConsideredForInput(Drawable child) => state == SelectionState.Selected || child is HoverSounds;
protected override bool OnClick(ClickEvent e)
{
if (Room != selectedRoom.Value)
{
sampleSelect?.Play();
selectedRoom.Value = Room;
return true;
}
if (Room.HasPassword.Value)
{
sampleJoin?.Play();
this.ShowPopover();
return true;
}
sampleJoin?.Play();
lounge?.Join(Room, null);
return base.OnClick(e);

View File

@ -96,7 +96,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
base.LoadComplete();
((IBindable<bool>)leaderboard.Expanded).BindTo(IsBreakTime);
((IBindable<bool>)leaderboard.Expanded).BindTo(HUDOverlay.ShowHud);
}
protected override void StartGameplay()

View File

@ -31,7 +31,7 @@ namespace osu.Game.Screens.Play.HUD
private UserLookupCache userLookupCache { get; set; }
private readonly ScoreProcessor scoreProcessor;
private readonly BindableList<int> playingUsers;
private readonly IBindableList<int> playingUsers;
private Bindable<ScoringMode> scoringMode;
/// <summary>

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.Utils;
using osu.Game.Rulesets.Judgements;
using osu.Game.Screens.Play.HUD;
using osu.Game.Utils;
using osuTK;
using osuTK.Graphics;
@ -83,10 +84,10 @@ namespace osu.Game.Skinning
private static Color4 getFillColour(double hp)
{
if (hp < 0.2)
return Interpolation.ValueAt(0.2 - hp, Color4.Black, Color4.Red, 0, 0.2);
return LegacyUtils.InterpolateNonLinear(0.2 - hp, Color4.Black, Color4.Red, 0, 0.2);
if (hp < epic_cutoff)
return Interpolation.ValueAt(0.5 - hp, Color4.White, Color4.Black, 0, 0.5);
return LegacyUtils.InterpolateNonLinear(0.5 - hp, Color4.White, Color4.Black, 0, 0.5);
return Color4.White;
}

View File

@ -50,7 +50,16 @@ namespace osu.Game.Tests.Visual.Multiplayer
public void Disconnect() => isConnected.Value = false;
public void AddUser(User user) => ((IMultiplayerClient)this).UserJoined(new MultiplayerRoomUser(user.Id) { User = user });
public MultiplayerRoomUser AddUser(User user, bool markAsPlaying = false)
{
var roomUser = new MultiplayerRoomUser(user.Id) { User = user };
((IMultiplayerClient)this).UserJoined(roomUser);
if (markAsPlaying)
PlayingUserIds.Add(user.Id);
return roomUser;
}
public void AddNullUser(int userId) => ((IMultiplayerClient)this).UserJoined(new MultiplayerRoomUser(userId));

View File

@ -0,0 +1,65 @@
// 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 osu.Framework.Graphics;
using osu.Framework.Graphics.Transforms;
using osuTK.Graphics;
namespace osu.Game.Utils
{
public static class LegacyUtils
{
public static Color4 InterpolateNonLinear(double time, Color4 startColour, Color4 endColour, double startTime, double endTime, Easing easing = Easing.None)
=> InterpolateNonLinear(time, startColour, endColour, startTime, endTime, new DefaultEasingFunction(easing));
public static Colour4 InterpolateNonLinear(double time, Colour4 startColour, Colour4 endColour, double startTime, double endTime, Easing easing = Easing.None)
=> InterpolateNonLinear(time, startColour, endColour, startTime, endTime, new DefaultEasingFunction(easing));
/// <summary>
/// Interpolates between two sRGB <see cref="Color4"/>s directly in sRGB space.
/// </summary>
public static Color4 InterpolateNonLinear<TEasing>(double time, Color4 startColour, Color4 endColour, double startTime, double endTime, TEasing easing) where TEasing : IEasingFunction
{
if (startColour == endColour)
return startColour;
double current = time - startTime;
double duration = endTime - startTime;
if (duration == 0 || current == 0)
return startColour;
float t = Math.Max(0, Math.Min(1, (float)easing.ApplyEasing(current / duration)));
return new Color4(
startColour.R + t * (endColour.R - startColour.R),
startColour.G + t * (endColour.G - startColour.G),
startColour.B + t * (endColour.B - startColour.B),
startColour.A + t * (endColour.A - startColour.A));
}
/// <summary>
/// Interpolates between two sRGB <see cref="Colour4"/>s directly in sRGB space.
/// </summary>
public static Colour4 InterpolateNonLinear<TEasing>(double time, Colour4 startColour, Colour4 endColour, double startTime, double endTime, TEasing easing) where TEasing : IEasingFunction
{
if (startColour == endColour)
return startColour;
double current = time - startTime;
double duration = endTime - startTime;
if (duration == 0 || current == 0)
return startColour;
float t = Math.Max(0, Math.Min(1, (float)easing.ApplyEasing(current / duration)));
return new Colour4(
startColour.R + t * (endColour.R - startColour.R),
startColour.G + t * (endColour.G - startColour.G),
startColour.B + t * (endColour.B - startColour.B),
startColour.A + t * (endColour.A - startColour.A));
}
}
}

View File

@ -36,8 +36,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Realm" Version="10.3.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.805.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.803.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.809.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.808.0" />
<PackageReference Include="Sentry" Version="3.8.3" />
<PackageReference Include="SharpCompress" Version="0.28.3" />
<PackageReference Include="NUnit" Version="3.13.2" />

View File

@ -70,8 +70,8 @@
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.805.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.803.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.809.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.808.0" />
</ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
<PropertyGroup>
@ -93,7 +93,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="13.0.1" />
<PackageReference Include="ppy.osu.Framework" Version="2021.805.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.809.0" />
<PackageReference Include="SharpCompress" Version="0.28.3" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="SharpRaven" Version="2.4.0" />