Context menu for duplicating multi rooms

This commit is contained in:
voidedWarranties
2020-08-09 16:16:01 -07:00
parent d8ffc00f75
commit 3a97ee4712
5 changed files with 67 additions and 28 deletions

View File

@ -103,38 +103,48 @@ namespace osu.Game.Online.Multiplayer
[JsonIgnore]
public readonly Bindable<int> Position = new Bindable<int>(-1);
public void CopyFrom(Room other)
/// <summary>
/// Copies the properties from another <see cref="Room"/> to this room.
/// </summary>
/// <param name="other">The room to copy</param>
/// <param name="duplicate">Whether the copy should exclude information unique to a specific room (i.e. when duplicating a room)</param>
public void CopyFrom(Room other, bool duplicate = false)
{
RoomID.Value = other.RoomID.Value;
if (!duplicate)
{
RoomID.Value = other.RoomID.Value;
if (other.Host.Value != null && Host.Value?.Id != other.Host.Value.Id)
Host.Value = other.Host.Value;
ChannelId.Value = other.ChannelId.Value;
Status.Value = other.Status.Value;
ParticipantCount.Value = other.ParticipantCount.Value;
EndDate.Value = other.EndDate.Value;
if (DateTimeOffset.Now >= EndDate.Value)
Status.Value = new RoomStatusEnded();
if (!RecentParticipants.SequenceEqual(other.RecentParticipants))
{
RecentParticipants.Clear();
RecentParticipants.AddRange(other.RecentParticipants);
}
Position.Value = other.Position.Value;
}
Name.Value = other.Name.Value;
if (other.Host.Value != null && Host.Value?.Id != other.Host.Value.Id)
Host.Value = other.Host.Value;
ChannelId.Value = other.ChannelId.Value;
Status.Value = other.Status.Value;
Availability.Value = other.Availability.Value;
Type.Value = other.Type.Value;
MaxParticipants.Value = other.MaxParticipants.Value;
ParticipantCount.Value = other.ParticipantCount.Value;
EndDate.Value = other.EndDate.Value;
if (DateTimeOffset.Now >= EndDate.Value)
Status.Value = new RoomStatusEnded();
if (!Playlist.SequenceEqual(other.Playlist))
{
Playlist.Clear();
Playlist.AddRange(other.Playlist);
}
if (!RecentParticipants.SequenceEqual(other.RecentParticipants))
{
RecentParticipants.Clear();
RecentParticipants.AddRange(other.RecentParticipants);
}
Position.Value = other.Position.Value;
}
public bool ShouldSerializeRoomID() => false;