mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Merge branch 'master' into chat-drag-improvements
This commit is contained in:
commit
1388e492b1
@ -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().OnEdit.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", () =>
|
||||||
{
|
{
|
||||||
|
@ -97,7 +97,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestFromSongSelectWithFilter([Values] ScorePresentType type)
|
public void TestFromSongSelectWithFilter([Values] ScorePresentType type)
|
||||||
{
|
{
|
||||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo.Invoke());
|
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo?.Invoke());
|
||||||
AddUntilStep("song select is current", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect && songSelect.BeatmapSetsLoaded);
|
AddUntilStep("song select is current", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect && songSelect.BeatmapSetsLoaded);
|
||||||
|
|
||||||
AddStep("filter to nothing", () => ((PlaySongSelect)Game.ScreenStack.CurrentScreen).FilterControl.CurrentTextSearch.Value = "fdsajkl;fgewq");
|
AddStep("filter to nothing", () => ((PlaySongSelect)Game.ScreenStack.CurrentScreen).FilterControl.CurrentTextSearch.Value = "fdsajkl;fgewq");
|
||||||
@ -110,7 +110,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestFromSongSelectWithConvertRulesetChange([Values] ScorePresentType type)
|
public void TestFromSongSelectWithConvertRulesetChange([Values] ScorePresentType type)
|
||||||
{
|
{
|
||||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo.Invoke());
|
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo?.Invoke());
|
||||||
AddUntilStep("song select is current", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect && songSelect.BeatmapSetsLoaded);
|
AddUntilStep("song select is current", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect && songSelect.BeatmapSetsLoaded);
|
||||||
|
|
||||||
AddStep("set convert to false", () => Game.LocalConfig.SetValue(OsuSetting.ShowConvertedBeatmaps, false));
|
AddStep("set convert to false", () => Game.LocalConfig.SetValue(OsuSetting.ShowConvertedBeatmaps, false));
|
||||||
@ -122,7 +122,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestFromSongSelect([Values] ScorePresentType type)
|
public void TestFromSongSelect([Values] ScorePresentType type)
|
||||||
{
|
{
|
||||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo.Invoke());
|
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo?.Invoke());
|
||||||
AddUntilStep("song select is current", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect && songSelect.BeatmapSetsLoaded);
|
AddUntilStep("song select is current", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect && songSelect.BeatmapSetsLoaded);
|
||||||
|
|
||||||
var firstImport = importScore(1);
|
var firstImport = importScore(1);
|
||||||
@ -135,7 +135,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestFromSongSelectDifferentRuleset([Values] ScorePresentType type)
|
public void TestFromSongSelectDifferentRuleset([Values] ScorePresentType type)
|
||||||
{
|
{
|
||||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo.Invoke());
|
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo?.Invoke());
|
||||||
AddUntilStep("song select is current", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect && songSelect.BeatmapSetsLoaded);
|
AddUntilStep("song select is current", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect && songSelect.BeatmapSetsLoaded);
|
||||||
|
|
||||||
var firstImport = importScore(1);
|
var firstImport = importScore(1);
|
||||||
|
@ -67,14 +67,15 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddStep("Enter mode", performEnterMode);
|
AddStep("Enter mode", performEnterMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(Key.P, true)]
|
[TestCase(Key.P, Key.P)]
|
||||||
[TestCase(Key.M, true)]
|
[TestCase(Key.M, Key.P)]
|
||||||
[TestCase(Key.L, true)]
|
[TestCase(Key.L, Key.P)]
|
||||||
[TestCase(Key.E, false)]
|
[TestCase(Key.B, Key.E)]
|
||||||
[TestCase(Key.D, false)]
|
[TestCase(Key.S, Key.E)]
|
||||||
[TestCase(Key.Q, false)]
|
[TestCase(Key.D, null)]
|
||||||
[TestCase(Key.O, false)]
|
[TestCase(Key.Q, null)]
|
||||||
public void TestShortcutKeys(Key key, bool entersPlay)
|
[TestCase(Key.O, null)]
|
||||||
|
public void TestShortcutKeys(Key key, Key? subMenuEnterKey)
|
||||||
{
|
{
|
||||||
int activationCount = -1;
|
int activationCount = -1;
|
||||||
AddStep("set up action", () =>
|
AddStep("set up action", () =>
|
||||||
@ -96,8 +97,12 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
buttons.OnPlaylists = action;
|
buttons.OnPlaylists = action;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Key.E:
|
case Key.B:
|
||||||
buttons.OnEdit = action;
|
buttons.OnEditBeatmap = action;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Key.S:
|
||||||
|
buttons.OnEditSkin = action;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Key.D:
|
case Key.D:
|
||||||
@ -117,10 +122,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddStep($"press {key}", () => InputManager.Key(key));
|
AddStep($"press {key}", () => InputManager.Key(key));
|
||||||
AddAssert("state is top level", () => buttons.State == ButtonSystemState.TopLevel);
|
AddAssert("state is top level", () => buttons.State == ButtonSystemState.TopLevel);
|
||||||
|
|
||||||
if (entersPlay)
|
if (subMenuEnterKey != null)
|
||||||
{
|
{
|
||||||
AddStep("press P", () => InputManager.Key(Key.P));
|
AddStep($"press {subMenuEnterKey}", () => InputManager.Key(subMenuEnterKey.Value));
|
||||||
AddAssert("state is play", () => buttons.State == ButtonSystemState.Play);
|
AddAssert("state is not top menu", () => buttons.State != ButtonSystemState.TopLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddStep($"press {key}", () => InputManager.Key(key));
|
AddStep($"press {key}", () => InputManager.Key(key));
|
||||||
|
@ -9,6 +9,11 @@ namespace osu.Game.Localisation
|
|||||||
{
|
{
|
||||||
private const string prefix = @"osu.Game.Resources.Localisation.Editor";
|
private const string prefix = @"osu.Game.Resources.Localisation.Editor";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Beatmap editor"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString BeatmapEditor => new TranslatableString(getKey(@"beatmap_editor"), @"Beatmap editor");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// "Waveform opacity"
|
/// "Waveform opacity"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
// 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;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
using osu.Framework.Extensions.LocalisationExtensions;
|
||||||
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;
|
||||||
@ -36,29 +34,29 @@ 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 OnEdit;
|
|
||||||
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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="logo">The instance of the logo to be assigned. If null, we are suspending from the screen that uses this ButtonSystem.</param>
|
/// <param name="logo">The instance of the logo to be assigned. If null, we are suspending from the screen that uses this ButtonSystem.</param>
|
||||||
public void SetOsuLogo(OsuLogo logo)
|
public void SetOsuLogo(OsuLogo? logo)
|
||||||
{
|
{
|
||||||
this.logo = logo;
|
this.logo = logo;
|
||||||
|
|
||||||
@ -84,9 +82,10 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
private readonly List<MainMenuButton> buttonsTopLevel = new List<MainMenuButton>();
|
private readonly List<MainMenuButton> buttonsTopLevel = new List<MainMenuButton>();
|
||||||
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 Sample sampleBackToLogo;
|
private Sample? sampleBackToLogo;
|
||||||
private Sample sampleLogoSwoosh;
|
private Sample? sampleLogoSwoosh;
|
||||||
|
|
||||||
private readonly LogoTrackingContainer logoTrackingContainer;
|
private readonly LogoTrackingContainer logoTrackingContainer;
|
||||||
|
|
||||||
@ -108,7 +107,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
backButton = new MainMenuButton(ButtonSystemStrings.Back, @"back-to-top", OsuIcon.LeftCircle, new Color4(51, 58, 94, 255), () => State = ButtonSystemState.TopLevel,
|
backButton = new MainMenuButton(ButtonSystemStrings.Back, @"back-to-top", OsuIcon.LeftCircle, new Color4(51, 58, 94, 255), () => State = ButtonSystemState.TopLevel,
|
||||||
-WEDGE_WIDTH)
|
-WEDGE_WIDTH)
|
||||||
{
|
{
|
||||||
VisibleState = ButtonSystemState.Play,
|
VisibleStateMin = ButtonSystemState.Play,
|
||||||
|
VisibleStateMax = ButtonSystemState.Edit,
|
||||||
},
|
},
|
||||||
logoTrackingContainer.LogoFacade.With(d => d.Scale = new Vector2(0.74f))
|
logoTrackingContainer.LogoFacade.With(d => d.Scale = new Vector2(0.74f))
|
||||||
});
|
});
|
||||||
@ -116,31 +116,36 @@ 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));
|
||||||
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Playlists, @"button-default-select", OsuIcon.Charts, new Color4(94, 63, 186, 255), onPlaylists, 0, Key.L));
|
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Playlists, @"button-default-select", OsuIcon.Charts, new Color4(94, 63, 186, 255), onPlaylists, 0, Key.L));
|
||||||
buttonsPlay.ForEach(b => b.VisibleState = ButtonSystemState.Play);
|
buttonsPlay.ForEach(b => b.VisibleState = ButtonSystemState.Play);
|
||||||
|
|
||||||
|
buttonsEdit.Add(new MainMenuButton(EditorStrings.BeatmapEditor.ToLower(), @"button-default-select", HexaconsIcons.Beatmap, new Color4(238, 170, 0, 255), () => OnEditBeatmap?.Invoke(), WEDGE_WIDTH, Key.B));
|
||||||
|
buttonsEdit.Add(new MainMenuButton(SkinEditorStrings.SkinEditor.ToLower(), @"button-default-select", HexaconsIcons.Editor, new Color4(220, 160, 0, 255), () => OnEditSkin?.Invoke(), 0, Key.S));
|
||||||
|
buttonsEdit.ForEach(b => b.VisibleState = ButtonSystemState.Edit);
|
||||||
|
|
||||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Play, @"button-play-select", OsuIcon.Logo, new Color4(102, 68, 204, 255), () => State = ButtonSystemState.Play, WEDGE_WIDTH, Key.P));
|
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Play, @"button-play-select", OsuIcon.Logo, new Color4(102, 68, 204, 255), () => State = ButtonSystemState.Play, WEDGE_WIDTH, Key.P));
|
||||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Edit, @"button-default-select", OsuIcon.EditCircle, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E));
|
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Edit, @"button-play-select", OsuIcon.EditCircle, new Color4(238, 170, 0, 255), () => State = ButtonSystemState.Edit, 0, Key.E));
|
||||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Browse, @"button-default-select", OsuIcon.ChevronDownCircle, new Color4(165, 204, 0, 255), () => OnBeatmapListing?.Invoke(), 0, Key.B, Key.D));
|
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Browse, @"button-default-select", OsuIcon.ChevronDownCircle, new Color4(165, 204, 0, 255), () => OnBeatmapListing?.Invoke(), 0, Key.B, Key.D));
|
||||||
|
|
||||||
if (host.CanExit)
|
if (host.CanExit)
|
||||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Exit, string.Empty, OsuIcon.CrossCircle, new Color4(238, 51, 153, 255), () => OnExit?.Invoke(), 0, Key.Q));
|
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Exit, string.Empty, OsuIcon.CrossCircle, new Color4(238, 51, 153, 255), () => OnExit?.Invoke(), 0, Key.Q));
|
||||||
|
|
||||||
buttonArea.AddRange(buttonsPlay);
|
buttonArea.AddRange(buttonsPlay);
|
||||||
|
buttonArea.AddRange(buttonsEdit);
|
||||||
buttonArea.AddRange(buttonsTopLevel);
|
buttonArea.AddRange(buttonsTopLevel);
|
||||||
|
|
||||||
buttonArea.ForEach(b =>
|
buttonArea.ForEach(b =>
|
||||||
@ -270,6 +275,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case ButtonSystemState.Edit:
|
||||||
case ButtonSystemState.Play:
|
case ButtonSystemState.Play:
|
||||||
StopSamplePlayback();
|
StopSamplePlayback();
|
||||||
backButton.TriggerClick();
|
backButton.TriggerClick();
|
||||||
@ -305,6 +311,10 @@ namespace osu.Game.Screens.Menu
|
|||||||
case ButtonSystemState.Play:
|
case ButtonSystemState.Play:
|
||||||
buttonsPlay.First().TriggerClick();
|
buttonsPlay.First().TriggerClick();
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
case ButtonSystemState.Edit:
|
||||||
|
buttonsEdit.First().TriggerClick();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,6 +338,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
Logger.Log($"{nameof(ButtonSystem)}'s state changed from {lastState} to {state}");
|
Logger.Log($"{nameof(ButtonSystem)}'s state changed from {lastState} to {state}");
|
||||||
|
|
||||||
|
buttonArea.FinishTransforms(true);
|
||||||
|
|
||||||
using (buttonArea.BeginDelayedSequence(lastState == ButtonSystemState.Initial ? 150 : 0))
|
using (buttonArea.BeginDelayedSequence(lastState == ButtonSystemState.Initial ? 150 : 0))
|
||||||
{
|
{
|
||||||
buttonArea.ButtonSystemState = state;
|
buttonArea.ButtonSystemState = state;
|
||||||
@ -340,7 +352,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)
|
||||||
{
|
{
|
||||||
@ -414,6 +426,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
Initial,
|
Initial,
|
||||||
TopLevel,
|
TopLevel,
|
||||||
Play,
|
Play,
|
||||||
|
Edit,
|
||||||
EnteringMode,
|
EnteringMode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ using osu.Game.Input.Bindings;
|
|||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.SkinEditor;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Screens.Backgrounds;
|
using osu.Game.Screens.Backgrounds;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
@ -93,6 +94,9 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
private Sample reappearSampleSwoosh;
|
private Sample reappearSampleSwoosh;
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private SkinEditorOverlay skinEditor { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings, OsuConfigManager config, SessionStatics statics, AudioManager audio)
|
private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings, OsuConfigManager config, SessionStatics statics, AudioManager audio)
|
||||||
{
|
{
|
||||||
@ -120,11 +124,15 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
Buttons = new ButtonSystem
|
Buttons = new ButtonSystem
|
||||||
{
|
{
|
||||||
OnEdit = delegate
|
OnEditBeatmap = () =>
|
||||||
{
|
{
|
||||||
Beatmap.SetDefault();
|
Beatmap.SetDefault();
|
||||||
this.Push(new EditorLoader());
|
this.Push(new EditorLoader());
|
||||||
},
|
},
|
||||||
|
OnEditSkin = () =>
|
||||||
|
{
|
||||||
|
skinEditor?.Show();
|
||||||
|
},
|
||||||
OnSolo = loadSoloSongSelect,
|
OnSolo = loadSoloSongSelect,
|
||||||
OnMultiplayer = () => this.Push(new Multiplayer()),
|
OnMultiplayer = () => this.Push(new Multiplayer()),
|
||||||
OnPlaylists = () => this.Push(new Playlists()),
|
OnPlaylists = () => this.Push(new Playlists()),
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// 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.Linq;
|
using System.Linq;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
@ -33,7 +31,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainMenuButton : BeatSyncedContainer, IStateful<ButtonState>
|
public partial class MainMenuButton : BeatSyncedContainer, IStateful<ButtonState>
|
||||||
{
|
{
|
||||||
public event Action<ButtonState> StateChanged;
|
public event Action<ButtonState>? StateChanged;
|
||||||
|
|
||||||
public readonly Key[] TriggerKeys;
|
public readonly Key[] TriggerKeys;
|
||||||
|
|
||||||
@ -44,18 +42,28 @@ namespace osu.Game.Screens.Menu
|
|||||||
private readonly string sampleName;
|
private readonly string sampleName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The menu state for which we are visible for.
|
/// The menu state for which we are visible for (assuming only one).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ButtonSystemState VisibleState = ButtonSystemState.TopLevel;
|
public ButtonSystemState VisibleState
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
VisibleStateMin = value;
|
||||||
|
VisibleStateMax = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private readonly Action clickAction;
|
public ButtonSystemState VisibleStateMin = ButtonSystemState.TopLevel;
|
||||||
private Sample sampleClick;
|
public ButtonSystemState VisibleStateMax = ButtonSystemState.TopLevel;
|
||||||
private Sample sampleHover;
|
|
||||||
private SampleChannel sampleChannel;
|
private readonly Action? clickAction;
|
||||||
|
private Sample? sampleClick;
|
||||||
|
private Sample? sampleHover;
|
||||||
|
private SampleChannel? sampleChannel;
|
||||||
|
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos);
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos);
|
||||||
|
|
||||||
public MainMenuButton(LocalisableString text, string sampleName, IconUsage symbol, Color4 colour, Action clickAction = null, float extraWidth = 0, params Key[] triggerKeys)
|
public MainMenuButton(LocalisableString text, string sampleName, IconUsage symbol, Color4 colour, Action? clickAction = null, float extraWidth = 0, params Key[] triggerKeys)
|
||||||
{
|
{
|
||||||
this.sampleName = sampleName;
|
this.sampleName = sampleName;
|
||||||
this.clickAction = clickAction;
|
this.clickAction = clickAction;
|
||||||
@ -315,9 +323,9 @@ namespace osu.Game.Screens.Menu
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (value == VisibleState)
|
if (value <= VisibleStateMax && value >= VisibleStateMin)
|
||||||
State = ButtonState.Expanded;
|
State = ButtonState.Expanded;
|
||||||
else if (value < VisibleState)
|
else if (value < VisibleStateMin)
|
||||||
State = ButtonState.Contracted;
|
State = ButtonState.Contracted;
|
||||||
else
|
else
|
||||||
State = ButtonState.Exploded;
|
State = ButtonState.Exploded;
|
||||||
|
Loading…
Reference in New Issue
Block a user