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

127 lines
4.1 KiB
C#
Raw Normal View History

2018-05-29 09:11:01 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
2018-05-29 09:11:01 +08:00
using osu.Framework.Allocation;
2018-12-06 11:21:30 +08:00
using osu.Framework.Configuration;
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;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
2018-05-29 09:11:01 +08:00
using osu.Game.Overlays.SearchableList;
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
{
public class Header : Container
{
2018-05-29 12:51:04 +08:00
public const float HEIGHT = 200;
2018-12-06 11:21:30 +08:00
public readonly IBindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
2018-05-29 09:11:01 +08:00
private readonly Box tabStrip;
public readonly MatchTabControl Tabs;
2018-05-29 09:11:01 +08:00
public Action OnRequestSelectBeatmap;
2018-05-29 09:11:01 +08:00
public Header()
{
RelativeSizeAxes = Axes.X;
2018-05-29 12:51:04 +08:00
Height = HEIGHT;
2018-05-29 09:11:01 +08:00
BeatmapSelectButton beatmapButton;
2018-12-06 11:21:30 +08:00
UpdateableBeatmapBackgroundSprite background;
2018-05-29 09:11:01 +08:00
Children = new Drawable[]
{
2018-12-06 11:21:30 +08:00
new Container
2018-05-29 09:11:01 +08:00
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Child = background = new HeaderBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both }
2018-05-29 09:11:01 +08:00
},
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0), Color4.Black.Opacity(0.5f)),
},
2018-05-29 09:11:01 +08:00
tabStrip = new Box
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Height = 1,
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING },
Children = new Drawable[]
{
new Container
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
Width = 200,
Padding = new MarginPadding { Vertical = 5 },
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
},
},
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
},
},
},
};
beatmapButton.Action = () => OnRequestSelectBeatmap?.Invoke();
2018-12-06 11:21:30 +08:00
background.Beatmap.BindTo(Beatmap);
2018-05-29 09:11:01 +08:00
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
tabStrip.Colour = colours.Yellow;
}
private class BeatmapSelectButton : TriangleButton
2018-05-29 09:11:01 +08:00
{
private readonly IBindable<bool> createdBind = new Bindable<bool>();
[Resolved]
private Room room { get; set; }
2018-05-29 09:11:01 +08:00
public BeatmapSelectButton()
{
Text = "Select beatmap";
2018-05-29 09:11:01 +08:00
}
[BackgroundDependencyLoader]
private void load()
{
createdBind.BindTo(room.Created);
createdBind.BindValueChanged(v => Enabled.Value = !v, true);
}
2018-05-29 09:11:01 +08:00
}
private class HeaderBeatmapBackgroundSprite : UpdateableBeatmapBackgroundSprite
{
protected override double FadeDuration => 0;
}
2018-05-29 09:11:01 +08:00
}
}