mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 09:22:54 +08:00
Add the ability to change multiplayer game type
This commit is contained in:
parent
c856611f65
commit
b956d32587
@ -192,8 +192,9 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="name">The new room name, if any.</param>
|
/// <param name="name">The new room name, if any.</param>
|
||||||
/// <param name="password">The new password, 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="item">The new room playlist item, if any.</param>
|
||||||
public Task ChangeSettings(Optional<string> name = default, Optional<string> password = default, Optional<PlaylistItem> item = default)
|
public Task ChangeSettings(Optional<string> name = default, Optional<string> password = default, Optional<MatchType> matchType = default, Optional<PlaylistItem> item = default)
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
throw new InvalidOperationException("Must be joined to a match to change settings.");
|
throw new InvalidOperationException("Must be joined to a match to change settings.");
|
||||||
@ -219,6 +220,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
BeatmapID = item.GetOr(existingPlaylistItem).BeatmapID,
|
BeatmapID = item.GetOr(existingPlaylistItem).BeatmapID,
|
||||||
BeatmapChecksum = item.GetOr(existingPlaylistItem).Beatmap.Value.MD5Hash,
|
BeatmapChecksum = item.GetOr(existingPlaylistItem).Beatmap.Value.MD5Hash,
|
||||||
RulesetID = item.GetOr(existingPlaylistItem).RulesetID,
|
RulesetID = item.GetOr(existingPlaylistItem).RulesetID,
|
||||||
|
MatchType = matchType.GetOr(Room.Settings.MatchType),
|
||||||
RequiredMods = item.HasValue ? item.Value.AsNonNull().RequiredMods.Select(m => new APIMod(m)).ToList() : Room.Settings.RequiredMods,
|
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,
|
AllowedMods = item.HasValue ? item.Value.AsNonNull().AllowedMods.Select(m => new APIMod(m)).ToList() : Room.Settings.AllowedMods,
|
||||||
});
|
});
|
||||||
|
@ -61,7 +61,7 @@ namespace osu.Game.Online.Rooms
|
|||||||
public readonly Bindable<RoomAvailability> Availability = new Bindable<RoomAvailability>();
|
public readonly Bindable<RoomAvailability> Availability = new Bindable<RoomAvailability>();
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
[JsonIgnore]
|
[JsonProperty("type")]
|
||||||
public readonly Bindable<MatchType> Type = new Bindable<MatchType>();
|
public readonly Bindable<MatchType> Type = new Bindable<MatchType>();
|
||||||
|
|
||||||
// Todo: osu-framework bug (https://github.com/ppy/osu-framework/issues/4106)
|
// Todo: osu-framework bug (https://github.com/ppy/osu-framework/issues/4106)
|
||||||
|
@ -9,7 +9,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
{
|
{
|
||||||
public abstract class DisableableTabControl<T> : TabControl<T>
|
public abstract class DisableableTabControl<T> : TabControl<T>
|
||||||
{
|
{
|
||||||
public readonly BindableBool Enabled = new BindableBool();
|
public readonly BindableBool Enabled = new BindableBool(true);
|
||||||
|
|
||||||
protected override void AddTabItem(TabItem<T> tab, bool addToDropdown = true)
|
protected override void AddTabItem(TabItem<T> tab, bool addToDropdown = true)
|
||||||
{
|
{
|
||||||
|
@ -149,7 +149,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
},
|
},
|
||||||
new Section("Game type")
|
new Section("Game type")
|
||||||
{
|
{
|
||||||
Alpha = disabled_alpha,
|
|
||||||
Child = new FillFlowContainer
|
Child = new FillFlowContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
@ -161,7 +160,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
TypePicker = new MatchTypePicker
|
TypePicker = new MatchTypePicker
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Enabled = { Value = false }
|
|
||||||
},
|
},
|
||||||
typeLabel = new OsuSpriteText
|
typeLabel = new OsuSpriteText
|
||||||
{
|
{
|
||||||
@ -305,7 +303,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
// Otherwise, update the room directly in preparation for it to be submitted to the API on match creation.
|
// Otherwise, update the room directly in preparation for it to be submitted to the API on match creation.
|
||||||
if (client.Room != null)
|
if (client.Room != null)
|
||||||
{
|
{
|
||||||
client.ChangeSettings(name: NameField.Text, password: PasswordTextBox.Text).ContinueWith(t => Schedule(() =>
|
client.ChangeSettings(name: NameField.Text, password: PasswordTextBox.Text, matchType: TypePicker.Current.Value).ContinueWith(t => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (t.IsCompletedSuccessfully)
|
if (t.IsCompletedSuccessfully)
|
||||||
onSuccess(currentRoom.Value);
|
onSuccess(currentRoom.Value);
|
||||||
|
@ -58,7 +58,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
new Room
|
new Room
|
||||||
{
|
{
|
||||||
Name = { Value = $"{API.LocalUser}'s awesome room" },
|
Name = { Value = $"{API.LocalUser}'s awesome room" },
|
||||||
Category = { Value = RoomCategory.Realtime }
|
Category = { Value = RoomCategory.Realtime },
|
||||||
|
Type = { Value = MatchType.HeadToHead },
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override string ScreenTitle => "Multiplayer";
|
protected override string ScreenTitle => "Multiplayer";
|
||||||
|
@ -48,7 +48,11 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
|||||||
|
|
||||||
protected override Room CreateNewRoom()
|
protected override Room CreateNewRoom()
|
||||||
{
|
{
|
||||||
return new Room { Name = { Value = $"{API.LocalUser}'s awesome playlist" } };
|
return new Room
|
||||||
|
{
|
||||||
|
Name = { Value = $"{API.LocalUser}'s awesome playlist" },
|
||||||
|
Type = { Value = MatchType.Playlists }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string ScreenTitle => "Playlists";
|
protected override string ScreenTitle => "Playlists";
|
||||||
|
Loading…
Reference in New Issue
Block a user