1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 00:42:55 +08:00

Merge branch 'master' into fix-taiko-alignment

This commit is contained in:
Dean Herbert 2023-07-28 16:32:37 +09:00
commit d26164e9fe
11 changed files with 98 additions and 45 deletions

View File

@ -21,9 +21,11 @@ using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
using osu.Game.Tests.Resources; using osu.Game.Tests.Resources;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Gameplay namespace osu.Game.Tests.Visual.Gameplay
{ {
@ -147,6 +149,38 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("score in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) != null)); AddUntilStep("score in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) != null));
} }
[Test]
public void TestReplayExport()
{
CreateTest();
AddUntilStep("wait for track to start running", () => Beatmap.Value.Track.IsRunning);
AddStep("seek to completion", () => Player.GameplayClockContainer.Seek(Player.DrawableRuleset.Objects.Last().GetEndTime()));
AddUntilStep("results displayed", () => (Player.GetChildScreen() as ResultsScreen)?.IsLoaded == true);
AddUntilStep("score in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) != null));
AddUntilStep("wait for button clickable", () => ((OsuScreen)Player.GetChildScreen())
.ChildrenOfType<ReplayDownloadButton>().FirstOrDefault()?
.ChildrenOfType<OsuClickableContainer>().FirstOrDefault()?
.Enabled.Value == true);
AddAssert("no export files", () => !LocalStorage.GetFiles("exports").Any());
AddStep("Export replay", () => InputManager.PressKey(Key.F2));
string? filePath = null;
// Files starting with _ are temporary, created by CreateFileSafely call.
AddUntilStep("wait for export file", () => filePath = LocalStorage.GetFiles("exports").SingleOrDefault(f => !f.StartsWith("_", StringComparison.Ordinal)), () => Is.Not.Null);
AddAssert("filesize is non-zero", () =>
{
using (var stream = LocalStorage.GetStream(filePath))
return stream.Length;
}, () => Is.Not.Zero);
}
[Test] [Test]
public void TestScoreStoredLocallyCustomRuleset() public void TestScoreStoredLocallyCustomRuleset()
{ {

View File

@ -542,7 +542,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("clear search", () => modSelectOverlay.SearchTerm = string.Empty); AddStep("clear search", () => modSelectOverlay.SearchTerm = string.Empty);
AddStep("press enter", () => InputManager.Key(Key.Enter)); AddStep("press enter", () => InputManager.Key(Key.Enter));
AddAssert("mod select still visible", () => modSelectOverlay.State.Value == Visibility.Visible); AddAssert("mod select hidden", () => modSelectOverlay.State.Value == Visibility.Hidden);
} }
[Test] [Test]

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq; using System.Linq;
@ -11,6 +9,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -21,19 +20,18 @@ namespace osu.Game.Tournament.Components
{ {
public partial class TournamentBeatmapPanel : CompositeDrawable public partial class TournamentBeatmapPanel : CompositeDrawable
{ {
public readonly TournamentBeatmap Beatmap; public readonly TournamentBeatmap? Beatmap;
private readonly string mod; private readonly string mod;
public const float HEIGHT = 50; public const float HEIGHT = 50;
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>(); private readonly Bindable<TournamentMatch?> currentMatch = new Bindable<TournamentMatch?>();
private Box flash;
public TournamentBeatmapPanel(TournamentBeatmap beatmap, string mod = null) private Box flash = null!;
public TournamentBeatmapPanel(TournamentBeatmap? beatmap, string mod = "")
{ {
ArgumentNullException.ThrowIfNull(beatmap);
Beatmap = beatmap; Beatmap = beatmap;
this.mod = mod; this.mod = mod;
@ -73,7 +71,7 @@ namespace osu.Game.Tournament.Components
{ {
new TournamentSpriteText new TournamentSpriteText
{ {
Text = Beatmap.GetDisplayTitleRomanisable(false, false), Text = Beatmap?.GetDisplayTitleRomanisable(false, false) ?? (LocalisableString)@"unknown",
Font = OsuFont.Torus.With(weight: FontWeight.Bold), Font = OsuFont.Torus.With(weight: FontWeight.Bold),
}, },
new FillFlowContainer new FillFlowContainer
@ -90,7 +88,7 @@ namespace osu.Game.Tournament.Components
}, },
new TournamentSpriteText new TournamentSpriteText
{ {
Text = Beatmap.Metadata.Author.Username, Text = Beatmap?.Metadata.Author.Username ?? "unknown",
Padding = new MarginPadding { Right = 20 }, Padding = new MarginPadding { Right = 20 },
Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14) Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14)
}, },
@ -102,7 +100,7 @@ namespace osu.Game.Tournament.Components
}, },
new TournamentSpriteText new TournamentSpriteText
{ {
Text = Beatmap.DifficultyName, Text = Beatmap?.DifficultyName ?? "unknown",
Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14) Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14)
}, },
} }
@ -131,36 +129,37 @@ namespace osu.Game.Tournament.Components
} }
} }
private void matchChanged(ValueChangedEvent<TournamentMatch> match) private void matchChanged(ValueChangedEvent<TournamentMatch?> match)
{ {
if (match.OldValue != null) if (match.OldValue != null)
match.OldValue.PicksBans.CollectionChanged -= picksBansOnCollectionChanged; match.OldValue.PicksBans.CollectionChanged -= picksBansOnCollectionChanged;
match.NewValue.PicksBans.CollectionChanged += picksBansOnCollectionChanged; if (match.NewValue != null)
match.NewValue.PicksBans.CollectionChanged += picksBansOnCollectionChanged;
updateState(); updateState();
} }
private void picksBansOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) private void picksBansOnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
=> updateState(); => updateState();
private BeatmapChoice choice; private BeatmapChoice? choice;
private void updateState() private void updateState()
{ {
var found = currentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == Beatmap.OnlineID); var newChoice = currentMatch.Value?.PicksBans.FirstOrDefault(p => p.BeatmapID == Beatmap?.OnlineID);
bool doFlash = found != choice; bool shouldFlash = newChoice != choice;
choice = found;
if (found != null) if (newChoice != null)
{ {
if (doFlash) if (shouldFlash)
flash?.FadeOutFromOne(500).Loop(0, 10); flash.FadeOutFromOne(500).Loop(0, 10);
BorderThickness = 6; BorderThickness = 6;
BorderColour = TournamentGame.GetTeamColour(found.Team); BorderColour = TournamentGame.GetTeamColour(newChoice.Team);
switch (found.Type) switch (newChoice.Type)
{ {
case ChoiceType.Pick: case ChoiceType.Pick:
Colour = Color4.White; Colour = Color4.White;
@ -179,6 +178,8 @@ namespace osu.Game.Tournament.Components
BorderThickness = 0; BorderThickness = 0;
Alpha = 1; Alpha = 1;
} }
choice = newChoice;
} }
private partial class NoUnloadBeatmapSetCover : UpdateableOnlineBeatmapSetCover private partial class NoUnloadBeatmapSetCover : UpdateableOnlineBeatmapSetCover

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using Newtonsoft.Json; using Newtonsoft.Json;
namespace osu.Game.Tournament.Models namespace osu.Game.Tournament.Models
@ -10,9 +8,10 @@ namespace osu.Game.Tournament.Models
public class RoundBeatmap public class RoundBeatmap
{ {
public int ID; public int ID;
public string Mods;
public string Mods = string.Empty;
[JsonProperty("BeatmapInfo")] [JsonProperty("BeatmapInfo")]
public TournamentBeatmap Beatmap; public TournamentBeatmap? Beatmap;
} }
} }

