mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 04:42:58 +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.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -23,47 +21,43 @@ namespace osu.Game.Screens.Play.Break
|
|||||||
|
|
||||||
public Bindable<T> Current = new Bindable<T>();
|
public Bindable<T> Current = new Bindable<T>();
|
||||||
|
|
||||||
private readonly OsuSpriteText text;
|
private readonly LocalisableString name;
|
||||||
private readonly OsuSpriteText valueText;
|
|
||||||
|
|
||||||
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;
|
AutoSizeAxes = Axes.Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
text = new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
Text = name,
|
Text = name,
|
||||||
Font = OsuFont.GetFont(size: 17),
|
Font = OsuFont.GetFont(size: 17),
|
||||||
Margin = new MarginPadding { Right = margin }
|
Margin = new MarginPadding { Right = margin },
|
||||||
|
Colour = colours.Yellow,
|
||||||
},
|
},
|
||||||
valueText = new OsuSpriteText
|
valueText = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Text = prefix + @"-",
|
Text = @"-",
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17),
|
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17),
|
||||||
Margin = new MarginPadding { Left = margin }
|
Margin = new MarginPadding { Left = margin },
|
||||||
|
Colour = colours.YellowLight,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Current.ValueChanged += currentValueChanged;
|
Current.BindValueChanged(text => valueText.Text = Format(text.NewValue));
|
||||||
}
|
|
||||||
|
|
||||||
private void currentValueChanged(ValueChangedEvent<T> e)
|
|
||||||
{
|
|
||||||
string newText = prefix + Format(e.NewValue);
|
|
||||||
|
|
||||||
if (valueText.Text == newText)
|
|
||||||
return;
|
|
||||||
|
|
||||||
valueText.Text = newText;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual LocalisableString Format(T count)
|
protected virtual LocalisableString Format(T count)
|
||||||
@ -71,21 +65,14 @@ namespace osu.Game.Screens.Play.Break
|
|||||||
if (count is Enum countEnum)
|
if (count is Enum countEnum)
|
||||||
return countEnum.GetDescription();
|
return countEnum.GetDescription();
|
||||||
|
|
||||||
return count.ToString();
|
return count.ToString() ?? string.Empty;
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuColour colours)
|
|
||||||
{
|
|
||||||
text.Colour = colours.Yellow;
|
|
||||||
valueText.Colour = colours.YellowLight;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class PercentageBreakInfoLine : BreakInfoLine<double>
|
public partial class PercentageBreakInfoLine : BreakInfoLine<double>
|
||||||
{
|
{
|
||||||
public PercentageBreakInfoLine(LocalisableString name, string prefix = "")
|
public PercentageBreakInfoLine(LocalisableString name)
|
||||||
: base(name, prefix)
|
: base(name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,13 +46,14 @@ namespace osu.Game.Screens.Play
|
|||||||
private readonly Container remainingTimeBox;
|
private readonly Container remainingTimeBox;
|
||||||
private readonly RemainingTimeCounter remainingTimeCounter;
|
private readonly RemainingTimeCounter remainingTimeCounter;
|
||||||
private readonly BreakArrows breakArrows;
|
private readonly BreakArrows breakArrows;
|
||||||
|
private readonly ScoreProcessor scoreProcessor;
|
||||||
|
private readonly BreakInfo info;
|
||||||
|
|
||||||
public BreakOverlay(bool letterboxing, ScoreProcessor scoreProcessor)
|
public BreakOverlay(bool letterboxing, ScoreProcessor scoreProcessor)
|
||||||
{
|
{
|
||||||
|
this.scoreProcessor = scoreProcessor;
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
BreakInfo info;
|
|
||||||
|
|
||||||
Child = fadeContainer = new Container
|
Child = fadeContainer = new Container
|
||||||
{
|
{
|
||||||
Alpha = 0,
|
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()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
initializeBreaks();
|
initializeBreaks();
|
||||||
|
|
||||||
|
if (scoreProcessor != null)
|
||||||
|
{
|
||||||
|
info.AccuracyDisplay.Current.BindTo(scoreProcessor.Accuracy);
|
||||||
|
info.GradeDisplay.Current.BindTo(scoreProcessor.Rank);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeBreaks()
|
private void initializeBreaks()
|
||||||
|
Loading…
Reference in New Issue
Block a user