mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 13:07:18 +08:00
Merge pull request #165 from Tom94/options-improvements
Options improvements
This commit is contained in:
commit
9cb9f3eb08
@ -22,6 +22,7 @@ using osu.Game.Overlays.Options.General;
|
|||||||
using osu.Game.Overlays.Options.Graphics;
|
using osu.Game.Overlays.Options.Graphics;
|
||||||
using osu.Game.Overlays.Options.Input;
|
using osu.Game.Overlays.Options.Input;
|
||||||
using osu.Game.Overlays.Options.Online;
|
using osu.Game.Overlays.Options.Online;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
@ -67,8 +68,7 @@ namespace osu.Game.Overlays
|
|||||||
},
|
},
|
||||||
scrollContainer = new ScrollContainer
|
scrollContainer = new ScrollContainer
|
||||||
{
|
{
|
||||||
ScrollbarOverlapsContent = false,
|
ScrollDraggerVisible = false,
|
||||||
ScrollDraggerAnchor = Anchor.TopLeft,
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Width = width,
|
Width = width,
|
||||||
Margin = new MarginPadding { Left = sidebar_width },
|
Margin = new MarginPadding { Left = sidebar_width },
|
||||||
@ -114,8 +114,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
Selected = sections[0] == section,
|
Selected = sections[0] == section,
|
||||||
Section = section,
|
Section = section,
|
||||||
Action = () => scrollContainer.ScrollTo(
|
Action = () => scrollContainer.ScrollIntoView(section),
|
||||||
scrollContainer.GetChildYInContent(section) - scrollContainer.DrawSize.Y / 2),
|
|
||||||
}
|
}
|
||||||
).ToArray()
|
).ToArray()
|
||||||
}
|
}
|
||||||
@ -131,24 +130,32 @@ namespace osu.Game.Overlays
|
|||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
if (scrollContainer.Current != lastKnownScroll)
|
|
||||||
|
float currentScroll = scrollContainer.Current;
|
||||||
|
if (currentScroll != lastKnownScroll)
|
||||||
{
|
{
|
||||||
for (int i = sections.Length - 1; i >= 0; i--)
|
lastKnownScroll = currentScroll;
|
||||||
|
|
||||||
|
OptionsSection bestCandidate = null;
|
||||||
|
float bestDistance = float.MaxValue;
|
||||||
|
|
||||||
|
foreach (OptionsSection section in sections)
|
||||||
{
|
{
|
||||||
var section = sections[i];
|
float distance = Math.Abs(scrollContainer.GetChildYInContent(section) - currentScroll);
|
||||||
float y = scrollContainer.GetChildYInContent(section) - scrollContainer.Current;
|
if (distance < bestDistance)
|
||||||
if (y <= scrollContainer.DrawSize.Y / 2 + 25)
|
|
||||||
{
|
{
|
||||||
var previous = sidebarButtons.SingleOrDefault(sb => sb.Selected);
|
bestDistance = distance;
|
||||||
var next = sidebarButtons.SingleOrDefault(sb => sb.Section == section);
|
bestCandidate = section;
|
||||||
if (next != null)
|
|
||||||
{
|
|
||||||
previous.Selected = false;
|
|
||||||
next.Selected = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var previous = sidebarButtons.SingleOrDefault(sb => sb.Selected);
|
||||||
|
var next = sidebarButtons.SingleOrDefault(sb => sb.Section == bestCandidate);
|
||||||
|
if (next != null)
|
||||||
|
{
|
||||||
|
previous.Selected = false;
|
||||||
|
next.Selected = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user