mirror of
https://github.com/ppy/osu.git
synced 2025-03-12 09:47:18 +08:00
Move current room to multiplayer
This commit is contained in:
parent
7f13e3c5f7
commit
42cd55e0d7
@ -19,11 +19,6 @@ namespace osu.Game.Screens.Multi
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
IBindableList<Room> Rooms { get; }
|
IBindableList<Room> Rooms { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The currently-active <see cref="Room"/>.
|
|
||||||
/// </summary>
|
|
||||||
Bindable<Room> CurrentRoom { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="Room"/>.
|
/// Creates a new <see cref="Room"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -19,13 +19,14 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
|||||||
{
|
{
|
||||||
public Action<Room> JoinRequested;
|
public Action<Room> JoinRequested;
|
||||||
|
|
||||||
private readonly Bindable<Room> currentRoom = new Bindable<Room>();
|
|
||||||
|
|
||||||
private readonly IBindableList<Room> rooms = new BindableList<Room>();
|
private readonly IBindableList<Room> rooms = new BindableList<Room>();
|
||||||
|
|
||||||
private readonly FillFlowContainer<DrawableRoom> roomFlow;
|
private readonly FillFlowContainer<DrawableRoom> roomFlow;
|
||||||
public IReadOnlyList<DrawableRoom> Rooms => roomFlow;
|
public IReadOnlyList<DrawableRoom> Rooms => roomFlow;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private Bindable<Room> currentRoom { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IRoomManager roomManager { get; set; }
|
private IRoomManager roomManager { get; set; }
|
||||||
|
|
||||||
@ -46,7 +47,6 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
currentRoom.BindTo(roomManager.CurrentRoom);
|
|
||||||
rooms.BindTo(roomManager.Rooms);
|
rooms.BindTo(roomManager.Rooms);
|
||||||
|
|
||||||
rooms.ItemsAdded += addRooms;
|
rooms.ItemsAdded += addRooms;
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// 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 System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Configuration;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
@ -26,8 +24,6 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
private readonly Action<Screen> pushGameplayScreen;
|
private readonly Action<Screen> pushGameplayScreen;
|
||||||
private readonly ProcessingOverlay processingOverlay;
|
private readonly ProcessingOverlay processingOverlay;
|
||||||
|
|
||||||
private readonly Bindable<Room> currentRoom = new Bindable<Room>();
|
|
||||||
|
|
||||||
public LoungeSubScreen(Action<Screen> pushGameplayScreen)
|
public LoungeSubScreen(Action<Screen> pushGameplayScreen)
|
||||||
{
|
{
|
||||||
this.pushGameplayScreen = pushGameplayScreen;
|
this.pushGameplayScreen = pushGameplayScreen;
|
||||||
@ -75,12 +71,6 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
Filter.Search.Exit += this.Exit;
|
Filter.Search.Exit += this.Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(IRoomManager roomManager)
|
|
||||||
{
|
|
||||||
currentRoom.BindTo(roomManager.CurrentRoom);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
{
|
{
|
||||||
base.UpdateAfterChildren();
|
base.UpdateAfterChildren();
|
||||||
@ -135,8 +125,6 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
if (!this.IsCurrentScreen())
|
if (!this.IsCurrentScreen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
currentRoom.Value = room;
|
|
||||||
|
|
||||||
this.Push(new MatchSubScreen(room, s => pushGameplayScreen?.Invoke(s)));
|
this.Push(new MatchSubScreen(room, s => pushGameplayScreen?.Invoke(s)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,10 @@ namespace osu.Game.Screens.Multi
|
|||||||
private readonly ScreenStack screenStack;
|
private readonly ScreenStack screenStack;
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private readonly Bindable<FilterCriteria> filter = new Bindable<FilterCriteria>();
|
private readonly Bindable<Room> currentRoom = new Bindable<Room>();
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
private readonly Bindable<FilterCriteria> currentFilter = new Bindable<FilterCriteria>();
|
||||||
|
|
||||||
[Cached(Type = typeof(IRoomManager))]
|
[Cached(Type = typeof(IRoomManager))]
|
||||||
private RoomManager roomManager;
|
private RoomManager roomManager;
|
||||||
@ -150,7 +153,7 @@ namespace osu.Game.Screens.Multi
|
|||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
dependencies = new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent));
|
dependencies = new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent));
|
||||||
dependencies.Model.BindTo(roomManager.CurrentRoom);
|
dependencies.Model.BindTo(currentRoom);
|
||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,12 +24,13 @@ namespace osu.Game.Screens.Multi
|
|||||||
private readonly BindableList<Room> rooms = new BindableList<Room>();
|
private readonly BindableList<Room> rooms = new BindableList<Room>();
|
||||||
public IBindableList<Room> Rooms => rooms;
|
public IBindableList<Room> Rooms => rooms;
|
||||||
|
|
||||||
public Bindable<Room> CurrentRoom { get; } = new Bindable<Room>();
|
|
||||||
|
|
||||||
private Room joinedRoom;
|
private Room joinedRoom;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private Bindable<FilterCriteria> filter { get; set; }
|
private Bindable<Room> currentRoom { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private Bindable<FilterCriteria> currentFilter { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private APIAccess api { get; set; }
|
private APIAccess api { get; set; }
|
||||||
@ -40,9 +41,10 @@ namespace osu.Game.Screens.Multi
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmaps { get; set; }
|
private BeatmapManager beatmaps { get; set; }
|
||||||
|
|
||||||
public RoomManager()
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
{
|
{
|
||||||
filter.BindValueChanged(_ =>
|
currentFilter.BindValueChanged(_ =>
|
||||||
{
|
{
|
||||||
if (IsLoaded)
|
if (IsLoaded)
|
||||||
PollImmediately();
|
PollImmediately();
|
||||||
@ -111,7 +113,7 @@ namespace osu.Game.Screens.Multi
|
|||||||
|
|
||||||
private void joinRoom(Room room)
|
private void joinRoom(Room room)
|
||||||
{
|
{
|
||||||
CurrentRoom.Value = room;
|
currentRoom.Value = room;
|
||||||
joinedRoom = room;
|
joinedRoom = room;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +136,7 @@ namespace osu.Game.Screens.Multi
|
|||||||
var tcs = new TaskCompletionSource<bool>();
|
var tcs = new TaskCompletionSource<bool>();
|
||||||
|
|
||||||
pollReq?.Cancel();
|
pollReq?.Cancel();
|
||||||
pollReq = new GetRoomsRequest(filter.Value.PrimaryFilter);
|
pollReq = new GetRoomsRequest(currentFilter.Value.PrimaryFilter);
|
||||||
|
|
||||||
pollReq.Success += result =>
|
pollReq.Success += result =>
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user