mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Re-implement the match header
This commit is contained in:
@ -1,39 +1,23 @@
|
||||
// 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 System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
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.Rulesets.Mods;
|
||||
using osu.Game.Screens.Multi.Components;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Users.Drawables;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Match.Components
|
||||
{
|
||||
public class Header : MultiplayerComposite
|
||||
{
|
||||
public const float HEIGHT = 200;
|
||||
public const float HEIGHT = 50;
|
||||
|
||||
public readonly BindableBool ShowBeatmapPanel = new BindableBool();
|
||||
|
||||
public MatchTabControl Tabs { get; private set; }
|
||||
|
||||
public Action RequestBeatmapSelection;
|
||||
|
||||
private MatchBeatmapPanel beatmapPanel;
|
||||
private ModDisplay modDisplay;
|
||||
private UpdateableAvatar avatar;
|
||||
private LinkFlowContainer hostText;
|
||||
|
||||
public Header()
|
||||
{
|
||||
@ -44,128 +28,52 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
BeatmapSelectButton beatmapButton;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
new Container
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(10, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
avatar = new UpdateableAvatar
|
||||
{
|
||||
new HeaderBackgroundSprite { RelativeSizeAxes = Axes.Both },
|
||||
new Box
|
||||
Size = new Vector2(50),
|
||||
Masking = true,
|
||||
CornerRadius = 10,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.7f), Color4.Black.Opacity(0.8f)),
|
||||
},
|
||||
beatmapPanel = new MatchBeatmapPanel
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Margin = new MarginPadding { Right = 100 },
|
||||
new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 30),
|
||||
Current = { BindTarget = RoomName }
|
||||
},
|
||||
hostText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.SemiBold))
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
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
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
beatmapButton.Action = () => RequestBeatmapSelection?.Invoke();
|
||||
|
||||
Playlist.ItemsAdded += _ => updateMods();
|
||||
Playlist.ItemsRemoved += _ => updateMods();
|
||||
|
||||
updateMods();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
ShowBeatmapPanel.BindValueChanged(value => beatmapPanel.FadeTo(value.NewValue ? 1 : 0, 200, Easing.OutQuint), true);
|
||||
}
|
||||
|
||||
private void updateMods()
|
||||
{
|
||||
var item = Playlist.FirstOrDefault();
|
||||
|
||||
modDisplay.Current.Value = item?.RequiredMods?.ToArray() ?? Array.Empty<Mod>();
|
||||
}
|
||||
|
||||
private class BeatmapSelectButton : HeaderButton
|
||||
{
|
||||
[Resolved(typeof(Room), nameof(Room.RoomID))]
|
||||
private Bindable<int?> roomId { get; set; }
|
||||
|
||||
public BeatmapSelectButton()
|
||||
Host.BindValueChanged(host =>
|
||||
{
|
||||
Text = "Select beatmap";
|
||||
}
|
||||
avatar.User = host.NewValue;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
roomId.BindValueChanged(id => this.FadeTo(id.NewValue.HasValue ? 0 : 1), true);
|
||||
}
|
||||
}
|
||||
hostText.Clear();
|
||||
|
||||
private class HeaderBackgroundSprite : MultiplayerBackgroundSprite
|
||||
{
|
||||
protected override UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new BackgroundSprite { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
private class BackgroundSprite : UpdateableBeatmapBackgroundSprite
|
||||
{
|
||||
protected override double TransformDuration => 200;
|
||||
}
|
||||
if (host.NewValue != null)
|
||||
{
|
||||
hostText.AddText("hosted by ");
|
||||
hostText.AddUserLink(host.NewValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user