Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void TestMapWithUnknownMapper()
AddAssert("mapped by text not present", () =>
this.ChildrenOfType<OsuSpriteText>().All(spriteText => !containsAny(spriteText.Text.ToString(), "mapped", "by")));

AddAssert("play time displayed", () => this.ChildrenOfType<ExpandedPanelMiddleContent.PlayedOnText>().Any());
AddAssert("play time displayed", () => this.ChildrenOfType<PlayedOnText>().Any());
}

[Test]
Expand Down Expand Up @@ -137,7 +137,7 @@ public void TestWithDefaultDate()
showPanel(score);
});

AddAssert("play time not displayed", () => !this.ChildrenOfType<ExpandedPanelMiddleContent.PlayedOnText>().Any());
AddAssert("play time not displayed", () => !this.ChildrenOfType<PlayedOnText>().Any());
}

[Test]
Expand Down
2 changes: 2 additions & 0 deletions osu.Game/Rulesets/Mods/ModExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 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.

using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps;
Expand All @@ -20,6 +21,7 @@ public static Score CreateScoreFromReplayData(this ICreateReplayData mod, IBeatm
Replay = replayData.Replay,
ScoreInfo =
{
Date = DateTimeOffset.Now,
User = new APIUser
{
Id = replayData.User.OnlineID,
Expand Down
10 changes: 8 additions & 2 deletions osu.Game/Screens/Play/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private void load(OsuConfigManager config, OsuGameBase game, CancellationToken c
{
// underlay and gameplay should have access to the skinning sources.
createUnderlayComponents(Beatmap.Value),
createGameplayComponents(Beatmap.Value)
createGameplayComponents()
}
},
FailOverlay = new FailOverlay
Expand Down Expand Up @@ -426,6 +426,11 @@ private void load(OsuConfigManager config, OsuGameBase game, CancellationToken c
IsBreakTime.BindValueChanged(onBreakTimeChanged, true);
}

/// <summary>
/// Implement to add any components which should exist above gameplay but below the HUD.
/// </summary>
protected virtual Drawable CreateOverlayComponents() => Empty();

protected virtual GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) => new MasterGameplayClockContainer(beatmap, gameplayStart);

private Drawable createUnderlayComponents(WorkingBeatmap working)
Expand All @@ -451,7 +456,7 @@ private Drawable createUnderlayComponents(WorkingBeatmap working)
return container;
}

private Drawable createGameplayComponents(IWorkingBeatmap working) => new ScalingContainer(ScalingMode.Gameplay)
private Drawable createGameplayComponents() => new ScalingContainer(ScalingMode.Gameplay)
{
Children = new Drawable[]
{
Expand All @@ -474,6 +479,7 @@ private Drawable createOverlayComponents()
Children = new[]
{
DimmableStoryboard.OverlayLayerContainer.CreateProxy(),
CreateOverlayComponents(),
HUDOverlay = new HUDOverlay(DrawableRuleset, GameplayState.Mods, Configuration)
{
HoldToQuit =
Expand Down
25 changes: 25 additions & 0 deletions osu.Game/Screens/Play/ReplayPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osu.Game.Screens.Play.Leaderboards;
using osu.Game.Screens.Play.PlayerSettings;
using osu.Game.Screens.Ranking;
using osu.Game.Screens.Ranking.Expanded;
using osu.Game.Skinning;
using osu.Game.Users;

Expand Down Expand Up @@ -97,6 +100,7 @@ private void load(OsuConfigManager config)
playbackSettings.UserPlaybackRate.BindTo(master.UserPlaybackRate);

HUDOverlay.PlayerSettingsOverlay.AddAtStart(playbackSettings);

AddInternal(new RulesetSkinProvidingContainer(GameplayState.Ruleset, GameplayState.Beatmap, Beatmap.Value.Skin)
{
Child = failIndicator = new ReplayFailIndicator(GameplayClockContainer)
Expand All @@ -113,6 +117,27 @@ private void load(OsuConfigManager config)
});
}

protected override Drawable CreateOverlayComponents()
{
OsuTextFlowContainer message = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Style.Body) { AutoSizeAxes = Axes.Both };
message.AddText("Watching ");
message.AddText(Score.ScoreInfo.User.Username, s => s.Font = s.Font.With(weight: FontWeight.SemiBold));
message.AddText(" play ");
message.AddText(Beatmap.Value.BeatmapInfo.GetDisplayTitleRomanisable(), s => s.Font = s.Font.With(weight: FontWeight.SemiBold));
message.AddText(" on ");
message.AddArbitraryDrawable(new PlayedOnText(Score.ScoreInfo.Date, false)
{
Font = OsuFont.Style.Body.With(weight: FontWeight.SemiBold),
});

return new ScrollingMessage(message)
{
Y = 100,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
};
}

protected override void PrepareReplay()
{
DrawableRuleset?.SetReplayScore(Score);
Expand Down
44 changes: 44 additions & 0 deletions osu.Game/Screens/Play/ScrollingMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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.

using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;

namespace osu.Game.Screens.Play
{
public partial class ScrollingMessage : CompositeDrawable
{
private readonly Drawable messageContent;

public ScrollingMessage(Drawable messageContent)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;

InternalChild = this.messageContent = messageContent;
}

protected override void LoadComplete()
{
base.LoadComplete();

this.FadeInFromZero(2000, Easing.OutQuint);
resetMessagePosition();
}

protected override void Update()
{
base.Update();

if (messageContent.X + messageContent.DrawWidth > 0)
messageContent.X -= (float)Clock.ElapsedFrameTime * 0.05f;
else
resetMessagePosition();
}

private void resetMessagePosition()
{
messageContent.X = DrawWidth + 10;
}
}
}
20 changes: 13 additions & 7 deletions osu.Game/Screens/Play/SpectatorPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.Containers;
using osu.Game.Online.Spectator;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Replays.Types;
Expand All @@ -29,17 +29,23 @@ protected SpectatorPlayer(Score score, PlayerConfiguration? configuration = null
this.score = score;
}

[BackgroundDependencyLoader]
private void load()
protected override Drawable CreateOverlayComponents()
{
AddInternal(new OsuSpriteText
// TODO: This should be customised for `MultiplayerSpectatorPlayer` to be static and only show the player name.
// Or maybe we should completely redesign this to show the user avatar and other things if that happens.
Comment on lines +34 to +35
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For when is this TODO? Is it for this PR or for an indeterminate future?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the latter. i'd want to get a designer involved. arguably that should be done before implementing this at all 🤷

OsuTextFlowContainer message = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Style.Body) { AutoSizeAxes = Axes.Both };
message.AddText("Watching ");
message.AddText(Score.ScoreInfo.User.Username, s => s.Font = s.Font.With(weight: FontWeight.SemiBold));
message.AddText(" play ");
message.AddText(Beatmap.Value.BeatmapInfo.GetDisplayTitleRomanisable(), s => s.Font = s.Font.With(weight: FontWeight.SemiBold));
message.AddText(" live", s => s.Font = s.Font.With(weight: FontWeight.Bold));

return new ScrollingMessage(message)
{
Text = $"Watching {score.ScoreInfo.User.Username} playing live!",
Font = OsuFont.Default.With(size: 30),
Y = 100,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
});
};
}

protected override void LoadComplete()
Expand Down
40 changes: 1 addition & 39 deletions osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
// 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.

using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
Expand Down Expand Up @@ -237,7 +233,7 @@ private void load(RealmAccess realmAccess, BeatmapDifficultyCache beatmapDifficu
});

