1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 07:42:55 +08:00

Add scrolling to the previous position when on "Back"

This commit is contained in:
HoutarouOreki 2018-07-24 20:57:09 +02:00
parent 3b36288185
commit 8e412fe403

View File

@ -28,6 +28,8 @@ namespace osu.Game.Overlays
private readonly ChangelogChart chart; private readonly ChangelogChart chart;
private readonly ChangelogContent content; private readonly ChangelogContent content;
private readonly ScrollContainer scroll;
private readonly Color4 purple = new Color4(191, 4, 255, 255); private readonly Color4 purple = new Color4(191, 4, 255, 255);
private SampleChannel sampleBack; private SampleChannel sampleBack;
@ -35,6 +37,7 @@ namespace osu.Game.Overlays
private APIAccess api; private APIAccess api;
private bool isAtListing; private bool isAtListing;
private float savedScrollPosition;
// receive input outside our bounds so we can trigger a close event on ourselves. // receive input outside our bounds so we can trigger a close event on ourselves.
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
@ -68,7 +71,7 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = new Color4(49, 36, 54, 255), Colour = new Color4(49, 36, 54, 255),
}, },
new ScrollContainer scroll = new ScrollContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false, ScrollbarVisible = false,
@ -152,7 +155,11 @@ namespace osu.Game.Overlays
var req = new GetChangelogRequest(); var req = new GetChangelogRequest();
badges.SelectNone(); badges.SelectNone();
chart.ShowAllUpdateStreams(); chart.ShowAllUpdateStreams();
req.Success += content.ShowListing; req.Success += listing =>
{
content.ShowListing(listing);
scroll.ScrollTo(savedScrollPosition);
};
api.Queue(req); api.Queue(req);
} }
@ -173,7 +180,13 @@ namespace osu.Game.Overlays
badges.SelectUpdateStream(build.UpdateStream.Name); badges.SelectUpdateStream(build.UpdateStream.Name);
chart.ShowUpdateStream(build.UpdateStream.Name); chart.ShowUpdateStream(build.UpdateStream.Name);
req.Success += content.ShowBuild; req.Success += APIChangelog =>
{
savedScrollPosition = scroll.Current;
content.ShowBuild(APIChangelog);
if (scroll.Current > scroll.GetChildPosInContent(content))
scroll.ScrollTo(content);
};
api.Queue(req); api.Queue(req);
} }
} }