Simplify score panel balance adjustment

This commit is contained in:
Dean Herbert
2022-07-23 02:09:08 +09:00
parent e08e4fc426
commit 9f045209b9
2 changed files with 12 additions and 20 deletions

View File

@ -96,7 +96,10 @@ namespace osu.Game.Screens.Ranking
public readonly ScoreInfo Score; public readonly ScoreInfo Score;
public DrawableAudioMixer Mixer; [Resolved]
private OsuGame game { get; set; }
private DrawableAudioMixer mixer;
private bool displayWithFlair; private bool displayWithFlair;
@ -127,7 +130,7 @@ namespace osu.Game.Screens.Ranking
// Adding a manual offset here allows the expanded version to take on an "acceptable" vertical centre when at 100% UI scale. // Adding a manual offset here allows the expanded version to take on an "acceptable" vertical centre when at 100% UI scale.
const float vertical_fudge = 20; const float vertical_fudge = 20;
InternalChild = Mixer = new DrawableAudioMixer InternalChild = mixer = new DrawableAudioMixer
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -219,6 +222,12 @@ namespace osu.Game.Screens.Ranking
} }
} }
protected override void Update()
{
base.Update();
mixer.Balance.Value = (ScreenSpaceDrawQuad.Centre.X / game.ScreenSpaceDrawQuad.Width) * 2 - 1;
}
private void playAppearSample() private void playAppearSample()
{ {
var channel = samplePanelFocus?.GetChannel(); var channel = samplePanelFocus?.GetChannel();
@ -265,7 +274,7 @@ namespace osu.Game.Screens.Ranking
break; break;
} }
Mixer.ResizeTo(Size, RESIZE_DURATION, Easing.OutQuint); mixer.ResizeTo(Size, RESIZE_DURATION, Easing.OutQuint);
bool topLayerExpanded = topLayerContainer.Y < 0; bool topLayerExpanded = topLayerContainer.Y < 0;

View File

@ -344,23 +344,6 @@ namespace osu.Game.Screens.Ranking
private IEnumerable<ScorePanelTrackingContainer> applySorting(IEnumerable<Drawable> drawables) => drawables.OfType<ScorePanelTrackingContainer>() private IEnumerable<ScorePanelTrackingContainer> applySorting(IEnumerable<Drawable> drawables) => drawables.OfType<ScorePanelTrackingContainer>()
.OrderByDescending(GetLayoutPosition) .OrderByDescending(GetLayoutPosition)
.ThenBy(s => s.Panel.Score.OnlineID); .ThenBy(s => s.Panel.Score.OnlineID);
protected override void Update()
{
foreach (ScorePanelTrackingContainer trackingContainer in FlowingChildren.OfType<ScorePanelTrackingContainer>())
{
var panel = trackingContainer.Panel;
if (panel.State != PanelState.Expanded) continue;
var scrollContainer = Parent.Parent;
float balance = scrollContainer.ToLocalSpace(panel.ToScreenSpace(panel.BoundingBox.Centre)).X / scrollContainer.RelativeToAbsoluteFactor.X;
panel.Mixer.Balance.Value = Math.Clamp(-1 + balance * 2, -1, 1);
}
base.Update();
}
} }
private class Scroll : OsuScrollContainer private class Scroll : OsuScrollContainer