1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 18:23:04 +08:00

Merge branch 'master' into registration-loc

This commit is contained in:
Feodor0090 2023-01-17 13:38:05 +03:00 committed by GitHub
commit 99c65af6cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 532 additions and 184 deletions

View File

@ -0,0 +1,30 @@
// 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.Linq;
using NUnit.Framework;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Tests.Visual;
using osuTK.Input;
namespace osu.Game.Rulesets.Mania.Tests.Editor
{
public partial class TestScenePlacementBeforeTrackStart : EditorTestScene
{
protected override Ruleset CreateEditorRuleset() => new ManiaRuleset();
[Test]
public void TestPlacement()
{
AddStep("Seek to 0", () => EditorClock.Seek(0));
AddStep("Select note", () => InputManager.Key(Key.Number2));
AddStep("Hover negative span", () =>
{
InputManager.MoveMouseTo(this.ChildrenOfType<Container>().First(x => x.Name == "Icons").Children[0]);
});
AddStep("Click", () => InputManager.Click(MouseButton.Left));
AddAssert("No notes placed", () => EditorBeatmap.HitObjects.All(x => x.StartTime >= 0));
}
}
}

View File

@ -0,0 +1,79 @@
// 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.Game.Beatmaps.ControlPoints;
namespace osu.Game.Tests.Editing
{
[TestFixture]
public class TestSceneSnappingNearZero
{
private readonly ControlPointInfo cpi = new ControlPointInfo();
[Test]
public void TestOnZero()
{
test(0, 500, 0, 0);
test(0, 500, 100, 0);
test(0, 500, 250, 500);
test(0, 500, 600, 500);
test(0, 500, -600, 0);
}
[Test]
public void TestAlmostOnZero()
{
test(50, 500, 0, 50);
test(50, 500, 50, 50);
test(50, 500, 100, 50);
test(50, 500, 299, 50);
test(50, 500, 300, 550);
test(50, 500, -500, 50);
}
[Test]
public void TestAlmostOnOne()
{
test(499, 500, -1, 499);
test(499, 500, 0, 499);
test(499, 500, 1, 499);
test(499, 500, 499, 499);
test(499, 500, 600, 499);
test(499, 500, 800, 999);
}
[Test]
public void TestOnOne()
{
test(500, 500, -500, 0);
test(500, 500, 0, 0);
test(500, 500, 200, 0);
test(500, 500, 400, 500);
test(500, 500, 500, 500);
test(500, 500, 600, 500);
test(500, 500, 900, 1000);
}
[Test]
public void TestNegative()
{
test(-600, 500, -600, 400);
test(-600, 500, -100, 400);
test(-600, 500, 0, 400);
test(-600, 500, 200, 400);
test(-600, 500, 400, 400);
test(-600, 500, 600, 400);
test(-600, 500, 1000, 900);
}
private void test(double pointTime, double beatLength, double from, double expected)
{
cpi.Clear();
cpi.Add(pointTime, new TimingControlPoint { BeatLength = beatLength });
Assert.That(cpi.GetClosestSnappedTime(from, 1), Is.EqualTo(expected), $"From: {from}");
}
}
}

View File

@ -17,7 +17,7 @@ namespace osu.Game.Tests.NonVisual
public void TestExactDivisors()
{
var cpi = new ControlPointInfo();
cpi.Add(-1000, new TimingControlPoint { BeatLength = 1000 });
cpi.Add(0, new TimingControlPoint { BeatLength = 1000 });
double[] divisors = { 3, 1, 16, 12, 8, 6, 4, 3, 2, 1 };
@ -47,7 +47,7 @@ namespace osu.Game.Tests.NonVisual
public void TestExactDivisorsHighBPMStream()
{
var cpi = new ControlPointInfo();
cpi.Add(-50, new TimingControlPoint { BeatLength = 50 }); // 1200 BPM 1/4 (limit testing)
cpi.Add(0, new TimingControlPoint { BeatLength = 50 }); // 1200 BPM 1/4 (limit testing)
// A 1/4 stream should land on 1/1, 1/2 and 1/4 divisors.
double[] divisors = { 4, 4, 4, 4, 4, 4, 4, 4 };
@ -60,7 +60,7 @@ namespace osu.Game.Tests.NonVisual
public void TestApproximateDivisors()
{
var cpi = new ControlPointInfo();
cpi.Add(-1000, new TimingControlPoint { BeatLength = 1000 });
cpi.Add(0, new TimingControlPoint { BeatLength = 1000 });
double[] divisors = { 3.03d, 0.97d, 14, 13, 7.94d, 6.08d, 3.93d, 2.96d, 2.02d, 64 };
double[] closestDivisors = { 3, 1, 16, 12, 8, 6, 4, 3, 2, 1 };
@ -68,7 +68,7 @@ namespace osu.Game.Tests.NonVisual
assertClosestDivisors(divisors, closestDivisors, cpi);
}
private void assertClosestDivisors(IReadOnlyList<double> divisors, IReadOnlyList<double> closestDivisors, ControlPointInfo cpi, double step = 1)
private static void assertClosestDivisors(IReadOnlyList<double> divisors, IReadOnlyList<double> closestDivisors, ControlPointInfo cpi, double step = 1)
{
List<HitObject> hitobjects = new List<HitObject>();
double offset = cpi.TimingPoints[0].Time;

View File

@ -20,6 +20,8 @@ using osu.Game.Rulesets.Catch;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.Taiko;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Setup;
using osu.Game.Storyboards;
@ -395,5 +397,52 @@ namespace osu.Game.Tests.Visual.Editing
return set != null && set.PerformRead(s => s.Beatmaps.Count == 2 && s.Files.Count == 2);
});
}
[Test]
public void TestCreateNewDifficultyForInconvertibleRuleset()
{
Guid setId = Guid.Empty;
AddStep("retrieve set ID", () => setId = EditorBeatmap.BeatmapInfo.BeatmapSet!.ID);
AddStep("save beatmap", () => Editor.Save());
AddStep("try to create new taiko difficulty", () => Editor.CreateNewDifficulty(new TaikoRuleset().RulesetInfo));
AddUntilStep("wait for created", () =>
{
string? difficultyName = Editor.ChildrenOfType<EditorBeatmap>().SingleOrDefault()?.BeatmapInfo.DifficultyName;
return difficultyName != null && difficultyName == "New Difficulty";
});
AddAssert("new difficulty persisted", () =>
{
var set = beatmapManager.QueryBeatmapSet(s => s.ID == setId);
return set != null && set.PerformRead(s => s.Beatmaps.Count == 2 && s.Files.Count == 2);
});
AddStep("add timing point", () => EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 1000 }));
AddStep("add hitobjects", () => EditorBeatmap.AddRange(new[]
{
new Hit
{
StartTime = 0
},
new Hit
{
StartTime = 1000
}
}));
AddStep("save beatmap", () => Editor.Save());
AddStep("try to create new catch difficulty", () => Editor.CreateNewDifficulty(new CatchRuleset().RulesetInfo));
AddUntilStep("wait for created", () =>
{
string? difficultyName = Editor.ChildrenOfType<EditorBeatmap>().SingleOrDefault()?.BeatmapInfo.DifficultyName;
return difficultyName != null && difficultyName == "New Difficulty (1)";
});
AddAssert("new difficulty persisted", () =>
{
var set = beatmapManager.QueryBeatmapSet(s => s.ID == setId);
return set != null && set.PerformRead(s => s.Beatmaps.Count == 3 && s.Files.Count == 3);
});
}
}
}

