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 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.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Online.Multiplayer;
|
|
|
|
|
using osu.Game.Overlays.SearchableList;
|
|
|
|
|
using osu.Game.Screens.Multi.Components;
|
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 const float HEIGHT = 128;
|
|
|
|
|
|
2018-12-07 15:20:05 +08:00
|
|
|
|
private readonly OsuSpriteText availabilityStatus;
|
2018-05-29 14:24:38 +08:00
|
|
|
|
private readonly ReadyButton readyButton;
|
2018-05-29 12:51:04 +08:00
|
|
|
|
|
|
|
|
|
private OsuColour colours;
|
|
|
|
|
|
2018-05-29 14:24:38 +08:00
|
|
|
|
public Bindable<bool> Ready => readyButton.Ready;
|
|
|
|
|
|
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-05-29 12:51:04 +08:00
|
|
|
|
|
|
|
|
|
public Info()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Height = HEIGHT;
|
|
|
|
|
|
2018-12-07 15:20:05 +08:00
|
|
|
|
BeatmapTypeInfo beatmapTypeInfo;
|
2018-12-10 12:18:03 +08:00
|
|
|
|
OsuSpriteText name;
|
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
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING },
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Padding = new MarginPadding { Vertical = 20 },
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2018-12-10 12:18:03 +08:00
|
|
|
|
name = new OsuSpriteText { TextSize = 30 },
|
|
|
|
|
availabilityStatus = new OsuSpriteText { TextSize = 14 },
|
2018-05-29 12:51:04 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
beatmapTypeInfo = new BeatmapTypeInfo
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2018-05-29 14:24:38 +08:00
|
|
|
|
readyButton = new ReadyButton
|
2018-05-29 12:51:04 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2018-06-21 09:19:37 +08:00
|
|
|
|
Size = new Vector2(200, 1),
|
2018-05-29 12:51:04 +08:00
|
|
|
|
Padding = new MarginPadding { Vertical = 10 },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
2018-12-07 15:20:05 +08:00
|
|
|
|
|
2018-12-07 18:38:46 +08:00
|
|
|
|
beatmapTypeInfo.Beatmap.BindTo(Beatmap);
|
|
|
|
|
beatmapTypeInfo.Type.BindTo(Type);
|
|
|
|
|
|
2018-12-07 15:20:05 +08:00
|
|
|
|
Availability.BindValueChanged(_ => updateAvailabilityStatus());
|
|
|
|
|
Status.BindValueChanged(_ => updateAvailabilityStatus());
|
2018-12-10 12:18:03 +08:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class ReadyButton : TriangleButton
|
|
|
|
|
{
|
|
|
|
|
public readonly Bindable<bool> Ready = new Bindable<bool>();
|
|
|
|
|
|
|
|
|
|
protected override SpriteText CreateText() => new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Depth = -1,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Font = @"Exo2.0-Light",
|
|
|
|
|
TextSize = 30,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
BackgroundColour = OsuColour.FromHex(@"1187aa");
|
|
|
|
|
Triangles.ColourLight = OsuColour.FromHex(@"277b9c");
|
|
|
|
|
Triangles.ColourDark = OsuColour.FromHex(@"1f6682");
|
|
|
|
|
Triangles.TriangleScale = 1.5f;
|
|
|
|
|
|
2018-05-29 14:03:51 +08:00
|
|
|
|
Container active;
|
|
|
|
|
Add(active = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0f,
|
|
|
|
|
Child = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0.15f,
|
|
|
|
|
Blending = BlendingMode.Additive,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2018-06-21 09:19:37 +08:00
|
|
|
|
Action = () => Ready.Value = !Ready.Value;
|
|
|
|
|
|
|
|
|
|
Ready.BindValueChanged(value =>
|
2018-05-29 12:51:04 +08:00
|
|
|
|
{
|
|
|
|
|
if (value)
|
2018-05-29 14:03:51 +08:00
|
|
|
|
{
|
2018-05-29 12:51:04 +08:00
|
|
|
|
Text = "Not Ready";
|
2018-05-29 14:03:51 +08:00
|
|
|
|
active.FadeIn(200);
|
|
|
|
|
}
|
2018-05-29 12:51:04 +08:00
|
|
|
|
else
|
2018-05-29 14:03:51 +08:00
|
|
|
|
{
|
2018-05-29 12:51:04 +08:00
|
|
|
|
Text = "Ready";
|
2018-05-29 14:03:51 +08:00
|
|
|
|
active.FadeOut(200);
|
|
|
|
|
}
|
2018-06-21 09:19:37 +08:00
|
|
|
|
}, true);
|
2018-05-29 12:51:04 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|