1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 16:32:54 +08:00

Merge branch 'master' into block-exit-if-save-failed

This commit is contained in:
Bartłomiej Dach 2023-08-08 23:41:03 +02:00 committed by GitHub
commit 2698ec9206
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 40 deletions

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -23,47 +21,43 @@ namespace osu.Game.Screens.Play.Break
public Bindable<T> Current = new Bindable<T>();
private readonly OsuSpriteText text;
private readonly OsuSpriteText valueText;
private readonly LocalisableString name;
private readonly string prefix;
private OsuSpriteText valueText = null!;
public BreakInfoLine(LocalisableString name, string prefix = @"")
public BreakInfoLine(LocalisableString name)
{
this.prefix = prefix;
this.name = name;
AutoSizeAxes = Axes.Y;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Children = new Drawable[]
{
text = new OsuSpriteText
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreRight,
Text = name,
Font = OsuFont.GetFont(size: 17),
Margin = new MarginPadding { Right = margin }
Margin = new MarginPadding { Right = margin },
Colour = colours.Yellow,
},
valueText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreLeft,
Text = prefix + @"-",
Text = @"-",
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17),
Margin = new MarginPadding { Left = margin }
Margin = new MarginPadding { Left = margin },
Colour = colours.YellowLight,
}
};
Current.ValueChanged += currentValueChanged;
}
private void currentValueChanged(ValueChangedEvent<T> e)
{
string newText = prefix + Format(e.NewValue);
if (valueText.Text == newText)
return;
valueText.Text = newText;
Current.BindValueChanged(text => valueText.Text = Format(text.NewValue));
}
protected virtual LocalisableString Format(T count)
@ -71,21 +65,14 @@ namespace osu.Game.Screens.Play.Break
if (count is Enum countEnum)
return countEnum.GetDescription();
return count.ToString();
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
text.Colour = colours.Yellow;
valueText.Colour = colours.YellowLight;
return count.ToString() ?? string.Empty;
}
}
public partial class PercentageBreakInfoLine : BreakInfoLine<double>
{
public PercentageBreakInfoLine(LocalisableString name, string prefix = "")
: base(name, prefix)
public PercentageBreakInfoLine(LocalisableString name)
: base(name)
{
}

View File

@ -46,13 +46,14 @@ namespace osu.Game.Screens.Play
private readonly Container remainingTimeBox;
private readonly RemainingTimeCounter remainingTimeCounter;
private readonly BreakArrows breakArrows;
private readonly ScoreProcessor scoreProcessor;
private readonly BreakInfo info;
public BreakOverlay(bool letterboxing, ScoreProcessor scoreProcessor)
{
this.scoreProcessor = scoreProcessor;
RelativeSizeAxes = Axes.Both;
BreakInfo info;
Child = fadeContainer = new Container
{
Alpha = 0,
@ -102,18 +103,18 @@ namespace osu.Game.Screens.Play
}
}
};
if (scoreProcessor != null)
{
info.AccuracyDisplay.Current.BindTo(scoreProcessor.Accuracy);
info.GradeDisplay.Current.BindTo(scoreProcessor.Rank);
}
}
protected override void LoadComplete()
{
base.LoadComplete();
initializeBreaks();
if (scoreProcessor != null)
{
info.AccuracyDisplay.Current.BindTo(scoreProcessor.Accuracy);
info.GradeDisplay.Current.BindTo(scoreProcessor.Rank);
}
}
private void initializeBreaks()