View File

@ -144,7 +144,7 @@ namespace osu.Game.Tests.Visual.Editing
double lastStarRating = 0;
double lastLength = 0;
AddStep("Add timing point", () => EditorBeatmap.ControlPointInfo.Add(500, new TimingControlPoint()));
AddStep("Add timing point", () => EditorBeatmap.ControlPointInfo.Add(200, new TimingControlPoint { BeatLength = 600 }));
AddStep("Change to placement mode", () => InputManager.Key(Key.Number2));
AddStep("Move to playfield", () => InputManager.MoveMouseTo(Game.ScreenSpaceDrawQuad.Centre));
AddStep("Place single hitcircle", () => InputManager.Click(MouseButton.Left));

View File

@ -5,6 +5,7 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -34,6 +35,12 @@ namespace osu.Game.Tests.Visual.Gameplay
base.Content.Add(content = new GlobalCursorDisplay { RelativeSizeAxes = Axes.Both });
}
[BackgroundDependencyLoader]
private void load()
{
LocalConfig.SetValue(OsuSetting.UIHoldActivationDelay, 0.0);
}
[SetUpSteps]
public override void SetUpSteps()
{
@ -43,6 +50,22 @@ namespace osu.Game.Tests.Visual.Gameplay
confirmClockRunning(true);
}
[Test]
public void TestTogglePauseViaBackAction()
{
pauseViaBackAction();
pauseViaBackAction();
confirmPausedWithNoOverlay();
}
[Test]
public void TestTogglePauseViaPauseGameplayAction()
{
pauseViaPauseGameplayAction();
pauseViaPauseGameplayAction();
confirmPausedWithNoOverlay();
}
[Test]
public void TestPauseWithLargeOffset()
{
@ -144,7 +167,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
AddStep("disable pause support", () => Player.Configuration.AllowPause = false);
pauseFromUserExitKey();
pauseViaBackAction();
confirmExited();
}
@ -156,7 +179,7 @@ namespace osu.Game.Tests.Visual.Gameplay
pauseAndConfirm();
resume();
pauseFromUserExitKey();
pauseViaBackAction();
confirmResumed();
confirmNotExited();
@ -170,7 +193,7 @@ namespace osu.Game.Tests.Visual.Gameplay
pauseAndConfirm();
resume();
AddStep("pause via exit key", () => Player.ExitViaQuickExit());
exitViaQuickExitAction();
confirmResumed();
AddAssert("exited", () => !Player.IsCurrentScreen());
@ -214,7 +237,7 @@ namespace osu.Game.Tests.Visual.Gameplay
confirmClockRunning(false);
AddStep("exit via user pause", () => Player.ExitViaPause());
pauseViaBackAction();
confirmExited();
}
@ -224,11 +247,11 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
// will finish the fail animation and show the fail/pause screen.
AddStep("attempt exit via pause key", () => Player.ExitViaPause());
pauseViaBackAction();
AddAssert("fail overlay shown", () => Player.FailOverlayVisible);
// will actually exit.
AddStep("exit via pause key", () => Player.ExitViaPause());
pauseViaBackAction();
confirmExited();
}
@ -245,7 +268,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public void TestQuickExitFromFailedGameplay()
{
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddStep("quick exit", () => Player.GameplayClockContainer.ChildrenOfType<HotkeyExitOverlay>().First().Action?.Invoke());
exitViaQuickExitAction();
confirmExited();
}
@ -261,7 +284,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestQuickExitFromGameplay()
{
AddStep("quick exit", () => Player.GameplayClockContainer.ChildrenOfType<HotkeyExitOverlay>().First().Action?.Invoke());
exitViaQuickExitAction();
confirmExited();
}
@ -327,7 +350,7 @@ namespace osu.Game.Tests.Visual.Gameplay
private void pauseAndConfirm()
{
pauseFromUserExitKey();
pauseViaBackAction();
confirmPaused();
}
@ -374,7 +397,17 @@ namespace osu.Game.Tests.Visual.Gameplay
}
private void restart() => AddStep("restart", () => Player.Restart());
private void pauseFromUserExitKey() => AddStep("user pause", () => Player.ExitViaPause());
private void pauseViaBackAction() => AddStep("press escape", () => InputManager.Key(Key.Escape));
private void pauseViaPauseGameplayAction() => AddStep("press middle mouse", () => InputManager.Click(MouseButton.Middle));
private void exitViaQuickExitAction() => AddStep("press ctrl-tilde", () =>
{
InputManager.PressKey(Key.ControlLeft);
InputManager.PressKey(Key.Tilde);
InputManager.ReleaseKey(Key.Tilde);
InputManager.ReleaseKey(Key.ControlLeft);
});
private void resume() => AddStep("resume", () => Player.Resume());
private void confirmPauseOverlayShown(bool isShown) =>
@ -405,10 +438,6 @@ namespace osu.Game.Tests.Visual.Gameplay
public bool PauseOverlayVisible => PauseOverlay.State.Value == Visibility.Visible;
public void ExitViaPause() => PerformExit(true);
public void ExitViaQuickExit() => PerformExit(false);
public override void OnEntering(ScreenTransitionEvent e)
{
base.OnEntering(e);

View File

@ -34,6 +34,24 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
public void TestSingleItemExpiredAfterGameplay()
{
RunGameplay();
AddUntilStep("playlist has only one item", () => MultiplayerClient.ClientAPIRoom?.Playlist.Count == 1);
AddUntilStep("playlist item is expired", () => MultiplayerClient.ClientAPIRoom?.Playlist[0].Expired == true);
AddUntilStep("last item selected", () => MultiplayerClient.ClientRoom?.Settings.PlaylistItemId == MultiplayerClient.ClientAPIRoom?.Playlist[0].ID);
}
[Test]
[FlakyTest]
/*
* TearDown : System.TimeoutException : "wait for ongoing operation to complete" timed out
* --TearDown
* at osu.Framework.Testing.Drawables.Steps.UntilStepButton.<>c__DisplayClass11_0.<.ctor>b__0()
* at osu.Framework.Testing.Drawables.Steps.StepButton.PerformStep(Boolean userTriggered)
* at osu.Framework.Testing.TestScene.runNextStep(Action onCompletion, Action`1 onError, Func`2 stopCondition)
*/
public void TestItemAddedToTheEndOfQueue()
{
addItem(() => OtherBeatmap);
@ -46,16 +64,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
public void TestSingleItemExpiredAfterGameplay()
{
RunGameplay();
AddUntilStep("playlist has only one item", () => MultiplayerClient.ClientAPIRoom?.Playlist.Count == 1);
AddUntilStep("playlist item is expired", () => MultiplayerClient.ClientAPIRoom?.Playlist[0].Expired == true);
AddUntilStep("last item selected", () => MultiplayerClient.ClientRoom?.Settings.PlaylistItemId == MultiplayerClient.ClientAPIRoom?.Playlist[0].ID);
}
[Test]
[FlakyTest] // See above
public void TestNextItemSelectedAfterGameplayFinish()
{
addItem(() => OtherBeatmap);
@ -73,6 +82,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest] // See above
public void TestItemsNotClearedWhenSwitchToHostOnlyMode()
{
addItem(() => OtherBeatmap);
@ -88,6 +98,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest] // See above
public void TestCorrectItemSelectedAfterNewItemAdded()
{
addItem(() => OtherBeatmap);
@ -95,6 +106,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest] // See above
public void TestCorrectRulesetSelectedAfterNewItemAdded()
{
addItem(() => OtherBeatmap, new CatchRuleset().RulesetInfo);
@ -112,6 +124,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest] // See above
public void TestCorrectModsSelectedAfterNewItemAdded()
{
addItem(() => OtherBeatmap, mods: new Mod[] { new OsuModDoubleTime() });

View File

@ -27,22 +27,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("first item selected", () => MultiplayerClient.ClientRoom?.Settings.PlaylistItemId == MultiplayerClient.ClientAPIRoom?.Playlist[0].ID);
}
[Test]
public void TestItemStillSelectedAfterChangeToSameBeatmap()
{
selectNewItem(() => InitialBeatmap);
AddUntilStep("playlist item still selected", () => MultiplayerClient.ClientRoom?.Settings.PlaylistItemId == MultiplayerClient.ClientAPIRoom?.Playlist[0].ID);
}
[Test]
public void TestItemStillSelectedAfterChangeToOtherBeatmap()
{
selectNewItem(() => OtherBeatmap);
AddUntilStep("playlist item still selected", () => MultiplayerClient.ClientRoom?.Settings.PlaylistItemId == MultiplayerClient.ClientAPIRoom?.Playlist[0].ID);
}
[Test]
public void TestNewItemCreatedAfterGameplayFinished()
{
@ -54,20 +38,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("second playlist item selected", () => MultiplayerClient.ClientRoom?.Settings.PlaylistItemId == MultiplayerClient.ClientAPIRoom?.Playlist[1].ID);
}
[Test]
public void TestOnlyLastItemChangedAfterGameplayFinished()
{
RunGameplay();
IBeatmapInfo firstBeatmap = null;
AddStep("get first playlist item beatmap", () => firstBeatmap = MultiplayerClient.ServerAPIRoom?.Playlist[0].Beatmap);
selectNewItem(() => OtherBeatmap);
AddUntilStep("first playlist item hasn't changed", () => MultiplayerClient.ServerAPIRoom?.Playlist[0].Beatmap == firstBeatmap);
AddUntilStep("second playlist item changed", () => MultiplayerClient.ClientAPIRoom?.Playlist[1].Beatmap != firstBeatmap);
}
[Test]
public void TestSettingsUpdatedWhenChangingQueueMode()
{
@ -80,6 +50,47 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest]
/*
* TearDown : System.TimeoutException : "wait for ongoing operation to complete" timed out
* --TearDown
* at osu.Framework.Testing.Drawables.Steps.UntilStepButton.<>c__DisplayClass11_0.<.ctor>b__0()
* at osu.Framework.Testing.Drawables.Steps.StepButton.PerformStep(Boolean userTriggered)
* at osu.Framework.Testing.TestScene.runNextStep(Action onCompletion, Action`1 onError, Func`2 stopCondition)
*/
public void TestItemStillSelectedAfterChangeToSameBeatmap()
{
selectNewItem(() => InitialBeatmap);
AddUntilStep("playlist item still selected", () => MultiplayerClient.ClientRoom?.Settings.PlaylistItemId == MultiplayerClient.ClientAPIRoom?.Playlist[0].ID);
}
[Test]
[FlakyTest] // See above
public void TestItemStillSelectedAfterChangeToOtherBeatmap()
{
selectNewItem(() => OtherBeatmap);
AddUntilStep("playlist item still selected", () => MultiplayerClient.ClientRoom?.Settings.PlaylistItemId == MultiplayerClient.ClientAPIRoom?.Playlist[0].ID);
}
[Test]
[FlakyTest] // See above
public void TestOnlyLastItemChangedAfterGameplayFinished()
{
RunGameplay();
IBeatmapInfo firstBeatmap = null;
AddStep("get first playlist item beatmap", () => firstBeatmap = MultiplayerClient.ServerAPIRoom?.Playlist[0].Beatmap);
selectNewItem(() => OtherBeatmap);
AddUntilStep("first playlist item hasn't changed", () => MultiplayerClient.ServerAPIRoom?.Playlist[0].Beatmap == firstBeatmap);
AddUntilStep("second playlist item changed", () => MultiplayerClient.ClientAPIRoom?.Playlist[1].Beatmap != firstBeatmap);
}
[Test]
[FlakyTest] // See above
public void TestAddItemsAsHost()
{
addItem(() => OtherBeatmap);

View File

@ -377,6 +377,17 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest]
/*
* On a slight investigation, this is occurring due to the ready button
* not receiving the click input generated by the manual input manager.
*
* TearDown : System.TimeoutException : "wait for ready button to be enabled" timed out
* --TearDown
* at osu.Framework.Testing.Drawables.Steps.UntilStepButton.<>c__DisplayClass11_0.<.ctor>b__0()
* at osu.Framework.Testing.Drawables.Steps.StepButton.PerformStep(Boolean userTriggered)
* at osu.Framework.Testing.TestScene.runNextStep(Action onCompletion, Action`1 onError, Func`2 stopCondition)
*/
public void TestUserSetToIdleWhenBeatmapDeleted()
{
createRoom(() => new Room
@ -398,6 +409,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest] // See above
public void TestPlayStartsWithCorrectBeatmapWhileAtSongSelect()
{
PlaylistItem? item = null;
@ -438,6 +450,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest] // See above
public void TestPlayStartsWithCorrectRulesetWhileAtSongSelect()
{
PlaylistItem? item = null;
@ -478,6 +491,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest] // See above
public void TestPlayStartsWithCorrectModsWhileAtSongSelect()
{
PlaylistItem? item = null;
@ -651,6 +665,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest] // See above
public void TestGameplayFlow()
{
createRoom(() => new Room
@ -678,6 +693,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest] // See above
public void TestGameplayExitFlow()
{
Bindable<double>? holdDelay = null;
@ -715,6 +731,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest] // See above
public void TestGameplayDoesntStartWithNonLoadedUser()
{
createRoom(() => new Room
@ -796,6 +813,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest] // See above
public void TestSpectatingStateResetOnBackButtonDuringGameplay()
{
createRoom(() => new Room
@ -831,6 +849,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest] // See above
public void TestSpectatingStateNotResetOnBackButtonOutsideOfGameplay()
{
createRoom(() => new Room
@ -869,6 +888,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest] // See above
public void TestItemAddedByOtherUserDuringGameplay()
{
createRoom(() => new Room
@ -899,6 +919,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
[FlakyTest] // See above
public void TestItemAddedAndDeletedByOtherUserDuringGameplay()
{
createRoom(() => new Room

View File

@ -219,7 +219,7 @@ namespace osu.Game.Tests.Visual.Navigation
AddStep("Click gameplay scene button", () =>
{
InputManager.MoveMouseTo(skinEditor.ChildrenOfType<SkinEditorSceneLibrary.SceneButton>().First(b => b.Text == "Gameplay"));
InputManager.MoveMouseTo(skinEditor.ChildrenOfType<SkinEditorSceneLibrary.SceneButton>().First(b => b.Text.ToString() == "Gameplay"));
InputManager.Click(MouseButton.Left);
});

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics.Containers;
@ -50,7 +48,7 @@ namespace osu.Game.Tests.Visual.Navigation
public void TestBeatmapLink()
{
AddUntilStep("Beatmap overlay displayed", () => Game.ChildrenOfType<BeatmapSetOverlay>().FirstOrDefault()?.State.Value == Visibility.Visible);
AddUntilStep("Beatmap overlay showing content", () => Game.ChildrenOfType<BeatmapPicker>().FirstOrDefault()?.Beatmap.Value.OnlineID == requested_beatmap_id);
AddUntilStep("Beatmap overlay showing content", () => Game.ChildrenOfType<BeatmapPicker>().FirstOrDefault()?.Beatmap.Value?.OnlineID == requested_beatmap_id);
}
}
}

View File

@ -136,14 +136,12 @@ namespace osu.Game.Beatmaps
/// <param name="rulesetInfo">The ruleset with which the new difficulty should be created.</param>
public virtual WorkingBeatmap CreateNewDifficulty(BeatmapSetInfo targetBeatmapSet, WorkingBeatmap referenceWorkingBeatmap, RulesetInfo rulesetInfo)
{
var playableBeatmap = referenceWorkingBeatmap.GetPlayableBeatmap(rulesetInfo);
var newBeatmapInfo = new BeatmapInfo(rulesetInfo, new BeatmapDifficulty(), playableBeatmap.Metadata.DeepClone())
var newBeatmapInfo = new BeatmapInfo(rulesetInfo, new BeatmapDifficulty(), referenceWorkingBeatmap.Metadata.DeepClone())
{
DifficultyName = NamingUtils.GetNextBestName(targetBeatmapSet.Beatmaps.Select(b => b.DifficultyName), "New Difficulty")
};
var newBeatmap = new Beatmap { BeatmapInfo = newBeatmapInfo };
foreach (var timingPoint in playableBeatmap.ControlPointInfo.TimingPoints)
foreach (var timingPoint in referenceWorkingBeatmap.Beatmap.ControlPointInfo.TimingPoints)
newBeatmap.ControlPointInfo.Add(timingPoint.Time, timingPoint.DeepClone());
return addDifficultyToSet(targetBeatmapSet, newBeatmap, referenceWorkingBeatmap.Skin);

View File

@ -183,9 +183,15 @@ namespace osu.Game.Beatmaps.ControlPoints
private static double getClosestSnappedTime(TimingControlPoint timingPoint, double time, int beatDivisor)
{
double beatLength = timingPoint.BeatLength / beatDivisor;
int beatLengths = (int)Math.Round((time - timingPoint.Time) / beatLength, MidpointRounding.AwayFromZero);
double beats = (Math.Max(time, 0) - timingPoint.Time) / beatLength;
return timingPoint.Time + beatLengths * beatLength;
int roundedBeats = (int)Math.Round(beats, MidpointRounding.AwayFromZero);
double snappedTime = timingPoint.Time + roundedBeats * beatLength;
if (snappedTime >= 0)
return snappedTime;
return snappedTime + beatLength;
}
/// <summary>

View File

@ -5,6 +5,7 @@
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
@ -14,6 +15,7 @@ using osu.Framework.Input.Events;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osuTK;
using osuTK.Input;
namespace osu.Game.Graphics.UserInterfaceV2
{
@ -58,6 +60,14 @@ namespace osu.Game.Graphics.UserInterfaceV2
this.FadeOut(fade_duration, Easing.OutQuint);
}
protected override bool OnKeyDown(KeyDownEvent e)
{
if (e.Key == Key.Escape)
return false; // disable the framework-level handling of escape key for conformity (we use GlobalAction.Back).
return base.OnKeyDown(e);
}
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (e.Repeat)
@ -68,7 +78,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
if (e.Action == GlobalAction.Back)
{
Hide();
this.HidePopover();
return true;
}

View File

@ -159,6 +159,11 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString CapsLockIsActive => new TranslatableString(getKey(@"caps_lock_is_active"), @"caps lock is active");
/// <summary>
/// "Revert to default"
/// </summary>
public static LocalisableString RevertToDefault => new TranslatableString(getKey(@"revert_to_default"), @"Revert to default");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -155,9 +155,9 @@ namespace osu.Game.Localisation
public static LocalisableString ToggleProfile => new TranslatableString(getKey(@"toggle_profile"), @"Toggle profile");
/// <summary>
/// "Pause gameplay"
/// "Pause / resume gameplay"
/// </summary>
public static LocalisableString PauseGameplay => new TranslatableString(getKey(@"pause_gameplay"), @"Pause gameplay");
public static LocalisableString PauseGameplay => new TranslatableString(getKey(@"pause_gameplay"), @"Pause / resume gameplay");
/// <summary>
/// "Setup mode"

View File

@ -0,0 +1,44 @@
// 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.Localisation;
namespace osu.Game.Localisation
{
public static class SkinEditorStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.SkinEditor";
/// <summary>
/// "Skin editor"
/// </summary>
public static LocalisableString SkinEditor => new TranslatableString(getKey(@"skin_editor"), @"Skin editor");
/// <summary>
/// "Components"
/// </summary>
public static LocalisableString Components => new TranslatableString(getKey(@"components"), @"Components");
/// <summary>
/// "Scene library"
/// </summary>
public static LocalisableString SceneLibrary => new TranslatableString(getKey(@"scene_library"), @"Scene library");
/// <summary>
/// "Song Select"
/// </summary>
public static LocalisableString SongSelect => new TranslatableString(getKey(@"song_select"), @"Song Select");
/// <summary>
/// "Gameplay"
/// </summary>
public static LocalisableString Gameplay => new TranslatableString(getKey(@"gameplay"), @"Gameplay");
/// <summary>
/// "Settings ({0})"
/// </summary>
public static LocalisableString Settings(string arg0) => new TranslatableString(getKey(@"settings"), @"Settings ({0})", arg0);
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -19,6 +19,21 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString Connecting => new TranslatableString(getKey(@"connecting"), @"Connecting...");
/// <summary>
/// "home"
/// </summary>
public static LocalisableString HomeHeaderTitle => new TranslatableString(getKey(@"home_header_title"), @"home");
/// <summary>
/// "return to the main menu"
/// </summary>
public static LocalisableString HomeHeaderDescription => new TranslatableString(getKey(@"home_header_description"), @"return to the main menu");
/// <summary>
/// "play some {0}"
/// </summary>
public static LocalisableString PlaySomeRuleset(string arg0) => new TranslatableString(getKey(@"play_some_ruleset"), @"play some {0}", arg0);
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -63,6 +63,9 @@ namespace osu.Game.Online.API.Requests.Responses
set => Length = TimeSpan.FromSeconds(value).TotalMilliseconds;
}
[JsonProperty(@"convert")]
public bool Convert { get; set; }
[JsonProperty(@"count_circles")]
public int CircleCount { get; set; }

View File

@ -125,6 +125,9 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"beatmaps")]
public APIBeatmap[] Beatmaps { get; set; } = Array.Empty<APIBeatmap>();
[JsonProperty(@"converts")]
public APIBeatmap[]? Converts { get; set; }
private BeatmapMetadata metadata => new BeatmapMetadata
{
Title = Title,

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System;
using System.Linq;
using osu.Framework;
@ -38,10 +36,10 @@ namespace osu.Game.Overlays.BeatmapSet
public readonly DifficultiesContainer Difficulties;
public readonly Bindable<APIBeatmap> Beatmap = new Bindable<APIBeatmap>();
private APIBeatmapSet beatmapSet;
public readonly Bindable<APIBeatmap?> Beatmap = new Bindable<APIBeatmap?>();
private APIBeatmapSet? beatmapSet;
public APIBeatmapSet BeatmapSet
public APIBeatmapSet? BeatmapSet
{
get => beatmapSet;
set
@ -142,7 +140,7 @@ namespace osu.Game.Overlays.BeatmapSet
}
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; }
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
@ -168,10 +166,11 @@ namespace osu.Game.Overlays.BeatmapSet
if (BeatmapSet != null)
{
Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps
Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps.Concat(BeatmapSet.Converts ?? Array.Empty<APIBeatmap>())
.Where(b => b.Ruleset.MatchesOnlineID(ruleset.Value))
.OrderBy(b => b.StarRating)
.Select(b => new DifficultySelectorButton(b)
.OrderBy(b => !b.Convert)
.ThenBy(b => b.StarRating)
.Select(b => new DifficultySelectorButton(b, b.Convert ? new RulesetInfo { OnlineID = 0 } : null)
{
State = DifficultySelectorState.NotSelected,
OnHovered = beatmap =>
@ -199,9 +198,9 @@ namespace osu.Game.Overlays.BeatmapSet
updateDifficultyButtons();
}
private void showBeatmap(IBeatmapInfo beatmapInfo)
private void showBeatmap(IBeatmapInfo? beatmapInfo)
{
version.Text = beatmapInfo?.DifficultyName;
version.Text = beatmapInfo?.DifficultyName ?? string.Empty;
}
private void updateDifficultyButtons()
@ -211,7 +210,7 @@ namespace osu.Game.Overlays.BeatmapSet
public partial class DifficultiesContainer : FillFlowContainer<DifficultySelectorButton>
{
public Action OnLostHover;
public Action? OnLostHover;
protected override void OnHoverLost(HoverLostEvent e)
{
@ -232,9 +231,9 @@ namespace osu.Game.Overlays.BeatmapSet
public readonly APIBeatmap Beatmap;
public Action<APIBeatmap> OnHovered;
public Action<APIBeatmap> OnClicked;
public event Action<DifficultySelectorState> StateChanged;
public Action<APIBeatmap>? OnHovered;
public Action<APIBeatmap>? OnClicked;
public event Action<DifficultySelectorState>? StateChanged;
private DifficultySelectorState state;
@ -255,7 +254,7 @@ namespace osu.Game.Overlays.BeatmapSet
}
}
public DifficultySelectorButton(APIBeatmap beatmapInfo)
public DifficultySelectorButton(APIBeatmap beatmapInfo, IRulesetInfo? ruleset)
{
Beatmap = beatmapInfo;
Size = new Vector2(size);
@ -274,7 +273,7 @@ namespace osu.Game.Overlays.BeatmapSet
Alpha = 0.5f
}
},
icon = new DifficultyIcon(beatmapInfo)
icon = new DifficultyIcon(beatmapInfo, ruleset)
{
ShowTooltip = false,
Current = { Value = new StarDifficulty(beatmapInfo.StarRating, 0) },

View File

@ -68,11 +68,12 @@ namespace osu.Game.Overlays.BeatmapSet
BeatmapSet.BindValueChanged(setInfo =>
{
int beatmapsCount = setInfo.NewValue?.Beatmaps.Count(b => b.Ruleset.MatchesOnlineID(Value)) ?? 0;
int osuBeatmaps = setInfo.NewValue?.Beatmaps.Count(b => b.Ruleset.OnlineID == 0) ?? 0;
count.Text = beatmapsCount.ToString();
countContainer.FadeTo(beatmapsCount > 0 ? 1 : 0);
Enabled.Value = beatmapsCount > 0;
Enabled.Value = beatmapsCount > 0 || osuBeatmaps > 0;
}, true);
}
}

View File

@ -6,6 +6,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Profile.Header.Components;
using osuTK;
@ -15,6 +16,8 @@ namespace osu.Game.Overlays.Profile.Header
{
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
private LevelBadge levelBadge = null!;
public CentreHeaderContainer()
{
Height = 60;
@ -62,12 +65,11 @@ namespace osu.Game.Overlays.Profile.Header
Margin = new MarginPadding { Right = UserProfileOverlay.CONTENT_X_MARGIN },
Children = new Drawable[]
{
new LevelBadge
levelBadge = new LevelBadge
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Size = new Vector2(40),
User = { BindTarget = User }
Size = new Vector2(40)
},
new Container
{
@ -86,5 +88,17 @@ namespace osu.Game.Overlays.Profile.Header
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
User.BindValueChanged(user => updateDisplay(user.NewValue?.User), true);
}
private void updateDisplay(APIUser? user)
{
levelBadge.LevelInfo.Value = user?.Statistics?.Level;
}
}
}

View File

@ -11,14 +11,14 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Users;
namespace osu.Game.Overlays.Profile.Header.Components
{
public partial class LevelBadge : CompositeDrawable, IHasTooltip
{
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
public readonly Bindable<UserStatistics.LevelInfo?> LevelInfo = new Bindable<UserStatistics.LevelInfo?>();
public LocalisableString TooltipText { get; private set; }
@ -47,13 +47,18 @@ namespace osu.Game.Overlays.Profile.Header.Components
Font = OsuFont.GetFont(size: 20)
}
};
User.BindValueChanged(user => updateLevel(user.NewValue?.User));
}
private void updateLevel(APIUser? user)
protected override void LoadComplete()
{
string level = user?.Statistics?.Level.Current.ToString() ?? "0";
base.LoadComplete();
LevelInfo.BindValueChanged(level => updateLevel(level.NewValue), true);
}
private void updateLevel(UserStatistics.LevelInfo? levelInfo)
{
string level = levelInfo?.Current.ToString() ?? "0";
levelText.Text = level;
TooltipText = UsersStrings.ShowStatsLevel(level);
}

View File

@ -6,6 +6,7 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
@ -17,6 +18,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osuTK;
using osu.Game.Localisation;
namespace osu.Game.Overlays
{
@ -96,7 +98,7 @@ namespace osu.Game.Overlays
FinishTransforms(true);
}
public override LocalisableString TooltipText => "revert to default";
public override LocalisableString TooltipText => CommonStrings.RevertToDefault.ToLower();
protected override bool OnHover(HoverEvent e)
{

View File

@ -135,12 +135,14 @@ namespace osu.Game.Overlays
protected override bool OnHover(HoverEvent e)
{
updateFadeState();
updateExpandedState(true);
return false;
}
protected override void OnHoverLost(HoverLostEvent e)
{
updateFadeState();
updateExpandedState(true);
base.OnHoverLost(e);
}
@ -168,7 +170,7 @@ namespace osu.Game.Overlays
// potentially continuing to get processed while content has changed to autosize.
content.ClearTransforms();
if (Expanded.Value)
if (Expanded.Value || IsHovered)
{
content.AutoSizeAxes = Axes.Y;
content.AutoSizeDuration = animate ? transition_duration : 0;

View File

@ -5,6 +5,7 @@
using osu.Framework.Allocation;
using osu.Game.Input.Bindings;
using osu.Game.Localisation;
namespace osu.Game.Overlays.Toolbar
{
@ -19,8 +20,8 @@ namespace osu.Game.Overlays.Toolbar
[BackgroundDependencyLoader]
private void load()
{
TooltipMain = "home";
TooltipSub = "return to the main menu";
TooltipMain = ToolbarStrings.HomeHeaderTitle;
TooltipSub = ToolbarStrings.HomeHeaderDescription;
SetIcon("Icons/Hexacons/home");
}
}

View File

@ -3,12 +3,13 @@
#nullable disable
using osu.Framework.Graphics;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Game.Localisation;
using osu.Game.Rulesets;
using osuTK.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
namespace osu.Game.Overlays.Toolbar
{
@ -29,7 +30,7 @@ namespace osu.Game.Overlays.Toolbar
var rInstance = value.CreateInstance();
ruleset.TooltipMain = rInstance.Description;
ruleset.TooltipSub = $"play some {rInstance.Description}";
ruleset.TooltipSub = ToolbarStrings.PlaySomeRuleset(rInstance.Description);
ruleset.SetIcon(rInstance.CreateIcon());
}

View File

@ -173,7 +173,7 @@ namespace osu.Game.Screens.OnlinePlay
IsValidMod = IsValidMod
};
protected override IEnumerable<(FooterButton, OverlayContainer)> CreateFooterButtons()
protected override IEnumerable<(FooterButton, OverlayContainer?)> CreateFooterButtons()
{
var buttons = base.CreateFooterButtons().ToList();
buttons.Insert(buttons.FindIndex(b => b.Item1 is FooterButtonMods) + 1, (new FooterButtonFreeMods { Current = FreeMods }, freeModSelectOverlay));

View File

@ -44,7 +44,7 @@ namespace osu.Game.Screens.Play
/// <summary>
/// Action that is invoked when <see cref="GlobalAction.Back"/> is triggered.
/// </summary>
protected virtual Action BackAction => () => InternalButtons.Children.LastOrDefault()?.TriggerClick();
protected virtual Action BackAction => () => InternalButtons.LastOrDefault()?.TriggerClick();
/// <summary>
/// Action that is invoked when <see cref="GlobalAction.Select"/> is triggered.
@ -189,7 +189,7 @@ namespace osu.Game.Screens.Play
InternalButtons.Add(button);
}
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
public virtual bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
{

View File

@ -41,7 +41,7 @@ namespace osu.Game.Screens.Play.HUD
{
//CollectionSettings = new CollectionSettings(),
//DiscussionSettings = new DiscussionSettings(),
PlaybackSettings = new PlaybackSettings(),
PlaybackSettings = new PlaybackSettings { Expanded = { Value = false } },
VisualSettings = new VisualSettings { Expanded = { Value = false } }
}
};

View File

@ -8,8 +8,10 @@ using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Audio;
using osu.Game.Graphics;
using osu.Game.Input.Bindings;
using osu.Game.Skinning;
using osuTK.Graphics;
@ -26,7 +28,7 @@ namespace osu.Game.Screens.Play
private SkinnableSound pauseLoop;
protected override Action BackAction => () => InternalButtons.Children.First().TriggerClick();
protected override Action BackAction => () => InternalButtons.First().TriggerClick();
[BackgroundDependencyLoader]
private void load(OsuColour colours)
@ -56,5 +58,17 @@ namespace osu.Game.Screens.Play
pauseLoop.VolumeTo(0, TRANSITION_DURATION, Easing.OutQuad).Finally(_ => pauseLoop.Stop());
}
public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
{
case GlobalAction.PauseGameplay:
InternalButtons.First().TriggerClick();
return true;
}
return base.OnPressed(e);
}
}
}

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using osu.Framework.Input.Events;
using osu.Game.Overlays;

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
@ -36,7 +34,7 @@ using osu.Framework.Input.Bindings;
using osu.Game.Collections;
using osu.Game.Graphics.UserInterface;
using System.Diagnostics;
using JetBrains.Annotations;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Game.Screens.Play;
using osu.Game.Skinning;
@ -49,7 +47,7 @@ namespace osu.Game.Screens.Select
protected const float BACKGROUND_BLUR = 20;
private const float left_area_padding = 20;
public FilterControl FilterControl { get; private set; }
public FilterControl FilterControl { get; private set; } = null!;
/// <summary>
/// Whether this song select instance should take control of the global track,
@ -64,75 +62,71 @@ namespace osu.Game.Screens.Select
/// <summary>
/// Can be null if <see cref="ShowFooter"/> is false.
/// </summary>
protected BeatmapOptionsOverlay BeatmapOptions { get; private set; }
protected BeatmapOptionsOverlay BeatmapOptions { get; private set; } = null!;
/// <summary>
/// Can be null if <see cref="ShowFooter"/> is false.
/// </summary>
protected Footer Footer { get; private set; }
protected Footer? Footer { get; private set; }
/// <summary>
/// Contains any panel which is triggered by a footer button.
/// Helps keep them located beneath the footer itself.
/// </summary>
protected Container FooterPanels { get; private set; }
protected Container FooterPanels { get; private set; } = null!;
/// <summary>
/// Whether entering editor mode should be allowed.
/// </summary>
public virtual bool AllowEditing => true;
public bool BeatmapSetsLoaded => IsLoaded && Carousel?.BeatmapSetsLoaded == true;
public bool BeatmapSetsLoaded => IsLoaded && Carousel.BeatmapSetsLoaded;
[Resolved]
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; }
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; } = null!;
protected BeatmapCarousel Carousel { get; private set; }
protected BeatmapCarousel Carousel { get; private set; } = null!;
private ParallaxContainer wedgeBackground;
private ParallaxContainer wedgeBackground = null!;
protected Container LeftArea { get; private set; }
protected Container LeftArea { get; private set; } = null!;
private BeatmapInfoWedge beatmapInfoWedge;
[Resolved(canBeNull: true)]
private IDialogOverlay dialogOverlay { get; set; }
private BeatmapInfoWedge beatmapInfoWedge = null!;
[Resolved]
private BeatmapManager beatmaps { get; set; }
private IDialogOverlay? dialogOverlay { get; set; }
protected ModSelectOverlay ModSelect { get; private set; }
[Resolved]
private BeatmapManager beatmaps { get; set; } = null!;
protected Sample SampleConfirm { get; private set; }
protected ModSelectOverlay ModSelect { get; private set; } = null!;
private Sample sampleChangeDifficulty;
private Sample sampleChangeBeatmap;
protected Sample? SampleConfirm { get; private set; }
private Container carouselContainer;
private Sample sampleChangeDifficulty = null!;
private Sample sampleChangeBeatmap = null!;
protected BeatmapDetailArea BeatmapDetails { get; private set; }
private Container carouselContainer = null!;
private FooterButtonOptions beatmapOptionsButton;
protected BeatmapDetailArea BeatmapDetails { get; private set; } = null!;
private FooterButtonOptions beatmapOptionsButton = null!;
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
private double audioFeedbackLastPlaybackTime;
[CanBeNull]
private IDisposable modSelectOverlayRegistration;
private IDisposable? modSelectOverlayRegistration;
[Resolved]
private MusicController music { get; set; }
private MusicController music { get; set; } = null!;
[Resolved(CanBeNull = true)]
internal IOverlayManager OverlayManager { get; private set; }
[Resolved]
internal IOverlayManager? OverlayManager { get; private set; }
[BackgroundDependencyLoader(true)]
private void load(AudioManager audio, OsuColour colours, ManageCollectionsDialog manageCollectionsDialog, DifficultyRecommender recommender)
private void load(AudioManager audio, OsuColour colours, ManageCollectionsDialog? manageCollectionsDialog, DifficultyRecommender? recommender)
{
// initial value transfer is required for FilterControl (it uses our re-cached bindables in its async load for the initial filter).
transferRulesetValue();
LoadComponentAsync(Carousel = new BeatmapCarousel
{
AllowSelection = false, // delay any selection until our bindables are ready to make a good choice.
@ -146,6 +140,9 @@ namespace osu.Game.Screens.Select
GetRecommendedBeatmap = s => recommender?.GetRecommendedBeatmap(s),
}, c => carouselContainer.Child = c);
// initial value transfer is required for FilterControl (it uses our re-cached bindables in its async load for the initial filter).
transferRulesetValue();
AddRangeInternal(new Drawable[]
{
new ResetScrollContainer(() => Carousel.ScrollToSelected())
@ -273,7 +270,7 @@ namespace osu.Game.Screens.Select
BeatmapOptions = new BeatmapOptionsOverlay(),
}
},
Footer = new Footer(),
Footer = new Footer()
});
}
@ -318,7 +315,7 @@ namespace osu.Game.Screens.Select
/// Creates the buttons to be displayed in the footer.
/// </summary>
/// <returns>A set of <see cref="FooterButton"/> and an optional <see cref="OverlayContainer"/> which the button opens when pressed.</returns>
protected virtual IEnumerable<(FooterButton, OverlayContainer)> CreateFooterButtons() => new (FooterButton, OverlayContainer)[]
protected virtual IEnumerable<(FooterButton, OverlayContainer?)> CreateFooterButtons() => new (FooterButton, OverlayContainer?)[]
{
(new FooterButtonMods { Current = Mods }, ModSelect),
(new FooterButtonRandom
@ -339,7 +336,7 @@ namespace osu.Game.Screens.Select
Carousel.Filter(criteria, shouldDebounce);
}
private DependencyContainer dependencies;
private DependencyContainer dependencies = null!;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
@ -357,7 +354,7 @@ namespace osu.Game.Screens.Select
/// </summary>
protected abstract BeatmapDetailArea CreateBeatmapDetailArea();
public void Edit(BeatmapInfo beatmapInfo = null)
public void Edit(BeatmapInfo? beatmapInfo = null)
{
if (!AllowEditing)
throw new InvalidOperationException($"Attempted to edit when {nameof(AllowEditing)} is disabled");
@ -372,7 +369,7 @@ namespace osu.Game.Screens.Select
/// <param name="beatmapInfo">An optional beatmap to override the current carousel selection.</param>
/// <param name="ruleset">An optional ruleset to override the current carousel selection.</param>
/// <param name="customStartAction">An optional custom action to perform instead of <see cref="OnStart"/>.</param>
public void FinaliseSelection(BeatmapInfo beatmapInfo = null, RulesetInfo ruleset = null, Action customStartAction = null)
public void FinaliseSelection(BeatmapInfo? beatmapInfo = null, RulesetInfo? ruleset = null, Action? customStartAction = null)
{
// This is very important as we have not yet bound to screen-level bindables before the carousel load is completed.
if (!Carousel.BeatmapSetsLoaded)
@ -419,9 +416,9 @@ namespace osu.Game.Screens.Select
/// <returns>If a resultant action occurred that takes the user away from SongSelect.</returns>
protected abstract bool OnStart();
private ScheduledDelegate selectionChangedDebounce;
private ScheduledDelegate? selectionChangedDebounce;
private void updateCarouselSelection(ValueChangedEvent<WorkingBeatmap> e = null)
private void updateCarouselSelection(ValueChangedEvent<WorkingBeatmap>? e = null)
{
var beatmap = e?.NewValue ?? Beatmap.Value;
if (beatmap is DummyWorkingBeatmap || !this.IsCurrentScreen()) return;
@ -451,11 +448,11 @@ namespace osu.Game.Screens.Select
}
// We need to keep track of the last selected beatmap ignoring debounce to play the correct selection sounds.
private BeatmapInfo beatmapInfoPrevious;
private BeatmapInfo beatmapInfoNoDebounce;
private RulesetInfo rulesetNoDebounce;
private BeatmapInfo? beatmapInfoPrevious;
private BeatmapInfo? beatmapInfoNoDebounce;
private RulesetInfo? rulesetNoDebounce;
private void updateSelectedBeatmap(BeatmapInfo beatmapInfo)
private void updateSelectedBeatmap(BeatmapInfo? beatmapInfo)
{
if (beatmapInfo == null && beatmapInfoNoDebounce == null)
return;
@ -467,7 +464,7 @@ namespace osu.Game.Screens.Select
performUpdateSelected();
}
private void updateSelectedRuleset(RulesetInfo ruleset)
private void updateSelectedRuleset(RulesetInfo? ruleset)
{
if (ruleset == null && rulesetNoDebounce == null)
return;
@ -485,7 +482,7 @@ namespace osu.Game.Screens.Select
private void performUpdateSelected()
{
var beatmap = beatmapInfoNoDebounce;
var ruleset = rulesetNoDebounce;
RulesetInfo? ruleset = rulesetNoDebounce;
selectionChangedDebounce?.Cancel();
@ -694,6 +691,7 @@ namespace osu.Game.Screens.Select
isHandlingLooping = true;
ensureTrackLooping(Beatmap.Value, TrackChangeDirection.None);
music.TrackChanged += ensureTrackLooping;
}
@ -728,7 +726,7 @@ namespace osu.Game.Screens.Select
decoupledRuleset.UnbindAll();
if (music != null)
if (music.IsNotNull())
music.TrackChanged -= ensureTrackLooping;
modSelectOverlayRegistration?.Dispose();
@ -763,7 +761,7 @@ namespace osu.Game.Screens.Select
}
}
private readonly WeakReference<ITrack> lastTrack = new WeakReference<ITrack>(null);
private readonly WeakReference<ITrack?> lastTrack = new WeakReference<ITrack?>(null);
/// <summary>
/// Ensures some music is playing for the current track.
@ -864,18 +862,18 @@ namespace osu.Game.Screens.Select
// if we have a pending filter operation, we want to run it now.
// it could change selection (ie. if the ruleset has been changed).
Carousel?.FlushPendingFilterOperations();
Carousel.FlushPendingFilterOperations();
return true;
}
private void delete(BeatmapSetInfo beatmap)
private void delete(BeatmapSetInfo? beatmap)
{
if (beatmap == null) return;
dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap));
}
private void clearScores(BeatmapInfo beatmapInfo)
private void clearScores(BeatmapInfo? beatmapInfo)
{
if (beatmapInfo == null) return;
@ -950,7 +948,7 @@ namespace osu.Game.Screens.Select
private partial class ResetScrollContainer : Container
{
private readonly Action onHoverAction;
private readonly Action? onHoverAction;
public ResetScrollContainer(Action onHoverAction)
{

View File

@ -10,6 +10,7 @@ using osu.Framework.Logging;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Overlays;
using osu.Game.Screens.Edit.Components;
using osu.Game.Screens.Play.HUD;
@ -26,7 +27,7 @@ namespace osu.Game.Skinning.Editor
private FillFlowContainer fill = null!;
public SkinComponentToolbox(CompositeDrawable? target = null)
: base("Components")
: base(SkinEditorStrings.Components)
{
this.target = target;
}

View File

@ -109,7 +109,7 @@ namespace osu.Game.Skinning.Editor
{
new Container
{
Name = "Menu container",
Name = @"Menu container",
RelativeSizeAxes = Axes.X,
Depth = float.MinValue,
Height = MENU_HEIGHT,
@ -122,14 +122,14 @@ namespace osu.Game.Skinning.Editor
RelativeSizeAxes = Axes.Both,
Items = new[]
{
new MenuItem("File")
new MenuItem(CommonStrings.MenuBarFile)
{
Items = new[]
{
new EditorMenuItem("Save", MenuItemType.Standard, Save),
new EditorMenuItem("Revert to default", MenuItemType.Destructive, revert),
new EditorMenuItem(Resources.Localisation.Web.CommonStrings.ButtonsSave, MenuItemType.Standard, Save),
new EditorMenuItem(CommonStrings.RevertToDefault, MenuItemType.Destructive, revert),
new EditorMenuItemSpacer(),
new EditorMenuItem("Exit", MenuItemType.Standard, () => skinEditorOverlay?.Hide()),
new EditorMenuItem(CommonStrings.Exit, MenuItemType.Standard, () => skinEditorOverlay?.Hide()),
},
},
}
@ -234,7 +234,6 @@ namespace osu.Game.Skinning.Editor
// Immediately clear the previous blueprint container to ensure it doesn't try to interact with the old target.
content?.Clear();
Scheduler.AddOnce(loadBlueprintContainer);
Scheduler.AddOnce(populateSettings);
@ -253,7 +252,7 @@ namespace osu.Game.Skinning.Editor
{
headerText.Clear();
headerText.AddParagraph("Skin editor", cp => cp.Font = OsuFont.Default.With(size: 16));
headerText.AddParagraph(SkinEditorStrings.SkinEditor, cp => cp.Font = OsuFont.Default.With(size: 16));
headerText.NewParagraph();
headerText.AddText("Currently editing ", cp =>
{

View File

@ -16,6 +16,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Overlays;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
@ -66,7 +67,7 @@ namespace osu.Game.Skinning.Editor
{
new FillFlowContainer
{
Name = "Scene library",
Name = @"Scene library",
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Spacing = new Vector2(padding),
@ -76,14 +77,14 @@ namespace osu.Game.Skinning.Editor
{
new OsuSpriteText
{
Text = "Scene library",
Text = SkinEditorStrings.SceneLibrary,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Margin = new MarginPadding(10),
},
new SceneButton
{
Text = "Song Select",
Text = SkinEditorStrings.SongSelect,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Action = () => performer?.PerformFromScreen(screen =>
@ -96,7 +97,7 @@ namespace osu.Game.Skinning.Editor
},
new SceneButton
{
Text = "Gameplay",
Text = SkinEditorStrings.Gameplay,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Action = () => performer?.PerformFromScreen(screen =>

View File

@ -1,12 +1,11 @@
// 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.
#nullable disable
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Configuration;
using osu.Game.Localisation;
using osu.Game.Screens.Edit.Components;
using osuTK;
@ -17,7 +16,7 @@ namespace osu.Game.Skinning.Editor
protected override Container<Drawable> Content { get; }
public SkinSettingsToolbox(Drawable component)
: base($"Settings ({component.GetType().Name})")
: base(SkinEditorStrings.Settings(component.GetType().Name))
{
base.Content.Add(Content = new FillFlowContainer
{

View File

@ -50,17 +50,16 @@ namespace osu.Game.Tests.Visual
{
var cursorDisplay = new GlobalCursorDisplay { RelativeSizeAxes = Axes.Both };
cursorDisplay.Add(new OsuTooltipContainer(cursorDisplay.MenuCursor)
cursorDisplay.Add(content = new OsuTooltipContainer(cursorDisplay.MenuCursor)
{
RelativeSizeAxes = Axes.Both,
Child = mainContent
});
mainContent = cursorDisplay;
mainContent.Add(cursorDisplay);
}
if (CreateNestedActionContainer)
mainContent = new GlobalActionContainer(null).WithChild(mainContent);
mainContent.Add(new GlobalActionContainer(null));
base.Content.AddRange(new Drawable[]
{