if (score.Date != default)
AddInternal(new PlayedOnText(score.Date));
AddInternal(new PlayedOnText(score.Date, true));
}

protected override void LoadComplete()
Expand Down Expand Up @@ -268,40 +264,6 @@ protected override void LoadComplete()
});
}

public partial class PlayedOnText : OsuSpriteText
{
private readonly DateTimeOffset time;
private readonly Bindable<bool> prefer24HourTime = new Bindable<bool>();

public PlayedOnText(DateTimeOffset time)
{
this.time = time;

Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold);
}

[BackgroundDependencyLoader]
private void load(OsuConfigManager configManager)
{
configManager.BindWith(OsuSetting.Prefer24HourTime, prefer24HourTime);
}

protected override void LoadComplete()
{
base.LoadComplete();

prefer24HourTime.BindValueChanged(_ => updateDisplay(), true);
}

private void updateDisplay()
{
Text = LocalisableString.Format("Played on {0}",
time.ToLocalTime().ToLocalisableString(prefer24HourTime.Value ? @"d MMMM yyyy HH:mm" : @"d MMMM yyyy h:mm tt"));
}
}

internal partial class ClickableMetadata : OsuHoverContainer
{
[Resolved]
Expand Down
55 changes: 55 additions & 0 deletions osu.Game/Screens/Ranking/Expanded/PlayedOnText.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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.

using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;

namespace osu.Game.Screens.Ranking.Expanded
{
public partial class PlayedOnText : OsuSpriteText
{
private readonly DateTimeOffset time;
private readonly bool withPrefix;
private readonly Bindable<bool> prefer24HourTime = new Bindable<bool>();

public PlayedOnText(DateTimeOffset time, bool withPrefix)
{
this.time = time;
this.withPrefix = withPrefix;

Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold);
}

[BackgroundDependencyLoader]
private void load(OsuConfigManager configManager)
{
configManager.BindWith(OsuSetting.Prefer24HourTime, prefer24HourTime);
}

protected override void LoadComplete()
{
base.LoadComplete();

prefer24HourTime.BindValueChanged(_ => updateDisplay(), true);
}

private void updateDisplay()
{
var timeText = time.ToLocalTime().ToLocalisableString(prefer24HourTime.Value ? @"d MMMM yyyy HH:mm" : @"d MMMM yyyy h:mm tt");

if (withPrefix)
Text = LocalisableString.Format("Played on {0}", timeText);
else
Text = timeText;
}
}
}
Loading