1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 21:27:23 +08:00
osu-lazer/osu.Game/Screens/Multi/Match/Components/Header.cs

145 lines
5.2 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-05-29 09:11:01 +08:00
using System;
2018-05-29 09:11:01 +08:00
using osu.Framework.Allocation;
2019-02-21 18:04:31 +08:00
using osu.Framework.Bindables;
2018-05-29 09:11:01 +08:00
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
2018-05-29 09:11:01 +08:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
using osu.Game.Online.Multiplayer;
2018-05-29 09:11:01 +08:00
using osu.Game.Overlays.SearchableList;
using osu.Game.Rulesets.Mods;
2018-12-20 14:17:33 +08:00
using osu.Game.Screens.Multi.Components;
using osu.Game.Screens.Play.HUD;
using osuTK;
2018-11-20 15:51:59 +08:00
using osuTK.Graphics;
2018-05-29 09:11:01 +08:00
2018-12-10 18:20:41 +08:00
namespace osu.Game.Screens.Multi.Match.Components
2018-05-29 09:11:01 +08:00
{
2019-02-05 18:00:01 +08:00
public class Header : MultiplayerComposite
2018-05-29 09:11:01 +08:00
{
2018-05-29 12:51:04 +08:00
public const float HEIGHT = 200;
2019-02-05 18:00:01 +08:00
public MatchTabControl Tabs;
2018-12-06 11:21:30 +08:00
2019-02-05 18:00:01 +08:00
public Action RequestBeatmapSelection;
2018-05-29 09:11:01 +08:00
2019-02-05 18:00:01 +08:00
public Header()
2018-05-29 09:11:01 +08:00
{
RelativeSizeAxes = Axes.X;
2018-05-29 12:51:04 +08:00
Height = HEIGHT;
2019-02-05 18:00:01 +08:00
}
2018-05-29 09:11:01 +08:00
2019-02-05 18:00:01 +08:00
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BeatmapSelectButton beatmapButton;
2018-12-20 14:17:33 +08:00
ModDisplay modDisplay;
2019-02-05 18:00:01 +08:00
InternalChildren = new Drawable[]
2018-05-29 09:11:01 +08:00
{
2018-12-06 11:21:30 +08:00
new Container
2018-05-29 09:11:01 +08:00
{
RelativeSizeAxes = Axes.Both,
Masking = true,
2018-12-20 14:17:33 +08:00
Children = new Drawable[]
{
2019-02-05 18:00:01 +08:00
new HeaderBackgroundSprite { RelativeSizeAxes = Axes.Both },
2018-12-20 14:17:33 +08:00
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.4f), Color4.Black.Opacity(0.6f)),
},
}
},
2019-02-05 18:00:01 +08:00
new Box
2018-05-29 09:11:01 +08:00
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Height = 1,
2019-02-05 18:00:01 +08:00
Colour = colours.Yellow
2018-05-29 09:11:01 +08:00
},
new Container
{
RelativeSizeAxes = Axes.Both,
2019-01-25 13:10:59 +08:00
Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING },
2018-05-29 09:11:01 +08:00
Children = new Drawable[]
{
2018-12-20 14:17:33 +08:00
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = 20 },
2018-12-20 14:17:33 +08:00
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
2019-02-05 18:00:01 +08:00
new BeatmapTypeInfo(),
2018-12-20 14:17:33 +08:00
modDisplay = new ModDisplay
{
Scale = new Vector2(0.75f),
DisplayUnrankedText = false
},
}
},
2018-05-29 09:11:01 +08:00
new Container
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
Width = 200,
Padding = new MarginPadding { Vertical = 10 },
2019-02-05 18:00:01 +08:00
Child = beatmapButton = new BeatmapSelectButton
2018-05-29 09:11:01 +08:00
{
RelativeSizeAxes = Axes.Both,
Height = 1,
2018-05-29 09:11:01 +08:00
},
},
2019-02-05 18:00:01 +08:00
Tabs = new MatchTabControl
2018-05-29 09:11:01 +08:00
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X
2018-05-29 09:11:01 +08:00
},
},
},
};
CurrentItem.BindValueChanged(item => modDisplay.Current.Value = item.NewValue?.RequiredMods?.ToArray() ?? Array.Empty<Mod>(), true);
2018-12-20 14:17:33 +08:00
2019-02-05 18:00:01 +08:00
beatmapButton.Action = () => RequestBeatmapSelection?.Invoke();
2018-05-29 09:11:01 +08:00
}
2018-12-14 13:20:03 +08:00
private class BeatmapSelectButton : HeaderButton
2018-05-29 09:11:01 +08:00
{
2019-02-08 14:44:05 +08:00
[Resolved(typeof(Room), nameof(Room.RoomID))]
2019-02-05 18:00:01 +08:00
private Bindable<int?> roomId { get; set; }
2019-02-05 18:00:01 +08:00
public BeatmapSelectButton()
2018-05-29 09:11:01 +08:00
{
Text = "Select beatmap";
2019-02-05 18:00:01 +08:00
}
2019-02-05 18:00:01 +08:00
[BackgroundDependencyLoader]
private void load()
{
roomId.BindValueChanged(id => this.FadeTo(id.NewValue.HasValue ? 0 : 1), true);
}
2018-05-29 09:11:01 +08:00
}
2019-02-05 18:00:01 +08:00
private class HeaderBackgroundSprite : MultiplayerBackgroundSprite
{
2019-02-05 18:00:01 +08:00
protected override UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new BackgroundSprite { RelativeSizeAxes = Axes.Both };
private class BackgroundSprite : UpdateableBeatmapBackgroundSprite
{
protected override double TransformDuration => 200;
2019-02-05 18:00:01 +08:00
}
}
2018-05-29 09:11:01 +08:00
}
}