1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 22:22:54 +08:00

Merge pull request #11661 from peppy/playlist-max-room-attempts

Add support for setting the maximum attempt count for a playlist
This commit is contained in:
Dean Herbert 2021-02-05 23:40:38 +09:00 committed by GitHub
commit dd4207cb4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 90 additions and 56 deletions

View File

@ -12,7 +12,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
{ {
public class ModeTypeInfo : OnlinePlayComposite public class ModeTypeInfo : OnlinePlayComposite
{ {
private const float height = 30; private const float height = 28;
private const float transition_duration = 100; private const float transition_duration = 100;
private Container drawableRuleset; private Container drawableRuleset;

View File

@ -0,0 +1,50 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.OnlinePlay.Components
{
public class RoomLocalUserInfo : OnlinePlayComposite
{
private OsuSpriteText attemptDisplay;
public RoomLocalUserInfo()
{
AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load()
{
InternalChild = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
attemptDisplay = new OsuSpriteText
{
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14)
},
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
MaxAttempts.BindValueChanged(attempts =>
{
attemptDisplay.Text = attempts.NewValue == null
? string.Empty
: $"Maximum attempts: {attempts.NewValue:N0}";
}, true);
}
}
}

View File

@ -63,7 +63,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
summary = new OsuSpriteText summary = new OsuSpriteText
{ {
Text = "0 participants", Text = "0 participants",
Font = OsuFont.GetFont(size: 14)
} }
}, },
}, },

View File

