mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 08:12:56 +08:00
Apply NRT to ButtonSystem
This commit is contained in:
parent
5905ca6492
commit
7e59a1d0be
@ -35,7 +35,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
() => Game.Notifications.AllNotifications.Count(x => x.Text == EditorStrings.MustBeInEditorToHandleLinks),
|
() => Game.Notifications.AllNotifications.Count(x => x.Text == EditorStrings.MustBeInEditorToHandleLinks),
|
||||||
() => Is.EqualTo(1));
|
() => Is.EqualTo(1));
|
||||||
|
|
||||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo.Invoke());
|
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo?.Invoke());
|
||||||
AddUntilStep("entered song select", () => Game.ScreenStack.CurrentScreen is PlaySongSelect);
|
AddUntilStep("entered song select", () => Game.ScreenStack.CurrentScreen is PlaySongSelect);
|
||||||
|
|
||||||
addStepClickLink("00:00:000 (1)", waitForSeek: false);
|
addStepClickLink("00:00:000 (1)", waitForSeek: false);
|
||||||
|
@ -239,7 +239,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
{
|
{
|
||||||
AddUntilStep("wait for dialog overlay", () => Game.ChildrenOfType<DialogOverlay>().SingleOrDefault() != null);
|
AddUntilStep("wait for dialog overlay", () => Game.ChildrenOfType<DialogOverlay>().SingleOrDefault() != null);
|
||||||
|
|
||||||
AddStep("open editor", () => Game.ChildrenOfType<ButtonSystem>().Single().OnEditBeatmap.Invoke());
|
AddStep("open editor", () => Game.ChildrenOfType<ButtonSystem>().Single().OnEditBeatmap?.Invoke());
|
||||||
AddUntilStep("wait for editor", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.IsLoaded);
|
AddUntilStep("wait for editor", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.IsLoaded);
|
||||||
AddStep("click on file", () =>
|
AddStep("click on file", () =>
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
@ -37,24 +34,23 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
public partial class ButtonSystem : Container, IStateful<ButtonSystemState>, IKeyBindingHandler<GlobalAction>
|
public partial class ButtonSystem : Container, IStateful<ButtonSystemState>, IKeyBindingHandler<GlobalAction>
|
||||||
{
|
{
|
||||||
public event Action<ButtonSystemState> StateChanged;
|
|
||||||
|
|
||||||
private readonly IBindable<bool> isIdle = new BindableBool();
|
|
||||||
|
|
||||||
public Action OnEditBeatmap;
|
|
||||||
public Action OnEditSkin;
|
|
||||||
public Action OnExit;
|
|
||||||
public Action OnBeatmapListing;
|
|
||||||
public Action OnSolo;
|
|
||||||
public Action OnSettings;
|
|
||||||
public Action OnMultiplayer;
|
|
||||||
public Action OnPlaylists;
|
|
||||||
|
|
||||||
public const float BUTTON_WIDTH = 140f;
|
public const float BUTTON_WIDTH = 140f;
|
||||||
public const float WEDGE_WIDTH = 20;
|
public const float WEDGE_WIDTH = 20;
|
||||||
|
|
||||||
[CanBeNull]
|
public event Action<ButtonSystemState>? StateChanged;
|
||||||
private OsuLogo logo;
|
|
||||||
|
public Action? OnEditBeatmap;
|
||||||
|
public Action? OnEditSkin;
|
||||||
|
public Action? OnExit;
|
||||||
|
public Action? OnBeatmapListing;
|
||||||
|
public Action? OnSolo;
|
||||||
|
public Action? OnSettings;
|
||||||
|
public Action? OnMultiplayer;
|
||||||
|
public Action? OnPlaylists;
|
||||||
|
|
||||||
|
private readonly IBindable<bool> isIdle = new BindableBool();
|
||||||
|
|
||||||
|
private OsuLogo? logo;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Assign the <see cref="OsuLogo"/> that this ButtonSystem should manage the position of.
|
/// Assign the <see cref="OsuLogo"/> that this ButtonSystem should manage the position of.
|
||||||
@ -88,8 +84,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
private readonly List<MainMenuButton> buttonsPlay = new List<MainMenuButton>();
|
private readonly List<MainMenuButton> buttonsPlay = new List<MainMenuButton>();
|
||||||
private readonly List<MainMenuButton> buttonsEdit = new List<MainMenuButton>();
|
private readonly List<MainMenuButton> buttonsEdit = new List<MainMenuButton>();
|
||||||
|
|
||||||
private Sample sampleBackToLogo;
|
private Sample? sampleBackToLogo;
|
||||||
private Sample sampleLogoSwoosh;
|
private Sample? sampleLogoSwoosh;
|
||||||
|
|
||||||
private readonly LogoTrackingContainer logoTrackingContainer;
|
private readonly LogoTrackingContainer logoTrackingContainer;
|
||||||
|
|
||||||
@ -124,17 +120,17 @@ namespace osu.Game.Screens.Menu
|
|||||||
buttonArea.Flow.CentreTarget = logoTrackingContainer.LogoFacade;
|
buttonArea.Flow.CentreTarget = logoTrackingContainer.LogoFacade;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved]
|
||||||
private OsuGame game { get; set; }
|
private IAPIProvider api { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; }
|
private OsuGame? game { get; set; }
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved]
|
||||||
private LoginOverlay loginOverlay { get; set; }
|
private LoginOverlay? loginOverlay { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio, IdleTracker idleTracker, GameHost host)
|
private void load(AudioManager audio, IdleTracker? idleTracker, GameHost host)
|
||||||
{
|
{
|
||||||
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Solo, @"button-default-select", FontAwesome.Solid.User, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
|
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Solo, @"button-default-select", FontAwesome.Solid.User, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
|
||||||
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Multi, @"button-default-select", FontAwesome.Solid.Users, new Color4(94, 63, 186, 255), onMultiplayer, 0, Key.M));
|
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Multi, @"button-default-select", FontAwesome.Solid.Users, new Color4(94, 63, 186, 255), onMultiplayer, 0, Key.M));
|
||||||
@ -354,7 +350,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScheduledDelegate logoDelayedAction;
|
private ScheduledDelegate? logoDelayedAction;
|
||||||
|
|
||||||
private void updateLogoState(ButtonSystemState lastState = ButtonSystemState.Initial)
|
private void updateLogoState(ButtonSystemState lastState = ButtonSystemState.Initial)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user