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 @@ -3,7 +3,6 @@

using System;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
Expand All @@ -21,24 +20,20 @@

namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components
{
public partial class RankedPlayStageDisplay : CompositeDrawable
public partial class RankedPlayStageDisplay : VisibilityContainer
{
public required LocalisableString Heading { get; init; }

public required LocalisableString Caption { get; init; }

public Color4? CaptionColour { get; init; }

[Resolved]
private MultiplayerClient client { get; set; } = null!;

private readonly RankedPlayColourScheme colourScheme;

private Drawable headingTextBackground = null!;
private OsuSpriteText headingText = null!;
private Drawable progressBar = null!;
private OsuSpriteText progressText = null!;

private OsuSpriteText? headingText;
private OsuSpriteText? captionText;

private DateTimeOffset countdownStartTime;
private DateTimeOffset countdownEndTime;

Expand All @@ -50,7 +45,7 @@ public RankedPlayStageDisplay(RankedPlayColourScheme colourScheme)
}

[BackgroundDependencyLoader]
private void load(AudioManager audio)
private void load()
{
const float phase_text_background_height = 55;
Vector2 progressBarSize = new Vector2(300, 25);
Expand Down Expand Up @@ -162,7 +157,7 @@ private void load(AudioManager audio)
}
]
},
new OsuSpriteText
captionText = new OsuSpriteText
{
Margin = new MarginPadding
{
Expand All @@ -176,6 +171,54 @@ private void load(AudioManager audio)
};
}

private LocalisableString heading;

/// <summary>
/// Heading text to be displayed indicating the purpose of the current stage.
/// </summary>
public LocalisableString Heading
{
get => heading;
set
{
heading = value;
if (headingText != null)
headingText.Text = value;
}
}

private LocalisableString caption;

/// <summary>
/// Subtitle text to be displayed indicating the action a user should take in the current stage.
/// </summary>
public LocalisableString Caption
{
get => caption;
set
{
caption = value;
if (captionText != null)
captionText.Text = value;
}
}

private Color4? captionColour;

/// <summary>
/// Overrides the default caption colour from the colour scheme with a custom one.
/// </summary>
public Color4? CaptionColour
{
get => captionColour;
set
{
captionColour = value;
if (captionText != null)
captionText.Colour = value ?? colourScheme.Primary;
}
}

protected override void LoadComplete()
{
base.LoadComplete();
Expand All @@ -194,7 +237,7 @@ protected override void Update()
{
base.Update();

headingTextBackground.Width = headingText.DrawWidth + 80;
headingTextBackground.Width = headingText!.DrawWidth + 80;

TimeSpan duration = countdownEndTime - countdownStartTime;
TimeSpan remaining = countdownEndTime - DateTimeOffset.Now;
Expand Down Expand Up @@ -226,6 +269,16 @@ private void onCountdownStopped(MultiplayerCountdown countdown) => Scheduler.Add
countdownEndTime = DateTimeOffset.Now;
});

protected override void PopIn()
{
this.FadeIn();
}

protected override void PopOut()
{
this.FadeOut();
}

protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Localisation;
using osu.Game.Audio;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
Expand All @@ -33,6 +34,9 @@ public partial class DiscardScreen : RankedPlaySubScreen

public CardFlow CenterRow { get; private set; } = null!;

protected override LocalisableString StageHeading => "Discard Phase";
protected override LocalisableString StageCaption => "Replace cards from your hand";

private PlayerHandOfCards playerHand = null!;
private ShearedButton discardButton = null!;
private OsuTextFlowContainer explainer = null!;
Expand All @@ -57,6 +61,11 @@ public partial class DiscardScreen : RankedPlaySubScreen
private DateTimeOffset stageEndTime;
private TimeSpan stageDuration;

public DiscardScreen()
{
StageDisplay.CaptionColour = Color4.White;
}

