1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 10:27:35 +08:00
osu-lazer/osu.Game.Tournament/Screens/Setup/TournamentSwitcher.cs

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

67 lines
2.0 KiB
C#
Raw Normal View History

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.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
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!;
[Resolved]
2023-07-25 19:50:55 +08:00
private TournamentGameBase game { get; set; } = null!;
[BackgroundDependencyLoader]
private void load(TournamentStorage storage)
{
2021-01-11 13:45:01 +08:00
string startupTournament = storage.CurrentTournament.Value;
dropdown.Current = storage.CurrentTournament;
dropdown.Items = storage.ListTournaments();
dropdown.Current.BindValueChanged(v => Button.Enabled.Value = v.NewValue != startupTournament, true);
reloadTournamentsButton.Action = () => dropdown.Items = storage.ListTournaments();
Action = () =>
{
game.RestartAppWhenExited();
game.AttemptExit();
};
folderButton.Action = () => storage.PresentExternally();
ButtonText = "Close osu!";
}
protected override Drawable CreateComponent()
{
var drawable = base.CreateComponent();
FlowContainer.Insert(-1, folderButton = new RoundedButton
{
Text = "Open folder",
Width = BUTTON_SIZE
});
FlowContainer.Insert(-2, reloadTournamentsButton = new RoundedButton
{
2023-07-22 20:01:32 +08:00
Text = "Refresh",
Width = BUTTON_SIZE
});
FlowContainer.Insert(-3, dropdown = new OsuDropdown<string>
{
Width = 510
});
return drawable;
}
}
2021-01-11 13:45:01 +08:00
}