"Improve" visuals of spectator screen

This commit is contained in:
Dean Herbert
2020-10-28 18:35:20 +09:00
parent 2d73dfbe39
commit 344ff8f4bc

View File

@ -9,6 +9,8 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -24,6 +26,7 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Replays.Types; using osu.Game.Rulesets.Replays.Types;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Multi.Match.Components;
using osu.Game.Users; using osu.Game.Users;
using osuTK; using osuTK;
@ -72,12 +75,27 @@ namespace osu.Game.Screens.Play
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load(OsuColour colours)
{ {
InternalChildren = new Drawable[] InternalChild = new Container
{ {
Masking = true,
CornerRadius = 20,
AutoSizeAxes = Axes.Both,
AutoSizeDuration = 500,
AutoSizeEasing = Easing.OutQuint,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
new Box
{
Colour = colours.GreySeafoamDark,
RelativeSizeAxes = Axes.Both,
},
new FillFlowContainer new FillFlowContainer
{ {
Margin = new MarginPadding(20),
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -87,40 +105,53 @@ namespace osu.Game.Screens.Play
{ {
new OsuSpriteText new OsuSpriteText
{ {
Text = "Currently spectating", Text = "Spectator Mode",
Font = OsuFont.Default.With(size: 30), Font = OsuFont.Default.With(size: 30),
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
}, },
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Spacing = new Vector2(15),
Children = new Drawable[]
{
new UserGridPanel(targetUser) new UserGridPanel(targetUser)
{ {
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Height = 145,
Width = 290, Width = 290,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}, },
new OsuSpriteText new SpriteIcon
{ {
Text = "playing", Size = new Vector2(40),
Font = OsuFont.Default.With(size: 30), Icon = FontAwesome.Solid.ArrowRight,
Anchor = Anchor.Centre, Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre, Origin = Anchor.CentreLeft,
}, },
beatmapPanelContainer = new Container beatmapPanelContainer = new Container
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre, Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre, Origin = Anchor.CentreLeft,
}, },
watchButton = new TriangleButton }
},
watchButton = new PurpleTriangleButton
{ {
Text = "Watch", Text = "Start Watching",
Width = 250, Width = 250,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Action = attemptStart Action = attemptStart
} }
} }
}, }
}
}; };
} }
@ -141,7 +172,7 @@ namespace osu.Game.Screens.Play
private void beatmapUpdated(ValueChangedEvent<WeakReference<BeatmapSetInfo>> beatmap) private void beatmapUpdated(ValueChangedEvent<WeakReference<BeatmapSetInfo>> beatmap)
{ {
if (beatmap.NewValue.TryGetTarget(out var beatmapSet) && beatmapSet.Beatmaps.Any(b => b.OnlineBeatmapID == state.BeatmapID)) if (beatmap.NewValue.TryGetTarget(out var beatmapSet) && beatmapSet.Beatmaps.Any(b => b.OnlineBeatmapID == state.BeatmapID))
attemptStart(); Schedule(attemptStart);
} }
private void userSentFrames(int userId, FrameDataBundle data) private void userSentFrames(int userId, FrameDataBundle data)
@ -189,14 +220,18 @@ namespace osu.Game.Screens.Play
replay = null; replay = null;
} }
// not really going to start anything, but will clear the beatmap card out. clearDisplay();
attemptStart(); }
private void clearDisplay()
{
watchButton.Enabled.Value = false;
beatmapPanelContainer.Clear();
} }
private void attemptStart() private void attemptStart()
{ {
watchButton.Enabled.Value = false; clearDisplay();
showBeatmapPanel(state); showBeatmapPanel(state);
var resolvedRuleset = rulesets.AvailableRulesets.FirstOrDefault(r => r.ID == state.RulesetID)?.CreateInstance(); var resolvedRuleset = rulesets.AvailableRulesets.FirstOrDefault(r => r.ID == state.RulesetID)?.CreateInstance();
@ -213,6 +248,9 @@ namespace osu.Game.Screens.Play
if (resolvedBeatmap == null) if (resolvedBeatmap == null)
return; return;
if (replay == null)
return;
var scoreInfo = new ScoreInfo var scoreInfo = new ScoreInfo
{ {
Beatmap = resolvedBeatmap, Beatmap = resolvedBeatmap,
@ -236,7 +274,7 @@ namespace osu.Game.Screens.Play
private void showBeatmapPanel(SpectatorState state) private void showBeatmapPanel(SpectatorState state)
{ {
if (state.BeatmapID == null) if (state?.BeatmapID == null)
{ {
beatmapPanelContainer.Clear(); beatmapPanelContainer.Clear();
return; return;