1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 03:22:54 +08:00

Merge pull request #14284 from LeNitrous/activity-on-multiplayer-screens

Update Discord user status for multiplayer/playlists
This commit is contained in:
Dan Balasescu 2021-08-25 11:22:26 +09:00 committed by GitHub
commit 6fcbf81995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 85 additions and 34 deletions

View File

@ -139,8 +139,8 @@ namespace osu.Desktop
{
switch (activity)
{
case UserActivity.SoloGame solo:
return solo.Beatmap.ToString();
case UserActivity.InGame game:
return game.Beatmap.ToString();
case UserActivity.Editing edit:
return edit.Beatmap.ToString();

View File

@ -15,6 +15,7 @@ using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Online.Rooms;
using osu.Game.Overlays.Mods;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Catch;
@ -89,7 +90,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
SelectedMods.SetDefault();
});
AddStep("create song select", () => LoadScreen(songSelect = new TestMultiplayerMatchSongSelect()));
AddStep("create song select", () => LoadScreen(songSelect = new TestMultiplayerMatchSongSelect(SelectedRoom.Value)));
AddUntilStep("wait for present", () => songSelect.IsCurrentScreen());
}
@ -168,6 +169,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
public new Bindable<IReadOnlyList<Mod>> FreeMods => base.FreeMods;
public new BeatmapCarousel Carousel => base.Carousel;
public TestMultiplayerMatchSongSelect(Room room, WorkingBeatmap beatmap = null, RulesetInfo ruleset = null)
: base(room, beatmap, ruleset)
{
}
}
}
}

View File

@ -93,7 +93,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
SelectedMods.Value = Array.Empty<Mod>();
});
AddStep("create song select", () => LoadScreen(songSelect = new TestPlaylistsSongSelect()));
AddStep("create song select", () => LoadScreen(songSelect = new TestPlaylistsSongSelect(SelectedRoom.Value)));
AddUntilStep("wait for present", () => songSelect.IsCurrentScreen());
}
@ -183,6 +183,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
private class TestPlaylistsSongSelect : PlaylistsSongSelect
{
public new MatchBeatmapDetailArea BeatmapDetails => (MatchBeatmapDetailArea)base.BeatmapDetails;
public TestPlaylistsSongSelect(Room room)
: base(room)
{
}
}
}
}

View File

