2019-03-04 12:24:19 +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.
|
2018-11-06 13:49:09 +08:00
|
|
|
|
2020-06-10 02:22:30 +08:00
|
|
|
using System.Drawing;
|
2021-03-24 06:22:17 +08:00
|
|
|
using System.Linq;
|
2020-06-10 02:22:30 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Configuration;
|
2021-03-24 06:22:17 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2018-11-07 00:20:32 +08:00
|
|
|
using osu.Framework.Graphics;
|
2021-03-24 06:22:17 +08:00
|
|
|
using osu.Framework.Graphics.Colour;
|
2020-06-10 02:22:30 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2021-03-24 06:22:17 +08:00
|
|
|
using osu.Framework.Input.Handlers.Mouse;
|
|
|
|
using osu.Framework.Platform;
|
2020-06-10 02:22:30 +08:00
|
|
|
using osu.Game.Graphics;
|
2021-03-24 06:22:17 +08:00
|
|
|
using osu.Game.Graphics.Cursor;
|
2021-02-12 15:55:34 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-03-24 06:22:17 +08:00
|
|
|
using osu.Game.Tournament.Models;
|
2020-06-10 02:22:30 +08:00
|
|
|
using osuTK;
|
2020-03-03 18:14:44 +08:00
|
|
|
using osuTK.Graphics;
|
2018-11-06 13:49:09 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tournament
|
|
|
|
{
|
2018-11-06 17:32:59 +08:00
|
|
|
public class TournamentGame : TournamentGameBase
|
2018-11-06 13:49:09 +08:00
|
|
|
{
|
2020-03-06 15:03:18 +08:00
|
|
|
public static ColourInfo GetTeamColour(TeamColour teamColour) => teamColour == TeamColour.Red ? COLOUR_RED : COLOUR_BLUE;
|
|
|
|
|
2021-08-05 17:23:39 +08:00
|
|
|
public static readonly Color4 COLOUR_RED = new OsuColour().TeamColourRed;
|
|
|
|
public static readonly Color4 COLOUR_BLUE = new OsuColour().TeamColourBlue;
|
2020-03-06 15:03:18 +08:00
|
|
|
|
2020-03-11 09:18:41 +08:00
|
|
|
public static readonly Color4 ELEMENT_BACKGROUND_COLOUR = Color4Extensions.FromHex("#fff");
|
|
|
|
public static readonly Color4 ELEMENT_FOREGROUND_COLOUR = Color4Extensions.FromHex("#000");
|
2020-03-06 15:03:18 +08:00
|
|
|
|
2020-03-11 09:18:41 +08:00
|
|
|
public static readonly Color4 TEXT_COLOUR = Color4Extensions.FromHex("#fff");
|
2020-06-10 02:22:30 +08:00
|
|
|
private Drawable heightWarning;
|
|
|
|
private Bindable<Size> windowSize;
|
2020-08-20 18:41:27 +08:00
|
|
|
private Bindable<WindowMode> windowMode;
|
2021-02-12 15:55:34 +08:00
|
|
|
private LoadingSpinner loadingSpinner;
|
2020-03-03 18:14:44 +08:00
|
|
|
|
2020-06-10 02:22:30 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2021-03-24 06:22:17 +08:00
|
|
|
private void load(FrameworkConfigManager frameworkConfig, GameHost host)
|
2018-11-06 13:49:09 +08:00
|
|
|
{
|
2020-06-10 02:22:30 +08:00
|
|
|
windowSize = frameworkConfig.GetBindable<Size>(FrameworkSetting.WindowedSize);
|
2020-08-20 18:41:27 +08:00
|
|
|
windowMode = frameworkConfig.GetBindable<WindowMode>(FrameworkSetting.WindowMode);
|
2021-02-12 15:55:34 +08:00
|
|
|
|
|
|
|
Add(loadingSpinner = new LoadingSpinner(true, true)
|
2020-08-20 18:41:27 +08:00
|
|
|
{
|
2021-02-12 15:55:34 +08:00
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
Margin = new MarginPadding(40),
|
|
|
|
});
|
|
|
|
|
2021-03-24 13:09:15 +08:00
|
|
|
// in order to have the OS mouse cursor visible, relative mode needs to be disabled.
|
|
|
|
// can potentially be removed when https://github.com/ppy/osu-framework/issues/4309 is resolved.
|
|
|
|
var mouseHandler = host.AvailableInputHandlers.OfType<MouseHandler>().FirstOrDefault();
|
|
|
|
|
|
|
|
if (mouseHandler != null)
|
|
|
|
mouseHandler.UseRelativeMode.Value = false;
|
2021-03-24 06:22:17 +08:00
|
|
|
|
2021-02-12 15:55:34 +08:00
|
|
|
loadingSpinner.Show();
|
2020-08-20 18:41:27 +08:00
|
|
|
|
2021-02-12 15:55:34 +08:00
|
|
|
BracketLoadTask.ContinueWith(_ => LoadComponentsAsync(new[]
|
2018-11-07 00:20:32 +08:00
|
|
|
{
|
2020-06-10 02:22:30 +08:00
|
|
|
new Container
|
|
|
|
{
|
|
|
|
CornerRadius = 10,
|
|
|
|
Depth = float.MinValue,
|
|
|
|
Position = new Vector2(5),
|
|
|
|
Masking = true,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = OsuColour.Gray(0.2f),
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
new TourneyButton
|
|
|
|
{
|
|
|
|
Text = "Save Changes",
|
|
|
|
Width = 140,
|
|
|
|
Height = 50,
|
|
|
|
Padding = new MarginPadding
|
|
|
|
{
|
|
|
|
Top = 10,
|
|
|
|
Left = 10,
|
|
|
|
},
|
|
|
|
Margin = new MarginPadding
|
|
|
|
{
|
|
|
|
Right = 10,
|
|
|
|
Bottom = 10,
|
|
|
|
},
|
|
|
|
Action = SaveChanges,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2021-07-16 22:59:16 +08:00
|
|
|
heightWarning = new WarningBox("Please make the window wider")
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
Margin = new MarginPadding(20),
|
|
|
|
},
|
2020-06-10 02:22:30 +08:00
|
|
|
new OsuContextMenuContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Child = new TournamentSceneManager()
|
|
|
|
}
|
2021-02-12 15:55:34 +08:00
|
|
|
}, drawables =>
|
|
|
|
{
|
|
|
|
loadingSpinner.Hide();
|
|
|
|
loadingSpinner.Expire();
|
|
|
|
|
|
|
|
AddRange(drawables);
|
|
|
|
|
|
|
|
windowSize.BindValueChanged(size => ScheduleAfterChildren(() =>
|
|
|
|
{
|
|
|
|
var minWidth = (int)(size.NewValue.Height / 768f * TournamentSceneManager.REQUIRED_WIDTH) - 1;
|
|
|
|
heightWarning.Alpha = size.NewValue.Width < minWidth ? 1 : 0;
|
|
|
|
}), true);
|
|
|
|
|
|
|
|
windowMode.BindValueChanged(mode => ScheduleAfterChildren(() =>
|
|
|
|
{
|
|
|
|
windowMode.Value = WindowMode.Windowed;
|
|
|
|
}), true);
|
|
|
|
}));
|
2020-06-10 02:22:30 +08:00
|
|
|
}
|
2018-11-06 13:49:09 +08:00
|
|
|
}
|
|
|
|
}
|