Skip to content

Commit

Permalink
Reduce application of UI scale at results screen to make things fit b…
Browse files Browse the repository at this point in the history
…etter

This also removes the vertical scroll container completely, simplifying
the whole interaction of the results screen.
  • Loading branch information
peppy committed Jul 13, 2023
1 parent f654dc7 commit e11e87d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ private void load()
{
const float winner_background_half_height = 250;

VerticalScrollContent.Anchor = VerticalScrollContent.Origin = Anchor.TopCentre;
VerticalScrollContent.Scale = new Vector2(0.9f);
VerticalScrollContent.Y = 75;
Content.Anchor = Content.Origin = Anchor.TopCentre;
Content.Scale = new Vector2(0.9f);
Content.Y = 75;

var redScore = teamScores.First().Value;
var blueScore = teamScores.Last().Value;
Expand Down
45 changes: 40 additions & 5 deletions osu.Game/Screens/Ranking/ResultsScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Screens;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
Expand Down Expand Up @@ -45,7 +46,7 @@ public abstract partial class ResultsScreen : ScreenWithBeatmapBackground, IKeyB

protected ScorePanelList ScorePanelList { get; private set; }

protected VerticalScrollContainer VerticalScrollContent { get; private set; }
protected Container Content { get; private set; }

[Resolved(CanBeNull = true)]
private Player player { get; set; }
Expand Down Expand Up @@ -87,11 +88,9 @@ private void load(AudioManager audio)
{
new Drawable[]
{
VerticalScrollContent = new VerticalScrollContainer
new UIScaleReductionContainer(0.2f)
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
Child = new Container
Child = Content = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
Expand Down Expand Up @@ -381,5 +380,41 @@ protected override void Update()
content.Height = Math.Max(screen_height, DrawHeight);
}
}

/// <summary>
/// Applies UI scale in reduced amounts.
/// </summary>
private partial class UIScaleReductionContainer : DrawSizePreservingFillContainer
{
private readonly float reductionFactor;

private Bindable<float> uiScale;

private float apply = 1;

public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;

public UIScaleReductionContainer(float reductionFactor)
{
this.reductionFactor = reductionFactor;
}

[BackgroundDependencyLoader]
private void load(OsuConfigManager osuConfig)
{
uiScale = osuConfig.GetBindable<float>(OsuSetting.UIScale);
uiScale.BindValueChanged(args => this.TransformTo(nameof(apply), args.NewValue, ScalingContainer.TRANSITION_DURATION, Easing.OutQuart), true);
}

protected override void Update()
{
float application = 1 + (apply - 1) * reductionFactor;

Scale = new Vector2(application);
Size = new Vector2(1 / application);

base.Update();
}
}
}
}

0 comments on commit e11e87d

Please sign in to comment.