mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 22:07:25 +08:00
Add realtime multiplayer screen
This commit is contained in:
parent
1d7d8bd6fc
commit
455a84c73f
@ -242,7 +242,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
{
|
||||
new OsuMenuItem("Create copy", MenuItemType.Standard, () =>
|
||||
{
|
||||
multiplayer?.CreateRoom(Room.CreateCopy());
|
||||
multiplayer?.OpenNewRoom(Room.CreateCopy());
|
||||
})
|
||||
};
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ namespace osu.Game.Screens.Multi
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Action = () => CreateRoom()
|
||||
Action = () => OpenNewRoom()
|
||||
},
|
||||
RoomManager = CreateRoomManager()
|
||||
}
|
||||
@ -264,10 +264,16 @@ namespace osu.Game.Screens.Multi
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new room.
|
||||
/// Creates and opens the newly-created room.
|
||||
/// </summary>
|
||||
/// <param name="room">An optional template to use when creating the room.</param>
|
||||
public void CreateRoom(Room room = null) => loungeSubScreen.Open(room ?? new Room { Name = { Value = $"{api.LocalUser}'s awesome room" } });
|
||||
public void OpenNewRoom(Room room = null) => loungeSubScreen.Open(room ?? CreateNewRoom());
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new room.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="Room"/>.</returns>
|
||||
protected virtual Room CreateNewRoom() => new Room { Name = { Value = $"{api.LocalUser}'s awesome room" } };
|
||||
|
||||
private void beginHandlingTrack()
|
||||
{
|
||||
|
@ -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 osu.Framework.Allocation;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.RealtimeMultiplayer;
|
||||
using osu.Game.Screens.Multi.Components;
|
||||
using osu.Game.Screens.Multi.Lounge;
|
||||
|
||||
namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
||||
{
|
||||
public class RealtimeMultiplayer : Multiplayer
|
||||
{
|
||||
[Resolved]
|
||||
private StatefulMultiplayerClient client { get; set; }
|
||||
|
||||
public override void OnResuming(IScreen last)
|
||||
{
|
||||
base.OnResuming(last);
|
||||
|
||||
if (client.Room != null)
|
||||
client.ChangeState(MultiplayerUserState.Idle);
|
||||
}
|
||||
|
||||
protected override void UpdatePollingRate(bool isIdle)
|
||||
{
|
||||
var timeshiftManager = (RealtimeRoomManager)RoomManager;
|
||||
|
||||
if (!this.IsCurrentScreen())
|
||||
{
|
||||
timeshiftManager.TimeBetweenListingPolls.Value = 0;
|
||||
timeshiftManager.TimeBetweenSelectionPolls.Value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (CurrentSubScreen)
|
||||
{
|
||||
case LoungeSubScreen _:
|
||||
timeshiftManager.TimeBetweenListingPolls.Value = isIdle ? 120000 : 15000;
|
||||
timeshiftManager.TimeBetweenSelectionPolls.Value = isIdle ? 120000 : 15000;
|
||||
break;
|
||||
|
||||
// Don't poll inside the match or anywhere else.
|
||||
default:
|
||||
timeshiftManager.TimeBetweenListingPolls.Value = 0;
|
||||
timeshiftManager.TimeBetweenSelectionPolls.Value = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Log($"Polling adjusted (listing: {timeshiftManager.TimeBetweenListingPolls.Value}, selection: {timeshiftManager.TimeBetweenSelectionPolls.Value})");
|
||||
}
|
||||
|
||||
protected override Room CreateNewRoom()
|
||||
{
|
||||
var room = base.CreateNewRoom();
|
||||
room.Category.Value = RoomCategory.Realtime;
|
||||
return room;
|
||||
}
|
||||
|
||||
protected override RoomManager CreateRoomManager() => new RealtimeRoomManager();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user