mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 14:03:01 +08:00
Merge branch 'master' into collection-database
This commit is contained in:
commit
66d3bda962
32
osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs
Normal file
32
osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
|
using osu.Game.Screens.Edit;
|
||||||
|
using osu.Game.Screens.Edit.Setup;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Editing
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestSceneSetupScreen : EditorClockTestScene
|
||||||
|
{
|
||||||
|
[Cached(typeof(EditorBeatmap))]
|
||||||
|
[Cached(typeof(IBeatSnapProvider))]
|
||||||
|
private readonly EditorBeatmap editorBeatmap;
|
||||||
|
|
||||||
|
public TestSceneSetupScreen()
|
||||||
|
{
|
||||||
|
editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
|
||||||
|
Child = new SetupScreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
83
osu.Game.Tests/Visual/Menus/TestSceneMusicActionHandling.cs
Normal file
83
osu.Game.Tests/Visual/Menus/TestSceneMusicActionHandling.cs
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Tests.Resources;
|
||||||
|
using osu.Game.Tests.Visual.Navigation;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Menus
|
||||||
|
{
|
||||||
|
public class TestSceneMusicActionHandling : OsuGameTestScene
|
||||||
|
{
|
||||||
|
private GlobalActionContainer globalActionContainer => Game.ChildrenOfType<GlobalActionContainer>().First();
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMusicPlayAction()
|
||||||
|
{
|
||||||
|
AddStep("ensure playing something", () => Game.MusicController.EnsurePlayingSomething());
|
||||||
|
AddStep("toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
|
||||||
|
AddAssert("music paused", () => !Game.MusicController.IsPlaying && Game.MusicController.IsUserPaused);
|
||||||
|
AddStep("toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
|
||||||
|
AddAssert("music resumed", () => Game.MusicController.IsPlaying && !Game.MusicController.IsUserPaused);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMusicNavigationActions()
|
||||||
|
{
|
||||||
|
int importId = 0;
|
||||||
|
Queue<(WorkingBeatmap working, TrackChangeDirection changeDirection)> trackChangeQueue = null;
|
||||||
|
|
||||||
|
// ensure we have at least two beatmaps available to identify the direction the music controller navigated to.
|
||||||
|
AddRepeatStep("import beatmap", () => Game.BeatmapManager.Import(new BeatmapSetInfo
|
||||||
|
{
|
||||||
|
Beatmaps = new List<BeatmapInfo>
|
||||||
|
{
|
||||||
|
new BeatmapInfo
|
||||||
|
{
|
||||||
|
BaseDifficulty = new BeatmapDifficulty(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Metadata = new BeatmapMetadata
|
||||||
|
{
|
||||||
|
Artist = $"a test map {importId++}",
|
||||||
|
Title = "title",
|
||||||
|
}
|
||||||
|
}).Wait(), 5);
|
||||||
|
|
||||||
|
AddStep("import beatmap with track", () =>
|
||||||
|
{
|
||||||
|
var setWithTrack = Game.BeatmapManager.Import(TestResources.GetTestBeatmapForImport()).Result;
|
||||||
|
Beatmap.Value = Game.BeatmapManager.GetWorkingBeatmap(setWithTrack.Beatmaps.First());
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("bind to track change", () =>
|
||||||
|
{
|
||||||
|
trackChangeQueue = new Queue<(WorkingBeatmap, TrackChangeDirection)>();
|
||||||
|
Game.MusicController.TrackChanged += (working, changeDirection) => trackChangeQueue.Enqueue((working, changeDirection));
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("seek track to 6 second", () => Game.MusicController.SeekTo(6000));
|
||||||
|
AddUntilStep("wait for current time to update", () => Game.MusicController.CurrentTrack.CurrentTime > 5000);
|
||||||
|
|
||||||
|
AddStep("press previous", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPrev));
|
||||||
|
AddAssert("no track change", () => trackChangeQueue.Count == 0);
|
||||||
|
AddUntilStep("track restarted", () => Game.MusicController.CurrentTrack.CurrentTime < 5000);
|
||||||
|
|
||||||
|
AddStep("press previous", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPrev));
|
||||||
|
AddAssert("track changed to previous", () =>
|
||||||
|
trackChangeQueue.Count == 1 &&
|
||||||
|
trackChangeQueue.Dequeue().changeDirection == TrackChangeDirection.Prev);
|
||||||
|
|
||||||
|
AddStep("press next", () => globalActionContainer.TriggerPressed(GlobalAction.MusicNext));
|
||||||
|
AddAssert("track changed to next", () =>
|
||||||
|
trackChangeQueue.Count == 1 &&
|
||||||
|
trackChangeQueue.Dequeue().changeDirection == TrackChangeDirection.Next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +1,11 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Platform;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Tests.Resources;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.UserInterface
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
{
|
{
|
||||||
@ -24,14 +17,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
private NowPlayingOverlay nowPlayingOverlay;
|
private NowPlayingOverlay nowPlayingOverlay;
|
||||||
|
|
||||||
private RulesetStore rulesets;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio, GameHost host)
|
private void load()
|
||||||
{
|
{
|
||||||
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
|
||||||
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));
|
|
||||||
|
|
||||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||||
|
|
||||||
nowPlayingOverlay = new NowPlayingOverlay
|
nowPlayingOverlay = new NowPlayingOverlay
|
||||||
@ -51,49 +39,5 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddToggleStep(@"toggle beatmap lock", state => Beatmap.Disabled = state);
|
AddToggleStep(@"toggle beatmap lock", state => Beatmap.Disabled = state);
|
||||||
AddStep(@"hide", () => nowPlayingOverlay.Hide());
|
AddStep(@"hide", () => nowPlayingOverlay.Hide());
|
||||||
}
|
}
|
||||||
|
|
||||||
private BeatmapManager manager { get; set; }
|
|
||||||
|
|
||||||
private int importId;
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestPrevTrackBehavior()
|
|
||||||
{
|
|
||||||
// ensure we have at least two beatmaps available.
|
|
||||||
AddRepeatStep("import beatmap", () => manager.Import(new BeatmapSetInfo
|
|
||||||
{
|
|
||||||
Beatmaps = new List<BeatmapInfo>
|
|
||||||
{
|
|
||||||
new BeatmapInfo
|
|
||||||
{
|
|
||||||
BaseDifficulty = new BeatmapDifficulty(),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Metadata = new BeatmapMetadata
|
|
||||||
{
|
|
||||||
Artist = $"a test map {importId++}",
|
|
||||||
Title = "title",
|
|
||||||
}
|
|
||||||
}).Wait(), 5);
|
|
||||||
|
|
||||||
WorkingBeatmap currentBeatmap = null;
|
|
||||||
|
|
||||||
AddStep("import beatmap with track", () =>
|
|
||||||
{
|
|
||||||
var setWithTrack = manager.Import(TestResources.GetTestBeatmapForImport()).Result;
|
|
||||||
Beatmap.Value = currentBeatmap = manager.GetWorkingBeatmap(setWithTrack.Beatmaps.First());
|
|
||||||
});
|
|
||||||
|
|
||||||
AddStep(@"Seek track to 6 second", () => musicController.SeekTo(6000));
|
|
||||||
AddUntilStep(@"Wait for current time to update", () => musicController.CurrentTrack.CurrentTime > 5000);
|
|
||||||
|
|
||||||
AddStep(@"Set previous", () => musicController.PreviousTrack());
|
|
||||||
|
|
||||||
AddAssert(@"Check beatmap didn't change", () => currentBeatmap == Beatmap.Value);
|
|
||||||
AddUntilStep("Wait for current time to update", () => musicController.CurrentTrack.CurrentTime < 5000);
|
|
||||||
|
|
||||||
AddStep(@"Set previous", () => musicController.PreviousTrack());
|
|
||||||
AddAssert(@"Check beatmap did change", () => currentBeatmap != Beatmap.Value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
public class OsuDropdown<T> : Dropdown<T>, IHasAccentColour
|
public class OsuDropdown<T> : Dropdown<T>, IHasAccentColour
|
||||||
{
|
{
|
||||||
|
private const float corner_radius = 4;
|
||||||
|
|
||||||
private Color4 accentColour;
|
private Color4 accentColour;
|
||||||
|
|
||||||
public Color4 AccentColour
|
public Color4 AccentColour
|
||||||
@ -57,9 +59,11 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
|
// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
|
||||||
public OsuDropdownMenu()
|
public OsuDropdownMenu()
|
||||||
{
|
{
|
||||||
CornerRadius = 4;
|
CornerRadius = corner_radius;
|
||||||
BackgroundColour = Color4.Black.Opacity(0.5f);
|
BackgroundColour = Color4.Black.Opacity(0.5f);
|
||||||
|
|
||||||
|
MaskingContainer.CornerRadius = corner_radius;
|
||||||
|
|
||||||
// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
|
// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
|
||||||
ItemsContainer.Padding = new MarginPadding(5);
|
ItemsContainer.Padding = new MarginPadding(5);
|
||||||
}
|
}
|
||||||
@ -138,7 +142,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Foreground.Padding = new MarginPadding(2);
|
Foreground.Padding = new MarginPadding(2);
|
||||||
|
|
||||||
Masking = true;
|
Masking = true;
|
||||||
CornerRadius = 6;
|
CornerRadius = corner_radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -237,7 +241,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
AutoSizeAxes = Axes.None;
|
AutoSizeAxes = Axes.None;
|
||||||
Margin = new MarginPadding { Bottom = 4 };
|
Margin = new MarginPadding { Bottom = 4 };
|
||||||
CornerRadius = 4;
|
CornerRadius = corner_radius;
|
||||||
Height = 40;
|
Height = 40;
|
||||||
|
|
||||||
Foreground.Children = new Drawable[]
|
Foreground.Children = new Drawable[]
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
|
||||||
@ -32,6 +33,11 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
|||||||
set => Component.Text = value;
|
set => Component.Text = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Container TabbableContentContainer
|
||||||
|
{
|
||||||
|
set => Component.TabbableContentContainer = value;
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,7 @@ using osu.Game.Input;
|
|||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
|
using osu.Game.Overlays.Music;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Game.Overlays.Volume;
|
using osu.Game.Overlays.Volume;
|
||||||
@ -652,6 +653,7 @@ namespace osu.Game
|
|||||||
chatOverlay.State.ValueChanged += state => channelManager.HighPollRate.Value = state.NewValue == Visibility.Visible;
|
chatOverlay.State.ValueChanged += state => channelManager.HighPollRate.Value = state.NewValue == Visibility.Visible;
|
||||||
|
|
||||||
Add(externalLinkOpener = new ExternalLinkOpener());
|
Add(externalLinkOpener = new ExternalLinkOpener());
|
||||||
|
Add(new MusicKeyBindingHandler());
|
||||||
|
|
||||||
// side overlays which cancel each other.
|
// side overlays which cancel each other.
|
||||||
var singleDisplaySideOverlays = new OverlayContainer[] { Settings, notifications };
|
var singleDisplaySideOverlays = new OverlayContainer[] { Settings, notifications };
|
||||||
|
@ -256,10 +256,11 @@ namespace osu.Game
|
|||||||
AddInternal(apiAccess);
|
AddInternal(apiAccess);
|
||||||
AddInternal(RulesetConfigCache);
|
AddInternal(RulesetConfigCache);
|
||||||
|
|
||||||
GlobalActionContainer globalBinding;
|
|
||||||
|
|
||||||
MenuCursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both };
|
MenuCursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both };
|
||||||
MenuCursorContainer.Child = globalBinding = new GlobalActionContainer(this)
|
|
||||||
|
GlobalActionContainer globalBindings;
|
||||||
|
|
||||||
|
MenuCursorContainer.Child = globalBindings = new GlobalActionContainer(this)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = content = new OsuTooltipContainer(MenuCursorContainer.Cursor) { RelativeSizeAxes = Axes.Both }
|
Child = content = new OsuTooltipContainer(MenuCursorContainer.Cursor) { RelativeSizeAxes = Axes.Both }
|
||||||
@ -267,8 +268,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
base.Content.Add(CreateScalingContainer().WithChild(MenuCursorContainer));
|
base.Content.Add(CreateScalingContainer().WithChild(MenuCursorContainer));
|
||||||
|
|
||||||
KeyBindingStore.Register(globalBinding);
|
KeyBindingStore.Register(globalBindings);
|
||||||
dependencies.Cache(globalBinding);
|
dependencies.Cache(globalBindings);
|
||||||
|
|
||||||
PreviewTrackManager previewTrackManager;
|
PreviewTrackManager previewTrackManager;
|
||||||
dependencies.Cache(previewTrackManager = new PreviewTrackManager());
|
dependencies.Cache(previewTrackManager = new PreviewTrackManager());
|
||||||
|
81
osu.Game/Overlays/Music/MusicKeyBindingHandler.cs
Normal file
81
osu.Game/Overlays/Music/MusicKeyBindingHandler.cs
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
|
using osu.Game.Overlays.OSD;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Music
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Handles <see cref="GlobalAction"/>s related to music playback, and displays <see cref="Toast"/>s via the global <see cref="OnScreenDisplay"/> accordingly.
|
||||||
|
/// </summary>
|
||||||
|
public class MusicKeyBindingHandler : Component, IKeyBindingHandler<GlobalAction>
|
||||||
|
{
|
||||||
|
[Resolved]
|
||||||
|
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private MusicController musicController { get; set; }
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private OnScreenDisplay onScreenDisplay { get; set; }
|
||||||
|
|
||||||
|
public bool OnPressed(GlobalAction action)
|
||||||
|
{
|
||||||
|
if (beatmap.Disabled)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case GlobalAction.MusicPlay:
|
||||||
|
// use previous state as TogglePause may not update the track's state immediately (state update is run on the audio thread see https://github.com/ppy/osu/issues/9880#issuecomment-674668842)
|
||||||
|
bool wasPlaying = musicController.IsPlaying;
|
||||||
|
|
||||||
|
if (musicController.TogglePause())
|
||||||
|
onScreenDisplay?.Display(new MusicActionToast(wasPlaying ? "Pause track" : "Play track"));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case GlobalAction.MusicNext:
|
||||||
|
musicController.NextTrack(() => onScreenDisplay?.Display(new MusicActionToast("Next track")));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case GlobalAction.MusicPrev:
|
||||||
|
musicController.PreviousTrack(res =>
|
||||||
|
{
|
||||||
|
switch (res)
|
||||||
|
{
|
||||||
|
case PreviousTrackResult.Restart:
|
||||||
|
onScreenDisplay?.Display(new MusicActionToast("Restart track"));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PreviousTrackResult.Previous:
|
||||||
|
onScreenDisplay?.Display(new MusicActionToast("Previous track"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnReleased(GlobalAction action)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MusicActionToast : Toast
|
||||||
|
{
|
||||||
|
public MusicActionToast(string action)
|
||||||
|
: base("Music Playback", action, string.Empty)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,12 +12,9 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Audio;
|
using osu.Framework.Graphics.Audio;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Bindings;
|
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Input.Bindings;
|
|
||||||
using osu.Game.Overlays.OSD;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
@ -25,7 +22,7 @@ namespace osu.Game.Overlays
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles playback of the global music track.
|
/// Handles playback of the global music track.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MusicController : CompositeDrawable, IKeyBindingHandler<GlobalAction>
|
public class MusicController : CompositeDrawable
|
||||||
{
|
{
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmaps { get; set; }
|
private BeatmapManager beatmaps { get; set; }
|
||||||
@ -62,9 +59,6 @@ namespace osu.Game.Overlays
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
|
||||||
private OnScreenDisplay onScreenDisplay { get; set; }
|
|
||||||
|
|
||||||
[NotNull]
|
[NotNull]
|
||||||
public DrawableTrack CurrentTrack { get; private set; } = new DrawableTrack(new TrackVirtual(1000));
|
public DrawableTrack CurrentTrack { get; private set; } = new DrawableTrack(new TrackVirtual(1000));
|
||||||
|
|
||||||
@ -207,7 +201,13 @@ namespace osu.Game.Overlays
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Play the previous track or restart the current track if it's current time below <see cref="restart_cutoff_point"/>.
|
/// Play the previous track or restart the current track if it's current time below <see cref="restart_cutoff_point"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PreviousTrack() => Schedule(() => prev());
|
/// <param name="onSuccess">Invoked when the operation has been performed successfully.</param>
|
||||||
|
public void PreviousTrack(Action<PreviousTrackResult> onSuccess = null) => Schedule(() =>
|
||||||
|
{
|
||||||
|
PreviousTrackResult res = prev();
|
||||||
|
if (res != PreviousTrackResult.None)
|
||||||
|
onSuccess?.Invoke(res);
|
||||||
|
});
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Play the previous track or restart the current track if it's current time below <see cref="restart_cutoff_point"/>.
|
/// Play the previous track or restart the current track if it's current time below <see cref="restart_cutoff_point"/>.
|
||||||
@ -243,7 +243,14 @@ namespace osu.Game.Overlays
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Play the next random or playlist track.
|
/// Play the next random or playlist track.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void NextTrack() => Schedule(() => next());
|
/// <param name="onSuccess">Invoked when the operation has been performed successfully.</param>
|
||||||
|
/// <returns>A <see cref="ScheduledDelegate"/> of the operation.</returns>
|
||||||
|
public void NextTrack(Action onSuccess = null) => Schedule(() =>
|
||||||
|
{
|
||||||
|
bool res = next();
|
||||||
|
if (res)
|
||||||
|
onSuccess?.Invoke();
|
||||||
|
});
|
||||||
|
|
||||||
private bool next()
|
private bool next()
|
||||||
{
|
{
|
||||||
@ -407,54 +414,6 @@ namespace osu.Game.Overlays
|
|||||||
mod.ApplyToTrack(CurrentTrack);
|
mod.ApplyToTrack(CurrentTrack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OnPressed(GlobalAction action)
|
|
||||||
{
|
|
||||||
if (beatmap.Disabled)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case GlobalAction.MusicPlay:
|
|
||||||
if (TogglePause())
|
|
||||||
onScreenDisplay?.Display(new MusicControllerToast(IsPlaying ? "Play track" : "Pause track"));
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case GlobalAction.MusicNext:
|
|
||||||
if (next())
|
|
||||||
onScreenDisplay?.Display(new MusicControllerToast("Next track"));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case GlobalAction.MusicPrev:
|
|
||||||
switch (prev())
|
|
||||||
{
|
|
||||||
case PreviousTrackResult.Restart:
|
|
||||||
onScreenDisplay?.Display(new MusicControllerToast("Restart track"));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PreviousTrackResult.Previous:
|
|
||||||
onScreenDisplay?.Display(new MusicControllerToast("Previous track"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnReleased(GlobalAction action)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MusicControllerToast : Toast
|
|
||||||
{
|
|
||||||
public MusicControllerToast(string action)
|
|
||||||
: base("Music Playback", action, string.Empty)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum TrackChangeDirection
|
public enum TrackChangeDirection
|
||||||
|
@ -61,7 +61,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
AddRangeInternal(new[]
|
AddRangeInternal(new[]
|
||||||
{
|
{
|
||||||
DragBox = CreateDragBox(select),
|
DragBox = CreateDragBox(selectBlueprintsFromDragRectangle),
|
||||||
selectionHandler,
|
selectionHandler,
|
||||||
SelectionBlueprints = CreateSelectionBlueprintContainer(),
|
SelectionBlueprints = CreateSelectionBlueprintContainer(),
|
||||||
selectionHandler.CreateProxy(),
|
selectionHandler.CreateProxy(),
|
||||||
@ -326,7 +326,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// Select all masks in a given rectangle selection area.
|
/// Select all masks in a given rectangle selection area.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rect">The rectangle to perform a selection on in screen-space coordinates.</param>
|
/// <param name="rect">The rectangle to perform a selection on in screen-space coordinates.</param>
|
||||||
private void select(RectangleF rect)
|
private void selectBlueprintsFromDragRectangle(RectangleF rect)
|
||||||
{
|
{
|
||||||
foreach (var blueprint in SelectionBlueprints)
|
foreach (var blueprint in SelectionBlueprints)
|
||||||
{
|
{
|
||||||
|
@ -398,7 +398,11 @@ namespace osu.Game.Screens.Edit
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadComponentAsync(currentScreen, screenContainer.Add);
|
LoadComponentAsync(currentScreen, newScreen =>
|
||||||
|
{
|
||||||
|
if (newScreen == currentScreen)
|
||||||
|
screenContainer.Add(newScreen);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void seek(UIEvent e, int direction)
|
private void seek(UIEvent e, int direction)
|
||||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
public void Exit()
|
public void Exit()
|
||||||
{
|
{
|
||||||
this.FadeOut(250).Expire();
|
Expire();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,123 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Game.Beatmaps.Drawables;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Setup
|
namespace osu.Game.Screens.Edit.Setup
|
||||||
{
|
{
|
||||||
public class SetupScreen : EditorScreen
|
public class SetupScreen : EditorScreen
|
||||||
{
|
{
|
||||||
public SetupScreen()
|
private FillFlowContainer flow;
|
||||||
|
private LabelledTextBox artistTextBox;
|
||||||
|
private LabelledTextBox titleTextBox;
|
||||||
|
private LabelledTextBox creatorTextBox;
|
||||||
|
private LabelledTextBox difficultyTextBox;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
Child = new ScreenWhiteBox.UnderConstructionMessage("Setup mode");
|
Child = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding(50),
|
||||||
|
Child = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
|
CornerRadius = 10,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Colour = colours.GreySeafoamDark,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
new OsuScrollContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding(10),
|
||||||
|
Child = flow = new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Spacing = new Vector2(20),
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 250,
|
||||||
|
Masking = true,
|
||||||
|
CornerRadius = 10,
|
||||||
|
Child = new BeatmapBackgroundSprite(Beatmap.Value)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
FillMode = FillMode.Fill,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = "Beatmap metadata"
|
||||||
|
},
|
||||||
|
artistTextBox = new LabelledTextBox
|
||||||
|
{
|
||||||
|
Label = "Artist",
|
||||||
|
Current = { Value = Beatmap.Value.Metadata.Artist },
|
||||||
|
TabbableContentContainer = this
|
||||||
|
},
|
||||||
|
titleTextBox = new LabelledTextBox
|
||||||
|
{
|
||||||
|
Label = "Title",
|
||||||
|
Current = { Value = Beatmap.Value.Metadata.Title },
|
||||||
|
TabbableContentContainer = this
|
||||||
|
},
|
||||||
|
creatorTextBox = new LabelledTextBox
|
||||||
|
{
|
||||||
|
Label = "Creator",
|
||||||
|
Current = { Value = Beatmap.Value.Metadata.AuthorString },
|
||||||
|
TabbableContentContainer = this
|
||||||
|
},
|
||||||
|
difficultyTextBox = new LabelledTextBox
|
||||||
|
{
|
||||||
|
Label = "Difficulty Name",
|
||||||
|
Current = { Value = Beatmap.Value.BeatmapInfo.Version },
|
||||||
|
TabbableContentContainer = this
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var item in flow.OfType<LabelledTextBox>())
|
||||||
|
item.OnCommit += onCommit;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onCommit(TextBox sender, bool newText)
|
||||||
|
{
|
||||||
|
if (!newText) return;
|
||||||
|
|
||||||
|
// for now, update these on commit rather than making BeatmapMetadata bindables.
|
||||||
|
// after switching database engines we can reconsider if switching to bindables is a good direction.
|
||||||
|
Beatmap.Value.Metadata.Artist = artistTextBox.Current.Value;
|
||||||
|
Beatmap.Value.Metadata.Title = titleTextBox.Current.Value;
|
||||||
|
Beatmap.Value.Metadata.AuthorString = creatorTextBox.Current.Value;
|
||||||
|
Beatmap.Value.BeatmapInfo.Version = difficultyTextBox.Current.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user