osu/osu.Game.Tournament/Screens/Setup/SetupScreen.cs

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

156 lines
5.8 KiB
C#
Raw Normal View History

2019-09-21 17:10:04 +00: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 System.Drawing;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Configuration;
2019-09-22 19:22:50 +00:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
2023-07-27 21:43:05 +00:00
using osu.Game.Graphics.Containers;
2019-09-24 10:00:26 +00:00
using osu.Game.Graphics.UserInterfaceV2;
2019-09-22 19:45:23 +00:00
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Rulesets;
using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Models;
2019-09-22 19:22:50 +00:00
using osuTK;
namespace osu.Game.Tournament.Screens.Setup
2019-09-21 17:10:04 +00:00
{
public partial class SetupScreen : TournamentScreen
2019-09-21 17:10:04 +00:00
{
2023-07-25 11:50:55 +00:00
private FillFlowContainer fillFlow = null!;
2019-09-22 19:45:23 +00:00
2023-07-25 11:50:55 +00:00
private LoginOverlay? loginOverlay;
private ResolutionSelector resolution = null!;
2019-09-22 19:45:23 +00:00
[Resolved]
2023-07-25 11:50:55 +00:00
private MatchIPCInfo ipc { get; set; } = null!;
[Resolved]
2023-07-25 11:50:55 +00:00
private StableInfo stableInfo { get; set; } = null!;
2019-09-22 19:45:23 +00:00
[Resolved]
2023-07-25 11:50:55 +00:00
private IAPIProvider api { get; set; } = null!;
2019-09-22 19:45:23 +00:00
[Resolved]
2023-07-25 11:50:55 +00:00
private RulesetStore rulesets { get; set; } = null!;
2023-07-29 16:57:44 +00:00
[Resolved]
2023-07-25 11:50:55 +00:00
private TournamentSceneManager? sceneManager { get; set; }
2023-07-25 11:50:55 +00:00
private Bindable<Size> windowSize = null!;
[BackgroundDependencyLoader]
private void load(FrameworkConfigManager frameworkConfig)
{
windowSize = frameworkConfig.GetBindable<Size>(FrameworkSetting.WindowedSize);
InternalChildren = new Drawable[]
2019-09-22 19:45:23 +00:00
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.2f),
},
2023-07-27 21:43:05 +00:00
new OsuScrollContainer
{
2023-07-27 21:43:05 +00:00
RelativeSizeAxes = Axes.Both,
Child = fillFlow = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Padding = new MarginPadding(10),
Spacing = new Vector2(10),
},
},
2019-09-22 19:45:23 +00:00
};
api.LocalUser.BindValueChanged(_ => Schedule(reload));
stableInfo.OnStableInfoSaved += () => Schedule(reload);
2019-09-22 19:22:50 +00:00
reload();
}
private void reload()
{
var fileBasedIpc = ipc as FileBasedIPC;
2019-09-22 19:45:23 +00:00
fillFlow.Children = new Drawable[]
2019-09-22 19:22:50 +00:00
{
new ActionableInfo
{
Label = "Current IPC source",
ButtonText = "Change source",
Action = () => sceneManager?.SetScreen(new StablePathSelectScreen()),
Value = fileBasedIpc?.IPCStorage?.GetFullPath(string.Empty) ?? "Not found",
Failing = fileBasedIpc?.IPCStorage == null,
Description =
"The osu!stable installation which is currently being used as a data source. If a source is not found, make sure you have created an empty ipc.txt in your stable cutting-edge installation."
},
new ActionableInfo
2019-09-22 19:45:23 +00:00
{
Label = "Current user",
ButtonText = "Change sign-in",
2019-09-22 19:45:23 +00:00
Action = () =>
{
api.Logout();
if (loginOverlay == null)
{
2019-09-22 19:49:21 +00:00
AddInternal(loginOverlay = new LoginOverlay
2019-09-22 19:45:23 +00:00
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
});
}
loginOverlay.State.Value = Visibility.Visible;
},
2023-07-20 18:47:32 +00:00
Value = api.LocalUser.Value.Username,
Failing = api.IsLoggedIn != true,
Description = "In order to access the API and display metadata, signing in is required."
},
2023-07-25 11:50:55 +00:00
new LabelledDropdown<RulesetInfo?>
{
Label = "Ruleset",
Description = "Decides what stats are displayed and which ranks are retrieved for players. This requires a restart to reload data for an existing bracket.",
Items = rulesets.AvailableRulesets,
Current = LadderInfo.Ruleset,
},
new TournamentSwitcher
2020-12-07 12:11:13 +00:00
{
Label = "Current tournament",
Description = "Changes the background videos and bracket to match the selected tournament. This requires a restart to apply changes.",
2020-12-07 12:11:13 +00:00
},
resolution = new ResolutionSelector
{
Label = "Stream area resolution",
ButtonText = "Set height",
2020-05-25 18:11:00 +00:00
Action = height =>
{
2020-05-25 18:11:00 +00:00
windowSize.Value = new Size((int)(height * aspect_ratio / TournamentSceneManager.STREAM_AREA_WIDTH * TournamentSceneManager.REQUIRED_WIDTH), height);
}
},
new LabelledSwitchButton
{
Label = "Auto advance screens",
Description = "Screens will progress automatically from gameplay -> results -> map pool",
Current = LadderInfo.AutoProgressScreens,
},
2019-09-22 19:22:50 +00:00
};
}
private const float aspect_ratio = 16f / 9f;
protected override void Update()
{
base.Update();
resolution.Value = $"{ScreenSpaceDrawQuad.Width:N0}x{ScreenSpaceDrawQuad.Height:N0}";
}
2019-09-21 17:10:04 +00:00
}
}