mirror of
https://github.com/ppy/osu
synced 2025-03-20 18:08:25 +00:00
Add scrolling capability to results screen
This commit is contained in:
parent
e7687a0927
commit
5e74985eda
@ -24,6 +24,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
public abstract class ResultsScreen : OsuScreen
|
public abstract class ResultsScreen : OsuScreen
|
||||||
{
|
{
|
||||||
protected const float BACKGROUND_BLUR = 20;
|
protected const float BACKGROUND_BLUR = 20;
|
||||||
|
private static readonly float screen_height = 768 - TwoLayerButton.SIZE_EXTENDED.Y;
|
||||||
|
|
||||||
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
||||||
|
|
||||||
@ -68,10 +69,24 @@ namespace osu.Game.Screens.Ranking
|
|||||||
{
|
{
|
||||||
new ResultsScrollContainer
|
new ResultsScrollContainer
|
||||||
{
|
{
|
||||||
Child = panels = new ScorePanelList
|
Child = new FillFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.X,
|
||||||
SelectedScore = { BindTarget = SelectedScore }
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
panels = new ScorePanelList
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = screen_height,
|
||||||
|
SelectedScore = { BindTarget = SelectedScore }
|
||||||
|
},
|
||||||
|
new StatisticsPanel(Score)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = screen_height,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -135,11 +150,6 @@ namespace osu.Game.Screens.Ranking
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
AddInternal(new StatisticsPanel(Score)
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -180,27 +190,38 @@ namespace osu.Game.Screens.Ranking
|
|||||||
return base.OnExiting(next);
|
return base.OnExiting(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Cached]
|
||||||
private class ResultsScrollContainer : OsuScrollContainer
|
private class ResultsScrollContainer : OsuScrollContainer
|
||||||
{
|
{
|
||||||
private readonly Container content;
|
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
|
||||||
|
|
||||||
public ResultsScrollContainer()
|
public ResultsScrollContainer()
|
||||||
{
|
{
|
||||||
base.Content.Add(content = new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X
|
|
||||||
});
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
ScrollbarVisible = false;
|
ScrollbarVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void OnUserScroll(float value, bool animated = true, double? distanceDecay = default)
|
||||||
{
|
{
|
||||||
base.Update();
|
if (!animated)
|
||||||
content.Height = Math.Max(768 - TwoLayerButton.SIZE_EXTENDED.Y, DrawHeight);
|
{
|
||||||
|
// If the user is scrolling via mouse drag, follow the mouse 1:1.
|
||||||
|
base.OnUserScroll(value, false, distanceDecay);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float direction = Math.Sign(value - Target);
|
||||||
|
float target = Target + direction * screen_height;
|
||||||
|
|
||||||
|
if (target <= -screen_height / 2 || target >= ScrollableExtent + screen_height / 2)
|
||||||
|
{
|
||||||
|
// If the user is already at either extent and scrolling in the clamped direction, we want to follow the default scroll exactly so that the bounces aren't too harsh.
|
||||||
|
base.OnUserScroll(value, true, distanceDecay);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Otherwise, scroll one screen in the target direction.
|
||||||
|
base.OnUserScroll(target, true, distanceDecay);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user