mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 14:12:54 +08:00
Don't allow creating or joining a room when not connected to server
This commit is contained in:
parent
12df3056e6
commit
a1d42dc4a0
@ -184,7 +184,7 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Push a room as a new subscreen.
|
/// Push a room as a new subscreen.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Open(Room room)
|
public virtual void Open(Room room)
|
||||||
{
|
{
|
||||||
// Handles the case where a room is clicked 3 times in quick succession
|
// Handles the case where a room is clicked 3 times in quick succession
|
||||||
if (!this.IsCurrentScreen())
|
if (!this.IsCurrentScreen())
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Online.RealtimeMultiplayer;
|
||||||
using osu.Game.Screens.Multi.Lounge;
|
using osu.Game.Screens.Multi.Lounge;
|
||||||
using osu.Game.Screens.Multi.Lounge.Components;
|
using osu.Game.Screens.Multi.Lounge.Components;
|
||||||
using osu.Game.Screens.Multi.Match;
|
using osu.Game.Screens.Multi.Match;
|
||||||
@ -13,5 +16,19 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
protected override FilterControl CreateFilterControl() => new RealtimeFilterControl();
|
protected override FilterControl CreateFilterControl() => new RealtimeFilterControl();
|
||||||
|
|
||||||
protected override RoomSubScreen CreateRoomSubScreen(Room room) => new RealtimeMatchSubScreen(room);
|
protected override RoomSubScreen CreateRoomSubScreen(Room room) => new RealtimeMatchSubScreen(room);
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private StatefulMultiplayerClient client { get; set; }
|
||||||
|
|
||||||
|
public override void Open(Room room)
|
||||||
|
{
|
||||||
|
if (!client.IsConnected.Value)
|
||||||
|
{
|
||||||
|
Logger.Log("Not currently connected to the multiplayer server.", LoggingTarget.Runtime, LogLevel.Important);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.Open(room);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,12 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
|
|
||||||
public override void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
public override void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||||
{
|
{
|
||||||
|
if (!multiplayerClient.IsConnected.Value)
|
||||||
|
{
|
||||||
|
onError?.Invoke("Not currently connected to the multiplayer server.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// this is done here as a pre-check to avoid clicking on already closed rooms in the lounge from triggering a server join.
|
// this is done here as a pre-check to avoid clicking on already closed rooms in the lounge from triggering a server join.
|
||||||
// should probably be done at a higher level, but due to the current structure of things this is the easiest place for now.
|
// should probably be done at a higher level, but due to the current structure of things this is the easiest place for now.
|
||||||
if (room.Status.Value is RoomStatusEnded)
|
if (room.Status.Value is RoomStatusEnded)
|
||||||
|
Loading…
Reference in New Issue
Block a user