Skip to content

Commit

Permalink
Simplify score panel balance adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jul 22, 2022
1 parent e08e4fc commit 9f04520
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
15 changes: 12 additions & 3 deletions osu.Game/Screens/Ranking/ScorePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ public class ScorePanel : CompositeDrawable, IStateful<PanelState>

public readonly ScoreInfo Score;

public DrawableAudioMixer Mixer;
[Resolved]
private OsuGame game { get; set; }

private DrawableAudioMixer mixer;

private bool displayWithFlair;

Expand Down Expand Up @@ -127,7 +130,7 @@ private void load(AudioManager audio)
// 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;

InternalChild = Mixer = new DrawableAudioMixer
InternalChild = mixer = new DrawableAudioMixer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Expand Down Expand Up @@ -219,6 +222,12 @@ public PanelState State
}
}

protected override void Update()
{
base.Update();
mixer.Balance.Value = (ScreenSpaceDrawQuad.Centre.X / game.ScreenSpaceDrawQuad.Width) * 2 - 1;
}

private void playAppearSample()
{
var channel = samplePanelFocus?.GetChannel();
Expand Down Expand Up @@ -265,7 +274,7 @@ private void updateState()
break;
}

Mixer.ResizeTo(Size, RESIZE_DURATION, Easing.OutQuint);
mixer.ResizeTo(Size, RESIZE_DURATION, Easing.OutQuint);

bool topLayerExpanded = topLayerContainer.Y < 0;

Expand Down
17 changes: 0 additions & 17 deletions osu.Game/Screens/Ranking/ScorePanelList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,23 +344,6 @@ private class Flow : FillFlowContainer<ScorePanelTrackingContainer>
private IEnumerable<ScorePanelTrackingContainer> applySorting(IEnumerable<Drawable> drawables) => drawables.OfType<ScorePanelTrackingContainer>()
.OrderByDescending(GetLayoutPosition)
.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
Expand Down

0 comments on commit 9f04520

Please sign in to comment.