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

148 lines
5.3 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.Drawables;
using osu.Game.Graphics;
using osu.Game.Online.Multiplayer;
2018-05-29 09:11:01 +08:00
using osu.Game.Overlays.SearchableList;
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
{
public class Header : Container
{
2018-05-29 12:51:04 +08:00
public const float HEIGHT = 200;
2018-12-22 13:12:27 +08:00
private readonly RoomBindings bindings = new RoomBindings();
2018-12-06 11:21:30 +08:00
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-12-20 14:17:33 +08:00
public Header(Room room)
2018-05-29 09:11:01 +08:00
{
RelativeSizeAxes = Axes.X;
2018-05-29 12:51:04 +08:00
Height = HEIGHT;
2018-05-29 09:11:01 +08:00
2018-12-22 13:12:27 +08:00
bindings.Room = room;
2018-12-20 14:17:33 +08:00
BeatmapTypeInfo beatmapTypeInfo;
BeatmapSelectButton beatmapButton;
2018-12-06 11:21:30 +08:00
UpdateableBeatmapBackgroundSprite background;
2018-12-20 14:17:33 +08:00
ModDisplay modDisplay;
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,
2018-12-20 14:17:33 +08:00
Children = new Drawable[]
{
background = new HeaderBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both },
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.4f), Color4.Black.Opacity(0.6f)),
},
}
},
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 },
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[]
{
beatmapTypeInfo = new BeatmapTypeInfo(),
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 },
2018-12-20 14:17:33 +08:00
Child = beatmapButton = new BeatmapSelectButton(room)
2018-05-29 09:11:01 +08:00
{
RelativeSizeAxes = Axes.Both,
Height = 1,
2018-05-29 09:11:01 +08:00
},
},
2018-12-20 14:17:33 +08:00
Tabs = new MatchTabControl(room)
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
},
},
},
};
2018-12-22 13:12:27 +08:00
beatmapTypeInfo.Beatmap.BindTo(bindings.CurrentBeatmap);
beatmapTypeInfo.Ruleset.BindTo(bindings.CurrentRuleset);
2018-12-22 13:12:27 +08:00
beatmapTypeInfo.Type.BindTo(bindings.Type);
background.Beatmap.BindTo(bindings.CurrentBeatmap);
bindings.CurrentMods.BindValueChanged(m => modDisplay.Current.Value = m, true);
2018-12-20 14:17:33 +08:00
beatmapButton.Action = () => OnRequestSelectBeatmap?.Invoke();
2018-05-29 09:11:01 +08:00
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
tabStrip.Colour = colours.Yellow;
}
2018-12-14 13:20:03 +08:00
private class BeatmapSelectButton : HeaderButton
2018-05-29 09:11:01 +08:00
{
2018-12-12 15:20:11 +08:00
private readonly IBindable<int?> roomIDBind = new Bindable<int?>();
2018-12-20 14:17:33 +08:00
public BeatmapSelectButton(Room room)
2018-05-29 09:11:01 +08:00
{
Text = "Select beatmap";
2018-12-12 15:20:11 +08:00
roomIDBind.BindTo(room.RoomID);
roomIDBind.BindValueChanged(v => this.FadeTo(v.HasValue ? 0 : 1), true);
}
2018-05-29 09:11:01 +08:00
}
private class HeaderBeatmapBackgroundSprite : UpdateableBeatmapBackgroundSprite
{
2018-12-26 20:18:55 +08:00
protected override double FadeDuration => 200;
}
2018-05-29 09:11:01 +08:00
}
}