mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 14:12:56 +08:00
Merge remote-tracking branch 'smoogipoo/timeshift-wip' into timeshift-wip
# Conflicts: # osu.Game.Tests/Visual/TestCaseLoungeRoomsContainer.cs # osu.Game.Tests/Visual/TestCaseMatchSettingsOverlay.cs # osu.Game/Screens/Multi/IRoomManager.cs # osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs # osu.Game/Screens/Multi/Match/Components/MatchSettingsOverlay.cs # osu.Game/Screens/Multi/RoomManager.cs
This commit is contained in:
commit
bf9954aede
@ -71,14 +71,14 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
private class TestRoomManager : IRoomManager
|
private class TestRoomManager : IRoomManager
|
||||||
{
|
{
|
||||||
public event Action<Room> RoomJoined;
|
|
||||||
|
|
||||||
public readonly BindableCollection<Room> Rooms = new BindableCollection<Room>();
|
public readonly BindableCollection<Room> Rooms = new BindableCollection<Room>();
|
||||||
IBindableCollection<Room> IRoomManager.Rooms => Rooms;
|
IBindableCollection<Room> IRoomManager.Rooms => Rooms;
|
||||||
|
|
||||||
public void CreateRoom(Room room, Action<string> onError = null) => Rooms.Add(room);
|
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null) => Rooms.Add(room);
|
||||||
|
|
||||||
public void JoinRoom(Room room) => RoomJoined?.Invoke(room);
|
public void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void PartRoom()
|
public void PartRoom()
|
||||||
{
|
{
|
||||||
|
@ -136,20 +136,20 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
public Func<Room, bool> CreateRequested;
|
public Func<Room, bool> CreateRequested;
|
||||||
|
|
||||||
public event Action<Room> RoomJoined;
|
|
||||||
|
|
||||||
public IBindableCollection<Room> Rooms { get; } = null;
|
public IBindableCollection<Room> Rooms { get; } = null;
|
||||||
|
|
||||||
public void CreateRoom(Room room, Action<string> onError = null)
|
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||||
{
|
{
|
||||||
if (CreateRequested == null)
|
if (CreateRequested == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!CreateRequested.Invoke(room))
|
if (!CreateRequested.Invoke(room))
|
||||||
onError?.Invoke(FAILED_TEXT);
|
onError?.Invoke(FAILED_TEXT);
|
||||||
|
else
|
||||||
|
onSuccess?.Invoke(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void JoinRoom(Room room) => throw new NotImplementedException();
|
public void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null) => throw new NotImplementedException();
|
||||||
|
|
||||||
public void PartRoom() => throw new NotImplementedException();
|
public void PartRoom() => throw new NotImplementedException();
|
||||||
|
|
||||||
|
@ -10,11 +10,6 @@ namespace osu.Game.Screens.Multi
|
|||||||
{
|
{
|
||||||
public interface IRoomManager
|
public interface IRoomManager
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Invoked when a room is joined.
|
|
||||||
/// </summary>
|
|
||||||
event Action<Room> RoomJoined;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All the active <see cref="Room"/>s.
|
/// All the active <see cref="Room"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -24,14 +19,17 @@ namespace osu.Game.Screens.Multi
|
|||||||
/// Creates a new <see cref="Room"/>.
|
/// Creates a new <see cref="Room"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="room">The <see cref="Room"/> to create.</param>
|
/// <param name="room">The <see cref="Room"/> to create.</param>
|
||||||
|
/// <param name="onSuccess">An action to be invoked if the creation succeeds.</param>
|
||||||
/// <param name="onError">An action to be invoked if an error occurred.</param>
|
/// <param name="onError">An action to be invoked if an error occurred.</param>
|
||||||
void CreateRoom(Room room, Action<string> onError = null);
|
void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Joins a <see cref="Room"/>.
|
/// Joins a <see cref="Room"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="room">The <see cref="Room"/> to join. <see cref="Room.RoomID"/> must be populated.</param>
|
/// <param name="room">The <see cref="Room"/> to join. <see cref="Room.RoomID"/> must be populated.</param>
|
||||||
void JoinRoom(Room room);
|
/// <param name="onSuccess"></param>
|
||||||
|
/// <param name="onError"></param>
|
||||||
|
void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parts the currently-joined <see cref="Room"/>.
|
/// Parts the currently-joined <see cref="Room"/>.
|
||||||
|
@ -7,6 +7,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Overlays.SearchableList;
|
using osu.Game.Overlays.SearchableList;
|
||||||
using osu.Game.Screens.Multi.Lounge.Components;
|
using osu.Game.Screens.Multi.Lounge.Components;
|
||||||
@ -21,6 +22,7 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
private readonly RoomsContainer rooms;
|
private readonly RoomsContainer rooms;
|
||||||
private readonly Action<Screen> pushGameplayScreen;
|
private readonly Action<Screen> pushGameplayScreen;
|
||||||
|
private readonly ProcessingOverlay processingOverlay;
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private IRoomManager roomManager { get; set; }
|
private IRoomManager roomManager { get; set; }
|
||||||
@ -43,18 +45,26 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new ScrollContainer
|
new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Width = 0.55f,
|
Width = 0.55f,
|
||||||
ScrollbarOverlapsContent = false,
|
Children = new Drawable[]
|
||||||
Padding = new MarginPadding(10),
|
|
||||||
Child = new SearchContainer
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
new ScrollContainer
|
||||||
AutoSizeAxes = Axes.Y,
|
{
|
||||||
Child = rooms = new RoomsContainer { JoinRequested = r => roomManager?.JoinRoom(r) }
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
ScrollbarOverlapsContent = false,
|
||||||
|
Padding = new MarginPadding(10),
|
||||||
|
Child = new SearchContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Child = rooms = new RoomsContainer { JoinRequested = joinRequested }
|
||||||
|
},
|
||||||
|
},
|
||||||
|
processingOverlay = new ProcessingOverlay { Alpha = 0 }
|
||||||
|
}
|
||||||
},
|
},
|
||||||
inspector = new RoomInspector
|
inspector = new RoomInspector
|
||||||
{
|
{
|
||||||
@ -74,13 +84,6 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
Filter.Search.Exit += Exit;
|
Filter.Search.Exit += Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
if (roomManager != null)
|
|
||||||
roomManager.RoomJoined += Push;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
{
|
{
|
||||||
base.UpdateAfterChildren();
|
base.UpdateAfterChildren();
|
||||||
@ -123,6 +126,16 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
roomManager?.Filter(Filter.CreateCriteria());
|
roomManager?.Filter(Filter.CreateCriteria());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void joinRequested(Room room)
|
||||||
|
{
|
||||||
|
processingOverlay.Show();
|
||||||
|
roomManager?.JoinRoom(room, r =>
|
||||||
|
{
|
||||||
|
Push(room);
|
||||||
|
processingOverlay.Hide();
|
||||||
|
}, _ => processingOverlay.Hide());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Push a room as a new subscreen.
|
/// Push a room as a new subscreen.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -134,13 +147,5 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
|
|
||||||
Push(new MatchSubScreen(room, s => pushGameplayScreen?.Invoke(s)));
|
Push(new MatchSubScreen(room, s => pushGameplayScreen?.Invoke(s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
|
||||||
{
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
|
|
||||||
if (roomManager != null)
|
|
||||||
roomManager.RoomJoined -= Push;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
|
|
||||||
protected readonly OsuSpriteText ErrorText;
|
protected readonly OsuSpriteText ErrorText;
|
||||||
|
|
||||||
|
private readonly ProcessingOverlay processingOverlay;
|
||||||
|
|
||||||
private readonly Room room;
|
private readonly Room room;
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
@ -231,7 +233,8 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
processingOverlay = new ProcessingOverlay { Alpha = 0 }
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -264,7 +267,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
ApplyButton.Enabled.Value = hasValidSettings;
|
ApplyButton.Enabled.Value = hasValidSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool hasValidSettings => NameField.Text.Length > 0 && bindings.Playlist.Count > 0;
|
private bool hasValidSettings => bindings.Room.RoomID.Value == null && NameField.Text.Length > 0 && bindings.Playlist.Count > 0;
|
||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
@ -291,15 +294,22 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
|
|
||||||
bindings.Duration.Value = DurationField.Current.Value;
|
bindings.Duration.Value = DurationField.Current.Value;
|
||||||
|
|
||||||
manager?.CreateRoom(room, showError);
|
|
||||||
|
manager?.CreateRoom(room, onSuccess, onError);
|
||||||
|
|
||||||
|
processingOverlay.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideError() => ErrorText.FadeOut(50);
|
private void hideError() => ErrorText.FadeOut(50);
|
||||||
|
|
||||||
private void showError(string text)
|
private void onSuccess(Room room) => processingOverlay.Hide();
|
||||||
|
|
||||||
|
private void onError(string text)
|
||||||
{
|
{
|
||||||
ErrorText.Text = text;
|
ErrorText.Text = text;
|
||||||
ErrorText.FadeIn(50);
|
ErrorText.FadeIn(50);
|
||||||
|
|
||||||
|
processingOverlay.Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SettingsTextBox : OsuTextBox
|
private class SettingsTextBox : OsuTextBox
|
||||||
|
@ -19,8 +19,6 @@ namespace osu.Game.Screens.Multi
|
|||||||
{
|
{
|
||||||
public class RoomManager : PollingComponent, IRoomManager
|
public class RoomManager : PollingComponent, IRoomManager
|
||||||
{
|
{
|
||||||
public event Action<Room> RoomJoined;
|
|
||||||
|
|
||||||
private readonly BindableCollection<Room> rooms = new BindableCollection<Room>();
|
private readonly BindableCollection<Room> rooms = new BindableCollection<Room>();
|
||||||
public IBindableCollection<Room> Rooms => rooms;
|
public IBindableCollection<Room> Rooms => rooms;
|
||||||
|
|
||||||
@ -42,21 +40,25 @@ namespace osu.Game.Screens.Multi
|
|||||||
TimeBetweenPolls = 5000;
|
TimeBetweenPolls = 5000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
PartRoom();
|
PartRoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateRoom(Room room, Action<string> onError = null)
|
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||||
{
|
{
|
||||||
room.Host.Value = api.LocalUser;
|
room.Host.Value = api.LocalUser;
|
||||||
|
|
||||||
var req = new CreateRoomRequest(room);
|
var req = new CreateRoomRequest(room);
|
||||||
|
|
||||||
req.Success += result =>
|
req.Success += result =>
|
||||||
{
|
{
|
||||||
update(room, result);
|
update(room, result);
|
||||||
addRoom(room);
|
addRoom(room);
|
||||||
|
|
||||||
|
onSuccess?.Invoke(room);
|
||||||
};
|
};
|
||||||
|
|
||||||
req.Failure += exception =>
|
req.Failure += exception =>
|
||||||
@ -72,7 +74,7 @@ namespace osu.Game.Screens.Multi
|
|||||||
|
|
||||||
private JoinRoomRequest currentJoinRoomRequest;
|
private JoinRoomRequest currentJoinRoomRequest;
|
||||||
|
|
||||||
public void JoinRoom(Room room)
|
public void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||||
{
|
{
|
||||||
currentJoinRoomRequest?.Cancel();
|
currentJoinRoomRequest?.Cancel();
|
||||||
currentJoinRoomRequest = null;
|
currentJoinRoomRequest = null;
|
||||||
@ -81,10 +83,14 @@ namespace osu.Game.Screens.Multi
|
|||||||
currentJoinRoomRequest.Success += () =>
|
currentJoinRoomRequest.Success += () =>
|
||||||
{
|
{
|
||||||
currentRoom = room;
|
currentRoom = room;
|
||||||
RoomJoined?.Invoke(room);
|
onSuccess?.Invoke(room);
|
||||||
};
|
};
|
||||||
|
|
||||||
currentJoinRoomRequest.Failure += exception => Logger.Log($"Failed to join room: {exception}", level: LogLevel.Important);
|
currentJoinRoomRequest.Failure += exception =>
|
||||||
|
{
|
||||||
|
Logger.Log($"Failed to join room: {exception}", level: LogLevel.Important);
|
||||||
|
onError?.Invoke(exception.ToString());
|
||||||
|
};
|
||||||
|
|
||||||
api.Queue(currentJoinRoomRequest);
|
api.Queue(currentJoinRoomRequest);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user