mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Merge pull request #24366 from Joehuu/supporter-playlist-duration
Always show supporter-only playlist durations
This commit is contained in:
commit
4915b2563c
19
osu.Game/Localisation/OnlinePlayStrings.cs
Normal file
19
osu.Game/Localisation/OnlinePlayStrings.cs
Normal file
@ -0,0 +1,19 @@
|
||||
// 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.Localisation;
|
||||
|
||||
namespace osu.Game.Localisation
|
||||
{
|
||||
public static class OnlinePlayStrings
|
||||
{
|
||||
private const string prefix = @"osu.Game.Resources.Localisation.OnlinePlay";
|
||||
|
||||
/// <summary>
|
||||
/// "Playlist durations longer than 2 weeks require an active osu!supporter tag."
|
||||
/// </summary>
|
||||
public static LocalisableString SupporterOnlyDurationNotice => new TranslatableString(getKey(@"supporter_only_duration_notice"), @"Playlist durations longer than 2 weeks require an active osu!supporter tag.");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
@ -113,7 +113,7 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
|
||||
|
||||
protected partial class Section : Container
|
||||
{
|
||||
private readonly Container content;
|
||||
private readonly ReverseChildIDFillFlowContainer<Drawable> content;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
@ -135,10 +135,11 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12),
|
||||
Text = title.ToUpperInvariant(),
|
||||
},
|
||||
content = new Container
|
||||
content = new ReverseChildIDFillFlowContainer<Drawable>
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Vertical
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -23,6 +23,7 @@ using osu.Game.Online.Rooms;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.OnlinePlay.Match.Components;
|
||||
using osuTK;
|
||||
using osu.Game.Localisation;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
{
|
||||
@ -80,6 +81,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
private IBindable<APIUser> localUser = null!;
|
||||
|
||||
private readonly Room room;
|
||||
private OsuSpriteText durationNoticeText = null!;
|
||||
|
||||
public MatchSettings(Room room)
|
||||
{
|
||||
@ -141,14 +143,22 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
},
|
||||
new Section("Duration")
|
||||
{
|
||||
Child = new Container
|
||||
Children = new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 40,
|
||||
Child = DurationField = new DurationDropdown
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X
|
||||
}
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 40,
|
||||
Child = DurationField = new DurationDropdown
|
||||
{
|
||||
RelativeSizeAxes = Axes.X
|
||||
},
|
||||
},
|
||||
durationNoticeText = new OsuSpriteText
|
||||
{
|
||||
Alpha = 0,
|
||||
Colour = colours.Yellow,
|
||||
},
|
||||
}
|
||||
},
|
||||
new Section("Allowed attempts (across all playlist items)")
|
||||
@ -305,6 +315,17 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
MaxAttempts.BindValueChanged(count => MaxAttemptsField.Text = count.NewValue?.ToString(), true);
|
||||
Duration.BindValueChanged(duration => DurationField.Current.Value = duration.NewValue ?? TimeSpan.FromMinutes(30), true);
|
||||
|
||||
DurationField.Current.BindValueChanged(duration =>
|
||||
{
|
||||
if (hasValidDuration)
|
||||
durationNoticeText.Hide();
|
||||
else
|
||||
{
|
||||
durationNoticeText.Show();
|
||||
durationNoticeText.Text = OnlinePlayStrings.SupporterOnlyDurationNotice;
|
||||
}
|
||||
});
|
||||
|
||||
localUser = api.LocalUser.GetBoundCopy();
|
||||
localUser.BindValueChanged(populateDurations, true);
|
||||
|
||||
@ -314,6 +335,10 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
|
||||
private void populateDurations(ValueChangedEvent<APIUser> user)
|
||||
{
|
||||
// roughly correct (see https://github.com/Humanizr/Humanizer/blob/18167e56c082449cc4fe805b8429e3127a7b7f93/readme.md?plain=1#L427)
|
||||
// if we want this to be more accurate we might consider sending an actual end time, not a time span. probably not required though.
|
||||
const int days_in_month = 31;
|
||||
|
||||
DurationField.Items = new[]
|
||||
{
|
||||
TimeSpan.FromMinutes(30),
|
||||
@ -326,18 +351,9 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
TimeSpan.FromDays(3),
|
||||
TimeSpan.FromDays(7),
|
||||
TimeSpan.FromDays(14),
|
||||
TimeSpan.FromDays(days_in_month),
|
||||
TimeSpan.FromDays(days_in_month * 3),
|
||||
};
|
||||
|
||||
// TODO: show these in the interface at all times.
|
||||
if (user.NewValue.IsSupporter)
|
||||
{
|
||||
// roughly correct (see https://github.com/Humanizr/Humanizer/blob/18167e56c082449cc4fe805b8429e3127a7b7f93/readme.md?plain=1#L427)
|
||||
// if we want this to be more accurate we might consider sending an actual end time, not a time span. probably not required though.
|
||||
const int days_in_month = 31;
|
||||
|
||||
DurationField.AddDropdownItem(TimeSpan.FromDays(days_in_month));
|
||||
DurationField.AddDropdownItem(TimeSpan.FromDays(days_in_month * 3));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@ -352,7 +368,10 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
private void onPlaylistChanged(object? sender, NotifyCollectionChangedEventArgs e) =>
|
||||
playlistLength.Text = $"Length: {Playlist.GetTotalDuration()}";
|
||||
|
||||
private bool hasValidSettings => RoomID.Value == null && NameField.Text.Length > 0 && Playlist.Count > 0;
|
||||
private bool hasValidSettings => RoomID.Value == null && NameField.Text.Length > 0 && Playlist.Count > 0
|
||||
&& hasValidDuration;
|
||||
|
||||
private bool hasValidDuration => DurationField.Current.Value <= TimeSpan.FromDays(14) || localUser.Value.IsSupporter;
|
||||
|
||||
private void apply()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user