mirror of https://github.com/ppy/osu
Populate beatmaps with api information when not present
This commit is contained in:
parent
61083190d0
commit
3a5af47ee8
|
@ -3,8 +3,13 @@
|
|||
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tournament.Screens.Ladder.Components;
|
||||
|
||||
|
@ -14,10 +19,35 @@ public abstract class LadderTestCase : OsuTestCase
|
|||
{
|
||||
protected LadderInfo Ladder;
|
||||
|
||||
protected LadderTestCase()
|
||||
[Resolved]
|
||||
private APIAccess api { get; set; } = null;
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; } = null;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Ladder = File.Exists(@"bracket.json") ? JsonConvert.DeserializeObject<LadderInfo>(File.ReadAllText(@"bracket.json")) : new LadderInfo();
|
||||
|
||||
bool addedInfo = false;
|
||||
|
||||
foreach (var g in Ladder.Groupings)
|
||||
foreach (var b in g.Beatmaps)
|
||||
{
|
||||
if (b.BeatmapInfo == null)
|
||||
{
|
||||
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
|
||||
req.Success += i => b.BeatmapInfo = i.ToBeatmap(rulesets);
|
||||
req.Perform(api);
|
||||
|
||||
addedInfo = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (addedInfo)
|
||||
SaveChanges();
|
||||
|
||||
Add(new OsuButton
|
||||
{
|
||||
Text = "Save Changes",
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
@ -37,6 +38,11 @@ public TestCaseGroupingManager()
|
|||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
foreach (var g in Ladder.Groupings)
|
||||
items.Add(new GroupingRow(g));
|
||||
}
|
||||
|
|
|
@ -11,9 +11,10 @@ namespace osu.Game.Tournament.Tests
|
|||
public class TestCaseLadderManager : LadderTestCase
|
||||
{
|
||||
[Cached]
|
||||
private readonly LadderManager manager;
|
||||
private LadderManager manager;
|
||||
|
||||
public TestCaseLadderManager()
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Add(new OsuContextMenuContainer
|
||||
{
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Screens.Ladder.Components;
|
||||
|
||||
|
@ -12,7 +12,8 @@ namespace osu.Game.Tournament.Tests
|
|||
{
|
||||
public class TestCaseMapPool : LadderTestCase
|
||||
{
|
||||
public TestCaseMapPool()
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
var round = Ladder.Groupings.First(g => g.Name == "Finals");
|
||||
|
||||
|
@ -22,10 +23,10 @@ public TestCaseMapPool()
|
|||
|
||||
public class MapPoolScreen : CompositeDrawable
|
||||
{
|
||||
private readonly FillFlowContainer maps;
|
||||
|
||||
public MapPoolScreen(TournamentGrouping round)
|
||||
{
|
||||
FillFlowContainer maps;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
maps = new FillFlowContainer
|
||||
|
@ -35,8 +36,8 @@ public MapPoolScreen(TournamentGrouping round)
|
|||
},
|
||||
};
|
||||
|
||||
//foreach (var b in round.Beatmaps)
|
||||
// maps.Add(new TournamentBeatmapPanel(new BeatmapInfo() { OnlineBeatmapID = b.ID }));
|
||||
foreach (var b in round.Beatmaps)
|
||||
maps.Add(new TournamentBeatmapPanel(b.BeatmapInfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Tournament.Screens.TeamIntro;
|
||||
|
||||
namespace osu.Game.Tournament.Tests
|
||||
{
|
||||
public class TestCaseTeamIntro : LadderTestCase
|
||||
{
|
||||
public TestCaseTeamIntro()
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
var team1 = Ladder.Teams.First(t => t.Acronym == "USA");
|
||||
var team2 = Ladder.Teams.First(t => t.Acronym == "JPN");
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Beatmaps;
|
||||
|
||||
namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
public class GroupingBeatmap
|
||||
{
|
||||
public int ID;
|
||||
public string Mods;
|
||||
|
||||
public BeatmapInfo BeatmapInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -666,6 +666,7 @@ Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/maste
|
|||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAlwaysTreatStructAsNotReorderableMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
|
|
Loading…
Reference in New Issue