diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs
index 257155478f..b864cf3c64 100644
--- a/osu.Desktop/Program.cs
+++ b/osu.Desktop/Program.cs
@@ -11,6 +11,7 @@ using osu.Framework.Development;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.IPC;
+using osu.Game.Tournament;
namespace osu.Desktop
{
@@ -45,6 +46,9 @@ namespace osu.Desktop
default:
host.Run(new OsuGameDesktop(args));
break;
+ case "--tournament":
+ host.Run(new TournamentGame());
+ break;
}
}
diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj
index e1e59804e5..a3e7625c44 100644
--- a/osu.Desktop/osu.Desktop.csproj
+++ b/osu.Desktop/osu.Desktop.csproj
@@ -17,6 +17,7 @@
osu.Desktop.Program
+
diff --git a/osu.Game.Tournament.Tests/TestCaseMapPool.cs b/osu.Game.Tournament.Tests/TestCaseMapPool.cs
index e4637b8fc3..1101d2828a 100644
--- a/osu.Game.Tournament.Tests/TestCaseMapPool.cs
+++ b/osu.Game.Tournament.Tests/TestCaseMapPool.cs
@@ -3,12 +3,7 @@
using System.Linq;
using osu.Framework.Allocation;
-using osu.Framework.Graphics;
-using osu.Framework.Graphics.Containers;
-using osu.Game.Screens;
-using osu.Game.Tournament.Components;
-using osu.Game.Tournament.Screens.Ladder.Components;
-using OpenTK;
+using osu.Game.Tournament.Screens.MapPool;
namespace osu.Game.Tournament.Tests
{
@@ -23,30 +18,4 @@ namespace osu.Game.Tournament.Tests
Add(new MapPoolScreen(round));
}
}
-
- public class MapPoolScreen : OsuScreen
- {
- public MapPoolScreen(TournamentGrouping round)
- {
- FillFlowContainer maps;
-
- InternalChildren = new Drawable[]
- {
- maps = new FillFlowContainer
- {
- Spacing = new Vector2(20),
- Padding = new MarginPadding(50),
- Direction = FillDirection.Full,
- RelativeSizeAxes = Axes.Both,
- }
- };
-
- foreach (var b in round.Beatmaps)
- maps.Add(new TournamentBeatmapPanel(b.BeatmapInfo)
- {
- Anchor = Anchor.TopCentre,
- Origin = Anchor.TopCentre,
- });
- }
- }
}
diff --git a/osu.Game.Tournament.Tests/TestCaseSceneManager.cs b/osu.Game.Tournament.Tests/TestCaseSceneManager.cs
index 62e5f77802..9853e31ee3 100644
--- a/osu.Game.Tournament.Tests/TestCaseSceneManager.cs
+++ b/osu.Game.Tournament.Tests/TestCaseSceneManager.cs
@@ -1,111 +1,18 @@
// Copyright (c) 2007-2018 ppy Pty Ltd .
// 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.Framework.Graphics.Shapes;
-using osu.Framework.Graphics.Video;
using osu.Framework.Platform;
-using osu.Game.Graphics.UserInterface;
-using osu.Game.Tournament.Screens.Drawings;
-using osu.Game.Tournament.Screens.Ladder;
-using osu.Game.Tournament.Screens.Showcase;
-using osu.Game.Tournament.Screens.TeamIntro;
-using OpenTK;
-using OpenTK.Graphics;
+using osu.Game.Tournament.Screens;
namespace osu.Game.Tournament.Tests
{
public class TestCaseSceneManager : LadderTestCase
{
- private LadderManager bracket;
- private MapPoolScreen mapPool;
- private TeamIntroScreen teamIntro;
- private DrawingsScreen drawings;
- private Container screens;
- private ShowcaseScreen showcase;
-
[BackgroundDependencyLoader]
private void load(Storage storage)
{
- Children = new Drawable[]
- {
- new Container
- {
- RelativeSizeAxes = Axes.Both,
- Width = 0.2f,
- Children = new Drawable[]
- {
- new Box
- {
- Colour = Color4.Black,
- RelativeSizeAxes = Axes.Both,
- },
- new FillFlowContainer
- {
- RelativeSizeAxes = Axes.Both,
- Direction = FillDirection.Vertical,
- Children = new Drawable[]
- {
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "Drawings", Action = () => setScreen(drawings) },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "Showcase", Action = () => setScreen(showcase) },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "TeamIntro", Action = () => setScreen(teamIntro) },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "MapPool", Action = () => setScreen(mapPool) },
- new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket", Action = () => setScreen(bracket) },
- }
- },
- },
- },
- new Container
- {
- RelativeSizeAxes = Axes.Both,
- RelativePositionAxes = Axes.Both,
- X = 0.2f,
- FillMode = FillMode.Fit,
- FillAspectRatio = 16/9f,
- Anchor = Anchor.TopLeft,
- Origin = Anchor.TopLeft,
- Size = new Vector2(0.8f, 1),
- //Masking = true,
- Children = new Drawable[]
- {
- new VideoSprite(storage.GetStream("BG Logoless - OWC.m4v"))
- {
- Loop = true,
- RelativeSizeAxes = Axes.Both,
- FillMode = FillMode.Fit,
- },
- screens = new Container
- {
- RelativeSizeAxes = Axes.Both,
- Children = new Drawable[]
- {
- bracket = new LadderManager(Ladder),
- showcase = new ShowcaseScreen(),
- mapPool = new MapPoolScreen(Ladder.Groupings.First(g => g.Name == "Finals")),
- teamIntro = new TeamIntroScreen(Ladder.Teams.First(t => t.Acronym == "USA"), Ladder.Teams.First(t => t.Acronym == "JPN"),
- Ladder.Groupings.First(g => g.Name == "Finals")),
- drawings = new DrawingsScreen()
- }
- },
- }
- },
- };
-
- setScreen(teamIntro);
- }
-
- private void setScreen(Drawable screen)
- {
- foreach (var s in screens.Children)
- {
- if (s == screen)
- s.FadeIn(100);
- else
- s.FadeOut(100);
- }
+ Add(new TournamentSceneManager());
}
}
}
diff --git a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs
new file mode 100644
index 0000000000..be7b3a0b3b
--- /dev/null
+++ b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs
@@ -0,0 +1,35 @@
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Game.Screens;
+using osu.Game.Tournament.Components;
+using osu.Game.Tournament.Screens.Ladder.Components;
+using OpenTK;
+
+namespace osu.Game.Tournament.Screens.MapPool
+{
+ public class MapPoolScreen : OsuScreen
+ {
+ public MapPoolScreen(TournamentGrouping round)
+ {
+ FillFlowContainer maps;
+
+ InternalChildren = new Drawable[]
+ {
+ maps = new FillFlowContainer
+ {
+ Spacing = new Vector2(20),
+ Padding = new MarginPadding(50),
+ Direction = FillDirection.Full,
+ RelativeSizeAxes = Axes.Both,
+ }
+ };
+
+ foreach (var b in round.Beatmaps)
+ maps.Add(new TournamentBeatmapPanel(b.BeatmapInfo)
+ {
+ Anchor = Anchor.TopCentre,
+ Origin = Anchor.TopCentre,
+ });
+ }
+ }
+}
diff --git a/osu.Game.Tournament/Screens/TournamentSceneManager.cs b/osu.Game.Tournament/Screens/TournamentSceneManager.cs
new file mode 100644
index 0000000000..82f17a85c4
--- /dev/null
+++ b/osu.Game.Tournament/Screens/TournamentSceneManager.cs
@@ -0,0 +1,113 @@
+// Copyright (c) 2007-2018 ppy Pty Ltd .
+// 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.Framework.Graphics.Shapes;
+using osu.Framework.Graphics.Video;
+using osu.Framework.Platform;
+using osu.Game.Graphics.UserInterface;
+using osu.Game.Screens;
+using osu.Game.Tournament.Screens.Drawings;
+using osu.Game.Tournament.Screens.Ladder;
+using osu.Game.Tournament.Screens.Ladder.Components;
+using osu.Game.Tournament.Screens.MapPool;
+using osu.Game.Tournament.Screens.Showcase;
+using osu.Game.Tournament.Screens.TeamIntro;
+using OpenTK;
+using OpenTK.Graphics;
+
+namespace osu.Game.Tournament.Screens
+{
+ public class TournamentSceneManager : OsuScreen
+ {
+ private LadderManager bracket;
+ private MapPoolScreen mapPool;
+ private TeamIntroScreen teamIntro;
+ private DrawingsScreen drawings;
+ private Container screens;
+ private ShowcaseScreen showcase;
+
+ [BackgroundDependencyLoader]
+ private void load(LadderInfo ladder, Storage storage)
+ {
+ Children = new Drawable[]
+ {
+ new Container
+ {
+ RelativeSizeAxes = Axes.Y,
+ Width = 200,
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ Colour = Color4.Black,
+ RelativeSizeAxes = Axes.Both,
+ },
+ new FillFlowContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ Direction = FillDirection.Vertical,
+ Children = new Drawable[]
+ {
+ new OsuButton { RelativeSizeAxes = Axes.X, Text = "Drawings", Action = () => setScreen(drawings) },
+ new OsuButton { RelativeSizeAxes = Axes.X, Text = "Showcase", Action = () => setScreen(showcase) },
+ new OsuButton { RelativeSizeAxes = Axes.X, Text = "TeamIntro", Action = () => setScreen(teamIntro) },
+ new OsuButton { RelativeSizeAxes = Axes.X, Text = "MapPool", Action = () => setScreen(mapPool) },
+ new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket", Action = () => setScreen(bracket) },
+ }
+ },
+ },
+ },
+ new Container
+ {
+ RelativeSizeAxes = Axes.Both,
+ X = 200,
+ FillMode = FillMode.Fit,
+ FillAspectRatio = 16/9f,
+ Anchor = Anchor.TopLeft,
+ Origin = Anchor.TopLeft,
+ Size = new Vector2(0.8f, 1),
+ //Masking = true,
+ Children = new Drawable[]
+ {
+ new VideoSprite(storage.GetStream("BG Logoless - OWC.m4v"))
+ {
+ Loop = true,
+ RelativeSizeAxes = Axes.Both,
+ FillMode = FillMode.Fit,
+ },
+ screens = new Container
+ {
+ RelativeSizeAxes = Axes.Both,
+ Children = new Drawable[]
+ {
+ bracket = new LadderManager(ladder),
+ showcase = new ShowcaseScreen(),
+ mapPool = new MapPoolScreen(ladder.Groupings.First(g => g.Name == "Finals")),
+ teamIntro = new TeamIntroScreen(ladder.Teams.First(t => t.Acronym == "USA"), ladder.Teams.First(t => t.Acronym == "JPN"),
+ ladder.Groupings.First(g => g.Name == "Finals")),
+ drawings = new DrawingsScreen()
+ }
+ },
+ }
+ },
+ };
+
+ setScreen(teamIntro);
+ }
+
+ private void setScreen(Drawable screen)
+ {
+ foreach (var s in screens.Children)
+ {
+ if (s == screen)
+ s.FadeIn(100);
+ else
+ s.FadeOut(100);
+ }
+ }
+ }
+}
diff --git a/osu.Game.Tournament/TournamentGame.cs b/osu.Game.Tournament/TournamentGame.cs
new file mode 100644
index 0000000000..1bbbfdc37a
--- /dev/null
+++ b/osu.Game.Tournament/TournamentGame.cs
@@ -0,0 +1,99 @@
+// Copyright (c) 2007-2018 ppy Pty Ltd .
+// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
+
+using System.IO;
+using Newtonsoft.Json;
+using osu.Framework.Allocation;
+using osu.Framework.Configuration;
+using osu.Framework.Graphics;
+using osu.Framework.Platform;
+using osu.Game.Beatmaps;
+using osu.Game.Graphics.UserInterface;
+using osu.Game.Online.API.Requests;
+using osu.Game.Rulesets;
+using osu.Game.Tournament.Screens;
+using osu.Game.Tournament.Screens.Ladder.Components;
+
+namespace osu.Game.Tournament
+{
+ public class TournamentGame : OsuGameBase
+ {
+ private const string bracket_filename = "bracket.json";
+
+ protected LadderInfo Ladder;
+ private Storage storage;
+
+ private DependencyContainer dependencies;
+
+ [Cached]
+ private readonly Bindable ruleset = new Bindable();
+
+ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
+
+ [BackgroundDependencyLoader]
+ private void load(Storage storage)
+ {
+ this.storage = storage;
+
+ string content = null;
+ if (storage.Exists(bracket_filename))
+ {
+ using (Stream stream = storage.GetStream(bracket_filename, FileAccess.Read, FileMode.Open))
+ using (var sr = new StreamReader(stream))
+ content = sr.ReadToEnd();
+ }
+
+ Ladder = content != null ? JsonConvert.DeserializeObject(content) : new LadderInfo();
+ dependencies.Cache(Ladder);
+
+ 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(RulesetStore);
+ req.Perform(API);
+
+ addedInfo = true;
+ }
+ }
+
+ if (addedInfo)
+ SaveChanges();
+
+ Add(new OsuButton
+ {
+ Text = "Save Changes",
+ Width = 140,
+ Height = 50,
+ Anchor = Anchor.BottomRight,
+ Origin = Anchor.BottomRight,
+ Padding = new MarginPadding(10),
+ Action = SaveChanges,
+ });
+ }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+ Add(new TournamentSceneManager());
+ }
+
+ protected virtual void SaveChanges()
+ {
+ using (var stream = storage.GetStream(bracket_filename, FileAccess.Write, FileMode.Create))
+ using (var sw = new StreamWriter(stream))
+ {
+ sw.Write(JsonConvert.SerializeObject(Ladder,
+ new JsonSerializerSettings
+ {
+ NullValueHandling = NullValueHandling.Ignore,
+ DefaultValueHandling = DefaultValueHandling.Ignore
+ }));
+ }
+ }
+ }
+}
diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs
index 73c970ce5d..ea1dbfa369 100644
--- a/osu.Game/OsuGameBase.cs
+++ b/osu.Game/OsuGameBase.cs
@@ -62,6 +62,8 @@ namespace osu.Game
protected MenuCursorContainer MenuCursorContainer;
+ protected APIAccess API;
+
private Container content;
protected override Container Content => content;
@@ -146,14 +148,14 @@ namespace osu.Game
dependencies.Cache(SkinManager = new SkinManager(Host.Storage, contextFactory, Host, Audio));
dependencies.CacheAs(SkinManager);
- var api = new APIAccess(LocalConfig);
+ API = new APIAccess(LocalConfig);
- dependencies.Cache(api);
- dependencies.CacheAs(api);
+ dependencies.Cache(API);
+ dependencies.CacheAs(API);
dependencies.Cache(RulesetStore = new RulesetStore(contextFactory));
dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage));
- dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, contextFactory, RulesetStore, api, Audio, Host));
+ dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, contextFactory, RulesetStore, API, Audio, Host));
dependencies.Cache(ScoreStore = new ScoreStore(contextFactory, Host, BeatmapManager, RulesetStore));
dependencies.Cache(KeyBindingStore = new KeyBindingStore(contextFactory, RulesetStore));
dependencies.Cache(SettingsStore = new SettingsStore(contextFactory));
@@ -177,7 +179,7 @@ namespace osu.Game
FileStore.Cleanup();
- AddInternal(api);
+ AddInternal(API);
GlobalActionContainer globalBinding;