@ -49,7 +49,7 @@ namespace osu.Game.Tests.Visual.Online
[Test]
public void TestPlayActivity()
{
AddStep("Set activity", () => api.Activity.Value = new UserActivity.SoloGame(new BeatmapInfo(), new RulesetInfo()));
AddStep("Set activity", () => api.Activity.Value = new UserActivity.InSoloGame(new BeatmapInfo(), new RulesetInfo()));
AddStep("Run command", () => Add(new NowPlayingCommand()));

View File

@ -130,7 +130,7 @@ namespace osu.Game.Tests.Visual.Online
AddAssert("visit message is not visible", () => !evast.LastVisitMessage.IsPresent);
}
private UserActivity soloGameStatusForRuleset(int rulesetId) => new UserActivity.SoloGame(null, rulesetStore.GetRuleset(rulesetId));
private UserActivity soloGameStatusForRuleset(int rulesetId) => new UserActivity.InSoloGame(null, rulesetStore.GetRuleset(rulesetId));
private class TestUserListPanel : UserListPanel
{

View File

@ -41,9 +41,9 @@ namespace osu.Game.Online.Chat
switch (api.Activity.Value)
{
case UserActivity.SoloGame solo:
case UserActivity.InGame game:
verb = "playing";
beatmap = solo.Beatmap;
beatmap = game.Beatmap;
break;
case UserActivity.Editing edit:

View File

@ -224,9 +224,9 @@ namespace osu.Game.Rulesets
public abstract string ShortName { get; }
/// <summary>
/// The playing verb to be shown in the <see cref="UserActivity.SoloGame.Status"/>.
/// The playing verb to be shown in the <see cref="UserActivity.InGame"/> activities.
/// </summary>
public virtual string PlayingVerb => "Playing solo";
public virtual string PlayingVerb => "Playing";
/// <summary>
/// A list of available variant ids.

View File

@ -52,7 +52,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
Action = () =>
{
if (matchSubScreen.IsCurrentScreen())
matchSubScreen.Push(new MultiplayerMatchSongSelect());
matchSubScreen.Push(new MultiplayerMatchSongSelect(matchSubScreen.Room));
},
Alpha = 0
}

View File

@ -24,9 +24,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
/// <summary>
/// Construct a new instance of multiplayer song select.
/// </summary>
/// <param name="room">The room.</param>
/// <param name="beatmap">An optional initial beatmap selection to perform.</param>
/// <param name="ruleset">An optional initial ruleset selection to perform.</param>
public MultiplayerMatchSongSelect(WorkingBeatmap beatmap = null, RulesetInfo ruleset = null)
public MultiplayerMatchSongSelect(Room room, WorkingBeatmap beatmap = null, RulesetInfo ruleset = null)
: base(room)
{
if (beatmap != null || ruleset != null)
{

View File

@ -412,7 +412,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
return;
}
this.Push(new MultiplayerMatchSongSelect(beatmap, ruleset));
this.Push(new MultiplayerMatchSongSelect(Room, beatmap, ruleset));
}
protected override void Dispose(bool isDisposing)

View File

@ -17,6 +17,7 @@ using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD;
using osu.Game.Screens.Ranking;
using osu.Game.Users;
using osuTK;
namespace osu.Game.Screens.OnlinePlay.Multiplayer
@ -28,6 +29,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
// Disallow fails in multiplayer for now.
protected override bool CheckModsAllowFailure() => false;
protected override UserActivity InitialActivity => new UserActivity.InMultiplayerGame(Beatmap.Value.BeatmapInfo, Ruleset.Value);
[Resolved]
private MultiplayerClient client { get; set; }

View File

@ -17,6 +17,7 @@ using osu.Game.Overlays.Mods;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Select;
using osu.Game.Users;
using osu.Game.Utils;
namespace osu.Game.Screens.OnlinePlay
@ -32,6 +33,8 @@ namespace osu.Game.Screens.OnlinePlay
[Resolved(typeof(Room), nameof(Room.Playlist))]
protected BindableList<PlaylistItem> Playlist { get; private set; }
protected override UserActivity InitialActivity => new UserActivity.InLobby(room);
protected readonly Bindable<IReadOnlyList<Mod>> FreeMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
[CanBeNull]
@ -39,14 +42,17 @@ namespace osu.Game.Screens.OnlinePlay
private IBindable<PlaylistItem> selectedItem { get; set; }
private readonly FreeModSelectOverlay freeModSelectOverlay;
private readonly Room room;
private WorkingBeatmap initialBeatmap;
private RulesetInfo initialRuleset;
private IReadOnlyList<Mod> initialMods;
private bool itemSelected;
protected OnlinePlaySongSelect()
protected OnlinePlaySongSelect(Room room)
{
this.room = room;
Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING };
freeModSelectOverlay = new FreeModSelectOverlay

View File

@ -13,6 +13,7 @@ using osu.Game.Rulesets;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking;
using osu.Game.Users;
namespace osu.Game.Screens.OnlinePlay.Playlists
{
@ -20,6 +21,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
{
public Action Exited;
protected override UserActivity InitialActivity => new UserActivity.InPlaylistGame(Beatmap.Value.BeatmapInfo, Ruleset.Value);
public PlaylistsPlayer(Room room, PlaylistItem playlistItem, PlayerConfiguration configuration = null)
: base(room, playlistItem, configuration)
{

View File

@ -189,7 +189,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
EditPlaylist = () =>
{
if (this.IsCurrentScreen())
this.Push(new PlaylistsSongSelect());
this.Push(new PlaylistsSongSelect(Room));
},
};

View File

@ -16,6 +16,11 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
[Resolved]
private BeatmapManager beatmaps { get; set; }
public PlaylistsSongSelect(Room room)
: base(room)
{
}
protected override BeatmapDetailArea CreateBeatmapDetailArea() => new MatchBeatmapDetailArea
{
CreateNewItem = createNewItem

View File

@ -47,7 +47,7 @@ namespace osu.Game.Screens.Play
public override bool AllowBackButton => false; // handled by HoldForMenuButton
protected override UserActivity InitialActivity => new UserActivity.SoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value);
protected override UserActivity InitialActivity => new UserActivity.InSoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value);
public override float BackgroundParallaxAmount => 0.1f;

View File

@ -25,9 +25,45 @@ namespace osu.Game.Users
public override string Status => "Choosing a beatmap";
}
public class MultiplayerGame : UserActivity
public abstract class InGame : UserActivity
{
public override string Status => "Playing with others";
public BeatmapInfo Beatmap { get; }
public RulesetInfo Ruleset { get; }
protected InGame(BeatmapInfo info, RulesetInfo ruleset)
{
Beatmap = info;
Ruleset = ruleset;
}
public override string Status => Ruleset.CreateInstance().PlayingVerb;
}
public class InMultiplayerGame : InGame
{
public InMultiplayerGame(BeatmapInfo beatmap, RulesetInfo ruleset)
: base(beatmap, ruleset)
{
}
public override string Status => $@"{base.Status} with others";
}
public class InPlaylistGame : InGame
{
public InPlaylistGame(BeatmapInfo beatmap, RulesetInfo ruleset)
: base(beatmap, ruleset)
{
}
}
public class InSoloGame : InGame
{
public InSoloGame(BeatmapInfo info, RulesetInfo ruleset)
: base(info, ruleset)
{
}
}
public class Editing : UserActivity
@ -42,21 +78,6 @@ namespace osu.Game.Users
public override string Status => @"Editing a beatmap";
}
public class SoloGame : UserActivity
{
public BeatmapInfo Beatmap { get; }
public RulesetInfo Ruleset { get; }
public SoloGame(BeatmapInfo info, RulesetInfo ruleset)
{
Beatmap = info;
Ruleset = ruleset;
}
public override string Status => Ruleset.CreateInstance().PlayingVerb;
}
public class Spectating : UserActivity
{
public override string Status => @"Spectating a game";
@ -69,7 +90,7 @@ namespace osu.Game.Users
public class InLobby : UserActivity
{
public override string Status => @"In a multiplayer lobby";
public override string Status => @"In a lobby";
public readonly Room Room;