1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 02:27:25 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Multiplayer/Multiplayer.cs

73 lines
2.6 KiB
C#
Raw Normal View History

2020-12-20 22:32:57 +08:00
// 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.Graphics.UserInterface;
2020-12-20 22:32:57 +08:00
using osu.Game.Online.Multiplayer;
2020-12-25 12:38:11 +08:00
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Components;
using osu.Game.Screens.OnlinePlay.Lounge;
2020-12-20 22:32:57 +08:00
namespace osu.Game.Screens.OnlinePlay.Multiplayer
2020-12-20 22:32:57 +08:00
{
public class Multiplayer : OnlinePlayScreen
2020-12-20 22:32:57 +08:00
{
[Resolved]
private StatefulMultiplayerClient client { get; set; }
public override void OnResuming(IScreen last)
{
base.OnResuming(last);
if (client.Room != null)
client.ChangeState(MultiplayerUserState.Idle);
2020-12-20 22:32:57 +08:00
}
protected override void UpdatePollingRate(bool isIdle)
{
2020-12-25 22:36:09 +08:00
var multiplayerRoomManager = (MultiplayerRoomManager)RoomManager;
2020-12-20 22:32:57 +08:00
if (!this.IsCurrentScreen())
{
2020-12-25 22:36:09 +08:00
multiplayerRoomManager.TimeBetweenListingPolls.Value = 0;
multiplayerRoomManager.TimeBetweenSelectionPolls.Value = 0;
2020-12-20 22:32:57 +08:00
}
else
{
switch (CurrentSubScreen)
{
case LoungeSubScreen _:
2020-12-25 22:36:09 +08:00
multiplayerRoomManager.TimeBetweenListingPolls.Value = isIdle ? 120000 : 15000;
multiplayerRoomManager.TimeBetweenSelectionPolls.Value = isIdle ? 120000 : 15000;
2020-12-20 22:32:57 +08:00
break;
// Don't poll inside the match or anywhere else.
default:
2020-12-25 22:36:09 +08:00
multiplayerRoomManager.TimeBetweenListingPolls.Value = 0;
multiplayerRoomManager.TimeBetweenSelectionPolls.Value = 0;
2020-12-20 22:32:57 +08:00
break;
}
}
Logger.Log($"Polling adjusted (listing: {multiplayerRoomManager.TimeBetweenListingPolls.Value}, selection: {multiplayerRoomManager.TimeBetweenSelectionPolls.Value})");
2020-12-20 22:32:57 +08:00
}
protected override Room CreateNewRoom()
{
var room = new Room { Name = { Value = $"{API.LocalUser}'s awesome room" } };
2020-12-25 22:36:09 +08:00
room.Category.Value = RoomCategory.Realtime;
2020-12-20 22:32:57 +08:00
return room;
}
protected override string ScreenTitle => "Multiplayer";
2020-12-25 12:38:11 +08:00
protected override RoomManager CreateRoomManager() => new MultiplayerRoomManager();
2020-12-20 22:36:56 +08:00
2020-12-25 12:38:11 +08:00
protected override LoungeSubScreen CreateLounge() => new MultiplayerLoungeSubScreen();
2020-12-25 12:38:11 +08:00
protected override OsuButton CreateNewMultiplayerGameButton() => new CreateMultiplayerMatchButton();
2020-12-20 22:32:57 +08:00
}
}