mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Add request to add a new playlist item
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using MessagePack;
|
||||
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
|
||||
using osu.Game.Online.Multiplayer.Queueing;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
@ -13,6 +14,7 @@ namespace osu.Game.Online.Multiplayer
|
||||
[Serializable]
|
||||
[MessagePackObject]
|
||||
[Union(0, typeof(ChangeTeamRequest))] // IMPORTANT: Add rules to SignalRUnionWorkaroundResolver for new derived types.
|
||||
[Union(1, typeof(AddPlaylistItemRequest))]
|
||||
public abstract class MatchUserRequest
|
||||
{
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -212,39 +211,18 @@ namespace osu.Game.Online.Multiplayer
|
||||
/// <param name="name">The new room name, if any.</param>
|
||||
/// <param name="password">The new password, if any.</param>
|
||||
/// <param name="matchType">The type of the match, if any.</param>
|
||||
/// <param name="item">The new room playlist item, if any.</param>
|
||||
/// <param name="queueMode">The new queue mode, if any.</param>
|
||||
public Task ChangeSettings(Optional<string> name = default, Optional<string> password = default, Optional<MatchType> matchType = default, Optional<PlaylistItem> item = default,
|
||||
Optional<QueueModes> queueMode = default)
|
||||
public Task ChangeSettings(Optional<string> name = default, Optional<string> password = default, Optional<MatchType> matchType = default, Optional<QueueModes> queueMode = default)
|
||||
{
|
||||
if (Room == null)
|
||||
throw new InvalidOperationException("Must be joined to a match to change settings.");
|
||||
|
||||
// A dummy playlist item filled with the current room settings (except mods).
|
||||
var existingPlaylistItem = new PlaylistItem
|
||||
{
|
||||
Beatmap =
|
||||
{
|
||||
Value = new BeatmapInfo
|
||||
{
|
||||
OnlineBeatmapID = Room.Settings.BeatmapID,
|
||||
MD5Hash = Room.Settings.BeatmapChecksum
|
||||
}
|
||||
},
|
||||
RulesetID = Room.Settings.RulesetID
|
||||
};
|
||||
|
||||
return ChangeSettings(new MultiplayerRoomSettings
|
||||
{
|
||||
Name = name.GetOr(Room.Settings.Name),
|
||||
Password = password.GetOr(Room.Settings.Password),
|
||||
BeatmapID = item.GetOr(existingPlaylistItem).BeatmapID,
|
||||
BeatmapChecksum = item.GetOr(existingPlaylistItem).Beatmap.Value.MD5Hash,
|
||||
RulesetID = item.GetOr(existingPlaylistItem).RulesetID,
|
||||
MatchType = matchType.GetOr(Room.Settings.MatchType),
|
||||
QueueMode = queueMode.GetOr(Room.Settings.QueueMode),
|
||||
RequiredMods = item.HasValue ? item.Value.AsNonNull().RequiredMods.Select(m => new APIMod(m)).ToList() : Room.Settings.RequiredMods,
|
||||
AllowedMods = item.HasValue ? item.Value.AsNonNull().AllowedMods.Select(m => new APIMod(m)).ToList() : Room.Settings.AllowedMods,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MessagePack;
|
||||
using osu.Game.Online.API;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer.Queueing
|
||||
{
|
||||
public class AddPlaylistItemRequest : MatchUserRequest
|
||||
{
|
||||
[Key(0)]
|
||||
public int BeatmapID { get; set; }
|
||||
|
||||
[Key(1)]
|
||||
public int RulesetID { get; set; }
|
||||
|
||||
[Key(2)]
|
||||
public string BeatmapChecksum { get; set; } = string.Empty;
|
||||
|
||||
[Key(3)]
|
||||
public IEnumerable<APIMod> RequiredMods { get; set; } = Enumerable.Empty<APIMod>();
|
||||
|
||||
[Key(4)]
|
||||
public IEnumerable<APIMod> AllowedMods { get; set; } = Enumerable.Empty<APIMod>();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user