mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Merge branch 'tournament-ladder-parsing' into move-online-beatmap-metrics
This commit is contained in:
commit
4dafe666ba
@ -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),
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tournament.IO;
|
||||
@ -152,7 +153,16 @@ namespace osu.Game.Tournament.Tests
|
||||
};
|
||||
|
||||
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();
|
||||
|
||||
|
@ -12,6 +12,7 @@ using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Handlers.Mouse;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
@ -60,7 +61,23 @@ namespace osu.Game.Tournament
|
||||
|
||||
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
|
||||
{
|
||||
@ -125,7 +142,8 @@ namespace osu.Game.Tournament
|
||||
{
|
||||
windowMode.Value = WindowMode.Windowed;
|
||||
}), true);
|
||||
}));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ namespace osu.Game.Tournament
|
||||
}
|
||||
|
||||
private void readBracket()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (storage.Exists(bracket_filename))
|
||||
{
|
||||
@ -127,6 +129,12 @@ namespace osu.Game.Tournament
|
||||
SaveChanges();
|
||||
|
||||
ladder.CurrentMatch.Value = ladder.Matches.FirstOrDefault(p => p.Current.Value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
taskCompletionSource.SetException(e);
|
||||
return;
|
||||
}
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
|
@ -237,7 +237,7 @@ namespace osu.Game.Tournament
|
||||
{
|
||||
Type = type;
|
||||
BackgroundColour = OsuColour.Gray(0.2f);
|
||||
Action = () => RequestSelection(type);
|
||||
Action = () => RequestSelection?.Invoke(type);
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user