mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:33:01 +08:00
Directly bind to room updates
Currently doesn't really cause any difference, however it may in the future if we decide the queueing algorithm shouldn't update PlaylistOrder when an item has been played.
This commit is contained in:
parent
e2f8c71081
commit
4ce61d4260
@ -8,7 +8,6 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -54,12 +53,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private MultiplayerClient multiplayerClient { get; set; }
|
private MultiplayerClient multiplayerClient { get; set; }
|
||||||
|
|
||||||
[Resolved(typeof(Room), nameof(Room.Host))]
|
|
||||||
private Bindable<APIUser> host { get; set; }
|
|
||||||
|
|
||||||
[Resolved(typeof(Room), nameof(Room.QueueMode))]
|
|
||||||
private Bindable<QueueMode> queueMode { get; set; }
|
|
||||||
|
|
||||||
public QueuePlaylistItem(PlaylistItem item)
|
public QueuePlaylistItem(PlaylistItem item)
|
||||||
: base(item)
|
: base(item)
|
||||||
{
|
{
|
||||||
@ -71,11 +64,12 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
|||||||
|
|
||||||
RequestDeletion = item => multiplayerClient.RemovePlaylistItem(item.ID);
|
RequestDeletion = item => multiplayerClient.RemovePlaylistItem(item.ID);
|
||||||
|
|
||||||
host.BindValueChanged(_ => updateDeleteButtonVisibility());
|
multiplayerClient.RoomUpdated += onRoomUpdated;
|
||||||
queueMode.BindValueChanged(_ => updateDeleteButtonVisibility());
|
onRoomUpdated();
|
||||||
SelectedItem.BindValueChanged(_ => updateDeleteButtonVisibility(), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onRoomUpdated() => Scheduler.AddOnce(updateDeleteButtonVisibility);
|
||||||
|
|
||||||
private void updateDeleteButtonVisibility()
|
private void updateDeleteButtonVisibility()
|
||||||
{
|
{
|
||||||
if (multiplayerClient.Room == null)
|
if (multiplayerClient.Room == null)
|
||||||
@ -86,6 +80,14 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
|||||||
AllowDeletion = isItemOwner && !Item.Expired && Item.ID != multiplayerClient.Room.Settings.PlaylistItemId;
|
AllowDeletion = isItemOwner && !Item.Expired && Item.ID != multiplayerClient.Room.Settings.PlaylistItemId;
|
||||||
AllowEditing = isItemOwner && !Item.Expired;
|
AllowEditing = isItemOwner && !Item.Expired;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
if (multiplayerClient != null)
|
||||||
|
multiplayerClient.RoomUpdated -= onRoomUpdated;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user