[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
Expand All @@ -72,13 +81,6 @@ private void load(AudioManager audio)
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
new RankedPlayStageDisplay(RankedPlayColourScheme.Blue)
{
Heading = "Discard Phase",
Caption = "Replace cards from your hand",
CaptionColour = Color4.White,
Margin = new MarginPadding { Top = 60 },
},
discardButton = new ShearedButton
{
Name = "Discard Button",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
Expand All @@ -24,6 +25,9 @@ public partial class EndedScreen : RankedPlaySubScreen
/// </summary>
public Action<bool>? ExitRequested { get; init; }

protected override LocalisableString StageHeading => "Results";
protected override LocalisableString StageCaption => string.Empty;

[Resolved]
private RankedPlayMatchInfo matchInfo { get; set; } = null!;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osuTK;
Expand All @@ -12,6 +13,9 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay
{
public partial class GameplayScreen : RankedPlaySubScreen
{
protected override LocalisableString StageHeading => "Gameplay";
protected override LocalisableString StageCaption => string.Empty;

[BackgroundDependencyLoader]
private void load()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Framework.Logging;
using osu.Game.Database;
using osu.Game.Graphics.Containers;
Expand All @@ -24,6 +25,9 @@ public partial class GameplayWarmupScreen : RankedPlaySubScreen
{
public override bool ShowBeatmapBackground => true;

protected override LocalisableString StageHeading => "Gameplay";
protected override LocalisableString StageCaption => string.Empty;

[Cached(typeof(IBindable<SongSelect.BeatmapSetLookupResult?>))]
private readonly Bindable<SongSelect.BeatmapSetLookupResult?> lastLookupResult = new Bindable<SongSelect.BeatmapSetLookupResult?>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
using osu.Game.Database;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
Expand All @@ -20,9 +21,13 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Intro
{
public partial class IntroScreen : RankedPlaySubScreen
{
protected override LocalisableString StageHeading => string.Empty;
protected override LocalisableString StageCaption => string.Empty;

public IntroScreen()
{
CornerPieceVisibility.Value = Visibility.Hidden;
CountdownVisibility.Value = Visibility.Hidden;
}

[Resolved]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Framework.Logging;
using osu.Game.Audio;
using osu.Game.Online.Multiplayer.MatchTypes.RankedPlay;
Expand All @@ -22,6 +23,11 @@ public partial class OpponentPickScreen : RankedPlaySubScreen
{
public CardFlow CenterRow { get; private set; } = null!;

protected override LocalisableString StageHeading => "Pick Phase";
protected override LocalisableString StageCaption => "Waiting for your opponent...";

protected override RankedPlayColourScheme ColourScheme => RankedPlayColourScheme.Red;

private PlayerHandOfCards playerHand = null!;
private OpponentHandOfCards opponentHand = null!;

Expand All @@ -46,12 +52,6 @@ private void load(AudioManager audio)
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
new RankedPlayStageDisplay(RankedPlayColourScheme.Red)
{
Heading = "Pick Phase",
Caption = "Waiting for your opponent...",
Margin = new MarginPadding { Top = 60 },
},
];

CenterColumn.Children =
Expand Down
10 changes: 4 additions & 6 deletions osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/PickScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Framework.Logging;
using osu.Game.Audio;
using osu.Game.Online.Multiplayer;
Expand All @@ -27,6 +28,9 @@ public partial class PickScreen : RankedPlaySubScreen

public CardFlow CenterRow { get; private set; } = null!;

protected override LocalisableString StageHeading => "Pick Phase";
protected override LocalisableString StageCaption => "It's your turn to play a card!";

private PlayerHandOfCards playerHand = null!;
private OpponentHandOfCards opponentHand = null!;

Expand Down Expand Up @@ -65,12 +69,6 @@ private void load(AudioManager audio)
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
new RankedPlayStageDisplay(RankedPlayColourScheme.Blue)
{
Heading = "Pick Phase",
Caption = "It's your turn to play a card!",
Margin = new MarginPadding { Top = 60 },
},
];

CenterColumn.Children =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay.Components;
using osuTK;
Expand All @@ -18,19 +19,34 @@ public abstract partial class RankedPlaySubScreen : Container
public const float CENTERED_CARD_SCALE = 1.2f;

public readonly Bindable<Visibility> CornerPieceVisibility = new Bindable<Visibility>(Visibility.Visible);
protected readonly Bindable<Visibility> CountdownVisibility = new Bindable<Visibility>(Visibility.Visible);

public virtual bool ShowBeatmapBackground => false;

/// <summary>
/// Heading text to be displayed indicating the purpose of the current stage.
/// </summary>
protected abstract LocalisableString StageHeading { get; }

/// <summary>
/// Subtitle text to be displayed indicating the action a user should take in the current stage.
/// </summary>
protected abstract LocalisableString StageCaption { get; }

/// <summary>
/// The colour scheme commonly used for components of this screen.
/// </summary>
protected virtual RankedPlayColourScheme ColourScheme => RankedPlayColourScheme.Blue;

[Resolved]
private MultiplayerClient client { get; set; } = null!;

protected MultiplayerClient Client => client;

protected override Container<Drawable> Content { get; }

protected readonly Container CenterColumn;

protected readonly FillFlowContainer ButtonsContainer;
protected readonly RankedPlayStageDisplay StageDisplay;

protected RankedPlaySubScreen()
{
Expand Down Expand Up @@ -62,6 +78,13 @@ protected RankedPlaySubScreen()
Direction = FillDirection.Vertical,
Spacing = new Vector2(8)
},
StageDisplay = new RankedPlayStageDisplay(ColourScheme)
{
Heading = StageHeading,
Caption = StageCaption,
Margin = new MarginPadding { Top = 60 },
State = { BindTarget = CountdownVisibility }
},
];
}

Expand Down
Loading
Loading