mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:52:54 +08:00
Merge branch 'nullable-endsat' into realtime-multiplayer-2
This commit is contained in:
commit
14ea49a14d
@ -22,22 +22,28 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
new DrawableRoom(new Room
|
new DrawableRoom(new Room
|
||||||
{
|
{
|
||||||
Name = { Value = "Room 1" },
|
Name = { Value = "Open - ending in 1 day" },
|
||||||
Status = { Value = new RoomStatusOpen() },
|
Status = { Value = new RoomStatusOpen() },
|
||||||
EndDate = { Value = DateTimeOffset.Now.AddDays(1) }
|
EndDate = { Value = DateTimeOffset.Now.AddDays(1) }
|
||||||
}) { MatchingFilter = true },
|
}) { MatchingFilter = true },
|
||||||
new DrawableRoom(new Room
|
new DrawableRoom(new Room
|
||||||
{
|
{
|
||||||
Name = { Value = "Room 2" },
|
Name = { Value = "Playing - ending in 1 day" },
|
||||||
Status = { Value = new RoomStatusPlaying() },
|
Status = { Value = new RoomStatusPlaying() },
|
||||||
EndDate = { Value = DateTimeOffset.Now.AddDays(1) }
|
EndDate = { Value = DateTimeOffset.Now.AddDays(1) }
|
||||||
}) { MatchingFilter = true },
|
}) { MatchingFilter = true },
|
||||||
new DrawableRoom(new Room
|
new DrawableRoom(new Room
|
||||||
{
|
{
|
||||||
Name = { Value = "Room 3" },
|
Name = { Value = "Ended" },
|
||||||
Status = { Value = new RoomStatusEnded() },
|
Status = { Value = new RoomStatusEnded() },
|
||||||
EndDate = { Value = DateTimeOffset.Now }
|
EndDate = { Value = DateTimeOffset.Now }
|
||||||
}) { MatchingFilter = true },
|
}) { MatchingFilter = true },
|
||||||
|
new DrawableRoom(new Room
|
||||||
|
{
|
||||||
|
Name = { Value = "Open (realtime)" },
|
||||||
|
Status = { Value = new RoomStatusOpen() },
|
||||||
|
Category = { Value = RoomCategory.Realtime }
|
||||||
|
}) { MatchingFilter = true },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public readonly Bindable<TimeSpan> Duration = new Bindable<TimeSpan>(TimeSpan.FromMinutes(30));
|
public readonly Bindable<TimeSpan?> Duration = new Bindable<TimeSpan?>();
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
@ -78,16 +78,22 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
}
|
}
|
||||||
|
|
||||||
[JsonProperty("duration")]
|
[JsonProperty("duration")]
|
||||||
private int duration
|
private int? duration
|
||||||
{
|
{
|
||||||
get => (int)Duration.Value.TotalMinutes;
|
get => (int?)Duration.Value?.TotalMinutes;
|
||||||
set => Duration.Value = TimeSpan.FromMinutes(value);
|
set
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
Duration.Value = null;
|
||||||
|
else
|
||||||
|
Duration.Value = TimeSpan.FromMinutes(value.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only supports retrieval for now
|
// Only supports retrieval for now
|
||||||
[Cached]
|
[Cached]
|
||||||
[JsonProperty("ends_at")]
|
[JsonProperty("ends_at")]
|
||||||
public readonly Bindable<DateTimeOffset> EndDate = new Bindable<DateTimeOffset>();
|
public readonly Bindable<DateTimeOffset?> EndDate = new Bindable<DateTimeOffset?>();
|
||||||
|
|
||||||
// Todo: Find a better way to do this (https://github.com/ppy/osu-framework/issues/1930)
|
// Todo: Find a better way to do this (https://github.com/ppy/osu-framework/issues/1930)
|
||||||
[JsonProperty("max_attempts", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("max_attempts", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
|
@ -48,16 +48,23 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
|
|
||||||
private class EndDatePart : DrawableDate
|
private class EndDatePart : DrawableDate
|
||||||
{
|
{
|
||||||
public readonly IBindable<DateTimeOffset> EndDate = new Bindable<DateTimeOffset>();
|
public readonly IBindable<DateTimeOffset?> EndDate = new Bindable<DateTimeOffset?>();
|
||||||
|
|
||||||
public EndDatePart()
|
public EndDatePart()
|
||||||
: base(DateTimeOffset.UtcNow)
|
: base(DateTimeOffset.UtcNow)
|
||||||
{
|
{
|
||||||
EndDate.BindValueChanged(date => Date = date.NewValue);
|
EndDate.BindValueChanged(date =>
|
||||||
|
{
|
||||||
|
// If null, set a very large future date to prevent unnecessary schedules.
|
||||||
|
Date = date.NewValue ?? DateTimeOffset.Now.AddYears(1);
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string Format()
|
protected override string Format()
|
||||||
{
|
{
|
||||||
|
if (EndDate.Value == null)
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
var diffToNow = Date.Subtract(DateTimeOffset.Now);
|
var diffToNow = Date.Subtract(DateTimeOffset.Now);
|
||||||
|
|
||||||
if (diffToNow.TotalSeconds < -5)
|
if (diffToNow.TotalSeconds < -5)
|
||||||
|
@ -325,7 +325,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
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);
|
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);
|
||||||
Duration.BindValueChanged(duration => DurationField.Current.Value = duration.NewValue, true);
|
Duration.BindValueChanged(duration => DurationField.Current.Value = duration.NewValue ?? TimeSpan.FromMinutes(30), true);
|
||||||
|
|
||||||
playlist.Items.BindTo(Playlist);
|
playlist.Items.BindTo(Playlist);
|
||||||
Playlist.BindCollectionChanged(onPlaylistChanged, true);
|
Playlist.BindCollectionChanged(onPlaylistChanged, true);
|
||||||
|
@ -40,12 +40,12 @@ namespace osu.Game.Screens.Multi
|
|||||||
protected Bindable<int?> MaxParticipants { get; private set; }
|
protected Bindable<int?> MaxParticipants { get; private set; }
|
||||||
|
|
||||||
[Resolved(typeof(Room))]
|
[Resolved(typeof(Room))]
|
||||||
protected Bindable<DateTimeOffset> EndDate { get; private set; }
|
protected Bindable<DateTimeOffset?> EndDate { get; private set; }
|
||||||
|
|
||||||
[Resolved(typeof(Room))]
|
[Resolved(typeof(Room))]
|
||||||
protected Bindable<RoomAvailability> Availability { get; private set; }
|
protected Bindable<RoomAvailability> Availability { get; private set; }
|
||||||
|
|
||||||
[Resolved(typeof(Room))]
|
[Resolved(typeof(Room))]
|
||||||
protected Bindable<TimeSpan> Duration { get; private set; }
|
protected Bindable<TimeSpan?> Duration { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Screens.Multi.Timeshift
|
|||||||
public class TimeshiftReadyButton : ReadyButton
|
public class TimeshiftReadyButton : ReadyButton
|
||||||
{
|
{
|
||||||
[Resolved(typeof(Room), nameof(Room.EndDate))]
|
[Resolved(typeof(Room), nameof(Room.EndDate))]
|
||||||
private Bindable<DateTimeOffset> endDate { get; set; }
|
private Bindable<DateTimeOffset?> endDate { get; set; }
|
||||||
|
|
||||||
public TimeshiftReadyButton()
|
public TimeshiftReadyButton()
|
||||||
{
|
{
|
||||||
@ -32,7 +32,7 @@ namespace osu.Game.Screens.Multi.Timeshift
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
Enabled.Value = DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(GameBeatmap.Value.Track.Length) < endDate.Value;
|
Enabled.Value = endDate.Value != null && DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(GameBeatmap.Value.Track.Length) < endDate.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user