mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 14:12:56 +08:00
Merge branch 'master' into block-exit-if-save-failed
This commit is contained in:
commit
2698ec9206
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user