2020-12-20 23:04:06 +08:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
using System;
|
2022-03-18 21:00:39 +08:00
|
|
|
using System.ComponentModel;
|
2020-12-29 15:20:43 +08:00
|
|
|
using System.Diagnostics;
|
2022-09-07 18:05:53 +08:00
|
|
|
using System.Linq;
|
2020-12-20 23:04:06 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
2021-08-03 13:46:31 +08:00
|
|
|
using osu.Framework.Extensions;
|
2020-12-24 00:08:28 +08:00
|
|
|
using osu.Framework.Extensions.ExceptionExtensions;
|
2020-12-20 23:04:06 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2021-10-22 18:41:36 +08:00
|
|
|
using osu.Framework.Screens;
|
2022-09-07 18:05:53 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2020-12-20 23:04:06 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using osu.Game.Online.Multiplayer;
|
2020-12-25 12:38:11 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
2020-12-20 23:04:06 +08:00
|
|
|
using osu.Game.Overlays;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Match.Components;
|
2020-12-20 23:04:06 +08:00
|
|
|
using osuTK;
|
2022-03-18 21:00:39 +08:00
|
|
|
using Container = osu.Framework.Graphics.Containers.Container;
|
2020-12-20 23:04:06 +08:00
|
|
|
|
2020-12-25 23:50:00 +08:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-08-17 16:14:21 +08:00
|
|
|
public class MultiplayerMatchSettingsOverlay : RoomSettingsOverlay
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2022-09-07 18:05:53 +08:00
|
|
|
private MatchSettings settings = null!;
|
2021-08-05 13:00:35 +08:00
|
|
|
|
|
|
|
protected override OsuButton SubmitButton => settings.ApplyButton;
|
|
|
|
|
2021-08-05 13:14:07 +08:00
|
|
|
[Resolved]
|
2022-09-07 18:05:53 +08:00
|
|
|
private OngoingOperationTracker ongoingOperationTracker { get; set; } = null!;
|
2021-08-05 13:14:07 +08:00
|
|
|
|
|
|
|
protected override bool IsLoading => ongoingOperationTracker.InProgress.Value;
|
|
|
|
|
2021-08-19 15:40:27 +08:00
|
|
|
public MultiplayerMatchSettingsOverlay(Room room)
|
|
|
|
: base(room)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-08-05 13:00:35 +08:00
|
|
|
protected override void SelectBeatmap() => settings.SelectBeatmap();
|
|
|
|
|
2021-08-19 15:40:27 +08:00
|
|
|
protected override OnlinePlayComposite CreateSettings(Room room) => settings = new MatchSettings(room)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
RelativePositionAxes = Axes.Y,
|
|
|
|
SettingsApplied = Hide
|
|
|
|
};
|
2020-12-20 23:04:06 +08:00
|
|
|
|
2020-12-26 00:12:33 +08:00
|
|
|
protected class MatchSettings : OnlinePlayComposite
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
|
|
|
private const float disabled_alpha = 0.2f;
|
|
|
|
|
2022-09-07 18:05:53 +08:00
|
|
|
public Action? SettingsApplied;
|
|
|
|
|
|
|
|
public OsuTextBox NameField = null!;
|
|
|
|
public OsuTextBox MaxParticipantsField = null!;
|
|
|
|
public MatchTypePicker TypePicker = null!;
|
|
|
|
public OsuEnumDropdown<QueueMode> QueueModeDropdown = null!;
|
|
|
|
public OsuTextBox PasswordTextBox = null!;
|
|
|
|
public OsuCheckbox AutoSkipCheckbox = null!;
|
|
|
|
public TriangleButton ApplyButton = null!;
|
2020-12-20 23:04:06 +08:00
|
|
|
|
2022-09-07 18:05:53 +08:00
|
|
|
public OsuSpriteText ErrorText = null!;
|
2020-12-20 23:04:06 +08:00
|
|
|
|
2022-09-07 18:05:53 +08:00
|
|
|
private OsuEnumDropdown<StartMode> startModeDropdown = null!;
|
|
|
|
private OsuSpriteText typeLabel = null!;
|
|
|
|
private LoadingLayer loadingLayer = null!;
|
2020-12-20 23:04:06 +08:00
|
|
|
|
2022-09-07 18:05:53 +08:00
|
|
|
[Resolved]
|
|
|
|
private BeatmapManager beatmapManager { get; set; } = null!;
|
2020-12-20 23:04:06 +08:00
|
|
|
|
2021-10-22 18:41:36 +08:00
|
|
|
public void SelectBeatmap()
|
|
|
|
{
|
|
|
|
if (matchSubScreen.IsCurrentScreen())
|
|
|
|
matchSubScreen.Push(new MultiplayerMatchSongSelect(matchSubScreen.Room));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Resolved]
|
2022-09-07 18:05:53 +08:00
|
|
|
private MultiplayerMatchSubScreen matchSubScreen { get; set; } = null!;
|
2021-08-05 13:00:35 +08:00
|
|
|
|
2020-12-20 23:04:06 +08:00
|
|
|
[Resolved]
|
2022-09-07 18:05:53 +08:00
|
|
|
private IRoomManager manager { get; set; } = null!;
|
2020-12-20 23:04:06 +08:00
|
|
|
|
|
|
|
[Resolved]
|
2022-09-07 18:05:53 +08:00
|
|
|
private MultiplayerClient client { get; set; } = null!;
|
2020-12-20 23:04:06 +08:00
|
|
|
|
2020-12-29 15:20:43 +08:00
|
|
|
[Resolved]
|
2022-09-07 18:05:53 +08:00
|
|
|
private OngoingOperationTracker ongoingOperationTracker { get; set; } = null!;
|
2020-12-29 15:20:43 +08:00
|
|
|
|
|
|
|
private readonly IBindable<bool> operationInProgress = new BindableBool();
|
2021-08-19 15:40:27 +08:00
|
|
|
private readonly Room room;
|
|
|
|
|
2022-09-07 18:05:53 +08:00
|
|
|
private IDisposable? applyingSettingsOperation;
|
|
|
|
private Drawable playlistContainer = null!;
|
|
|
|
private DrawableRoomPlaylist drawablePlaylist = null!;
|
2021-10-22 18:41:36 +08:00
|
|
|
|
2021-08-19 15:40:27 +08:00
|
|
|
public MatchSettings(Room room)
|
|
|
|
{
|
|
|
|
this.room = room;
|
|
|
|
}
|
|
|
|
|
2020-12-20 23:04:06 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2021-10-14 04:50:19 +08:00
|
|
|
private void load(OverlayColourProvider colourProvider, OsuColour colours)
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
new Box
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-10-14 04:50:19 +08:00
|
|
|
Colour = colourProvider.Background4
|
2021-01-04 21:42:39 +08:00
|
|
|
},
|
|
|
|
new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
RowDimensions = new[]
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-07-05 23:52:39 +08:00
|
|
|
new Dimension(),
|
2021-01-04 21:42:39 +08:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
new OsuScrollContainer
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
Padding = new MarginPadding
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
Horizontal = OsuScreen.HORIZONTAL_OVERFLOW_PADDING,
|
|
|
|
Vertical = 10
|
|
|
|
},
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
new FillFlowContainer
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Spacing = new Vector2(0, 10),
|
2021-10-22 18:41:36 +08:00
|
|
|
Children = new[]
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
new Container
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Padding = new MarginPadding { Horizontal = WaveOverlayContainer.WIDTH_PADDING },
|
2020-12-20 23:04:06 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
new SectionContainer
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
Padding = new MarginPadding { Right = FIELD_PADDING / 2 },
|
|
|
|
Children = new[]
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
new Section("Room name")
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-10-17 19:10:23 +08:00
|
|
|
Child = NameField = new OsuTextBox
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
TabbableContentContainer = this,
|
2021-08-19 01:30:50 +08:00
|
|
|
LengthLimit = 100,
|
2020-12-20 23:04:06 +08:00
|
|
|
},
|
|
|
|
},
|
2022-03-25 17:37:20 +08:00
|
|
|
// new Section("Room visibility")
|
|
|
|
// {
|
|
|
|
// Alpha = disabled_alpha,
|
|
|
|
// Child = AvailabilityPicker = new RoomAvailabilityPicker
|
|
|
|
// {
|
|
|
|
// Enabled = { Value = false }
|
|
|
|
// },
|
|
|
|
// },
|
2021-01-04 21:42:39 +08:00
|
|
|
new Section("Game type")
|
|
|
|
{
|
|
|
|
Child = new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Spacing = new Vector2(7),
|
|
|
|
Children = new Drawable[]
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-08-03 16:47:53 +08:00
|
|
|
TypePicker = new MatchTypePicker
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
},
|
2021-01-04 21:42:39 +08:00
|
|
|
typeLabel = new OsuSpriteText
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
Font = OsuFont.GetFont(size: 14),
|
|
|
|
Colour = colours.Yellow
|
2020-12-20 23:04:06 +08:00
|
|
|
},
|
|
|
|
},
|
2021-01-04 21:42:39 +08:00
|
|
|
},
|
|
|
|
},
|
2021-11-19 14:47:38 +08:00
|
|
|
new Section("Queue mode")
|
2021-10-20 13:51:59 +08:00
|
|
|
{
|
2021-10-20 16:52:05 +08:00
|
|
|
Child = new Container
|
2021-10-20 13:51:59 +08:00
|
|
|
{
|
2021-10-20 16:52:05 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 40,
|
2021-11-16 13:53:10 +08:00
|
|
|
Child = QueueModeDropdown = new OsuEnumDropdown<QueueMode>
|
2021-10-20 16:52:05 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X
|
|
|
|
}
|
2021-10-20 13:51:59 +08:00
|
|
|
}
|
2022-03-18 21:00:39 +08:00
|
|
|
},
|
|
|
|
new Section("Auto start")
|
|
|
|
{
|
|
|
|
Child = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 40,
|
|
|
|
Child = startModeDropdown = new OsuEnumDropdown<StartMode>
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X
|
|
|
|
}
|
|
|
|
}
|
2021-10-20 13:51:59 +08:00
|
|
|
}
|
2020-12-20 23:04:06 +08:00
|
|
|
},
|
|
|
|
},
|
2021-01-04 21:42:39 +08:00
|
|
|
new SectionContainer
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Padding = new MarginPadding { Left = FIELD_PADDING / 2 },
|
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
new Section("Max participants")
|
|
|
|
{
|
|
|
|
Alpha = disabled_alpha,
|
2021-10-17 19:10:23 +08:00
|
|
|
Child = MaxParticipantsField = new OsuNumberBox
|
2021-01-04 21:42:39 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
TabbableContentContainer = this,
|
|
|
|
ReadOnly = true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
new Section("Password (optional)")
|
|
|
|
{
|
2021-10-17 19:10:23 +08:00
|
|
|
Child = PasswordTextBox = new OsuPasswordTextBox
|
2021-01-04 21:42:39 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
TabbableContentContainer = this,
|
2021-08-19 01:30:50 +08:00
|
|
|
LengthLimit = 255,
|
2021-01-04 21:42:39 +08:00
|
|
|
},
|
|
|
|
},
|
2022-08-31 18:49:04 +08:00
|
|
|
new Section("Other")
|
|
|
|
{
|
|
|
|
Child = AutoSkipCheckbox = new OsuCheckbox
|
|
|
|
{
|
|
|
|
LabelText = "Automatically skip the beatmap intro"
|
|
|
|
}
|
|
|
|
}
|
2021-01-04 21:42:39 +08:00
|
|
|
}
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
2021-01-04 21:42:39 +08:00
|
|
|
},
|
|
|
|
},
|
2021-10-22 18:41:36 +08:00
|
|
|
playlistContainer = new FillFlowContainer
|
2021-01-04 21:42:39 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2021-10-22 18:41:36 +08:00
|
|
|
AutoSizeAxes = Axes.Y,
|
2021-10-20 16:52:05 +08:00
|
|
|
Width = 0.5f,
|
2021-10-22 18:41:36 +08:00
|
|
|
Depth = float.MaxValue,
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2021-12-09 00:04:28 +08:00
|
|
|
drawablePlaylist = new DrawableRoomPlaylist
|
2021-10-22 18:41:36 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2021-11-15 23:31:35 +08:00
|
|
|
Height = DrawableRoomPlaylistItem.HEIGHT
|
2021-10-22 18:41:36 +08:00
|
|
|
},
|
|
|
|
new PurpleTriangleButton
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 40,
|
|
|
|
Text = "Select beatmap",
|
|
|
|
Action = SelectBeatmap
|
|
|
|
}
|
|
|
|
}
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
2021-01-04 21:42:39 +08:00
|
|
|
}
|
|
|
|
}
|
2020-12-20 23:04:06 +08:00
|
|
|
},
|
2021-01-04 21:42:39 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
Y = 2,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Children = new Drawable[]
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-10-14 04:50:19 +08:00
|
|
|
Colour = colourProvider.Background5
|
2021-01-04 21:42:39 +08:00
|
|
|
},
|
|
|
|
new FillFlowContainer
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2021-01-04 21:42:39 +08:00
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Spacing = new Vector2(0, 20),
|
|
|
|
Margin = new MarginPadding { Vertical = 20 },
|
|
|
|
Padding = new MarginPadding { Horizontal = OsuScreen.HORIZONTAL_OVERFLOW_PADDING },
|
2020-12-20 23:04:06 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
ApplyButton = new CreateOrUpdateButton
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
Size = new Vector2(230, 55),
|
|
|
|
Enabled = { Value = false },
|
|
|
|
Action = apply,
|
2020-12-20 23:04:06 +08:00
|
|
|
},
|
2021-01-04 21:42:39 +08:00
|
|
|
ErrorText = new OsuSpriteText
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-01-04 21:42:39 +08:00
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
Alpha = 0,
|
|
|
|
Depth = 1,
|
|
|
|
Colour = colours.RedDark
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-04 21:42:39 +08:00
|
|
|
}
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
|
|
|
},
|
2021-01-04 21:42:39 +08:00
|
|
|
loadingLayer = new LoadingLayer(true)
|
2020-12-20 23:04:06 +08:00
|
|
|
};
|
|
|
|
|
2021-08-03 13:46:31 +08:00
|
|
|
TypePicker.Current.BindValueChanged(type => typeLabel.Text = type.NewValue.GetLocalisableDescription(), true);
|
2020-12-20 23:04:06 +08:00
|
|
|
RoomName.BindValueChanged(name => NameField.Text = name.NewValue, true);
|
|
|
|
Type.BindValueChanged(type => TypePicker.Current.Value = type.NewValue, true);
|
|
|
|
MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true);
|
2021-10-22 18:41:36 +08:00
|
|
|
RoomID.BindValueChanged(roomId => playlistContainer.Alpha = roomId.NewValue == null ? 1 : 0, true);
|
2021-07-19 19:02:14 +08:00
|
|
|
Password.BindValueChanged(password => PasswordTextBox.Text = password.NewValue ?? string.Empty, true);
|
2021-11-01 17:52:57 +08:00
|
|
|
QueueMode.BindValueChanged(mode => QueueModeDropdown.Current.Value = mode.NewValue, true);
|
2022-03-18 21:00:39 +08:00
|
|
|
AutoStartDuration.BindValueChanged(duration => startModeDropdown.Current.Value = (StartMode)(int)duration.NewValue.TotalSeconds, true);
|
2022-08-31 18:49:04 +08:00
|
|
|
AutoSkip.BindValueChanged(autoSkip => AutoSkipCheckbox.Current.Value = autoSkip.NewValue, true);
|
2020-12-29 04:44:58 +08:00
|
|
|
|
2020-12-29 15:20:43 +08:00
|
|
|
operationInProgress.BindTo(ongoingOperationTracker.InProgress);
|
|
|
|
operationInProgress.BindValueChanged(v =>
|
2020-12-29 04:44:58 +08:00
|
|
|
{
|
|
|
|
if (v.NewValue)
|
|
|
|
loadingLayer.Show();
|
|
|
|
else
|
|
|
|
loadingLayer.Hide();
|
|
|
|
});
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
|
|
|
|
2021-11-15 23:31:35 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
drawablePlaylist.Items.BindTo(Playlist);
|
2022-02-24 15:20:40 +08:00
|
|
|
drawablePlaylist.SelectedItem.BindTo(CurrentPlaylistItem);
|
2021-11-15 23:31:35 +08:00
|
|
|
}
|
|
|
|
|
2020-12-20 23:04:06 +08:00
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
2020-12-29 15:20:43 +08:00
|
|
|
ApplyButton.Enabled.Value = Playlist.Count > 0 && NameField.Text.Length > 0 && !operationInProgress.Value;
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void apply()
|
|
|
|
{
|
|
|
|
if (!ApplyButton.Enabled.Value)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hideError();
|
2020-12-29 15:20:43 +08:00
|
|
|
|
|
|
|
Debug.Assert(applyingSettingsOperation == null);
|
|
|
|
applyingSettingsOperation = ongoingOperationTracker.BeginOperation();
|
2020-12-20 23:04:06 +08:00
|
|
|
|
2022-03-18 21:00:39 +08:00
|
|
|
TimeSpan autoStartDuration = TimeSpan.FromSeconds((int)startModeDropdown.Current.Value);
|
|
|
|
|
2020-12-20 23:04:06 +08:00
|
|
|
// If the client is already in a room, update via the client.
|
|
|
|
// Otherwise, update the room directly in preparation for it to be submitted to the API on match creation.
|
|
|
|
if (client.Room != null)
|
|
|
|
{
|
2021-10-20 19:25:06 +08:00
|
|
|
client.ChangeSettings(
|
|
|
|
name: NameField.Text,
|
|
|
|
password: PasswordTextBox.Text,
|
|
|
|
matchType: TypePicker.Current.Value,
|
2022-03-18 21:00:39 +08:00
|
|
|
queueMode: QueueModeDropdown.Current.Value,
|
2022-08-31 18:49:04 +08:00
|
|
|
autoStartDuration: autoStartDuration,
|
|
|
|
autoSkip: AutoSkipCheckbox.Current.Value)
|
2021-10-20 19:25:06 +08:00
|
|
|
.ContinueWith(t => Schedule(() =>
|
|
|
|
{
|
|
|
|
if (t.IsCompletedSuccessfully)
|
|
|
|
onSuccess(room);
|
|
|
|
else
|
|
|
|
onError(t.Exception?.AsSingular().Message ?? "Error changing settings.");
|
|
|
|
}));
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-19 15:40:27 +08:00
|
|
|
room.Name.Value = NameField.Text;
|
|
|
|
room.Type.Value = TypePicker.Current.Value;
|
|
|
|
room.Password.Value = PasswordTextBox.Current.Value;
|
2021-10-20 19:25:06 +08:00
|
|
|
room.QueueMode.Value = QueueModeDropdown.Current.Value;
|
2022-03-18 21:00:39 +08:00
|
|
|
room.AutoStartDuration.Value = autoStartDuration;
|
2022-08-31 18:49:04 +08:00
|
|
|
room.AutoSkip.Value = AutoSkipCheckbox.Current.Value;
|
2020-12-20 23:04:06 +08:00
|
|
|
|
|
|
|
if (int.TryParse(MaxParticipantsField.Text, out int max))
|
2021-08-19 15:40:27 +08:00
|
|
|
room.MaxParticipants.Value = max;
|
2020-12-20 23:04:06 +08:00
|
|
|
else
|
2021-08-19 15:40:27 +08:00
|
|
|
room.MaxParticipants.Value = null;
|
2020-12-20 23:04:06 +08:00
|
|
|
|
2022-09-07 18:05:53 +08:00
|
|
|
manager.CreateRoom(room, onSuccess, onError);
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void hideError() => ErrorText.FadeOut(50);
|
|
|
|
|
|
|
|
private void onSuccess(Room room)
|
|
|
|
{
|
2020-12-29 15:20:43 +08:00
|
|
|
Debug.Assert(applyingSettingsOperation != null);
|
|
|
|
|
2020-12-20 23:04:06 +08:00
|
|
|
SettingsApplied?.Invoke();
|
2020-12-29 15:20:43 +08:00
|
|
|
|
|
|
|
applyingSettingsOperation.Dispose();
|
|
|
|
applyingSettingsOperation = null;
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void onError(string text)
|
|
|
|
{
|
2020-12-29 15:20:43 +08:00
|
|
|
Debug.Assert(applyingSettingsOperation != null);
|
|
|
|
|
2021-11-19 12:27:28 +08:00
|
|
|
// see https://github.com/ppy/osu-web/blob/2c97aaeb64fb4ed97c747d8383a35b30f57428c7/app/Models/Multiplayer/PlaylistItem.php#L48.
|
|
|
|
const string not_found_prefix = "beatmaps not found:";
|
|
|
|
|
|
|
|
if (text.StartsWith(not_found_prefix, StringComparison.Ordinal))
|
|
|
|
{
|
|
|
|
ErrorText.Text = "The selected beatmap is not available online.";
|
2022-02-24 15:20:40 +08:00
|
|
|
CurrentPlaylistItem.Value.MarkInvalid();
|
2021-11-19 12:27:28 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ErrorText.Text = text;
|
|
|
|
}
|
|
|
|
|
2020-12-20 23:04:06 +08:00
|
|
|
ErrorText.FadeIn(50);
|
2020-12-29 15:20:43 +08:00
|
|
|
|
|
|
|
applyingSettingsOperation.Dispose();
|
|
|
|
applyingSettingsOperation = null;
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-05 13:00:35 +08:00
|
|
|
public class CreateOrUpdateButton : TriangleButton
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
|
|
|
[Resolved(typeof(Room), nameof(Room.RoomID))]
|
2022-09-07 18:05:53 +08:00
|
|
|
private Bindable<long?> roomId { get; set; } = null!;
|
2020-12-20 23:04:06 +08:00
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
roomId.BindValueChanged(id => Text = id.NewValue == null ? "Create" : "Update", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
BackgroundColour = colours.Yellow;
|
|
|
|
Triangles.ColourLight = colours.YellowLight;
|
|
|
|
Triangles.ColourDark = colours.YellowDark;
|
|
|
|
}
|
|
|
|
}
|
2022-03-18 21:00:39 +08:00
|
|
|
|
|
|
|
private enum StartMode
|
|
|
|
{
|
|
|
|
[Description("Off")]
|
|
|
|
Off = 0,
|
|
|
|
|
|
|
|
[Description("30 seconds")]
|
|
|
|
Seconds_30 = 30,
|
|
|
|
|
|
|
|
[Description("1 minute")]
|
|
|
|
Seconds_60 = 60,
|
|
|
|
|
|
|
|
[Description("3 minutes")]
|
|
|
|
Seconds_180 = 180,
|
|
|
|
|
|
|
|
[Description("5 minutes")]
|
|
|
|
Seconds_300 = 300
|
|
|
|
}
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
|
|
|
}
|