mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 15:57:24 +08:00
Merge branch 'master' into features/minimum-and-maximum-rank-display
This commit is contained in:
commit
2e1133bbb4
2
.github/workflows/diffcalc.yml
vendored
2
.github/workflows/diffcalc.yml
vendored
@ -111,7 +111,7 @@ jobs:
|
||||
steps:
|
||||
- name: Check permissions
|
||||
run: |
|
||||
ALLOWED_USERS=(smoogipoo peppy bdach)
|
||||
ALLOWED_USERS=(smoogipoo peppy bdach frenzibyte)
|
||||
for i in "${ALLOWED_USERS[@]}"; do
|
||||
if [[ "${{ github.actor }}" == "$i" ]]; then
|
||||
exit 0
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -266,6 +266,7 @@ __pycache__/
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
.idea/*/.idea/projectSettingsUpdater.xml
|
||||
.idea/*/.idea/encodings.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
|
||||
</project>
|
@ -7,7 +7,6 @@ T:SixLabors.ImageSharp.IDeepCloneable`1;Use osu.Game.Utils.IDeepCloneable<T> ins
|
||||
M:osu.Framework.Graphics.Sprites.SpriteText.#ctor;Use OsuSpriteText.
|
||||
M:osu.Framework.Bindables.IBindableList`1.GetBoundCopy();Fails on iOS. Use manual ctor + BindTo instead. (see https://github.com/mono/mono/issues/19900)
|
||||
T:NuGet.Packaging.CollectionExtensions;Don't use internal extension methods.
|
||||
M:System.Enum.HasFlag(System.Enum);Use osu.Framework.Extensions.EnumExtensions.HasFlagFast<T>() instead.
|
||||
M:Realms.IRealmCollection`1.SubscribeForNotifications`1(Realms.NotificationCallbackDelegate{``0});Use osu.Game.Database.RealmObjectExtensions.QueryAsyncWithNotifications(IRealmCollection<T>,NotificationCallbackDelegate<T>) instead.
|
||||
M:System.Guid.#ctor;Probably meaning to use Guid.NewGuid() instead. If actually wanting empty, use Guid.Empty.
|
||||
M:Realms.CollectionExtensions.SubscribeForNotifications`1(System.Linq.IQueryable{``0},Realms.NotificationCallbackDelegate{``0});Use osu.Game.Database.RealmObjectExtensions.QueryAsyncWithNotifications(IQueryable<T>,NotificationCallbackDelegate<T>) instead.
|
||||
|
@ -10,7 +10,7 @@
|
||||
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2024.627.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2024.702.0" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Fody does not handle Android build well, and warns when unchanged.
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Security.Principal;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
@ -21,48 +20,14 @@ namespace osu.Desktop.Security
|
||||
[Resolved]
|
||||
private INotificationOverlay notifications { get; set; } = null!;
|
||||
|
||||
private bool elevated;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
elevated = checkElevated();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
if (elevated)
|
||||
if (Environment.IsPrivilegedProcess)
|
||||
notifications.Post(new ElevatedPrivilegesNotification());
|
||||
}
|
||||
|
||||
private bool checkElevated()
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (RuntimeInfo.OS)
|
||||
{
|
||||
case RuntimeInfo.Platform.Windows:
|
||||
if (!OperatingSystem.IsWindows()) return false;
|
||||
|
||||
var windowsIdentity = WindowsIdentity.GetCurrent();
|
||||
var windowsPrincipal = new WindowsPrincipal(windowsIdentity);
|
||||
|
||||
return windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
|
||||
case RuntimeInfo.Platform.macOS:
|
||||
case RuntimeInfo.Platform.Linux:
|
||||
return Mono.Unix.Native.Syscall.geteuid() == 0;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private partial class ElevatedPrivilegesNotification : SimpleNotification
|
||||
{
|
||||
public override bool IsImportant => true;
|
||||
|
@ -24,7 +24,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="Clowd.Squirrel" Version="2.11.1" />
|
||||
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
|
||||
<PackageReference Include="System.IO.Packaging" Version="8.0.0" />
|
||||
<PackageReference Include="DiscordRichPresence" Version="1.2.1.24" />
|
||||
</ItemGroup>
|
||||
|
@ -0,0 +1,36 @@
|
||||
// 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.Testing;
|
||||
using osu.Game.Rulesets.Catch.Beatmaps;
|
||||
using osu.Game.Rulesets.Catch.UI;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Tests
|
||||
{
|
||||
public partial class TestSceneCatchReplayHandling : OsuManualInputManagerTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestReplayDetach()
|
||||
{
|
||||
DrawableCatchRuleset drawableRuleset = null!;
|
||||
float catcherPosition = 0;
|
||||
|
||||
AddStep("create drawable ruleset", () => Child = drawableRuleset = new DrawableCatchRuleset(new CatchRuleset(), new CatchBeatmap(), []));
|
||||
AddStep("attach replay", () => drawableRuleset.SetReplayScore(new Score()));
|
||||
AddStep("store catcher position", () => catcherPosition = drawableRuleset.ChildrenOfType<Catcher>().Single().X);
|
||||
AddStep("hold down left", () => InputManager.PressKey(Key.Left));
|
||||
AddAssert("catcher didn't move", () => drawableRuleset.ChildrenOfType<Catcher>().Single().X, () => Is.EqualTo(catcherPosition));
|
||||
AddStep("release left", () => InputManager.ReleaseKey(Key.Left));
|
||||
|
||||
AddStep("detach replay", () => drawableRuleset.SetReplayScore(null));
|
||||
AddStep("hold down left", () => InputManager.PressKey(Key.Left));
|
||||
AddUntilStep("catcher moved", () => drawableRuleset.ChildrenOfType<Catcher>().Single().X, () => Is.Not.EqualTo(catcherPosition));
|
||||
AddStep("release left", () => InputManager.ReleaseKey(Key.Left));
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
@ -62,43 +61,43 @@ namespace osu.Game.Rulesets.Catch
|
||||
|
||||
public override IEnumerable<Mod> ConvertFromLegacyMods(LegacyMods mods)
|
||||
{
|
||||
if (mods.HasFlagFast(LegacyMods.Nightcore))
|
||||
if (mods.HasFlag(LegacyMods.Nightcore))
|
||||
yield return new CatchModNightcore();
|
||||
else if (mods.HasFlagFast(LegacyMods.DoubleTime))
|
||||
else if (mods.HasFlag(LegacyMods.DoubleTime))
|
||||
yield return new CatchModDoubleTime();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Perfect))
|
||||
if (mods.HasFlag(LegacyMods.Perfect))
|
||||
yield return new CatchModPerfect();
|
||||
else if (mods.HasFlagFast(LegacyMods.SuddenDeath))
|
||||
else if (mods.HasFlag(LegacyMods.SuddenDeath))
|
||||
yield return new CatchModSuddenDeath();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Cinema))
|
||||
if (mods.HasFlag(LegacyMods.Cinema))
|
||||
yield return new CatchModCinema();
|
||||
else if (mods.HasFlagFast(LegacyMods.Autoplay))
|
||||
else if (mods.HasFlag(LegacyMods.Autoplay))
|
||||
yield return new CatchModAutoplay();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Easy))
|
||||
if (mods.HasFlag(LegacyMods.Easy))
|
||||
yield return new CatchModEasy();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Flashlight))
|
||||
if (mods.HasFlag(LegacyMods.Flashlight))
|
||||
yield return new CatchModFlashlight();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.HalfTime))
|
||||
if (mods.HasFlag(LegacyMods.HalfTime))
|
||||
yield return new CatchModHalfTime();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.HardRock))
|
||||
if (mods.HasFlag(LegacyMods.HardRock))
|
||||
yield return new CatchModHardRock();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Hidden))
|
||||
if (mods.HasFlag(LegacyMods.Hidden))
|
||||
yield return new CatchModHidden();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.NoFail))
|
||||
if (mods.HasFlag(LegacyMods.NoFail))
|
||||
yield return new CatchModNoFail();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Relax))
|
||||
if (mods.HasFlag(LegacyMods.Relax))
|
||||
yield return new CatchModRelax();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.ScoreV2))
|
||||
if (mods.HasFlag(LegacyMods.ScoreV2))
|
||||
yield return new ModScoreV2();
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
@ -121,7 +120,7 @@ namespace osu.Game.Rulesets.Catch.Edit
|
||||
|
||||
result.ScreenSpacePosition.X = screenSpacePosition.X;
|
||||
|
||||
if (snapType.HasFlagFast(SnapType.RelativeGrids))
|
||||
if (snapType.HasFlag(SnapType.RelativeGrids))
|
||||
{
|
||||
if (distanceSnapGrid.IsPresent && distanceSnapGrid.GetSnappedPosition(result.ScreenSpacePosition) is SnapResult snapResult &&
|
||||
Vector2.Distance(snapResult.ScreenSpacePosition, result.ScreenSpacePosition) < distance_snap_radius)
|
||||
|
@ -1,13 +1,18 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Mania.Configuration;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Screens.Edit.Timing;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
{
|
||||
@ -30,5 +35,43 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
var config = (ManiaRulesetConfigManager)RulesetConfigs.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
|
||||
config.BindWith(ManiaRulesetSetting.ScrollDirection, direction);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestReloadOnBPMChange()
|
||||
{
|
||||
HitObjectComposer oldComposer = null!;
|
||||
|
||||
AddStep("store composer", () => oldComposer = this.ChildrenOfType<HitObjectComposer>().Single());
|
||||
AddUntilStep("composer stored", () => oldComposer, () => Is.Not.Null);
|
||||
AddStep("switch to timing tab", () => InputManager.Key(Key.F3));
|
||||
AddUntilStep("wait for loaded", () => this.ChildrenOfType<TimingAdjustButton>().ElementAtOrDefault(1), () => Is.Not.Null);
|
||||
AddStep("change timing point BPM", () =>
|
||||
{
|
||||
var bpmControl = this.ChildrenOfType<TimingAdjustButton>().ElementAt(1);
|
||||
InputManager.MoveMouseTo(bpmControl);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddStep("switch back to composer", () => InputManager.Key(Key.F1));
|
||||
AddUntilStep("composer reloaded", () =>
|
||||
{
|
||||
var composer = this.ChildrenOfType<HitObjectComposer>().SingleOrDefault();
|
||||
return composer != null && composer != oldComposer;
|
||||
});
|
||||
|
||||
AddStep("store composer", () => oldComposer = this.ChildrenOfType<HitObjectComposer>().Single());
|
||||
AddUntilStep("composer stored", () => oldComposer, () => Is.Not.Null);
|
||||
AddStep("undo", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ControlLeft);
|
||||
InputManager.Key(Key.Z);
|
||||
InputManager.ReleaseKey(Key.ControlLeft);
|
||||
});
|
||||
AddUntilStep("composer reloaded", () =>
|
||||
{
|
||||
var composer = this.ChildrenOfType<HitObjectComposer>().SingleOrDefault();
|
||||
return composer != null && composer != oldComposer;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Rulesets.Mania.Mods;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
@ -17,5 +19,22 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
|
||||
Mod = new ManiaModInvert(),
|
||||
PassCondition = () => Player.ScoreProcessor.JudgedHits >= 2
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestBreaksPreservedOnOriginalBeatmap()
|
||||
{
|
||||
var beatmap = CreateBeatmap(new ManiaRuleset().RulesetInfo);
|
||||
beatmap.Breaks.Clear();
|
||||
beatmap.Breaks.Add(new BreakPeriod(0, 1000));
|
||||
|
||||
var workingBeatmap = new FlatWorkingBeatmap(beatmap);
|
||||
|
||||
var playableWithInvert = workingBeatmap.GetPlayableBeatmap(new ManiaRuleset().RulesetInfo, new[] { new ManiaModInvert() });
|
||||
Assert.That(playableWithInvert.Breaks.Count, Is.Zero);
|
||||
|
||||
var playableWithoutInvert = workingBeatmap.GetPlayableBeatmap(new ManiaRuleset().RulesetInfo);
|
||||
Assert.That(playableWithoutInvert.Breaks.Count, Is.Not.Zero);
|
||||
Assert.That(playableWithoutInvert.Breaks[0], Is.EqualTo(new BreakPeriod(0, 1000)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
643
osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModNoRelease.cs
Normal file
643
osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModNoRelease.cs
Normal file
@ -0,0 +1,643 @@
|
||||
// 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.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mania.Mods;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Replays;
|
||||
using osu.Game.Rulesets.Mania.Scoring;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests.Mods
|
||||
{
|
||||
public partial class TestSceneManiaModNoRelease : RateAdjustedBeatmapTestScene
|
||||
{
|
||||
private const double time_before_head = 250;
|
||||
private const double time_head = 1500;
|
||||
private const double time_during_hold_1 = 2500;
|
||||
private const double time_tail = 4000;
|
||||
private const double time_after_tail = 5250;
|
||||
|
||||
private List<JudgementResult> judgementResults = new List<JudgementResult>();
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// o o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestNoInput()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_before_head),
|
||||
new ManiaReplayFrame(time_after_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTailJudgement(HitResult.Miss);
|
||||
assertNoteJudgement(HitResult.IgnoreMiss);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// x o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestCorrectInput()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Perfect);
|
||||
assertTailJudgement(HitResult.Perfect);
|
||||
assertNoteJudgement(HitResult.IgnoreHit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// x o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestLateRelease()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_after_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Perfect);
|
||||
assertTailJudgement(HitResult.Perfect);
|
||||
assertNoteJudgement(HitResult.IgnoreHit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// x o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressTooEarlyAndReleaseAfterTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_before_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_after_tail, ManiaAction.Key1),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTailJudgement(HitResult.Miss);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// x o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressTooEarlyAndReleaseAtTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_before_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTailJudgement(HitResult.Miss);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// xo x o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressTooEarlyThenPressAtStartAndReleaseAfterTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_before_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_before_head + 10),
|
||||
new ManiaReplayFrame(time_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_after_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Perfect);
|
||||
assertTailJudgement(HitResult.Perfect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// xo x o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressTooEarlyThenPressAtStartAndReleaseAtTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_before_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_before_head + 10),
|
||||
new ManiaReplayFrame(time_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Perfect);
|
||||
assertTailJudgement(HitResult.Perfect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// xo o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressAtStartAndBreak()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_head + 10),
|
||||
new ManiaReplayFrame(time_after_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Perfect);
|
||||
assertTailJudgement(HitResult.Miss);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// xox o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressAtStartThenReleaseAndImmediatelyRepress()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_head + 1),
|
||||
new ManiaReplayFrame(time_head + 2, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Perfect);
|
||||
assertComboAtJudgement(0, 1);
|
||||
assertTailJudgement(HitResult.Meh);
|
||||
assertComboAtJudgement(1, 0);
|
||||
assertComboAtJudgement(3, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// xo x o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressAtStartThenBreakThenRepressAndReleaseAfterTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_head + 10),
|
||||
new ManiaReplayFrame(time_during_hold_1, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_after_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Perfect);
|
||||
assertTailJudgement(HitResult.Meh);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// xo x o o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressAtStartThenBreakThenRepressAndReleaseAtTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_head + 10),
|
||||
new ManiaReplayFrame(time_during_hold_1, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Perfect);
|
||||
assertTailJudgement(HitResult.Meh);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// x o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressDuringNoteAndReleaseAfterTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_during_hold_1, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_after_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTailJudgement(HitResult.Meh);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// x o o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressDuringNoteAndReleaseAtTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_during_hold_1, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTailJudgement(HitResult.Meh);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]--------------
|
||||
/// xo
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressAndReleaseAfterTailWithCloseByHead()
|
||||
{
|
||||
const int duration = 30;
|
||||
|
||||
var beatmap = new Beatmap<ManiaHitObject>
|
||||
{
|
||||
HitObjects =
|
||||
{
|
||||
// hold note is very short, to make the head still in range
|
||||
new HoldNote
|
||||
{
|
||||
StartTime = time_head,
|
||||
Duration = duration,
|
||||
Column = 0,
|
||||
}
|
||||
},
|
||||
BeatmapInfo =
|
||||
{
|
||||
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
|
||||
Ruleset = new ManiaRuleset().RulesetInfo
|
||||
},
|
||||
};
|
||||
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_head + duration + 60, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_head + duration + 70),
|
||||
}, beatmap);
|
||||
|
||||
assertHeadJudgement(HitResult.Ok);
|
||||
assertTailJudgement(HitResult.Perfect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-O-------------
|
||||
/// xo o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressAndReleaseJustBeforeTailWithNearbyNoteAndCloseByHead()
|
||||
{
|
||||
Note note;
|
||||
|
||||
const int duration = 50;
|
||||
|
||||
var beatmap = new Beatmap<ManiaHitObject>
|
||||
{
|
||||
HitObjects =
|
||||
{
|
||||
// hold note is very short, to make the head still in range
|
||||
new HoldNote
|
||||
{
|
||||
StartTime = time_head,
|
||||
Duration = duration,
|
||||
Column = 0,
|
||||
},
|
||||
{
|
||||
// Next note within tail lenience
|
||||
note = new Note
|
||||
{
|
||||
StartTime = time_head + duration + 10
|
||||
}
|
||||
}
|
||||
},
|
||||
BeatmapInfo =
|
||||
{
|
||||
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
|
||||
Ruleset = new ManiaRuleset().RulesetInfo
|
||||
},
|
||||
};
|
||||
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_head + duration, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_head + duration + 10),
|
||||
}, beatmap);
|
||||
|
||||
assertHeadJudgement(HitResult.Good);
|
||||
assertTailJudgement(HitResult.Perfect);
|
||||
|
||||
assertHitObjectJudgement(note, HitResult.Miss);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]--O--
|
||||
/// xo o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressAndReleaseJustBeforeTailWithNearbyNote()
|
||||
{
|
||||
Note note;
|
||||
|
||||
var beatmap = new Beatmap<ManiaHitObject>
|
||||
{
|
||||
HitObjects =
|
||||
{
|
||||
new HoldNote
|
||||
{
|
||||
StartTime = time_head,
|
||||
Duration = time_tail - time_head,
|
||||
Column = 0,
|
||||
},
|
||||
{
|
||||
// Next note within tail lenience
|
||||
note = new Note
|
||||
{
|
||||
StartTime = time_tail + 50
|
||||
}
|
||||
}
|
||||
},
|
||||
BeatmapInfo =
|
||||
{
|
||||
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
|
||||
Ruleset = new ManiaRuleset().RulesetInfo
|
||||
},
|
||||
};
|
||||
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_tail - 10, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail),
|
||||
}, beatmap);
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTailJudgement(HitResult.Miss);
|
||||
|
||||
assertHitObjectJudgement(note, HitResult.Good);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// xo
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressAndReleaseJustAfterTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_tail + 20, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail + 30),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTailJudgement(HitResult.Meh);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]--O--
|
||||
/// xo o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressAndReleaseJustAfterTailWithNearbyNote()
|
||||
{
|
||||
// Next note within tail lenience
|
||||
Note note = new Note { StartTime = time_tail + 50 };
|
||||
|
||||
var beatmap = new Beatmap<ManiaHitObject>
|
||||
{
|
||||
HitObjects =
|
||||
{
|
||||
new HoldNote
|
||||
{
|
||||
StartTime = time_head,
|
||||
Duration = time_tail - time_head,
|
||||
Column = 0,
|
||||
},
|
||||
note
|
||||
},
|
||||
BeatmapInfo =
|
||||
{
|
||||
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
|
||||
Ruleset = new ManiaRuleset().RulesetInfo
|
||||
},
|
||||
};
|
||||
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_tail + 10, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail + 20),
|
||||
}, beatmap);
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTailJudgement(HitResult.Miss);
|
||||
|
||||
assertHitObjectJudgement(note, HitResult.Great);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// xo o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressAndReleaseAtTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_tail, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail + 10),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTailJudgement(HitResult.Meh);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMissReleaseAndHitSecondRelease()
|
||||
{
|
||||
var windows = new ManiaHitWindows();
|
||||
windows.SetDifficulty(10);
|
||||
|
||||
var beatmap = new Beatmap<ManiaHitObject>
|
||||
{
|
||||
HitObjects =
|
||||
{
|
||||
new HoldNote
|
||||
{
|
||||
StartTime = 1000,
|
||||
Duration = 500,
|
||||
Column = 0,
|
||||
},
|
||||
new HoldNote
|
||||
{
|
||||
StartTime = 1000 + 500 + windows.WindowFor(HitResult.Miss) + 10,
|
||||
Duration = 500,
|
||||
Column = 0,
|
||||
},
|
||||
},
|
||||
BeatmapInfo =
|
||||
{
|
||||
Difficulty = new BeatmapDifficulty
|
||||
{
|
||||
SliderTickRate = 4,
|
||||
OverallDifficulty = 10,
|
||||
},
|
||||
Ruleset = new ManiaRuleset().RulesetInfo
|
||||
},
|
||||
};
|
||||
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(beatmap.HitObjects[1].StartTime, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(beatmap.HitObjects[1].GetEndTime()),
|
||||
}, beatmap);
|
||||
|
||||
AddAssert("first hold note missed", () => judgementResults.Where(j => beatmap.HitObjects[0].NestedHitObjects.Contains(j.HitObject))
|
||||
.All(j => !j.Type.IsHit()));
|
||||
|
||||
AddAssert("second hold note hit", () => judgementResults.Where(j => beatmap.HitObjects[1].NestedHitObjects.Contains(j.HitObject))
|
||||
.All(j => j.Type.IsHit()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestZeroLength()
|
||||
{
|
||||
var beatmap = new Beatmap<ManiaHitObject>
|
||||
{
|
||||
HitObjects =
|
||||
{
|
||||
new HoldNote
|
||||
{
|
||||
StartTime = 1000,
|
||||
Duration = 0,
|
||||
Column = 0,
|
||||
},
|
||||
},
|
||||
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
|
||||
};
|
||||
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(beatmap.HitObjects[0].StartTime, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(beatmap.HitObjects[0].GetEndTime() + 1),
|
||||
}, beatmap);
|
||||
|
||||
AddAssert("hold note hit", () => judgementResults.Where(j => beatmap.HitObjects[0].NestedHitObjects.Contains(j.HitObject))
|
||||
.All(j => j.Type.IsHit()));
|
||||
}
|
||||
|
||||
private void assertHitObjectJudgement(HitObject hitObject, HitResult result)
|
||||
=> AddAssert($"object judged as {result}", () => judgementResults.First(j => j.HitObject == hitObject).Type, () => Is.EqualTo(result));
|
||||
|
||||
private void assertHeadJudgement(HitResult result)
|
||||
=> AddAssert($"head judged as {result}", () => judgementResults.First(j => j.HitObject is Note).Type, () => Is.EqualTo(result));
|
||||
|
||||
private void assertTailJudgement(HitResult result)
|
||||
=> AddAssert($"tail judged as {result}", () => judgementResults.Single(j => j.HitObject is TailNote).Type, () => Is.EqualTo(result));
|
||||
|
||||
private void assertNoteJudgement(HitResult result)
|
||||
=> AddAssert($"hold note judged as {result}", () => judgementResults.Single(j => j.HitObject is HoldNote).Type, () => Is.EqualTo(result));
|
||||
|
||||
private void assertComboAtJudgement(int judgementIndex, int combo)
|
||||
=> AddAssert($"combo at judgement {judgementIndex} is {combo}", () => judgementResults.ElementAt(judgementIndex).ComboAfterJudgement, () => Is.EqualTo(combo));
|
||||
|
||||
private ScoreAccessibleReplayPlayer currentPlayer = null!;
|
||||
|
||||
private void performTest(List<ReplayFrame> frames, Beatmap<ManiaHitObject>? beatmap = null)
|
||||
{
|
||||
if (beatmap == null)
|
||||
{
|
||||
beatmap = new Beatmap<ManiaHitObject>
|
||||
{
|
||||
HitObjects =
|
||||
{
|
||||
new HoldNote
|
||||
{
|
||||
StartTime = time_head,
|
||||
Duration = time_tail - time_head,
|
||||
Column = 0,
|
||||
}
|
||||
},
|
||||
BeatmapInfo =
|
||||
{
|
||||
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
|
||||
Ruleset = new ManiaRuleset().RulesetInfo,
|
||||
},
|
||||
};
|
||||
|
||||
beatmap.ControlPointInfo.Add(0, new EffectControlPoint { ScrollSpeed = 0.1f });
|
||||
}
|
||||
|
||||
AddStep("load player", () =>
|
||||
{
|
||||
SelectedMods.Value = new List<Mod>
|
||||
{
|
||||
new ManiaModNoRelease()
|
||||
};
|
||||
|
||||
Beatmap.Value = CreateWorkingBeatmap(beatmap);
|
||||
|
||||
var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } });
|
||||
|
||||
p.OnLoadComplete += _ =>
|
||||
{
|
||||
p.ScoreProcessor.NewJudgement += result =>
|
||||
{
|
||||
if (currentPlayer == p) judgementResults.Add(result);
|
||||
};
|
||||
};
|
||||
|
||||
LoadScreen(currentPlayer = p);
|
||||
judgementResults = new List<JudgementResult>();
|
||||
});
|
||||
|
||||
AddUntilStep("Beatmap at 0", () => Beatmap.Value.Track.CurrentTime == 0);
|
||||
AddUntilStep("Wait until player is loaded", () => currentPlayer.IsCurrentScreen());
|
||||
|
||||
AddUntilStep("Wait for completion", () => currentPlayer.ScoreProcessor.HasCompleted.Value);
|
||||
}
|
||||
|
||||
private partial class ScoreAccessibleReplayPlayer : ReplayPlayer
|
||||
{
|
||||
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
|
||||
|
||||
protected override bool PauseOnFocusLost => false;
|
||||
|
||||
public ScoreAccessibleReplayPlayer(Score score)
|
||||
: base(score, new PlayerConfiguration
|
||||
{
|
||||
AllowPause = false,
|
||||
ShowResults = false,
|
||||
})
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -474,8 +474,8 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
AddAssert("first hold note missed", () => judgementResults.Where(j => beatmap.HitObjects[0].NestedHitObjects.Contains(j.HitObject))
|
||||
.All(j => !j.Type.IsHit()));
|
||||
|
||||
AddAssert("second hold note missed", () => judgementResults.Where(j => beatmap.HitObjects[1].NestedHitObjects.Contains(j.HitObject))
|
||||
.All(j => j.Type.IsHit()));
|
||||
AddAssert("second hold note hit", () => judgementResults.Where(j => beatmap.HitObjects[1].NestedHitObjects.Contains(j.HitObject))
|
||||
.All(j => j.Type.IsHit()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -8,7 +8,6 @@ using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -100,7 +99,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
}
|
||||
|
||||
private bool verifyAnchors(DrawableHitObject hitObject, Anchor expectedAnchor)
|
||||
=> hitObject.Anchor.HasFlagFast(expectedAnchor) && hitObject.Origin.HasFlagFast(expectedAnchor);
|
||||
=> hitObject.Anchor.HasFlag(expectedAnchor) && hitObject.Origin.HasFlag(expectedAnchor);
|
||||
|
||||
private bool verifyAnchors(DrawableHoldNote holdNote, Anchor expectedAnchor)
|
||||
=> verifyAnchors((DrawableHitObject)holdNote, expectedAnchor) && holdNote.NestedHitObjects.All(n => verifyAnchors(n, expectedAnchor));
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osuTK;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -79,7 +78,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
else
|
||||
convertType |= PatternType.LowProbability;
|
||||
|
||||
if (!convertType.HasFlagFast(PatternType.KeepSingle))
|
||||
if (!convertType.HasFlag(PatternType.KeepSingle))
|
||||
{
|
||||
if (HitObject.Samples.Any(s => s.Name == HitSampleInfo.HIT_FINISH) && TotalColumns != 8)
|
||||
convertType |= PatternType.Mirror;
|
||||
@ -102,7 +101,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
|
||||
int lastColumn = PreviousPattern.HitObjects.FirstOrDefault()?.Column ?? 0;
|
||||
|
||||
if (convertType.HasFlagFast(PatternType.Reverse) && PreviousPattern.HitObjects.Any())
|
||||
if (convertType.HasFlag(PatternType.Reverse) && PreviousPattern.HitObjects.Any())
|
||||
{
|
||||
// Generate a new pattern by copying the last hit objects in reverse-column order
|
||||
for (int i = RandomStart; i < TotalColumns; i++)
|
||||
@ -114,7 +113,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
return pattern;
|
||||
}
|
||||
|
||||
if (convertType.HasFlagFast(PatternType.Cycle) && PreviousPattern.HitObjects.Count() == 1
|
||||
if (convertType.HasFlag(PatternType.Cycle) && PreviousPattern.HitObjects.Count() == 1
|
||||
// If we convert to 7K + 1, let's not overload the special key
|
||||
&& (TotalColumns != 8 || lastColumn != 0)
|
||||
// Make sure the last column was not the centre column
|
||||
@ -127,7 +126,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
return pattern;
|
||||
}
|
||||
|
||||
if (convertType.HasFlagFast(PatternType.ForceStack) && PreviousPattern.HitObjects.Any())
|
||||
if (convertType.HasFlag(PatternType.ForceStack) && PreviousPattern.HitObjects.Any())
|
||||
{
|
||||
// Generate a new pattern by placing on the already filled columns
|
||||
for (int i = RandomStart; i < TotalColumns; i++)
|
||||
@ -141,7 +140,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
|
||||
if (PreviousPattern.HitObjects.Count() == 1)
|
||||
{
|
||||
if (convertType.HasFlagFast(PatternType.Stair))
|
||||
if (convertType.HasFlag(PatternType.Stair))
|
||||
{
|
||||
// Generate a new pattern by placing on the next column, cycling back to the start if there is no "next"
|
||||
int targetColumn = lastColumn + 1;
|
||||
@ -152,7 +151,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
return pattern;
|
||||
}
|
||||
|
||||
if (convertType.HasFlagFast(PatternType.ReverseStair))
|
||||
if (convertType.HasFlag(PatternType.ReverseStair))
|
||||
{
|
||||
// Generate a new pattern by placing on the previous column, cycling back to the end if there is no "previous"
|
||||
int targetColumn = lastColumn - 1;
|
||||
@ -164,10 +163,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
}
|
||||
}
|
||||
|
||||
if (convertType.HasFlagFast(PatternType.KeepSingle))
|
||||
if (convertType.HasFlag(PatternType.KeepSingle))
|
||||
return generateRandomNotes(1);
|
||||
|
||||
if (convertType.HasFlagFast(PatternType.Mirror))
|
||||
if (convertType.HasFlag(PatternType.Mirror))
|
||||
{
|
||||
if (ConversionDifficulty > 6.5)
|
||||
return generateRandomPatternWithMirrored(0.12, 0.38, 0.12);
|
||||
@ -179,7 +178,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
|
||||
if (ConversionDifficulty > 6.5)
|
||||
{
|
||||
if (convertType.HasFlagFast(PatternType.LowProbability))
|
||||
if (convertType.HasFlag(PatternType.LowProbability))
|
||||
return generateRandomPattern(0.78, 0.42, 0, 0);
|
||||
|
||||
return generateRandomPattern(1, 0.62, 0, 0);
|
||||
@ -187,7 +186,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
|
||||
if (ConversionDifficulty > 4)
|
||||
{
|
||||
if (convertType.HasFlagFast(PatternType.LowProbability))
|
||||
if (convertType.HasFlag(PatternType.LowProbability))
|
||||
return generateRandomPattern(0.35, 0.08, 0, 0);
|
||||
|
||||
return generateRandomPattern(0.52, 0.15, 0, 0);
|
||||
@ -195,7 +194,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
|
||||
if (ConversionDifficulty > 2)
|
||||
{
|
||||
if (convertType.HasFlagFast(PatternType.LowProbability))
|
||||
if (convertType.HasFlag(PatternType.LowProbability))
|
||||
return generateRandomPattern(0.18, 0, 0, 0);
|
||||
|
||||
return generateRandomPattern(0.45, 0, 0, 0);
|
||||
@ -208,9 +207,9 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
|
||||
foreach (var obj in p.HitObjects)
|
||||
{
|
||||
if (convertType.HasFlagFast(PatternType.Stair) && obj.Column == TotalColumns - 1)
|
||||
if (convertType.HasFlag(PatternType.Stair) && obj.Column == TotalColumns - 1)
|
||||
StairType = PatternType.ReverseStair;
|
||||
if (convertType.HasFlagFast(PatternType.ReverseStair) && obj.Column == RandomStart)
|
||||
if (convertType.HasFlag(PatternType.ReverseStair) && obj.Column == RandomStart)
|
||||
StairType = PatternType.Stair;
|
||||
}
|
||||
|
||||
@ -230,7 +229,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
{
|
||||
var pattern = new Pattern();
|
||||
|
||||
bool allowStacking = !convertType.HasFlagFast(PatternType.ForceNotStack);
|
||||
bool allowStacking = !convertType.HasFlag(PatternType.ForceNotStack);
|
||||
|
||||
if (!allowStacking)
|
||||
noteCount = Math.Min(noteCount, TotalColumns - RandomStart - PreviousPattern.ColumnWithObjects);
|
||||
@ -250,7 +249,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
|
||||
int getNextColumn(int last)
|
||||
{
|
||||
if (convertType.HasFlagFast(PatternType.Gathered))
|
||||
if (convertType.HasFlag(PatternType.Gathered))
|
||||
{
|
||||
last++;
|
||||
if (last == TotalColumns)
|
||||
@ -297,7 +296,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
/// <returns>The <see cref="Pattern"/> containing the hit objects.</returns>
|
||||
private Pattern generateRandomPatternWithMirrored(double centreProbability, double p2, double p3)
|
||||
{
|
||||
if (convertType.HasFlagFast(PatternType.ForceNotStack))
|
||||
if (convertType.HasFlag(PatternType.ForceNotStack))
|
||||
return generateRandomPattern(1 / 2f + p2 / 2, p2, (p2 + p3) / 2, p3);
|
||||
|
||||
var pattern = new Pattern();
|
||||
|
@ -7,7 +7,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@ -139,7 +138,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
|
||||
if (ConversionDifficulty > 6.5)
|
||||
{
|
||||
if (convertType.HasFlagFast(PatternType.LowProbability))
|
||||
if (convertType.HasFlag(PatternType.LowProbability))
|
||||
return generateNRandomNotes(StartTime, 0.78, 0.3, 0);
|
||||
|
||||
return generateNRandomNotes(StartTime, 0.85, 0.36, 0.03);
|
||||
@ -147,7 +146,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
|
||||
if (ConversionDifficulty > 4)
|
||||
{
|
||||
if (convertType.HasFlagFast(PatternType.LowProbability))
|
||||
if (convertType.HasFlag(PatternType.LowProbability))
|
||||
return generateNRandomNotes(StartTime, 0.43, 0.08, 0);
|
||||
|
||||
return generateNRandomNotes(StartTime, 0.56, 0.18, 0);
|
||||
@ -155,13 +154,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
|
||||
if (ConversionDifficulty > 2.5)
|
||||
{
|
||||
if (convertType.HasFlagFast(PatternType.LowProbability))
|
||||
if (convertType.HasFlag(PatternType.LowProbability))
|
||||
return generateNRandomNotes(StartTime, 0.3, 0, 0);
|
||||
|
||||
return generateNRandomNotes(StartTime, 0.37, 0.08, 0);
|
||||
}
|
||||
|
||||
if (convertType.HasFlagFast(PatternType.LowProbability))
|
||||
if (convertType.HasFlag(PatternType.LowProbability))
|
||||
return generateNRandomNotes(StartTime, 0.17, 0, 0);
|
||||
|
||||
return generateNRandomNotes(StartTime, 0.27, 0, 0);
|
||||
@ -219,7 +218,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
var pattern = new Pattern();
|
||||
|
||||
int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true);
|
||||
if (convertType.HasFlagFast(PatternType.ForceNotStack) && PreviousPattern.ColumnWithObjects < TotalColumns)
|
||||
if (convertType.HasFlag(PatternType.ForceNotStack) && PreviousPattern.ColumnWithObjects < TotalColumns)
|
||||
nextColumn = FindAvailableColumn(nextColumn, PreviousPattern);
|
||||
|
||||
int lastColumn = nextColumn;
|
||||
@ -371,7 +370,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
|
||||
static bool isDoubleSample(HitSampleInfo sample) => sample.Name == HitSampleInfo.HIT_CLAP || sample.Name == HitSampleInfo.HIT_FINISH;
|
||||
|
||||
bool canGenerateTwoNotes = !convertType.HasFlagFast(PatternType.LowProbability);
|
||||
bool canGenerateTwoNotes = !convertType.HasFlag(PatternType.LowProbability);
|
||||
canGenerateTwoNotes &= HitObject.Samples.Any(isDoubleSample) || sampleInfoListAt(StartTime).Any(isDoubleSample);
|
||||
|
||||
if (canGenerateTwoNotes)
|
||||
@ -404,7 +403,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
int endTime = startTime + SegmentDuration * SpanCount;
|
||||
|
||||
int nextColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true);
|
||||
if (convertType.HasFlagFast(PatternType.ForceNotStack) && PreviousPattern.ColumnWithObjects < TotalColumns)
|
||||
if (convertType.HasFlag(PatternType.ForceNotStack) && PreviousPattern.ColumnWithObjects < TotalColumns)
|
||||
nextColumn = FindAvailableColumn(nextColumn, PreviousPattern);
|
||||
|
||||
for (int i = 0; i < columnRepeat; i++)
|
||||
@ -433,7 +432,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
var pattern = new Pattern();
|
||||
|
||||
int holdColumn = GetColumn((HitObject as IHasXPosition)?.X ?? 0, true);
|
||||
if (convertType.HasFlagFast(PatternType.ForceNotStack) && PreviousPattern.ColumnWithObjects < TotalColumns)
|
||||
if (convertType.HasFlag(PatternType.ForceNotStack) && PreviousPattern.ColumnWithObjects < TotalColumns)
|
||||
holdColumn = FindAvailableColumn(holdColumn, PreviousPattern);
|
||||
|
||||
// Create the hold note
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
@ -89,79 +88,79 @@ namespace osu.Game.Rulesets.Mania
|
||||
|
||||
public override IEnumerable<Mod> ConvertFromLegacyMods(LegacyMods mods)
|
||||
{
|
||||
if (mods.HasFlagFast(LegacyMods.Nightcore))
|
||||
if (mods.HasFlag(LegacyMods.Nightcore))
|
||||
yield return new ManiaModNightcore();
|
||||
else if (mods.HasFlagFast(LegacyMods.DoubleTime))
|
||||
else if (mods.HasFlag(LegacyMods.DoubleTime))
|
||||
yield return new ManiaModDoubleTime();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Perfect))
|
||||
if (mods.HasFlag(LegacyMods.Perfect))
|
||||
yield return new ManiaModPerfect();
|
||||
else if (mods.HasFlagFast(LegacyMods.SuddenDeath))
|
||||
else if (mods.HasFlag(LegacyMods.SuddenDeath))
|
||||
yield return new ManiaModSuddenDeath();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Cinema))
|
||||
if (mods.HasFlag(LegacyMods.Cinema))
|
||||
yield return new ManiaModCinema();
|
||||
else if (mods.HasFlagFast(LegacyMods.Autoplay))
|
||||
else if (mods.HasFlag(LegacyMods.Autoplay))
|
||||
yield return new ManiaModAutoplay();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Easy))
|
||||
if (mods.HasFlag(LegacyMods.Easy))
|
||||
yield return new ManiaModEasy();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.FadeIn))
|
||||
if (mods.HasFlag(LegacyMods.FadeIn))
|
||||
yield return new ManiaModFadeIn();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Flashlight))
|
||||
if (mods.HasFlag(LegacyMods.Flashlight))
|
||||
yield return new ManiaModFlashlight();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.HalfTime))
|
||||
if (mods.HasFlag(LegacyMods.HalfTime))
|
||||
yield return new ManiaModHalfTime();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.HardRock))
|
||||
if (mods.HasFlag(LegacyMods.HardRock))
|
||||
yield return new ManiaModHardRock();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Hidden))
|
||||
if (mods.HasFlag(LegacyMods.Hidden))
|
||||
yield return new ManiaModHidden();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Key1))
|
||||
if (mods.HasFlag(LegacyMods.Key1))
|
||||
yield return new ManiaModKey1();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Key2))
|
||||
if (mods.HasFlag(LegacyMods.Key2))
|
||||
yield return new ManiaModKey2();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Key3))
|
||||
if (mods.HasFlag(LegacyMods.Key3))
|
||||
yield return new ManiaModKey3();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Key4))
|
||||
if (mods.HasFlag(LegacyMods.Key4))
|
||||
yield return new ManiaModKey4();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Key5))
|
||||
if (mods.HasFlag(LegacyMods.Key5))
|
||||
yield return new ManiaModKey5();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Key6))
|
||||
if (mods.HasFlag(LegacyMods.Key6))
|
||||
yield return new ManiaModKey6();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Key7))
|
||||
if (mods.HasFlag(LegacyMods.Key7))
|
||||
yield return new ManiaModKey7();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Key8))
|
||||
if (mods.HasFlag(LegacyMods.Key8))
|
||||
yield return new ManiaModKey8();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Key9))
|
||||
if (mods.HasFlag(LegacyMods.Key9))
|
||||
yield return new ManiaModKey9();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.KeyCoop))
|
||||
if (mods.HasFlag(LegacyMods.KeyCoop))
|
||||
yield return new ManiaModDualStages();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.NoFail))
|
||||
if (mods.HasFlag(LegacyMods.NoFail))
|
||||
yield return new ManiaModNoFail();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Random))
|
||||
if (mods.HasFlag(LegacyMods.Random))
|
||||
yield return new ManiaModRandom();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Mirror))
|
||||
if (mods.HasFlag(LegacyMods.Mirror))
|
||||
yield return new ManiaModMirror();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.ScoreV2))
|
||||
if (mods.HasFlag(LegacyMods.ScoreV2))
|
||||
yield return new ModScoreV2();
|
||||
}
|
||||
|
||||
@ -241,6 +240,7 @@ namespace osu.Game.Rulesets.Mania
|
||||
new ManiaModEasy(),
|
||||
new ManiaModNoFail(),
|
||||
new MultiMod(new ManiaModHalfTime(), new ManiaModDaycore()),
|
||||
new ManiaModNoRelease(),
|
||||
};
|
||||
|
||||
case ModType.DifficultyIncrease:
|
||||
|
107
osu.Game.Rulesets.Mania/Mods/ManiaModNoRelease.cs
Normal file
107
osu.Game.Rulesets.Mania/Mods/ManiaModNoRelease.cs
Normal file
@ -0,0 +1,107 @@
|
||||
// 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 System.Threading;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public partial class ManiaModNoRelease : Mod, IApplicableAfterBeatmapConversion, IApplicableToDrawableRuleset<ManiaHitObject>
|
||||
{
|
||||
public override string Name => "No Release";
|
||||
|
||||
public override string Acronym => "NR";
|
||||
|
||||
public override LocalisableString Description => "No more timing the end of hold notes.";
|
||||
|
||||
public override double ScoreMultiplier => 0.9;
|
||||
|
||||
public override ModType Type => ModType.DifficultyReduction;
|
||||
|
||||
public void ApplyToBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
var maniaBeatmap = (ManiaBeatmap)beatmap;
|
||||
var hitObjects = maniaBeatmap.HitObjects.Select(obj =>
|
||||
{
|
||||
if (obj is HoldNote hold)
|
||||
return new NoReleaseHoldNote(hold);
|
||||
|
||||
return obj;
|
||||
}).ToList();
|
||||
|
||||
maniaBeatmap.HitObjects = hitObjects;
|
||||
}
|
||||
|
||||
public void ApplyToDrawableRuleset(DrawableRuleset<ManiaHitObject> drawableRuleset)
|
||||
{
|
||||
var maniaRuleset = (DrawableManiaRuleset)drawableRuleset;
|
||||
|
||||
foreach (var stage in maniaRuleset.Playfield.Stages)
|
||||
{
|
||||
foreach (var column in stage.Columns)
|
||||
{
|
||||
column.RegisterPool<NoReleaseTailNote, NoReleaseDrawableHoldNoteTail>(10, 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private partial class NoReleaseDrawableHoldNoteTail : DrawableHoldNoteTail
|
||||
{
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
{
|
||||
// apply perfect once the tail is reached
|
||||
if (HoldNote.HoldStartTime != null && timeOffset >= 0)
|
||||
ApplyResult(GetCappedResult(HitResult.Perfect));
|
||||
else
|
||||
base.CheckForResult(userTriggered, timeOffset);
|
||||
}
|
||||
}
|
||||
|
||||
private class NoReleaseTailNote : TailNote
|
||||
{
|
||||
}
|
||||
|
||||
private class NoReleaseHoldNote : HoldNote
|
||||
{
|
||||
public NoReleaseHoldNote(HoldNote hold)
|
||||
{
|
||||
StartTime = hold.StartTime;
|
||||
Duration = hold.Duration;
|
||||
Column = hold.Column;
|
||||
NodeSamples = hold.NodeSamples;
|
||||
}
|
||||
|
||||
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
|
||||
{
|
||||
AddNested(Head = new HeadNote
|
||||
{
|
||||
StartTime = StartTime,
|
||||
Column = Column,
|
||||
Samples = GetNodeSamples(0),
|
||||
});
|
||||
|
||||
AddNested(Tail = new NoReleaseTailNote
|
||||
{
|
||||
StartTime = EndTime,
|
||||
Column = Column,
|
||||
Samples = GetNodeSamples((NodeSamples?.Count - 1) ?? 1),
|
||||
});
|
||||
|
||||
AddNested(Body = new HoldNoteBody
|
||||
{
|
||||
StartTime = StartTime,
|
||||
Column = Column
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -72,18 +72,18 @@ namespace osu.Game.Rulesets.Mania.Objects
|
||||
/// <summary>
|
||||
/// The head note of the hold.
|
||||
/// </summary>
|
||||
public HeadNote Head { get; private set; }
|
||||
public HeadNote Head { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The tail note of the hold.
|
||||
/// </summary>
|
||||
public TailNote Tail { get; private set; }
|
||||
public TailNote Tail { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The body of the hold.
|
||||
/// This is an invisible and silent object that tracks the holding state of the <see cref="HoldNote"/>.
|
||||
/// </summary>
|
||||
public HoldNoteBody Body { get; private set; }
|
||||
public HoldNoteBody Body { get; protected set; }
|
||||
|
||||
public override double MaximumJudgementOffset => Tail.MaximumJudgementOffset;
|
||||
|
||||
|
@ -192,12 +192,12 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
|
||||
if (press)
|
||||
{
|
||||
inputManager?.KeyBindingContainer?.TriggerPressed(Action.Value);
|
||||
inputManager?.KeyBindingContainer.TriggerPressed(Action.Value);
|
||||
highlightOverlay.FadeTo(0.1f, 80, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
{
|
||||
inputManager?.KeyBindingContainer?.TriggerReleased(Action.Value);
|
||||
inputManager?.KeyBindingContainer.TriggerReleased(Action.Value);
|
||||
highlightOverlay.FadeTo(0, 400, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
@ -160,6 +161,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
return grid switch
|
||||
{
|
||||
RectangularPositionSnapGrid rectangular => rectangular.StartPosition.Value + GeometryUtils.RotateVector(rectangular.Spacing.Value, -rectangular.GridLineRotation.Value),
|
||||
TriangularPositionSnapGrid triangular => triangular.StartPosition.Value + GeometryUtils.RotateVector(new Vector2(triangular.Spacing.Value / 2, triangular.Spacing.Value / 2 * MathF.Sqrt(3)), -triangular.GridLineRotation.Value),
|
||||
CircularPositionSnapGrid circular => circular.StartPosition.Value + GeometryUtils.RotateVector(new Vector2(circular.Spacing.Value, 0), -45),
|
||||
_ => Vector2.Zero
|
||||
};
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
{
|
||||
@ -177,6 +178,79 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
addAssertPointPositionChanged(points, i);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChangingControlPointTypeViaTab()
|
||||
{
|
||||
createVisualiser(true);
|
||||
|
||||
addControlPointStep(new Vector2(200), PathType.LINEAR);
|
||||
addControlPointStep(new Vector2(300));
|
||||
addControlPointStep(new Vector2(500, 300));
|
||||
addControlPointStep(new Vector2(700, 200));
|
||||
addControlPointStep(new Vector2(500, 100));
|
||||
|
||||
AddStep("select first control point", () => visualiser.Pieces[0].IsSelected.Value = true);
|
||||
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||
assertControlPointPathType(0, PathType.BEZIER);
|
||||
|
||||
AddStep("press shift-tab", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.LShift);
|
||||
InputManager.Key(Key.Tab);
|
||||
InputManager.ReleaseKey(Key.LShift);
|
||||
});
|
||||
assertControlPointPathType(0, PathType.LINEAR);
|
||||
|
||||
AddStep("press shift-tab", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.LShift);
|
||||
InputManager.Key(Key.Tab);
|
||||
InputManager.ReleaseKey(Key.LShift);
|
||||
});
|
||||
assertControlPointPathType(0, PathType.BSpline(4));
|
||||
|
||||
AddStep("press shift-tab", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.LShift);
|
||||
InputManager.Key(Key.Tab);
|
||||
InputManager.ReleaseKey(Key.LShift);
|
||||
});
|
||||
assertControlPointPathType(0, PathType.PERFECT_CURVE);
|
||||
assertControlPointPathType(2, PathType.BSpline(4));
|
||||
|
||||
AddStep("select third last control point", () =>
|
||||
{
|
||||
visualiser.Pieces[0].IsSelected.Value = false;
|
||||
visualiser.Pieces[2].IsSelected.Value = true;
|
||||
});
|
||||
|
||||
AddStep("press shift-tab", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.LShift);
|
||||
InputManager.Key(Key.Tab);
|
||||
InputManager.ReleaseKey(Key.LShift);
|
||||
});
|
||||
assertControlPointPathType(2, PathType.PERFECT_CURVE);
|
||||
|
||||
AddRepeatStep("press tab", () => InputManager.Key(Key.Tab), 2);
|
||||
assertControlPointPathType(0, PathType.BEZIER);
|
||||
assertControlPointPathType(2, null);
|
||||
|
||||
AddStep("select first and third control points", () =>
|
||||
{
|
||||
visualiser.Pieces[0].IsSelected.Value = true;
|
||||
visualiser.Pieces[2].IsSelected.Value = true;
|
||||
});
|
||||
AddStep("press alt-1", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.AltLeft);
|
||||
InputManager.Key(Key.Number1);
|
||||
InputManager.ReleaseKey(Key.AltLeft);
|
||||
});
|
||||
assertControlPointPathType(0, PathType.LINEAR);
|
||||
assertControlPointPathType(2, PathType.LINEAR);
|
||||
}
|
||||
|
||||
private void addAssertPointPositionChanged(Vector2[] points, int index)
|
||||
{
|
||||
AddAssert($"Point at {points.ElementAt(index)} changed",
|
||||
|
@ -2,13 +2,16 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders;
|
||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Tests.Visual;
|
||||
@ -57,7 +60,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
assertPlaced(true);
|
||||
assertLength(200);
|
||||
assertControlPointCount(2);
|
||||
assertControlPointType(0, PathType.LINEAR);
|
||||
assertFinalControlPointType(0, PathType.LINEAR);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -71,7 +74,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
|
||||
assertPlaced(true);
|
||||
assertControlPointCount(2);
|
||||
assertControlPointType(0, PathType.LINEAR);
|
||||
assertFinalControlPointType(0, PathType.LINEAR);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -89,7 +92,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
assertPlaced(true);
|
||||
assertControlPointCount(3);
|
||||
assertControlPointPosition(1, new Vector2(100, 0));
|
||||
assertControlPointType(0, PathType.PERFECT_CURVE);
|
||||
assertFinalControlPointType(0, PathType.PERFECT_CURVE);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -111,7 +114,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
assertControlPointCount(4);
|
||||
assertControlPointPosition(1, new Vector2(100, 0));
|
||||
assertControlPointPosition(2, new Vector2(100, 100));
|
||||
assertControlPointType(0, PathType.BEZIER);
|
||||
assertFinalControlPointType(0, PathType.BEZIER);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -130,8 +133,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
assertPlaced(true);
|
||||
assertControlPointCount(3);
|
||||
assertControlPointPosition(1, new Vector2(100, 0));
|
||||
assertControlPointType(0, PathType.LINEAR);
|
||||
assertControlPointType(1, PathType.LINEAR);
|
||||
assertFinalControlPointType(0, PathType.LINEAR);
|
||||
assertFinalControlPointType(1, PathType.LINEAR);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -149,7 +152,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
|
||||
assertPlaced(true);
|
||||
assertControlPointCount(2);
|
||||
assertControlPointType(0, PathType.LINEAR);
|
||||
assertFinalControlPointType(0, PathType.LINEAR);
|
||||
assertLength(100);
|
||||
}
|
||||
|
||||
@ -171,7 +174,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
|
||||
assertPlaced(true);
|
||||
assertControlPointCount(3);
|
||||
assertControlPointType(0, PathType.PERFECT_CURVE);
|
||||
assertFinalControlPointType(0, PathType.PERFECT_CURVE);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -195,7 +198,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
|
||||
assertPlaced(true);
|
||||
assertControlPointCount(4);
|
||||
assertControlPointType(0, PathType.BEZIER);
|
||||
assertFinalControlPointType(0, PathType.BEZIER);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -215,8 +218,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
assertControlPointCount(3);
|
||||
assertControlPointPosition(1, new Vector2(100, 0));
|
||||
assertControlPointPosition(2, new Vector2(100));
|
||||
assertControlPointType(0, PathType.LINEAR);
|
||||
assertControlPointType(1, PathType.LINEAR);
|
||||
assertFinalControlPointType(0, PathType.LINEAR);
|
||||
assertFinalControlPointType(1, PathType.LINEAR);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -239,8 +242,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
assertControlPointCount(4);
|
||||
assertControlPointPosition(1, new Vector2(100, 0));
|
||||
assertControlPointPosition(2, new Vector2(100));
|
||||
assertControlPointType(0, PathType.LINEAR);
|
||||
assertControlPointType(1, PathType.PERFECT_CURVE);
|
||||
assertFinalControlPointType(0, PathType.LINEAR);
|
||||
assertFinalControlPointType(1, PathType.PERFECT_CURVE);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -268,8 +271,46 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
assertControlPointPosition(2, new Vector2(100));
|
||||
assertControlPointPosition(3, new Vector2(200, 100));
|
||||
assertControlPointPosition(4, new Vector2(200));
|
||||
assertControlPointType(0, PathType.PERFECT_CURVE);
|
||||
assertControlPointType(2, PathType.PERFECT_CURVE);
|
||||
assertFinalControlPointType(0, PathType.PERFECT_CURVE);
|
||||
assertFinalControlPointType(2, PathType.PERFECT_CURVE);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestManualPathTypeControlViaKeyboard()
|
||||
{
|
||||
addMovementStep(new Vector2(200));
|
||||
addClickStep(MouseButton.Left);
|
||||
|
||||
addMovementStep(new Vector2(300, 200));
|
||||
addClickStep(MouseButton.Left);
|
||||
|
||||
addMovementStep(new Vector2(300));
|
||||
|
||||
assertControlPointTypeDuringPlacement(0, PathType.PERFECT_CURVE);
|
||||
|
||||
AddRepeatStep("press tab", () => InputManager.Key(Key.Tab), 2);
|
||||
assertControlPointTypeDuringPlacement(0, PathType.LINEAR);
|
||||
|
||||
AddStep("press shift-tab", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ShiftLeft);
|
||||
InputManager.Key(Key.Tab);
|
||||
InputManager.ReleaseKey(Key.ShiftLeft);
|
||||
});
|
||||
assertControlPointTypeDuringPlacement(0, PathType.BSpline(4));
|
||||
|
||||
AddStep("start new segment via S", () => InputManager.Key(Key.S));
|
||||
assertControlPointTypeDuringPlacement(2, PathType.LINEAR);
|
||||
|
||||
addMovementStep(new Vector2(400, 300));
|
||||
addClickStep(MouseButton.Left);
|
||||
|
||||
addMovementStep(new Vector2(400));
|
||||
addClickStep(MouseButton.Right);
|
||||
|
||||
assertPlaced(true);
|
||||
assertFinalControlPointType(0, PathType.BSpline(4));
|
||||
assertFinalControlPointType(2, PathType.PERFECT_CURVE);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -293,7 +334,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
addClickStep(MouseButton.Right);
|
||||
assertPlaced(true);
|
||||
|
||||
assertControlPointType(0, PathType.BEZIER);
|
||||
assertFinalControlPointType(0, PathType.BEZIER);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -312,11 +353,11 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
assertPlaced(true);
|
||||
assertLength(808, tolerance: 10);
|
||||
assertControlPointCount(5);
|
||||
assertControlPointType(0, PathType.BSpline(4));
|
||||
assertControlPointType(1, null);
|
||||
assertControlPointType(2, null);
|
||||
assertControlPointType(3, null);
|
||||
assertControlPointType(4, null);
|
||||
assertFinalControlPointType(0, PathType.BSpline(4));
|
||||
assertFinalControlPointType(1, null);
|
||||
assertFinalControlPointType(2, null);
|
||||
assertFinalControlPointType(3, null);
|
||||
assertFinalControlPointType(4, null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -337,10 +378,10 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
assertPlaced(true);
|
||||
assertLength(600, tolerance: 10);
|
||||
assertControlPointCount(4);
|
||||
assertControlPointType(0, PathType.BSpline(4));
|
||||
assertControlPointType(1, PathType.BSpline(4));
|
||||
assertControlPointType(2, PathType.BSpline(4));
|
||||
assertControlPointType(3, null);
|
||||
assertFinalControlPointType(0, PathType.BSpline(4));
|
||||
assertFinalControlPointType(1, PathType.BSpline(4));
|
||||
assertFinalControlPointType(2, PathType.BSpline(4));
|
||||
assertFinalControlPointType(3, null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -359,7 +400,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
|
||||
assertPlaced(true);
|
||||
assertControlPointCount(3);
|
||||
assertControlPointType(0, PathType.BEZIER);
|
||||
assertFinalControlPointType(0, PathType.BEZIER);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -379,7 +420,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
|
||||
assertPlaced(true);
|
||||
assertControlPointCount(3);
|
||||
assertControlPointType(0, PathType.PERFECT_CURVE);
|
||||
assertFinalControlPointType(0, PathType.PERFECT_CURVE);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -400,7 +441,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
|
||||
assertPlaced(true);
|
||||
assertControlPointCount(3);
|
||||
assertControlPointType(0, PathType.PERFECT_CURVE);
|
||||
assertFinalControlPointType(0, PathType.PERFECT_CURVE);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -421,7 +462,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
|
||||
assertPlaced(true);
|
||||
assertControlPointCount(3);
|
||||
assertControlPointType(0, PathType.BEZIER);
|
||||
assertFinalControlPointType(0, PathType.BEZIER);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -438,7 +479,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
|
||||
assertPlaced(true);
|
||||
assertControlPointCount(3);
|
||||
assertControlPointType(0, PathType.PERFECT_CURVE);
|
||||
assertFinalControlPointType(0, PathType.PERFECT_CURVE);
|
||||
}
|
||||
|
||||
private void addMovementStep(Vector2 position) => AddStep($"move mouse to {position}", () => InputManager.MoveMouseTo(InputManager.ToScreenSpace(position)));
|
||||
@ -454,7 +495,10 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
|
||||
private void assertControlPointCount(int expected) => AddAssert($"has {expected} control points", () => getSlider()!.Path.ControlPoints.Count, () => Is.EqualTo(expected));
|
||||
|
||||
private void assertControlPointType(int index, PathType? type) => AddAssert($"control point {index} is {type?.ToString() ?? "inherit"}", () => getSlider()!.Path.ControlPoints[index].Type, () => Is.EqualTo(type));
|
||||
private void assertControlPointTypeDuringPlacement(int index, PathType? type) => AddAssert($"control point {index} is {type?.ToString() ?? "inherit"}",
|
||||
() => this.ChildrenOfType<PathControlPointPiece<Slider>>().ElementAt(index).ControlPoint.Type, () => Is.EqualTo(type));
|
||||
|
||||
private void assertFinalControlPointType(int index, PathType? type) => AddAssert($"control point {index} is {type?.ToString() ?? "inherit"}", () => getSlider()!.Path.ControlPoints[index].Type, () => Is.EqualTo(type));
|
||||
|
||||
private void assertControlPointPosition(int index, Vector2 position) =>
|
||||
AddAssert($"control point {index} at {position}", () => Precision.AlmostEquals(position, getSlider()!.Path.ControlPoints[index].Position, 1));
|
||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
public partial class PathControlPointVisualiser<T> : CompositeDrawable, IKeyBindingHandler<PlatformAction>, IHasContextMenu
|
||||
where T : OsuHitObject, IHasPath
|
||||
{
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; // allow context menu to appear outside of the playfield.
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; // allow context menu to appear outside the playfield.
|
||||
|
||||
internal readonly Container<PathControlPointPiece<T>> Pieces;
|
||||
|
||||
@ -196,6 +196,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
if (allowSelection)
|
||||
d.RequestSelection = selectionRequested;
|
||||
|
||||
d.ControlPoint.Changed += controlPointChanged;
|
||||
d.DragStarted = DragStarted;
|
||||
d.DragInProgress = DragInProgress;
|
||||
d.DragEnded = DragEnded;
|
||||
@ -209,6 +210,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
|
||||
foreach (var point in e.OldItems.Cast<PathControlPoint>())
|
||||
{
|
||||
point.Changed -= controlPointChanged;
|
||||
|
||||
foreach (var piece in Pieces.Where(p => p.ControlPoint == point).ToArray())
|
||||
piece.RemoveAndDisposeImmediately();
|
||||
}
|
||||
@ -217,6 +220,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
}
|
||||
}
|
||||
|
||||
private void controlPointChanged() => updateCurveMenuItems();
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (Pieces.Any(piece => piece.IsHovered))
|
||||
@ -245,6 +250,86 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
{
|
||||
}
|
||||
|
||||
// ReSharper disable once StaticMemberInGenericType
|
||||
private static readonly PathType?[] path_types =
|
||||
[
|
||||
PathType.LINEAR,
|
||||
PathType.BEZIER,
|
||||
PathType.PERFECT_CURVE,
|
||||
PathType.BSpline(4),
|
||||
null,
|
||||
];
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (e.Repeat)
|
||||
return false;
|
||||
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Tab:
|
||||
{
|
||||
var selectedPieces = Pieces.Where(p => p.IsSelected.Value).ToArray();
|
||||
if (selectedPieces.Length != 1)
|
||||
return false;
|
||||
|
||||
var selectedPiece = selectedPieces.Single();
|
||||
var selectedPoint = selectedPiece.ControlPoint;
|
||||
|
||||
var validTypes = path_types;
|
||||
|
||||
if (selectedPoint == controlPoints[0])
|
||||
validTypes = validTypes.Where(t => t != null).ToArray();
|
||||
|
||||
int currentTypeIndex = Array.IndexOf(validTypes, selectedPoint.Type);
|
||||
|
||||
if (currentTypeIndex < 0 && e.ShiftPressed)
|
||||
currentTypeIndex = 0;
|
||||
|
||||
changeHandler?.BeginChange();
|
||||
|
||||
do
|
||||
{
|
||||
currentTypeIndex = (validTypes.Length + currentTypeIndex + (e.ShiftPressed ? -1 : 1)) % validTypes.Length;
|
||||
|
||||
updatePathTypeOfSelectedPieces(validTypes[currentTypeIndex]);
|
||||
} while (selectedPoint.Type != validTypes[currentTypeIndex]);
|
||||
|
||||
changeHandler?.EndChange();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case Key.Number1:
|
||||
case Key.Number2:
|
||||
case Key.Number3:
|
||||
case Key.Number4:
|
||||
case Key.Number5:
|
||||
{
|
||||
if (!e.AltPressed)
|
||||
return false;
|
||||
|
||||
var type = path_types[e.Key - Key.Number1];
|
||||
|
||||
if (Pieces[0].IsSelected.Value && type == null)
|
||||
return false;
|
||||
|
||||
updatePathTypeOfSelectedPieces(type);
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
foreach (var p in Pieces)
|
||||
p.ControlPoint.Changed -= controlPointChanged;
|
||||
}
|
||||
|
||||
private void selectionRequested(PathControlPointPiece<T> piece, MouseButtonEvent e)
|
||||
{
|
||||
if (e.Button == MouseButton.Left && inputManager.CurrentState.Keyboard.ControlPressed)
|
||||
@ -254,30 +339,38 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to set the given control point piece to the given path type.
|
||||
/// If that would fail, try to change the path such that it instead succeeds
|
||||
/// Attempts to set all selected control point pieces to the given path type.
|
||||
/// If that fails, try to change the path such that it instead succeeds
|
||||
/// in a UX-friendly way.
|
||||
/// </summary>
|
||||
/// <param name="piece">The control point piece that we want to change the path type of.</param>
|
||||
/// <param name="type">The path type we want to assign to the given control point piece.</param>
|
||||
private void updatePathType(PathControlPointPiece<T> piece, PathType? type)
|
||||
private void updatePathTypeOfSelectedPieces(PathType? type)
|
||||
{
|
||||
var pointsInSegment = hitObject.Path.PointsInSegment(piece.ControlPoint);
|
||||
int indexInSegment = pointsInSegment.IndexOf(piece.ControlPoint);
|
||||
changeHandler?.BeginChange();
|
||||
|
||||
if (type?.Type == SplineType.PerfectCurve)
|
||||
foreach (var p in Pieces.Where(p => p.IsSelected.Value))
|
||||
{
|
||||
// Can't always create a circular arc out of 4 or more points,
|
||||
// so we split the segment into one 3-point circular arc segment
|
||||
// and one segment of the previous type.
|
||||
int thirdPointIndex = indexInSegment + 2;
|
||||
var pointsInSegment = hitObject.Path.PointsInSegment(p.ControlPoint);
|
||||
int indexInSegment = pointsInSegment.IndexOf(p.ControlPoint);
|
||||
|
||||
if (pointsInSegment.Count > thirdPointIndex + 1)
|
||||
pointsInSegment[thirdPointIndex].Type = pointsInSegment[0].Type;
|
||||
if (type?.Type == SplineType.PerfectCurve)
|
||||
{
|
||||
// Can't always create a circular arc out of 4 or more points,
|
||||
// so we split the segment into one 3-point circular arc segment
|
||||
// and one segment of the previous type.
|
||||
int thirdPointIndex = indexInSegment + 2;
|
||||
|
||||
if (pointsInSegment.Count > thirdPointIndex + 1)
|
||||
pointsInSegment[thirdPointIndex].Type = pointsInSegment[0].Type;
|
||||
}
|
||||
|
||||
hitObject.Path.ExpectedDistance.Value = null;
|
||||
p.ControlPoint.Type = type;
|
||||
}
|
||||
|
||||
hitObject.Path.ExpectedDistance.Value = null;
|
||||
piece.ControlPoint.Type = type;
|
||||
EnsureValidPathTypes();
|
||||
|
||||
changeHandler?.EndChange();
|
||||
}
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
@ -290,6 +383,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
private int draggedControlPointIndex;
|
||||
private HashSet<PathControlPoint> selectedControlPoints;
|
||||
|
||||
private List<MenuItem> curveTypeItems;
|
||||
|
||||
public void DragStarted(PathControlPoint controlPoint)
|
||||
{
|
||||
dragStartPositions = hitObject.Path.ControlPoints.Select(point => point.Position).ToArray();
|
||||
@ -386,22 +481,27 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
var splittablePieces = selectedPieces.Where(isSplittable).ToList();
|
||||
int splittableCount = splittablePieces.Count;
|
||||
|
||||
List<MenuItem> curveTypeItems = new List<MenuItem>();
|
||||
curveTypeItems = new List<MenuItem>();
|
||||
|
||||
if (!selectedPieces.Contains(Pieces[0]))
|
||||
foreach (PathType? type in path_types)
|
||||
{
|
||||
curveTypeItems.Add(createMenuItemForPathType(null));
|
||||
curveTypeItems.Add(new OsuMenuItemSpacer());
|
||||
// special inherit case
|
||||
if (type == null)
|
||||
{
|
||||
if (selectedPieces.Contains(Pieces[0]))
|
||||
continue;
|
||||
|
||||
curveTypeItems.Add(new OsuMenuItemSpacer());
|
||||
}
|
||||
|
||||
curveTypeItems.Add(createMenuItemForPathType(type));
|
||||
}
|
||||
|
||||
// todo: hide/disable items which aren't valid for selected points
|
||||
curveTypeItems.Add(createMenuItemForPathType(PathType.LINEAR));
|
||||
curveTypeItems.Add(createMenuItemForPathType(PathType.PERFECT_CURVE));
|
||||
curveTypeItems.Add(createMenuItemForPathType(PathType.BEZIER));
|
||||
curveTypeItems.Add(createMenuItemForPathType(PathType.BSpline(4)));
|
||||
|
||||
if (selectedPieces.Any(piece => piece.ControlPoint.Type?.Type == SplineType.Catmull))
|
||||
{
|
||||
curveTypeItems.Add(new OsuMenuItemSpacer());
|
||||
curveTypeItems.Add(createMenuItemForPathType(PathType.CATMULL));
|
||||
}
|
||||
|
||||
var menuItems = new List<MenuItem>
|
||||
{
|
||||
@ -424,35 +524,42 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
() => DeleteSelected())
|
||||
);
|
||||
|
||||
updateCurveMenuItems();
|
||||
|
||||
return menuItems.ToArray();
|
||||
|
||||
CurveTypeMenuItem createMenuItemForPathType(PathType? type) => new CurveTypeMenuItem(type, _ => updatePathTypeOfSelectedPieces(type));
|
||||
}
|
||||
}
|
||||
|
||||
private MenuItem createMenuItemForPathType(PathType? type)
|
||||
private void updateCurveMenuItems()
|
||||
{
|
||||
int totalCount = Pieces.Count(p => p.IsSelected.Value);
|
||||
int countOfState = Pieces.Where(p => p.IsSelected.Value).Count(p => p.ControlPoint.Type == type);
|
||||
if (curveTypeItems == null)
|
||||
return;
|
||||
|
||||
var item = new TernaryStateRadioMenuItem(type?.Description ?? "Inherit", MenuItemType.Standard, _ =>
|
||||
foreach (var item in curveTypeItems.OfType<CurveTypeMenuItem>())
|
||||
{
|
||||
changeHandler?.BeginChange();
|
||||
int totalCount = Pieces.Count(p => p.IsSelected.Value);
|
||||
int countOfState = Pieces.Where(p => p.IsSelected.Value).Count(p => p.ControlPoint.Type == item.PathType);
|
||||
|
||||
foreach (var p in Pieces.Where(p => p.IsSelected.Value))
|
||||
updatePathType(p, type);
|
||||
if (countOfState == totalCount)
|
||||
item.State.Value = TernaryState.True;
|
||||
else if (countOfState > 0)
|
||||
item.State.Value = TernaryState.Indeterminate;
|
||||
else
|
||||
item.State.Value = TernaryState.False;
|
||||
}
|
||||
}
|
||||
|
||||
EnsureValidPathTypes();
|
||||
private class CurveTypeMenuItem : TernaryStateRadioMenuItem
|
||||
{
|
||||
public readonly PathType? PathType;
|
||||
|
||||
changeHandler?.EndChange();
|
||||
});
|
||||
|
||||
if (countOfState == totalCount)
|
||||
item.State.Value = TernaryState.True;
|
||||
else if (countOfState > 0)
|
||||
item.State.Value = TernaryState.Indeterminate;
|
||||
else
|
||||
item.State.Value = TernaryState.False;
|
||||
|
||||
return item;
|
||||
public CurveTypeMenuItem(PathType? pathType, Action<TernaryState> action)
|
||||
: base(pathType?.Description ?? "Inherit", MenuItemType.Standard, action)
|
||||
{
|
||||
PathType = pathType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
private PathControlPoint segmentStart;
|
||||
private PathControlPoint cursor;
|
||||
private int currentSegmentLength;
|
||||
private bool usingCustomSegmentType;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
[CanBeNull]
|
||||
@ -149,21 +150,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
|
||||
case SliderPlacementState.ControlPoints:
|
||||
if (canPlaceNewControlPoint(out var lastPoint))
|
||||
{
|
||||
// Place a new point by detatching the current cursor.
|
||||
updateCursor();
|
||||
cursor = null;
|
||||
}
|
||||
placeNewControlPoint();
|
||||
else
|
||||
{
|
||||
// Transform the last point into a new segment.
|
||||
Debug.Assert(lastPoint != null);
|
||||
|
||||
segmentStart = lastPoint;
|
||||
segmentStart.Type = PathType.LINEAR;
|
||||
|
||||
currentSegmentLength = 1;
|
||||
}
|
||||
beginNewSegment(lastPoint);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -171,6 +160,18 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
return true;
|
||||
}
|
||||
|
||||
private void beginNewSegment(PathControlPoint lastPoint)
|
||||
{
|
||||
// Transform the last point into a new segment.
|
||||
Debug.Assert(lastPoint != null);
|
||||
|
||||
segmentStart = lastPoint;
|
||||
segmentStart.Type = PathType.LINEAR;
|
||||
|
||||
currentSegmentLength = 1;
|
||||
usingCustomSegmentType = false;
|
||||
}
|
||||
|
||||
protected override bool OnDragStart(DragStartEvent e)
|
||||
{
|
||||
if (e.Button != MouseButton.Left)
|
||||
@ -223,6 +224,72 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
||||
private static readonly PathType[] path_types =
|
||||
[
|
||||
PathType.LINEAR,
|
||||
PathType.BEZIER,
|
||||
PathType.PERFECT_CURVE,
|
||||
PathType.BSpline(4),
|
||||
];
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (e.Repeat)
|
||||
return false;
|
||||
|
||||
if (state != SliderPlacementState.ControlPoints)
|
||||
return false;
|
||||
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.S:
|
||||
{
|
||||
if (!canPlaceNewControlPoint(out _))
|
||||
return false;
|
||||
|
||||
placeNewControlPoint();
|
||||
var last = HitObject.Path.ControlPoints.Last(p => p != cursor);
|
||||
beginNewSegment(last);
|
||||
return true;
|
||||
}
|
||||
|
||||
case Key.Number1:
|
||||
case Key.Number2:
|
||||
case Key.Number3:
|
||||
case Key.Number4:
|
||||
{
|
||||
if (!e.AltPressed)
|
||||
return false;
|
||||
|
||||
usingCustomSegmentType = true;
|
||||
segmentStart.Type = path_types[e.Key - Key.Number1];
|
||||
controlPointVisualiser.EnsureValidPathTypes();
|
||||
return true;
|
||||
}
|
||||
|
||||
case Key.Tab:
|
||||
{
|
||||
usingCustomSegmentType = true;
|
||||
|
||||
int currentTypeIndex = segmentStart.Type.HasValue ? Array.IndexOf(path_types, segmentStart.Type.Value) : -1;
|
||||
|
||||
if (currentTypeIndex < 0 && e.ShiftPressed)
|
||||
currentTypeIndex = 0;
|
||||
|
||||
do
|
||||
{
|
||||
currentTypeIndex = (path_types.Length + currentTypeIndex + (e.ShiftPressed ? -1 : 1)) % path_types.Length;
|
||||
segmentStart.Type = path_types[currentTypeIndex];
|
||||
controlPointVisualiser.EnsureValidPathTypes();
|
||||
} while (segmentStart.Type != path_types[currentTypeIndex]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
@ -246,6 +313,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
|
||||
private void updatePathType()
|
||||
{
|
||||
if (usingCustomSegmentType)
|
||||
{
|
||||
controlPointVisualiser.EnsureValidPathTypes();
|
||||
return;
|
||||
}
|
||||
|
||||
if (state == SliderPlacementState.Drawing)
|
||||
{
|
||||
segmentStart.Type = PathType.BSpline(4);
|
||||
@ -316,6 +389,13 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
return lastPiece.IsHovered != true;
|
||||
}
|
||||
|
||||
private void placeNewControlPoint()
|
||||
{
|
||||
// Place a new point by detatching the current cursor.
|
||||
updateCursor();
|
||||
cursor = null;
|
||||
}
|
||||
|
||||
private void updateSlider()
|
||||
{
|
||||
if (state == SliderPlacementState.Drawing)
|
||||
|
@ -55,7 +55,21 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
[Resolved(CanBeNull = true)]
|
||||
private BindableBeatDivisor beatDivisor { get; set; }
|
||||
|
||||
public override Quad SelectionQuad => BodyPiece.ScreenSpaceDrawQuad;
|
||||
public override Quad SelectionQuad
|
||||
{
|
||||
get
|
||||
{
|
||||
var result = BodyPiece.ScreenSpaceDrawQuad.AABBFloat;
|
||||
|
||||
if (ControlPointVisualiser != null)
|
||||
{
|
||||
foreach (var piece in ControlPointVisualiser.Pieces)
|
||||
result = RectangleF.Union(result, piece.ScreenSpaceDrawQuad.AABBFloat);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly BindableList<PathControlPoint> controlPoints = new BindableList<PathControlPoint>();
|
||||
private readonly IBindable<int> pathVersion = new Bindable<int>();
|
||||
|
@ -1,17 +1,24 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Components.RadioButtons;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
@ -20,6 +27,9 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
[Resolved]
|
||||
private EditorBeatmap editorBeatmap { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private IExpandingContainer? expandingContainer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// X position of the grid's origin.
|
||||
/// </summary>
|
||||
@ -55,8 +65,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
/// </summary>
|
||||
public BindableFloat GridLinesRotation { get; } = new BindableFloat(0f)
|
||||
{
|
||||
MinValue = -45f,
|
||||
MaxValue = 45f,
|
||||
MinValue = -180f,
|
||||
MaxValue = 180f,
|
||||
Precision = 1f
|
||||
};
|
||||
|
||||
@ -72,10 +82,13 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
/// </summary>
|
||||
public Bindable<Vector2> SpacingVector { get; } = new Bindable<Vector2>();
|
||||
|
||||
public Bindable<PositionSnapGridType> GridType { get; } = new Bindable<PositionSnapGridType>();
|
||||
|
||||
private ExpandableSlider<float> startPositionXSlider = null!;
|
||||
private ExpandableSlider<float> startPositionYSlider = null!;
|
||||
private ExpandableSlider<float> spacingSlider = null!;
|
||||
private ExpandableSlider<float> gridLinesRotationSlider = null!;
|
||||
private EditorRadioButtonCollection gridTypeButtons = null!;
|
||||
|
||||
public OsuGridToolboxGroup()
|
||||
: base("grid")
|
||||
@ -109,6 +122,31 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
Current = GridLinesRotation,
|
||||
KeyboardStep = 1,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(0f, 10f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
gridTypeButtons = new EditorRadioButtonCollection
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Items = new[]
|
||||
{
|
||||
new RadioButton("Square",
|
||||
() => GridType.Value = PositionSnapGridType.Square,
|
||||
() => new SpriteIcon { Icon = FontAwesome.Regular.Square }),
|
||||
new RadioButton("Triangle",
|
||||
() => GridType.Value = PositionSnapGridType.Triangle,
|
||||
() => new OutlineTriangle(true, 20)),
|
||||
new RadioButton("Circle",
|
||||
() => GridType.Value = PositionSnapGridType.Circle,
|
||||
() => new SpriteIcon { Icon = FontAwesome.Regular.Circle }),
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Spacing.Value = editorBeatmap.BeatmapInfo.GridSize;
|
||||
@ -118,6 +156,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
gridTypeButtons.Items.First().Select();
|
||||
|
||||
StartPositionX.BindValueChanged(x =>
|
||||
{
|
||||
startPositionXSlider.ContractedLabelText = $"X: {x.NewValue:N0}";
|
||||
@ -145,6 +185,32 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
gridLinesRotationSlider.ContractedLabelText = $"R: {rotation.NewValue:#,0.##}";
|
||||
gridLinesRotationSlider.ExpandedLabelText = $"Rotation: {rotation.NewValue:#,0.##}";
|
||||
}, true);
|
||||
|
||||
expandingContainer?.Expanded.BindValueChanged(v =>
|
||||
{
|
||||
gridTypeButtons.FadeTo(v.NewValue ? 1f : 0f, 500, Easing.OutQuint);
|
||||
gridTypeButtons.BypassAutoSizeAxes = !v.NewValue ? Axes.Y : Axes.None;
|
||||
}, true);
|
||||
|
||||
GridType.BindValueChanged(v =>
|
||||
{
|
||||
GridLinesRotation.Disabled = v.NewValue == PositionSnapGridType.Circle;
|
||||
|
||||
switch (v.NewValue)
|
||||
{
|
||||
case PositionSnapGridType.Square:
|
||||
GridLinesRotation.Value = ((GridLinesRotation.Value + 405) % 90) - 45;
|
||||
GridLinesRotation.MinValue = -45;
|
||||
GridLinesRotation.MaxValue = 45;
|
||||
break;
|
||||
|
||||
case PositionSnapGridType.Triangle:
|
||||
GridLinesRotation.Value = ((GridLinesRotation.Value + 390) % 60) - 30;
|
||||
GridLinesRotation.MinValue = -30;
|
||||
GridLinesRotation.MaxValue = 30;
|
||||
break;
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
private void nextGridSize()
|
||||
@ -167,5 +233,42 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
|
||||
{
|
||||
}
|
||||
|
||||
public partial class OutlineTriangle : BufferedContainer
|
||||
{
|
||||
public OutlineTriangle(bool outlineOnly, float size)
|
||||
: base(cachedFrameBuffer: true)
|
||||
{
|
||||
Size = new Vector2(size);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new EquilateralTriangle { RelativeSizeAxes = Axes.Both },
|
||||
};
|
||||
|
||||
if (outlineOnly)
|
||||
{
|
||||
AddInternal(new EquilateralTriangle
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativePositionAxes = Axes.Y,
|
||||
Y = 0.48f,
|
||||
Colour = Color4.Black,
|
||||
Size = new Vector2(size - 7),
|
||||
Blending = BlendingParameters.None,
|
||||
});
|
||||
}
|
||||
|
||||
Blending = BlendingParameters.Additive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum PositionSnapGridType
|
||||
{
|
||||
Square,
|
||||
Triangle,
|
||||
Circle,
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ using System.Text.RegularExpressions;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -101,7 +100,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
// we may be entering the screen with a selection already active
|
||||
updateDistanceSnapGrid();
|
||||
|
||||
updatePositionSnapGrid();
|
||||
OsuGridToolboxGroup.GridType.BindValueChanged(updatePositionSnapGrid, true);
|
||||
|
||||
RightToolbox.AddRange(new Drawable[]
|
||||
{
|
||||
@ -116,18 +115,45 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
);
|
||||
}
|
||||
|
||||
private void updatePositionSnapGrid()
|
||||
private void updatePositionSnapGrid(ValueChangedEvent<PositionSnapGridType> obj)
|
||||
{
|
||||
if (positionSnapGrid != null)
|
||||
LayerBelowRuleset.Remove(positionSnapGrid, true);
|
||||
|
||||
var rectangularPositionSnapGrid = new RectangularPositionSnapGrid();
|
||||
switch (obj.NewValue)
|
||||
{
|
||||
case PositionSnapGridType.Square:
|
||||
var rectangularPositionSnapGrid = new RectangularPositionSnapGrid();
|
||||
|
||||
rectangularPositionSnapGrid.StartPosition.BindTo(OsuGridToolboxGroup.StartPosition);
|
||||
rectangularPositionSnapGrid.Spacing.BindTo(OsuGridToolboxGroup.SpacingVector);
|
||||
rectangularPositionSnapGrid.GridLineRotation.BindTo(OsuGridToolboxGroup.GridLinesRotation);
|
||||
rectangularPositionSnapGrid.Spacing.BindTo(OsuGridToolboxGroup.SpacingVector);
|
||||
rectangularPositionSnapGrid.GridLineRotation.BindTo(OsuGridToolboxGroup.GridLinesRotation);
|
||||
|
||||
positionSnapGrid = rectangularPositionSnapGrid;
|
||||
positionSnapGrid = rectangularPositionSnapGrid;
|
||||
break;
|
||||
|
||||
case PositionSnapGridType.Triangle:
|
||||
var triangularPositionSnapGrid = new TriangularPositionSnapGrid();
|
||||
|
||||
triangularPositionSnapGrid.Spacing.BindTo(OsuGridToolboxGroup.Spacing);
|
||||
triangularPositionSnapGrid.GridLineRotation.BindTo(OsuGridToolboxGroup.GridLinesRotation);
|
||||
|
||||
positionSnapGrid = triangularPositionSnapGrid;
|
||||
break;
|
||||
|
||||
case PositionSnapGridType.Circle:
|
||||
var circularPositionSnapGrid = new CircularPositionSnapGrid();
|
||||
|
||||
circularPositionSnapGrid.Spacing.BindTo(OsuGridToolboxGroup.Spacing);
|
||||
|
||||
positionSnapGrid = circularPositionSnapGrid;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(OsuGridToolboxGroup.GridType), OsuGridToolboxGroup.GridType, "Unsupported grid type.");
|
||||
}
|
||||
|
||||
// Bind the start position to the toolbox sliders.
|
||||
positionSnapGrid.StartPosition.BindTo(OsuGridToolboxGroup.StartPosition);
|
||||
|
||||
positionSnapGrid.RelativeSizeAxes = Axes.Both;
|
||||
LayerBelowRuleset.Add(positionSnapGrid);
|
||||
@ -194,7 +220,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
public override SnapResult FindSnappedPositionAndTime(Vector2 screenSpacePosition, SnapType snapType = SnapType.All)
|
||||
{
|
||||
if (snapType.HasFlagFast(SnapType.NearbyObjects) && snapToVisibleBlueprints(screenSpacePosition, out var snapResult))
|
||||
if (snapType.HasFlag(SnapType.NearbyObjects) && snapToVisibleBlueprints(screenSpacePosition, out var snapResult))
|
||||
{
|
||||
// In the case of snapping to nearby objects, a time value is not provided.
|
||||
// This matches the stable editor (which also uses current time), but with the introduction of time-snapping distance snap
|
||||
@ -204,7 +230,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
// We want to ensure that in this particular case, the time-snapping component of distance snap is still applied.
|
||||
// The easiest way to ensure this is to attempt application of distance snap after a nearby object is found, and copy over
|
||||
// the time value if the proposed positions are roughly the same.
|
||||
if (snapType.HasFlagFast(SnapType.RelativeGrids) && DistanceSnapProvider.DistanceSnapToggle.Value == TernaryState.True && distanceSnapGrid != null)
|
||||
if (snapType.HasFlag(SnapType.RelativeGrids) && DistanceSnapProvider.DistanceSnapToggle.Value == TernaryState.True && distanceSnapGrid != null)
|
||||
{
|
||||
(Vector2 distanceSnappedPosition, double distanceSnappedTime) = distanceSnapGrid.GetSnappedPosition(distanceSnapGrid.ToLocalSpace(snapResult.ScreenSpacePosition));
|
||||
if (Precision.AlmostEquals(distanceSnapGrid.ToScreenSpace(distanceSnappedPosition), snapResult.ScreenSpacePosition, 1))
|
||||
@ -216,7 +242,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
SnapResult result = base.FindSnappedPositionAndTime(screenSpacePosition, snapType);
|
||||
|
||||
if (snapType.HasFlagFast(SnapType.RelativeGrids))
|
||||
if (snapType.HasFlag(SnapType.RelativeGrids))
|
||||
{
|
||||
if (DistanceSnapProvider.DistanceSnapToggle.Value == TernaryState.True && distanceSnapGrid != null)
|
||||
{
|
||||
@ -227,7 +253,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
}
|
||||
}
|
||||
|
||||
if (snapType.HasFlagFast(SnapType.GlobalGrids))
|
||||
if (snapType.HasFlag(SnapType.GlobalGrids))
|
||||
{
|
||||
if (rectangularGridSnapToggle.Value == TernaryState.True)
|
||||
{
|
||||
|
@ -15,6 +15,13 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
public SliderCompositionTool()
|
||||
: base(nameof(Slider))
|
||||
{
|
||||
TooltipText = """
|
||||
Left click for new point.
|
||||
Left click twice or S key for new segment.
|
||||
Tab, Shift-Tab, or Alt-1~4 to change current segment type.
|
||||
Right click to finish.
|
||||
Click and drag for drawing mode.
|
||||
""";
|
||||
}
|
||||
|
||||
public override Drawable CreateIcon() => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders);
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
@ -70,55 +69,55 @@ namespace osu.Game.Rulesets.Osu
|
||||
|
||||
public override IEnumerable<Mod> ConvertFromLegacyMods(LegacyMods mods)
|
||||
{
|
||||
if (mods.HasFlagFast(LegacyMods.Nightcore))
|
||||
if (mods.HasFlag(LegacyMods.Nightcore))
|
||||
yield return new OsuModNightcore();
|
||||
else if (mods.HasFlagFast(LegacyMods.DoubleTime))
|
||||
else if (mods.HasFlag(LegacyMods.DoubleTime))
|
||||
yield return new OsuModDoubleTime();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Perfect))
|
||||
if (mods.HasFlag(LegacyMods.Perfect))
|
||||
yield return new OsuModPerfect();
|
||||
else if (mods.HasFlagFast(LegacyMods.SuddenDeath))
|
||||
else if (mods.HasFlag(LegacyMods.SuddenDeath))
|
||||
yield return new OsuModSuddenDeath();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Autopilot))
|
||||
if (mods.HasFlag(LegacyMods.Autopilot))
|
||||
yield return new OsuModAutopilot();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Cinema))
|
||||
if (mods.HasFlag(LegacyMods.Cinema))
|
||||
yield return new OsuModCinema();
|
||||
else if (mods.HasFlagFast(LegacyMods.Autoplay))
|
||||
else if (mods.HasFlag(LegacyMods.Autoplay))
|
||||
yield return new OsuModAutoplay();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Easy))
|
||||
if (mods.HasFlag(LegacyMods.Easy))
|
||||
yield return new OsuModEasy();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Flashlight))
|
||||
if (mods.HasFlag(LegacyMods.Flashlight))
|
||||
yield return new OsuModFlashlight();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.HalfTime))
|
||||
if (mods.HasFlag(LegacyMods.HalfTime))
|
||||
yield return new OsuModHalfTime();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.HardRock))
|
||||
if (mods.HasFlag(LegacyMods.HardRock))
|
||||
yield return new OsuModHardRock();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Hidden))
|
||||
if (mods.HasFlag(LegacyMods.Hidden))
|
||||
yield return new OsuModHidden();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.NoFail))
|
||||
if (mods.HasFlag(LegacyMods.NoFail))
|
||||
yield return new OsuModNoFail();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Relax))
|
||||
if (mods.HasFlag(LegacyMods.Relax))
|
||||
yield return new OsuModRelax();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.SpunOut))
|
||||
if (mods.HasFlag(LegacyMods.SpunOut))
|
||||
yield return new OsuModSpunOut();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Target))
|
||||
if (mods.HasFlag(LegacyMods.Target))
|
||||
yield return new OsuModTargetPractice();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.TouchDevice))
|
||||
if (mods.HasFlag(LegacyMods.TouchDevice))
|
||||
yield return new OsuModTouchDevice();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.ScoreV2))
|
||||
if (mods.HasFlag(LegacyMods.ScoreV2))
|
||||
yield return new ModScoreV2();
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Rendering;
|
||||
@ -243,14 +242,14 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
|
||||
originPosition = Vector2.Zero;
|
||||
|
||||
if (Source.TrailOrigin.HasFlagFast(Anchor.x1))
|
||||
if (Source.TrailOrigin.HasFlag(Anchor.x1))
|
||||
originPosition.X = 0.5f;
|
||||
else if (Source.TrailOrigin.HasFlagFast(Anchor.x2))
|
||||
else if (Source.TrailOrigin.HasFlag(Anchor.x2))
|
||||
originPosition.X = 1f;
|
||||
|
||||
if (Source.TrailOrigin.HasFlagFast(Anchor.y1))
|
||||
if (Source.TrailOrigin.HasFlag(Anchor.y1))
|
||||
originPosition.Y = 0.5f;
|
||||
else if (Source.TrailOrigin.HasFlagFast(Anchor.y2))
|
||||
else if (Source.TrailOrigin.HasFlag(Anchor.y2))
|
||||
originPosition.Y = 1f;
|
||||
|
||||
Source.parts.CopyTo(parts, 0);
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
@ -79,43 +78,43 @@ namespace osu.Game.Rulesets.Taiko
|
||||
|
||||
public override IEnumerable<Mod> ConvertFromLegacyMods(LegacyMods mods)
|
||||
{
|
||||
if (mods.HasFlagFast(LegacyMods.Nightcore))
|
||||
if (mods.HasFlag(LegacyMods.Nightcore))
|
||||
yield return new TaikoModNightcore();
|
||||
else if (mods.HasFlagFast(LegacyMods.DoubleTime))
|
||||
else if (mods.HasFlag(LegacyMods.DoubleTime))
|
||||
yield return new TaikoModDoubleTime();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Perfect))
|
||||
if (mods.HasFlag(LegacyMods.Perfect))
|
||||
yield return new TaikoModPerfect();
|
||||
else if (mods.HasFlagFast(LegacyMods.SuddenDeath))
|
||||
else if (mods.HasFlag(LegacyMods.SuddenDeath))
|
||||
yield return new TaikoModSuddenDeath();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Cinema))
|
||||
if (mods.HasFlag(LegacyMods.Cinema))
|
||||
yield return new TaikoModCinema();
|
||||
else if (mods.HasFlagFast(LegacyMods.Autoplay))
|
||||
else if (mods.HasFlag(LegacyMods.Autoplay))
|
||||
yield return new TaikoModAutoplay();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Easy))
|
||||
if (mods.HasFlag(LegacyMods.Easy))
|
||||
yield return new TaikoModEasy();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Flashlight))
|
||||
if (mods.HasFlag(LegacyMods.Flashlight))
|
||||
yield return new TaikoModFlashlight();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.HalfTime))
|
||||
if (mods.HasFlag(LegacyMods.HalfTime))
|
||||
yield return new TaikoModHalfTime();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.HardRock))
|
||||
if (mods.HasFlag(LegacyMods.HardRock))
|
||||
yield return new TaikoModHardRock();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Hidden))
|
||||
if (mods.HasFlag(LegacyMods.Hidden))
|
||||
yield return new TaikoModHidden();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.NoFail))
|
||||
if (mods.HasFlag(LegacyMods.NoFail))
|
||||
yield return new TaikoModNoFail();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.Relax))
|
||||
if (mods.HasFlag(LegacyMods.Relax))
|
||||
yield return new TaikoModRelax();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.ScoreV2))
|
||||
if (mods.HasFlag(LegacyMods.ScoreV2))
|
||||
yield return new ModScoreV2();
|
||||
}
|
||||
|
||||
|
@ -528,8 +528,17 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
Assert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
|
||||
Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[3]).LookupNames.First());
|
||||
|
||||
// The control point at the end time of the slider should be applied
|
||||
Assert.AreEqual("Gameplay/soft-hitnormal8", getTestableSampleInfo(hitObjects[4]).LookupNames.First());
|
||||
// The fourth object is a slider.
|
||||
// `Samples` of a slider are presumed to control the volume of sounds that last the entire duration of the slider
|
||||
// (such as ticks, slider slide sounds, etc.)
|
||||
// Thus, the point of query of control points used for `Samples` is just beyond the start time of the slider.
|
||||
Assert.AreEqual("Gameplay/soft-hitnormal11", getTestableSampleInfo(hitObjects[4]).LookupNames.First());
|
||||
|
||||
// That said, the `NodeSamples` of the slider are responsible for the sounds of the slider's head / tail / repeats / large ticks etc.
|
||||
// Therefore, they should be read at the time instant correspondent to the given node.
|
||||
// This means that the tail should use bank 8 rather than 11.
|
||||
Assert.AreEqual("Gameplay/soft-hitnormal11", ((ConvertSlider)hitObjects[4]).NodeSamples[0][0].LookupNames.First());
|
||||
Assert.AreEqual("Gameplay/soft-hitnormal8", ((ConvertSlider)hitObjects[4]).NodeSamples[1][0].LookupNames.First());
|
||||
}
|
||||
|
||||
static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.Samples[0];
|
||||
|
@ -71,6 +71,35 @@ namespace osu.Game.Tests.Database
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSubscriptionInitialChangeSetNull()
|
||||
{
|
||||
ChangeSet? firstChanges = null;
|
||||
int receivedChangesCount = 0;
|
||||
|
||||
RunTestWithRealm((realm, _) =>
|
||||
{
|
||||
var registration = realm.RegisterForNotifications(r => r.All<BeatmapSetInfo>(), onChanged);
|
||||
|
||||
realm.WriteAsync(r => r.Add(TestResources.CreateTestBeatmapSetInfo())).WaitSafely();
|
||||
|
||||
realm.Run(r => r.Refresh());
|
||||
|
||||
Assert.That(receivedChangesCount, Is.EqualTo(1));
|
||||
Assert.That(firstChanges, Is.Null);
|
||||
|
||||
registration.Dispose();
|
||||
});
|
||||
|
||||
void onChanged(IRealmCollection<BeatmapSetInfo> sender, ChangeSet? changes)
|
||||
{
|
||||
if (receivedChangesCount == 0)
|
||||
firstChanges = changes;
|
||||
|
||||
receivedChangesCount++;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSubscriptionWithAsyncWrite()
|
||||
{
|
||||
|
235
osu.Game.Tests/Editing/Checks/CheckTitleMarkersTest.cs
Normal file
235
osu.Game.Tests/Editing/Checks/CheckTitleMarkersTest.cs
Normal file
@ -0,0 +1,235 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Checks;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
|
||||
namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
[TestFixture]
|
||||
public class CheckTitleMarkersTest
|
||||
{
|
||||
private CheckTitleMarkers check = null!;
|
||||
|
||||
private IBeatmap beatmap = null!;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
check = new CheckTitleMarkers();
|
||||
|
||||
beatmap = new Beatmap<HitObject>
|
||||
{
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = "Egao no Kanata",
|
||||
TitleUnicode = "エガオノカナタ"
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNoTitleMarkers()
|
||||
{
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
Assert.That(issues, Has.Count.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTvSizeMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (TV Size)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (TV Size)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMalformedTvSizeMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (tv size)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (tv size)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(2));
|
||||
Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGameVerMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (Game Ver.)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (Game Ver.)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMalformedGameVerMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (game ver.)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (game ver.)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(2));
|
||||
Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShortVerMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (Short Ver.)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (Short Ver.)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMalformedShortVerMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (short ver.)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (short ver.)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(2));
|
||||
Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCutVerMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (Cut Ver.)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (Cut Ver.)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMalformedCutVerMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (cut ver.)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (cut ver.)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(2));
|
||||
Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSpedUpVerMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (Sped Up Ver.)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (Sped Up Ver.)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMalformedSpedUpVerMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (sped up ver.)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (sped up ver.)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(2));
|
||||
Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNightcoreMixMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (Nightcore Mix)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (Nightcore Mix)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMalformedNightcoreMixMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (nightcore mix)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (nightcore mix)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(2));
|
||||
Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSpedUpCutVerMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (Sped Up & Cut Ver.)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (Sped Up & Cut Ver.)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMalformedSpedUpCutVerMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (sped up & cut ver.)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (sped up & cut ver.)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(2));
|
||||
Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNightcoreCutVerMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (Nightcore & Cut Ver.)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (Nightcore & Cut Ver.)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMalformedNightcoreCutVerMarker()
|
||||
{
|
||||
beatmap.BeatmapInfo.Metadata.Title += " (nightcore & cut ver.)";
|
||||
beatmap.BeatmapInfo.Metadata.TitleUnicode += " (nightcore & cut ver.)";
|
||||
|
||||
var issues = check.Run(getContext(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(2));
|
||||
Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker));
|
||||
}
|
||||
|
||||
private BeatmapVerifierContext getContext(IBeatmap beatmap)
|
||||
{
|
||||
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||
}
|
||||
}
|
||||
}
|
43
osu.Game.Tests/Editing/EditorTimestampParserTest.cs
Normal file
43
osu.Game.Tests/Editing/EditorTimestampParserTest.cs
Normal file
@ -0,0 +1,43 @@
|
||||
// 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;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
|
||||
namespace osu.Game.Tests.Editing
|
||||
{
|
||||
[TestFixture]
|
||||
public class EditorTimestampParserTest
|
||||
{
|
||||
private static readonly object?[][] test_cases =
|
||||
{
|
||||
new object?[] { ":", false, null, null },
|
||||
new object?[] { "1", true, TimeSpan.FromMilliseconds(1), null },
|
||||
new object?[] { "99", true, TimeSpan.FromMilliseconds(99), null },
|
||||
new object?[] { "320000", true, TimeSpan.FromMilliseconds(320000), null },
|
||||
new object?[] { "1:2", true, new TimeSpan(0, 0, 1, 2), null },
|
||||
new object?[] { "1:02", true, new TimeSpan(0, 0, 1, 2), null },
|
||||
new object?[] { "1:92", false, null, null },
|
||||
new object?[] { "1:002", false, null, null },
|
||||
new object?[] { "1:02:3", true, new TimeSpan(0, 0, 1, 2, 3), null },
|
||||
new object?[] { "1:02:300", true, new TimeSpan(0, 0, 1, 2, 300), null },
|
||||
new object?[] { "1:02:3000", false, null, null },
|
||||
new object?[] { "1:02:300 ()", false, null, null },
|
||||
new object?[] { "1:02:300 (1,2,3)", true, new TimeSpan(0, 0, 1, 2, 300), "1,2,3" },
|
||||
};
|
||||
|
||||
[TestCaseSource(nameof(test_cases))]
|
||||
public void TestTryParse(string timestamp, bool expectedSuccess, TimeSpan? expectedParsedTime, string? expectedSelection)
|
||||
{
|
||||
bool actualSuccess = EditorTimestampParser.TryParse(timestamp, out var actualParsedTime, out string? actualSelection);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(actualSuccess, Is.EqualTo(expectedSuccess));
|
||||
Assert.That(actualParsedTime, Is.EqualTo(expectedParsedTime));
|
||||
Assert.That(actualSelection, Is.EqualTo(expectedSelection));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -21,10 +21,11 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
};
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -38,14 +39,15 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -59,15 +61,16 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
new HitCircle { StartTime = 2000 },
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -81,14 +84,15 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HoldNote { StartTime = 1000, Duration = 10000 },
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new ManiaRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -102,16 +106,17 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HoldNote { StartTime = 1000, Duration = 10000 },
|
||||
new Note { StartTime = 2000 },
|
||||
new Note { StartTime = 12000 },
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new ManiaRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -125,15 +130,16 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
new HitCircle { StartTime = 5000 },
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -152,9 +158,10 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
@ -165,7 +172,7 @@ namespace osu.Game.Tests.Editing
|
||||
new BreakPeriod(1200, 4000),
|
||||
new BreakPeriod(5200, 8000),
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -184,9 +191,10 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
@ -197,7 +205,7 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
new BreakPeriod(1200, 8000),
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -218,9 +226,10 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1100 },
|
||||
@ -230,7 +239,7 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
new BreakPeriod(1200, 8000),
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -249,9 +258,10 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
@ -262,7 +272,7 @@ namespace osu.Game.Tests.Editing
|
||||
new ManualBreakPeriod(1200, 4000),
|
||||
new ManualBreakPeriod(5200, 8000),
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -283,9 +293,10 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
@ -296,7 +307,7 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
new ManualBreakPeriod(1200, 8000),
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -317,9 +328,10 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
@ -329,7 +341,7 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
new ManualBreakPeriod(1200, 8800),
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -348,9 +360,10 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
@ -360,7 +373,7 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
new BreakPeriod(10000, 15000),
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -374,9 +387,10 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
@ -386,7 +400,7 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
new ManualBreakPeriod(10000, 15000),
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -400,9 +414,10 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HoldNote { StartTime = 1000, EndTime = 20000 },
|
||||
@ -412,7 +427,7 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
new ManualBreakPeriod(10000, 15000),
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -426,9 +441,10 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 10000 },
|
||||
@ -438,7 +454,7 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
new BreakPeriod(0, 9000),
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
@ -452,9 +468,10 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
var beatmap = new EditorBeatmap(new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 10000 },
|
||||
@ -464,7 +481,7 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
new ManualBreakPeriod(0, 9000),
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
|
22
osu.Game.Tests/Resources/per-slider-node-sample-settings.osu
Normal file
22
osu.Game.Tests/Resources/per-slider-node-sample-settings.osu
Normal file
@ -0,0 +1,22 @@
|
||||
osu file format v128
|
||||
|
||||
[General]
|
||||
SampleSet: Normal
|
||||
|
||||
[TimingPoints]
|
||||
15,1000,4,1,0,100,1,0
|
||||
2271,-100,4,1,0,5,0,0
|
||||
6021,-100,4,1,0,100,0,0
|
||||
8515,-100,4,1,0,5,0,0
|
||||
12765,-100,4,1,0,100,0,0
|
||||
14764,-100,4,1,0,5,0,0
|
||||
14770,-100,4,1,0,50,0,0
|
||||
17264,-100,4,1,0,5,0,0
|
||||
17270,-100,4,1,0,50,0,0
|
||||
22264,-100,4,1,0,100,0,0
|
||||
|
||||
[HitObjects]
|
||||
113,54,2265,6,0,L|422:55,1,300,0|0,1:0|1:0,1:0:0:0:
|
||||
82,206,6015,2,0,L|457:204,1,350,0|0,2:0|2:0,2:0:0:0:
|
||||
75,310,10265,2,0,L|435:312,1,350,0|0,3:0|3:0,3:0:0:0:
|
||||
75,310,14764,2,0,L|435:312,3,350,0|0|0|0,3:0|3:0|3:0|3:0,3:0:0:0:
|
@ -11,10 +11,11 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.OnlinePlay.DailyChallenge;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Screens.OnlinePlay.DailyChallenge.Events;
|
||||
|
||||
namespace osu.Game.Tests.Visual.DailyChallenge
|
||||
{
|
||||
@ -129,19 +130,27 @@ namespace osu.Game.Tests.Visual.DailyChallenge
|
||||
});
|
||||
AddStep("add normal score", () =>
|
||||
{
|
||||
var testScore = TestResources.CreateTestScoreInfo();
|
||||
testScore.TotalScore = RNG.Next(1_000_000);
|
||||
var ev = new NewScoreEvent(1, new APIUser
|
||||
{
|
||||
Id = 2,
|
||||
Username = "peppy",
|
||||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
}, RNG.Next(1_000_000), null);
|
||||
|
||||
feed.AddNewScore(new DailyChallengeEventFeed.NewScoreEvent(testScore, null));
|
||||
breakdown.AddNewScore(testScore);
|
||||
feed.AddNewScore(ev);
|
||||
breakdown.AddNewScore(ev);
|
||||
});
|
||||
AddStep("add new user best", () =>
|
||||
{
|
||||
var testScore = TestResources.CreateTestScoreInfo();
|
||||
testScore.TotalScore = RNG.Next(1_000_000);
|
||||
var ev = new NewScoreEvent(1, new APIUser
|
||||
{
|
||||
Id = 2,
|
||||
Username = "peppy",
|
||||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
}, RNG.Next(1_000_000), RNG.Next(1, 1000));
|
||||
|
||||
feed.AddNewScore(new DailyChallengeEventFeed.NewScoreEvent(testScore, RNG.Next(1, 1000)));
|
||||
breakdown.AddNewScore(testScore);
|
||||
feed.AddNewScore(ev);
|
||||
breakdown.AddNewScore(ev);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,10 @@ using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.OnlinePlay.DailyChallenge;
|
||||
using osu.Game.Screens.OnlinePlay.DailyChallenge.Events;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
namespace osu.Game.Tests.Visual.DailyChallenge
|
||||
@ -50,26 +52,41 @@ namespace osu.Game.Tests.Visual.DailyChallenge
|
||||
|
||||
AddStep("add normal score", () =>
|
||||
{
|
||||
var testScore = TestResources.CreateTestScoreInfo();
|
||||
testScore.TotalScore = RNG.Next(1_000_000);
|
||||
var ev = new NewScoreEvent(1, new APIUser
|
||||
{
|
||||
Id = 2,
|
||||
Username = "peppy",
|
||||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
}, RNG.Next(1_000_000), null);
|
||||
|
||||
feed.AddNewScore(new DailyChallengeEventFeed.NewScoreEvent(testScore, null));
|
||||
feed.AddNewScore(ev);
|
||||
});
|
||||
|
||||
AddStep("add new user best", () =>
|
||||
{
|
||||
var ev = new NewScoreEvent(1, new APIUser
|
||||
{
|
||||
Id = 2,
|
||||
Username = "peppy",
|
||||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
}, RNG.Next(1_000_000), RNG.Next(11, 1000));
|
||||
|
||||
var testScore = TestResources.CreateTestScoreInfo();
|
||||
testScore.TotalScore = RNG.Next(1_000_000);
|
||||
|
||||
feed.AddNewScore(new DailyChallengeEventFeed.NewScoreEvent(testScore, RNG.Next(1, 1000)));
|
||||
feed.AddNewScore(ev);
|
||||
});
|
||||
|
||||
AddStep("add top 10 score", () =>
|
||||
{
|
||||
var testScore = TestResources.CreateTestScoreInfo();
|
||||
testScore.TotalScore = RNG.Next(1_000_000);
|
||||
var ev = new NewScoreEvent(1, new APIUser
|
||||
{
|
||||
Id = 2,
|
||||
Username = "peppy",
|
||||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
}, RNG.Next(1_000_000), RNG.Next(1, 10));
|
||||
|
||||
feed.AddNewScore(new DailyChallengeEventFeed.NewScoreEvent(testScore, RNG.Next(1, 10)));
|
||||
feed.AddNewScore(ev);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,10 @@ using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.OnlinePlay.DailyChallenge;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Screens.OnlinePlay.DailyChallenge.Events;
|
||||
|
||||
namespace osu.Game.Tests.Visual.DailyChallenge
|
||||
{
|
||||
@ -51,10 +52,14 @@ namespace osu.Game.Tests.Visual.DailyChallenge
|
||||
AddStep("set initial data", () => breakdown.SetInitialCounts([1, 4, 9, 16, 25, 36, 49, 36, 25, 16, 9, 4, 1]));
|
||||
AddStep("add new score", () =>
|
||||
{
|
||||
var testScore = TestResources.CreateTestScoreInfo();
|
||||
testScore.TotalScore = RNG.Next(1_000_000);
|
||||
var ev = new NewScoreEvent(1, new APIUser
|
||||
{
|
||||
Id = 2,
|
||||
Username = "peppy",
|
||||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
}, RNG.Next(1_000_000), null);
|
||||
|
||||
breakdown.AddNewScore(testScore);
|
||||
breakdown.AddNewScore(ev);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,9 @@ using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Catch;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Taiko;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Storyboards;
|
||||
@ -169,6 +171,24 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddAssert("stack empty", () => Stack.CurrentScreen == null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSwitchToDifficultyOfAnotherRuleset()
|
||||
{
|
||||
BeatmapInfo targetDifficulty = null;
|
||||
|
||||
AddAssert("ruleset is catch", () => Ruleset.Value.CreateInstance() is CatchRuleset);
|
||||
|
||||
AddStep("set taiko difficulty", () => targetDifficulty = importedBeatmapSet.Beatmaps.First(b => b.Ruleset.OnlineID == 1));
|
||||
switchToDifficulty(() => targetDifficulty);
|
||||
confirmEditingBeatmap(() => targetDifficulty);
|
||||
|
||||
AddAssert("ruleset switched to taiko", () => Ruleset.Value.CreateInstance() is TaikoRuleset);
|
||||
|
||||
AddStep("exit editor forcefully", () => Stack.Exit());
|
||||
// ensure editor loader didn't resume.
|
||||
AddAssert("stack empty", () => Stack.CurrentScreen == null);
|
||||
}
|
||||
|
||||
private void switchToDifficulty(Func<BeatmapInfo> difficulty) => AddStep("switch to difficulty", () => Editor.SwitchToDifficulty(difficulty.Invoke()));
|
||||
|
||||
private void confirmEditingBeatmap(Func<BeatmapInfo> targetDifficulty)
|
||||
|
@ -1,10 +1,13 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Components;
|
||||
@ -19,9 +22,10 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
[Cached]
|
||||
private EditorBeatmap editorBeatmap = new EditorBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo));
|
||||
|
||||
public TestSceneEditorClock()
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
Add(new FillFlowContainer
|
||||
AddStep("create content", () => Add(new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
@ -39,19 +43,17 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
Size = new Vector2(200, 100)
|
||||
}
|
||||
}
|
||||
}));
|
||||
AddStep("set working beatmap", () =>
|
||||
{
|
||||
Beatmap.Disabled = false;
|
||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
// ensure that music controller does not change this beatmap due to it
|
||||
// completing naturally as part of the test.
|
||||
Beatmap.Disabled = true;
|
||||
});
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
// ensure that music controller does not change this beatmap due to it
|
||||
// completing naturally as part of the test.
|
||||
Beatmap.Disabled = true;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStopAtTrackEnd()
|
||||
{
|
||||
@ -102,6 +104,29 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddUntilStep("time is clamped to track length", () => EditorClock.CurrentTime, () => Is.EqualTo(EditorClock.TrackLength));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCurrentTimeDoubleTransform()
|
||||
{
|
||||
AddAssert("seek smoothly twice and current time is accurate", () =>
|
||||
{
|
||||
EditorClock.SeekSmoothlyTo(1000);
|
||||
EditorClock.SeekSmoothlyTo(2000);
|
||||
return 2000 == EditorClock.CurrentTimeAccurate;
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAdjustmentsRemovedOnDisposal()
|
||||
{
|
||||
AddStep("reset clock", () => EditorClock.Seek(0));
|
||||
|
||||
AddStep("set 0.25x speed", () => this.ChildrenOfType<OsuTabControl<double>>().First().Current.Value = 0.25);
|
||||
AddAssert("track has 0.25x tempo", () => Beatmap.Value.Track.AggregateTempo.Value, () => Is.EqualTo(0.25));
|
||||
|
||||
AddStep("dispose playback control", () => Clear(disposeChildren: true));
|
||||
AddAssert("track has 1x tempo", () => Beatmap.Value.Track.AggregateTempo.Value, () => Is.EqualTo(1));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
Beatmap.Disabled = false;
|
||||
|
@ -16,6 +16,7 @@ using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Components.Timelines.Summary;
|
||||
@ -224,6 +225,116 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddAssert("time reverted to 00:01:00", () => EditorClock.CurrentTime, () => Is.EqualTo(60_000));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAutoplayToggle()
|
||||
{
|
||||
AddStep("click test gameplay button", () =>
|
||||
{
|
||||
var button = Editor.ChildrenOfType<TestGameplayButton>().Single();
|
||||
|
||||
InputManager.MoveMouseTo(button);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
EditorPlayer editorPlayer = null;
|
||||
AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null);
|
||||
AddUntilStep("no replay active", () => editorPlayer.ChildrenOfType<DrawableRuleset>().Single().ReplayScore, () => Is.Null);
|
||||
AddStep("press Tab", () => InputManager.Key(Key.Tab));
|
||||
AddUntilStep("replay active", () => editorPlayer.ChildrenOfType<DrawableRuleset>().Single().ReplayScore, () => Is.Not.Null);
|
||||
AddStep("press Tab", () => InputManager.Key(Key.Tab));
|
||||
AddUntilStep("no replay active", () => editorPlayer.ChildrenOfType<DrawableRuleset>().Single().ReplayScore, () => Is.Null);
|
||||
AddStep("exit player", () => editorPlayer.Exit());
|
||||
AddUntilStep("current screen is editor", () => Stack.CurrentScreen is Editor);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestQuickPause()
|
||||
{
|
||||
AddStep("click test gameplay button", () =>
|
||||
{
|
||||
var button = Editor.ChildrenOfType<TestGameplayButton>().Single();
|
||||
|
||||
InputManager.MoveMouseTo(button);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
EditorPlayer editorPlayer = null;
|
||||
AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null);
|
||||
AddUntilStep("clock running", () => editorPlayer.ChildrenOfType<GameplayClockContainer>().Single().IsPaused.Value, () => Is.False);
|
||||
AddStep("press Ctrl-P", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ControlLeft);
|
||||
InputManager.Key(Key.P);
|
||||
InputManager.ReleaseKey(Key.ControlLeft);
|
||||
});
|
||||
AddUntilStep("clock not running", () => editorPlayer.ChildrenOfType<GameplayClockContainer>().Single().IsPaused.Value, () => Is.True);
|
||||
AddStep("press Ctrl-P", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ControlLeft);
|
||||
InputManager.Key(Key.P);
|
||||
InputManager.ReleaseKey(Key.ControlLeft);
|
||||
});
|
||||
AddUntilStep("clock running", () => editorPlayer.ChildrenOfType<GameplayClockContainer>().Single().IsPaused.Value, () => Is.False);
|
||||
AddStep("exit player", () => editorPlayer.Exit());
|
||||
AddUntilStep("current screen is editor", () => Stack.CurrentScreen is Editor);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestQuickExitAtInitialPosition()
|
||||
{
|
||||
AddStep("seek to 00:01:00", () => EditorClock.Seek(60_000));
|
||||
AddStep("click test gameplay button", () =>
|
||||
{
|
||||
var button = Editor.ChildrenOfType<TestGameplayButton>().Single();
|
||||
|
||||
InputManager.MoveMouseTo(button);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
EditorPlayer editorPlayer = null;
|
||||
AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null);
|
||||
|
||||
GameplayClockContainer gameplayClockContainer = null;
|
||||
AddStep("fetch gameplay clock", () => gameplayClockContainer = editorPlayer.ChildrenOfType<GameplayClockContainer>().First());
|
||||
AddUntilStep("gameplay clock running", () => gameplayClockContainer.IsRunning);
|
||||
// when the gameplay test is entered, the clock is expected to continue from where it was in the main editor...
|
||||
AddAssert("gameplay time past 00:01:00", () => gameplayClockContainer.CurrentTime >= 60_000);
|
||||
|
||||
AddWaitStep("wait some", 5);
|
||||
|
||||
AddStep("exit player", () => InputManager.PressKey(Key.F1));
|
||||
AddUntilStep("current screen is editor", () => Stack.CurrentScreen is Editor);
|
||||
AddAssert("time reverted to 00:01:00", () => EditorClock.CurrentTime, () => Is.EqualTo(60_000));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestQuickExitAtCurrentPosition()
|
||||
{
|
||||
AddStep("seek to 00:01:00", () => EditorClock.Seek(60_000));
|
||||
AddStep("click test gameplay button", () =>
|
||||
{
|
||||
var button = Editor.ChildrenOfType<TestGameplayButton>().Single();
|
||||
|
||||
InputManager.MoveMouseTo(button);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
EditorPlayer editorPlayer = null;
|
||||
AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null);
|
||||
|
||||
GameplayClockContainer gameplayClockContainer = null;
|
||||
AddStep("fetch gameplay clock", () => gameplayClockContainer = editorPlayer.ChildrenOfType<GameplayClockContainer>().First());
|
||||
AddUntilStep("gameplay clock running", () => gameplayClockContainer.IsRunning);
|
||||
// when the gameplay test is entered, the clock is expected to continue from where it was in the main editor...
|
||||
AddAssert("gameplay time past 00:01:00", () => gameplayClockContainer.CurrentTime >= 60_000);
|
||||
|
||||
AddWaitStep("wait some", 5);
|
||||
|
||||
AddStep("exit player", () => InputManager.PressKey(Key.F2));
|
||||
AddUntilStep("current screen is editor", () => Stack.CurrentScreen is Editor);
|
||||
AddAssert("time moved forward", () => EditorClock.CurrentTime, () => Is.GreaterThan(60_000));
|
||||
}
|
||||
|
||||
public override void TearDownSteps()
|
||||
{
|
||||
base.TearDownSteps();
|
||||
|
@ -402,6 +402,107 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
void checkPlacementSample(string expected) => AddAssert($"Placement sample is {expected}", () => EditorBeatmap.PlacementObject.Value.Samples.First().Bank, () => Is.EqualTo(expected));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHotkeysAffectNodeSamples()
|
||||
{
|
||||
AddStep("add slider", () =>
|
||||
{
|
||||
EditorBeatmap.Add(new Slider
|
||||
{
|
||||
Position = new Vector2(256, 256),
|
||||
StartTime = 1000,
|
||||
Path = new SliderPath(new[] { new PathControlPoint(Vector2.Zero), new PathControlPoint(new Vector2(250, 0)) }),
|
||||
Samples =
|
||||
{
|
||||
new HitSampleInfo(HitSampleInfo.HIT_NORMAL)
|
||||
},
|
||||
NodeSamples = new List<IList<HitSampleInfo>>
|
||||
{
|
||||
new List<HitSampleInfo>
|
||||
{
|
||||
new HitSampleInfo(HitSampleInfo.HIT_NORMAL, bank: HitSampleInfo.BANK_DRUM),
|
||||
new HitSampleInfo(HitSampleInfo.HIT_CLAP, bank: HitSampleInfo.BANK_DRUM),
|
||||
},
|
||||
new List<HitSampleInfo>
|
||||
{
|
||||
new HitSampleInfo(HitSampleInfo.HIT_NORMAL, bank: HitSampleInfo.BANK_SOFT),
|
||||
new HitSampleInfo(HitSampleInfo.HIT_WHISTLE, bank: HitSampleInfo.BANK_SOFT),
|
||||
},
|
||||
}
|
||||
});
|
||||
});
|
||||
AddStep("select everything", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
|
||||
|
||||
AddStep("add clap addition", () => InputManager.Key(Key.R));
|
||||
|
||||
hitObjectHasSampleBank(0, HitSampleInfo.BANK_NORMAL);
|
||||
hitObjectHasSamples(0, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_CLAP);
|
||||
|
||||
hitObjectHasSampleBank(1, HitSampleInfo.BANK_SOFT);
|
||||
hitObjectHasSamples(1, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_CLAP);
|
||||
|
||||
hitObjectHasSampleBank(2, HitSampleInfo.BANK_NORMAL);
|
||||
hitObjectHasSamples(2, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_CLAP);
|
||||
hitObjectNodeHasSampleBank(2, 0, HitSampleInfo.BANK_DRUM);
|
||||
hitObjectNodeHasSamples(2, 0, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_CLAP);
|
||||
hitObjectNodeHasSampleBank(2, 1, HitSampleInfo.BANK_SOFT);
|
||||
hitObjectNodeHasSamples(2, 1, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_WHISTLE, HitSampleInfo.HIT_CLAP);
|
||||
|
||||
AddStep("remove clap addition", () => InputManager.Key(Key.R));
|
||||
|
||||
hitObjectHasSampleBank(0, HitSampleInfo.BANK_NORMAL);
|
||||
hitObjectHasSamples(0, HitSampleInfo.HIT_NORMAL);
|
||||
|
||||
hitObjectHasSampleBank(1, HitSampleInfo.BANK_SOFT);
|
||||
hitObjectHasSamples(1, HitSampleInfo.HIT_NORMAL);
|
||||
|
||||
hitObjectHasSampleBank(2, HitSampleInfo.BANK_NORMAL);
|
||||
hitObjectHasSamples(2, HitSampleInfo.HIT_NORMAL);
|
||||
hitObjectNodeHasSampleBank(2, 0, HitSampleInfo.BANK_DRUM);
|
||||
hitObjectNodeHasSamples(2, 0, HitSampleInfo.HIT_NORMAL);
|
||||
hitObjectNodeHasSampleBank(2, 1, HitSampleInfo.BANK_SOFT);
|
||||
hitObjectNodeHasSamples(2, 1, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_WHISTLE);
|
||||
|
||||
AddStep("set drum bank", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.LShift);
|
||||
InputManager.Key(Key.R);
|
||||
InputManager.ReleaseKey(Key.LShift);
|
||||
});
|
||||
|
||||
hitObjectHasSampleBank(0, HitSampleInfo.BANK_DRUM);
|
||||
hitObjectHasSamples(0, HitSampleInfo.HIT_NORMAL);
|
||||
|
||||
hitObjectHasSampleBank(1, HitSampleInfo.BANK_DRUM);
|
||||
hitObjectHasSamples(1, HitSampleInfo.HIT_NORMAL);
|
||||
|
||||
hitObjectHasSampleBank(2, HitSampleInfo.BANK_DRUM);
|
||||
hitObjectHasSamples(2, HitSampleInfo.HIT_NORMAL);
|
||||
hitObjectNodeHasSampleBank(2, 0, HitSampleInfo.BANK_DRUM);
|
||||
hitObjectNodeHasSamples(2, 0, HitSampleInfo.HIT_NORMAL);
|
||||
hitObjectNodeHasSampleBank(2, 1, HitSampleInfo.BANK_DRUM);
|
||||
hitObjectNodeHasSamples(2, 1, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_WHISTLE);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectingObjectDoesNotMutateSamples()
|
||||
{
|
||||
clickSamplePiece(0);
|
||||
toggleAdditionViaPopover(1);
|
||||
setAdditionBankViaPopover(HitSampleInfo.BANK_SOFT);
|
||||
dismissPopover();
|
||||
|
||||
hitObjectHasSamples(0, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_FINISH);
|
||||
hitObjectHasSampleNormalBank(0, HitSampleInfo.BANK_NORMAL);
|
||||
hitObjectHasSampleAdditionBank(0, HitSampleInfo.BANK_SOFT);
|
||||
|
||||
AddStep("select first object", () => EditorBeatmap.SelectedHitObjects.Add(EditorBeatmap.HitObjects[0]));
|
||||
|
||||
hitObjectHasSamples(0, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_FINISH);
|
||||
hitObjectHasSampleNormalBank(0, HitSampleInfo.BANK_NORMAL);
|
||||
hitObjectHasSampleAdditionBank(0, HitSampleInfo.BANK_SOFT);
|
||||
}
|
||||
|
||||
private void clickSamplePiece(int objectIndex) => AddStep($"click {objectIndex.ToOrdinalWords()} sample piece", () =>
|
||||
{
|
||||
var samplePiece = this.ChildrenOfType<SamplePointPiece>().Single(piece => piece.HitObject == EditorBeatmap.HitObjects.ElementAt(objectIndex));
|
||||
|
@ -5,11 +5,14 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
@ -102,5 +105,120 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddStep("change tool to circle", () => InputManager.Key(Key.Number2));
|
||||
AddAssert("slider placed", () => EditorBeatmap.HitObjects.Count, () => Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAutomaticBankAssignment()
|
||||
{
|
||||
AddStep("add object with soft bank", () => EditorBeatmap.Add(new HitCircle
|
||||
{
|
||||
StartTime = 0,
|
||||
Samples =
|
||||
{
|
||||
new HitSampleInfo(name: HitSampleInfo.HIT_NORMAL, bank: HitSampleInfo.BANK_SOFT, volume: 70),
|
||||
new HitSampleInfo(name: HitSampleInfo.HIT_WHISTLE, bank: HitSampleInfo.BANK_DRUM, volume: 70),
|
||||
}
|
||||
}));
|
||||
|
||||
AddStep("seek to 500", () => EditorClock.Seek(500)); // previous object is the one at time 0
|
||||
AddStep("enable automatic bank assignment", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.LShift);
|
||||
InputManager.Key(Key.Q);
|
||||
InputManager.ReleaseKey(Key.LShift);
|
||||
});
|
||||
AddStep("select circle placement tool", () => InputManager.Key(Key.Number2));
|
||||
AddStep("move mouse to center of playfield", () => InputManager.MoveMouseTo(this.ChildrenOfType<Playfield>().Single()));
|
||||
AddStep("place circle", () => InputManager.Click(MouseButton.Left));
|
||||
AddAssert("circle has soft bank", () => EditorBeatmap.HitObjects[1].Samples.Single().Bank, () => Is.EqualTo(HitSampleInfo.BANK_SOFT));
|
||||
AddAssert("circle inherited volume", () => EditorBeatmap.HitObjects[1].Samples.All(s => s.Volume == 70));
|
||||
|
||||
AddStep("seek to 250", () => EditorClock.Seek(250)); // previous object is the one at time 0
|
||||
AddStep("enable clap addition", () => InputManager.Key(Key.R));
|
||||
AddStep("select circle placement tool", () => InputManager.Key(Key.Number2));
|
||||
AddStep("move mouse to center of playfield", () => InputManager.MoveMouseTo(this.ChildrenOfType<Playfield>().Single()));
|
||||
AddStep("place circle", () => InputManager.Click(MouseButton.Left));
|
||||
AddAssert("circle has 2 samples", () => EditorBeatmap.HitObjects[1].Samples, () => Has.Count.EqualTo(2));
|
||||
AddAssert("normal sample has soft bank", () => EditorBeatmap.HitObjects[1].Samples.Single(s => s.Name == HitSampleInfo.HIT_NORMAL).Bank,
|
||||
() => Is.EqualTo(HitSampleInfo.BANK_SOFT));
|
||||
AddAssert("clap sample has drum bank", () => EditorBeatmap.HitObjects[1].Samples.Single(s => s.Name == HitSampleInfo.HIT_CLAP).Bank,
|
||||
() => Is.EqualTo(HitSampleInfo.BANK_DRUM));
|
||||
AddAssert("circle inherited volume", () => EditorBeatmap.HitObjects[1].Samples.All(s => s.Volume == 70));
|
||||
|
||||
AddStep("seek to 1000", () => EditorClock.Seek(1000)); // previous object is the one at time 500, which has no additions
|
||||
AddStep("select circle placement tool", () => InputManager.Key(Key.Number2));
|
||||
AddStep("move mouse to center of playfield", () => InputManager.MoveMouseTo(this.ChildrenOfType<Playfield>().Single()));
|
||||
AddStep("place circle", () => InputManager.Click(MouseButton.Left));
|
||||
AddAssert("circle has 2 samples", () => EditorBeatmap.HitObjects[3].Samples, () => Has.Count.EqualTo(2));
|
||||
AddAssert("all samples have soft bank", () => EditorBeatmap.HitObjects[3].Samples.All(s => s.Bank == HitSampleInfo.BANK_SOFT));
|
||||
AddAssert("circle inherited volume", () => EditorBeatmap.HitObjects[3].Samples.All(s => s.Volume == 70));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestVolumeIsInheritedFromLastObject()
|
||||
{
|
||||
AddStep("add object with soft bank", () => EditorBeatmap.Add(new HitCircle
|
||||
{
|
||||
StartTime = 0,
|
||||
Samples =
|
||||
{
|
||||
new HitSampleInfo(name: HitSampleInfo.HIT_NORMAL, bank: HitSampleInfo.BANK_SOFT, volume: 70),
|
||||
}
|
||||
}));
|
||||
AddStep("seek to 500", () => EditorClock.Seek(500));
|
||||
AddStep("select drum bank", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.LShift);
|
||||
InputManager.Key(Key.R);
|
||||
InputManager.ReleaseKey(Key.LShift);
|
||||
});
|
||||
AddStep("select circle placement tool", () => InputManager.Key(Key.Number2));
|
||||
AddStep("move mouse to center of playfield", () => InputManager.MoveMouseTo(this.ChildrenOfType<Playfield>().Single()));
|
||||
AddStep("place circle", () => InputManager.Click(MouseButton.Left));
|
||||
AddAssert("circle has drum bank", () => EditorBeatmap.HitObjects[1].Samples.All(s => s.Bank == HitSampleInfo.BANK_DRUM));
|
||||
AddAssert("circle inherited volume", () => EditorBeatmap.HitObjects[1].Samples.All(s => s.Volume == 70));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNodeSamplesAndSamplesAreSame()
|
||||
{
|
||||
Playfield playfield = null!;
|
||||
|
||||
AddStep("select drum bank", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.LShift);
|
||||
InputManager.Key(Key.R);
|
||||
InputManager.ReleaseKey(Key.LShift);
|
||||
});
|
||||
AddStep("enable clap addition", () => InputManager.Key(Key.R));
|
||||
|
||||
AddStep("select slider placement tool", () => InputManager.Key(Key.Number3));
|
||||
AddStep("move mouse to top left of playfield", () =>
|
||||
{
|
||||
playfield = this.ChildrenOfType<Playfield>().Single();
|
||||
var location = (3 * playfield.ScreenSpaceDrawQuad.TopLeft + playfield.ScreenSpaceDrawQuad.BottomRight) / 4;
|
||||
InputManager.MoveMouseTo(location);
|
||||
});
|
||||
AddStep("begin placement", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("move mouse to bottom right of playfield", () =>
|
||||
{
|
||||
var location = (playfield.ScreenSpaceDrawQuad.TopLeft + 3 * playfield.ScreenSpaceDrawQuad.BottomRight) / 4;
|
||||
InputManager.MoveMouseTo(location);
|
||||
});
|
||||
AddStep("confirm via global action", () =>
|
||||
{
|
||||
globalActionContainer.TriggerPressed(GlobalAction.Select);
|
||||
globalActionContainer.TriggerReleased(GlobalAction.Select);
|
||||
});
|
||||
AddAssert("slider placed", () => EditorBeatmap.HitObjects.Count, () => Is.EqualTo(1));
|
||||
|
||||
AddAssert("slider samples have drum bank", () => EditorBeatmap.HitObjects[0].Samples.All(s => s.Bank == HitSampleInfo.BANK_DRUM));
|
||||
AddAssert("slider node samples have drum bank",
|
||||
() => ((IHasRepeats)EditorBeatmap.HitObjects[0]).NodeSamples.SelectMany(s => s).All(s => s.Bank == HitSampleInfo.BANK_DRUM));
|
||||
|
||||
AddAssert("slider samples have clap addition",
|
||||
() => EditorBeatmap.HitObjects[0].Samples.Select(s => s.Name), () => Does.Contain(HitSampleInfo.HIT_CLAP));
|
||||
AddAssert("slider node samples have clap addition",
|
||||
() => ((IHasRepeats)EditorBeatmap.HitObjects[0]).NodeSamples.All(samples => samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,51 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
}));
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(test_cases))]
|
||||
public void TestTriangularGrid(Vector2 position, Vector2 spacing, float rotation)
|
||||
{
|
||||
TriangularPositionSnapGrid grid = null;
|
||||
|
||||
AddStep("create grid", () =>
|
||||
{
|
||||
Child = grid = new TriangularPositionSnapGrid
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
grid.StartPosition.Value = position;
|
||||
grid.Spacing.Value = spacing.X;
|
||||
grid.GridLineRotation.Value = rotation;
|
||||
});
|
||||
|
||||
AddStep("add snapping cursor", () => Add(new SnappingCursorContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
GetSnapPosition = pos => grid.GetSnappedPosition(grid.ToLocalSpace(pos))
|
||||
}));
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(test_cases))]
|
||||
public void TestCircularGrid(Vector2 position, Vector2 spacing, float rotation)
|
||||
{
|
||||
CircularPositionSnapGrid grid = null;
|
||||
|
||||
AddStep("create grid", () =>
|
||||
{
|
||||
Child = grid = new CircularPositionSnapGrid
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
grid.StartPosition.Value = position;
|
||||
grid.Spacing.Value = spacing.X;
|
||||
});
|
||||
|
||||
AddStep("add snapping cursor", () => Add(new SnappingCursorContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
GetSnapPosition = pos => grid.GetSnappedPosition(grid.ToLocalSpace(pos))
|
||||
}));
|
||||
}
|
||||
|
||||
private partial class SnappingCursorContainer : CompositeDrawable
|
||||
{
|
||||
public Func<Vector2, Vector2> GetSnapPosition;
|
||||
|
@ -403,6 +403,28 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddAssert("placement committed", () => EditorBeatmap.HitObjects, () => Has.Count.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBreakRemoval()
|
||||
{
|
||||
var addedObjects = new[]
|
||||
{
|
||||
new HitCircle { StartTime = 0 },
|
||||
new HitCircle { StartTime = 5000 },
|
||||
};
|
||||
|
||||
AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects));
|
||||
AddAssert("beatmap has one break", () => EditorBeatmap.Breaks, () => Has.Count.EqualTo(1));
|
||||
|
||||
AddStep("move mouse to break", () => InputManager.MoveMouseTo(this.ChildrenOfType<TimelineBreak>().Single()));
|
||||
AddStep("right click", () => InputManager.Click(MouseButton.Right));
|
||||
|
||||
AddStep("move mouse to delete menu item", () => InputManager.MoveMouseTo(this.ChildrenOfType<OsuContextMenu>().First().ChildrenOfType<DrawableOsuMenuItem>().First()));
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("beatmap has no breaks", () => EditorBeatmap.Breaks, () => Is.Empty);
|
||||
AddAssert("break piece went away", () => this.ChildrenOfType<TimelineBreak>().Count(), () => Is.Zero);
|
||||
}
|
||||
|
||||
private void assertSelectionIs(IEnumerable<HitObject> hitObjects)
|
||||
=> AddAssert("correct hitobjects selected", () => EditorBeatmap.SelectedHitObjects.OrderBy(h => h.StartTime).SequenceEqual(hitObjects));
|
||||
}
|
||||
|
70
osu.Game.Tests/Visual/Gameplay/TestSceneUnorderedBreaks.cs
Normal file
70
osu.Game.Tests/Visual/Gameplay/TestSceneUnorderedBreaks.cs
Normal file
@ -0,0 +1,70 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Storyboards;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public partial class TestSceneUnorderedBreaks : OsuPlayerTestScene
|
||||
{
|
||||
[Resolved]
|
||||
private AudioManager audioManager { get; set; } = null!;
|
||||
|
||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
||||
{
|
||||
var beatmap = new OsuBeatmap();
|
||||
beatmap.HitObjects.Add(new HitCircle { StartTime = 0 });
|
||||
beatmap.HitObjects.Add(new HitCircle { StartTime = 5000 });
|
||||
beatmap.HitObjects.Add(new HitCircle { StartTime = 10000 });
|
||||
beatmap.Breaks.Add(new BreakPeriod(6000, 9000));
|
||||
beatmap.Breaks.Add(new BreakPeriod(1000, 4000));
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard? storyboard = null) =>
|
||||
new ClockBackedTestWorkingBeatmap(beatmap, storyboard, new FramedClock(new ManualClock { Rate = 1 }), audioManager);
|
||||
|
||||
[SetUpSteps]
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
|
||||
AddUntilStep("wait for track to start running", () => Beatmap.Value.Track.IsRunning);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBreakOverlayVisibility()
|
||||
{
|
||||
AddAssert("break overlay hidden", () => !this.ChildrenOfType<BreakOverlay>().Single().Child.IsPresent);
|
||||
addSeekStep(2000);
|
||||
AddUntilStep("break overlay visible", () => this.ChildrenOfType<BreakOverlay>().Single().Child.IsPresent);
|
||||
addSeekStep(5000);
|
||||
AddAssert("break overlay hidden", () => !this.ChildrenOfType<BreakOverlay>().Single().Child.IsPresent);
|
||||
addSeekStep(7000);
|
||||
AddUntilStep("break overlay visible", () => this.ChildrenOfType<BreakOverlay>().Single().Child.IsPresent);
|
||||
addSeekStep(10000);
|
||||
AddAssert("break overlay hidden", () => !this.ChildrenOfType<BreakOverlay>().Single().Child.IsPresent);
|
||||
}
|
||||
|
||||
private void addSeekStep(double time)
|
||||
{
|
||||
AddStep($"seek to {time}", () => Beatmap.Value.Track.Seek(time));
|
||||
|
||||
// Allow a few frames of lenience
|
||||
AddUntilStep("wait for seek to finish", () => Precision.AlmostEquals(time, Player.DrawableRuleset.FrameStableClock.CurrentTime, 100));
|
||||
}
|
||||
}
|
||||
}
|
180
osu.Game.Tests/Visual/Menus/TestSceneAudioDucking.cs
Normal file
180
osu.Game.Tests/Visual/Menus/TestSceneAudioDucking.cs
Normal file
@ -0,0 +1,180 @@
|
||||
// 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;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Audio.Effects;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
public partial class TestSceneAudioDucking : OsuGameTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestMomentaryDuck()
|
||||
{
|
||||
AddStep("duck momentarily", () => Game.MusicController.DuckMomentarily(1000));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleDucks()
|
||||
{
|
||||
IDisposable duckOp1 = null!;
|
||||
IDisposable duckOp2 = null!;
|
||||
|
||||
double normalVolume = 1;
|
||||
|
||||
AddStep("get initial volume", () =>
|
||||
{
|
||||
normalVolume = Game.Audio.Tracks.AggregateVolume.Value;
|
||||
});
|
||||
|
||||
AddStep("duck one", () =>
|
||||
{
|
||||
duckOp1 = Game.MusicController.Duck(new DuckParameters
|
||||
{
|
||||
DuckVolumeTo = 0.5,
|
||||
});
|
||||
});
|
||||
|
||||
AddUntilStep("wait for duck to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.5f).Within(0.01));
|
||||
|
||||
AddStep("duck two", () =>
|
||||
{
|
||||
duckOp2 = Game.MusicController.Duck(new DuckParameters
|
||||
{
|
||||
DuckVolumeTo = 0.2,
|
||||
});
|
||||
});
|
||||
|
||||
AddUntilStep("wait for duck to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.2f).Within(0.01));
|
||||
|
||||
AddStep("restore two", () => duckOp2.Dispose());
|
||||
AddUntilStep("wait for restore to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.5f).Within(0.01));
|
||||
|
||||
AddStep("restore one", () => duckOp1.Dispose());
|
||||
AddUntilStep("wait for restore to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume).Within(0.01));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleDucksSameParameters()
|
||||
{
|
||||
var duckParameters = new DuckParameters
|
||||
{
|
||||
DuckVolumeTo = 0.5,
|
||||
};
|
||||
|
||||
IDisposable duckOp1 = null!;
|
||||
IDisposable duckOp2 = null!;
|
||||
|
||||
double normalVolume = 1;
|
||||
|
||||
AddStep("get initial volume", () =>
|
||||
{
|
||||
normalVolume = Game.Audio.Tracks.AggregateVolume.Value;
|
||||
});
|
||||
|
||||
AddStep("duck one", () =>
|
||||
{
|
||||
duckOp1 = Game.MusicController.Duck(duckParameters);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for duck to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.5f).Within(0.01));
|
||||
|
||||
AddStep("duck two", () =>
|
||||
{
|
||||
duckOp2 = Game.MusicController.Duck(duckParameters);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for duck to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.5f).Within(0.01));
|
||||
|
||||
AddStep("restore two", () => duckOp2.Dispose());
|
||||
AddUntilStep("wait for restore to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.5f).Within(0.01));
|
||||
|
||||
AddStep("restore one", () => duckOp1.Dispose());
|
||||
AddUntilStep("wait for restore to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume).Within(0.01));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleDucksReverseOrder()
|
||||
{
|
||||
IDisposable duckOp1 = null!;
|
||||
IDisposable duckOp2 = null!;
|
||||
|
||||
double normalVolume = 1;
|
||||
|
||||
AddStep("get initial volume", () =>
|
||||
{
|
||||
normalVolume = Game.Audio.Tracks.AggregateVolume.Value;
|
||||
});
|
||||
|
||||
AddStep("duck one", () =>
|
||||
{
|
||||
duckOp1 = Game.MusicController.Duck(new DuckParameters
|
||||
{
|
||||
DuckVolumeTo = 0.5,
|
||||
});
|
||||
});
|
||||
|
||||
AddUntilStep("wait for duck to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.5f).Within(0.01));
|
||||
|
||||
AddStep("duck two", () =>
|
||||
{
|
||||
duckOp2 = Game.MusicController.Duck(new DuckParameters
|
||||
{
|
||||
DuckVolumeTo = 0.2,
|
||||
});
|
||||
});
|
||||
|
||||
AddUntilStep("wait for duck to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.2f).Within(0.01));
|
||||
|
||||
AddStep("restore one", () => duckOp1.Dispose());
|
||||
|
||||
// reverse order, less extreme duck removed so won't change
|
||||
AddUntilStep("wait for restore to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.2f).Within(0.01));
|
||||
|
||||
AddStep("restore two", () => duckOp2.Dispose());
|
||||
AddUntilStep("wait for restore to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume).Within(0.01));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleDisposalIsNoop()
|
||||
{
|
||||
IDisposable duckOp1 = null!;
|
||||
|
||||
AddStep("duck", () => duckOp1 = Game.MusicController.Duck());
|
||||
AddStep("restore", () => duckOp1.Dispose());
|
||||
AddStep("restore", () => duckOp1.Dispose());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleDucksDifferentPieces()
|
||||
{
|
||||
IDisposable duckOp1 = null!;
|
||||
IDisposable duckOp2 = null!;
|
||||
|
||||
AddStep("duck volume", () =>
|
||||
{
|
||||
duckOp1 = Game.MusicController.Duck(new DuckParameters
|
||||
{
|
||||
DuckVolumeTo = 0.2,
|
||||
DuckCutoffTo = AudioFilter.MAX_LOWPASS_CUTOFF,
|
||||
DuckDuration = 500,
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("duck lowpass", () =>
|
||||
{
|
||||
duckOp2 = Game.MusicController.Duck(new DuckParameters
|
||||
{
|
||||
DuckVolumeTo = 1,
|
||||
DuckCutoffTo = 300,
|
||||
DuckDuration = 500,
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("restore lowpass", () => duckOp2.Dispose());
|
||||
AddStep("restore volume", () => duckOp1.Dispose());
|
||||
}
|
||||
}
|
||||
}
|
@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
AddStep("select difficulty adjust", () => freeModSelectOverlay.SelectedMods.Value = new[] { new OsuModDifficultyAdjust() });
|
||||
AddWaitStep("wait some", 3);
|
||||
AddAssert("customisation area not expanded", () => this.ChildrenOfType<ModSettingsArea>().Single().Height == 0);
|
||||
AddAssert("customisation area not expanded", () => !this.ChildrenOfType<ModCustomisationPanel>().Single().Expanded.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -1211,6 +1211,20 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
AddAssert("0 matching shown", () => songSelect.ChildrenOfType<FilterControl>().Single().InformationalText == "0 matches");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Solo]
|
||||
public void TestHardDeleteHandledCorrectly()
|
||||
{
|
||||
createSongSelect();
|
||||
|
||||
addRulesetImportStep(0);
|
||||
AddAssert("3 matching shown", () => songSelect.ChildrenOfType<FilterControl>().Single().InformationalText == "3 matches");
|
||||
|
||||
AddStep("hard delete beatmap", () => Realm.Write(r => r.RemoveRange(r.All<BeatmapSetInfo>().Where(s => !s.Protected))));
|
||||
|
||||
AddUntilStep("0 matching shown", () => songSelect.ChildrenOfType<FilterControl>().Single().InformationalText == "0 matches");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDeleteHotkey()
|
||||
{
|
||||
|
@ -47,9 +47,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
public void TestArrowDirection()
|
||||
{
|
||||
AddStep("Set upwards", () => button.SetIconDirection(true));
|
||||
AddAssert("Icon facing upwards", () => button.Icon.Scale.Y == -1);
|
||||
AddUntilStep("Icon facing upwards", () => button.Icon.Scale.Y == -1);
|
||||
AddStep("Set downwards", () => button.SetIconDirection(false));
|
||||
AddAssert("Icon facing downwards", () => button.Icon.Scale.Y == 1);
|
||||
AddUntilStep("Icon facing downwards", () => button.Icon.Scale.Y == 1);
|
||||
}
|
||||
|
||||
private partial class TestButton : CommentRepliesButton
|
||||
|
@ -0,0 +1,66 @@
|
||||
// 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;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public partial class TestSceneModCustomisationPanel : OsuManualInputManagerTestScene
|
||||
{
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
|
||||
|
||||
private ModCustomisationPanel panel = null!;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
Child = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(20f),
|
||||
Child = panel = new ModCustomisationPanel
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Width = 400f,
|
||||
State = { Value = Visibility.Visible },
|
||||
SelectedMods = { BindTarget = SelectedMods },
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestDisplay()
|
||||
{
|
||||
AddStep("set DT", () =>
|
||||
{
|
||||
SelectedMods.Value = new[] { new OsuModDoubleTime() };
|
||||
panel.Enabled.Value = panel.Expanded.Value = true;
|
||||
});
|
||||
AddStep("set DA", () =>
|
||||
{
|
||||
SelectedMods.Value = new Mod[] { new OsuModDifficultyAdjust() };
|
||||
panel.Enabled.Value = panel.Expanded.Value = true;
|
||||
});
|
||||
AddStep("set FL+WU+DA+AD", () =>
|
||||
{
|
||||
SelectedMods.Value = new Mod[] { new OsuModFlashlight(), new ModWindUp(), new OsuModDifficultyAdjust(), new OsuModApproachDifferent() };
|
||||
panel.Enabled.Value = panel.Expanded.Value = true;
|
||||
});
|
||||
AddStep("set empty", () =>
|
||||
{
|
||||
SelectedMods.Value = Array.Empty<Mod>();
|
||||
panel.Enabled.Value = panel.Expanded.Value = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
@ -56,6 +55,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddStep("clear contents", Clear);
|
||||
AddStep("reset ruleset", () => Ruleset.Value = rulesetStore.GetRuleset(0));
|
||||
AddStep("reset mods", () => SelectedMods.SetDefault());
|
||||
AddStep("reset config", () => configManager.SetValue(OsuSetting.ModSelectTextSearchStartsActive, true));
|
||||
AddStep("set beatmap", () => Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo));
|
||||
AddStep("set up presets", () =>
|
||||
{
|
||||
@ -225,7 +225,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
AddStep("dismiss mod customisation via toggle", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(modSelectOverlay.CustomisationButton.AsNonNull());
|
||||
InputManager.MoveMouseTo(modSelectOverlay.ChildrenOfType<ModCustomisationHeader>().Single());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
assertCustomisationToggleState(disabled: false, active: false);
|
||||
@ -258,7 +258,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDismissCustomisationViaDimmedArea()
|
||||
public void TestDismissCustomisationViaClickingAway()
|
||||
{
|
||||
createScreen();
|
||||
assertCustomisationToggleState(disabled: true, active: false);
|
||||
@ -266,18 +266,23 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddStep("select difficulty adjust via panel", () => getPanelForMod(typeof(OsuModDifficultyAdjust)).TriggerClick());
|
||||
assertCustomisationToggleState(disabled: false, active: true);
|
||||
|
||||
AddStep("move mouse to settings area", () => InputManager.MoveMouseTo(this.ChildrenOfType<ModSettingsArea>().Single()));
|
||||
AddStep("move mouse to dimmed area", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(new Vector2(
|
||||
modSelectOverlay.ScreenSpaceDrawQuad.TopLeft.X,
|
||||
(modSelectOverlay.ScreenSpaceDrawQuad.TopLeft.Y + modSelectOverlay.ScreenSpaceDrawQuad.BottomLeft.Y) / 2));
|
||||
});
|
||||
AddStep("move mouse to search bar", () => InputManager.MoveMouseTo(modSelectOverlay.ChildrenOfType<ShearedSearchTextBox>().Single()));
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
assertCustomisationToggleState(disabled: false, active: false);
|
||||
}
|
||||
|
||||
AddStep("move mouse to first mod panel", () => InputManager.MoveMouseTo(modSelectOverlay.ChildrenOfType<ModPanel>().First()));
|
||||
AddAssert("first mod panel is hovered", () => modSelectOverlay.ChildrenOfType<ModPanel>().First().IsHovered);
|
||||
[Test]
|
||||
public void TestDismissCustomisationWhenHidingOverlay()
|
||||
{
|
||||
createScreen();
|
||||
assertCustomisationToggleState(disabled: true, active: false);
|
||||
|
||||
AddStep("select difficulty adjust via panel", () => getPanelForMod(typeof(OsuModDifficultyAdjust)).TriggerClick());
|
||||
assertCustomisationToggleState(disabled: false, active: true);
|
||||
|
||||
AddStep("hide overlay", () => modSelectOverlay.Hide());
|
||||
AddStep("show overlay again", () => modSelectOverlay.Show());
|
||||
assertCustomisationToggleState(disabled: false, active: false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -339,7 +344,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
createScreen();
|
||||
changeRuleset(0);
|
||||
|
||||
AddStep("Select all fun mods", () =>
|
||||
AddStep("Select all difficulty-increase mods", () =>
|
||||
{
|
||||
modSelectOverlay.ChildrenOfType<ModColumn>()
|
||||
.Single(c => c.ModType == ModType.DifficultyIncrease)
|
||||
@ -641,13 +646,15 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddStep("select DT", () => SelectedMods.Value = new Mod[] { new OsuModDoubleTime() });
|
||||
AddAssert("DT selected", () => modSelectOverlay.ChildrenOfType<ModPanel>().Count(panel => panel.Active.Value), () => Is.EqualTo(1));
|
||||
|
||||
AddStep("open customisation area", () => modSelectOverlay.CustomisationButton!.TriggerClick());
|
||||
assertCustomisationToggleState(false, true);
|
||||
AddStep("open customisation area", () => modSelectOverlay.ChildrenOfType<ModCustomisationHeader>().Single().TriggerClick());
|
||||
assertCustomisationToggleState(disabled: false, active: true);
|
||||
|
||||
AddStep("hover over mod settings slider", () =>
|
||||
{
|
||||
var slider = modSelectOverlay.ChildrenOfType<ModSettingsArea>().Single().ChildrenOfType<OsuSliderBar<double>>().First();
|
||||
var slider = modSelectOverlay.ChildrenOfType<ModCustomisationPanel>().Single().ChildrenOfType<OsuSliderBar<double>>().First();
|
||||
InputManager.MoveMouseTo(slider);
|
||||
});
|
||||
|
||||
AddStep("press right arrow", () => InputManager.PressKey(Key.Right));
|
||||
AddAssert("DT speed changed", () => !SelectedMods.Value.OfType<OsuModDoubleTime>().Single().SpeedChange.IsDefault);
|
||||
|
||||
@ -744,9 +751,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
AddStep("select difficulty adjust via panel", () => getPanelForMod(typeof(OsuModDifficultyAdjust)).TriggerClick());
|
||||
assertCustomisationToggleState(disabled: false, active: true);
|
||||
AddAssert("back button disabled", () => !modSelectOverlay.BackButton.Enabled.Value);
|
||||
|
||||
AddStep("dismiss customisation area", () => InputManager.Key(Key.Escape));
|
||||
AddAssert("mod select still visible", () => modSelectOverlay.State.Value == Visibility.Visible);
|
||||
|
||||
AddStep("click back button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(modSelectOverlay.BackButton);
|
||||
@ -755,6 +763,19 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddAssert("mod select hidden", () => modSelectOverlay.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCloseViaToggleModSelectionBinding()
|
||||
{
|
||||
createScreen();
|
||||
changeRuleset(0);
|
||||
|
||||
AddStep("select difficulty adjust via panel", () => getPanelForMod(typeof(OsuModDifficultyAdjust)).TriggerClick());
|
||||
assertCustomisationToggleState(disabled: false, active: true);
|
||||
|
||||
AddStep("press F1", () => InputManager.Key(Key.F1));
|
||||
AddAssert("mod select hidden", () => modSelectOverlay.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Covers columns hiding/unhiding on changes of <see cref="ModSelectOverlay.IsValidMod"/>.
|
||||
/// </summary>
|
||||
@ -870,8 +891,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
// it is instrumental in the reproduction of the failure scenario that this test is supposed to cover.
|
||||
AddStep("force collection", GC.Collect);
|
||||
|
||||
AddStep("open customisation area", () => modSelectOverlay.CustomisationButton!.TriggerClick());
|
||||
AddStep("reset half time speed to default", () => modSelectOverlay.ChildrenOfType<ModSettingsArea>().Single()
|
||||
AddStep("open customisation area", () => modSelectOverlay.ChildrenOfType<ModCustomisationHeader>().Single().TriggerClick());
|
||||
AddStep("reset half time speed to default", () => modSelectOverlay.ChildrenOfType<ModCustomisationPanel>().Single()
|
||||
.ChildrenOfType<RevertToDefaultButton<double>>().Single().TriggerClick());
|
||||
AddUntilStep("difficulty multiplier display shows correct value",
|
||||
() => modSelectOverlay.ChildrenOfType<RankingInformationDisplay>().Single().ModMultiplier.Value, () => Is.EqualTo(0.3).Within(Precision.DOUBLE_EPSILON));
|
||||
@ -883,24 +904,91 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
createScreen();
|
||||
|
||||
AddStep("select DT + HD + DF", () => SelectedMods.Value = new Mod[] { new OsuModDoubleTime(), new OsuModHidden(), new OsuModDeflate() });
|
||||
AddStep("open customisation panel", () => this.ChildrenOfType<ModCustomisationHeader>().Single().TriggerClick());
|
||||
AddAssert("mod settings order: DT, HD, DF", () =>
|
||||
{
|
||||
var columns = this.ChildrenOfType<ModSettingsArea>().Single().ChildrenOfType<ModSettingsArea.ModSettingsColumn>();
|
||||
var columns = this.ChildrenOfType<ModCustomisationSection>();
|
||||
return columns.ElementAt(0).Mod is OsuModDoubleTime &&
|
||||
columns.ElementAt(1).Mod is OsuModHidden &&
|
||||
columns.ElementAt(2).Mod is OsuModDeflate;
|
||||
});
|
||||
|
||||
AddStep("replace DT with NC", () => SelectedMods.Value = SelectedMods.Value.Where(m => m is not ModDoubleTime).Append(new OsuModNightcore()).ToList());
|
||||
AddStep("replace DT with NC", () =>
|
||||
{
|
||||
SelectedMods.Value = SelectedMods.Value.Where(m => m is not ModDoubleTime).Append(new OsuModNightcore()).ToList();
|
||||
this.ChildrenOfType<ModCustomisationHeader>().Single().TriggerClick();
|
||||
});
|
||||
AddAssert("mod settings order: NC, HD, DF", () =>
|
||||
{
|
||||
var columns = this.ChildrenOfType<ModSettingsArea>().Single().ChildrenOfType<ModSettingsArea.ModSettingsColumn>();
|
||||
var columns = this.ChildrenOfType<ModCustomisationSection>();
|
||||
return columns.ElementAt(0).Mod is OsuModNightcore &&
|
||||
columns.ElementAt(1).Mod is OsuModHidden &&
|
||||
columns.ElementAt(2).Mod is OsuModDeflate;
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOpeningCustomisationHidesPresetPopover()
|
||||
{
|
||||
createScreen();
|
||||
|
||||
AddStep("select DT", () => SelectedMods.Value = new Mod[] { new OsuModDoubleTime() });
|
||||
AddStep("click new preset", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<AddPresetButton>().Single());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("preset popover shown", () => this.ChildrenOfType<AddPresetPopover>().SingleOrDefault()?.IsPresent, () => Is.True);
|
||||
|
||||
AddStep("click customisation header", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<ModCustomisationHeader>().Single());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("preset popover hidden", () => this.ChildrenOfType<AddPresetPopover>().SingleOrDefault()?.IsPresent, () => Is.Not.True);
|
||||
AddAssert("customisation panel shown", () => this.ChildrenOfType<ModCustomisationPanel>().Single().State.Value, () => Is.EqualTo(Visibility.Visible));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCustomisationPanelAbsorbsInput([Values] bool textSearchStartsActive)
|
||||
{
|
||||
AddStep($"text search starts active = {textSearchStartsActive}", () => configManager.SetValue(OsuSetting.ModSelectTextSearchStartsActive, textSearchStartsActive));
|
||||
createScreen();
|
||||
|
||||
AddStep("select DT", () => SelectedMods.Value = new Mod[] { new OsuModDoubleTime() });
|
||||
AddStep("open customisation panel", () => this.ChildrenOfType<ModCustomisationHeader>().Single().TriggerClick());
|
||||
AddAssert("search lost focus", () => !this.ChildrenOfType<ShearedSearchTextBox>().Single().HasFocus);
|
||||
|
||||
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||
AddAssert("search still not focused", () => !this.ChildrenOfType<ShearedSearchTextBox>().Single().HasFocus);
|
||||
|
||||
AddStep("press q", () => InputManager.Key(Key.Q));
|
||||
AddAssert("easy not selected", () => SelectedMods.Value.Single() is OsuModDoubleTime);
|
||||
|
||||
// the "deselect all mods" action is intentionally disabled when customisation panel is open to not conflict with pressing backspace to delete characters in a textbox.
|
||||
// this is supposed to be handled by the textbox itself especially since it's focused and thus prioritised in input queue,
|
||||
// but it's not for some reason, and figuring out why is probably not going to be a pleasant experience (read TextBox.OnKeyDown for a head start).
|
||||
AddStep("press backspace", () => InputManager.Key(Key.BackSpace));
|
||||
AddAssert("mods not deselected", () => SelectedMods.Value.Single() is OsuModDoubleTime);
|
||||
|
||||
AddStep("move mouse to scroll bar", () => InputManager.MoveMouseTo(modSelectOverlay.ChildrenOfType<ModSelectOverlay.ColumnScrollContainer>().Single().ScreenSpaceDrawQuad.BottomLeft + new Vector2(10f, -5f)));
|
||||
|
||||
AddStep("scroll down", () => InputManager.ScrollVerticalBy(-10f));
|
||||
AddAssert("column not scrolled", () => modSelectOverlay.ChildrenOfType<ModSelectOverlay.ColumnScrollContainer>().Single().IsScrolledToStart());
|
||||
|
||||
AddStep("press mouse", () => InputManager.PressButton(MouseButton.Left));
|
||||
AddAssert("search still not focused", () => !this.ChildrenOfType<ShearedSearchTextBox>().Single().HasFocus);
|
||||
AddStep("release mouse", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||
AddAssert("customisation panel closed by click", () => !this.ChildrenOfType<ModCustomisationPanel>().Single().Expanded.Value);
|
||||
|
||||
if (textSearchStartsActive)
|
||||
AddAssert("search focused", () => this.ChildrenOfType<ShearedSearchTextBox>().Single().HasFocus);
|
||||
else
|
||||
AddAssert("search still not focused", () => !this.ChildrenOfType<ShearedSearchTextBox>().Single().HasFocus);
|
||||
}
|
||||
|
||||
private void waitForColumnLoad() => AddUntilStep("all column content loaded", () =>
|
||||
modSelectOverlay.ChildrenOfType<ModColumn>().Any()
|
||||
&& modSelectOverlay.ChildrenOfType<ModColumn>().All(column => column.IsLoaded && column.ItemsLoaded)
|
||||
@ -915,8 +1003,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
private void assertCustomisationToggleState(bool disabled, bool active)
|
||||
{
|
||||
AddAssert($"customisation toggle is {(disabled ? "" : "not ")}disabled", () => modSelectOverlay.CustomisationButton.AsNonNull().Active.Disabled == disabled);
|
||||
AddAssert($"customisation toggle is {(active ? "" : "not ")}active", () => modSelectOverlay.CustomisationButton.AsNonNull().Active.Value == active);
|
||||
AddUntilStep($"customisation panel is {(disabled ? "" : "not ")}disabled", () => modSelectOverlay.ChildrenOfType<ModCustomisationPanel>().Single().Enabled.Value == !disabled);
|
||||
AddAssert($"customisation panel is {(active ? "" : "not ")}active", () => modSelectOverlay.ChildrenOfType<ModCustomisationPanel>().Single().Expanded.Value == active);
|
||||
}
|
||||
|
||||
private T getSelectedMod<T>() where T : Mod => SelectedMods.Value.OfType<T>().Single();
|
||||
@ -929,7 +1017,6 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
protected override bool ShowPresets => true;
|
||||
|
||||
public new ShearedButton BackButton => base.BackButton;
|
||||
public new ShearedToggleButton? CustomisationButton => base.CustomisationButton;
|
||||
}
|
||||
|
||||
private class TestUnimplementedMod : Mod
|
||||
|
@ -1,42 +0,0 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public partial class TestSceneModSettingsArea : OsuTestScene
|
||||
{
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||
|
||||
[Test]
|
||||
public void TestModToggleArea()
|
||||
{
|
||||
ModSettingsArea modSettingsArea = null;
|
||||
|
||||
AddStep("create content", () => Child = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Child = modSettingsArea = new ModSettingsArea()
|
||||
});
|
||||
AddStep("set DT", () => modSettingsArea.SelectedMods.Value = new[] { new OsuModDoubleTime() });
|
||||
AddStep("set DA", () => modSettingsArea.SelectedMods.Value = new Mod[] { new OsuModDifficultyAdjust() });
|
||||
AddStep("set FL+WU+DA+AD", () => modSettingsArea.SelectedMods.Value = new Mod[] { new OsuModFlashlight(), new ModWindUp(), new OsuModDifficultyAdjust(), new OsuModApproachDifferent() });
|
||||
AddStep("set empty", () => modSettingsArea.SelectedMods.Value = Array.Empty<Mod>());
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Game.IO.Serialization.Converters;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
@ -62,7 +62,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public ControlPointInfo ControlPointInfo { get; set; } = new ControlPointInfo();
|
||||
|
||||
public BindableList<BreakPeriod> Breaks { get; set; } = new BindableList<BreakPeriod>();
|
||||
public SortedList<BreakPeriod> Breaks { get; set; } = new SortedList<BreakPeriod>(Comparer<BreakPeriod>.Default);
|
||||
|
||||
public List<string> UnhandledEventLines { get; set; } = new List<string>();
|
||||
|
||||
|
@ -7,6 +7,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
@ -49,6 +51,10 @@ namespace osu.Game.Beatmaps
|
||||
original.BeatmapInfo = original.BeatmapInfo.Clone();
|
||||
original.ControlPointInfo = original.ControlPointInfo.DeepClone();
|
||||
|
||||
// Used in osu!mania conversion.
|
||||
original.Breaks = new SortedList<BreakPeriod>(Comparer<BreakPeriod>.Default);
|
||||
original.Breaks.AddRange(Beatmap.Breaks);
|
||||
|
||||
return ConvertBeatmap(original, cancellationToken);
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@ -33,7 +32,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
/// <remarks>
|
||||
/// Compare: https://github.com/peppy/osu-stable-reference/blob/master/osu!/GameplayElements/HitObjects/HitObject.cs#L319
|
||||
/// </remarks>
|
||||
private const double control_point_leniency = 5;
|
||||
public const double CONTROL_POINT_LENIENCY = 5;
|
||||
|
||||
internal static RulesetStore? RulesetStore;
|
||||
|
||||
@ -160,20 +159,24 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
private void applySamples(HitObject hitObject)
|
||||
{
|
||||
SampleControlPoint sampleControlPoint = (beatmap.ControlPointInfo as LegacyControlPointInfo)?.SamplePointAt(hitObject.GetEndTime() + control_point_leniency) ?? SampleControlPoint.DEFAULT;
|
||||
|
||||
hitObject.Samples = hitObject.Samples.Select(o => sampleControlPoint.ApplyTo(o)).ToList();
|
||||
|
||||
if (hitObject is IHasRepeats hasRepeats)
|
||||
{
|
||||
SampleControlPoint sampleControlPoint = (beatmap.ControlPointInfo as LegacyControlPointInfo)?.SamplePointAt(hitObject.StartTime + CONTROL_POINT_LENIENCY + 1) ?? SampleControlPoint.DEFAULT;
|
||||
hitObject.Samples = hitObject.Samples.Select(o => sampleControlPoint.ApplyTo(o)).ToList();
|
||||
|
||||
for (int i = 0; i < hasRepeats.NodeSamples.Count; i++)
|
||||
{
|
||||
double time = hitObject.StartTime + i * hasRepeats.Duration / hasRepeats.SpanCount() + control_point_leniency;
|
||||
double time = hitObject.StartTime + i * hasRepeats.Duration / hasRepeats.SpanCount() + CONTROL_POINT_LENIENCY;
|
||||
var nodeSamplePoint = (beatmap.ControlPointInfo as LegacyControlPointInfo)?.SamplePointAt(time) ?? SampleControlPoint.DEFAULT;
|
||||
|
||||
hasRepeats.NodeSamples[i] = hasRepeats.NodeSamples[i].Select(o => nodeSamplePoint.ApplyTo(o)).ToList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SampleControlPoint sampleControlPoint = (beatmap.ControlPointInfo as LegacyControlPointInfo)?.SamplePointAt(hitObject.GetEndTime() + CONTROL_POINT_LENIENCY) ?? SampleControlPoint.DEFAULT;
|
||||
hitObject.Samples = hitObject.Samples.Select(o => sampleControlPoint.ApplyTo(o)).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -528,8 +531,8 @@ namespace osu.Game.Beatmaps.Formats
|
||||
if (split.Length >= 8)
|
||||
{
|
||||
LegacyEffectFlags effectFlags = (LegacyEffectFlags)Parsing.ParseInt(split[7]);
|
||||
kiaiMode = effectFlags.HasFlagFast(LegacyEffectFlags.Kiai);
|
||||
omitFirstBarSignature = effectFlags.HasFlagFast(LegacyEffectFlags.OmitFirstBarLine);
|
||||
kiaiMode = effectFlags.HasFlag(LegacyEffectFlags.Kiai);
|
||||
omitFirstBarSignature = effectFlags.HasFlag(LegacyEffectFlags.OmitFirstBarLine);
|
||||
}
|
||||
|
||||
string stringSampleSet = sampleSet.ToString().ToLowerInvariant();
|
||||
|
@ -282,19 +282,39 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
foreach (var hitObject in hitObjects)
|
||||
{
|
||||
if (hitObject.Samples.Count > 0)
|
||||
if (hitObject is IHasRepeats hasNodeSamples)
|
||||
{
|
||||
int volume = hitObject.Samples.Max(o => o.Volume);
|
||||
int customIndex = hitObject.Samples.Any(o => o is ConvertHitObjectParser.LegacyHitSampleInfo)
|
||||
? hitObject.Samples.OfType<ConvertHitObjectParser.LegacyHitSampleInfo>().Max(o => o.CustomSampleBank)
|
||||
: -1;
|
||||
double spanDuration = hasNodeSamples.Duration / hasNodeSamples.SpanCount();
|
||||
|
||||
yield return new LegacyBeatmapDecoder.LegacySampleControlPoint { Time = hitObject.GetEndTime(), SampleVolume = volume, CustomSampleBank = customIndex };
|
||||
for (int i = 0; i < hasNodeSamples.NodeSamples.Count; ++i)
|
||||
{
|
||||
double nodeTime = hitObject.StartTime + i * spanDuration;
|
||||
|
||||
if (hasNodeSamples.NodeSamples[i].Count > 0)
|
||||
yield return createSampleControlPointFor(nodeTime, hasNodeSamples.NodeSamples[i]);
|
||||
|
||||
if (spanDuration > LegacyBeatmapDecoder.CONTROL_POINT_LENIENCY + 1 && hitObject.Samples.Count > 0 && i < hasNodeSamples.NodeSamples.Count - 1)
|
||||
yield return createSampleControlPointFor(nodeTime + LegacyBeatmapDecoder.CONTROL_POINT_LENIENCY + 1, hitObject.Samples);
|
||||
}
|
||||
}
|
||||
else if (hitObject.Samples.Count > 0)
|
||||
{
|
||||
yield return createSampleControlPointFor(hitObject.GetEndTime(), hitObject.Samples);
|
||||
}
|
||||
|
||||
foreach (var nested in collectSampleControlPoints(hitObject.NestedHitObjects))
|
||||
yield return nested;
|
||||
}
|
||||
|
||||
SampleControlPoint createSampleControlPointFor(double time, IList<HitSampleInfo> samples)
|
||||
{
|
||||
int volume = samples.Max(o => o.Volume);
|
||||
int customIndex = samples.Any(o => o is ConvertHitObjectParser.LegacyHitSampleInfo)
|
||||
? samples.OfType<ConvertHitObjectParser.LegacyHitSampleInfo>().Max(o => o.CustomSampleBank)
|
||||
: -1;
|
||||
|
||||
return new LegacyBeatmapDecoder.LegacySampleControlPoint { Time = time, SampleVolume = volume, CustomSampleBank = customIndex };
|
||||
}
|
||||
}
|
||||
|
||||
void extractSampleControlPoints(IEnumerable<HitObject> hitObject)
|
||||
|
@ -4,7 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
@ -41,11 +41,11 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// The breaks in this beatmap.
|
||||
/// </summary>
|
||||
BindableList<BreakPeriod> Breaks { get; }
|
||||
SortedList<BreakPeriod> Breaks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// All lines from the [Events] section which aren't handled in the encoding process yet.
|
||||
/// These lines shoule be written out to the beatmap file on save or export.
|
||||
/// These lines should be written out to the beatmap file on save or export.
|
||||
/// </summary>
|
||||
List<string> UnhandledEventLines { get; }
|
||||
|
||||
|
@ -6,7 +6,7 @@ using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Beatmaps.Timing
|
||||
{
|
||||
public class BreakPeriod : IEquatable<BreakPeriod>
|
||||
public class BreakPeriod : IEquatable<BreakPeriod>, IComparable<BreakPeriod>
|
||||
{
|
||||
/// <summary>
|
||||
/// The minimum gap between the start of the break and the previous object.
|
||||
@ -76,5 +76,17 @@ namespace osu.Game.Beatmaps.Timing
|
||||
&& EndTime == other.EndTime;
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(StartTime, EndTime);
|
||||
|
||||
public int CompareTo(BreakPeriod? other)
|
||||
{
|
||||
if (ReferenceEquals(this, other)) return 0;
|
||||
if (ReferenceEquals(null, other)) return 1;
|
||||
|
||||
int result = StartTime.CompareTo(other.StartTime);
|
||||
if (result != 0)
|
||||
return result;
|
||||
|
||||
return EndTime.CompareTo(other.EndTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,8 +163,8 @@ namespace osu.Game.Collections
|
||||
public CollectionDropdownHeader()
|
||||
{
|
||||
Height = 25;
|
||||
Icon.Size = new Vector2(16);
|
||||
Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4, Left = 8, Right = 4 };
|
||||
Chevron.Size = new Vector2(12);
|
||||
Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4, Left = 8, Right = 8 };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
// 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;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Audio.Effects;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Collections
|
||||
@ -21,11 +21,14 @@ namespace osu.Game.Collections
|
||||
private const double enter_duration = 500;
|
||||
private const double exit_duration = 200;
|
||||
|
||||
private AudioFilter lowPassFilter = null!;
|
||||
|
||||
protected override string PopInSampleName => @"UI/overlay-big-pop-in";
|
||||
protected override string PopOutSampleName => @"UI/overlay-big-pop-out";
|
||||
|
||||
private IDisposable? duckOperation;
|
||||
|
||||
[Resolved]
|
||||
private MusicController? musicController { get; set; }
|
||||
|
||||
public ManageCollectionsDialog()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
@ -39,7 +42,7 @@ namespace osu.Game.Collections
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, AudioManager audio)
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -110,19 +113,25 @@ namespace osu.Game.Collections
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
lowPassFilter = new AudioFilter(audio.TrackMixer)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override bool IsPresent => base.IsPresent
|
||||
// Safety for low pass filter potentially getting stuck in applied state due to
|
||||
// transforms on `this` causing children to no longer be updated.
|
||||
|| lowPassFilter.IsAttached;
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
duckOperation?.Dispose();
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
lowPassFilter.CutoffTo(300, 100, Easing.OutCubic);
|
||||
duckOperation = musicController?.Duck(new DuckParameters
|
||||
{
|
||||
DuckVolumeTo = 1,
|
||||
DuckDuration = 100,
|
||||
RestoreDuration = 100,
|
||||
});
|
||||
|
||||
this.FadeIn(enter_duration, Easing.OutQuint);
|
||||
this.ScaleTo(0.9f).Then().ScaleTo(1f, enter_duration, Easing.OutQuint);
|
||||
}
|
||||
@ -131,7 +140,7 @@ namespace osu.Game.Collections
|
||||
{
|
||||
base.PopOut();
|
||||
|
||||
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF, 100, Easing.InCubic);
|
||||
duckOperation?.Dispose();
|
||||
|
||||
this.FadeOut(exit_duration, Easing.OutQuint);
|
||||
this.ScaleTo(0.9f, exit_duration);
|
||||
|
@ -10,7 +10,6 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -164,13 +163,13 @@ namespace osu.Game.Database
|
||||
var importTasks = new List<Task>();
|
||||
|
||||
Task beatmapImportTask = Task.CompletedTask;
|
||||
if (content.HasFlagFast(StableContent.Beatmaps))
|
||||
if (content.HasFlag(StableContent.Beatmaps))
|
||||
importTasks.Add(beatmapImportTask = new LegacyBeatmapImporter(beatmaps).ImportFromStableAsync(stableStorage));
|
||||
|
||||
if (content.HasFlagFast(StableContent.Skins))
|
||||
if (content.HasFlag(StableContent.Skins))
|
||||
importTasks.Add(new LegacySkinImporter(skins).ImportFromStableAsync(stableStorage));
|
||||
|
||||
if (content.HasFlagFast(StableContent.Collections))
|
||||
if (content.HasFlag(StableContent.Collections))
|
||||
{
|
||||
importTasks.Add(beatmapImportTask.ContinueWith(_ => new LegacyCollectionImporter(realmAccess)
|
||||
{
|
||||
@ -180,7 +179,7 @@ namespace osu.Game.Database
|
||||
}.ImportFromStorage(stableStorage), TaskContinuationOptions.OnlyOnRanToCompletion));
|
||||
}
|
||||
|
||||
if (content.HasFlagFast(StableContent.Scores))
|
||||
if (content.HasFlag(StableContent.Scores))
|
||||
importTasks.Add(beatmapImportTask.ContinueWith(_ => new LegacyScoreImporter(scores).ImportFromStableAsync(stableStorage), TaskContinuationOptions.OnlyOnRanToCompletion));
|
||||
|
||||
await Task.WhenAll(importTasks.ToArray()).ConfigureAwait(false);
|
||||
|
@ -15,7 +15,6 @@ using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Development;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
@ -1035,7 +1034,7 @@ namespace osu.Game.Database
|
||||
|
||||
var legacyMods = (LegacyMods)sr.ReadInt32();
|
||||
|
||||
if (!legacyMods.HasFlagFast(LegacyMods.ScoreV2) || score.APIMods.Any(mod => mod.Acronym == @"SV2"))
|
||||
if (!legacyMods.HasFlag(LegacyMods.ScoreV2) || score.APIMods.Any(mod => mod.Acronym == @"SV2"))
|
||||
return;
|
||||
|
||||
score.APIMods = score.APIMods.Append(new APIMod(new ModScoreV2())).ToArray();
|
||||
|
@ -65,7 +65,8 @@ namespace osu.Game.Database
|
||||
if (!d.Beatmaps.Contains(existingBeatmap))
|
||||
{
|
||||
Debug.Fail("Beatmaps should never become detached under normal circumstances. If this ever triggers, it should be investigated further.");
|
||||
Logger.Log("WARNING: One of the difficulties in a beatmap was detached from its set. Please save a copy of logs and report this to devs.", LoggingTarget.Database, LogLevel.Important);
|
||||
Logger.Log("WARNING: One of the difficulties in a beatmap was detached from its set. Please save a copy of logs and report this to devs.", LoggingTarget.Database,
|
||||
LogLevel.Important);
|
||||
d.Beatmaps.Add(existingBeatmap);
|
||||
}
|
||||
|
||||
@ -291,7 +292,24 @@ namespace osu.Game.Database
|
||||
if (!RealmAccess.CurrentThreadSubscriptionsAllowed)
|
||||
throw new InvalidOperationException($"Make sure to call {nameof(RealmAccess)}.{nameof(RealmAccess.RegisterForNotifications)}");
|
||||
|
||||
return collection.SubscribeForNotifications(callback);
|
||||
bool initial = true;
|
||||
return collection.SubscribeForNotifications(((sender, changes) =>
|
||||
{
|
||||
if (initial)
|
||||
{
|
||||
initial = false;
|
||||
|
||||
// Realm might coalesce the initial callback, meaning we never receive a `ChangeSet` of `null` marking the first callback.
|
||||
// Let's decouple it for simplicity in handling.
|
||||
if (changes != null)
|
||||
{
|
||||
callback(sender, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
callback(sender, changes);
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -6,7 +6,6 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Rendering;
|
||||
@ -190,9 +189,9 @@ namespace osu.Game.Graphics
|
||||
float width = Texture.DisplayWidth * scale;
|
||||
float height = Texture.DisplayHeight * scale;
|
||||
|
||||
if (relativePositionAxes.HasFlagFast(Axes.X))
|
||||
if (relativePositionAxes.HasFlag(Axes.X))
|
||||
position.X *= sourceSize.X;
|
||||
if (relativePositionAxes.HasFlagFast(Axes.Y))
|
||||
if (relativePositionAxes.HasFlag(Axes.Y))
|
||||
position.Y *= sourceSize.Y;
|
||||
|
||||
return new RectangleF(
|
||||
|
@ -119,9 +119,14 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Expanded.BindValueChanged(v =>
|
||||
{
|
||||
label.Text = v.NewValue ? expandedLabelText : contractedLabelText;
|
||||
slider.FadeTo(v.NewValue ? 1f : 0f, 500, Easing.OutQuint);
|
||||
slider.FadeTo(v.NewValue ? Current.Disabled ? 0.3f : 1f : 0f, 500, Easing.OutQuint);
|
||||
slider.BypassAutoSizeAxes = !v.NewValue ? Axes.Y : Axes.None;
|
||||
}, true);
|
||||
|
||||
Current.BindDisabledChanged(disabled =>
|
||||
{
|
||||
slider.Alpha = Expanded.Value ? disabled ? 0.3f : 1 : 0f;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
@ -30,6 +31,12 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override DropdownMenu CreateMenu() => new OsuDropdownMenu();
|
||||
|
||||
public OsuDropdown()
|
||||
{
|
||||
if (Header is OsuDropdownHeader osuHeader)
|
||||
osuHeader.Dropdown = this;
|
||||
}
|
||||
|
||||
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||
{
|
||||
if (e.Repeat) return false;
|
||||
@ -307,7 +314,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
set => Text.Text = value;
|
||||
}
|
||||
|
||||
protected readonly SpriteIcon Icon;
|
||||
protected readonly SpriteIcon Chevron;
|
||||
|
||||
public OsuDropdown<T>? Dropdown { get; set; }
|
||||
|
||||
public OsuDropdownHeader()
|
||||
{
|
||||
@ -341,7 +350,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Origin = Anchor.CentreLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
},
|
||||
Icon = new SpriteIcon
|
||||
Chevron = new SpriteIcon
|
||||
{
|
||||
Icon = FontAwesome.Solid.ChevronDown,
|
||||
Anchor = Anchor.CentreRight,
|
||||
@ -365,6 +374,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
if (Dropdown != null)
|
||||
Dropdown.Menu.StateChanged += _ => updateChevron();
|
||||
|
||||
SearchBar.State.ValueChanged += _ => updateColour();
|
||||
Enabled.BindValueChanged(_ => updateColour());
|
||||
updateColour();
|
||||
@ -392,16 +404,23 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
if (SearchBar.State.Value == Visibility.Visible)
|
||||
{
|
||||
Icon.Colour = hovered ? hoveredColour.Lighten(0.5f) : Colour4.White;
|
||||
Chevron.Colour = hovered ? hoveredColour.Lighten(0.5f) : Colour4.White;
|
||||
Background.Colour = unhoveredColour;
|
||||
}
|
||||
else
|
||||
{
|
||||
Icon.Colour = Color4.White;
|
||||
Chevron.Colour = Color4.White;
|
||||
Background.Colour = hovered ? hoveredColour : unhoveredColour;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateChevron()
|
||||
{
|
||||
Debug.Assert(Dropdown != null);
|
||||
bool open = Dropdown.Menu.State == MenuState.Open;
|
||||
Chevron.ScaleTo(open ? new Vector2(1f, -1f) : Vector2.One, 300, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override DropdownSearchBar CreateSearchBar() => new OsuDropdownSearchBar
|
||||
{
|
||||
Padding = new MarginPadding { Right = 26 },
|
||||
|
@ -12,7 +12,6 @@ using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Framework.Audio.Track;
|
||||
using System;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
@ -57,15 +56,15 @@ namespace osu.Game.Graphics.UserInterface
|
||||
set
|
||||
{
|
||||
base.Origin = value;
|
||||
c1.Origin = c1.Anchor = value.HasFlagFast(Anchor.x2) ? Anchor.TopLeft : Anchor.TopRight;
|
||||
c2.Origin = c2.Anchor = value.HasFlagFast(Anchor.x2) ? Anchor.TopRight : Anchor.TopLeft;
|
||||
c1.Origin = c1.Anchor = value.HasFlag(Anchor.x2) ? Anchor.TopLeft : Anchor.TopRight;
|
||||
c2.Origin = c2.Anchor = value.HasFlag(Anchor.x2) ? Anchor.TopRight : Anchor.TopLeft;
|
||||
|
||||
X = value.HasFlagFast(Anchor.x2) ? SIZE_RETRACTED.X * shear.X * 0.5f : 0;
|
||||
X = value.HasFlag(Anchor.x2) ? SIZE_RETRACTED.X * shear.X * 0.5f : 0;
|
||||
|
||||
Remove(c1, false);
|
||||
Remove(c2, false);
|
||||
c1.Depth = value.HasFlagFast(Anchor.x2) ? 0 : 1;
|
||||
c2.Depth = value.HasFlagFast(Anchor.x2) ? 1 : 0;
|
||||
c1.Depth = value.HasFlag(Anchor.x2) ? 0 : 1;
|
||||
c2.Depth = value.HasFlag(Anchor.x2) ? 1 : 0;
|
||||
Add(c1);
|
||||
Add(c2);
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ namespace osu.Game.Input.Bindings
|
||||
/// </remarks>
|
||||
public override IEnumerable<IKeyBinding> DefaultKeyBindings => globalKeyBindings
|
||||
.Concat(editorKeyBindings)
|
||||
.Concat(editorTestPlayKeyBindings)
|
||||
.Concat(inGameKeyBindings)
|
||||
.Concat(replayKeyBindings)
|
||||
.Concat(songSelectKeyBindings)
|
||||
@ -68,6 +69,9 @@ namespace osu.Game.Input.Bindings
|
||||
case GlobalActionCategory.Overlays:
|
||||
return overlayKeyBindings;
|
||||
|
||||
case GlobalActionCategory.EditorTestPlay:
|
||||
return editorTestPlayKeyBindings;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(category), category, $"Unexpected {nameof(GlobalActionCategory)}");
|
||||
}
|
||||
@ -100,7 +104,6 @@ namespace osu.Game.Input.Bindings
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.F }, GlobalAction.ToggleFPSDisplay),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.T }, GlobalAction.ToggleToolbar),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.S }, GlobalAction.ToggleSkinEditor),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.P }, GlobalAction.ToggleProfile),
|
||||
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.R }, GlobalAction.ResetInputSettings),
|
||||
|
||||
@ -118,6 +121,7 @@ namespace osu.Game.Input.Bindings
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.B }, GlobalAction.ToggleBeatmapListing),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.O }, GlobalAction.ToggleSettings),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.N }, GlobalAction.ToggleNotifications),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.P }, GlobalAction.ToggleProfile),
|
||||
};
|
||||
|
||||
private static IEnumerable<KeyBinding> editorKeyBindings => new[]
|
||||
@ -145,6 +149,14 @@ namespace osu.Game.Input.Bindings
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.E }, GlobalAction.EditorToggleScaleControl),
|
||||
};
|
||||
|
||||
private static IEnumerable<KeyBinding> editorTestPlayKeyBindings => new[]
|
||||
{
|
||||
new KeyBinding(new[] { InputKey.Tab }, GlobalAction.EditorTestPlayToggleAutoplay),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.P }, GlobalAction.EditorTestPlayToggleQuickPause),
|
||||
new KeyBinding(new[] { InputKey.F1 }, GlobalAction.EditorTestPlayQuickExitToInitialTime),
|
||||
new KeyBinding(new[] { InputKey.F2 }, GlobalAction.EditorTestPlayQuickExitToCurrentTime),
|
||||
};
|
||||
|
||||
private static IEnumerable<KeyBinding> inGameKeyBindings => new[]
|
||||
{
|
||||
new KeyBinding(InputKey.Space, GlobalAction.SkipCutscene),
|
||||
@ -432,6 +444,18 @@ namespace osu.Game.Input.Bindings
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorToggleScaleControl))]
|
||||
EditorToggleScaleControl,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorTestPlayToggleAutoplay))]
|
||||
EditorTestPlayToggleAutoplay,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorTestPlayToggleQuickPause))]
|
||||
EditorTestPlayToggleQuickPause,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorTestPlayQuickExitToInitialTime))]
|
||||
EditorTestPlayQuickExitToInitialTime,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorTestPlayQuickExitToCurrentTime))]
|
||||
EditorTestPlayQuickExitToCurrentTime,
|
||||
}
|
||||
|
||||
public enum GlobalActionCategory
|
||||
@ -442,6 +466,7 @@ namespace osu.Game.Input.Bindings
|
||||
Replay,
|
||||
SongSelect,
|
||||
AudioControl,
|
||||
Overlays
|
||||
Overlays,
|
||||
EditorTestPlay,
|
||||
}
|
||||
}
|
||||
|
@ -374,6 +374,26 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString EditorToggleScaleControl => new TranslatableString(getKey(@"editor_toggle_scale_control"), @"Toggle scale control");
|
||||
|
||||
/// <summary>
|
||||
/// "Toggle autoplay"
|
||||
/// </summary>
|
||||
public static LocalisableString EditorTestPlayToggleAutoplay => new TranslatableString(getKey(@"editor_test_play_toggle_autoplay"), @"Toggle autoplay");
|
||||
|
||||
/// <summary>
|
||||
/// "Toggle quick pause"
|
||||
/// </summary>
|
||||
public static LocalisableString EditorTestPlayToggleQuickPause => new TranslatableString(getKey(@"editor_test_play_toggle_quick_pause"), @"Toggle quick pause");
|
||||
|
||||
/// <summary>
|
||||
/// "Quick exit to initial time"
|
||||
/// </summary>
|
||||
public static LocalisableString EditorTestPlayQuickExitToInitialTime => new TranslatableString(getKey(@"editor_test_play_quick_exit_to_initial_time"), @"Quick exit to initial time");
|
||||
|
||||
/// <summary>
|
||||
/// "Quick exit to current time"
|
||||
/// </summary>
|
||||
public static LocalisableString EditorTestPlayQuickExitToCurrentTime => new TranslatableString(getKey(@"editor_test_play_quick_exit_to_current_time"), @"Quick exit to current time");
|
||||
|
||||
/// <summary>
|
||||
/// "Increase mod speed"
|
||||
/// </summary>
|
||||
|
@ -49,6 +49,11 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString EditorSection => new TranslatableString(getKey(@"editor_section"), @"Editor");
|
||||
|
||||
/// <summary>
|
||||
/// "Editor: Test play"
|
||||
/// </summary>
|
||||
public static LocalisableString EditorTestPlaySection => new TranslatableString(getKey(@"editor_test_play_section"), @"Editor: Test play");
|
||||
|
||||
/// <summary>
|
||||
/// "Reset all bindings in section"
|
||||
/// </summary>
|
||||
|
@ -75,6 +75,16 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString UnrankedExplanation => new TranslatableString(getKey(@"unranked_explanation"), @"Performance points will not be granted due to active mods.");
|
||||
|
||||
/// <summary>
|
||||
/// "Customise"
|
||||
/// </summary>
|
||||
public static LocalisableString CustomisationPanelHeader => new TranslatableString(getKey(@"customisation_panel_header"), @"Customise");
|
||||
|
||||
/// <summary>
|
||||
/// "No mod selected which can be customised."
|
||||
/// </summary>
|
||||
public static LocalisableString CustomisationPanelDisabledReason => new TranslatableString(getKey(@"customisation_panel_disabled_reason"), @"No mod selected which can be customised.");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ namespace osu.Game.Online.Chat
|
||||
handleAdvanced(advanced_link_regex, result, startIndex);
|
||||
|
||||
// handle editor times
|
||||
handleMatches(EditorTimestampParser.TIME_REGEX, "{0}", $@"{OsuGameBase.OSU_PROTOCOL}edit/{{0}}", result, startIndex, LinkAction.OpenEditorTimestamp);
|
||||
handleMatches(EditorTimestampParser.TIME_REGEX_STRICT, "{0}", $@"{OsuGameBase.OSU_PROTOCOL}edit/{{0}}", result, startIndex, LinkAction.OpenEditorTimestamp);
|
||||
|
||||
// handle channels
|
||||
handleMatches(channel_regex, "{0}", $@"{OsuGameBase.OSU_PROTOCOL}chan/{{0}}", result, startIndex, LinkAction.OpenChannel);
|
||||
|
@ -256,7 +256,7 @@ namespace osu.Game.Online.Metadata
|
||||
throw new OperationCanceledException();
|
||||
|
||||
Debug.Assert(connection != null);
|
||||
await connection.InvokeAsync(nameof(IMetadataServer.EndWatchingMultiplayerRoom)).ConfigureAwait(false);
|
||||
await connection.InvokeAsync(nameof(IMetadataServer.EndWatchingMultiplayerRoom), id).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public override async Task DisconnectRequested()
|
||||
|
@ -596,7 +596,7 @@ namespace osu.Game
|
||||
return;
|
||||
}
|
||||
|
||||
editor.HandleTimestamp(timestamp);
|
||||
editor.HandleTimestamp(timestamp, notifyOnError: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -126,7 +126,8 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
Origin = Anchor.Centre,
|
||||
AlwaysPresent = true,
|
||||
Alpha = 0,
|
||||
Size = new Vector2(6)
|
||||
Size = new Vector2(6),
|
||||
Icon = FontAwesome.Solid.CaretDown,
|
||||
});
|
||||
}
|
||||
|
||||
@ -136,7 +137,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
|
||||
SortDirection.BindValueChanged(direction =>
|
||||
{
|
||||
icon.Icon = direction.NewValue == Overlays.SortDirection.Ascending && Active.Value ? FontAwesome.Solid.CaretUp : FontAwesome.Solid.CaretDown;
|
||||
icon.ScaleTo(direction.NewValue == Overlays.SortDirection.Ascending && Active.Value ? new Vector2(1f, -1f) : Vector2.One, 300, Easing.OutQuint);
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace osu.Game.Overlays.Comments.Buttons
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(12),
|
||||
Icon = FontAwesome.Solid.ChevronDown
|
||||
};
|
||||
}
|
||||
|
||||
@ -38,11 +39,12 @@ namespace osu.Game.Overlays.Comments.Buttons
|
||||
base.LoadComplete();
|
||||
Action = Expanded.Toggle;
|
||||
Expanded.BindValueChanged(onExpandedChanged, true);
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
private void onExpandedChanged(ValueChangedEvent<bool> expanded)
|
||||
{
|
||||
icon.Icon = expanded.NewValue ? FontAwesome.Solid.ChevronUp : FontAwesome.Solid.ChevronDown;
|
||||
icon.ScaleTo(expanded.NewValue ? new Vector2(1f, -1f) : Vector2.One, 300, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ namespace osu.Game.Overlays.Comments.Buttons
|
||||
background.Colour = colourProvider.Background2;
|
||||
}
|
||||
|
||||
protected void SetIconDirection(bool upwards) => icon.ScaleTo(new Vector2(1, upwards ? -1 : 1));
|
||||
protected void SetIconDirection(bool upwards) => icon.ScaleTo(upwards ? new Vector2(1f, -1f) : Vector2.One, 300, Easing.OutQuint);
|
||||
|
||||
public void ToggleTextVisibility(bool visible) => text.FadeTo(visible ? 1 : 0, 200, Easing.OutQuint);
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
@ -11,7 +10,6 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Audio.Effects;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
@ -57,7 +55,6 @@ namespace osu.Game.Overlays.Dialog
|
||||
private Sample tickSample;
|
||||
private Sample confirmSample;
|
||||
private double lastTickPlaybackTime;
|
||||
private AudioFilter lowPassFilter = null!;
|
||||
private bool mouseDown;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -65,8 +62,6 @@ namespace osu.Game.Overlays.Dialog
|
||||
{
|
||||
tickSample = audio.Samples.Get(@"UI/dialog-dangerous-tick");
|
||||
confirmSample = audio.Samples.Get(@"UI/dialog-dangerous-select");
|
||||
|
||||
AddInternal(lowPassFilter = new AudioFilter(audio.SampleMixer));
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -75,15 +70,8 @@ namespace osu.Game.Overlays.Dialog
|
||||
Progress.BindValueChanged(progressChanged, true);
|
||||
}
|
||||
|
||||
protected override void AbortConfirm()
|
||||
{
|
||||
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF);
|
||||
base.AbortConfirm();
|
||||
}
|
||||
|
||||
protected override void Confirm()
|
||||
{
|
||||
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF);
|
||||
confirmSample?.Play();
|
||||
base.Confirm();
|
||||
}
|
||||
@ -123,8 +111,6 @@ namespace osu.Game.Overlays.Dialog
|
||||
|
||||
private void progressChanged(ValueChangedEvent<double> progress)
|
||||
{
|
||||
lowPassFilter.Cutoff = Math.Max(1, (int)(progress.NewValue * AudioFilter.MAX_LOWPASS_CUTOFF * 0.5));
|
||||
|
||||
if (progress.NewValue < progress.OldValue)
|
||||
return;
|
||||
|
||||
|
@ -3,16 +3,16 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Input.Bindings;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Audio.Effects;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -23,15 +23,16 @@ namespace osu.Game.Overlays
|
||||
protected override string PopInSampleName => "UI/dialog-pop-in";
|
||||
protected override string PopOutSampleName => "UI/dialog-pop-out";
|
||||
|
||||
private AudioFilter lowPassFilter;
|
||||
[Resolved]
|
||||
private MusicController musicController { get; set; }
|
||||
|
||||
public PopupDialog CurrentDialog { get; private set; }
|
||||
|
||||
public override bool IsPresent => Scheduler.HasPendingTasks
|
||||
|| dialogContainer.Children.Count > 0
|
||||
// Safety for low pass filter potentially getting stuck in applied state due to
|
||||
// transforms on `this` causing children to no longer be updated.
|
||||
|| lowPassFilter.IsAttached;
|
||||
|| dialogContainer.Children.Count > 0;
|
||||
|
||||
[CanBeNull]
|
||||
private IDisposable duckOperation;
|
||||
|
||||
public DialogOverlay()
|
||||
{
|
||||
@ -49,10 +50,10 @@ namespace osu.Game.Overlays
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
AddInternal(lowPassFilter = new AudioFilter(audio.TrackMixer));
|
||||
base.Dispose(isDisposing);
|
||||
duckOperation?.Dispose();
|
||||
}
|
||||
|
||||
public void Push(PopupDialog dialog)
|
||||
@ -105,13 +106,18 @@ namespace osu.Game.Overlays
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
lowPassFilter.CutoffTo(300, 100, Easing.OutCubic);
|
||||
duckOperation = musicController?.Duck(new DuckParameters
|
||||
{
|
||||
DuckVolumeTo = 1,
|
||||
DuckDuration = 100,
|
||||
RestoreDuration = 100,
|
||||
});
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
base.PopOut();
|
||||
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF, 100, Easing.InCubic);
|
||||
duckOperation?.Dispose();
|
||||
|
||||
// PopOut gets called initially, but we only want to hide dialog when we have been loaded and are present.
|
||||
if (IsLoaded && CurrentDialog?.State.Value == Visibility.Visible)
|
||||
|
95
osu.Game/Overlays/Mods/ModCustomisationHeader.cs
Normal file
95
osu.Game/Overlays/Mods/ModCustomisationHeader.cs
Normal file
@ -0,0 +1,95 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK;
|
||||
using osu.Game.Localisation;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public partial class ModCustomisationHeader : OsuHoverContainer
|
||||
{
|
||||
private Box background = null!;
|
||||
private SpriteIcon icon = null!;
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
|
||||
|
||||
public readonly BindableBool Expanded = new BindableBool();
|
||||
|
||||
public ModCustomisationHeader()
|
||||
{
|
||||
Action = Expanded.Toggle;
|
||||
Enabled.Value = false;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
CornerRadius = 10f;
|
||||
Masking = true;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = ModSelectOverlayStrings.CustomisationPanelHeader,
|
||||
UseFullGlyphHeight = false,
|
||||
Font = OsuFont.Torus.With(size: 20f, weight: FontWeight.SemiBold),
|
||||
Margin = new MarginPadding { Left = 20f },
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Size = new Vector2(16f),
|
||||
Margin = new MarginPadding { Right = 20f },
|
||||
Child = icon = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Icon = FontAwesome.Solid.ChevronDown,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
IdleColour = colourProvider.Dark3;
|
||||
HoverColour = colourProvider.Light4;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Enabled.BindValueChanged(e =>
|
||||
{
|
||||
TooltipText = e.NewValue
|
||||
? string.Empty
|
||||
: ModSelectOverlayStrings.CustomisationPanelDisabledReason;
|
||||
}, true);
|
||||
|
||||
Expanded.BindValueChanged(v =>
|
||||
{
|
||||
icon.ScaleTo(v.NewValue ? new Vector2(1, -1) : Vector2.One, 300, Easing.OutQuint);
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
}
|
211
osu.Game/Overlays/Mods/ModCustomisationPanel.cs
Normal file
211
osu.Game/Overlays/Mods/ModCustomisationPanel.cs
Normal file
@ -0,0 +1,211 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public partial class ModCustomisationPanel : OverlayContainer, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
private const float header_height = 42f;
|
||||
private const float content_vertical_padding = 20f;
|
||||
private const float content_border_thickness = 2f;
|
||||
|
||||
private Container content = null!;
|
||||
private OsuScrollContainer scrollContainer = null!;
|
||||
private FillFlowContainer sectionsFlow = null!;
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
public readonly BindableBool Enabled = new BindableBool();
|
||||
|
||||
public readonly BindableBool Expanded = new BindableBool();
|
||||
|
||||
public Bindable<IReadOnlyList<Mod>> SelectedMods { get; } = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||
|
||||
// Handle{Non}PositionalInput controls whether the panel should act as a blocking layer on the screen. only block when the panel is expanded.
|
||||
// These properties are used because they correctly handle blocking/unblocking hover when mouse is pointing at a drawable outside
|
||||
// (returning Expanded.Value to OnHover or overriding Block{Non}PositionalInput doesn't work).
|
||||
public override bool HandlePositionalInput => Expanded.Value;
|
||||
public override bool HandleNonPositionalInput => Expanded.Value;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new ModCustomisationHeader
|
||||
{
|
||||
Depth = float.MinValue,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = header_height,
|
||||
Enabled = { BindTarget = Enabled },
|
||||
Expanded = { BindTarget = Expanded },
|
||||
},
|
||||
content = new FocusGrabbingContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
BorderColour = colourProvider.Dark3,
|
||||
BorderThickness = content_border_thickness,
|
||||
CornerRadius = 10f,
|
||||
Masking = true,
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Offset = new Vector2(0f, 5f),
|
||||
Radius = 20f,
|
||||
Roundness = 5f,
|
||||
Colour = Color4.Black.Opacity(0.25f),
|
||||
},
|
||||
Expanded = { BindTarget = Expanded },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colourProvider.Dark4,
|
||||
},
|
||||
scrollContainer = new OsuScrollContainer(Direction.Vertical)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Top = header_height + content_border_thickness,
|
||||
Bottom = content_border_thickness
|
||||
},
|
||||
Child = sectionsFlow = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(0f, 40f),
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Top = content_vertical_padding,
|
||||
Bottom = 5f + content_vertical_padding
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Enabled.BindValueChanged(e =>
|
||||
{
|
||||
this.FadeColour(OsuColour.Gray(e.NewValue ? 1f : 0.6f), 300, Easing.OutQuint);
|
||||
}, true);
|
||||
|
||||
Expanded.BindValueChanged(_ => updateDisplay(), true);
|
||||
SelectedMods.BindValueChanged(_ => updateMods(), true);
|
||||
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
protected override void PopIn() => this.FadeIn(300, Easing.OutQuint);
|
||||
|
||||
protected override void PopOut() => this.FadeOut(300, Easing.OutQuint);
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
Expanded.Value = false;
|
||||
return base.OnClick(e);
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e) => true;
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e) => true;
|
||||
|
||||
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||
{
|
||||
switch (e.Action)
|
||||
{
|
||||
case GlobalAction.Back:
|
||||
Expanded.Value = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
|
||||
{
|
||||
}
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
content.ClearTransforms();
|
||||
|
||||
if (Expanded.Value)
|
||||
{
|
||||
content.AutoSizeDuration = 400;
|
||||
content.AutoSizeEasing = Easing.OutQuint;
|
||||
content.AutoSizeAxes = Axes.Y;
|
||||
content.FadeIn(120, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
{
|
||||
content.AutoSizeAxes = Axes.None;
|
||||
content.ResizeHeightTo(header_height, 400, Easing.OutQuint);
|
||||
content.FadeOut(400, Easing.OutSine);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMods()
|
||||
{
|
||||
Expanded.Value = false;
|
||||
sectionsFlow.Clear();
|
||||
|
||||
// Importantly, the selected mods bindable is already ordered by the mod select overlay (following the order of mod columns and panels).
|
||||
// Using AsOrdered produces a slightly different order (e.g. DT and NC no longer becoming adjacent),
|
||||
// which breaks user expectations when interacting with the overlay.
|
||||
foreach (var mod in SelectedMods.Value)
|
||||
{
|
||||
var settings = mod.CreateSettingsControls().ToList();
|
||||
|
||||
if (settings.Count > 0)
|
||||
sectionsFlow.Add(new ModCustomisationSection(mod, settings));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
scrollContainer.Height = Math.Min(scrollContainer.AvailableContent, DrawHeight - header_height);
|
||||
}
|
||||
|
||||
private partial class FocusGrabbingContainer : InputBlockingContainer
|
||||
{
|
||||
public IBindable<bool> Expanded { get; } = new BindableBool();
|
||||
|
||||
public override bool RequestsFocus => Expanded.Value;
|
||||
public override bool AcceptsFocus => Expanded.Value;
|
||||
}
|
||||
}
|
||||
}
|
82
osu.Game/Overlays/Mods/ModCustomisationSection.cs
Normal file
82
osu.Game/Overlays/Mods/ModCustomisationSection.cs
Normal file
@ -0,0 +1,82 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public partial class ModCustomisationSection : CompositeDrawable
|
||||
{
|
||||
public readonly Mod Mod;
|
||||
|
||||
private readonly IReadOnlyList<Drawable> settings;
|
||||
|
||||
public ModCustomisationSection(Mod mod, IReadOnlyList<Drawable> settings)
|
||||
{
|
||||
Mod = mod;
|
||||
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
FillFlowContainer flow;
|
||||
|
||||
InternalChild = flow = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0f, 8f),
|
||||
Padding = new MarginPadding { Left = 7f },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding { Left = 20f, Right = 27f },
|
||||
Margin = new MarginPadding { Bottom = 4f },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = Mod.Name,
|
||||
Font = OsuFont.TorusAlternate.With(size: 20, weight: FontWeight.SemiBold),
|
||||
},
|
||||
new ModSwitchTiny(Mod)
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Active = { Value = true },
|
||||
Scale = new Vector2(0.5f),
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
flow.AddRange(settings);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
FinishTransforms(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@ using osu.Game.Localisation;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Utils;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
@ -109,15 +110,6 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
protected virtual IEnumerable<ShearedButton> CreateFooterButtons()
|
||||
{
|
||||
if (AllowCustomisation)
|
||||
{
|
||||
yield return CustomisationButton = new ShearedToggleButton(BUTTON_WIDTH)
|
||||
{
|
||||
Text = ModSelectOverlayStrings.ModCustomisation,
|
||||
Active = { BindTarget = customisationVisible }
|
||||
};
|
||||
}
|
||||
|
||||
yield return deselectAllModsButton = new DeselectAllModsButton(this);
|
||||
}
|
||||
|
||||
@ -125,10 +117,8 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
public IEnumerable<ModState> AllAvailableMods => AvailableMods.Value.SelectMany(pair => pair.Value);
|
||||
|
||||
private readonly BindableBool customisationVisible = new BindableBool();
|
||||
private Bindable<bool> textSearchStartsActive = null!;
|
||||
|
||||
private ModSettingsArea modSettingsArea = null!;
|
||||
private ColumnScrollContainer columnScroll = null!;
|
||||
private ColumnFlowContainer columnFlow = null!;
|
||||
private FillFlowContainer<ShearedButton> footerButtonFlow = null!;
|
||||
@ -138,9 +128,9 @@ namespace osu.Game.Overlays.Mods
|
||||
private Container aboveColumnsContent = null!;
|
||||
private RankingInformationDisplay? rankingInformationDisplay;
|
||||
private BeatmapAttributesDisplay? beatmapAttributesDisplay;
|
||||
private ModCustomisationPanel customisationPanel = null!;
|
||||
|
||||
protected ShearedButton BackButton { get; private set; } = null!;
|
||||
protected ShearedToggleButton? CustomisationButton { get; private set; }
|
||||
protected SelectAllModsButton? SelectAllModsButton { get; set; }
|
||||
|
||||
private Sample? columnAppearSample;
|
||||
@ -173,70 +163,67 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
columnAppearSample = audio.Samples.Get(@"SongSelect/mod-column-pop-in");
|
||||
|
||||
AddRange(new Drawable[]
|
||||
MainAreaContent.Add(new OsuContextMenuContainer
|
||||
{
|
||||
new ClickToReturnContainer
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new PopoverContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
HandleMouse = { BindTarget = customisationVisible },
|
||||
OnClicked = () => customisationVisible.Value = false
|
||||
},
|
||||
modSettingsArea = new ModSettingsArea
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Height = 0
|
||||
},
|
||||
});
|
||||
|
||||
MainAreaContent.AddRange(new Drawable[]
|
||||
{
|
||||
aboveColumnsContent = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = RankingInformationDisplay.HEIGHT,
|
||||
Padding = new MarginPadding { Horizontal = 100 },
|
||||
Child = SearchTextBox = new ShearedSearchTextBox
|
||||
Children = new Drawable[]
|
||||
{
|
||||
HoldFocus = false,
|
||||
Width = 300
|
||||
}
|
||||
},
|
||||
new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new PopoverContainer
|
||||
{
|
||||
Padding = new MarginPadding
|
||||
new Container
|
||||
{
|
||||
Top = RankingInformationDisplay.HEIGHT + PADDING,
|
||||
Bottom = PADDING
|
||||
},
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
columnScroll = new ColumnScrollContainer
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = false,
|
||||
ClampExtension = 100,
|
||||
ScrollbarOverlapsContent = false,
|
||||
Child = columnFlow = new ColumnFlowContainer
|
||||
Top = RankingInformationDisplay.HEIGHT + PADDING,
|
||||
Bottom = PADDING
|
||||
},
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
columnScroll = new ColumnScrollContainer
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Shear = new Vector2(OsuGame.SHEAR, 0),
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Margin = new MarginPadding { Horizontal = 70 },
|
||||
Padding = new MarginPadding { Bottom = 10 },
|
||||
ChildrenEnumerable = createColumns()
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = false,
|
||||
ClampExtension = 100,
|
||||
ScrollbarOverlapsContent = false,
|
||||
Child = columnFlow = new ColumnFlowContainer
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Shear = new Vector2(OsuGame.SHEAR, 0),
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Margin = new MarginPadding { Horizontal = 70 },
|
||||
Padding = new MarginPadding { Bottom = 10 },
|
||||
ChildrenEnumerable = createColumns()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
aboveColumnsContent = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Horizontal = 100, Bottom = 15f },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
SearchTextBox = new ShearedSearchTextBox
|
||||
{
|
||||
HoldFocus = false,
|
||||
Width = 300,
|
||||
},
|
||||
customisationPanel = new ModCustomisationPanel
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Width = 400,
|
||||
State = { Value = Visibility.Visible },
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
@ -320,7 +307,7 @@ namespace osu.Game.Overlays.Mods
|
||||
// This is an optimisation to prevent refreshing the available settings controls when it can be
|
||||
// reasonably assumed that the settings panel is never to be displayed (e.g. FreeModSelectOverlay).
|
||||
if (AllowCustomisation)
|
||||
((IBindable<IReadOnlyList<Mod>>)modSettingsArea.SelectedMods).BindTo(SelectedMods);
|
||||
((IBindable<IReadOnlyList<Mod>>)customisationPanel.SelectedMods).BindTo(SelectedMods);
|
||||
|
||||
SelectedMods.BindValueChanged(_ =>
|
||||
{
|
||||
@ -347,7 +334,7 @@ namespace osu.Game.Overlays.Mods
|
||||
}
|
||||
}, true);
|
||||
|
||||
customisationVisible.BindValueChanged(_ => updateCustomisationVisualState(), true);
|
||||
customisationPanel.Expanded.BindValueChanged(_ => updateCustomisationVisualState(), true);
|
||||
|
||||
SearchTextBox.Current.BindValueChanged(query =>
|
||||
{
|
||||
@ -390,6 +377,7 @@ namespace osu.Game.Overlays.Mods
|
||||
footerContentFlow.LayoutDuration = 200;
|
||||
footerContentFlow.LayoutEasing = Easing.OutQuint;
|
||||
footerContentFlow.Direction = screenIsntWideEnough ? FillDirection.Vertical : FillDirection.Horizontal;
|
||||
aboveColumnsContent.Padding = aboveColumnsContent.Padding with { Bottom = screenIsntWideEnough ? 70f : 15f };
|
||||
}
|
||||
}
|
||||
|
||||
@ -491,7 +479,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
private void updateCustomisation()
|
||||
{
|
||||
if (CustomisationButton == null)
|
||||
if (!AllowCustomisation)
|
||||
return;
|
||||
|
||||
bool anyCustomisableModActive = false;
|
||||
@ -506,41 +494,32 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
if (anyCustomisableModActive)
|
||||
{
|
||||
customisationVisible.Disabled = false;
|
||||
customisationPanel.Enabled.Value = true;
|
||||
|
||||
if (anyModPendingConfiguration && !customisationVisible.Value)
|
||||
customisationVisible.Value = true;
|
||||
if (anyModPendingConfiguration)
|
||||
customisationPanel.Expanded.Value = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (customisationVisible.Value)
|
||||
customisationVisible.Value = false;
|
||||
|
||||
customisationVisible.Disabled = true;
|
||||
customisationPanel.Expanded.Value = false;
|
||||
customisationPanel.Enabled.Value = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCustomisationVisualState()
|
||||
{
|
||||
const double transition_duration = 300;
|
||||
|
||||
MainAreaContent.FadeColour(customisationVisible.Value ? Colour4.Gray : Colour4.White, transition_duration, Easing.InOutCubic);
|
||||
|
||||
foreach (var button in footerButtonFlow)
|
||||
if (customisationPanel.Expanded.Value)
|
||||
{
|
||||
if (button != CustomisationButton)
|
||||
button.Enabled.Value = !customisationVisible.Value;
|
||||
}
|
||||
|
||||
float modAreaHeight = customisationVisible.Value ? ModSettingsArea.HEIGHT : 0;
|
||||
|
||||
modSettingsArea.ResizeHeightTo(modAreaHeight, transition_duration, Easing.InOutCubic);
|
||||
TopLevelContent.MoveToY(-modAreaHeight, transition_duration, Easing.InOutCubic);
|
||||
|
||||
if (customisationVisible.Value)
|
||||
columnScroll.FadeColour(OsuColour.Gray(0.5f), 400, Easing.OutQuint);
|
||||
SearchTextBox.FadeColour(OsuColour.Gray(0.5f), 400, Easing.OutQuint);
|
||||
SearchTextBox.KillFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
columnScroll.FadeColour(Color4.White, 400, Easing.OutQuint);
|
||||
SearchTextBox.FadeColour(Color4.White, 400, Easing.OutQuint);
|
||||
setTextBoxFocus(textSearchStartsActive.Value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -693,6 +672,8 @@ namespace osu.Game.Overlays.Mods
|
||||
if (!allFiltered)
|
||||
nonFilteredColumnCount += 1;
|
||||
}
|
||||
|
||||
customisationPanel.Expanded.Value = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -706,16 +687,12 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
switch (e.Action)
|
||||
{
|
||||
// If the customisation panel is expanded, the back action will be handled by it first.
|
||||
case GlobalAction.Back:
|
||||
// Pressing the back binding should only go back one step at a time.
|
||||
hideOverlay(false);
|
||||
return true;
|
||||
|
||||
// This is handled locally here because this overlay is being registered at the game level
|
||||
// and therefore takes away keyboard focus from the screen stack.
|
||||
case GlobalAction.ToggleModSelection:
|
||||
// Pressing toggle should completely hide the overlay in one shot.
|
||||
hideOverlay(true);
|
||||
hideOverlay();
|
||||
return true;
|
||||
|
||||
// This is handled locally here due to conflicts in input handling between the search text box and the deselect all mods button.
|
||||
@ -723,7 +700,7 @@ namespace osu.Game.Overlays.Mods
|
||||
// wherein activating the binding will both change the contents of the search text box and deselect all mods.
|
||||
case GlobalAction.DeselectAllMods:
|
||||
{
|
||||
if (!SearchTextBox.HasFocus)
|
||||
if (!SearchTextBox.HasFocus && !customisationPanel.Expanded.Value)
|
||||
{
|
||||
deselectAllModsButton.TriggerClick();
|
||||
return true;
|
||||
@ -738,7 +715,7 @@ namespace osu.Game.Overlays.Mods
|
||||
// If there is no search in progress, it should exit the dialog (a bit weird, but this is the expectation from stable).
|
||||
if (string.IsNullOrEmpty(SearchTerm))
|
||||
{
|
||||
hideOverlay(true);
|
||||
hideOverlay();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -756,19 +733,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
return base.OnPressed(e);
|
||||
|
||||
void hideOverlay(bool immediate)
|
||||
{
|
||||
if (customisationVisible.Value)
|
||||
{
|
||||
Debug.Assert(CustomisationButton != null);
|
||||
CustomisationButton.TriggerClick();
|
||||
|
||||
if (!immediate)
|
||||
return;
|
||||
}
|
||||
|
||||
BackButton.TriggerClick();
|
||||
}
|
||||
void hideOverlay() => BackButton.TriggerClick();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IKeyBindingHandler{PlatformAction}"/>
|
||||
@ -795,6 +760,9 @@ namespace osu.Game.Overlays.Mods
|
||||
if (e.Repeat || e.Key != Key.Tab)
|
||||
return false;
|
||||
|
||||
if (customisationPanel.Expanded.Value)
|
||||
return true;
|
||||
|
||||
// TODO: should probably eventually support typical platform search shortcuts (`Ctrl-F`, `/`)
|
||||
setTextBoxFocus(!SearchTextBox.HasFocus);
|
||||
return true;
|
||||
@ -967,38 +935,5 @@ namespace osu.Game.Overlays.Mods
|
||||
updateState();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A container which blocks and handles input, managing the "return from customisation" state change.
|
||||
/// </summary>
|
||||
private partial class ClickToReturnContainer : Container
|
||||
{
|
||||
public BindableBool HandleMouse { get; } = new BindableBool();
|
||||
|
||||
public Action? OnClicked { get; set; }
|
||||
|
||||
public override bool HandlePositionalInput => base.HandlePositionalInput && HandleMouse.Value;
|
||||
|
||||
protected override bool Handle(UIEvent e)
|
||||
{
|
||||
if (!HandleMouse.Value)
|
||||
return base.Handle(e);
|
||||
|
||||
switch (e)
|
||||
{
|
||||
case ClickEvent:
|
||||
OnClicked?.Invoke();
|
||||
return true;
|
||||
|
||||
case HoverEvent:
|
||||
return false;
|
||||
|
||||
case MouseEvent:
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.Handle(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,189 +0,0 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public partial class ModSettingsArea : CompositeDrawable
|
||||
{
|
||||
public Bindable<IReadOnlyList<Mod>> SelectedMods { get; } = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
public const float HEIGHT = 250;
|
||||
|
||||
private readonly Box background;
|
||||
private readonly FillFlowContainer modSettingsFlow;
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
public override bool AcceptsFocus => true;
|
||||
|
||||
public ModSettingsArea()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = HEIGHT;
|
||||
|
||||
Anchor = Anchor.BottomRight;
|
||||
Origin = Anchor.BottomRight;
|
||||
|
||||
InternalChild = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
new OsuScrollContainer(Direction.Horizontal)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ScrollbarOverlapsContent = false,
|
||||
ClampExtension = 100,
|
||||
Child = modSettingsFlow = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding { Vertical = 7, Horizontal = 70 },
|
||||
Spacing = new Vector2(7),
|
||||
Direction = FillDirection.Horizontal
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
background.Colour = colourProvider.Dark3;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
SelectedMods.BindValueChanged(_ => updateMods(), true);
|
||||
}
|
||||
|
||||
private void updateMods()
|
||||
{
|
||||
modSettingsFlow.Clear();
|
||||
|
||||
// Importantly, the selected mods bindable is already ordered by the mod select overlay (following the order of mod columns and panels).
|
||||
// Using AsOrdered produces a slightly different order (e.g. DT and NC no longer becoming adjacent),
|
||||
// which breaks user expectations when interacting with the overlay.
|
||||
foreach (var mod in SelectedMods.Value)
|
||||
{
|
||||
var settings = mod.CreateSettingsControls().ToList();
|
||||
|
||||
if (settings.Count > 0)
|
||||
{
|
||||
if (modSettingsFlow.Any())
|
||||
{
|
||||
modSettingsFlow.Add(new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 2,
|
||||
Colour = colourProvider.Dark4,
|
||||
});
|
||||
}
|
||||
|
||||
modSettingsFlow.Add(new ModSettingsColumn(mod, settings));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e) => true;
|
||||
protected override bool OnHover(HoverEvent e) => true;
|
||||
|
||||
public partial class ModSettingsColumn : CompositeDrawable
|
||||
{
|
||||
public readonly Mod Mod;
|
||||
|
||||
public ModSettingsColumn(Mod mod, IEnumerable<Drawable> settingsControls)
|
||||
{
|
||||
Mod = mod;
|
||||
|
||||
Width = 250;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
Padding = new MarginPadding { Bottom = 7 };
|
||||
|
||||
InternalChild = new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RowDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
new Dimension(GridSizeMode.Absolute, 10),
|
||||
new Dimension()
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(7),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ModSwitchTiny(mod)
|
||||
{
|
||||
Active = { Value = true },
|
||||
Scale = new Vector2(0.6f),
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = mod.Name,
|
||||
Font = OsuFont.Default.With(size: 16, weight: FontWeight.SemiBold),
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Bottom = 2 }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
new[] { Empty() },
|
||||
new Drawable[]
|
||||
{
|
||||
new OsuScrollContainer(Direction.Vertical)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ClampExtension = 100,
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding { Right = 7 },
|
||||
ChildrenEnumerable = settingsControls,
|
||||
Spacing = new Vector2(0, 7)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -53,8 +53,8 @@ namespace osu.Game.Overlays.Music
|
||||
{
|
||||
CornerRadius = 5;
|
||||
Height = 30;
|
||||
Icon.Size = new Vector2(14);
|
||||
Icon.Margin = new MarginPadding(0);
|
||||
Chevron.Size = new Vector2(14);
|
||||
Chevron.Margin = new MarginPadding(0);
|
||||
Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4, Left = 10, Right = 10 };
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
@ -131,7 +130,7 @@ namespace osu.Game.Overlays.Music
|
||||
filter.Search.HoldFocus = true;
|
||||
Schedule(() => filter.Search.TakeFocus());
|
||||
|
||||
this.ResizeTo(new Vector2(1, RelativeSizeAxes.HasFlagFast(Axes.Y) ? 1f : PLAYLIST_HEIGHT), transition_duration, Easing.OutQuint);
|
||||
this.ResizeTo(new Vector2(1, RelativeSizeAxes.HasFlag(Axes.Y) ? 1f : PLAYLIST_HEIGHT), transition_duration, Easing.OutQuint);
|
||||
this.FadeIn(transition_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
@ -16,6 +13,7 @@ using osu.Framework.Graphics.Audio;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Audio.Effects;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@ -28,7 +26,7 @@ namespace osu.Game.Overlays
|
||||
public partial class MusicController : CompositeDrawable
|
||||
{
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; }
|
||||
private BeatmapManager beatmaps { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Point in time after which the current track will be restarted on triggering a "previous track" action.
|
||||
@ -49,25 +47,39 @@ namespace osu.Game.Overlays
|
||||
/// Fired when the global <see cref="WorkingBeatmap"/> has changed.
|
||||
/// Includes direction information for display purposes.
|
||||
/// </summary>
|
||||
public event Action<WorkingBeatmap, TrackChangeDirection> TrackChanged;
|
||||
public event Action<WorkingBeatmap, TrackChangeDirection>? TrackChanged;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
||||
private IBindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
|
||||
|
||||
[NotNull]
|
||||
public DrawableTrack CurrentTrack { get; private set; } = new DrawableTrack(new TrackVirtual(1000));
|
||||
|
||||
[Resolved]
|
||||
private RealmAccess realm { get; set; }
|
||||
private RealmAccess realm { get; set; } = null!;
|
||||
|
||||
private readonly BindableDouble audioDuckVolume = new BindableDouble(1);
|
||||
|
||||
private AudioFilter audioDuckFilter = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
AddInternal(audioDuckFilter = new AudioFilter(audio.TrackMixer));
|
||||
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, audioDuckVolume);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
beatmap.BindValueChanged(b => changeBeatmap(b.NewValue), true);
|
||||
beatmap.BindValueChanged(b =>
|
||||
{
|
||||
if (b.NewValue != null)
|
||||
changeBeatmap(b.NewValue);
|
||||
}, true);
|
||||
mods.BindValueChanged(_ => ResetTrackAdjustments(), true);
|
||||
}
|
||||
|
||||
@ -76,6 +88,9 @@ namespace osu.Game.Overlays
|
||||
/// </summary>
|
||||
public void ReloadCurrentTrack()
|
||||
{
|
||||
if (current == null)
|
||||
return;
|
||||
|
||||
changeTrack();
|
||||
TrackChanged?.Invoke(current, TrackChangeDirection.None);
|
||||
}
|
||||
@ -90,7 +105,7 @@ namespace osu.Game.Overlays
|
||||
/// </summary>
|
||||
public bool TrackLoaded => CurrentTrack.TrackLoaded;
|
||||
|
||||
private ScheduledDelegate seekDelegate;
|
||||
private ScheduledDelegate? seekDelegate;
|
||||
|
||||
public void SeekTo(double position)
|
||||
{
|
||||
@ -192,7 +207,7 @@ namespace osu.Game.Overlays
|
||||
/// Play the previous track or restart the current track if it's current time below <see cref="restart_cutoff_point"/>.
|
||||
/// </summary>
|
||||
/// <param name="onSuccess">Invoked when the operation has been performed successfully.</param>
|
||||
public void PreviousTrack(Action<PreviousTrackResult> onSuccess = null) => Schedule(() =>
|
||||
public void PreviousTrack(Action<PreviousTrackResult>? onSuccess = null) => Schedule(() =>
|
||||
{
|
||||
PreviousTrackResult res = prev();
|
||||
if (res != PreviousTrackResult.None)
|
||||
@ -218,7 +233,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
queuedDirection = TrackChangeDirection.Prev;
|
||||
|
||||
var playableSet = getBeatmapSets().AsEnumerable().TakeWhile(i => !i.Equals(current.BeatmapSetInfo)).LastOrDefault()
|
||||
var playableSet = getBeatmapSets().AsEnumerable().TakeWhile(i => !i.Equals(current?.BeatmapSetInfo)).LastOrDefault()
|
||||
?? getBeatmapSets().LastOrDefault();
|
||||
|
||||
if (playableSet != null)
|
||||
@ -236,13 +251,61 @@ namespace osu.Game.Overlays
|
||||
/// </summary>
|
||||
/// <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(() =>
|
||||
public void NextTrack(Action? onSuccess = null) => Schedule(() =>
|
||||
{
|
||||
bool res = next();
|
||||
if (res)
|
||||
onSuccess?.Invoke();
|
||||
});
|
||||
|
||||
private readonly List<DuckParameters> duckOperations = new List<DuckParameters>();
|
||||
|
||||
/// <summary>
|
||||
/// Applies ducking, attenuating the volume and/or low-pass cutoff of the currently playing track to make headroom for effects (or just to apply an effect).
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="IDisposable"/> which will restore the duck operation when disposed.</returns>
|
||||
public IDisposable Duck(DuckParameters? parameters = null)
|
||||
{
|
||||
parameters ??= new DuckParameters();
|
||||
|
||||
duckOperations.Add(parameters);
|
||||
|
||||
DuckParameters volumeOperation = duckOperations.MinBy(p => p.DuckVolumeTo)!;
|
||||
DuckParameters lowPassOperation = duckOperations.MinBy(p => p.DuckCutoffTo)!;
|
||||
|
||||
audioDuckFilter.CutoffTo(lowPassOperation.DuckCutoffTo, lowPassOperation.DuckDuration, lowPassOperation.DuckEasing);
|
||||
this.TransformBindableTo(audioDuckVolume, volumeOperation.DuckVolumeTo, volumeOperation.DuckDuration, volumeOperation.DuckEasing);
|
||||
|
||||
return new InvokeOnDisposal(restoreDucking);
|
||||
|
||||
void restoreDucking() => Schedule(() =>
|
||||
{
|
||||
if (!duckOperations.Remove(parameters))
|
||||
return;
|
||||
|
||||
DuckParameters? restoreVolumeOperation = duckOperations.MinBy(p => p.DuckVolumeTo);
|
||||
DuckParameters? restoreLowPassOperation = duckOperations.MinBy(p => p.DuckCutoffTo);
|
||||
|
||||
// If another duck operation is in the list, restore ducking to its level, else reset back to defaults.
|
||||
audioDuckFilter.CutoffTo(restoreLowPassOperation?.DuckCutoffTo ?? AudioFilter.MAX_LOWPASS_CUTOFF, parameters.RestoreDuration, parameters.RestoreEasing);
|
||||
this.TransformBindableTo(audioDuckVolume, restoreVolumeOperation?.DuckVolumeTo ?? 1, parameters.RestoreDuration, parameters.RestoreEasing);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A convenience method that ducks the currently playing track, then after a delay, restores automatically.
|
||||
/// </summary>
|
||||
/// <param name="delayUntilRestore">A delay in milliseconds which defines how long to delay restoration after ducking completes.</param>
|
||||
/// <param name="parameters">Parameters defining the ducking operation.</param>
|
||||
public void DuckMomentarily(double delayUntilRestore, DuckParameters? parameters = null)
|
||||
{
|
||||
parameters ??= new DuckParameters();
|
||||
|
||||
IDisposable duckOperation = Duck(parameters);
|
||||
|
||||
Scheduler.AddDelayed(() => duckOperation.Dispose(), delayUntilRestore);
|
||||
}
|
||||
|
||||
private bool next()
|
||||
{
|
||||
if (beatmap.Disabled || !AllowTrackControl.Value)
|
||||
@ -250,7 +313,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
queuedDirection = TrackChangeDirection.Next;
|
||||
|
||||
var playableSet = getBeatmapSets().AsEnumerable().SkipWhile(i => !i.Equals(current.BeatmapSetInfo)).ElementAtOrDefault(1)
|
||||
var playableSet = getBeatmapSets().AsEnumerable().SkipWhile(i => !i.Equals(current?.BeatmapSetInfo)).ElementAtOrDefault(1)
|
||||
?? getBeatmapSets().FirstOrDefault();
|
||||
|
||||
var playableBeatmap = playableSet?.Beatmaps.FirstOrDefault();
|
||||
@ -272,7 +335,7 @@ namespace osu.Game.Overlays
|
||||
Schedule(() => CurrentTrack.RestartAsync());
|
||||
}
|
||||
|
||||
private WorkingBeatmap current;
|
||||
private WorkingBeatmap? current;
|
||||
|
||||
private TrackChangeDirection? queuedDirection;
|
||||
|
||||
@ -289,7 +352,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
TrackChangeDirection direction = TrackChangeDirection.None;
|
||||
|
||||
bool audioEquals = newWorking?.BeatmapInfo?.AudioEquals(current?.BeatmapInfo) == true;
|
||||
bool audioEquals = newWorking.BeatmapInfo?.AudioEquals(current?.BeatmapInfo) == true;
|
||||
|
||||
if (current != null)
|
||||
{
|
||||
@ -304,7 +367,7 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
// figure out the best direction based on order in playlist.
|
||||
int last = getBeatmapSets().AsEnumerable().TakeWhile(b => !b.Equals(current.BeatmapSetInfo)).Count();
|
||||
int next = newWorking == null ? -1 : getBeatmapSets().AsEnumerable().TakeWhile(b => !b.Equals(newWorking.BeatmapSetInfo)).Count();
|
||||
int next = getBeatmapSets().AsEnumerable().TakeWhile(b => !b.Equals(newWorking.BeatmapSetInfo)).Count();
|
||||
|
||||
direction = last > next ? TrackChangeDirection.Prev : TrackChangeDirection.Next;
|
||||
}
|
||||
@ -361,7 +424,7 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
// Important to keep this in its own method to avoid inadvertently capturing unnecessary variables in the callback.
|
||||
// Can lead to leaks.
|
||||
var queuedTrack = new DrawableTrack(current.LoadTrack());
|
||||
var queuedTrack = new DrawableTrack(current!.LoadTrack());
|
||||
queuedTrack.Completed += onTrackCompleted;
|
||||
return queuedTrack;
|
||||
}
|
||||
@ -390,7 +453,7 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
}
|
||||
|
||||
private AudioAdjustments modTrackAdjustments;
|
||||
private AudioAdjustments? modTrackAdjustments;
|
||||
|
||||
/// <summary>
|
||||
/// Resets the adjustments currently applied on <see cref="CurrentTrack"/> and applies the mod adjustments if <see cref="ApplyModTrackAdjustments"/> is <c>true</c>.
|
||||
@ -416,6 +479,45 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
}
|
||||
|
||||
public class DuckParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// The duration of the ducking transition in milliseconds.
|
||||
/// Defaults to 100 ms.
|
||||
/// </summary>
|
||||
public double DuckDuration = 100;
|
||||
|
||||
/// <summary>
|
||||
/// The final volume which should be reached during ducking, when 0 is silent and 1 is original volume.
|
||||
/// Defaults to 25%.
|
||||
/// </summary>
|
||||
public double DuckVolumeTo = 0.25;
|
||||
|
||||
/// <summary>
|
||||
/// The low-pass cutoff frequency which should be reached during ducking. If not required, set to <see cref="AudioFilter.MAX_LOWPASS_CUTOFF"/>.
|
||||
/// Defaults to 300 Hz.
|
||||
/// </summary>
|
||||
public int DuckCutoffTo = 300;
|
||||
|
||||
/// <summary>
|
||||
/// The easing curve to be applied during ducking.
|
||||
/// Defaults to <see cref="Easing.Out"/>.
|
||||
/// </summary>
|
||||
public Easing DuckEasing = Easing.Out;
|
||||
|
||||
/// <summary>
|
||||
/// The duration of the restoration transition in milliseconds.
|
||||
/// Defaults to 500 ms.
|
||||
/// </summary>
|
||||
public double RestoreDuration = 500;
|
||||
|
||||
/// <summary>
|
||||
/// The easing curve to be applied during restoration.
|
||||
/// Defaults to <see cref="Easing.In"/>.
|
||||
/// </summary>
|
||||
public Easing RestoreEasing = Easing.In;
|
||||
}
|
||||
|
||||
public enum TrackChangeDirection
|
||||
{
|
||||
None,
|
||||
|
@ -118,7 +118,7 @@ namespace osu.Game.Overlays.News.Sidebar
|
||||
|
||||
Expanded.BindValueChanged(open =>
|
||||
{
|
||||
icon.Scale = new Vector2(1, open.NewValue ? -1 : 1);
|
||||
icon.ScaleTo(open.NewValue ? new Vector2(1f, -1f) : Vector2.One, 300, Easing.OutQuint);
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
LastScrollTarget.BindValueChanged(target =>
|
||||
{
|
||||
spriteIcon.RotateTo(target.NewValue != null ? 180 : 0, fade_duration, Easing.OutQuint);
|
||||
spriteIcon.ScaleTo(target.NewValue != null ? new Vector2(1f, -1f) : Vector2.One, fade_duration, Easing.OutQuint);
|
||||
TooltipText = target.NewValue != null ? CommonStrings.ButtonsBackToPrevious : CommonStrings.ButtonsBackToTop;
|
||||
}, true);
|
||||
}
|
||||
|
@ -50,12 +50,13 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(10.5f, 12)
|
||||
Size = new Vector2(10.5f, 12),
|
||||
Icon = FontAwesome.Solid.ChevronDown,
|
||||
};
|
||||
|
||||
CoverExpanded.BindValueChanged(visible => updateState(visible.NewValue), true);
|
||||
}
|
||||
|
||||
private void updateState(bool detailsVisible) => icon.Icon = detailsVisible ? FontAwesome.Solid.ChevronUp : FontAwesome.Solid.ChevronDown;
|
||||
private void updateState(bool detailsVisible) => icon.ScaleTo(detailsVisible ? new Vector2(1f, -1f) : Vector2.One, 300, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ namespace osu.Game.Overlays.Rankings
|
||||
Text.Font = OsuFont.GetFont(size: 15);
|
||||
Text.Padding = new MarginPadding { Vertical = 1.5f }; // osu-web line-height difference compensation
|
||||
Foreground.Padding = new MarginPadding { Horizontal = 10, Vertical = 15 };
|
||||
Margin = Icon.Margin = new MarginPadding(0);
|
||||
Margin = Chevron.Margin = new MarginPadding(0);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -87,6 +87,7 @@ namespace osu.Game.Overlays
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
updateState();
|
||||
FinishTransforms(true);
|
||||
}
|
||||
@ -95,33 +96,50 @@ namespace osu.Game.Overlays
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
UpdateState();
|
||||
updateHover();
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
UpdateState();
|
||||
updateHover();
|
||||
}
|
||||
|
||||
public void UpdateState() => Scheduler.AddOnce(updateState);
|
||||
|
||||
private const double fade_duration = 200;
|
||||
|
||||
private bool? isDisplayed;
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
if (current == null)
|
||||
return;
|
||||
|
||||
Enabled.Value = !current.Disabled;
|
||||
// Avoid running animations if we are already in an up-to-date state.
|
||||
if (Enabled.Value == !current.Disabled && isDisplayed == !current.IsDefault)
|
||||
return;
|
||||
|
||||
if (current.IsDefault)
|
||||
Enabled.Value = !current.Disabled;
|
||||
isDisplayed = !current.IsDefault;
|
||||
|
||||
updateHover();
|
||||
|
||||
if (isDisplayed == false)
|
||||
this.FadeTo(0, fade_duration, Easing.OutQuint);
|
||||
else if (current.Disabled)
|
||||
this.FadeTo(0.2f, fade_duration, Easing.OutQuint);
|
||||
else
|
||||
this.FadeTo(1, fade_duration, Easing.OutQuint);
|
||||
{
|
||||
icon.RotateTo(150).RotateTo(0, fade_duration * 2, Easing.OutQuint);
|
||||
icon.ScaleTo(0.7f).ScaleTo(1, fade_duration * 2, Easing.OutQuint);
|
||||
|
||||
this.FadeTo(1, fade_duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateHover()
|
||||
{
|
||||
if (IsHovered && Enabled.Value)
|
||||
{
|
||||
icon.RotateTo(-40, 500, Easing.OutQuint);
|
||||
|
@ -31,6 +31,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
new GlobalKeyBindingsSubsection(InputSettingsStrings.InGameSection, GlobalActionCategory.InGame),
|
||||
new GlobalKeyBindingsSubsection(InputSettingsStrings.ReplaySection, GlobalActionCategory.Replay),
|
||||
new GlobalKeyBindingsSubsection(InputSettingsStrings.EditorSection, GlobalActionCategory.Editor),
|
||||
new GlobalKeyBindingsSubsection(InputSettingsStrings.EditorTestPlaySection, GlobalActionCategory.EditorTestPlay),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -161,7 +160,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source)
|
||||
{
|
||||
if (invalidation.HasFlagFast(Invalidation.DrawSize))
|
||||
if (invalidation.HasFlag(Invalidation.DrawSize))
|
||||
headerTextVisibilityCache.Invalidate();
|
||||
|
||||
return base.OnInvalidate(invalidation, source);
|
||||
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
@ -145,9 +144,9 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
var blueprintItem = ((Drawable)blueprint.Item);
|
||||
blueprintItem.Scale = Vector2.One;
|
||||
|
||||
if (blueprintItem.RelativeSizeAxes.HasFlagFast(Axes.X))
|
||||
if (blueprintItem.RelativeSizeAxes.HasFlag(Axes.X))
|
||||
blueprintItem.Width = 1;
|
||||
if (blueprintItem.RelativeSizeAxes.HasFlagFast(Axes.Y))
|
||||
if (blueprintItem.RelativeSizeAxes.HasFlag(Axes.Y))
|
||||
blueprintItem.Height = 1;
|
||||
}
|
||||
});
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user