View File

@ -139,9 +139,11 @@ namespace osu.Game.Tournament.Screens.Editors
public void CreateNew() public void CreateNew()
{ {
var user = new RoundBeatmap(); var b = new RoundBeatmap();
round.Beatmaps.Add(user);
flow.Add(new RoundBeatmapRow(round, user)); round.Beatmaps.Add(b);
flow.Add(new RoundBeatmapRow(round, b));
} }
public partial class RoundBeatmapRow : CompositeDrawable public partial class RoundBeatmapRow : CompositeDrawable

View File

@ -165,11 +165,11 @@ namespace osu.Game.Tournament.Screens.MapPool
if (map != null) if (map != null)
{ {
if (e.Button == MouseButton.Left && map.Beatmap.OnlineID > 0) if (e.Button == MouseButton.Left && map.Beatmap?.OnlineID > 0)
addForBeatmap(map.Beatmap.OnlineID); addForBeatmap(map.Beatmap.OnlineID);
else else
{ {
var existing = CurrentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == map.Beatmap.OnlineID); var existing = CurrentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == map.Beatmap?.OnlineID);
if (existing != null) if (existing != null)
{ {
@ -195,7 +195,7 @@ namespace osu.Game.Tournament.Screens.MapPool
if (CurrentMatch.Value == null) if (CurrentMatch.Value == null)
return; return;
if (CurrentMatch.Value.Round.Value.Beatmaps.All(b => b.Beatmap.OnlineID != beatmapId)) if (CurrentMatch.Value.Round.Value.Beatmaps.All(b => b.Beatmap?.OnlineID != beatmapId))
// don't attempt to add if the beatmap isn't in our pool // don't attempt to add if the beatmap isn't in our pool
return; return;

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Overlays; using osu.Game.Overlays;
@ -57,14 +58,18 @@ namespace osu.Game.Tournament.Screens.Setup
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.2f), Colour = OsuColour.Gray(0.2f),
}, },
fillFlow = new FillFlowContainer new OsuScrollContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.Both,
AutoSizeAxes = Axes.Y, Child = fillFlow = new FillFlowContainer
Direction = FillDirection.Vertical, {
Padding = new MarginPadding(10), RelativeSizeAxes = Axes.X,
Spacing = new Vector2(10), AutoSizeAxes = Axes.Y,
} Direction = FillDirection.Vertical,
Padding = new MarginPadding(10),
Spacing = new Vector2(10),
},
},
}; };
api.LocalUser.BindValueChanged(_ => Schedule(reload)); api.LocalUser.BindValueChanged(_ => Schedule(reload));

