2021-01-11 06:47:27 +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.
|
|
|
|
|
2021-01-11 05:44:07 +00:00
|
|
|
using System;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Screens.Setup
|
|
|
|
{
|
|
|
|
internal partial class ResolutionSelector : ActionableInfo
|
|
|
|
{
|
|
|
|
private const int minimum_window_height = 480;
|
|
|
|
private const int maximum_window_height = 2160;
|
|
|
|
|
2023-07-25 11:50:55 +00:00
|
|
|
public new Action<int>? Action;
|
2021-01-11 05:44:07 +00:00
|
|
|
|
2023-07-25 11:50:55 +00:00
|
|
|
private OsuNumberBox? numberBox;
|
2021-01-11 05:44:07 +00:00
|
|
|
|
|
|
|
protected override Drawable CreateComponent()
|
|
|
|
{
|
|
|
|
var drawable = base.CreateComponent();
|
|
|
|
FlowContainer.Insert(-1, numberBox = new OsuNumberBox
|
|
|
|
{
|
|
|
|
Text = "1080",
|
|
|
|
Width = 100
|
|
|
|
});
|
|
|
|
|
|
|
|
base.Action = () =>
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(numberBox.Text))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// box contains text
|
2021-10-27 04:04:41 +00:00
|
|
|
if (!int.TryParse(numberBox.Text, out int number))
|
2021-01-11 05:44:07 +00:00
|
|
|
{
|
|
|
|
// at this point, the only reason we can arrive here is if the input number was too big to parse into an int
|
|
|
|
// so clamp to max allowed value
|
|
|
|
number = maximum_window_height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
number = Math.Clamp(number, minimum_window_height, maximum_window_height);
|
|
|
|
}
|
|
|
|
|
|
|
|
// in case number got clamped, reset number in numberBox
|
|
|
|
numberBox.Text = number.ToString();
|
|
|
|
|
|
|
|
Action?.Invoke(number);
|
|
|
|
};
|
|
|
|
return drawable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|