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

154 lines
5.4 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-12-20 14:17:33 +08:00
using System.Collections.Generic;
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.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.Rulesets.Mods;
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-13 17:38:03 +08:00
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
2018-12-20 14:17:33 +08:00
public readonly IBindable<GameType> Type = new Bindable<GameType>();
public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>();
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-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,
2018-12-20 14:17:33 +08:00
Padding = new MarginPadding
{
Left = SearchableListOverlay.WIDTH_PADDING,
Top = 20
},
2018-05-29 09:11:01 +08:00
Children = new Drawable[]
{
2018-12-20 14:17:33 +08:00
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
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 = 5 },
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-20 14:17:33 +08:00
beatmapTypeInfo.Beatmap.BindTo(Beatmap);
beatmapTypeInfo.Type.BindTo(Type);
modDisplay.Current.BindTo(Mods);
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;
}
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
{
protected override double FadeDuration => 0;
}
2018-05-29 09:11:01 +08:00
}
}