mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 21:07:18 +09:00
Update settings UI using SectionsContainer basically.
This commit is contained in:
parent
93668e53a0
commit
35712514a4
@ -7,10 +7,11 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Overlays.Settings;
|
|
||||||
using System;
|
|
||||||
using osu.Game.Overlays.Settings.Sections;
|
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Overlays.Settings;
|
||||||
|
using osu.Game.Overlays.Settings.Sections;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
@ -37,6 +38,8 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private SearchContainer searchContainer;
|
private SearchContainer searchContainer;
|
||||||
|
|
||||||
|
private SettingsSectionsContainer sectionsContainer;
|
||||||
|
|
||||||
private float lastKnownScroll;
|
private float lastKnownScroll;
|
||||||
|
|
||||||
public SettingsOverlay()
|
public SettingsOverlay()
|
||||||
@ -68,27 +71,27 @@ namespace osu.Game.Overlays
|
|||||||
Colour = Color4.Black,
|
Colour = Color4.Black,
|
||||||
Alpha = 0.6f,
|
Alpha = 0.6f,
|
||||||
},
|
},
|
||||||
scrollContainer = new ScrollContainer
|
sectionsContainer = new SettingsSectionsContainer
|
||||||
{
|
{
|
||||||
ScrollDraggerVisible = false,
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Width = width,
|
Width = width,
|
||||||
Margin = new MarginPadding { Left = SIDEBAR_WIDTH },
|
Margin = new MarginPadding { Left = SIDEBAR_WIDTH },
|
||||||
Children = new Drawable[]
|
ExpandableHeader = header = new SettingsHeader(() => sectionsContainer.ScrollContainer.Current),
|
||||||
|
FixedHeader = new SearchTextBox
|
||||||
{
|
{
|
||||||
searchContainer = new SearchContainer
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Width = 0.95f,
|
||||||
|
Margin = new MarginPadding
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Y,
|
Top = 20,
|
||||||
RelativeSizeAxes = Axes.X,
|
Bottom = 20
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
Children = sections,
|
|
||||||
},
|
},
|
||||||
footer = new SettingsFooter(),
|
Exit = Hide,
|
||||||
header = new SettingsHeader(() => scrollContainer.Current)
|
},
|
||||||
{
|
Sections = sections,
|
||||||
Exit = Hide,
|
Footer = footer = new SettingsFooter()
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
sidebar = new Sidebar
|
sidebar = new Sidebar
|
||||||
{
|
{
|
||||||
@ -104,54 +107,16 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
header.SearchTextBox.Current.ValueChanged += newValue => searchContainer.SearchTerm = newValue;
|
//header.SearchTextBox.Current.ValueChanged += newValue => searchContainer.SearchTerm = newValue;
|
||||||
|
|
||||||
scrollContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 };
|
sectionsContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 };
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
|
||||||
{
|
|
||||||
base.UpdateAfterChildren();
|
|
||||||
|
|
||||||
//we need to update these manually because we can't put the SettingsHeader inside the SearchContainer (due to its anchoring).
|
|
||||||
searchContainer.Y = header.DrawHeight;
|
|
||||||
footer.Y = searchContainer.Y + searchContainer.DrawHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
float currentScroll = scrollContainer.Current;
|
|
||||||
if (currentScroll != lastKnownScroll)
|
|
||||||
{
|
|
||||||
lastKnownScroll = currentScroll;
|
|
||||||
|
|
||||||
SettingsSection bestCandidate = null;
|
|
||||||
float bestDistance = float.MaxValue;
|
|
||||||
|
|
||||||
foreach (SettingsSection section in sections)
|
|
||||||
{
|
|
||||||
float distance = Math.Abs(scrollContainer.GetChildPosInContent(section) - currentScroll);
|
|
||||||
if (distance < bestDistance)
|
|
||||||
{
|
|
||||||
bestDistance = distance;
|
|
||||||
bestCandidate = section;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var previous = sidebarButtons.SingleOrDefault(sb => sb.Selected);
|
|
||||||
var next = sidebarButtons.SingleOrDefault(sb => sb.Section == bestCandidate);
|
|
||||||
if (previous != null) previous.Selected = false;
|
|
||||||
if (next != null) next.Selected = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
base.PopIn();
|
base.PopIn();
|
||||||
|
|
||||||
scrollContainer.MoveToX(0, TRANSITION_LENGTH, EasingTypes.OutQuint);
|
sectionsContainer.MoveToX(0, TRANSITION_LENGTH, EasingTypes.OutQuint);
|
||||||
sidebar.MoveToX(0, TRANSITION_LENGTH, EasingTypes.OutQuint);
|
sidebar.MoveToX(0, TRANSITION_LENGTH, EasingTypes.OutQuint);
|
||||||
FadeTo(1, TRANSITION_LENGTH / 2);
|
FadeTo(1, TRANSITION_LENGTH / 2);
|
||||||
|
|
||||||
@ -162,7 +127,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
base.PopOut();
|
base.PopOut();
|
||||||
|
|
||||||
scrollContainer.MoveToX(-width, TRANSITION_LENGTH, EasingTypes.OutQuint);
|
sectionsContainer.MoveToX(-width, TRANSITION_LENGTH, EasingTypes.OutQuint);
|
||||||
sidebar.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, EasingTypes.OutQuint);
|
sidebar.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, EasingTypes.OutQuint);
|
||||||
FadeTo(0, TRANSITION_LENGTH / 2);
|
FadeTo(0, TRANSITION_LENGTH / 2);
|
||||||
|
|
||||||
@ -175,5 +140,21 @@ namespace osu.Game.Overlays
|
|||||||
header.SearchTextBox.TriggerFocus(state);
|
header.SearchTextBox.TriggerFocus(state);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class SettingsSectionsContainer : SectionsContainer
|
||||||
|
{
|
||||||
|
public SearchContainer SearchContainer;
|
||||||
|
protected override Container<Drawable> CreateScrollContentContainer()
|
||||||
|
=> SearchContainer = new SearchContainer
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
};
|
||||||
|
public SettingsSectionsContainer()
|
||||||
|
{
|
||||||
|
ScrollContainer.ScrollDraggerVisible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user