"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,55 +75,83 @@ namespace osu.Game.Screens.Play
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load(OsuColour colours)
{ {
InternalChildren = new Drawable[] InternalChild = new Container
{ {
new FillFlowContainer Masking = true,
CornerRadius = 20,
AutoSizeAxes = Axes.Both,
AutoSizeDuration = 500,
AutoSizeEasing = Easing.OutQuint,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{ {
AutoSizeAxes = Axes.Both, new Box
Direction = FillDirection.Vertical,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Spacing = new Vector2(15),
Children = new Drawable[]
{ {
new OsuSpriteText Colour = colours.GreySeafoamDark,
RelativeSizeAxes = Axes.Both,
},
new FillFlowContainer
{
Margin = new MarginPadding(20),
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Spacing = new Vector2(15),
Children = new Drawable[]
{ {
Text = "Currently spectating", new OsuSpriteText
Font = OsuFont.Default.With(size: 30), {
Anchor = Anchor.Centre, Text = "Spectator Mode",
Origin = Anchor.Centre, Font = OsuFont.Default.With(size: 30),
}, Anchor = Anchor.Centre,
new UserGridPanel(targetUser) Origin = Anchor.Centre,
{ },
Width = 290, new FillFlowContainer
Anchor = Anchor.Centre, {
Origin = Anchor.Centre, AutoSizeAxes = Axes.Both,
}, Direction = FillDirection.Horizontal,
new OsuSpriteText Anchor = Anchor.Centre,
{ Origin = Anchor.Centre,
Text = "playing", Spacing = new Vector2(15),
Font = OsuFont.Default.With(size: 30), Children = new Drawable[]
Anchor = Anchor.Centre, {
Origin = Anchor.Centre, new UserGridPanel(targetUser)
}, {
beatmapPanelContainer = new Container Anchor = Anchor.CentreLeft,
{ Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both, Height = 145,
Anchor = Anchor.Centre, Width = 290,
Origin = Anchor.Centre, },
}, new SpriteIcon
watchButton = new TriangleButton {
{ Size = new Vector2(40),
Text = "Watch", Icon = FontAwesome.Solid.ArrowRight,
Width = 250, Anchor = Anchor.CentreLeft,
Anchor = Anchor.Centre, Origin = Anchor.CentreLeft,
Origin = Anchor.Centre, },
Action = attemptStart beatmapPanelContainer = new Container
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
}
},
watchButton = new PurpleTriangleButton
{
Text = "Start Watching",
Width = 250,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
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;