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

157 lines
5.9 KiB
C#
Raw Normal View History

2018-05-29 12:51:04 +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-12 13:38:03 +08:00
using System.Collections.Generic;
2018-05-29 12:51:04 +08:00
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Multiplayer;
using osu.Game.Overlays.SearchableList;
2018-12-12 13:38:03 +08:00
using osu.Game.Rulesets.Mods;
2018-05-29 12:51:04 +08:00
using osu.Game.Screens.Multi.Components;
2018-12-12 13:38:03 +08:00
using osu.Game.Screens.Play.HUD;
2018-11-20 15:51:59 +08:00
using osuTK;
2018-05-29 12:51:04 +08:00
2018-12-10 18:20:41 +08:00
namespace osu.Game.Screens.Multi.Match.Components
2018-05-29 12:51:04 +08:00
{
public class Info : Container
{
public Action OnStart;
2018-12-07 15:20:05 +08:00
private readonly OsuSpriteText availabilityStatus;
2018-05-29 12:51:04 +08:00
private OsuColour colours;
2018-12-07 15:20:05 +08:00
public readonly Bindable<string> Name = new Bindable<string>();
public readonly Bindable<RoomAvailability> Availability = new Bindable<RoomAvailability>();
public readonly Bindable<RoomStatus> Status = new Bindable<RoomStatus>();
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
public readonly Bindable<GameType> Type = new Bindable<GameType>();
2018-12-12 13:38:03 +08:00
public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>();
2018-05-29 12:51:04 +08:00
public Info()
{
RelativeSizeAxes = Axes.X;
2018-12-14 13:20:03 +08:00
AutoSizeAxes = Axes.Y;
2018-05-29 12:51:04 +08:00
ReadyButton readyButton;
ViewBeatmapButton viewBeatmapButton;
2018-12-07 15:20:05 +08:00
BeatmapTypeInfo beatmapTypeInfo;
OsuSpriteText name;
2018-12-12 13:38:03 +08:00
ModDisplay modDisplay;
2018-12-07 15:20:05 +08:00
2018-05-29 12:51:04 +08:00
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"28242d"),
},
new Container
{
2018-12-14 13:20:03 +08:00
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
2018-05-29 12:51:04 +08:00
Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING },
Children = new Drawable[]
{
2018-12-14 13:20:03 +08:00
new FillFlowContainer
2018-05-29 12:51:04 +08:00
{
2018-12-14 13:20:03 +08:00
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 10),
2018-05-29 12:51:04 +08:00
Padding = new MarginPadding { Vertical = 20 },
Children = new Drawable[]
{
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
name = new OsuSpriteText { TextSize = 30 },
availabilityStatus = new OsuSpriteText { TextSize = 14 },
2018-12-14 13:20:03 +08:00
}
2018-05-29 12:51:04 +08:00
},
2018-12-12 13:38:03 +08:00
new FillFlowContainer
2018-05-29 12:51:04 +08:00
{
2018-12-12 13:38:03 +08:00
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 12:51:04 +08:00
},
},
2018-12-14 13:20:03 +08:00
new FillFlowContainer
2018-05-29 12:51:04 +08:00
{
2018-12-14 13:20:03 +08:00
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
AutoSizeAxes = Axes.X,
Height = 70,
Spacing = new Vector2(10, 0),
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
viewBeatmapButton = new ViewBeatmapButton(),
readyButton = new ReadyButton
2018-12-14 13:20:03 +08:00
{
Action = () => OnStart?.Invoke()
}
}
}
2018-05-29 12:51:04 +08:00
},
},
};
2018-12-07 15:20:05 +08:00
beatmapTypeInfo.Beatmap.BindTo(Beatmap);
beatmapTypeInfo.Type.BindTo(Type);
2018-12-12 13:38:03 +08:00
modDisplay.Current.BindTo(Mods);
viewBeatmapButton.Beatmap.BindTo(Beatmap);
readyButton.Beatmap.BindTo(Beatmap);
2018-12-07 15:20:05 +08:00
Availability.BindValueChanged(_ => updateAvailabilityStatus());
Status.BindValueChanged(_ => updateAvailabilityStatus());
Name.BindValueChanged(n => name.Text = n);
2018-05-29 12:51:04 +08:00
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
this.colours = colours;
}
protected override void LoadComplete()
{
base.LoadComplete();
updateAvailabilityStatus();
}
private void updateAvailabilityStatus()
{
2018-12-07 15:20:05 +08:00
if (!IsLoaded)
return;
if (Status.Value != null)
2018-05-29 12:51:04 +08:00
{
2018-12-07 15:20:05 +08:00
availabilityStatus.FadeColour(Status.Value.GetAppropriateColour(colours), 100);
availabilityStatus.Text = $"{Availability.Value.GetDescription()}, {Status.Value.Message}";
2018-05-29 12:51:04 +08:00
}
}
}
}