mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 00:33:21 +08:00
Make sidebar buttons working.
This commit is contained in:
parent
aa409ac1a9
commit
f06f8b4dcd
@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Settings
|
||||
private readonly Box backgroundBox;
|
||||
private readonly Box selectionIndicator;
|
||||
private readonly Container text;
|
||||
public Action Action;
|
||||
public Action<SettingsSection> Action;
|
||||
|
||||
private SettingsSection section;
|
||||
public SettingsSection Section
|
||||
@ -75,6 +75,7 @@ namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
Width = Sidebar.DEFAULT_WIDTH,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Colour = OsuColour.Gray(0.6f),
|
||||
Children = new[]
|
||||
{
|
||||
headerText = new OsuSpriteText
|
||||
@ -110,7 +111,7 @@ namespace osu.Game.Overlays.Settings
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
Action?.Invoke();
|
||||
Action?.Invoke(section);
|
||||
backgroundBox.FlashColour(Color4.White, 400);
|
||||
return true;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
private Sidebar sidebar;
|
||||
private SidebarButton[] sidebarButtons;
|
||||
private SettingsSection[] sections;
|
||||
private SidebarButton selectedSidebarButton;
|
||||
|
||||
private SettingsSectionsContainer sectionsContainer;
|
||||
|
||||
@ -44,7 +44,7 @@ namespace osu.Game.Overlays
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuGame game)
|
||||
{
|
||||
sections = new SettingsSection[]
|
||||
var sections = new SettingsSection[]
|
||||
{
|
||||
new GeneralSection(),
|
||||
new GraphicsSection(),
|
||||
@ -92,14 +92,23 @@ namespace osu.Game.Overlays
|
||||
Children = sidebarButtons = sections.Select(section =>
|
||||
new SidebarButton
|
||||
{
|
||||
Selected = sections[0] == section,
|
||||
Section = section,
|
||||
Action = () => sectionsContainer.ScrollContainer.ScrollIntoView(section),
|
||||
Action = sectionsContainer.ScrollContainer.ScrollIntoView,
|
||||
}
|
||||
).ToArray()
|
||||
}
|
||||
};
|
||||
|
||||
selectedSidebarButton = sidebarButtons[0];
|
||||
selectedSidebarButton.Selected = true;
|
||||
|
||||
sectionsContainer.SelectedSection.ValueChanged += section =>
|
||||
{
|
||||
selectedSidebarButton.Selected = false;
|
||||
selectedSidebarButton = sidebarButtons.Single(b => b.Section == section);
|
||||
selectedSidebarButton.Selected = true;
|
||||
};
|
||||
|
||||
searchTextBox.Current.ValueChanged += newValue => sectionsContainer.SearchContainer.SearchTerm = newValue;
|
||||
|
||||
sectionsContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 };
|
||||
|
Loading…
Reference in New Issue
Block a user