1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-12 07:52:57 +08:00

Merge branch 'master' into spinner-judgement-fix

This commit is contained in:
Roxie Wattz 2021-10-25 16:08:55 -07:00 committed by GitHub
commit b1d60779aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 220 additions and 121 deletions

View File

@ -0,0 +1,65 @@
// 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 Newtonsoft.Json;
using NUnit.Framework;
using osu.Game.Tournament.Models;
namespace osu.Game.Tournament.Tests.NonVisual
{
[TestFixture]
public class LadderInfoSerialisationTest
{
[Test]
public void TestDeserialise()
{
var ladder = createSampleLadder();
string serialised = JsonConvert.SerializeObject(ladder);
JsonConvert.DeserializeObject<LadderInfo>(serialised, new JsonPointConverter());
}
[Test]
public void TestSerialise()
{
var ladder = createSampleLadder();
JsonConvert.SerializeObject(ladder);
}
private static LadderInfo createSampleLadder()
{
var match = TournamentTestScene.CreateSampleMatch();
return new LadderInfo
{
PlayersPerTeam = { Value = 4 },
Teams =
{
match.Team1.Value,
match.Team2.Value,
},
Rounds =
{
new TournamentRound
{
Beatmaps =
{
new RoundBeatmap { BeatmapInfo = TournamentTestScene.CreateSampleBeatmapInfo() },
new RoundBeatmap { BeatmapInfo = TournamentTestScene.CreateSampleBeatmapInfo() },
}
}
},
Matches =
{
match,
},
Progressions =
{
new TournamentProgression(1, 2),
new TournamentProgression(1, 3, true),
}
};
}
}
}

View File

@ -152,7 +152,16 @@ namespace osu.Game.Tournament.Tests
}; };
public static BeatmapInfo CreateSampleBeatmapInfo() => public static BeatmapInfo CreateSampleBeatmapInfo() =>
new BeatmapInfo { Metadata = new BeatmapMetadata { Title = "Test Title", Artist = "Test Artist", ID = RNG.Next(0, 1000000) } }; new BeatmapInfo
{
Metadata = new BeatmapMetadata
{
Title = "Test Title",
Artist = "Test Artist",
ID = RNG.Next(0, 1000000)
},
OnlineInfo = new BeatmapOnlineInfo(),
};
protected override ITestSceneTestRunner CreateRunner() => new TournamentTestSceneTestRunner(); protected override ITestSceneTestRunner CreateRunner() => new TournamentTestSceneTestRunner();

View File

@ -12,6 +12,7 @@ using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Handlers.Mouse; using osu.Framework.Input.Handlers.Mouse;
using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Cursor;
@ -60,7 +61,23 @@ namespace osu.Game.Tournament
loadingSpinner.Show(); loadingSpinner.Show();
BracketLoadTask.ContinueWith(_ => LoadComponentsAsync(new[] BracketLoadTask.ContinueWith(t =>
{
if (t.IsFaulted)
{
Schedule(() =>
{
loadingSpinner.Hide();
loadingSpinner.Expire();
Logger.Error(t.Exception, "Couldn't load bracket with error");
Add(new WarningBox("Your bracket.json file could not be parsed. Please check runtime.log for more details."));
});
return;
}
LoadComponentsAsync(new[]
{ {
new Container new Container
{ {
@ -125,7 +142,8 @@ namespace osu.Game.Tournament
{ {
windowMode.Value = WindowMode.Windowed; windowMode.Value = WindowMode.Windowed;
}), true); }), true);
})); });
});
} }
} }
} }

View File

@ -57,6 +57,8 @@ namespace osu.Game.Tournament
} }
private void readBracket() private void readBracket()
{
try
{ {
if (storage.Exists(bracket_filename)) if (storage.Exists(bracket_filename))
{ {
@ -127,6 +129,12 @@ namespace osu.Game.Tournament
SaveChanges(); SaveChanges();
ladder.CurrentMatch.Value = ladder.Matches.FirstOrDefault(p => p.Current.Value); ladder.CurrentMatch.Value = ladder.Matches.FirstOrDefault(p => p.Current.Value);
}
catch (Exception e)
{
taskCompletionSource.SetException(e);
return;
}
Schedule(() => Schedule(() =>
{ {

View File

@ -237,7 +237,7 @@ namespace osu.Game.Tournament
{ {
Type = type; Type = type;
BackgroundColour = OsuColour.Gray(0.2f); BackgroundColour = OsuColour.Gray(0.2f);
Action = () => RequestSelection(type); Action = () => RequestSelection?.Invoke(type);
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
} }

View File

@ -117,7 +117,6 @@ namespace osu.Game.Beatmaps
[JsonIgnore] [JsonIgnore]
public DateTimeOffset? LastUpdated => OnlineInfo.LastUpdated; public DateTimeOffset? LastUpdated => OnlineInfo.LastUpdated;
[NotMapped]
[JsonIgnore] [JsonIgnore]
public BeatmapSetOnlineStatus Status { get; set; } = BeatmapSetOnlineStatus.None; public BeatmapSetOnlineStatus Status { get; set; } = BeatmapSetOnlineStatus.None;

View File

@ -54,7 +54,7 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"accuracy")] [JsonProperty(@"accuracy")]
private float overallDifficulty { get; set; } private float overallDifficulty { get; set; }
public double Length => lengthInSeconds * 1000; public double Length => TimeSpan.FromSeconds(lengthInSeconds).TotalMilliseconds;
[JsonProperty(@"total_length")] [JsonProperty(@"total_length")]
private double lengthInSeconds { get; set; } private double lengthInSeconds { get; set; }
@ -86,7 +86,7 @@ namespace osu.Game.Online.API.Requests.Responses
OnlineBeatmapID = OnlineID, OnlineBeatmapID = OnlineID,
Version = DifficultyName, Version = DifficultyName,
// this is actually an incorrect mapping (Length is calculated as drain length in lazer's import process, see BeatmapManager.calculateLength). // this is actually an incorrect mapping (Length is calculated as drain length in lazer's import process, see BeatmapManager.calculateLength).
Length = TimeSpan.FromSeconds(Length).TotalMilliseconds, Length = Length,
Status = Status, Status = Status,
MD5Hash = Checksum, MD5Hash = Checksum,
BeatmapSet = set, BeatmapSet = set,