1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 16:52:54 +08:00

Use CMC in the Multiplayer screen

This commit is contained in:
smoogipoo 2019-02-05 15:56:18 +09:00
parent 37c1f5a824
commit d9537017c8
3 changed files with 16 additions and 7 deletions

View File

@ -83,7 +83,7 @@ namespace osu.Game.Online.Multiplayer
/// The position of this <see cref="Room"/> in the list. This is not read from or written to the API.
/// </summary>
[JsonIgnore]
public int Position = -1;
public Bindable<int> Position { get; private set; } = new Bindable<int>(-1);
public void CopyFrom(Room other)
{

View File

@ -149,6 +149,15 @@ namespace osu.Game.Screens.Multi
isIdle.BindTo(idleTracker.IsIdle);
}
private CachedModelDependencyContainer<Room> dependencies;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
dependencies = new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent));
dependencies.Model.BindTo(roomManager.CurrentRoom);
return dependencies;
}
protected override void LoadComplete()
{
base.LoadComplete();

View File

@ -23,7 +23,7 @@ namespace osu.Game.Screens.Multi
private readonly BindableList<Room> rooms = new BindableList<Room>();
public IBindableList<Room> Rooms => rooms;
private Room currentRoom;
public readonly Bindable<Room> CurrentRoom = new Bindable<Room>();
[Resolved]
private APIAccess api { get; set; }
@ -77,7 +77,7 @@ namespace osu.Game.Screens.Multi
currentJoinRoomRequest = new JoinRoomRequest(room, api.LocalUser.Value);
currentJoinRoomRequest.Success += () =>
{
currentRoom = room;
CurrentRoom.Value = room;
onSuccess?.Invoke(room);
};
@ -92,11 +92,11 @@ namespace osu.Game.Screens.Multi
public void PartRoom()
{
if (currentRoom == null)
if (CurrentRoom.Value == null)
return;
api.Queue(new PartRoomRequest(currentRoom, api.LocalUser.Value));
currentRoom = null;
api.Queue(new PartRoomRequest(CurrentRoom.Value, api.LocalUser.Value));
CurrentRoom.Value = null;
}
public void UpdateRooms(List<Room> newRooms)
@ -111,7 +111,7 @@ namespace osu.Game.Screens.Multi
for (int i = 0; i < newRooms.Count; i++)
{
var r = newRooms[i];
r.Position = i;
r.Position.Value = i;
update(r, r);
addRoom(r);