2021-01-11 14:47:27 +08:00
|
|
|
// 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.
|
|
|
|
|
2021-01-11 13:44:07 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2022-11-24 15:26:57 +08:00
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
2021-01-11 13:44:07 +08:00
|
|
|
using osu.Game.Tournament.IO;
|
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Screens.Setup
|
|
|
|
{
|
|
|
|
internal partial class TournamentSwitcher : ActionableInfo
|
|
|
|
{
|
2023-07-25 19:50:55 +08:00
|
|
|
private OsuDropdown<string> dropdown = null!;
|
|
|
|
private OsuButton folderButton = null!;
|
|
|
|
private OsuButton reloadTournamentsButton = null!;
|
2021-01-11 13:44:07 +08:00
|
|
|
|
|
|
|
[Resolved]
|
2023-07-25 19:50:55 +08:00
|
|
|
private TournamentGameBase game { get; set; } = null!;
|
2021-01-11 13:44:07 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(TournamentStorage storage)
|
|
|
|
{
|
2021-01-11 13:45:01 +08:00
|
|
|
string startupTournament = storage.CurrentTournament.Value;
|
2021-01-11 13:44:07 +08:00
|
|
|
|
|
|
|
dropdown.Current = storage.CurrentTournament;
|
|
|
|
dropdown.Items = storage.ListTournaments();
|
|
|
|
dropdown.Current.BindValueChanged(v => Button.Enabled.Value = v.NewValue != startupTournament, true);
|
|
|
|
|
2023-07-22 16:44:02 +08:00
|
|
|
reloadTournamentsButton.Action = () => dropdown.Items = storage.ListTournaments();
|
|
|
|
|
2023-06-21 17:29:34 +08:00
|
|
|
Action = () =>
|
|
|
|
{
|
2024-07-05 05:30:42 +08:00
|
|
|
game.RestartAppWhenExited();
|
|
|
|
game.AttemptExit();
|
2023-06-21 17:29:34 +08:00
|
|
|
};
|
2022-03-24 22:40:46 +08:00
|
|
|
folderButton.Action = () => storage.PresentExternally();
|
2021-01-11 13:44:07 +08:00
|
|
|
|
|
|
|
ButtonText = "Close osu!";
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override Drawable CreateComponent()
|
|
|
|
{
|
|
|
|
var drawable = base.CreateComponent();
|
|
|
|
|
2022-11-24 15:26:57 +08:00
|
|
|
FlowContainer.Insert(-1, folderButton = new RoundedButton
|
2021-01-11 13:44:07 +08:00
|
|
|
{
|
2022-02-25 22:13:32 +08:00
|
|
|
Text = "Open folder",
|
2023-07-20 18:56:32 +08:00
|
|
|
Width = BUTTON_SIZE
|
2021-01-11 13:44:07 +08:00
|
|
|
});
|
|
|
|
|
2023-07-22 16:44:02 +08:00
|
|
|
FlowContainer.Insert(-2, reloadTournamentsButton = new RoundedButton
|
|
|
|
{
|
2023-07-22 20:01:32 +08:00
|
|
|
Text = "Refresh",
|
2023-07-22 16:44:02 +08:00
|
|
|
Width = BUTTON_SIZE
|
|
|
|
});
|
|
|
|
|
|
|
|
FlowContainer.Insert(-3, dropdown = new OsuDropdown<string>
|
2022-02-25 21:16:18 +08:00
|
|
|
{
|
2022-02-25 22:13:32 +08:00
|
|
|
Width = 510
|
2022-02-25 21:16:18 +08:00
|
|
|
});
|
|
|
|
|
2021-01-11 13:44:07 +08:00
|
|
|
return drawable;
|
|
|
|
}
|
|
|
|
}
|
2021-01-11 13:45:01 +08:00
|
|
|
}
|