From 552230af9d23f53e83cc57a06a425c0486e36c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 11 Sep 2023 09:37:25 +0200 Subject: [PATCH] Refactor layout of display --- .../Overlays/Mods/ModEffectPreviewPanel.cs | 48 ++++++++----------- .../Overlays/Mods/VerticalAttributeDisplay.cs | 10 ++-- 2 files changed, 23 insertions(+), 35 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModEffectPreviewPanel.cs b/osu.Game/Overlays/Mods/ModEffectPreviewPanel.cs index dde3761c4a..1a5d1e98c7 100644 --- a/osu.Game/Overlays/Mods/ModEffectPreviewPanel.cs +++ b/osu.Game/Overlays/Mods/ModEffectPreviewPanel.cs @@ -61,7 +61,6 @@ namespace osu.Game.Overlays.Mods [BackgroundDependencyLoader] private void load() { - // values as ModSelectOverlay footer buttons const float shear = ShearedOverlayContainer.SHEAR; AutoSizeAxes = Axes.Both; @@ -103,36 +102,26 @@ namespace osu.Game.Overlays.Mods { RelativeSizeAxes = Axes.Both }, - new FillFlowContainer // actual inner content + new Container // actual inner content { - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - AutoSizeAxes = Axes.X, - Direction = FillDirection.Horizontal, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Width = 140, + RelativeSizeAxes = Axes.Y, Margin = new MarginPadding { Horizontal = 15 }, Children = new Drawable[] { - new Container // wrap to reserve space for StarRatingDisplay - { - 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 + starRatingDisplay = new StarRatingDisplay(default, animated: true) { Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, - Width = 70, - Child = bpmDisplay = new BPMDisplay - { - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - Shear = new Vector2(-shear, 0), - } + Shear = new Vector2(-shear, 0), + }, + bpmDisplay = new BPMDisplay + { + Origin = Anchor.CentreRight, + Anchor = Anchor.CentreRight, + Shear = new Vector2(-shear, 0), } } } @@ -147,10 +136,10 @@ namespace osu.Game.Overlays.Mods Direction = FillDirection.Horizontal, Children = new[] { - circleSizeDisplay = new VerticalAttributeDisplay("CS", "0.#"), - drainRateDisplay = new VerticalAttributeDisplay("HP", "0.#"), - approachRateDisplay = new VerticalAttributeDisplay("AR", "0.##"), - overallDifficultyDisplay = new VerticalAttributeDisplay("OD", "0.##"), + circleSizeDisplay = new VerticalAttributeDisplay("CS"), + drainRateDisplay = new VerticalAttributeDisplay("HP"), + approachRateDisplay = new VerticalAttributeDisplay("AR"), + overallDifficultyDisplay = new VerticalAttributeDisplay("OD"), } } } @@ -221,7 +210,8 @@ namespace osu.Game.Overlays.Mods 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, }; } } diff --git a/osu.Game/Overlays/Mods/VerticalAttributeDisplay.cs b/osu.Game/Overlays/Mods/VerticalAttributeDisplay.cs index 503b07f3b9..ba8efd1c2b 100644 --- a/osu.Game/Overlays/Mods/VerticalAttributeDisplay.cs +++ b/osu.Game/Overlays/Mods/VerticalAttributeDisplay.cs @@ -21,6 +21,7 @@ namespace osu.Game.Overlays.Mods get => current.Current; set => current.Current = value; } + private readonly BindableWithCurrent current = new BindableWithCurrent(); /// @@ -28,7 +29,7 @@ namespace osu.Game.Overlays.Mods /// public LocalisableString Label { get; protected set; } - public VerticalAttributeDisplay(LocalisableString label, string format = "0.#") + public VerticalAttributeDisplay(LocalisableString label) { Label = label; AutoSizeAxes = Axes.X; @@ -50,12 +51,11 @@ namespace osu.Game.Overlays.Mods Margin = new MarginPadding { Horizontal = 15 }, // to reserve space for 0.XX value Font = OsuFont.Default.With(size: 20, weight: FontWeight.Bold) }, - new EffectCounter() + new EffectCounter { Origin = Anchor.Centre, Anchor = Anchor.Centre, Current = { BindTarget = Current }, - Format = format } } }; @@ -65,9 +65,7 @@ namespace osu.Game.Overlays.Mods { protected override double RollingDuration => 500; - public string Format = "0.#"; - - protected override LocalisableString FormatCount(double count) => count.ToLocalisableString(Format); + protected override LocalisableString FormatCount(double count) => count.ToLocalisableString("0.0"); protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText {