2019-01-24 17:43:03 +09: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-06-06 00:29:52 -03:00
|
|
|
|
|
2018-06-06 00:53:24 -03:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-06-06 00:29:52 -03:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-08-05 14:00:35 +09:00
|
|
|
|
using osu.Framework.Input.Bindings;
|
2021-09-16 18:26:12 +09:00
|
|
|
|
using osu.Framework.Input.Events;
|
2018-06-06 00:29:52 -03:00
|
|
|
|
using osu.Game.Graphics;
|
2018-06-06 00:53:24 -03:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-08-05 14:00:35 +09:00
|
|
|
|
using osu.Game.Input.Bindings;
|
2021-08-19 16:40:27 +09:00
|
|
|
|
using osu.Game.Online.Rooms;
|
2018-11-26 16:29:56 +09:00
|
|
|
|
using osuTK;
|
2018-06-06 00:29:52 -03:00
|
|
|
|
|
2020-12-25 16:50:00 +01:00
|
|
|
|
namespace osu.Game.Screens.OnlinePlay.Match.Components
|
2018-06-06 00:29:52 -03:00
|
|
|
|
{
|
2021-08-17 17:14:21 +09:00
|
|
|
|
public abstract class RoomSettingsOverlay : FocusedOverlayContainer, IKeyBindingHandler<GlobalAction>
|
2018-06-06 00:29:52 -03:00
|
|
|
|
{
|
2020-12-22 15:51:24 +09:00
|
|
|
|
protected const float TRANSITION_DURATION = 350;
|
2021-08-18 17:28:20 +09:00
|
|
|
|
protected const float FIELD_PADDING = 25;
|
2018-06-06 00:29:52 -03:00
|
|
|
|
|
2020-12-25 17:12:33 +01:00
|
|
|
|
protected OnlinePlayComposite Settings { get; set; }
|
2018-06-06 02:38:09 -03:00
|
|
|
|
|
2021-04-12 16:41:36 +09:00
|
|
|
|
protected override bool BlockScrollInput => false;
|
|
|
|
|
|
2021-08-05 14:00:35 +09:00
|
|
|
|
protected abstract OsuButton SubmitButton { get; }
|
|
|
|
|
|
2021-08-05 14:14:07 +09:00
|
|
|
|
protected abstract bool IsLoading { get; }
|
|
|
|
|
|
2021-08-19 16:40:27 +09:00
|
|
|
|
private readonly Room room;
|
|
|
|
|
|
|
|
|
|
protected RoomSettingsOverlay(Room room)
|
2019-02-05 19:00:01 +09:00
|
|
|
|
{
|
2021-08-19 16:40:27 +09:00
|
|
|
|
this.room = room;
|
|
|
|
|
|
2021-08-17 18:24:04 +09:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2019-02-05 19:00:01 +09:00
|
|
|
|
Masking = true;
|
2021-08-18 15:29:01 +09:00
|
|
|
|
CornerRadius = 10;
|
2021-08-17 18:24:04 +09:00
|
|
|
|
}
|
2021-07-07 16:12:28 +09:00
|
|
|
|
|
2021-08-17 18:24:04 +09:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2021-08-19 16:40:27 +09:00
|
|
|
|
Add(Settings = CreateSettings(room));
|
2019-02-05 19:00:01 +09:00
|
|
|
|
}
|
2018-06-06 23:30:17 -03:00
|
|
|
|
|
2021-08-05 14:00:35 +09:00
|
|
|
|
protected abstract void SelectBeatmap();
|
|
|
|
|
|
2021-08-19 16:40:27 +09:00
|
|
|
|
protected abstract OnlinePlayComposite CreateSettings(Room room);
|
2021-07-07 16:12:28 +09:00
|
|
|
|
|
2019-02-05 19:00:01 +09:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
2021-08-17 08:56:49 +03:00
|
|
|
|
base.PopIn();
|
2020-12-22 15:51:24 +09:00
|
|
|
|
Settings.MoveToY(0, TRANSITION_DURATION, Easing.OutQuint);
|
2021-08-18 15:29:01 +09:00
|
|
|
|
Settings.FadeIn(TRANSITION_DURATION / 2);
|
2019-02-05 19:00:01 +09:00
|
|
|
|
}
|
2018-12-26 18:38:58 +09:00
|
|
|
|
|
2019-02-05 19:00:01 +09:00
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
2021-08-17 08:56:49 +03:00
|
|
|
|
base.PopOut();
|
2020-12-22 15:51:24 +09:00
|
|
|
|
Settings.MoveToY(-1, TRANSITION_DURATION, Easing.InSine);
|
2021-08-18 15:29:01 +09:00
|
|
|
|
Settings.Delay(TRANSITION_DURATION / 2).FadeOut(TRANSITION_DURATION / 2);
|
2020-12-22 15:51:24 +09:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 18:26:12 +09:00
|
|
|
|
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
2021-08-05 14:00:35 +09:00
|
|
|
|
{
|
2021-11-18 12:35:47 +09:00
|
|
|
|
if (e.Repeat)
|
|
|
|
|
return false;
|
|
|
|
|
|
2021-09-16 18:26:12 +09:00
|
|
|
|
switch (e.Action)
|
2021-08-05 14:00:35 +09:00
|
|
|
|
{
|
|
|
|
|
case GlobalAction.Select:
|
2021-08-05 14:14:07 +09:00
|
|
|
|
if (IsLoading)
|
|
|
|
|
return true;
|
|
|
|
|
|
2021-08-05 14:00:35 +09:00
|
|
|
|
if (SubmitButton.Enabled.Value)
|
|
|
|
|
{
|
|
|
|
|
SubmitButton.TriggerClick();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SelectBeatmap();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 18:26:12 +09:00
|
|
|
|
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
|
2021-08-05 14:00:35 +09:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-22 15:51:24 +09:00
|
|
|
|
protected class SectionContainer : FillFlowContainer<Section>
|
|
|
|
|
{
|
|
|
|
|
public SectionContainer()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
Width = 0.5f;
|
|
|
|
|
Direction = FillDirection.Vertical;
|
|
|
|
|
Spacing = new Vector2(FIELD_PADDING);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected class Section : Container
|
|
|
|
|
{
|
|
|
|
|
private readonly Container content;
|
|
|
|
|
|
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
|
|
|
|
public Section(string title)
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
|
|
|
|
|
InternalChild = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12),
|
|
|
|
|
Text = title.ToUpper(),
|
|
|
|
|
},
|
|
|
|
|
content = new Container
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-06 00:29:52 -03:00
|
|
|
|
}
|