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