1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-30 19:32:54 +08:00
osu-lazer/osu.Game.Tournament/IO/TournamentStorage.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.8 KiB
C#
Raw Normal View History

// 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 System;
using System.Collections.Generic;
using System.Linq;
2020-12-07 20:11:13 +08:00
using osu.Framework.Bindables;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.IO;
using osu.Game.Tournament.Configuration;
namespace osu.Game.Tournament.IO
{
public class TournamentStorage : WrappedStorage
{
/// <summary>
/// The storage where all tournaments are located.
/// </summary>
public readonly Storage AllTournaments;
2020-12-07 20:11:13 +08:00
public readonly Bindable<string> CurrentTournament;
2020-06-24 06:00:21 +08:00
protected TournamentConfigManager TournamentConfigManager { get; }
public TournamentStorage(Storage storage)
: base(storage.GetStorageForDirectory("tournaments"), string.Empty)
{
AllTournaments = UnderlyingStorage;
TournamentConfigManager = new TournamentConfigManager(storage);
2020-06-11 19:56:16 +08:00
CurrentTournament = TournamentConfigManager.GetBindable<string>(StorageConfig.CurrentTournament);
ChangeTargetStorage(AllTournaments.GetStorageForDirectory(CurrentTournament.Value));
Logger.Log("Using tournament storage: " + GetFullPath(string.Empty));
2020-12-07 20:11:13 +08:00
2020-12-08 04:38:15 +08:00
CurrentTournament.BindValueChanged(updateTournament);
}
2020-12-07 20:11:13 +08:00
private void updateTournament(ValueChangedEvent<string> newTournament)
{
ChangeTargetStorage(AllTournaments.GetStorageForDirectory(newTournament.NewValue));
2020-12-07 20:11:13 +08:00
Logger.Log("Changing tournament storage: " + GetFullPath(string.Empty));
}
public IEnumerable<string> ListTournaments() => AllTournaments.GetDirectories(string.Empty).Order(StringComparer.CurrentCultureIgnoreCase);
}
}