View File

@ -19,7 +19,6 @@ using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online; using osu.Game.Online;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Tournament.IO; using osu.Game.Tournament.IO;
using osu.Game.Tournament.IPC; using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
@ -236,7 +235,7 @@ namespace osu.Game.Tournament
{ {
var beatmapsRequiringPopulation = ladder.Rounds var beatmapsRequiringPopulation = ladder.Rounds
.SelectMany(r => r.Beatmaps) .SelectMany(r => r.Beatmaps)
.Where(b => b.Beatmap?.OnlineID == 0 && b.ID > 0).ToList(); .Where(b => (b.Beatmap == null || b.Beatmap?.OnlineID == 0) && b.ID > 0).ToList();
if (beatmapsRequiringPopulation.Count == 0) if (beatmapsRequiringPopulation.Count == 0)
return false; return false;
@ -245,7 +244,9 @@ namespace osu.Game.Tournament
{ {
var b = beatmapsRequiringPopulation[i]; var b = beatmapsRequiringPopulation[i];
b.Beatmap = new TournamentBeatmap(await beatmapCache.GetBeatmapAsync(b.ID).ConfigureAwait(false) ?? new APIBeatmap()); var populated = await beatmapCache.GetBeatmapAsync(b.ID).ConfigureAwait(false);
if (populated != null)
b.Beatmap = new TournamentBeatmap(populated);
updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})"); updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
} }
@ -270,7 +271,9 @@ namespace osu.Game.Tournament
{ {
var b = beatmapsRequiringPopulation[i]; var b = beatmapsRequiringPopulation[i];
b.Beatmap = new TournamentBeatmap(await beatmapCache.GetBeatmapAsync(b.ID).ConfigureAwait(false) ?? new APIBeatmap()); var populated = await beatmapCache.GetBeatmapAsync(b.ID).ConfigureAwait(false);
if (populated != null)
b.Beatmap = new TournamentBeatmap(populated);
updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})"); updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
} }

View File

@ -638,8 +638,12 @@ namespace osu.Game.Overlays.Mods
case GlobalAction.Select: case GlobalAction.Select:
{ {
// Pressing select should select first filtered mod if a search is in progress. // Pressing select should select first filtered mod if a search is in progress.
// If there is no search in progress, it should exit the dialog (a bit weird, but this is the expectation from stable).
if (string.IsNullOrEmpty(SearchTerm)) if (string.IsNullOrEmpty(SearchTerm))
{
hideOverlay(true);
return true; return true;
}
ModState? firstMod = columnFlow.Columns.OfType<ModColumn>().FirstOrDefault(m => m.IsPresent)?.AvailableMods.FirstOrDefault(x => x.Visible); ModState? firstMod = columnFlow.Columns.OfType<ModColumn>().FirstOrDefault(m => m.IsPresent)?.AvailableMods.FirstOrDefault(x => x.Visible);

View File

@ -22,6 +22,7 @@ using osu.Framework.Threading;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Extensions; using osu.Game.Extensions;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.IO.Archives; using osu.Game.IO.Archives;
@ -1170,6 +1171,7 @@ namespace osu.Game.Screens.Play
// because of the clone above, it's required that we copy back the post-import hash/ID to use for availability matching. // because of the clone above, it's required that we copy back the post-import hash/ID to use for availability matching.
score.ScoreInfo.Hash = s.Hash; score.ScoreInfo.Hash = s.Hash;
score.ScoreInfo.ID = s.ID; score.ScoreInfo.ID = s.ID;
score.ScoreInfo.Files.AddRange(s.Files.Detach());
}); });
return Task.CompletedTask; return Task.CompletedTask;

View File

@ -107,6 +107,9 @@ namespace osu.Game.Screens.Ranking
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e) public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{ {
if (e.Repeat)
return false;
switch (e.Action) switch (e.Action)
{ {
case GlobalAction.SaveReplay: case GlobalAction.SaveReplay: