mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Allow running tournament tools from main executable
This commit is contained in:
parent
43c70d354d
commit
9c5eddea54
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
<StartupObject>osu.Desktop.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Label="Project References">
|
||||
<ProjectReference Include="..\osu.Game.Tournament\osu.Game.Tournament.csproj" />
|
||||
<ProjectReference Include="..\osu.Game\osu.Game.csproj" />
|
||||
<ProjectReference Include="..\osu.Game.Rulesets.Osu\osu.Game.Rulesets.Osu.csproj" />
|
||||
<ProjectReference Include="..\osu.Game.Rulesets.Catch\osu.Game.Rulesets.Catch.csproj" />
|
||||
|
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,111 +1,18 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
35
osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs
Normal file
35
osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs
Normal file
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
113
osu.Game.Tournament/Screens/TournamentSceneManager.cs
Normal file
113
osu.Game.Tournament/Screens/TournamentSceneManager.cs
Normal file
@ -0,0 +1,113 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
99
osu.Game.Tournament/TournamentGame.cs
Normal file
99
osu.Game.Tournament/TournamentGame.cs
Normal file
@ -0,0 +1,99 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
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<LadderInfo>(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
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -62,6 +62,8 @@ namespace osu.Game
|
||||
|
||||
protected MenuCursorContainer MenuCursorContainer;
|
||||
|
||||
protected APIAccess API;
|
||||
|
||||
private Container content;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
@ -146,14 +148,14 @@ namespace osu.Game
|
||||
dependencies.Cache(SkinManager = new SkinManager(Host.Storage, contextFactory, Host, Audio));
|
||||
dependencies.CacheAs<ISkinSource>(SkinManager);
|
||||
|
||||
var api = new APIAccess(LocalConfig);
|
||||
API = new APIAccess(LocalConfig);
|
||||
|
||||
dependencies.Cache(api);
|
||||
dependencies.CacheAs<IAPIProvider>(api);
|
||||
dependencies.Cache(API);
|
||||
dependencies.CacheAs<IAPIProvider>(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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user