mirror of
https://github.com/ppy/osu
synced 2024-12-14 02:46:27 +00:00
Move RoomManager to multiplayer screen
This commit is contained in:
parent
7e9cc4e876
commit
dd0c04ea36
@ -22,8 +22,8 @@ namespace osu.Game.Screens.Multi.Lounge
|
||||
private readonly RoomsContainer rooms;
|
||||
private readonly Action<Screen> pushGameplayScreen;
|
||||
|
||||
[Cached]
|
||||
private readonly RoomManager manager;
|
||||
[Resolved]
|
||||
private RoomManager roomManager { get; set; }
|
||||
|
||||
public override string Title => "Lounge";
|
||||
|
||||
@ -56,7 +56,7 @@ namespace osu.Game.Screens.Multi.Lounge
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = rooms = new RoomsContainer { JoinRequested = r => manager?.JoinRoom(r) }
|
||||
Child = rooms = new RoomsContainer { JoinRequested = r => roomManager?.JoinRoom(r) }
|
||||
},
|
||||
},
|
||||
inspector = new RoomInspector
|
||||
@ -68,7 +68,6 @@ namespace osu.Game.Screens.Multi.Lounge
|
||||
},
|
||||
},
|
||||
},
|
||||
manager = new RoomManager { OpenRequested = Open }
|
||||
};
|
||||
|
||||
inspector.Room.BindTo(rooms.SelectedRoom);
|
||||
@ -78,6 +77,12 @@ namespace osu.Game.Screens.Multi.Lounge
|
||||
Filter.Search.Exit += Exit;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
roomManager.OpenRequested += Open;
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
@ -103,7 +108,7 @@ namespace osu.Game.Screens.Multi.Lounge
|
||||
|
||||
protected override bool OnExiting(Screen next)
|
||||
{
|
||||
manager?.PartRoom();
|
||||
roomManager?.PartRoom();
|
||||
|
||||
Filter.Search.HoldFocus = false;
|
||||
return base.OnExiting(next);
|
||||
@ -111,7 +116,7 @@ namespace osu.Game.Screens.Multi.Lounge
|
||||
|
||||
protected override void OnResuming(Screen last)
|
||||
{
|
||||
manager?.PartRoom();
|
||||
roomManager?.PartRoom();
|
||||
|
||||
base.OnResuming(last);
|
||||
}
|
||||
@ -125,7 +130,7 @@ namespace osu.Game.Screens.Multi.Lounge
|
||||
private void filterRooms()
|
||||
{
|
||||
rooms.Filter(Filter.CreateCriteria());
|
||||
manager.Filter(Filter.CreateCriteria());
|
||||
roomManager.Filter(Filter.CreateCriteria());
|
||||
}
|
||||
|
||||
public void Open(Room room)
|
||||
@ -136,5 +141,13 @@ namespace osu.Game.Screens.Multi.Lounge
|
||||
|
||||
Push(new MatchScreen(room, s => pushGameplayScreen?.Invoke(s)));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (roomManager != null)
|
||||
roomManager.OpenRequested -= Open;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ namespace osu.Game.Screens.Multi
|
||||
|
||||
private OsuScreen currentScreen;
|
||||
|
||||
[Cached]
|
||||
private RoomManager roomManager;
|
||||
|
||||
public Multiplayer()
|
||||
{
|
||||
Child = waves = new MultiplayerWaveContainer
|
||||
@ -80,7 +83,8 @@ namespace osu.Game.Screens.Multi
|
||||
},
|
||||
Text = "Create room",
|
||||
Action = () => loungeScreen.Open(new Room())
|
||||
}
|
||||
},
|
||||
roomManager = new RoomManager()
|
||||
});
|
||||
|
||||
screenAdded(loungeScreen);
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Screens.Multi
|
||||
{
|
||||
public class RoomManager : PollingComponent
|
||||
{
|
||||
public Action<Room> OpenRequested;
|
||||
public event Action<Room> OpenRequested;
|
||||
|
||||
public IBindableCollection<Room> Rooms => rooms;
|
||||
private readonly BindableCollection<Room> rooms = new BindableCollection<Room>();
|
||||
|
Loading…
Reference in New Issue
Block a user