mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:23:20 +08:00
Compare commits
10 Commits
26a47be32c
...
202b4a46b2
Author | SHA1 | Date | |
---|---|---|---|
|
202b4a46b2 | ||
|
be05f2a1c2 | ||
|
6ff1dec7b2 | ||
|
e920cfa187 | ||
|
164b809c89 | ||
|
f4e155bfa6 | ||
|
2787d74169 | ||
|
5c7ceedd06 | ||
|
c07e7da40f | ||
|
6dffa948d4 |
@ -5,25 +5,64 @@ using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Online.Rooms.RoomStatuses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Tests.Visual.OnlinePlay;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
public partial class TestScenePlaylistsRoomSubScreen : OnlinePlayTestScene
|
||||
{
|
||||
private const double track_length = 10000;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; } = null!;
|
||||
|
||||
protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager;
|
||||
|
||||
private BeatmapManager beatmaps = null!;
|
||||
private RulesetStore rulesets = null!;
|
||||
private BeatmapSetInfo? importedSet;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host, AudioManager audio)
|
||||
{
|
||||
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
||||
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, Realm, null, audio, Resources, host, Beatmap.Default));
|
||||
Dependencies.Cache(new ScoreManager(rulesets, () => beatmaps, LocalStorage, Realm, API));
|
||||
Dependencies.Cache(Realm);
|
||||
|
||||
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
|
||||
|
||||
Realm.Write(r =>
|
||||
{
|
||||
foreach (var set in r.All<BeatmapSetInfo>())
|
||||
{
|
||||
foreach (var b in set.Beatmaps)
|
||||
{
|
||||
// These will all have a virtual track length of 1000, see WorkingBeatmap.GetVirtualTrack().
|
||||
b.Length = track_length - 1000;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
importedSet = beatmaps.GetAllUsableBeatmapSets().First();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStatusUpdateOnEnter()
|
||||
{
|
||||
@ -69,5 +108,42 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
AddAssert("close button present", () => roomScreen.ChildrenOfType<DangerousRoundedButton>().Any());
|
||||
AddUntilStep("wait for close button to disappear", () => !roomScreen.ChildrenOfType<DangerousRoundedButton>().Any());
|
||||
}
|
||||
|
||||
[TestCase(120_000, true)] // Definitely enough time.
|
||||
[TestCase(45_000, true)] // Enough time.
|
||||
[TestCase(35_000, false)] // Not enough time to complete beatmap after lenience.
|
||||
[TestCase(20_000, false)] // Not enough time.
|
||||
[TestCase(5_000, false)] // Not enough time to complete beatmap before lenience.
|
||||
[TestCase(37_500, true, 2)] // Enough time to complete beatmap after mods are applied.
|
||||
public void TestReadyButtonEnablementPeriod(int offsetMs, bool enabled, double rate = 1)
|
||||
{
|
||||
Room room = null!;
|
||||
PlaylistsRoomSubScreen roomScreen = null!;
|
||||
|
||||
AddStep("create room", () =>
|
||||
{
|
||||
RoomManager.AddRoom(room = new Room
|
||||
{
|
||||
Name = @"Test Room",
|
||||
Host = api.LocalUser.Value,
|
||||
Category = RoomCategory.Normal,
|
||||
StartDate = DateTimeOffset.Now,
|
||||
EndDate = DateTimeOffset.Now.AddMilliseconds(offsetMs),
|
||||
Playlist =
|
||||
[
|
||||
new PlaylistItem(importedSet!.Beatmaps[0])
|
||||
{
|
||||
RequiredMods = rate == 1
|
||||
? []
|
||||
: [new APIMod(new OsuModDoubleTime { SpeedChange = { Value = rate } })]
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("push screen", () => LoadScreen(roomScreen = new PlaylistsRoomSubScreen(room)));
|
||||
AddUntilStep("wait for screen load", () => roomScreen.IsCurrentScreen());
|
||||
AddUntilStep("ready button enabled", () => roomScreen.ChildrenOfType<PlaylistsReadyButton>().SingleOrDefault()?.Enabled.Value, () => Is.EqualTo(enabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,9 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
|
||||
public partial class RoundRow : CompositeDrawable, IModelBacked<TournamentRound>
|
||||
{
|
||||
[Resolved]
|
||||
private TournamentGameBase? game { get; set; }
|
||||
|
||||
public TournamentRound Model { get; }
|
||||
|
||||
[Resolved]
|
||||
@ -38,6 +41,12 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
{
|
||||
Model = round;
|
||||
|
||||
Model.Name.Default = Model.Name.Value;
|
||||
Model.Description.Default = Model.Description.Value;
|
||||
Model.StartDate.Default = Model.StartDate.Value;
|
||||
Model.BanCount.Default = Model.BanCount.Value;
|
||||
Model.BestOf.Default = Model.BestOf.Value;
|
||||
|
||||
Masking = true;
|
||||
CornerRadius = 10;
|
||||
|
||||
@ -122,6 +131,22 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
AutoSizeAxes = Axes.Y;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
// TournamentGameBase won't be loaded so early, probably binding the event here
|
||||
game?.IsSaveTriggered.BindValueChanged(state =>
|
||||
{
|
||||
if (!state.NewValue) return;
|
||||
|
||||
Model.Name.Default = Model.Name.Value;
|
||||
Model.Description.Default = Model.Description.Value;
|
||||
Model.StartDate.Default = Model.StartDate.Value;
|
||||
Model.BanCount.Default = Model.BanCount.Value;
|
||||
Model.BestOf.Default = Model.BestOf.Value;
|
||||
});
|
||||
}
|
||||
|
||||
public partial class RoundBeatmapEditor : CompositeDrawable
|
||||
{
|
||||
private readonly TournamentRound round;
|
||||
@ -154,6 +179,9 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
|
||||
public partial class RoundBeatmapRow : CompositeDrawable
|
||||
{
|
||||
[Resolved]
|
||||
private TournamentGameBase? game { get; set; }
|
||||
|
||||
public RoundBeatmap Model { get; }
|
||||
|
||||
[Resolved]
|
||||
@ -232,7 +260,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
beatmapId.Value = Model.ID;
|
||||
beatmapId.Default = beatmapId.Value = Model.ID;
|
||||
beatmapId.BindValueChanged(id =>
|
||||
{
|
||||
Model.ID = id.NewValue ?? 0;
|
||||
@ -263,8 +291,16 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
API.Queue(req);
|
||||
}, true);
|
||||
|
||||
mods.Value = Model.Mods;
|
||||
mods.Default = mods.Value = Model.Mods;
|
||||
mods.BindValueChanged(modString => Model.Mods = modString.NewValue);
|
||||
|
||||
game?.IsSaveTriggered.BindValueChanged(state =>
|
||||
{
|
||||
if (!state.NewValue) return;
|
||||
|
||||
beatmapId.Default = beatmapId.Value;
|
||||
mods.Default = mods.Value;
|
||||
});
|
||||
}
|
||||
|
||||
private void updatePanel() => Schedule(() =>
|
||||
|
@ -34,10 +34,16 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
{
|
||||
public SeedingResult Model { get; }
|
||||
|
||||
[Resolved]
|
||||
private TournamentGameBase? game { get; set; }
|
||||
|
||||
public SeedingResultRow(TournamentTeam team, SeedingResult round)
|
||||
{
|
||||
Model = round;
|
||||
|
||||
Model.Mod.Default = Model.Mod.Value;
|
||||
Model.Seed.Default = Model.Seed.Value;
|
||||
|
||||
Masking = true;
|
||||
CornerRadius = 10;
|
||||
|
||||
@ -104,6 +110,18 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
AutoSizeAxes = Axes.Y;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
game?.IsSaveTriggered.BindValueChanged(state =>
|
||||
{
|
||||
if (!state.NewValue) return;
|
||||
|
||||
Model.Mod.Default = Model.Mod.Value;
|
||||
Model.Seed.Default = Model.Seed.Value;
|
||||
});
|
||||
}
|
||||
|
||||
public partial class SeedingBeatmapEditor : CompositeDrawable
|
||||
{
|
||||
private readonly SeedingResult round;
|
||||
@ -137,6 +155,9 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
private readonly SeedingResult result;
|
||||
public SeedingBeatmap Model { get; }
|
||||
|
||||
[Resolved]
|
||||
private TournamentGameBase? game { get; set; }
|
||||
|
||||
[Resolved]
|
||||
protected IAPIProvider API { get; private set; } = null!;
|
||||
|
||||
@ -221,7 +242,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
beatmapId.Value = Model.ID;
|
||||
beatmapId.Default = beatmapId.Value = Model.ID;
|
||||
beatmapId.BindValueChanged(id =>
|
||||
{
|
||||
Model.ID = id.NewValue ?? 0;
|
||||
@ -252,8 +273,19 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
API.Queue(req);
|
||||
}, true);
|
||||
|
||||
score.Value = Model.Score.ToString();
|
||||
Model.Seed.Default = Model.Seed.Value;
|
||||
|
||||
score.Default = score.Value = Model.Score.ToString();
|
||||
score.BindValueChanged(str => long.TryParse(str.NewValue, out Model.Score));
|
||||
|
||||
game?.IsSaveTriggered.BindValueChanged(state =>
|
||||
{
|
||||
if (!state.NewValue) return;
|
||||
|
||||
beatmapId.Default = beatmapId.Value;
|
||||
Model.Seed.Default = Model.Seed.Value;
|
||||
score.Default = score.Value;
|
||||
});
|
||||
}
|
||||
|
||||
private void updatePanel()
|
||||
|
@ -71,10 +71,19 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
[Resolved]
|
||||
private LadderInfo ladderInfo { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private TournamentGameBase? game { get; set; }
|
||||
|
||||
public TeamRow(TournamentTeam team, TournamentScreen parent)
|
||||
{
|
||||
Model = team;
|
||||
|
||||
Model.FullName.Default = Model.FullName.Value;
|
||||
Model.Acronym.Default = Model.Acronym.Value;
|
||||
Model.FlagName.Default = Model.FlagName.Value;
|
||||
Model.LastYearPlacing.Default = Model.LastYearPlacing.Value;
|
||||
Model.Seed.Default = Model.Seed.Value;
|
||||
|
||||
Masking = true;
|
||||
CornerRadius = 10;
|
||||
|
||||
@ -177,6 +186,22 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
// TournamentGameBase won't be loaded so early, probably binding the event here
|
||||
game?.IsSaveTriggered.BindValueChanged(state =>
|
||||
{
|
||||
if (!state.NewValue) return;
|
||||
|
||||
Model.FullName.Default = Model.FullName.Value;
|
||||
Model.Acronym.Default = Model.Acronym.Value;
|
||||
Model.FlagName.Default = Model.FlagName.Value;
|
||||
Model.LastYearPlacing.Default = Model.LastYearPlacing.Value;
|
||||
Model.Seed.Default = Model.Seed.Value;
|
||||
});
|
||||
}
|
||||
|
||||
private partial class LastYearPlacementSlider : RoundedSliderBar<int>
|
||||
{
|
||||
public override LocalisableString TooltipText => Current.Value == 0 ? "N/A" : base.TooltipText;
|
||||
@ -283,7 +308,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
playerId.Value = user.OnlineID;
|
||||
playerId.Default = playerId.Value = user.OnlineID;
|
||||
playerId.BindValueChanged(id =>
|
||||
{
|
||||
user.OnlineID = id.NewValue ?? 0;
|
||||
@ -299,6 +324,13 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
|
||||
game.PopulatePlayer(user, updatePanel, updatePanel);
|
||||
}, true);
|
||||
|
||||
game.IsSaveTriggered.BindValueChanged(state =>
|
||||
{
|
||||
if (!state.NewValue) return;
|
||||
|
||||
playerId.Default = playerId.Value;
|
||||
});
|
||||
}
|
||||
|
||||
private void updatePanel() => Scheduler.AddOnce(() =>
|
||||
|
@ -63,6 +63,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
|
||||
{
|
||||
LabelText = "Show specific team",
|
||||
Current = currentTeam,
|
||||
ShowsDefaultIndicator = false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
@ -36,6 +37,8 @@ namespace osu.Game.Tournament
|
||||
private FileBasedIPC ipc = null!;
|
||||
private BeatmapLookupCache beatmapCache = null!;
|
||||
|
||||
public BindableBool IsSaveTriggered = new BindableBool(false);
|
||||
|
||||
protected Task BracketLoadTask => bracketLoadTaskCompletionSource.Task;
|
||||
|
||||
private readonly TaskCompletionSource<bool> bracketLoadTaskCompletionSource = new TaskCompletionSource<bool>();
|
||||
@ -329,7 +332,9 @@ namespace osu.Game.Tournament
|
||||
return;
|
||||
}
|
||||
|
||||
IsSaveTriggered.Value = true;
|
||||
saveChanges();
|
||||
IsSaveTriggered.Value = false;
|
||||
}
|
||||
|
||||
private void saveChanges()
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
@ -10,7 +11,9 @@ using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osu.Game.Utils;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
{
|
||||
@ -19,6 +22,9 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> gameBeatmap { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
|
||||
|
||||
private readonly Room room;
|
||||
|
||||
public PlaylistsReadyButton(Room room)
|
||||
@ -63,14 +69,14 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Enabled.Value = hasRemainingAttempts && enoughTimeLeft;
|
||||
Enabled.Value = hasRemainingAttempts && enoughTimeLeft();
|
||||
}
|
||||
|
||||
public override LocalisableString TooltipText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!enoughTimeLeft)
|
||||
if (!enoughTimeLeft())
|
||||
return "No time left!";
|
||||
|
||||
if (!hasRemainingAttempts)
|
||||
@ -80,9 +86,17 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
}
|
||||
}
|
||||
|
||||
private bool enoughTimeLeft =>
|
||||
// This should probably consider the length of the currently selected item, rather than a constant 30 seconds.
|
||||
room.EndDate != null && DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(gameBeatmap.Value.Track.Length) < room.EndDate;
|
||||
private bool enoughTimeLeft()
|
||||
{
|
||||
double rate = ModUtils.CalculateRateWithMods(mods.Value);
|
||||
|
||||
// We want to avoid users not being able to submit scores if they chose to not skip,
|
||||
// so track length is chosen over playable length.
|
||||
double trackLength = Math.Round(gameBeatmap.Value.Track.Length / rate);
|
||||
|
||||
// Additional 30 second delay added to account for load and/or submit time.
|
||||
return room.EndDate != null && DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(trackLength) < room.EndDate;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
|
@ -401,7 +401,6 @@ namespace osu.Game.Screens.Select
|
||||
if (beatmap == null || bpmLabelContainer == null)
|
||||
return;
|
||||
|
||||
// this doesn't consider mods which apply variable rates, yet.
|
||||
double rate = ModUtils.CalculateRateWithMods(mods.Value);
|
||||
|
||||
int bpmMax = FormatUtils.RoundBPM(beatmap.ControlPointInfo.BPMMaximum, rate);
|
||||
|
@ -286,6 +286,7 @@ namespace osu.Game.Utils
|
||||
{
|
||||
double rate = 1;
|
||||
|
||||
// TODO: This doesn't consider mods which apply variable rates, yet.
|
||||
foreach (var mod in mods.OfType<IApplicableToRate>())
|
||||
rate = mod.ApplyToRate(0, rate);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user