1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 09:17:52 +08:00
osu-lazer/osu.Game/Screens/Multi/Match/Components/Header.cs
2019-02-05 19:00:08 +09:00

144 lines
5.1 KiB
C#

// 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.
using System;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
using osu.Game.Online.Multiplayer;
using osu.Game.Overlays.SearchableList;
using osu.Game.Screens.Multi.Components;
using osu.Game.Screens.Play.HUD;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Multi.Match.Components
{
public class Header : MultiplayerComposite
{
public const float HEIGHT = 200;
public MatchTabControl Tabs;
public Action RequestBeatmapSelection;
public Header()
{
RelativeSizeAxes = Axes.X;
Height = HEIGHT;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BeatmapSelectButton beatmapButton;
ModDisplay modDisplay;
InternalChildren = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Children = new Drawable[]
{
new HeaderBackgroundSprite { RelativeSizeAxes = Axes.Both },
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.4f), Color4.Black.Opacity(0.6f)),
},
}
},
new Box
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Height = 1,
Colour = colours.Yellow
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING },
Children = new Drawable[]
{
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = 20 },
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
new BeatmapTypeInfo(),
modDisplay = new ModDisplay
{
Scale = new Vector2(0.75f),
DisplayUnrankedText = false
},
}
},
new Container
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
Width = 200,
Padding = new MarginPadding { Vertical = 10 },
Child = beatmapButton = new BeatmapSelectButton
{
RelativeSizeAxes = Axes.Both,
Height = 1,
},
},
Tabs = new MatchTabControl
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X
},
},
},
};
CurrentMods.BindValueChanged(m => modDisplay.Current.Value = m, true);
beatmapButton.Action = () => RequestBeatmapSelection?.Invoke();
}
private class BeatmapSelectButton : HeaderButton
{
[Resolved(typeof(Room), nameof(Online.Multiplayer.Room.RoomID))]
private Bindable<int?> roomId { get; set; }
public BeatmapSelectButton()
{
Text = "Select beatmap";
}
[BackgroundDependencyLoader]
private void load()
{
roomId.BindValueChanged(v => this.FadeTo(v.HasValue ? 0 : 1), true);
}
}
private class HeaderBackgroundSprite : MultiplayerBackgroundSprite
{
protected override UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new BackgroundSprite { RelativeSizeAxes = Axes.Both };
private class BackgroundSprite : UpdateableBeatmapBackgroundSprite
{
protected override double FadeDuration => 200;
}
}
}
}