1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 23:47:25 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Match/Components/RoomSettingsOverlay.cs

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

150 lines
4.7 KiB
C#
Raw Normal View History

// 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 11:29:52 +08:00
2022-06-17 15:37:17 +08:00
#nullable disable
2018-06-06 11:53:24 +08:00
using osu.Framework.Allocation;
2018-06-06 11:29:52 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
2021-09-16 17:26:12 +08:00
using osu.Framework.Input.Events;
2018-06-06 11:29:52 +08:00
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
2018-06-06 11:53:24 +08:00
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
2021-08-19 15:40:27 +08:00
using osu.Game.Online.Rooms;
2018-11-26 15:29:56 +08:00
using osuTK;
2018-06-06 11:29:52 +08:00
namespace osu.Game.Screens.OnlinePlay.Match.Components
2018-06-06 11:29:52 +08:00
{
public abstract partial class RoomSettingsOverlay : FocusedOverlayContainer, IKeyBindingHandler<GlobalAction>
2018-06-06 11:29:52 +08:00
{
protected const float TRANSITION_DURATION = 350;
2021-08-18 16:28:20 +08:00
protected const float FIELD_PADDING = 25;
2018-06-06 11:29:52 +08:00
protected OnlinePlayComposite Settings { get; set; }
2018-06-06 13:38:09 +08:00
protected override bool BlockScrollInput => false;
protected abstract OsuButton SubmitButton { get; }
protected abstract bool IsLoading { get; }
2021-08-19 15:40:27 +08:00
private readonly Room room;
protected RoomSettingsOverlay(Room room)
2019-02-05 18:00:01 +08:00
{
2021-08-19 15:40:27 +08:00
this.room = room;
RelativeSizeAxes = Axes.Both;
2019-02-05 18:00:01 +08:00
Masking = true;
2021-08-18 14:29:01 +08:00
CornerRadius = 10;
}
[BackgroundDependencyLoader]
private void load()
{
2021-08-19 15:40:27 +08:00
Add(Settings = CreateSettings(room));
2019-02-05 18:00:01 +08:00
}
2018-06-07 10:30:17 +08:00
protected abstract void SelectBeatmap();
2021-08-19 15:40:27 +08:00
protected abstract OnlinePlayComposite CreateSettings(Room room);
2019-02-05 18:00:01 +08:00
protected override void PopIn()
{
Settings.MoveToY(0, TRANSITION_DURATION, Easing.OutQuint);
2021-08-18 14:29:01 +08:00
Settings.FadeIn(TRANSITION_DURATION / 2);
2019-02-05 18:00:01 +08:00
}
2018-12-26 17:38:58 +08:00
2019-02-05 18:00:01 +08:00
protected override void PopOut()
{
Settings.MoveToY(-1, TRANSITION_DURATION, Easing.InSine);
2021-08-18 14:29:01 +08:00
Settings.Delay(TRANSITION_DURATION / 2).FadeOut(TRANSITION_DURATION / 2);
}
2021-09-16 17:26:12 +08:00
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (e.Repeat)
return false;
2021-09-16 17:26:12 +08:00
switch (e.Action)
{
case GlobalAction.Select:
if (IsLoading)
return true;
if (SubmitButton.Enabled.Value)
{
SubmitButton.TriggerClick();
return true;
}
else
{
SelectBeatmap();
return true;
}
}
return false;
}
2021-09-16 17:26:12 +08:00
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}
/// <remarks>
/// <see cref="ReverseChildIDFillFlowContainer{T}"/> is used to ensure that if the nested <see cref="Section"/>s
/// use expanded overhanging content (like an <see cref="OsuDropdown{T}"/>'s dropdown),
/// then the overhanging content will be correctly Z-ordered.
/// </remarks>
protected partial class SectionContainer : ReverseChildIDFillFlowContainer<Section>
{
public SectionContainer()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Width = 0.5f;
Direction = FillDirection.Vertical;
Spacing = new Vector2(FIELD_PADDING);
}
}
protected partial class Section : Container
{
private readonly ReverseChildIDFillFlowContainer<Drawable> 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.ToUpperInvariant(),
},
content = new ReverseChildIDFillFlowContainer<Drawable>
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical
},
},
};
}
}
}
2018-06-06 11:29:52 +08:00
}