Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to switch tournaments to the SetupScreen #11118

Merged
merged 16 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add tournament switching in the UI
  • Loading branch information
MiraiSubject committed Dec 7, 2020
commit eda6e1fbddb46b9eec3a33a1417581154645ff8a
18 changes: 18 additions & 0 deletions osu.Game.Tournament/IO/TournamentStorage.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// 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 osu.Framework.Bindables;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.IO;
using System.IO;
using System.Collections.Generic;
using osu.Game.Tournament.Configuration;

namespace osu.Game.Tournament.IO
Expand All @@ -13,12 +15,15 @@ public class TournamentStorage : MigratableStorage
{
private const string default_tournament = "default";
private readonly Storage storage;
private readonly Storage allTournaments;
peppy marked this conversation as resolved.
Show resolved Hide resolved
private readonly TournamentStorageManager storageConfig;
public readonly Bindable<string> CurrentTournament;

public TournamentStorage(Storage storage)
: base(storage.GetStorageForDirectory("tournaments"), string.Empty)
{
this.storage = storage;
allTournaments = UnderlyingStorage;

storageConfig = new TournamentStorageManager(storage);

Expand All @@ -29,9 +34,22 @@ public TournamentStorage(Storage storage)
else
Migrate(UnderlyingStorage.GetStorageForDirectory(default_tournament));

CurrentTournament = new Bindable<string>(storageConfig.Get<string>(StorageConfig.CurrentTournament));
MiraiSubject marked this conversation as resolved.
Show resolved Hide resolved
Logger.Log("Using tournament storage: " + GetFullPath(string.Empty));

CurrentTournament.BindValueChanged(updateTournament, false);
MiraiSubject marked this conversation as resolved.
Show resolved Hide resolved
}

private void updateTournament(ValueChangedEvent<string> newTournament)
{
ChangeTargetStorage(allTournaments.GetStorageForDirectory(newTournament.NewValue));
Logger.Log("Changing tournament storage: " + GetFullPath(string.Empty));
storageConfig.Set(StorageConfig.CurrentTournament, newTournament.NewValue);
storageConfig.Save();
}

public IEnumerable<string> ListTournaments() => allTournaments.GetDirectories(string.Empty);

public override void Migrate(Storage newStorage)
{
// this migration only happens once on moving to the per-tournament storage system.
Expand Down
13 changes: 13 additions & 0 deletions osu.Game.Tournament/Screens/SetupScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Platform;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Tournament.IO;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Rulesets;
Expand Down Expand Up @@ -40,6 +42,9 @@ public class SetupScreen : TournamentScreen, IProvideVideo
[Resolved]
private RulesetStore rulesets { get; set; }

[Resolved]
private Storage storage { get; set; }
MiraiSubject marked this conversation as resolved.
Show resolved Hide resolved

[Resolved(canBeNull: true)]
private TournamentSceneManager sceneManager { get; set; }

Expand Down Expand Up @@ -70,6 +75,7 @@ private void load(FrameworkConfigManager frameworkConfig)
private void reload()
{
var fileBasedIpc = ipc as FileBasedIPC;
var tourneyStorage = storage as TournamentStorage;
fillFlow.Children = new Drawable[]
{
new ActionableInfo
Expand Down Expand Up @@ -111,6 +117,13 @@ private void reload()
Items = rulesets.AvailableRulesets,
Current = LadderInfo.Ruleset,
},
new LabelledDropdown<string>
{
Label = "Current tournament",
Description = "Changes the background videos and bracket to match the selected tournament. This requires a restart after selecting to apply changes.",
Items = tourneyStorage?.ListTournaments(),
Current = tourneyStorage?.CurrentTournament,
},
resolution = new ResolutionSelector
{
Label = "Stream area resolution",
Expand Down