@ -20,41 +20,34 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{ {
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
RoomLocalUserInfo localUserInfo;
RoomStatusInfo statusInfo; RoomStatusInfo statusInfo;
ModeTypeInfo typeInfo; ModeTypeInfo typeInfo;
ParticipantInfo participantInfo; ParticipantInfo participantInfo;
InternalChild = new FillFlowContainer InternalChild = new FillFlowContainer
{ {
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Spacing = new Vector2(0, 10),
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 4),
Children = new Drawable[] Children = new Drawable[]
{ {
roomName = new OsuTextFlowContainer(t => t.Font = OsuFont.GetFont(size: 30))
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
},
participantInfo = new ParticipantInfo(),
new Container new Container
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Children = new Drawable[] Children = new Drawable[]
{ {
new FillFlowContainer statusInfo = new RoomStatusInfo(),
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
roomName = new OsuTextFlowContainer(t => t.Font = OsuFont.GetFont(size: 30))
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
},
statusInfo = new RoomStatusInfo(),
}
},
typeInfo = new ModeTypeInfo typeInfo = new ModeTypeInfo
{ {
Anchor = Anchor.BottomRight, Anchor = Anchor.BottomRight,
@ -62,20 +55,21 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
} }
} }
}, },
participantInfo = new ParticipantInfo(), localUserInfo = new RoomLocalUserInfo(),
} }
}; };
statusElements.AddRange(new Drawable[] { statusInfo, typeInfo, participantInfo }); statusElements.AddRange(new Drawable[]
{
statusInfo, typeInfo, participantInfo, localUserInfo
});
} }
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
if (RoomID.Value == null) if (RoomID.Value == null)
statusElements.ForEach(e => e.FadeOut()); statusElements.ForEach(e => e.FadeOut());
RoomID.BindValueChanged(id => RoomID.BindValueChanged(id =>
{ {
if (id.NewValue == null) if (id.NewValue == null)
@ -83,7 +77,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
else else
statusElements.ForEach(e => e.FadeIn(100)); statusElements.ForEach(e => e.FadeIn(100));
}, true); }, true);
RoomName.BindValueChanged(name => RoomName.BindValueChanged(name =>
{ {
roomName.Text = name.NewValue ?? "No room selected"; roomName.Text = name.NewValue ?? "No room selected";

View File

@ -39,6 +39,9 @@ namespace osu.Game.Screens.OnlinePlay
[Resolved(typeof(Room))] [Resolved(typeof(Room))]
protected Bindable<int?> MaxParticipants { get; private set; } protected Bindable<int?> MaxParticipants { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<int?> MaxAttempts { get; private set; }
[Resolved(typeof(Room))] [Resolved(typeof(Room))]
protected Bindable<DateTimeOffset?> EndDate { get; private set; } protected Bindable<DateTimeOffset?> EndDate { get; private set; }

View File

@ -42,15 +42,13 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
public Action EditPlaylist; public Action EditPlaylist;
public OsuTextBox NameField, MaxParticipantsField; public OsuTextBox NameField, MaxParticipantsField, MaxAttemptsField;
public OsuDropdown<TimeSpan> DurationField; public OsuDropdown<TimeSpan> DurationField;
public RoomAvailabilityPicker AvailabilityPicker; public RoomAvailabilityPicker AvailabilityPicker;
public GameTypePicker TypePicker;
public TriangleButton ApplyButton; public TriangleButton ApplyButton;
public OsuSpriteText ErrorText; public OsuSpriteText ErrorText;
private OsuSpriteText typeLabel;
private LoadingLayer loadingLayer; private LoadingLayer loadingLayer;
private DrawableRoomPlaylist playlist; private DrawableRoomPlaylist playlist;
private OsuSpriteText playlistLength; private OsuSpriteText playlistLength;
@ -134,6 +132,15 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
} }
} }
}, },
new Section("Allowed attempts (across all playlist items)")
{
Child = MaxAttemptsField = new SettingsNumberTextBox
{
RelativeSizeAxes = Axes.X,
TabbableContentContainer = this,
PlaceholderText = "Unlimited",
},
},
new Section("Room visibility") new Section("Room visibility")
{ {
Alpha = disabled_alpha, Alpha = disabled_alpha,
@ -142,30 +149,6 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
Enabled = { Value = false } Enabled = { Value = false }
}, },
}, },
new Section("Game type")
{
Alpha = disabled_alpha,
Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
Spacing = new Vector2(7),
Children = new Drawable[]
{
TypePicker = new GameTypePicker
{
RelativeSizeAxes = Axes.X,
Enabled = { Value = false }
},
typeLabel = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 14),
Colour = colours.Yellow
},
},
},
},
new Section("Max participants") new Section("Max participants")
{ {
Alpha = disabled_alpha, Alpha = disabled_alpha,
@ -294,11 +277,10 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
loadingLayer = new LoadingLayer(true) loadingLayer = new LoadingLayer(true)
}; };
TypePicker.Current.BindValueChanged(type => typeLabel.Text = type.NewValue?.Name ?? string.Empty, true);
RoomName.BindValueChanged(name => NameField.Text = name.NewValue, true); RoomName.BindValueChanged(name => NameField.Text = name.NewValue, true);
Availability.BindValueChanged(availability => AvailabilityPicker.Current.Value = availability.NewValue, true); Availability.BindValueChanged(availability => AvailabilityPicker.Current.Value = availability.NewValue, true);
Type.BindValueChanged(type => TypePicker.Current.Value = type.NewValue, true);
MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true); MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true);
MaxAttempts.BindValueChanged(count => MaxAttemptsField.Text = count.NewValue?.ToString(), true);
Duration.BindValueChanged(duration => DurationField.Current.Value = duration.NewValue ?? TimeSpan.FromMinutes(30), true); Duration.BindValueChanged(duration => DurationField.Current.Value = duration.NewValue ?? TimeSpan.FromMinutes(30), true);
playlist.Items.BindTo(Playlist); playlist.Items.BindTo(Playlist);
@ -326,13 +308,17 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
RoomName.Value = NameField.Text; RoomName.Value = NameField.Text;
Availability.Value = AvailabilityPicker.Current.Value; Availability.Value = AvailabilityPicker.Current.Value;
Type.Value = TypePicker.Current.Value;
if (int.TryParse(MaxParticipantsField.Text, out int max)) if (int.TryParse(MaxParticipantsField.Text, out int max))
MaxParticipants.Value = max; MaxParticipants.Value = max;
else else
MaxParticipants.Value = null; MaxParticipants.Value = null;
if (int.TryParse(MaxAttemptsField.Text, out max))
MaxAttempts.Value = max;
else
MaxAttempts.Value = null;
Duration.Value = DurationField.Current.Value; Duration.Value = DurationField.Current.Value;
manager?.CreateRoom(currentRoom.Value, onSuccess, onError); manager?.CreateRoom(currentRoom.Value, onSuccess, onError);

View File

@ -65,7 +65,10 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
{ {
failed = true; failed = true;
Logger.Error(e, "Failed to retrieve a score submission token.\n\nThis may happen if you are running an old or non-official release of osu! (ie. you are self-compiling)."); if (string.IsNullOrEmpty(e.Message))
Logger.Error(e, "Failed to retrieve a score submission token.");
else
Logger.Log($"You are not able to submit a score: {e.Message}", level: LogLevel.Important);
Schedule(() => Schedule(() =>
{ {