2020-12-22 17:25:45 +08:00
|
|
|
// 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.
|
|
|
|
|
2021-02-05 14:46:03 +08:00
|
|
|
using System;
|
2021-01-18 16:09:45 +08:00
|
|
|
using System.Diagnostics;
|
2020-12-22 17:25:45 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2021-01-18 16:09:45 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using osu.Game.Online;
|
2020-12-25 12:38:11 +08:00
|
|
|
using osu.Game.Online.Multiplayer;
|
2021-01-18 16:09:45 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
2020-12-22 17:25:45 +08:00
|
|
|
using osuTK;
|
2021-01-18 16:09:45 +08:00
|
|
|
using osuTK.Graphics;
|
2020-12-22 17:25:45 +08:00
|
|
|
|
2020-12-25 23:50:00 +08:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
2020-12-22 17:25:45 +08:00
|
|
|
{
|
|
|
|
public class StateDisplay : CompositeDrawable
|
|
|
|
{
|
2021-01-18 16:09:45 +08:00
|
|
|
private const double fade_time = 50;
|
2020-12-22 17:25:45 +08:00
|
|
|
|
|
|
|
private SpriteIcon icon;
|
2021-01-18 16:09:45 +08:00
|
|
|
private OsuSpriteText text;
|
|
|
|
private ProgressBar progressBar;
|
2020-12-22 17:25:45 +08:00
|
|
|
|
2021-01-18 16:09:45 +08:00
|
|
|
public StateDisplay()
|
2020-12-22 17:25:45 +08:00
|
|
|
{
|
2021-01-18 16:09:45 +08:00
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
Alpha = 0;
|
2020-12-22 17:25:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2021-01-18 16:09:45 +08:00
|
|
|
private void load(OsuColour colours)
|
2020-12-22 17:25:45 +08:00
|
|
|
{
|
2021-01-18 16:09:45 +08:00
|
|
|
this.colours = colours;
|
|
|
|
|
2020-12-22 17:25:45 +08:00
|
|
|
InternalChild = new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2021-01-18 16:09:45 +08:00
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
2020-12-22 17:25:45 +08:00
|
|
|
Spacing = new Vector2(5),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
icon = new SpriteIcon
|
|
|
|
{
|
2021-01-18 16:09:45 +08:00
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
2020-12-22 17:25:45 +08:00
|
|
|
Icon = FontAwesome.Solid.CheckCircle,
|
|
|
|
Size = new Vector2(12),
|
2021-01-18 16:09:45 +08:00
|
|
|
},
|
|
|
|
new CircularContainer
|
|
|
|
{
|
|
|
|
Masking = true,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
progressBar = new ProgressBar(false)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
BackgroundColour = Color4.Black.Opacity(0.4f),
|
|
|
|
FillColour = colours.Blue,
|
|
|
|
Alpha = 0f,
|
|
|
|
},
|
|
|
|
text = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Padding = new MarginPadding { Horizontal = 5f, Vertical = 1f },
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 12),
|
|
|
|
Colour = Color4Extensions.FromHex("#DDFFFF")
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2020-12-22 17:25:45 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-01-18 16:09:45 +08:00
|
|
|
private OsuColour colours;
|
2020-12-22 17:25:45 +08:00
|
|
|
|
2021-01-18 16:09:45 +08:00
|
|
|
public void UpdateStatus(MultiplayerUserState state, BeatmapAvailability availability)
|
2020-12-22 17:25:45 +08:00
|
|
|
{
|
2021-02-05 14:46:03 +08:00
|
|
|
// the only case where the progress bar is used does its own local fade in.
|
|
|
|
// starting by fading out is a sane default.
|
|
|
|
progressBar.FadeOut(fade_time);
|
|
|
|
this.FadeIn(fade_time);
|
|
|
|
|
|
|
|
switch (state)
|
2021-01-18 16:09:45 +08:00
|
|
|
{
|
2021-02-05 14:46:03 +08:00
|
|
|
case MultiplayerUserState.Idle:
|
|
|
|
showBeatmapAvailability(availability);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MultiplayerUserState.Ready:
|
|
|
|
text.Text = "ready";
|
|
|
|
icon.Icon = FontAwesome.Solid.CheckCircle;
|
|
|
|
icon.Colour = Color4Extensions.FromHex("#AADD00");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MultiplayerUserState.WaitingForLoad:
|
|
|
|
text.Text = "loading";
|
|
|
|
icon.Icon = FontAwesome.Solid.PauseCircle;
|
|
|
|
icon.Colour = colours.Yellow;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MultiplayerUserState.Loaded:
|
|
|
|
text.Text = "loaded";
|
|
|
|
icon.Icon = FontAwesome.Solid.DotCircle;
|
|
|
|
icon.Colour = colours.YellowLight;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MultiplayerUserState.Playing:
|
|
|
|
text.Text = "playing";
|
|
|
|
icon.Icon = FontAwesome.Solid.PlayCircle;
|
|
|
|
icon.Colour = colours.BlueLight;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MultiplayerUserState.FinishedPlay:
|
|
|
|
text.Text = "results pending";
|
|
|
|
icon.Icon = FontAwesome.Solid.ArrowAltCircleUp;
|
|
|
|
icon.Colour = colours.BlueLighter;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MultiplayerUserState.Results:
|
|
|
|
text.Text = "results";
|
|
|
|
icon.Icon = FontAwesome.Solid.ArrowAltCircleUp;
|
|
|
|
icon.Colour = colours.BlueLighter;
|
|
|
|
break;
|
|
|
|
|
2021-04-07 15:40:24 +08:00
|
|
|
case MultiplayerUserState.Spectating:
|
|
|
|
text.Text = "spectating";
|
2021-04-08 14:54:58 +08:00
|
|
|
icon.Icon = FontAwesome.Solid.Binoculars;
|
2021-04-07 15:40:24 +08:00
|
|
|
icon.Colour = colours.BlueLight;
|
|
|
|
break;
|
|
|
|
|
2021-02-05 14:46:03 +08:00
|
|
|
default:
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(state), state, null);
|
2021-01-18 16:09:45 +08:00
|
|
|
}
|
2021-02-05 14:46:03 +08:00
|
|
|
}
|
2021-01-18 16:09:45 +08:00
|
|
|
|
2021-02-05 14:46:03 +08:00
|
|
|
private void showBeatmapAvailability(BeatmapAvailability availability)
|
|
|
|
{
|
|
|
|
switch (availability.State)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
this.FadeOut(fade_time);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DownloadState.NotDownloaded:
|
|
|
|
text.Text = "no map";
|
|
|
|
icon.Icon = FontAwesome.Solid.MinusCircle;
|
|
|
|
icon.Colour = colours.RedLight;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DownloadState.Downloading:
|
|
|
|
Debug.Assert(availability.DownloadProgress != null);
|
|
|
|
|
|
|
|
progressBar.FadeIn(fade_time);
|
|
|
|
progressBar.CurrentTime = availability.DownloadProgress.Value;
|
|
|
|
|
|
|
|
text.Text = "downloading map";
|
|
|
|
icon.Icon = FontAwesome.Solid.ArrowAltCircleDown;
|
|
|
|
icon.Colour = colours.Blue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DownloadState.Importing:
|
|
|
|
text.Text = "importing map";
|
|
|
|
icon.Icon = FontAwesome.Solid.ArrowAltCircleDown;
|
|
|
|
icon.Colour = colours.Yellow;
|
|
|
|
break;
|
2020-12-22 17:25:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|