1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 06:47:24 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Match/Components/RoomAvailabilityPicker.cs

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

111 lines
3.5 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 13:25:08 +08:00
2022-06-17 15:37:17 +08:00
#nullable disable
2018-06-06 13:25:08 +08:00
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions;
2018-06-06 13:25:08 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
2018-11-26 15:29:56 +08:00
using osu.Framework.Input.Events;
2018-06-06 13:25:08 +08:00
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
2020-12-25 12:38:11 +08:00
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Components;
2018-11-26 15:29:56 +08:00
using osuTK;
using osuTK.Graphics;
2018-06-06 13:25:08 +08:00
namespace osu.Game.Screens.OnlinePlay.Match.Components
2018-06-06 13:25:08 +08:00
{
2018-12-05 16:01:14 +08:00
public partial class RoomAvailabilityPicker : DisableableTabControl<RoomAvailability>
2018-06-06 13:25:08 +08:00
{
protected override TabItem<RoomAvailability> CreateTabItem(RoomAvailability value) => new RoomAvailabilityPickerItem(value);
2018-06-06 13:25:08 +08:00
protected override Dropdown<RoomAvailability> CreateDropdown() => null;
2018-06-06 13:38:09 +08:00
public RoomAvailabilityPicker()
2018-06-06 13:25:08 +08:00
{
RelativeSizeAxes = Axes.X;
Height = 35;
TabContainer.Spacing = new Vector2(10);
AddItem(RoomAvailability.Public);
AddItem(RoomAvailability.FriendsOnly);
AddItem(RoomAvailability.InviteOnly);
}
2019-04-25 16:36:17 +08:00
private partial class RoomAvailabilityPickerItem : DisableableTabItem
2018-06-06 13:25:08 +08:00
{
private const float transition_duration = 200;
private readonly Box hover, selection;
2018-06-06 13:25:08 +08:00
2019-02-28 12:31:40 +08:00
public RoomAvailabilityPickerItem(RoomAvailability value)
: base(value)
2018-06-06 13:25:08 +08:00
{
RelativeSizeAxes = Axes.Y;
2018-12-05 16:01:14 +08:00
Width = 102;
2018-06-06 13:25:08 +08:00
Masking = true;
CornerRadius = 5;
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4Extensions.FromHex(@"3d3943"),
2018-06-06 13:25:08 +08:00
},
selection = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
},
hover = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
Alpha = 0,
},
2018-06-06 13:25:08 +08:00
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(weight: FontWeight.Bold),
2018-06-06 13:25:08 +08:00
Text = value.GetDescription(),
},
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
selection.Colour = colours.GreenLight;
}
2018-11-26 15:29:56 +08:00
protected override bool OnHover(HoverEvent e)
{
hover.FadeTo(0.05f, transition_duration, Easing.OutQuint);
2018-11-26 15:29:56 +08:00
return base.OnHover(e);
}
2018-11-26 15:29:56 +08:00
protected override void OnHoverLost(HoverLostEvent e)
{
hover.FadeOut(transition_duration, Easing.OutQuint);
2018-11-26 15:29:56 +08:00
base.OnHoverLost(e);
}
2018-06-06 13:25:08 +08:00
protected override void OnActivated()
{
selection.FadeIn(transition_duration, Easing.OutQuint);
}
protected override void OnDeactivated()
{
selection.FadeOut(transition_duration, Easing.OutQuint);
}
}
}
}