1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-28 01:37:46 +08:00

Refactor layout of display

This commit is contained in:
Bartłomiej Dach 2023-09-11 09:37:25 +02:00
parent a631fae6df
commit 552230af9d
No known key found for this signature in database
2 changed files with 23 additions and 35 deletions

View File

@ -61,7 +61,6 @@ namespace osu.Game.Overlays.Mods
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
// values as ModSelectOverlay footer buttons
const float shear = ShearedOverlayContainer.SHEAR; const float shear = ShearedOverlayContainer.SHEAR;
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
@ -103,36 +102,26 @@ namespace osu.Game.Overlays.Mods
{ {
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
}, },
new FillFlowContainer // actual inner content new Container // actual inner content
{ {
Origin = Anchor.CentreLeft, Origin = Anchor.Centre,
Anchor = Anchor.CentreLeft, Anchor = Anchor.Centre,
AutoSizeAxes = Axes.X, Width = 140,
Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.Y,
Margin = new MarginPadding { Horizontal = 15 }, Margin = new MarginPadding { Horizontal = 15 },
Children = new Drawable[] Children = new Drawable[]
{ {
new Container // wrap to reserve space for StarRatingDisplay starRatingDisplay = new StarRatingDisplay(default, animated: true)
{
Width = 70, // can be up to 70px on extra high SR
Child = starRatingDisplay = new StarRatingDisplay(default, animated: true)
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
Shear = new Vector2(-shear, 0),
}
},
new Container // wrap to reserve space for BPM
{ {
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Width = 70, Shear = new Vector2(-shear, 0),
Child = bpmDisplay = new BPMDisplay },
{ bpmDisplay = new BPMDisplay
Origin = Anchor.CentreLeft, {
Anchor = Anchor.CentreLeft, Origin = Anchor.CentreRight,
Shear = new Vector2(-shear, 0), Anchor = Anchor.CentreRight,
} Shear = new Vector2(-shear, 0),
} }
} }
} }
@ -147,10 +136,10 @@ namespace osu.Game.Overlays.Mods
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Children = new[] Children = new[]
{ {
circleSizeDisplay = new VerticalAttributeDisplay("CS", "0.#"), circleSizeDisplay = new VerticalAttributeDisplay("CS"),
drainRateDisplay = new VerticalAttributeDisplay("HP", "0.#"), drainRateDisplay = new VerticalAttributeDisplay("HP"),
approachRateDisplay = new VerticalAttributeDisplay("AR", "0.##"), approachRateDisplay = new VerticalAttributeDisplay("AR"),
overallDifficultyDisplay = new VerticalAttributeDisplay("OD", "0.##"), overallDifficultyDisplay = new VerticalAttributeDisplay("OD"),
} }
} }
} }
@ -221,7 +210,8 @@ namespace osu.Game.Overlays.Mods
protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText
{ {
Font = OsuFont.Default.With(size: 20, weight: FontWeight.SemiBold) Font = OsuFont.Default.With(size: 20, weight: FontWeight.SemiBold),
UseFullGlyphHeight = false,
}; };
} }
} }

View File

@ -21,6 +21,7 @@ namespace osu.Game.Overlays.Mods
get => current.Current; get => current.Current;
set => current.Current = value; set => current.Current = value;
} }
private readonly BindableWithCurrent<double> current = new BindableWithCurrent<double>(); private readonly BindableWithCurrent<double> current = new BindableWithCurrent<double>();
/// <summary> /// <summary>
@ -28,7 +29,7 @@ namespace osu.Game.Overlays.Mods
/// </summary> /// </summary>
public LocalisableString Label { get; protected set; } public LocalisableString Label { get; protected set; }
public VerticalAttributeDisplay(LocalisableString label, string format = "0.#") public VerticalAttributeDisplay(LocalisableString label)
{ {
Label = label; Label = label;
AutoSizeAxes = Axes.X; AutoSizeAxes = Axes.X;
@ -50,12 +51,11 @@ namespace osu.Game.Overlays.Mods
Margin = new MarginPadding { Horizontal = 15 }, // to reserve space for 0.XX value Margin = new MarginPadding { Horizontal = 15 }, // to reserve space for 0.XX value
Font = OsuFont.Default.With(size: 20, weight: FontWeight.Bold) Font = OsuFont.Default.With(size: 20, weight: FontWeight.Bold)
}, },
new EffectCounter() new EffectCounter
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Current = { BindTarget = Current }, Current = { BindTarget = Current },
Format = format
} }
} }
}; };
@ -65,9 +65,7 @@ namespace osu.Game.Overlays.Mods
{ {
protected override double RollingDuration => 500; protected override double RollingDuration => 500;
public string Format = "0.#"; protected override LocalisableString FormatCount(double count) => count.ToLocalisableString("0.0");
protected override LocalisableString FormatCount(double count) => count.ToLocalisableString(Format);
protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText
{ {