mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 18:27:19 +08:00
Merge branch 'master' into mania-edit-disable-sv
This commit is contained in:
commit
0f5eff1230
@ -50,7 +50,7 @@ Please make sure you have the following prerequisites:
|
||||
|
||||
- A desktop platform with the [.NET 6.0 SDK](https://dotnet.microsoft.com/download) installed.
|
||||
|
||||
When working with the codebase, we recommend using an IDE with intelligent code completion and syntax highlighting, such as the latest version of [Visual Studio](https://visualstudio.microsoft.com/vs/), [JetBrains Rider](https://www.jetbrains.com/rider/) or [Visual Studio Code](https://code.visualstudio.com/).
|
||||
When working with the codebase, we recommend using an IDE with intelligent code completion and syntax highlighting, such as the latest version of [Visual Studio](https://visualstudio.microsoft.com/vs/), [JetBrains Rider](https://www.jetbrains.com/rider/), or [Visual Studio Code](https://code.visualstudio.com/) with the [EditorConfig](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig) and [C#](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) plugin installed.
|
||||
|
||||
### Downloading the source code
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.815.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.823.0" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Fody does not handle Android build well, and warns when unchanged.
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="sh.ppy.osulazer" android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
|
||||
<application android:allowBackup="true" android:supportsRtl="true" android:label="osu!" android:icon="@drawable/lazer" />
|
||||
<!-- for editor usage -->
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
|
||||
</manifest>
|
@ -85,7 +85,7 @@ namespace osu.Desktop
|
||||
}
|
||||
}
|
||||
|
||||
using (DesktopGameHost host = Host.GetSuitableDesktopHost(gameName, new HostOptions { BindIPC = true }))
|
||||
using (DesktopGameHost host = Host.GetSuitableDesktopHost(gameName, new HostOptions { BindIPC = !tournamentClient }))
|
||||
{
|
||||
if (!host.IsPrimaryInstance)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- using a different name because package name cannot contain 'catch' -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="osu.Game.Rulesets.Catch_Tests.Android" android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
|
||||
<application android:allowBackup="true" android:supportsRtl="true" android:label="osu!catch Test" />
|
||||
</manifest>
|
@ -26,6 +26,8 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
AddSliderStep("start time", 500, 600, 0, x =>
|
||||
{
|
||||
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = x;
|
||||
drawableFruit.RefreshStateTransforms();
|
||||
drawableBanana.RefreshStateTransforms();
|
||||
});
|
||||
}
|
||||
|
||||
@ -44,6 +46,8 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
AddStep("Initialize start time", () =>
|
||||
{
|
||||
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = initial_start_time;
|
||||
drawableFruit.RefreshStateTransforms();
|
||||
drawableBanana.RefreshStateTransforms();
|
||||
|
||||
fruitRotation = drawableFruit.DisplayRotation;
|
||||
bananaRotation = drawableBanana.DisplayRotation;
|
||||
@ -54,6 +58,8 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
AddStep("change start time", () =>
|
||||
{
|
||||
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = another_start_time;
|
||||
drawableFruit.RefreshStateTransforms();
|
||||
drawableBanana.RefreshStateTransforms();
|
||||
});
|
||||
|
||||
AddAssert("fruit rotation is changed", () => drawableFruit.DisplayRotation != fruitRotation);
|
||||
@ -64,6 +70,8 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
AddStep("reset start time", () =>
|
||||
{
|
||||
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = initial_start_time;
|
||||
drawableFruit.RefreshStateTransforms();
|
||||
drawableBanana.RefreshStateTransforms();
|
||||
});
|
||||
|
||||
AddAssert("rotation and size restored", () =>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="osu.Game.Rulesets.Mania.Tests.Android" android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
|
||||
<application android:allowBackup="true" android:supportsRtl="true" android:label="osu!mania Test" />
|
||||
</manifest>
|
@ -6,7 +6,6 @@ using NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Mods;
|
||||
using osu.Game.Tests.Visual;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
@ -24,21 +23,6 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
|
||||
Assert.False(testBeatmap.HitObjects.OfType<HoldNote>().Any());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCorrectNoteValues()
|
||||
{
|
||||
var testBeatmap = createRawBeatmap();
|
||||
var noteValues = new List<double>(testBeatmap.HitObjects.OfType<HoldNote>().Count());
|
||||
|
||||
foreach (HoldNote h in testBeatmap.HitObjects.OfType<HoldNote>())
|
||||
{
|
||||
noteValues.Add(ManiaModHoldOff.GetNoteDurationInBeatLength(h, testBeatmap));
|
||||
}
|
||||
|
||||
noteValues.Sort();
|
||||
Assert.AreEqual(noteValues, new List<double> { 0.125, 0.250, 0.500, 1.000, 2.000 });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCorrectObjectCount()
|
||||
{
|
||||
@ -47,25 +31,8 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
|
||||
var rawBeatmap = createRawBeatmap();
|
||||
var testBeatmap = createModdedBeatmap();
|
||||
|
||||
// Calculate expected number of objects
|
||||
int expectedObjectCount = 0;
|
||||
|
||||
foreach (ManiaHitObject h in rawBeatmap.HitObjects)
|
||||
{
|
||||
// Both notes and hold notes account for at least one object
|
||||
expectedObjectCount++;
|
||||
|
||||
if (h.GetType() == typeof(HoldNote))
|
||||
{
|
||||
double noteValue = ManiaModHoldOff.GetNoteDurationInBeatLength((HoldNote)h, rawBeatmap);
|
||||
|
||||
if (noteValue >= ManiaModHoldOff.END_NOTE_ALLOW_THRESHOLD)
|
||||
{
|
||||
// Should generate an end note if it's longer than the minimum note value
|
||||
expectedObjectCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Both notes and hold notes account for at least one object
|
||||
int expectedObjectCount = rawBeatmap.HitObjects.Count;
|
||||
|
||||
Assert.That(testBeatmap.HitObjects.Count == expectedObjectCount);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Mania.Difficulty.Skills
|
||||
{
|
||||
private const double individual_decay_base = 0.125;
|
||||
private const double overall_decay_base = 0.30;
|
||||
private const double release_threshold = 24;
|
||||
private const double release_threshold = 30;
|
||||
|
||||
protected override double SkillMultiplier => 1;
|
||||
protected override double StrainDecayBase => 1;
|
||||
@ -50,10 +50,13 @@ namespace osu.Game.Rulesets.Mania.Difficulty.Skills
|
||||
for (int i = 0; i < endTimes.Length; ++i)
|
||||
{
|
||||
// The current note is overlapped if a previous note or end is overlapping the current note body
|
||||
isOverlapping |= Precision.DefinitelyBigger(endTimes[i], startTime, 1) && Precision.DefinitelyBigger(endTime, endTimes[i], 1);
|
||||
isOverlapping |= Precision.DefinitelyBigger(endTimes[i], startTime, 1) &&
|
||||
Precision.DefinitelyBigger(endTime, endTimes[i], 1) &&
|
||||
Precision.DefinitelyBigger(startTime, startTimes[i], 1);
|
||||
|
||||
// We give a slight bonus to everything if something is held meanwhile
|
||||
if (Precision.DefinitelyBigger(endTimes[i], endTime, 1))
|
||||
if (Precision.DefinitelyBigger(endTimes[i], endTime, 1) &&
|
||||
Precision.DefinitelyBigger(startTime, startTimes[i], 1))
|
||||
holdFactor = 1.25;
|
||||
|
||||
closestEndTime = Math.Min(closestEndTime, Math.Abs(endTime - endTimes[i]));
|
||||
@ -70,7 +73,7 @@ namespace osu.Game.Rulesets.Mania.Difficulty.Skills
|
||||
// 0.0 +--------+-+---------------> Release Difference / ms
|
||||
// release_threshold
|
||||
if (isOverlapping)
|
||||
holdAddition = 1 / (1 + Math.Exp(0.5 * (release_threshold - closestEndTime)));
|
||||
holdAddition = 1 / (1 + Math.Exp(0.27 * (release_threshold - closestEndTime)));
|
||||
|
||||
// Decay and increase individualStrains in own column
|
||||
individualStrains[column] = applyDecay(individualStrains[column], startTime - startTimes[column], individual_decay_base);
|
||||
|
@ -29,8 +29,6 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ManiaModInvert) };
|
||||
|
||||
public const double END_NOTE_ALLOW_THRESHOLD = 0.5;
|
||||
|
||||
public void ApplyToBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
var maniaBeatmap = (ManiaBeatmap)beatmap;
|
||||
@ -46,28 +44,9 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
StartTime = h.StartTime,
|
||||
Samples = h.GetNodeSamples(0)
|
||||
});
|
||||
|
||||
// Don't add an end note if the duration is shorter than the threshold
|
||||
double noteValue = GetNoteDurationInBeatLength(h, maniaBeatmap); // 1/1, 1/2, 1/4, etc.
|
||||
|
||||
if (noteValue >= END_NOTE_ALLOW_THRESHOLD)
|
||||
{
|
||||
newObjects.Add(new Note
|
||||
{
|
||||
Column = h.Column,
|
||||
StartTime = h.EndTime,
|
||||
Samples = h.GetNodeSamples((h.NodeSamples?.Count - 1) ?? 1)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
maniaBeatmap.HitObjects = maniaBeatmap.HitObjects.OfType<Note>().Concat(newObjects).OrderBy(h => h.StartTime).ToList();
|
||||
}
|
||||
|
||||
public static double GetNoteDurationInBeatLength(HoldNote holdNote, ManiaBeatmap beatmap)
|
||||
{
|
||||
double beatLength = beatmap.ControlPointInfo.TimingPointAt(holdNote.StartTime).BeatLength;
|
||||
return holdNote.Duration / beatLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="osu.Game.Rulesets.Osu.Tests.Android" android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
|
||||
<application android:allowBackup="true" android:supportsRtl="true" android:label="osu!standard Test" />
|
||||
</manifest>
|
@ -9,6 +9,7 @@ using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
@ -70,12 +71,12 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
base.Content.Children = new Drawable[]
|
||||
{
|
||||
editorClock = new EditorClock(editorBeatmap),
|
||||
snapProvider,
|
||||
new PopoverContainer { Child = snapProvider },
|
||||
Content
|
||||
};
|
||||
}
|
||||
|
||||
protected override Container<Drawable> Content { get; } = new Container { RelativeSizeAxes = Axes.Both };
|
||||
protected override Container<Drawable> Content { get; } = new PopoverContainer { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
|
@ -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.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Edit;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Screens.Edit.Components.RadioButtons;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
{
|
||||
public partial class TestScenePreciseRotation : TestSceneOsuEditor
|
||||
{
|
||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset);
|
||||
|
||||
[Test]
|
||||
public void TestHotkeyHandling()
|
||||
{
|
||||
AddStep("select single circle", () => EditorBeatmap.SelectedHitObjects.Add(EditorBeatmap.HitObjects.OfType<HitCircle>().First()));
|
||||
AddStep("press rotate hotkey", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ControlLeft);
|
||||
InputManager.Key(Key.R);
|
||||
InputManager.ReleaseKey(Key.ControlLeft);
|
||||
});
|
||||
AddUntilStep("no popover present", () => this.ChildrenOfType<PreciseRotationPopover>().Count(), () => Is.Zero);
|
||||
|
||||
AddStep("select first three objects", () =>
|
||||
{
|
||||
EditorBeatmap.SelectedHitObjects.Clear();
|
||||
EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects.Take(3));
|
||||
});
|
||||
AddStep("press rotate hotkey", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ControlLeft);
|
||||
InputManager.Key(Key.R);
|
||||
InputManager.ReleaseKey(Key.ControlLeft);
|
||||
});
|
||||
AddUntilStep("popover present", () => this.ChildrenOfType<PreciseRotationPopover>().Count(), () => Is.EqualTo(1));
|
||||
AddStep("press rotate hotkey", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ControlLeft);
|
||||
InputManager.Key(Key.R);
|
||||
InputManager.ReleaseKey(Key.ControlLeft);
|
||||
});
|
||||
AddUntilStep("no popover present", () => this.ChildrenOfType<PreciseRotationPopover>().Count(), () => Is.Zero);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRotateCorrectness()
|
||||
{
|
||||
AddStep("replace objects", () =>
|
||||
{
|
||||
EditorBeatmap.Clear();
|
||||
EditorBeatmap.AddRange(new HitObject[]
|
||||
{
|
||||
new HitCircle { Position = new Vector2(100) },
|
||||
new HitCircle { Position = new Vector2(200) },
|
||||
});
|
||||
});
|
||||
AddStep("select both circles", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
|
||||
AddStep("press rotate hotkey", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ControlLeft);
|
||||
InputManager.Key(Key.R);
|
||||
InputManager.ReleaseKey(Key.ControlLeft);
|
||||
});
|
||||
AddUntilStep("popover present", getPopover, () => Is.Not.Null);
|
||||
|
||||
AddStep("rotate by 180deg", () => getPopover().ChildrenOfType<TextBox>().Single().Current.Value = "180");
|
||||
AddAssert("first object rotated 180deg around playfield centre",
|
||||
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(0).Position,
|
||||
() => Is.EqualTo(OsuPlayfield.BASE_SIZE - new Vector2(100)));
|
||||
AddAssert("second object rotated 180deg around playfield centre",
|
||||
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(1).Position,
|
||||
() => Is.EqualTo(OsuPlayfield.BASE_SIZE - new Vector2(200)));
|
||||
|
||||
AddStep("change rotation origin", () => getPopover().ChildrenOfType<EditorRadioButton>().ElementAt(1).TriggerClick());
|
||||
AddAssert("first object rotated 90deg around selection centre",
|
||||
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(0).Position, () => Is.EqualTo(new Vector2(200, 200)));
|
||||
AddAssert("second object rotated 90deg around selection centre",
|
||||
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(1).Position, () => Is.EqualTo(new Vector2(100, 100)));
|
||||
|
||||
PreciseRotationPopover? getPopover() => this.ChildrenOfType<PreciseRotationPopover>().SingleOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
110
osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderReversal.cs
Normal file
110
osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderReversal.cs
Normal file
@ -0,0 +1,110 @@
|
||||
// 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.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
{
|
||||
public partial class TestSceneSliderReversal : TestSceneOsuEditor
|
||||
{
|
||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(Ruleset.Value, false);
|
||||
|
||||
private readonly PathControlPoint[][] paths =
|
||||
{
|
||||
createPathSegment(
|
||||
PathType.PerfectCurve,
|
||||
new Vector2(200, -50),
|
||||
new Vector2(250, 0)
|
||||
),
|
||||
createPathSegment(
|
||||
PathType.Linear,
|
||||
new Vector2(100, 0),
|
||||
new Vector2(100, 100)
|
||||
)
|
||||
};
|
||||
|
||||
private static PathControlPoint[] createPathSegment(PathType type, params Vector2[] positions)
|
||||
{
|
||||
return positions.Select(p => new PathControlPoint
|
||||
{
|
||||
Position = p
|
||||
}).Prepend(new PathControlPoint
|
||||
{
|
||||
Type = type
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
private Slider selectedSlider => (Slider)EditorBeatmap.SelectedHitObjects[0];
|
||||
|
||||
[TestCase(0, 250)]
|
||||
[TestCase(0, 200)]
|
||||
[TestCase(1, 120)]
|
||||
[TestCase(1, 80)]
|
||||
public void TestSliderReversal(int pathIndex, double length)
|
||||
{
|
||||
var controlPoints = paths[pathIndex];
|
||||
|
||||
Vector2 oldStartPos = default;
|
||||
Vector2 oldEndPos = default;
|
||||
double oldDistance = default;
|
||||
var oldControlPointTypes = controlPoints.Select(p => p.Type);
|
||||
|
||||
AddStep("Add slider", () =>
|
||||
{
|
||||
var slider = new Slider
|
||||
{
|
||||
Position = new Vector2(OsuPlayfield.BASE_SIZE.X / 2, OsuPlayfield.BASE_SIZE.Y / 2),
|
||||
Path = new SliderPath(controlPoints)
|
||||
{
|
||||
ExpectedDistance = { Value = length }
|
||||
}
|
||||
};
|
||||
|
||||
EditorBeatmap.Add(slider);
|
||||
|
||||
oldStartPos = slider.Position;
|
||||
oldEndPos = slider.EndPosition;
|
||||
oldDistance = slider.Path.Distance;
|
||||
});
|
||||
|
||||
AddStep("Select slider", () =>
|
||||
{
|
||||
var slider = (Slider)EditorBeatmap.HitObjects[0];
|
||||
EditorBeatmap.SelectedHitObjects.Add(slider);
|
||||
});
|
||||
|
||||
AddStep("Reverse slider", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.LControl);
|
||||
InputManager.Key(Key.G);
|
||||
InputManager.ReleaseKey(Key.LControl);
|
||||
});
|
||||
|
||||
AddAssert("Slider has correct length", () =>
|
||||
Precision.AlmostEquals(selectedSlider.Path.Distance, oldDistance));
|
||||
|
||||
AddAssert("Slider has correct start position", () =>
|
||||
Vector2.Distance(selectedSlider.Position, oldEndPos) < 1);
|
||||
|
||||
AddAssert("Slider has correct end position", () =>
|
||||
Vector2.Distance(selectedSlider.EndPosition, oldStartPos) < 1);
|
||||
|
||||
AddAssert("Control points have correct types", () =>
|
||||
{
|
||||
var newControlPointTypes = selectedSlider.Path.ControlPoints.Select(p => p.Type).ToArray();
|
||||
|
||||
return oldControlPointTypes.Take(newControlPointTypes.Length).SequenceEqual(newControlPointTypes);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -131,7 +131,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
{
|
||||
if (auto && !userTriggered && timeOffset > hitOffset && CheckHittable?.Invoke(this, Time.Current) != false)
|
||||
if (auto && !userTriggered && timeOffset > hitOffset && CheckHittable?.Invoke(this, Time.Current, HitResult.Great) == ClickAction.Hit)
|
||||
{
|
||||
// force success
|
||||
ApplyResult(r => r.Type = HitResult.Great);
|
||||
|
@ -13,6 +13,7 @@ using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osuTK;
|
||||
|
||||
@ -23,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
private float? alphaAtMiss;
|
||||
|
||||
[Test]
|
||||
public void TestHitCircleClassicMod()
|
||||
public void TestHitCircleClassicModMiss()
|
||||
{
|
||||
AddStep("Create hit circle", () =>
|
||||
{
|
||||
@ -61,8 +62,27 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
AddAssert("Transparent when missed", () => alphaAtMiss == 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// No early fade is expected to be applied if the hit circle has been hit.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestHitCircleNoMod()
|
||||
public void TestHitCircleClassicModHit()
|
||||
{
|
||||
TestDrawableHitCircle circle = null!;
|
||||
|
||||
AddStep("Create hit circle", () =>
|
||||
{
|
||||
SelectedMods.Value = new Mod[] { new OsuModClassic() };
|
||||
circle = createCircle(true);
|
||||
});
|
||||
|
||||
AddUntilStep("Wait until circle is hit", () => circle.Result?.Type == HitResult.Great);
|
||||
AddUntilStep("Wait for miss window", () => Clock.CurrentTime, () => Is.GreaterThanOrEqualTo(circle.HitObject.StartTime + circle.HitObject.HitWindows.WindowFor(HitResult.Miss)));
|
||||
AddAssert("Check circle is still visible", () => circle.Alpha, () => Is.GreaterThan(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHitCircleNoModMiss()
|
||||
{
|
||||
AddStep("Create hit circle", () =>
|
||||
{
|
||||
@ -74,6 +94,16 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
AddAssert("Opaque when missed", () => alphaAtMiss == 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHitCircleNoModHit()
|
||||
{
|
||||
AddStep("Create hit circle", () =>
|
||||
{
|
||||
SelectedMods.Value = Array.Empty<Mod>();
|
||||
createCircle(true);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSliderClassicMod()
|
||||
{
|
||||
@ -100,27 +130,32 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
AddAssert("Head circle opaque when missed", () => alphaAtMiss == 1);
|
||||
}
|
||||
|
||||
private void createCircle()
|
||||
private TestDrawableHitCircle createCircle(bool shouldHit = false)
|
||||
{
|
||||
alphaAtMiss = null;
|
||||
|
||||
DrawableHitCircle drawableHitCircle = new DrawableHitCircle(new HitCircle
|
||||
TestDrawableHitCircle drawableHitCircle = new TestDrawableHitCircle(new HitCircle
|
||||
{
|
||||
StartTime = Time.Current + 500,
|
||||
Position = new Vector2(250)
|
||||
});
|
||||
Position = new Vector2(250),
|
||||
}, shouldHit);
|
||||
|
||||
drawableHitCircle.Scale = new Vector2(2f);
|
||||
|
||||
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObject>())
|
||||
mod.ApplyToDrawableHitObject(drawableHitCircle);
|
||||
|
||||
drawableHitCircle.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
|
||||
drawableHitCircle.OnNewResult += (_, _) =>
|
||||
drawableHitCircle.OnNewResult += (_, result) =>
|
||||
{
|
||||
alphaAtMiss = drawableHitCircle.Alpha;
|
||||
if (!result.IsHit)
|
||||
alphaAtMiss = drawableHitCircle.Alpha;
|
||||
};
|
||||
|
||||
Child = drawableHitCircle;
|
||||
|
||||
return drawableHitCircle;
|
||||
}
|
||||
|
||||
private void createSlider()
|
||||
@ -138,6 +173,8 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
})
|
||||
});
|
||||
|
||||
drawableSlider.Scale = new Vector2(2f);
|
||||
|
||||
drawableSlider.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
|
||||
drawableSlider.OnLoadComplete += _ =>
|
||||
@ -145,12 +182,36 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObject>())
|
||||
mod.ApplyToDrawableHitObject(drawableSlider.HeadCircle);
|
||||
|
||||
drawableSlider.HeadCircle.OnNewResult += (_, _) =>
|
||||
drawableSlider.HeadCircle.OnNewResult += (_, result) =>
|
||||
{
|
||||
alphaAtMiss = drawableSlider.HeadCircle.Alpha;
|
||||
if (!result.IsHit)
|
||||
alphaAtMiss = drawableSlider.HeadCircle.Alpha;
|
||||
};
|
||||
};
|
||||
|
||||
Child = drawableSlider;
|
||||
}
|
||||
|
||||
protected partial class TestDrawableHitCircle : DrawableHitCircle
|
||||
{
|
||||
private readonly bool shouldHit;
|
||||
|
||||
public TestDrawableHitCircle(HitCircle h, bool shouldHit)
|
||||
: base(h)
|
||||
{
|
||||
this.shouldHit = shouldHit;
|
||||
}
|
||||
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
{
|
||||
if (shouldHit && !userTriggered && timeOffset >= 0)
|
||||
{
|
||||
// force success
|
||||
ApplyResult(r => r.Type = HitResult.Great);
|
||||
}
|
||||
else
|
||||
base.CheckForResult(userTriggered, timeOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +1,57 @@
|
||||
// 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.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.TypeExtensions;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Replays;
|
||||
using osu.Game.Rulesets.Osu.Scoring;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Scoring.Legacy;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
public partial class TestSceneObjectOrderedHitPolicy : RateAdjustedBeatmapTestScene
|
||||
public partial class TestSceneLegacyHitPolicy : RateAdjustedBeatmapTestScene
|
||||
{
|
||||
private const double early_miss_window = 1000; // time after -1000 to -500 is considered a miss
|
||||
private const double late_miss_window = 500; // time after +500 is considered a miss
|
||||
private readonly OsuHitWindows referenceHitWindows;
|
||||
|
||||
/// <summary>
|
||||
/// This is provided as a convenience for testing note lock behaviour against osu!stable.
|
||||
/// Setting this field to a non-null path will cause beatmap files and replays used in all test cases
|
||||
/// to be exported to disk so that they can be cross-checked against stable.
|
||||
/// </summary>
|
||||
private readonly string? exportLocation = null;
|
||||
|
||||
public TestSceneLegacyHitPolicy()
|
||||
{
|
||||
referenceHitWindows = new OsuHitWindows();
|
||||
referenceHitWindows.SetDifficulty(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests clicking a future circle before the first circle's start time, while the first circle HAS NOT been judged.
|
||||
@ -46,12 +66,12 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
var hitObjects = new List<OsuHitObject>
|
||||
{
|
||||
new TestHitCircle
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_first_circle,
|
||||
Position = positionFirstCircle
|
||||
},
|
||||
new TestHitCircle
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_second_circle,
|
||||
Position = positionSecondCircle
|
||||
@ -65,7 +85,9 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
addJudgementAssert(hitObjects[0], HitResult.Miss);
|
||||
addJudgementAssert(hitObjects[1], HitResult.Miss);
|
||||
addJudgementOffsetAssert(hitObjects[0], late_miss_window);
|
||||
// note lock prevented the object from being hit, so the judgement offset should be very late.
|
||||
addJudgementOffsetAssert(hitObjects[0], referenceHitWindows.WindowFor(HitResult.Meh));
|
||||
addClickActionAssert(0, ClickAction.Shake);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -81,12 +103,12 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
var hitObjects = new List<OsuHitObject>
|
||||
{
|
||||
new TestHitCircle
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_first_circle,
|
||||
Position = positionFirstCircle
|
||||
},
|
||||
new TestHitCircle
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_second_circle,
|
||||
Position = positionSecondCircle
|
||||
@ -100,7 +122,9 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
addJudgementAssert(hitObjects[0], HitResult.Miss);
|
||||
addJudgementAssert(hitObjects[1], HitResult.Miss);
|
||||
addJudgementOffsetAssert(hitObjects[0], late_miss_window);
|
||||
// note lock prevented the object from being hit, so the judgement offset should be very late.
|
||||
addJudgementOffsetAssert(hitObjects[0], referenceHitWindows.WindowFor(HitResult.Meh));
|
||||
addClickActionAssert(0, ClickAction.Shake);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -116,12 +140,12 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
var hitObjects = new List<OsuHitObject>
|
||||
{
|
||||
new TestHitCircle
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_first_circle,
|
||||
Position = positionFirstCircle
|
||||
},
|
||||
new TestHitCircle
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_second_circle,
|
||||
Position = positionSecondCircle
|
||||
@ -135,7 +159,9 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
addJudgementAssert(hitObjects[0], HitResult.Miss);
|
||||
addJudgementAssert(hitObjects[1], HitResult.Miss);
|
||||
addJudgementOffsetAssert(hitObjects[0], late_miss_window);
|
||||
// note lock prevented the object from being hit, so the judgement offset should be very late.
|
||||
addJudgementOffsetAssert(hitObjects[0], referenceHitWindows.WindowFor(HitResult.Meh));
|
||||
addClickActionAssert(0, ClickAction.Shake);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -151,12 +177,12 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
var hitObjects = new List<OsuHitObject>
|
||||
{
|
||||
new TestHitCircle
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_first_circle,
|
||||
Position = positionFirstCircle
|
||||
},
|
||||
new TestHitCircle
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_second_circle,
|
||||
Position = positionSecondCircle
|
||||
@ -165,14 +191,16 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
performTest(hitObjects, new List<ReplayFrame>
|
||||
{
|
||||
new OsuReplayFrame { Time = time_first_circle - 200, Position = positionFirstCircle, Actions = { OsuAction.LeftButton } },
|
||||
new OsuReplayFrame { Time = time_first_circle - 100, Position = positionSecondCircle, Actions = { OsuAction.RightButton } }
|
||||
new OsuReplayFrame { Time = time_first_circle - 190, Position = positionFirstCircle, Actions = { OsuAction.LeftButton } },
|
||||
new OsuReplayFrame { Time = time_first_circle - 90, Position = positionSecondCircle, Actions = { OsuAction.RightButton } }
|
||||
});
|
||||
|
||||
addJudgementAssert(hitObjects[0], HitResult.Great);
|
||||
addJudgementAssert(hitObjects[1], HitResult.Great);
|
||||
addJudgementOffsetAssert(hitObjects[0], -200); // time_first_circle - 200
|
||||
addJudgementOffsetAssert(hitObjects[0], -200); // time_second_circle - first_circle_time - 100
|
||||
addJudgementAssert(hitObjects[0], HitResult.Meh);
|
||||
addJudgementAssert(hitObjects[1], HitResult.Meh);
|
||||
addJudgementOffsetAssert(hitObjects[0], -190); // time_first_circle - 190
|
||||
addJudgementOffsetAssert(hitObjects[1], -190); // time_second_circle - first_circle_time - 90
|
||||
addClickActionAssert(0, ClickAction.Hit);
|
||||
addClickActionAssert(1, ClickAction.Hit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -188,12 +216,12 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
var hitObjects = new List<OsuHitObject>
|
||||
{
|
||||
new TestHitCircle
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_first_circle,
|
||||
Position = positionFirstCircle
|
||||
},
|
||||
new TestHitCircle
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_second_circle,
|
||||
Position = positionSecondCircle
|
||||
@ -202,21 +230,23 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
performTest(hitObjects, new List<ReplayFrame>
|
||||
{
|
||||
new OsuReplayFrame { Time = time_first_circle - 200, Position = positionFirstCircle, Actions = { OsuAction.LeftButton } },
|
||||
new OsuReplayFrame { Time = time_first_circle - 190, Position = positionFirstCircle, Actions = { OsuAction.LeftButton } },
|
||||
new OsuReplayFrame { Time = time_first_circle, Position = positionSecondCircle, Actions = { OsuAction.RightButton } }
|
||||
});
|
||||
|
||||
addJudgementAssert(hitObjects[0], HitResult.Great);
|
||||
addJudgementAssert(hitObjects[1], HitResult.Great);
|
||||
addJudgementOffsetAssert(hitObjects[0], -200); // time_first_circle - 200
|
||||
addJudgementAssert(hitObjects[0], HitResult.Meh);
|
||||
addJudgementAssert(hitObjects[1], HitResult.Ok);
|
||||
addJudgementOffsetAssert(hitObjects[0], -190); // time_first_circle - 190
|
||||
addJudgementOffsetAssert(hitObjects[1], -100); // time_second_circle - first_circle_time
|
||||
addClickActionAssert(0, ClickAction.Hit);
|
||||
addClickActionAssert(1, ClickAction.Hit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests clicking a future circle after a slider's start time, but hitting all slider ticks.
|
||||
/// Tests clicking a future circle after a slider's start time, but hitting the slider head and all slider ticks.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestMissSliderHeadAndHitAllSliderTicks()
|
||||
public void TestHitCircleBeforeSliderHead()
|
||||
{
|
||||
const double time_slider = 1500;
|
||||
const double time_circle = 1510;
|
||||
@ -225,19 +255,19 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
var hitObjects = new List<OsuHitObject>
|
||||
{
|
||||
new TestHitCircle
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_circle,
|
||||
Position = positionCircle
|
||||
},
|
||||
new TestSlider
|
||||
new Slider
|
||||
{
|
||||
StartTime = time_slider,
|
||||
Position = positionSlider,
|
||||
Path = new SliderPath(PathType.Linear, new[]
|
||||
{
|
||||
Vector2.Zero,
|
||||
new Vector2(25, 0),
|
||||
new Vector2(50, 0),
|
||||
})
|
||||
}
|
||||
};
|
||||
@ -248,10 +278,12 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
new OsuReplayFrame { Time = time_slider + 10, Position = positionSlider, Actions = { OsuAction.RightButton } }
|
||||
});
|
||||
|
||||
addJudgementAssert(hitObjects[0], HitResult.Miss);
|
||||
addJudgementAssert(hitObjects[0], HitResult.Great);
|
||||
addJudgementAssert(hitObjects[1], HitResult.Great);
|
||||
addJudgementAssert("slider head", () => ((Slider)hitObjects[1]).HeadCircle, HitResult.LargeTickHit);
|
||||
addJudgementAssert("slider tick", () => ((Slider)hitObjects[1]).NestedHitObjects[1] as SliderTick, HitResult.LargeTickHit);
|
||||
addClickActionAssert(0, ClickAction.Hit);
|
||||
addClickActionAssert(1, ClickAction.Hit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -267,19 +299,19 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
var hitObjects = new List<OsuHitObject>
|
||||
{
|
||||
new TestHitCircle
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_circle,
|
||||
Position = positionCircle
|
||||
},
|
||||
new TestSlider
|
||||
new Slider
|
||||
{
|
||||
StartTime = time_slider,
|
||||
Position = positionSlider,
|
||||
Path = new SliderPath(PathType.Linear, new[]
|
||||
{
|
||||
Vector2.Zero,
|
||||
new Vector2(25, 0),
|
||||
new Vector2(50, 0),
|
||||
})
|
||||
}
|
||||
};
|
||||
@ -287,14 +319,16 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
performTest(hitObjects, new List<ReplayFrame>
|
||||
{
|
||||
new OsuReplayFrame { Time = time_slider, Position = positionSlider, Actions = { OsuAction.LeftButton } },
|
||||
new OsuReplayFrame { Time = time_circle + late_miss_window - 100, Position = positionCircle, Actions = { OsuAction.RightButton } },
|
||||
new OsuReplayFrame { Time = time_circle + late_miss_window - 90, Position = positionSlider, Actions = { OsuAction.LeftButton } },
|
||||
new OsuReplayFrame { Time = time_circle + referenceHitWindows.WindowFor(HitResult.Meh) - 100, Position = positionCircle, Actions = { OsuAction.RightButton } },
|
||||
new OsuReplayFrame { Time = time_circle + referenceHitWindows.WindowFor(HitResult.Meh) - 90, Position = positionSlider, Actions = { OsuAction.LeftButton } },
|
||||
});
|
||||
|
||||
addJudgementAssert(hitObjects[0], HitResult.Great);
|
||||
addJudgementAssert(hitObjects[0], HitResult.Ok);
|
||||
addJudgementAssert(hitObjects[1], HitResult.Great);
|
||||
addJudgementAssert("slider head", () => ((Slider)hitObjects[1]).HeadCircle, HitResult.LargeTickHit);
|
||||
addJudgementAssert("slider tick", () => ((Slider)hitObjects[1]).NestedHitObjects[1] as SliderTick, HitResult.LargeTickHit);
|
||||
addClickActionAssert(0, ClickAction.Hit);
|
||||
addClickActionAssert(1, ClickAction.Hit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -304,7 +338,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
public void TestHitCircleBeforeSpinner()
|
||||
{
|
||||
const double time_spinner = 1500;
|
||||
const double time_circle = 1800;
|
||||
const double time_circle = 1600;
|
||||
Vector2 positionCircle = Vector2.Zero;
|
||||
|
||||
var hitObjects = new List<OsuHitObject>
|
||||
@ -315,7 +349,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
Position = new Vector2(256, 192),
|
||||
EndTime = time_spinner + 1000,
|
||||
},
|
||||
new TestHitCircle
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_circle,
|
||||
Position = positionCircle
|
||||
@ -324,7 +358,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
performTest(hitObjects, new List<ReplayFrame>
|
||||
{
|
||||
new OsuReplayFrame { Time = time_spinner - 100, Position = positionCircle, Actions = { OsuAction.LeftButton } },
|
||||
new OsuReplayFrame { Time = time_spinner - 90, Position = positionCircle, Actions = { OsuAction.LeftButton } },
|
||||
new OsuReplayFrame { Time = time_spinner + 10, Position = new Vector2(236, 192), Actions = { OsuAction.RightButton } },
|
||||
new OsuReplayFrame { Time = time_spinner + 20, Position = new Vector2(256, 172), Actions = { OsuAction.RightButton } },
|
||||
new OsuReplayFrame { Time = time_spinner + 30, Position = new Vector2(276, 192), Actions = { OsuAction.RightButton } },
|
||||
@ -333,7 +367,8 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
});
|
||||
|
||||
addJudgementAssert(hitObjects[0], HitResult.Great);
|
||||
addJudgementAssert(hitObjects[1], HitResult.Great);
|
||||
addJudgementAssert(hitObjects[1], HitResult.Meh);
|
||||
addClickActionAssert(0, ClickAction.Hit);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -346,12 +381,12 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
var hitObjects = new List<OsuHitObject>
|
||||
{
|
||||
new TestHitCircle
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_circle,
|
||||
Position = positionCircle
|
||||
},
|
||||
new TestSlider
|
||||
new Slider
|
||||
{
|
||||
StartTime = time_slider,
|
||||
Position = positionSlider,
|
||||
@ -372,6 +407,102 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
addJudgementAssert(hitObjects[0], HitResult.Great);
|
||||
addJudgementAssert(hitObjects[1], HitResult.Great);
|
||||
addClickActionAssert(0, ClickAction.Shake);
|
||||
addClickActionAssert(1, ClickAction.Hit);
|
||||
addClickActionAssert(2, ClickAction.Hit);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOverlappingSliders()
|
||||
{
|
||||
const double time_first_slider = 1000;
|
||||
const double time_second_slider = 1200;
|
||||
Vector2 positionFirstSlider = new Vector2(100, 50);
|
||||
Vector2 positionSecondSlider = new Vector2(100, 80);
|
||||
var midpoint = (positionFirstSlider + positionSecondSlider) / 2;
|
||||
|
||||
var hitObjects = new List<OsuHitObject>
|
||||
{
|
||||
new Slider
|
||||
{
|
||||
StartTime = time_first_slider,
|
||||
Position = positionFirstSlider,
|
||||
Path = new SliderPath(PathType.Linear, new[]
|
||||
{
|
||||
Vector2.Zero,
|
||||
new Vector2(25, 0),
|
||||
})
|
||||
},
|
||||
new Slider
|
||||
{
|
||||
StartTime = time_second_slider,
|
||||
Position = positionSecondSlider,
|
||||
Path = new SliderPath(PathType.Linear, new[]
|
||||
{
|
||||
Vector2.Zero,
|
||||
new Vector2(25, 0),
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
performTest(hitObjects, new List<ReplayFrame>
|
||||
{
|
||||
new OsuReplayFrame { Time = time_first_slider, Position = midpoint, Actions = { OsuAction.RightButton } },
|
||||
new OsuReplayFrame { Time = time_first_slider + 25, Position = midpoint, Actions = { OsuAction.LeftButton, OsuAction.RightButton } },
|
||||
new OsuReplayFrame { Time = time_first_slider + 50, Position = midpoint },
|
||||
new OsuReplayFrame { Time = time_second_slider, Position = positionSecondSlider + new Vector2(0, 10), Actions = { OsuAction.LeftButton } },
|
||||
});
|
||||
|
||||
addJudgementAssert(hitObjects[0], HitResult.Ok);
|
||||
addJudgementAssert(hitObjects[1], HitResult.Great);
|
||||
addClickActionAssert(0, ClickAction.Hit);
|
||||
addClickActionAssert(1, ClickAction.Hit);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStacksDoNotShake()
|
||||
{
|
||||
const double time_stack_start = 1000;
|
||||
Vector2 position = new Vector2(80);
|
||||
|
||||
var hitObjects = Enumerable.Range(0, 20).Select(i => new HitCircle
|
||||
{
|
||||
StartTime = time_stack_start + i * 100,
|
||||
Position = position
|
||||
}).Cast<OsuHitObject>().ToList();
|
||||
|
||||
performTest(hitObjects, new List<ReplayFrame>
|
||||
{
|
||||
new OsuReplayFrame { Time = time_stack_start - 450, Position = new Vector2(55), Actions = { OsuAction.LeftButton } },
|
||||
});
|
||||
|
||||
addClickActionAssert(0, ClickAction.Ignore);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAutopilotReducesHittableRange()
|
||||
{
|
||||
const double time_circle = 1500;
|
||||
Vector2 positionCircle = Vector2.Zero;
|
||||
|
||||
var hitObjects = new List<OsuHitObject>
|
||||
{
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = time_circle,
|
||||
Position = positionCircle
|
||||
},
|
||||
};
|
||||
|
||||
performTest(hitObjects, new List<ReplayFrame>
|
||||
{
|
||||
new OsuReplayFrame { Time = time_circle - 250, Position = positionCircle, Actions = { OsuAction.LeftButton } }
|
||||
}, new Mod[] { new OsuModAutopilot() });
|
||||
|
||||
addJudgementAssert(hitObjects[0], HitResult.Miss);
|
||||
// note lock prevented the object from being hit, so the judgement offset should be very late.
|
||||
addJudgementOffsetAssert(hitObjects[0], referenceHitWindows.WindowFor(HitResult.Meh));
|
||||
addClickActionAssert(0, ClickAction.Shake);
|
||||
}
|
||||
|
||||
private void addJudgementAssert(OsuHitObject hitObject, HitResult result)
|
||||
@ -380,38 +511,119 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
() => judgementResults.Single(r => r.HitObject == hitObject).Type, () => Is.EqualTo(result));
|
||||
}
|
||||
|
||||
private void addJudgementAssert(string name, Func<OsuHitObject> hitObject, HitResult result)
|
||||
private void addJudgementAssert(string name, Func<OsuHitObject?> hitObject, HitResult result)
|
||||
{
|
||||
AddAssert($"{name} judgement is {result}",
|
||||
() => judgementResults.Single(r => r.HitObject == hitObject()).Type == result);
|
||||
() => judgementResults.Single(r => r.HitObject == hitObject()).Type, () => Is.EqualTo(result));
|
||||
}
|
||||
|
||||
private void addJudgementOffsetAssert(OsuHitObject hitObject, double offset)
|
||||
{
|
||||
AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judged at {offset}",
|
||||
() => Precision.AlmostEquals(judgementResults.Single(r => r.HitObject == hitObject).TimeOffset, offset, 100));
|
||||
() => judgementResults.Single(r => r.HitObject == hitObject).TimeOffset, () => Is.EqualTo(offset).Within(50));
|
||||
}
|
||||
|
||||
private ScoreAccessibleReplayPlayer currentPlayer;
|
||||
private List<JudgementResult> judgementResults;
|
||||
private void addClickActionAssert(int inputIndex, ClickAction action)
|
||||
=> AddAssert($"input #{inputIndex} resulted in {action}", () => testPolicy.ClickActions[inputIndex], () => Is.EqualTo(action));
|
||||
|
||||
private void performTest(List<OsuHitObject> hitObjects, List<ReplayFrame> frames)
|
||||
private ScoreAccessibleReplayPlayer currentPlayer = null!;
|
||||
private List<JudgementResult> judgementResults = null!;
|
||||
private TestLegacyHitPolicy testPolicy = null!;
|
||||
|
||||
private void performTest(List<OsuHitObject> hitObjects, List<ReplayFrame> frames, IEnumerable<Mod>? extraMods = null, [CallerMemberName] string testCaseName = "")
|
||||
{
|
||||
AddStep("load player", () =>
|
||||
List<Mod> mods = null!;
|
||||
IBeatmap playableBeatmap = null!;
|
||||
Score score = null!;
|
||||
|
||||
AddStep("set up mods", () =>
|
||||
{
|
||||
mods = new List<Mod> { new OsuModClassic() };
|
||||
|
||||
if (extraMods != null)
|
||||
mods.AddRange(extraMods);
|
||||
});
|
||||
|
||||
AddStep("create beatmap", () =>
|
||||
{
|
||||
var cpi = new ControlPointInfo();
|
||||
cpi.Add(0, new TimingControlPoint { BeatLength = 1000 });
|
||||
Beatmap.Value = CreateWorkingBeatmap(new Beatmap<OsuHitObject>
|
||||
{
|
||||
Metadata =
|
||||
{
|
||||
Title = testCaseName
|
||||
},
|
||||
HitObjects = hitObjects,
|
||||
Difficulty = new BeatmapDifficulty { SliderTickRate = 3 },
|
||||
Difficulty = new BeatmapDifficulty
|
||||
{
|
||||
OverallDifficulty = 0,
|
||||
SliderTickRate = 3
|
||||
},
|
||||
BeatmapInfo =
|
||||
{
|
||||
Ruleset = new OsuRuleset().RulesetInfo
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
BeatmapVersion = LegacyBeatmapEncoder.FIRST_LAZER_VERSION // for correct offset treatment by score encoder
|
||||
},
|
||||
ControlPointInfo = cpi
|
||||
});
|
||||
playableBeatmap = Beatmap.Value.GetPlayableBeatmap(new OsuRuleset().RulesetInfo);
|
||||
});
|
||||
|
||||
AddStep("create score", () =>
|
||||
{
|
||||
score = new Score
|
||||
{
|
||||
Replay = new Replay
|
||||
{
|
||||
Frames = new List<ReplayFrame>
|
||||
{
|
||||
// required for correct playback in stable
|
||||
new OsuReplayFrame(0, new Vector2(256, -500)),
|
||||
new OsuReplayFrame(0, new Vector2(256, -500))
|
||||
}.Concat(frames).ToList()
|
||||
},
|
||||
ScoreInfo =
|
||||
{
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
BeatmapInfo = playableBeatmap.BeatmapInfo,
|
||||
Mods = mods.ToArray()
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
if (exportLocation != null)
|
||||
{
|
||||
AddStep("export beatmap", () =>
|
||||
{
|
||||
var beatmapEncoder = new LegacyBeatmapEncoder(playableBeatmap, null);
|
||||
|
||||
using (var stream = File.Open(Path.Combine(exportLocation, $"{testCaseName}.osu"), FileMode.Create))
|
||||
{
|
||||
var memoryStream = new MemoryStream();
|
||||
using (var writer = new StreamWriter(memoryStream, Encoding.UTF8, leaveOpen: true))
|
||||
beatmapEncoder.Encode(writer);
|
||||
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
memoryStream.CopyTo(stream);
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
playableBeatmap.BeatmapInfo.MD5Hash = memoryStream.ComputeMD5Hash();
|
||||
}
|
||||
});
|
||||
|
||||
SelectedMods.Value = new[] { new OsuModClassic() };
|
||||
AddStep("export score", () =>
|
||||
{
|
||||
using var stream = File.Open(Path.Combine(exportLocation, $"{testCaseName}.osr"), FileMode.Create);
|
||||
var encoder = new LegacyScoreEncoder(score, playableBeatmap);
|
||||
encoder.Encode(stream);
|
||||
});
|
||||
}
|
||||
|
||||
var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } });
|
||||
AddStep("load player", () =>
|
||||
{
|
||||
SelectedMods.Value = mods.ToArray();
|
||||
|
||||
var p = new ScoreAccessibleReplayPlayer(score);
|
||||
|
||||
p.OnLoadComplete += _ =>
|
||||
{
|
||||
@ -427,29 +639,13 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
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 class TestHitCircle : HitCircle
|
||||
{
|
||||
protected override HitWindows CreateHitWindows() => new TestHitWindows();
|
||||
}
|
||||
|
||||
private class TestSlider : Slider
|
||||
{
|
||||
public TestSlider()
|
||||
AddStep("Substitute hit policy", () =>
|
||||
{
|
||||
SliderVelocity = 0.1f;
|
||||
|
||||
DefaultsApplied += _ =>
|
||||
{
|
||||
HeadCircle.HitWindows = new TestHitWindows();
|
||||
TailCircle.HitWindows = new TestHitWindows();
|
||||
|
||||
HeadCircle.HitWindows.SetDifficulty(0);
|
||||
TailCircle.HitWindows.SetDifficulty(0);
|
||||
};
|
||||
}
|
||||
var playfield = currentPlayer.ChildrenOfType<OsuPlayfield>().Single();
|
||||
var currentPolicy = playfield.HitPolicy;
|
||||
playfield.HitPolicy = testPolicy = new TestLegacyHitPolicy(currentPolicy);
|
||||
});
|
||||
AddUntilStep("Wait for completion", () => currentPlayer.ScoreProcessor.HasCompleted.Value);
|
||||
}
|
||||
|
||||
private class TestSpinner : Spinner
|
||||
@ -461,19 +657,6 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
}
|
||||
}
|
||||
|
||||
private class TestHitWindows : HitWindows
|
||||
{
|
||||
private static readonly DifficultyRange[] ranges =
|
||||
{
|
||||
new DifficultyRange(HitResult.Great, 500, 500, 500),
|
||||
new DifficultyRange(HitResult.Miss, early_miss_window, early_miss_window, early_miss_window),
|
||||
};
|
||||
|
||||
public override bool IsHitResultAllowed(HitResult result) => result == HitResult.Great || result == HitResult.Miss;
|
||||
|
||||
protected override DifficultyRange[] GetRanges() => ranges;
|
||||
}
|
||||
|
||||
private partial class ScoreAccessibleReplayPlayer : ReplayPlayer
|
||||
{
|
||||
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
|
||||
@ -489,5 +672,24 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class TestLegacyHitPolicy : LegacyHitPolicy
|
||||
{
|
||||
private readonly IHitPolicy currentPolicy;
|
||||
|
||||
public TestLegacyHitPolicy(IHitPolicy currentPolicy)
|
||||
{
|
||||
this.currentPolicy = currentPolicy;
|
||||
}
|
||||
|
||||
public List<ClickAction> ClickActions { get; } = new List<ClickAction>();
|
||||
|
||||
public override ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result)
|
||||
{
|
||||
var action = currentPolicy.CheckHittable(hitObject, time, result);
|
||||
ClickActions.Add(action);
|
||||
return action;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -85,6 +85,11 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
// we may be entering the screen with a selection already active
|
||||
updateDistanceSnapGrid();
|
||||
|
||||
RightToolbox.Add(new TransformToolboxGroup
|
||||
{
|
||||
RotationHandler = BlueprintContainer.SelectionHandler.RotationHandler
|
||||
});
|
||||
}
|
||||
|
||||
protected override ComposeBlueprintContainer CreateBlueprintContainer()
|
||||
|
107
osu.Game.Rulesets.Osu/Edit/PreciseRotationPopover.cs
Normal file
107
osu.Game.Rulesets.Osu/Edit/PreciseRotationPopover.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 osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Screens.Edit.Components.RadioButtons;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
public partial class PreciseRotationPopover : OsuPopover
|
||||
{
|
||||
private readonly SelectionRotationHandler rotationHandler;
|
||||
|
||||
private readonly Bindable<PreciseRotationInfo> rotationInfo = new Bindable<PreciseRotationInfo>(new PreciseRotationInfo(0, RotationOrigin.PlayfieldCentre));
|
||||
|
||||
private SliderWithTextBoxInput<float> angleInput = null!;
|
||||
private EditorRadioButtonCollection rotationOrigin = null!;
|
||||
|
||||
public PreciseRotationPopover(SelectionRotationHandler rotationHandler)
|
||||
{
|
||||
this.rotationHandler = rotationHandler;
|
||||
|
||||
AllowableAnchors = new[] { Anchor.CentreLeft, Anchor.CentreRight };
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
Width = 220,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(20),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
angleInput = new SliderWithTextBoxInput<float>("Angle (degrees):")
|
||||
{
|
||||
Current = new BindableNumber<float>
|
||||
{
|
||||
MinValue = -360,
|
||||
MaxValue = 360,
|
||||
Precision = 1
|
||||
},
|
||||
Instantaneous = true
|
||||
},
|
||||
rotationOrigin = new EditorRadioButtonCollection
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Items = new[]
|
||||
{
|
||||
new RadioButton("Playfield centre",
|
||||
() => rotationInfo.Value = rotationInfo.Value with { Origin = RotationOrigin.PlayfieldCentre },
|
||||
() => new SpriteIcon { Icon = FontAwesome.Regular.Square }),
|
||||
new RadioButton("Selection centre",
|
||||
() => rotationInfo.Value = rotationInfo.Value with { Origin = RotationOrigin.SelectionCentre },
|
||||
() => new SpriteIcon { Icon = FontAwesome.Solid.VectorSquare })
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
ScheduleAfterChildren(() => angleInput.TakeFocus());
|
||||
angleInput.Current.BindValueChanged(angle => rotationInfo.Value = rotationInfo.Value with { Degrees = angle.NewValue });
|
||||
rotationOrigin.Items.First().Select();
|
||||
|
||||
rotationInfo.BindValueChanged(rotation =>
|
||||
{
|
||||
rotationHandler.Update(rotation.NewValue.Degrees, rotation.NewValue.Origin == RotationOrigin.PlayfieldCentre ? OsuPlayfield.BASE_SIZE / 2 : null);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
base.PopIn();
|
||||
rotationHandler.Begin();
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
base.PopOut();
|
||||
|
||||
if (IsLoaded)
|
||||
rotationHandler.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
public enum RotationOrigin
|
||||
{
|
||||
PlayfieldCentre,
|
||||
SelectionCentre
|
||||
}
|
||||
|
||||
public record PreciseRotationInfo(float Degrees, RotationOrigin Origin);
|
||||
}
|
80
osu.Game.Rulesets.Osu/Edit/TransformToolboxGroup.cs
Normal file
80
osu.Game.Rulesets.Osu/Edit/TransformToolboxGroup.cs
Normal file
@ -0,0 +1,80 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Screens.Edit.Components;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
public partial class TransformToolboxGroup : EditorToolboxGroup, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
private readonly Bindable<bool> canRotate = new BindableBool();
|
||||
|
||||
private EditorToolButton rotateButton = null!;
|
||||
|
||||
public SelectionRotationHandler RotationHandler { get; init; } = null!;
|
||||
|
||||
public TransformToolboxGroup()
|
||||
: base("transform")
|
||||
{
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
rotateButton = new EditorToolButton("Rotate",
|
||||
() => new SpriteIcon { Icon = FontAwesome.Solid.Undo },
|
||||
() => new PreciseRotationPopover(RotationHandler)),
|
||||
// TODO: scale
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
// bindings to `Enabled` on the buttons are decoupled on purpose
|
||||
// due to the weird `OsuButton` behaviour of resetting `Enabled` to `false` when `Action` is set.
|
||||
canRotate.BindTo(RotationHandler.CanRotate);
|
||||
canRotate.BindValueChanged(_ => rotateButton.Enabled.Value = canRotate.Value, true);
|
||||
}
|
||||
|
||||
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||
{
|
||||
if (e.Repeat) return false;
|
||||
|
||||
switch (e.Action)
|
||||
{
|
||||
case GlobalAction.EditorToggleRotateControl:
|
||||
{
|
||||
rotateButton.TriggerClick();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Scoring;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
@ -57,7 +58,10 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
var osuRuleset = (DrawableOsuRuleset)drawableRuleset;
|
||||
|
||||
if (ClassicNoteLock.Value)
|
||||
osuRuleset.Playfield.HitPolicy = new ObjectOrderedHitPolicy();
|
||||
{
|
||||
double hittableRange = OsuHitWindows.MISS_WINDOW - (drawableRuleset.Mods.OfType<OsuModAutopilot>().Any() ? 200 : 0);
|
||||
osuRuleset.Playfield.HitPolicy = new LegacyHitPolicy(hittableRange);
|
||||
}
|
||||
|
||||
usingHiddenFading = drawableRuleset.Mods.OfType<OsuModHidden>().SingleOrDefault()?.OnlyFadeApproachCircles.Value == false;
|
||||
}
|
||||
@ -85,13 +89,16 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
private void applyEarlyFading(DrawableHitCircle circle)
|
||||
{
|
||||
circle.ApplyCustomUpdateState += (o, _) =>
|
||||
circle.ApplyCustomUpdateState += (dho, state) =>
|
||||
{
|
||||
using (o.BeginAbsoluteSequence(o.StateUpdateTime))
|
||||
using (dho.BeginAbsoluteSequence(dho.StateUpdateTime))
|
||||
{
|
||||
double okWindow = o.HitObject.HitWindows.WindowFor(HitResult.Ok);
|
||||
double lateMissFadeTime = o.HitObject.HitWindows.WindowFor(HitResult.Meh) - okWindow;
|
||||
o.Delay(okWindow).FadeOut(lateMissFadeTime);
|
||||
if (state != ArmedState.Hit)
|
||||
{
|
||||
double okWindow = dho.HitObject.HitWindows.WindowFor(HitResult.Ok);
|
||||
double lateMissFadeTime = dho.HitObject.HitWindows.WindowFor(HitResult.Meh) - okWindow;
|
||||
dho.Delay(okWindow).FadeOut(lateMissFadeTime);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Osu.Skinning;
|
||||
using osu.Game.Rulesets.Osu.Skinning.Default;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
@ -154,12 +155,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
}
|
||||
|
||||
var result = ResultFor(timeOffset);
|
||||
var clickAction = CheckHittable?.Invoke(this, Time.Current, result);
|
||||
|
||||
if (result == HitResult.None || CheckHittable?.Invoke(this, Time.Current) == false)
|
||||
{
|
||||
if (clickAction == ClickAction.Shake)
|
||||
Shake();
|
||||
|
||||
if (result == HitResult.None || clickAction != ClickAction.Hit)
|
||||
return;
|
||||
}
|
||||
|
||||
ApplyResult(r =>
|
||||
{
|
||||
|
@ -12,6 +12,8 @@ using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Osu.Scoring;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -30,10 +32,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
protected override float SamplePlaybackPosition => CalculateDrawableRelativePosition(this);
|
||||
|
||||
/// <summary>
|
||||
/// Whether this <see cref="DrawableOsuHitObject"/> can be hit, given a time value.
|
||||
/// If non-null, judgements will be ignored (resulting in a shake) whilst the function returns false.
|
||||
/// What action this <see cref="DrawableOsuHitObject"/> should take in response to a
|
||||
/// click at the given time value.
|
||||
/// If non-null, judgements will be ignored for return values of <see cref="ClickAction.Ignore"/>
|
||||
/// and <see cref="ClickAction.Shake"/>, and this hit object will be shaken for return values of
|
||||
/// <see cref="ClickAction.Shake"/>.
|
||||
/// </summary>
|
||||
public Func<DrawableHitObject, double, bool> CheckHittable;
|
||||
public Func<DrawableHitObject, double, HitResult, ClickAction> CheckHittable;
|
||||
|
||||
protected DrawableOsuHitObject(OsuHitObject hitObject)
|
||||
: base(hitObject)
|
||||
|
@ -8,6 +8,7 @@ using System.Diagnostics;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
@ -60,7 +61,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
|
||||
pathVersion.BindTo(DrawableSlider.PathVersion);
|
||||
|
||||
CheckHittable = (d, t) => DrawableSlider.CheckHittable?.Invoke(d, t) ?? true;
|
||||
CheckHittable = (d, t, r) => DrawableSlider.CheckHittable?.Invoke(d, t, r) ?? ClickAction.Hit;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
|
@ -257,7 +257,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
texture.Bind();
|
||||
|
||||
for (int i = 0; i < points.Count; i++)
|
||||
drawPointQuad(points[i], textureRect, i + firstVisiblePointIndex);
|
||||
drawPointQuad(renderer, points[i], textureRect, i + firstVisiblePointIndex);
|
||||
|
||||
UnbindTextureShader(renderer);
|
||||
renderer.PopLocalMatrix();
|
||||
@ -325,7 +325,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
|
||||
private float getRotation(int index) => max_rotation * (StatelessRNG.NextSingle(rotationSeed, index) * 2 - 1);
|
||||
|
||||
private void drawPointQuad(SmokePoint point, RectangleF textureRect, int index)
|
||||
private void drawPointQuad(IRenderer renderer, SmokePoint point, RectangleF textureRect, int index)
|
||||
{
|
||||
Debug.Assert(quadBatch != null);
|
||||
|
||||
@ -347,25 +347,25 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
var localBotLeft = point.Position + ortho - dir;
|
||||
var localBotRight = point.Position + ortho + dir;
|
||||
|
||||
quadBatch.Add(new TexturedVertex2D
|
||||
quadBatch.Add(new TexturedVertex2D(renderer)
|
||||
{
|
||||
Position = localTopLeft,
|
||||
TexturePosition = textureRect.TopLeft,
|
||||
Colour = Color4Extensions.Multiply(ColourAtPosition(localTopLeft), colour),
|
||||
});
|
||||
quadBatch.Add(new TexturedVertex2D
|
||||
quadBatch.Add(new TexturedVertex2D(renderer)
|
||||
{
|
||||
Position = localTopRight,
|
||||
TexturePosition = textureRect.TopRight,
|
||||
Colour = Color4Extensions.Multiply(ColourAtPosition(localTopRight), colour),
|
||||
});
|
||||
quadBatch.Add(new TexturedVertex2D
|
||||
quadBatch.Add(new TexturedVertex2D(renderer)
|
||||
{
|
||||
Position = localBotRight,
|
||||
TexturePosition = textureRect.BottomRight,
|
||||
Colour = Color4Extensions.Multiply(ColourAtPosition(localBotRight), colour),
|
||||
});
|
||||
quadBatch.Add(new TexturedVertex2D
|
||||
quadBatch.Add(new TexturedVertex2D(renderer)
|
||||
{
|
||||
Position = localBotLeft,
|
||||
TexturePosition = textureRect.BottomLeft,
|
||||
|
@ -1,9 +1,8 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
@ -13,9 +12,9 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
/// </summary>
|
||||
public class AnyOrderHitPolicy : IHitPolicy
|
||||
{
|
||||
public IHitObjectContainer HitObjectContainer { get; set; }
|
||||
public IHitObjectContainer HitObjectContainer { get; set; } = null!;
|
||||
|
||||
public bool IsHittable(DrawableHitObject hitObject, double time) => true;
|
||||
public ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result) => ClickAction.Hit;
|
||||
|
||||
public void HandleHit(DrawableHitObject hitObject)
|
||||
{
|
||||
|
18
osu.Game.Rulesets.Osu/UI/ClickAction.cs
Normal file
18
osu.Game.Rulesets.Osu/UI/ClickAction.cs
Normal file
@ -0,0 +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 osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// An action that an <see cref="IHitPolicy"/> recommends be taken in response to a click
|
||||
/// on a <see cref="DrawableOsuHitObject"/>.
|
||||
/// </summary>
|
||||
public enum ClickAction
|
||||
{
|
||||
Ignore,
|
||||
Shake,
|
||||
Hit
|
||||
}
|
||||
}
|
@ -286,7 +286,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
if (time - part.Time >= 1)
|
||||
continue;
|
||||
|
||||
vertexBatch.Add(new TexturedTrailVertex
|
||||
vertexBatch.Add(new TexturedTrailVertex(renderer)
|
||||
{
|
||||
Position = new Vector2(part.Position.X - size.X * originPosition.X, part.Position.Y + size.Y * (1 - originPosition.Y)),
|
||||
TexturePosition = textureRect.BottomLeft,
|
||||
@ -295,7 +295,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
Time = part.Time
|
||||
});
|
||||
|
||||
vertexBatch.Add(new TexturedTrailVertex
|
||||
vertexBatch.Add(new TexturedTrailVertex(renderer)
|
||||
{
|
||||
Position = new Vector2(part.Position.X + size.X * (1 - originPosition.X), part.Position.Y + size.Y * (1 - originPosition.Y)),
|
||||
TexturePosition = textureRect.BottomRight,
|
||||
@ -304,7 +304,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
Time = part.Time
|
||||
});
|
||||
|
||||
vertexBatch.Add(new TexturedTrailVertex
|
||||
vertexBatch.Add(new TexturedTrailVertex(renderer)
|
||||
{
|
||||
Position = new Vector2(part.Position.X + size.X * (1 - originPosition.X), part.Position.Y - size.Y * originPosition.Y),
|
||||
TexturePosition = textureRect.TopRight,
|
||||
@ -313,7 +313,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
Time = part.Time
|
||||
});
|
||||
|
||||
vertexBatch.Add(new TexturedTrailVertex
|
||||
vertexBatch.Add(new TexturedTrailVertex(renderer)
|
||||
{
|
||||
Position = new Vector2(part.Position.X - size.X * originPosition.X, part.Position.Y - size.Y * originPosition.Y),
|
||||
TexturePosition = textureRect.TopLeft,
|
||||
@ -362,12 +362,22 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
[VertexMember(1, VertexAttribPointerType.Float)]
|
||||
public float Time;
|
||||
|
||||
[VertexMember(1, VertexAttribPointerType.Int)]
|
||||
private readonly int maskingIndex;
|
||||
|
||||
public TexturedTrailVertex(IRenderer renderer)
|
||||
{
|
||||
this = default;
|
||||
maskingIndex = renderer.CurrentMaskingIndex;
|
||||
}
|
||||
|
||||
public bool Equals(TexturedTrailVertex other)
|
||||
{
|
||||
return Position.Equals(other.Position)
|
||||
&& TexturePosition.Equals(other.TexturePosition)
|
||||
&& Colour.Equals(other.Colour)
|
||||
&& Time.Equals(other.Time);
|
||||
&& Time.Equals(other.Time)
|
||||
&& maskingIndex == other.maskingIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
@ -19,8 +20,9 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to check.</param>
|
||||
/// <param name="time">The time to check.</param>
|
||||
/// <param name="result">The result that the object would be judged with if hit.</param>
|
||||
/// <returns>Whether <paramref name="hitObject"/> can be hit at the given <paramref name="time"/>.</returns>
|
||||
bool IsHittable(DrawableHitObject hitObject, double time);
|
||||
ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result);
|
||||
|
||||
/// <summary>
|
||||
/// Handles a <see cref="HitObject"/> being hit.
|
||||
|
72
osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs
Normal file
72
osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs
Normal file
@ -0,0 +1,72 @@
|
||||
// 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 osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Scoring;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Ensures that <see cref="HitObject"/>s are hit in order of appearance. The classic note lock.
|
||||
/// <remarks>
|
||||
/// Hits will be blocked until the previous <see cref="HitObject"/>s have been judged.
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public class LegacyHitPolicy : IHitPolicy
|
||||
{
|
||||
public IHitObjectContainer? HitObjectContainer { get; set; }
|
||||
|
||||
private readonly double hittableRange;
|
||||
|
||||
public LegacyHitPolicy(double hittableRange = OsuHitWindows.MISS_WINDOW)
|
||||
{
|
||||
this.hittableRange = hittableRange;
|
||||
}
|
||||
|
||||
public void HandleHit(DrawableHitObject hitObject)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result)
|
||||
{
|
||||
if (HitObjectContainer == null)
|
||||
throw new InvalidOperationException($"{nameof(HitObjectContainer)} should be set before {nameof(CheckHittable)} is called.");
|
||||
|
||||
var aliveObjects = HitObjectContainer.AliveObjects.ToList();
|
||||
int index = aliveObjects.IndexOf(hitObject);
|
||||
|
||||
if (index > 0)
|
||||
{
|
||||
var previousHitObject = (DrawableOsuHitObject)aliveObjects[index - 1];
|
||||
if (previousHitObject.HitObject.StackHeight > 0 && !previousHitObject.AllJudged)
|
||||
return ClickAction.Ignore;
|
||||
}
|
||||
|
||||
if (result == HitResult.None)
|
||||
return ClickAction.Shake;
|
||||
|
||||
foreach (DrawableHitObject testObject in aliveObjects)
|
||||
{
|
||||
if (testObject.AllJudged)
|
||||
continue;
|
||||
|
||||
// if we found the object being checked, we can move on to the final timing test.
|
||||
if (testObject == hitObject)
|
||||
break;
|
||||
|
||||
// for all other objects, we check for validity and block the hit if any are still valid.
|
||||
// 3ms of extra leniency to account for slightly unsnapped objects.
|
||||
if (testObject.HitObject.GetEndTime() + 3 < hitObject.HitObject.StartTime)
|
||||
return ClickAction.Shake;
|
||||
}
|
||||
|
||||
return Math.Abs(hitObject.HitObject.StartTime - time) < hittableRange ? ClickAction.Hit : ClickAction.Shake;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,56 +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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Ensures that <see cref="HitObject"/>s are hit in order of appearance. The classic note lock.
|
||||
/// <remarks>
|
||||
/// Hits will be blocked until the previous <see cref="HitObject"/>s have been judged.
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public class ObjectOrderedHitPolicy : IHitPolicy
|
||||
{
|
||||
public IHitObjectContainer HitObjectContainer { get; set; }
|
||||
|
||||
public bool IsHittable(DrawableHitObject hitObject, double time) => enumerateHitObjectsUpTo(hitObject.HitObject.StartTime).All(obj => obj.AllJudged);
|
||||
|
||||
public void HandleHit(DrawableHitObject hitObject)
|
||||
{
|
||||
}
|
||||
|
||||
private IEnumerable<DrawableHitObject> enumerateHitObjectsUpTo(double targetTime)
|
||||
{
|
||||
foreach (var obj in HitObjectContainer.AliveObjects)
|
||||
{
|
||||
if (obj.HitObject.StartTime >= targetTime)
|
||||
yield break;
|
||||
|
||||
switch (obj)
|
||||
{
|
||||
case DrawableSpinner:
|
||||
continue;
|
||||
|
||||
case DrawableSlider slider:
|
||||
yield return slider.HeadCircle;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
yield return obj;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -89,7 +89,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
|
||||
protected override void OnNewDrawableHitObject(DrawableHitObject drawable)
|
||||
{
|
||||
((DrawableOsuHitObject)drawable).CheckHittable = hitPolicy.IsHittable;
|
||||
((DrawableOsuHitObject)drawable).CheckHittable = hitPolicy.CheckHittable;
|
||||
|
||||
Debug.Assert(!drawable.IsLoaded, $"Already loaded {nameof(DrawableHitObject)} is added to {nameof(OsuPlayfield)}");
|
||||
drawable.OnLoadComplete += onDrawableHitObjectLoaded;
|
||||
|
@ -1,13 +1,12 @@
|
||||
// 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 osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
@ -22,11 +21,14 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
/// </summary>
|
||||
public class StartTimeOrderedHitPolicy : IHitPolicy
|
||||
{
|
||||
public IHitObjectContainer HitObjectContainer { get; set; }
|
||||
public IHitObjectContainer? HitObjectContainer { get; set; }
|
||||
|
||||
public bool IsHittable(DrawableHitObject hitObject, double time)
|
||||
public ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult _)
|
||||
{
|
||||
DrawableHitObject blockingObject = null;
|
||||
if (HitObjectContainer == null)
|
||||
throw new InvalidOperationException($"{nameof(HitObjectContainer)} should be set before {nameof(CheckHittable)} is called.");
|
||||
|
||||
DrawableHitObject? blockingObject = null;
|
||||
|
||||
foreach (var obj in enumerateHitObjectsUpTo(hitObject.HitObject.StartTime))
|
||||
{
|
||||
@ -36,22 +38,25 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
|
||||
// If there is no previous hitobject, allow the hit.
|
||||
if (blockingObject == null)
|
||||
return true;
|
||||
return ClickAction.Hit;
|
||||
|
||||
// A hit is allowed if:
|
||||
// 1. The last blocking hitobject has been judged.
|
||||
// 2. The current time is after the last hitobject's start time.
|
||||
// Hits at exactly the same time as the blocking hitobject are allowed for maps that contain simultaneous hitobjects (e.g. /b/372245).
|
||||
return blockingObject.Judged || time >= blockingObject.HitObject.StartTime;
|
||||
return (blockingObject.Judged || time >= blockingObject.HitObject.StartTime) ? ClickAction.Hit : ClickAction.Shake;
|
||||
}
|
||||
|
||||
public void HandleHit(DrawableHitObject hitObject)
|
||||
{
|
||||
if (HitObjectContainer == null)
|
||||
throw new InvalidOperationException($"{nameof(HitObjectContainer)} should be set before {nameof(HandleHit)} is called.");
|
||||
|
||||
// Hitobjects which themselves don't block future hitobjects don't cause misses (e.g. slider ticks, spinners).
|
||||
if (!hitObjectCanBlockFutureHits(hitObject))
|
||||
return;
|
||||
|
||||
if (!IsHittable(hitObject, hitObject.HitObject.StartTime + hitObject.Result.TimeOffset))
|
||||
if (CheckHittable(hitObject, hitObject.HitObject.StartTime + hitObject.Result.TimeOffset, hitObject.Result.Type) != ClickAction.Hit)
|
||||
throw new InvalidOperationException($"A {hitObject} was hit before it became hittable!");
|
||||
|
||||
// Miss all hitobjects prior to the hit one.
|
||||
@ -74,7 +79,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
|
||||
private IEnumerable<DrawableHitObject> enumerateHitObjectsUpTo(double targetTime)
|
||||
{
|
||||
foreach (var obj in HitObjectContainer.AliveObjects)
|
||||
foreach (var obj in HitObjectContainer!.AliveObjects)
|
||||
{
|
||||
if (obj.HitObject.StartTime >= targetTime)
|
||||
yield break;
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="osu.Game.Rulesets.Taiko.Tests.Android" android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
|
||||
<application android:allowBackup="true" android:supportsRtl="true" android:label="osu!taiko Test" />
|
||||
</manifest>
|
@ -139,7 +139,6 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
|
||||
StartTime = obj.StartTime,
|
||||
Samples = obj.Samples,
|
||||
Duration = taikoDuration,
|
||||
SliderVelocity = obj is IHasSliderVelocity velocityData ? velocityData.SliderVelocity : 1
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using System.Threading;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
@ -14,7 +13,7 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects
|
||||
{
|
||||
public class DrumRoll : TaikoStrongableHitObject, IHasPath, IHasSliderVelocity
|
||||
public class DrumRoll : TaikoStrongableHitObject, IHasPath
|
||||
{
|
||||
/// <summary>
|
||||
/// Drum roll distance that results in a duration of 1 speed-adjusted beat length.
|
||||
@ -34,19 +33,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
/// </summary>
|
||||
public double Velocity { get; private set; }
|
||||
|
||||
public BindableNumber<double> SliderVelocityBindable { get; } = new BindableDouble(1)
|
||||
{
|
||||
Precision = 0.01,
|
||||
MinValue = 0.1,
|
||||
MaxValue = 10
|
||||
};
|
||||
|
||||
public double SliderVelocity
|
||||
{
|
||||
get => SliderVelocityBindable.Value;
|
||||
set => SliderVelocityBindable.Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Numer of ticks per beat length.
|
||||
/// </summary>
|
||||
@ -63,8 +49,9 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||
|
||||
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
||||
EffectControlPoint effectPoint = controlPointInfo.EffectPointAt(StartTime);
|
||||
|
||||
double scoringDistance = base_distance * difficulty.SliderMultiplier * SliderVelocity;
|
||||
double scoringDistance = base_distance * difficulty.SliderMultiplier * effectPoint.ScrollSpeed;
|
||||
Velocity = scoringDistance / timingPoint.BeatLength;
|
||||
|
||||
TickRate = difficulty.SliderTickRate == 3 ? 3 : 4;
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="osu.Game.Tests.Android" android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
|
||||
<application android:allowBackup="true" android:supportsRtl="true" android:label="osu!visual Test" />
|
||||
</manifest>
|
@ -8,6 +8,9 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Scoring.Legacy;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
using osu.Game.Tests.Visual;
|
||||
@ -15,7 +18,7 @@ using osu.Game.Tests.Visual;
|
||||
namespace osu.Game.Tests.Database
|
||||
{
|
||||
[HeadlessTest]
|
||||
public partial class BackgroundBeatmapProcessorTests : OsuTestScene, ILocalUserPlayInfo
|
||||
public partial class BackgroundDataStoreProcessorTests : OsuTestScene, ILocalUserPlayInfo
|
||||
{
|
||||
public IBindable<bool> IsPlaying => isPlaying;
|
||||
|
||||
@ -59,7 +62,7 @@ namespace osu.Game.Tests.Database
|
||||
|
||||
AddStep("Run background processor", () =>
|
||||
{
|
||||
Add(new TestBackgroundBeatmapProcessor());
|
||||
Add(new TestBackgroundDataStoreProcessor());
|
||||
});
|
||||
|
||||
AddUntilStep("wait for difficulties repopulated", () =>
|
||||
@ -98,7 +101,7 @@ namespace osu.Game.Tests.Database
|
||||
|
||||
AddStep("Run background processor", () =>
|
||||
{
|
||||
Add(new TestBackgroundBeatmapProcessor());
|
||||
Add(new TestBackgroundDataStoreProcessor());
|
||||
});
|
||||
|
||||
AddWaitStep("wait some", 500);
|
||||
@ -124,7 +127,58 @@ namespace osu.Game.Tests.Database
|
||||
});
|
||||
}
|
||||
|
||||
public partial class TestBackgroundBeatmapProcessor : BackgroundBeatmapProcessor
|
||||
[Test]
|
||||
public void TestScoreUpgradeSuccess()
|
||||
{
|
||||
ScoreInfo scoreInfo = null!;
|
||||
|
||||
AddStep("Add score which requires upgrade (and has beatmap)", () =>
|
||||
{
|
||||
Realm.Write(r =>
|
||||
{
|
||||
r.Add(scoreInfo = new ScoreInfo(ruleset: r.All<RulesetInfo>().First(), beatmap: r.All<BeatmapInfo>().First())
|
||||
{
|
||||
TotalScoreVersion = 30000002,
|
||||
LegacyTotalScore = 123456,
|
||||
IsLegacyScore = true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("Run background processor", () => Add(new TestBackgroundDataStoreProcessor()));
|
||||
|
||||
AddUntilStep("Score version upgraded", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.TotalScoreVersion), () => Is.EqualTo(LegacyScoreEncoder.LATEST_VERSION));
|
||||
AddAssert("Score not marked as failed", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.BackgroundReprocessingFailed), () => Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestScoreUpgradeFailed()
|
||||
{
|
||||
ScoreInfo scoreInfo = null!;
|
||||
|
||||
AddStep("Add score which requires upgrade (but has no beatmap)", () =>
|
||||
{
|
||||
Realm.Write(r =>
|
||||
{
|
||||
r.Add(scoreInfo = new ScoreInfo(ruleset: r.All<RulesetInfo>().First(), beatmap: new BeatmapInfo
|
||||
{
|
||||
BeatmapSet = new BeatmapSetInfo(),
|
||||
Ruleset = r.All<RulesetInfo>().First(),
|
||||
})
|
||||
{
|
||||
TotalScoreVersion = 30000002,
|
||||
IsLegacyScore = true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("Run background processor", () => Add(new TestBackgroundDataStoreProcessor()));
|
||||
|
||||
AddUntilStep("Score marked as failed", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.BackgroundReprocessingFailed), () => Is.True);
|
||||
AddAssert("Score version not upgraded", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.TotalScoreVersion), () => Is.EqualTo(30000002));
|
||||
}
|
||||
|
||||
public partial class TestBackgroundDataStoreProcessor : BackgroundDataStoreProcessor
|
||||
{
|
||||
protected override int TimeToSleepDuringGameplay => 10;
|
||||
}
|
@ -1,19 +1,23 @@
|
||||
// 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.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
namespace osu.Game.Tests.Database
|
||||
{
|
||||
[TestFixture]
|
||||
public class LegacyBeatmapImporterTest
|
||||
public class LegacyBeatmapImporterTest : RealmTest
|
||||
{
|
||||
private readonly TestLegacyBeatmapImporter importer = new TestLegacyBeatmapImporter();
|
||||
|
||||
@ -60,6 +64,33 @@ namespace osu.Game.Tests.Database
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStableDateAddedApplied()
|
||||
{
|
||||
RunTestWithRealmAsync(async (realm, storage) =>
|
||||
{
|
||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
|
||||
using (var tmpStorage = new TemporaryNativeStorage("stable-songs-folder"))
|
||||
{
|
||||
var stableStorage = new StableStorage(tmpStorage.GetFullPath(""), host);
|
||||
var songsStorage = stableStorage.GetStorageForDirectory(StableStorage.STABLE_DEFAULT_SONGS_PATH);
|
||||
|
||||
ZipFile.ExtractToDirectory(TestResources.GetQuickTestBeatmapForImport(), songsStorage.GetFullPath("renatus"));
|
||||
|
||||
string[] beatmaps = Directory.GetFiles(songsStorage.GetFullPath("renatus"), "*.osu", SearchOption.TopDirectoryOnly);
|
||||
|
||||
File.SetLastWriteTimeUtc(beatmaps[beatmaps.Length / 2], new DateTime(2000, 1, 1, 12, 0, 0));
|
||||
|
||||
await new LegacyBeatmapImporter(new BeatmapImporter(storage, realm)).ImportFromStableAsync(stableStorage);
|
||||
|
||||
var importedSet = realm.Realm.All<BeatmapSetInfo>().Single();
|
||||
|
||||
Assert.NotNull(importedSet);
|
||||
Assert.AreEqual(new DateTimeOffset(new DateTime(2000, 1, 1, 12, 0, 0, DateTimeKind.Utc)), importedSet.DateAdded);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class TestLegacyBeatmapImporter : LegacyBeatmapImporter
|
||||
{
|
||||
public TestLegacyBeatmapImporter()
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@ -29,7 +30,7 @@ namespace osu.Game.Tests.Editing
|
||||
[Cached(typeof(IBeatSnapProvider))]
|
||||
private readonly EditorBeatmap editorBeatmap;
|
||||
|
||||
protected override Container<Drawable> Content { get; } = new Container { RelativeSizeAxes = Axes.Both };
|
||||
protected override Container<Drawable> Content { get; } = new PopoverContainer { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
public TestSceneHitObjectComposerDistanceSnapping()
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ layout(location = 4) out mediump vec2 v_BlendRange;
|
||||
void main(void)
|
||||
{
|
||||
// Transform from screen space to masking space.
|
||||
highp vec3 maskingPos = g_ToMaskingSpace * vec3(m_Position, 1.0);
|
||||
highp vec3 maskingPos = g_MaskingInfo.ToMaskingSpace * vec3(m_Position, 1.0);
|
||||
v_MaskingPosition = maskingPos.xy / maskingPos.z;
|
||||
|
||||
v_Colour = m_Colour;
|
||||
|
@ -92,25 +92,6 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
}
|
||||
|
||||
[Test]
|
||||
[FlakyTest]
|
||||
/*
|
||||
* Fail rate around 1.2%.
|
||||
*
|
||||
* Failing with realm refetch occasionally being null.
|
||||
* My only guess is that the WorkingBeatmap at SetupScreen is dummy instead of the true one.
|
||||
* If it's something else, we have larger issues with realm, but I don't think that's the case.
|
||||
*
|
||||
* at osu.Framework.Logging.ThrowingTraceListener.Fail(String message1, String message2)
|
||||
* at System.Diagnostics.TraceInternal.Fail(String message, String detailMessage)
|
||||
* at System.Diagnostics.TraceInternal.TraceProvider.Fail(String message, String detailMessage)
|
||||
* at System.Diagnostics.Debug.Fail(String message, String detailMessage)
|
||||
* at osu.Game.Database.ModelManager`1.<>c__DisplayClass8_0.<performFileOperation>b__0(Realm realm) ModelManager.cs:line 50
|
||||
* at osu.Game.Database.RealmExtensions.Write(Realm realm, Action`1 function) RealmExtensions.cs:line 14
|
||||
* at osu.Game.Database.ModelManager`1.performFileOperation(TModel item, Action`1 operation) ModelManager.cs:line 47
|
||||
* at osu.Game.Database.ModelManager`1.AddFile(TModel item, Stream contents, String filename) ModelManager.cs:line 37
|
||||
* at osu.Game.Screens.Edit.Setup.ResourcesSection.ChangeAudioTrack(FileInfo source) ResourcesSection.cs:line 115
|
||||
* at osu.Game.Tests.Visual.Editing.TestSceneEditorBeatmapCreation.<TestAddAudioTrack>b__11_0() TestSceneEditorBeatmapCreation.cs:line 101
|
||||
*/
|
||||
public void TestAddAudioTrack()
|
||||
{
|
||||
AddAssert("track is virtual", () => Beatmap.Value.Track is TrackVirtual);
|
||||
|
@ -8,7 +8,7 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@ -178,7 +178,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddAssert("distance spacing increased by 0.5", () => editorBeatmap.BeatmapInfo.DistanceSpacing == originalSpacing + 0.5);
|
||||
}
|
||||
|
||||
public partial class EditorBeatmapContainer : Container
|
||||
public partial class EditorBeatmapContainer : PopoverContainer
|
||||
{
|
||||
private readonly IWorkingBeatmap working;
|
||||
|
||||
|
@ -185,6 +185,37 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddStep("shorten to -10 length", () => path.ExpectedDistance.Value = -10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetSegmentEnds()
|
||||
{
|
||||
var positions = new[]
|
||||
{
|
||||
Vector2.Zero,
|
||||
new Vector2(100, 0),
|
||||
new Vector2(100),
|
||||
new Vector2(200, 100),
|
||||
};
|
||||
double[] distances = { 100d, 200d, 300d };
|
||||
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(positions.Select(p => new PathControlPoint(p, PathType.Linear))));
|
||||
AddAssert("segment ends are correct", () => path.GetSegmentEnds(), () => Is.EqualTo(distances.Select(d => d / 300)));
|
||||
AddAssert("segment end positions recovered", () => path.GetSegmentEnds().Select(p => path.PositionAt(p)), () => Is.EqualTo(positions.Skip(1)));
|
||||
|
||||
AddStep("lengthen last segment", () => path.ExpectedDistance.Value = 400);
|
||||
AddAssert("segment ends are correct", () => path.GetSegmentEnds(), () => Is.EqualTo(distances.Select(d => d / 400)));
|
||||
AddAssert("segment end positions recovered", () => path.GetSegmentEnds().Select(p => path.PositionAt(p)), () => Is.EqualTo(positions.Skip(1)));
|
||||
|
||||
AddStep("shorten last segment", () => path.ExpectedDistance.Value = 150);
|
||||
AddAssert("segment ends are correct", () => path.GetSegmentEnds(), () => Is.EqualTo(distances.Select(d => d / 150)));
|
||||
// see remarks in `GetSegmentEnds()` xmldoc (`SliderPath.PositionAt()` clamps progress to [0,1]).
|
||||
AddAssert("segment end positions not recovered", () => path.GetSegmentEnds().Select(p => path.PositionAt(p)), () => Is.EqualTo(new[]
|
||||
{
|
||||
positions[1],
|
||||
new Vector2(100, 50),
|
||||
new Vector2(100, 50),
|
||||
}));
|
||||
}
|
||||
|
||||
private List<PathControlPoint> createSegment(PathType type, params Vector2[] controlPoints)
|
||||
{
|
||||
var points = controlPoints.Select(p => new PathControlPoint { Position = p }).ToList();
|
||||
|
@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
foreach (var fountain in Children.OfType<StarFountain>())
|
||||
{
|
||||
if (RNG.NextSingle() > 0.8f)
|
||||
fountain.Shoot();
|
||||
fountain.Shoot(RNG.Next(-1, 2));
|
||||
}
|
||||
}, 150);
|
||||
}
|
||||
|
@ -84,12 +84,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFocusOnTabKeyWhenExpanded()
|
||||
public void TestFocusOnEnterKeyWhenExpanded()
|
||||
{
|
||||
setLocalUserPlaying(true);
|
||||
|
||||
assertChatFocused(false);
|
||||
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||
AddStep("press enter", () => InputManager.Key(Key.Enter));
|
||||
assertChatFocused(true);
|
||||
}
|
||||
|
||||
@ -99,19 +99,19 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
setLocalUserPlaying(true);
|
||||
|
||||
assertChatFocused(false);
|
||||
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||
AddStep("press enter", () => InputManager.Key(Key.Enter));
|
||||
assertChatFocused(true);
|
||||
AddStep("press escape", () => InputManager.Key(Key.Escape));
|
||||
assertChatFocused(false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFocusOnTabKeyWhenNotExpanded()
|
||||
public void TestFocusOnEnterKeyWhenNotExpanded()
|
||||
{
|
||||
AddStep("set not expanded", () => chatDisplay.Expanded.Value = false);
|
||||
AddUntilStep("is not visible", () => !chatDisplay.IsPresent);
|
||||
|
||||
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||
AddStep("press enter", () => InputManager.Key(Key.Enter));
|
||||
assertChatFocused(true);
|
||||
AddUntilStep("is visible", () => chatDisplay.IsPresent);
|
||||
|
||||
@ -120,21 +120,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddUntilStep("is not visible", () => !chatDisplay.IsPresent);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFocusToggleViaAction()
|
||||
{
|
||||
AddStep("set not expanded", () => chatDisplay.Expanded.Value = false);
|
||||
AddUntilStep("is not visible", () => !chatDisplay.IsPresent);
|
||||
|
||||
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||
assertChatFocused(true);
|
||||
AddUntilStep("is visible", () => chatDisplay.IsPresent);
|
||||
|
||||
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||
assertChatFocused(false);
|
||||
AddUntilStep("is not visible", () => !chatDisplay.IsPresent);
|
||||
}
|
||||
|
||||
private void assertChatFocused(bool isFocused) =>
|
||||
AddAssert($"chat {(isFocused ? "focused" : "not focused")}", () => textBox.HasFocus == isFocused);
|
||||
|
||||
|
@ -49,6 +49,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
LoadComponentAsync(leaderboard = new MultiSpectatorLeaderboard(clocks.Keys.Select(id => new MultiplayerRoomUser(id)).ToArray())
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Expanded = { Value = true }
|
||||
}, Add);
|
||||
});
|
||||
|
@ -79,6 +79,19 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddWaitStep("wait a bit", 20);
|
||||
}
|
||||
|
||||
[TestCase(2)]
|
||||
[TestCase(16)]
|
||||
public void TestTeams(int count)
|
||||
{
|
||||
int[] userIds = getPlayerIds(count);
|
||||
|
||||
start(userIds, teams: true);
|
||||
loadSpectateScreen();
|
||||
|
||||
sendFrames(userIds, 1000);
|
||||
AddWaitStep("wait a bit", 20);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleStartRequests()
|
||||
{
|
||||
@ -450,16 +463,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
private void start(int userId, int? beatmapId = null) => start(new[] { userId }, beatmapId);
|
||||
|
||||
private void start(int[] userIds, int? beatmapId = null, APIMod[]? mods = null)
|
||||
private void start(int[] userIds, int? beatmapId = null, APIMod[]? mods = null, bool teams = false)
|
||||
{
|
||||
AddStep("start play", () =>
|
||||
{
|
||||
foreach (int id in userIds)
|
||||
for (int i = 0; i < userIds.Length; i++)
|
||||
{
|
||||
int id = userIds[i];
|
||||
var user = new MultiplayerRoomUser(id)
|
||||
{
|
||||
User = new APIUser { Id = id },
|
||||
Mods = mods ?? Array.Empty<APIMod>(),
|
||||
MatchState = teams ? new TeamVersusUserState { TeamID = i % 2 } : null,
|
||||
};
|
||||
|
||||
OnlinePlayDependencies.MultiplayerClient.AddUser(user, true);
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
@ -16,6 +17,7 @@ using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.GameplayTest;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK.Input;
|
||||
|
||||
@ -203,6 +205,33 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
AddUntilStep("wait for music stopped", () => !Game.MusicController.IsPlaying);
|
||||
}
|
||||
|
||||
[TestCase(SortMode.Title)]
|
||||
[TestCase(SortMode.Difficulty)]
|
||||
public void TestSelectionRetainedOnExit(SortMode sortMode)
|
||||
{
|
||||
BeatmapSetInfo beatmapSet = null!;
|
||||
|
||||
AddStep("import test beatmap", () => Game.BeatmapManager.Import(TestResources.GetTestBeatmapForImport()).WaitSafely());
|
||||
AddStep("retrieve beatmap", () => beatmapSet = Game.BeatmapManager.QueryBeatmapSet(set => !set.Protected).AsNonNull().Value.Detach());
|
||||
|
||||
AddStep($"set sort mode to {sortMode}", () => Game.LocalConfig.SetValue(OsuSetting.SongSelectSortingMode, sortMode));
|
||||
AddStep("present beatmap", () => Game.PresentBeatmap(beatmapSet));
|
||||
AddUntilStep("wait for song select",
|
||||
() => Game.Beatmap.Value.BeatmapSetInfo.Equals(beatmapSet)
|
||||
&& Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect
|
||||
&& songSelect.IsLoaded);
|
||||
|
||||
AddStep("open editor", () => ((PlaySongSelect)Game.ScreenStack.CurrentScreen).Edit(beatmapSet.Beatmaps.First(beatmap => beatmap.Ruleset.OnlineID == 0)));
|
||||
AddUntilStep("wait for editor open", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.ReadyForUse);
|
||||
|
||||
AddStep("exit editor", () => InputManager.Key(Key.Escape));
|
||||
AddUntilStep("wait for editor exit", () => Game.ScreenStack.CurrentScreen is not Editor);
|
||||
|
||||
AddUntilStep("selection retained on song select",
|
||||
() => Game.Beatmap.Value.BeatmapInfo.ID,
|
||||
() => Is.EqualTo(beatmapSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0).ID));
|
||||
}
|
||||
|
||||
private EditorBeatmap getEditorBeatmap() => getEditor().ChildrenOfType<EditorBeatmap>().Single();
|
||||
|
||||
private Editor getEditor() => (Editor)Game.ScreenStack.CurrentScreen;
|
||||
|
@ -39,6 +39,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
private BeatmapInfo currentSelection => carousel.SelectedBeatmapInfo;
|
||||
|
||||
private const int set_count = 5;
|
||||
private const int diff_count = 3;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetStore rulesets)
|
||||
@ -111,7 +112,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
[Test]
|
||||
public void TestScrollPositionMaintainedOnAdd()
|
||||
{
|
||||
loadBeatmaps(count: 1, randomDifficulties: false);
|
||||
loadBeatmaps(setCount: 1);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
@ -124,7 +125,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
[Test]
|
||||
public void TestDeletion()
|
||||
{
|
||||
loadBeatmaps(count: 5, randomDifficulties: true);
|
||||
loadBeatmaps(setCount: 5, randomDifficulties: true);
|
||||
|
||||
AddStep("remove first set", () => carousel.RemoveBeatmapSet(carousel.Items.Select(item => item.Item).OfType<CarouselBeatmapSet>().First().BeatmapSet));
|
||||
AddUntilStep("4 beatmap sets visible", () => this.ChildrenOfType<DrawableCarouselBeatmapSet>().Count(set => set.Alpha > 0) == 4);
|
||||
@ -133,7 +134,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
[Test]
|
||||
public void TestScrollPositionMaintainedOnDelete()
|
||||
{
|
||||
loadBeatmaps(count: 50, randomDifficulties: false);
|
||||
loadBeatmaps(setCount: 50);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
@ -150,7 +151,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
[Test]
|
||||
public void TestManyPanels()
|
||||
{
|
||||
loadBeatmaps(count: 5000, randomDifficulties: true);
|
||||
loadBeatmaps(setCount: 5000, randomDifficulties: true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -501,6 +502,33 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
waitForSelection(set_count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAddRemoveDifficultySort()
|
||||
{
|
||||
const int local_set_count = 2;
|
||||
const int local_diff_count = 2;
|
||||
|
||||
loadBeatmaps(setCount: local_set_count, diffCount: local_diff_count);
|
||||
|
||||
AddStep("Sort by difficulty", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty }, false));
|
||||
|
||||
checkVisibleItemCount(false, local_set_count * local_diff_count);
|
||||
|
||||
var firstAdded = TestResources.CreateTestBeatmapSetInfo(local_diff_count);
|
||||
|
||||
AddStep("Add new set", () => carousel.UpdateBeatmapSet(firstAdded));
|
||||
|
||||
checkVisibleItemCount(false, (local_set_count + 1) * local_diff_count);
|
||||
|
||||
AddStep("Remove set", () => carousel.RemoveBeatmapSet(firstAdded));
|
||||
|
||||
checkVisibleItemCount(false, (local_set_count) * local_diff_count);
|
||||
|
||||
setSelected(local_set_count, 1);
|
||||
|
||||
waitForSelection(local_set_count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectionEnteringFromEmptyRuleset()
|
||||
{
|
||||
@ -662,7 +690,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
var set = TestResources.CreateTestBeatmapSetInfo(3);
|
||||
var set = TestResources.CreateTestBeatmapSetInfo(diff_count);
|
||||
|
||||
// only need to set the first as they are a shared reference.
|
||||
var beatmap = set.Beatmaps.First();
|
||||
@ -709,7 +737,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
var set = TestResources.CreateTestBeatmapSetInfo(3);
|
||||
var set = TestResources.CreateTestBeatmapSetInfo(diff_count);
|
||||
|
||||
// only need to set the first as they are a shared reference.
|
||||
var beatmap = set.Beatmaps.First();
|
||||
@ -758,32 +786,54 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSortingWithFiltered()
|
||||
public void TestSortingWithDifficultyFiltered()
|
||||
{
|
||||
const int local_diff_count = 3;
|
||||
const int local_set_count = 2;
|
||||
|
||||
List<BeatmapSetInfo> sets = new List<BeatmapSetInfo>();
|
||||
|
||||
AddStep("Populuate beatmap sets", () =>
|
||||
{
|
||||
sets.Clear();
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int i = 0; i < local_set_count; i++)
|
||||
{
|
||||
var set = TestResources.CreateTestBeatmapSetInfo(3);
|
||||
var set = TestResources.CreateTestBeatmapSetInfo(local_diff_count);
|
||||
set.Beatmaps[0].StarRating = 3 - i;
|
||||
set.Beatmaps[2].StarRating = 6 + i;
|
||||
set.Beatmaps[1].StarRating = 6 + i;
|
||||
sets.Add(set);
|
||||
}
|
||||
});
|
||||
|
||||
loadBeatmaps(sets);
|
||||
|
||||
AddStep("Sort by difficulty", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty }, false));
|
||||
|
||||
checkVisibleItemCount(false, local_set_count * local_diff_count);
|
||||
checkVisibleItemCount(true, 1);
|
||||
|
||||
AddStep("Filter to normal", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty, SearchText = "Normal" }, false));
|
||||
AddAssert("Check first set at end", () => carousel.BeatmapSets.First().Equals(sets.Last()));
|
||||
AddAssert("Check last set at start", () => carousel.BeatmapSets.Last().Equals(sets.First()));
|
||||
checkVisibleItemCount(false, local_set_count);
|
||||
checkVisibleItemCount(true, 1);
|
||||
|
||||
AddUntilStep("Check all visible sets have one normal", () =>
|
||||
{
|
||||
return carousel.Items.OfType<DrawableCarouselBeatmapSet>()
|
||||
.Where(p => p.IsPresent)
|
||||
.Count(p => ((CarouselBeatmapSet)p.Item)!.Beatmaps.Single().BeatmapInfo.DifficultyName.StartsWith("Normal", StringComparison.Ordinal)) == local_set_count;
|
||||
});
|
||||
|
||||
AddStep("Filter to insane", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty, SearchText = "Insane" }, false));
|
||||
AddAssert("Check first set at start", () => carousel.BeatmapSets.First().Equals(sets.First()));
|
||||
AddAssert("Check last set at end", () => carousel.BeatmapSets.Last().Equals(sets.Last()));
|
||||
checkVisibleItemCount(false, local_set_count);
|
||||
checkVisibleItemCount(true, 1);
|
||||
|
||||
AddUntilStep("Check all visible sets have one insane", () =>
|
||||
{
|
||||
return carousel.Items.OfType<DrawableCarouselBeatmapSet>()
|
||||
.Where(p => p.IsPresent)
|
||||
.Count(p => ((CarouselBeatmapSet)p.Item)!.Beatmaps.Single().BeatmapInfo.DifficultyName.StartsWith("Insane", StringComparison.Ordinal)) == local_set_count;
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -838,7 +888,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
AddStep("create hidden set", () =>
|
||||
{
|
||||
hidingSet = TestResources.CreateTestBeatmapSetInfo(3);
|
||||
hidingSet = TestResources.CreateTestBeatmapSetInfo(diff_count);
|
||||
hidingSet.Beatmaps[1].Hidden = true;
|
||||
|
||||
hiddenList.Clear();
|
||||
@ -885,7 +935,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
AddStep("add mixed ruleset beatmapset", () =>
|
||||
{
|
||||
testMixed = TestResources.CreateTestBeatmapSetInfo(3);
|
||||
testMixed = TestResources.CreateTestBeatmapSetInfo(diff_count);
|
||||
|
||||
for (int i = 0; i <= 2; i++)
|
||||
{
|
||||
@ -907,7 +957,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
BeatmapSetInfo testSingle = null;
|
||||
AddStep("add single ruleset beatmapset", () =>
|
||||
{
|
||||
testSingle = TestResources.CreateTestBeatmapSetInfo(3);
|
||||
testSingle = TestResources.CreateTestBeatmapSetInfo(diff_count);
|
||||
testSingle.Beatmaps.ForEach(b =>
|
||||
{
|
||||
b.Ruleset = rulesets.AvailableRulesets.ElementAt(1);
|
||||
@ -930,7 +980,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
manySets.Clear();
|
||||
|
||||
for (int i = 1; i <= 50; i++)
|
||||
manySets.Add(TestResources.CreateTestBeatmapSetInfo(3));
|
||||
manySets.Add(TestResources.CreateTestBeatmapSetInfo(diff_count));
|
||||
});
|
||||
|
||||
loadBeatmaps(manySets);
|
||||
@ -955,6 +1005,43 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
AddAssert("Selection was remembered", () => eagerSelectedIDs.Count == 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCarouselRemembersSelectionDifficultySort()
|
||||
{
|
||||
List<BeatmapSetInfo> manySets = new List<BeatmapSetInfo>();
|
||||
|
||||
AddStep("Populate beatmap sets", () =>
|
||||
{
|
||||
manySets.Clear();
|
||||
|
||||
for (int i = 1; i <= 50; i++)
|
||||
manySets.Add(TestResources.CreateTestBeatmapSetInfo(diff_count));
|
||||
});
|
||||
|
||||
loadBeatmaps(manySets);
|
||||
|
||||
AddStep("Sort by difficulty", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty }, false));
|
||||
|
||||
advanceSelection(direction: 1, diff: false);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
AddStep("Toggle non-matching filter", () =>
|
||||
{
|
||||
carousel.Filter(new FilterCriteria { SearchText = Guid.NewGuid().ToString() }, false);
|
||||
});
|
||||
|
||||
AddStep("Restore no filter", () =>
|
||||
{
|
||||
carousel.Filter(new FilterCriteria(), false);
|
||||
eagerSelectedIDs.Add(carousel.SelectedBeatmapSet!.ID);
|
||||
});
|
||||
}
|
||||
|
||||
// always returns to same selection as long as it's available.
|
||||
AddAssert("Selection was remembered", () => eagerSelectedIDs.Count == 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFilteringByUserStarDifficulty()
|
||||
{
|
||||
@ -1081,8 +1168,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets = null, Func<FilterCriteria> initialCriteria = null, Action<BeatmapCarousel> carouselAdjust = null, int? count = null,
|
||||
bool randomDifficulties = false)
|
||||
private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets = null, Func<FilterCriteria> initialCriteria = null, Action<BeatmapCarousel> carouselAdjust = null,
|
||||
int? setCount = null, int? diffCount = null, bool randomDifficulties = false)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
@ -1090,11 +1177,11 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
{
|
||||
beatmapSets = new List<BeatmapSetInfo>();
|
||||
|
||||
for (int i = 1; i <= (count ?? set_count); i++)
|
||||
for (int i = 1; i <= (setCount ?? set_count); i++)
|
||||
{
|
||||
beatmapSets.Add(randomDifficulties
|
||||
? TestResources.CreateTestBeatmapSetInfo()
|
||||
: TestResources.CreateTestBeatmapSetInfo(3));
|
||||
: TestResources.CreateTestBeatmapSetInfo(diffCount ?? diff_count));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Screens.Select.Carousel;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
using osu.Game.Tests.Online;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK.Input;
|
||||
@ -192,6 +193,57 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
AddStep("release mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSplitDisplay()
|
||||
{
|
||||
ArchiveDownloadRequest<IBeatmapSetInfo>? downloadRequest = null;
|
||||
|
||||
AddStep("set difficulty sort mode", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty }));
|
||||
AddStep("update online hash", () =>
|
||||
{
|
||||
testBeatmapSetInfo.Beatmaps.First().OnlineMD5Hash = "different hash";
|
||||
testBeatmapSetInfo.Beatmaps.First().LastOnlineUpdate = DateTimeOffset.Now;
|
||||
|
||||
carousel.UpdateBeatmapSet(testBeatmapSetInfo);
|
||||
});
|
||||
|
||||
AddUntilStep("multiple \"sets\" visible", () => carousel.ChildrenOfType<DrawableCarouselBeatmapSet>().Count(), () => Is.GreaterThan(1));
|
||||
AddUntilStep("update button visible", getUpdateButton, () => Is.Not.Null);
|
||||
|
||||
AddStep("click button", () => getUpdateButton()?.TriggerClick());
|
||||
|
||||
AddUntilStep("wait for download started", () =>
|
||||
{
|
||||
downloadRequest = beatmapDownloader.GetExistingDownload(testBeatmapSetInfo);
|
||||
return downloadRequest != null;
|
||||
});
|
||||
|
||||
AddUntilStep("wait for button disabled", () => getUpdateButton()?.Enabled.Value == false);
|
||||
|
||||
AddUntilStep("progress download to completion", () =>
|
||||
{
|
||||
if (downloadRequest is TestSceneOnlinePlayBeatmapAvailabilityTracker.TestDownloadRequest testRequest)
|
||||
{
|
||||
testRequest.SetProgress(testRequest.Progress + 0.1f);
|
||||
|
||||
if (testRequest.Progress >= 1)
|
||||
{
|
||||
testRequest.TriggerSuccess();
|
||||
|
||||
// usually this would be done by the import process.
|
||||
testBeatmapSetInfo.Beatmaps.First().MD5Hash = "different hash";
|
||||
testBeatmapSetInfo.Beatmaps.First().LastOnlineUpdate = DateTimeOffset.Now;
|
||||
|
||||
// usually this would be done by a realm subscription.
|
||||
carousel.UpdateBeatmapSet(testBeatmapSetInfo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
private BeatmapCarousel createCarousel()
|
||||
{
|
||||
return carousel = new BeatmapCarousel
|
||||
@ -199,7 +251,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
BeatmapSets = new List<BeatmapSetInfo>
|
||||
{
|
||||
(testBeatmapSetInfo = TestResources.CreateTestBeatmapSetInfo()),
|
||||
(testBeatmapSetInfo = TestResources.CreateTestBeatmapSetInfo(5)),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,130 @@
|
||||
// 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.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public partial class TestSceneSliderWithTextBoxInput : OsuManualInputManagerTestScene
|
||||
{
|
||||
private SliderWithTextBoxInput<float> sliderWithTextBoxInput = null!;
|
||||
|
||||
private OsuSliderBar<float> slider => sliderWithTextBoxInput.ChildrenOfType<OsuSliderBar<float>>().Single();
|
||||
private Nub nub => sliderWithTextBoxInput.ChildrenOfType<Nub>().Single();
|
||||
private OsuTextBox textBox => sliderWithTextBoxInput.ChildrenOfType<OsuTextBox>().Single();
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("create slider", () => Child = sliderWithTextBoxInput = new SliderWithTextBoxInput<float>("Test Slider")
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 0.5f,
|
||||
Current = new BindableFloat
|
||||
{
|
||||
MinValue = -5,
|
||||
MaxValue = 5,
|
||||
Precision = 0.2f
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNonInstantaneousMode()
|
||||
{
|
||||
AddStep("set instantaneous to false", () => sliderWithTextBoxInput.Instantaneous = false);
|
||||
|
||||
AddStep("focus textbox", () => InputManager.ChangeFocus(textBox));
|
||||
AddStep("change text", () => textBox.Text = "3");
|
||||
AddAssert("slider not moved", () => slider.Current.Value, () => Is.Zero);
|
||||
AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.Zero);
|
||||
|
||||
AddStep("commit text", () => InputManager.Key(Key.Enter));
|
||||
AddAssert("slider moved", () => slider.Current.Value, () => Is.EqualTo(3));
|
||||
AddAssert("current changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(3));
|
||||
|
||||
AddStep("move mouse to nub", () => InputManager.MoveMouseTo(nub));
|
||||
AddStep("hold left mouse", () => InputManager.PressButton(MouseButton.Left));
|
||||
AddStep("move mouse to minimum", () => InputManager.MoveMouseTo(sliderWithTextBoxInput.ScreenSpaceDrawQuad.BottomLeft));
|
||||
AddAssert("textbox not changed", () => textBox.Current.Value, () => Is.EqualTo("3"));
|
||||
AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(3));
|
||||
|
||||
AddStep("release left mouse", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||
AddAssert("textbox changed", () => textBox.Current.Value, () => Is.EqualTo("-5"));
|
||||
AddAssert("current changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
|
||||
|
||||
AddStep("focus textbox", () => InputManager.ChangeFocus(textBox));
|
||||
AddStep("set text to invalid", () => textBox.Text = "garbage");
|
||||
AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
|
||||
AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
|
||||
|
||||
AddStep("commit text", () => InputManager.Key(Key.Enter));
|
||||
AddAssert("text restored", () => textBox.Text, () => Is.EqualTo("-5"));
|
||||
AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
|
||||
AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
|
||||
|
||||
AddStep("focus textbox", () => InputManager.ChangeFocus(textBox));
|
||||
AddStep("set text to invalid", () => textBox.Text = "garbage");
|
||||
AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
|
||||
AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
|
||||
|
||||
AddStep("lose focus", () => InputManager.ChangeFocus(null));
|
||||
AddAssert("text restored", () => textBox.Text, () => Is.EqualTo("-5"));
|
||||
AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
|
||||
AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInstantaneousMode()
|
||||
{
|
||||
AddStep("set instantaneous to true", () => sliderWithTextBoxInput.Instantaneous = true);
|
||||
|
||||
AddStep("focus textbox", () => InputManager.ChangeFocus(textBox));
|
||||
AddStep("change text", () => textBox.Text = "3");
|
||||
AddAssert("slider moved", () => slider.Current.Value, () => Is.EqualTo(3));
|
||||
AddAssert("current changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(3));
|
||||
|
||||
AddStep("commit text", () => InputManager.Key(Key.Enter));
|
||||
AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(3));
|
||||
AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(3));
|
||||
|
||||
AddStep("move mouse to nub", () => InputManager.MoveMouseTo(nub));
|
||||
AddStep("hold left mouse", () => InputManager.PressButton(MouseButton.Left));
|
||||
AddStep("move mouse to minimum", () => InputManager.MoveMouseTo(sliderWithTextBoxInput.ScreenSpaceDrawQuad.BottomLeft));
|
||||
AddAssert("textbox changed", () => textBox.Current.Value, () => Is.EqualTo("-5"));
|
||||
AddAssert("current changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
|
||||
|
||||
AddStep("release left mouse", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||
AddAssert("textbox not changed", () => textBox.Current.Value, () => Is.EqualTo("-5"));
|
||||
AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
|
||||
|
||||
AddStep("focus textbox", () => InputManager.ChangeFocus(textBox));
|
||||
AddStep("set text to invalid", () => textBox.Text = "garbage");
|
||||
AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
|
||||
AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
|
||||
|
||||
AddStep("commit text", () => InputManager.Key(Key.Enter));
|
||||
AddAssert("text restored", () => textBox.Text, () => Is.EqualTo("-5"));
|
||||
AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
|
||||
AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
|
||||
|
||||
AddStep("focus textbox", () => InputManager.ChangeFocus(textBox));
|
||||
AddStep("set text to invalid", () => textBox.Text = "garbage");
|
||||
AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
|
||||
AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
|
||||
|
||||
AddStep("lose focus", () => InputManager.ChangeFocus(null));
|
||||
AddAssert("text restored", () => textBox.Text, () => Is.EqualTo("-5"));
|
||||
AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
|
||||
AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
|
||||
}
|
||||
}
|
||||
}
|
@ -2,25 +2,35 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Models;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Components
|
||||
{
|
||||
[TestFixture]
|
||||
public partial class TestSceneSongBar : OsuTestScene
|
||||
public partial class TestSceneSongBar : TournamentTestScene
|
||||
{
|
||||
[Cached]
|
||||
private readonly LadderInfo ladder = new LadderInfo();
|
||||
private SongBar songBar = null!;
|
||||
private TournamentBeatmap ladderBeatmap = null!;
|
||||
|
||||
[Test]
|
||||
public void TestSongBar()
|
||||
[SetUpSteps]
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
SongBar songBar = null!;
|
||||
base.SetUpSteps();
|
||||
|
||||
AddStep("setup picks bans", () =>
|
||||
{
|
||||
ladderBeatmap = CreateSampleBeatmap();
|
||||
Ladder.CurrentMatch.Value!.PicksBans.Add(new BeatmapChoice
|
||||
{
|
||||
BeatmapID = ladderBeatmap.OnlineID,
|
||||
Team = TeamColour.Red,
|
||||
Type = ChoiceType.Pick,
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("create bar", () => Child = songBar = new SongBar
|
||||
{
|
||||
@ -29,22 +39,33 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
Origin = Anchor.Centre
|
||||
});
|
||||
AddUntilStep("wait for loaded", () => songBar.IsLoaded);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSongBar()
|
||||
{
|
||||
AddStep("set beatmap", () =>
|
||||
{
|
||||
var beatmap = CreateAPIBeatmap(Ruleset.Value);
|
||||
|
||||
beatmap.CircleSize = 3.4f;
|
||||
beatmap.ApproachRate = 6.8f;
|
||||
beatmap.OverallDifficulty = 5.5f;
|
||||
beatmap.StarRating = 4.56f;
|
||||
beatmap.Length = 123456;
|
||||
beatmap.BPM = 133;
|
||||
beatmap.OnlineID = ladderBeatmap.OnlineID;
|
||||
|
||||
songBar.Beatmap = new TournamentBeatmap(beatmap);
|
||||
});
|
||||
|
||||
AddStep("set mods to HR", () => songBar.Mods = LegacyMods.HardRock);
|
||||
AddStep("set mods to DT", () => songBar.Mods = LegacyMods.DoubleTime);
|
||||
AddStep("unset mods", () => songBar.Mods = LegacyMods.None);
|
||||
|
||||
AddToggleStep("toggle expanded", expanded => songBar.Expanded = expanded);
|
||||
|
||||
AddStep("set null beatmap", () => songBar.Beatmap = null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,13 @@ namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
public partial class TestSceneScheduleScreen : TournamentScreenTestScene
|
||||
{
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
AddStep("clear matches", () => Ladder.Matches.Clear());
|
||||
|
||||
base.SetUpSteps();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -34,6 +41,36 @@ namespace osu.Game.Tournament.Tests.Screens
|
||||
AddStep("Set null current match", () => Ladder.CurrentMatch.Value = null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUpcomingMatches()
|
||||
{
|
||||
AddStep("Add upcoming match", () =>
|
||||
{
|
||||
var tournamentMatch = CreateSampleMatch();
|
||||
|
||||
tournamentMatch.Date.Value = DateTimeOffset.UtcNow.AddMinutes(5);
|
||||
tournamentMatch.Completed.Value = false;
|
||||
|
||||
Ladder.Matches.Add(tournamentMatch);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRecentMatches()
|
||||
{
|
||||
AddStep("Add recent match", () =>
|
||||
{
|
||||
var tournamentMatch = CreateSampleMatch();
|
||||
|
||||
tournamentMatch.Date.Value = DateTimeOffset.UtcNow;
|
||||
tournamentMatch.Completed.Value = true;
|
||||
tournamentMatch.Team1Score.Value = tournamentMatch.PointsToWin;
|
||||
tournamentMatch.Team2Score.Value = tournamentMatch.PointsToWin / 2;
|
||||
|
||||
Ladder.Matches.Add(tournamentMatch);
|
||||
});
|
||||
}
|
||||
|
||||
private void setMatchDate(TimeSpan relativeTime)
|
||||
// Humanizer cannot handle negative timespans.
|
||||
=> AddStep($"start time is {relativeTime}", () =>
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Tournament.Tests
|
||||
{
|
||||
public TournamentScalingContainer()
|
||||
{
|
||||
TargetDrawSize = new Vector2(1920, 1080);
|
||||
TargetDrawSize = new Vector2(1024, 768);
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@ using osu.Game.Extensions;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -22,14 +21,14 @@ namespace osu.Game.Tournament.Components
|
||||
{
|
||||
public partial class SongBar : CompositeDrawable
|
||||
{
|
||||
private TournamentBeatmap? beatmap;
|
||||
private IBeatmapInfo? beatmap;
|
||||
|
||||
public const float HEIGHT = 145 / 2f;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
|
||||
|
||||
public TournamentBeatmap? Beatmap
|
||||
public IBeatmapInfo? Beatmap
|
||||
{
|
||||
set
|
||||
{
|
||||
@ -37,7 +36,7 @@ namespace osu.Game.Tournament.Components
|
||||
return;
|
||||
|
||||
beatmap = value;
|
||||
update();
|
||||
refreshContent();
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +48,7 @@ namespace osu.Game.Tournament.Components
|
||||
set
|
||||
{
|
||||
mods = value;
|
||||
update();
|
||||
refreshContent();
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,19 +70,25 @@ namespace osu.Game.Tournament.Components
|
||||
protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => false;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
Masking = true;
|
||||
CornerRadius = 5;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colours.Gray3,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
flow = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
LayoutDuration = 500,
|
||||
LayoutEasing = Easing.OutQuint,
|
||||
Direction = FillDirection.Full,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
@ -93,7 +98,7 @@ namespace osu.Game.Tournament.Components
|
||||
Expanded = true;
|
||||
}
|
||||
|
||||
private void update()
|
||||
private void refreshContent()
|
||||
{
|
||||
if (beatmap == null)
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Tournament.Components
|
||||
{
|
||||
public partial class TournamentBeatmapPanel : CompositeDrawable
|
||||
{
|
||||
public readonly TournamentBeatmap? Beatmap;
|
||||
public readonly IBeatmapInfo? Beatmap;
|
||||
|
||||
private readonly string mod;
|
||||
|
||||
@ -30,7 +30,7 @@ namespace osu.Game.Tournament.Components
|
||||
|
||||
private Box flash = null!;
|
||||
|
||||
public TournamentBeatmapPanel(TournamentBeatmap? beatmap, string mod = "")
|
||||
public TournamentBeatmapPanel(IBeatmapInfo? beatmap, string mod = "")
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
this.mod = mod;
|
||||
@ -58,7 +58,7 @@ namespace osu.Game.Tournament.Components
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.Gray(0.5f),
|
||||
OnlineInfo = Beatmap,
|
||||
OnlineInfo = (Beatmap as IBeatmapSetOnlineInfo),
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
|
@ -92,8 +92,16 @@ namespace osu.Game.Tournament.IPC
|
||||
else
|
||||
{
|
||||
beatmapLookupRequest = new GetBeatmapRequest(new APIBeatmap { OnlineID = beatmapId });
|
||||
beatmapLookupRequest.Success += b => Beatmap.Value = new TournamentBeatmap(b);
|
||||
beatmapLookupRequest.Failure += _ => Beatmap.Value = null;
|
||||
beatmapLookupRequest.Success += b =>
|
||||
{
|
||||
if (lastBeatmapId == beatmapId)
|
||||
Beatmap.Value = new TournamentBeatmap(b);
|
||||
};
|
||||
beatmapLookupRequest.Failure += _ =>
|
||||
{
|
||||
if (lastBeatmapId == beatmapId)
|
||||
Beatmap.Value = null;
|
||||
};
|
||||
API.Queue(beatmapLookupRequest);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Tournament.IPC
|
||||
public Bindable<LegacyMods> Mods { get; } = new Bindable<LegacyMods>();
|
||||
public Bindable<TourneyState> State { get; } = new Bindable<TourneyState>();
|
||||
public Bindable<string> ChatChannel { get; } = new Bindable<string>();
|
||||
public BindableInt Score1 { get; } = new BindableInt();
|
||||
public BindableInt Score2 { get; } = new BindableInt();
|
||||
public BindableLong Score1 { get; } = new BindableLong();
|
||||
public BindableLong Score2 { get; } = new BindableLong();
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace osu.Game.Tournament.Models
|
||||
|
||||
public Bindable<int> LastYearPlacing = new BindableInt
|
||||
{
|
||||
MinValue = 1,
|
||||
MinValue = 0,
|
||||
MaxValue = 256
|
||||
};
|
||||
|
||||
|
@ -7,13 +7,16 @@ using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tournament
|
||||
{
|
||||
internal partial class SaveChangesOverlay : CompositeDrawable
|
||||
internal partial class SaveChangesOverlay : CompositeDrawable, IKeyBindingHandler<PlatformAction>
|
||||
{
|
||||
[Resolved]
|
||||
private TournamentGame tournamentGame { get; set; } = null!;
|
||||
@ -78,6 +81,21 @@ namespace osu.Game.Tournament
|
||||
scheduleNextCheck();
|
||||
}
|
||||
|
||||
public bool OnPressed(KeyBindingPressEvent<PlatformAction> e)
|
||||
{
|
||||
if (e.Action == PlatformAction.Save && !e.Repeat)
|
||||
{
|
||||
saveChangesButton.TriggerClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnReleased(KeyBindingReleaseEvent<PlatformAction> e)
|
||||
{
|
||||
}
|
||||
|
||||
private void scheduleNextCheck() => Scheduler.AddDelayed(() => checkForChanges().FireAndForget(), 1000);
|
||||
|
||||
private void saveChanges()
|
||||
|
@ -10,7 +10,9 @@ using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Tournament.Models;
|
||||
@ -128,7 +130,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
Width = 0.2f,
|
||||
Current = Model.Seed
|
||||
},
|
||||
new SettingsSlider<int>
|
||||
new SettingsSlider<int, LastYearPlacementSlider>
|
||||
{
|
||||
LabelText = "Last Year Placement",
|
||||
Width = 0.33f,
|
||||
@ -175,6 +177,11 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
};
|
||||
}
|
||||
|
||||
private partial class LastYearPlacementSlider : RoundedSliderBar<int>
|
||||
{
|
||||
public override LocalisableString TooltipText => Current.Value == 0 ? "N/A" : base.TooltipText;
|
||||
}
|
||||
|
||||
public partial class PlayerEditor : CompositeDrawable
|
||||
{
|
||||
private readonly TournamentTeam team;
|
||||
|
@ -1,181 +1,19 @@
|
||||
// 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.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tournament.Screens.Gameplay.Components
|
||||
{
|
||||
// TODO: Update to derive from osu-side class?
|
||||
public partial class TournamentMatchScoreDisplay : CompositeDrawable
|
||||
public partial class TournamentMatchScoreDisplay : MatchScoreDisplay
|
||||
{
|
||||
private const float bar_height = 18;
|
||||
|
||||
private readonly BindableInt score1 = new BindableInt();
|
||||
private readonly BindableInt score2 = new BindableInt();
|
||||
|
||||
private readonly MatchScoreCounter score1Text;
|
||||
private readonly MatchScoreCounter score2Text;
|
||||
|
||||
private readonly MatchScoreDiffCounter scoreDiffText;
|
||||
|
||||
private readonly Drawable score1Bar;
|
||||
private readonly Drawable score2Bar;
|
||||
|
||||
public TournamentMatchScoreDisplay()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
InternalChildren = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Name = "top bar red (static)",
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = bar_height / 4,
|
||||
Width = 0.5f,
|
||||
Colour = TournamentGame.COLOUR_RED,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopRight
|
||||
},
|
||||
new Box
|
||||
{
|
||||
Name = "top bar blue (static)",
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = bar_height / 4,
|
||||
Width = 0.5f,
|
||||
Colour = TournamentGame.COLOUR_BLUE,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopLeft
|
||||
},
|
||||
score1Bar = new Box
|
||||
{
|
||||
Name = "top bar red",
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = bar_height,
|
||||
Width = 0,
|
||||
Colour = TournamentGame.COLOUR_RED,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopRight
|
||||
},
|
||||
score1Text = new MatchScoreCounter
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre
|
||||
},
|
||||
score2Bar = new Box
|
||||
{
|
||||
Name = "top bar blue",
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = bar_height,
|
||||
Width = 0,
|
||||
Colour = TournamentGame.COLOUR_BLUE,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopLeft
|
||||
},
|
||||
score2Text = new MatchScoreCounter
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre
|
||||
},
|
||||
scoreDiffText = new MatchScoreDiffCounter
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Top = bar_height / 4,
|
||||
Horizontal = 8
|
||||
},
|
||||
Alpha = 0
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(MatchIPCInfo ipc)
|
||||
{
|
||||
score1.BindValueChanged(_ => updateScores());
|
||||
score1.BindTo(ipc.Score1);
|
||||
|
||||
score2.BindValueChanged(_ => updateScores());
|
||||
score2.BindTo(ipc.Score2);
|
||||
}
|
||||
|
||||
private void updateScores()
|
||||
{
|
||||
score1Text.Current.Value = score1.Value;
|
||||
score2Text.Current.Value = score2.Value;
|
||||
|
||||
var winningText = score1.Value > score2.Value ? score1Text : score2Text;
|
||||
var losingText = score1.Value <= score2.Value ? score1Text : score2Text;
|
||||
|
||||
winningText.Winning = true;
|
||||
losingText.Winning = false;
|
||||
|
||||
var winningBar = score1.Value > score2.Value ? score1Bar : score2Bar;
|
||||
var losingBar = score1.Value <= score2.Value ? score1Bar : score2Bar;
|
||||
|
||||
int diff = Math.Max(score1.Value, score2.Value) - Math.Min(score1.Value, score2.Value);
|
||||
|
||||
losingBar.ResizeWidthTo(0, 400, Easing.OutQuint);
|
||||
winningBar.ResizeWidthTo(Math.Min(0.4f, MathF.Pow(diff / 1500000f, 0.5f) / 2), 400, Easing.OutQuint);
|
||||
|
||||
scoreDiffText.Alpha = diff != 0 ? 1 : 0;
|
||||
scoreDiffText.Current.Value = -diff;
|
||||
scoreDiffText.Origin = score1.Value > score2.Value ? Anchor.TopLeft : Anchor.TopRight;
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
score1Text.X = -Math.Max(5 + score1Text.DrawWidth / 2, score1Bar.DrawWidth);
|
||||
score2Text.X = Math.Max(5 + score2Text.DrawWidth / 2, score2Bar.DrawWidth);
|
||||
}
|
||||
|
||||
private partial class MatchScoreCounter : CommaSeparatedScoreCounter
|
||||
{
|
||||
private OsuSpriteText displayedSpriteText = null!;
|
||||
|
||||
public MatchScoreCounter()
|
||||
{
|
||||
Margin = new MarginPadding { Top = bar_height, Horizontal = 10 };
|
||||
}
|
||||
|
||||
public bool Winning
|
||||
{
|
||||
set => updateFont(value);
|
||||
}
|
||||
|
||||
protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s =>
|
||||
{
|
||||
displayedSpriteText = s;
|
||||
displayedSpriteText.Spacing = new Vector2(-6);
|
||||
updateFont(false);
|
||||
});
|
||||
|
||||
private void updateFont(bool winning)
|
||||
=> displayedSpriteText.Font = winning
|
||||
? OsuFont.Torus.With(weight: FontWeight.Bold, size: 50, fixedWidth: true)
|
||||
: OsuFont.Torus.With(weight: FontWeight.Regular, size: 40, fixedWidth: true);
|
||||
}
|
||||
|
||||
private partial class MatchScoreDiffCounter : CommaSeparatedScoreCounter
|
||||
{
|
||||
protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s =>
|
||||
{
|
||||
s.Spacing = new Vector2(-2);
|
||||
s.Font = OsuFont.Torus.With(weight: FontWeight.Regular, size: bar_height, fixedWidth: true);
|
||||
});
|
||||
Team1Score.BindTo(ipc.Score1);
|
||||
Team2Score.BindTo(ipc.Score2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// 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;
|
||||
@ -19,6 +20,7 @@ namespace osu.Game.Tournament.Screens.Schedule
|
||||
{
|
||||
public partial class ScheduleScreen : TournamentScreen
|
||||
{
|
||||
private readonly BindableList<TournamentMatch> allMatches = new BindableList<TournamentMatch>();
|
||||
private readonly Bindable<TournamentMatch?> currentMatch = new Bindable<TournamentMatch?>();
|
||||
private Container mainContainer = null!;
|
||||
private LadderInfo ladder = null!;
|
||||
@ -101,19 +103,34 @@ namespace osu.Game.Tournament.Screens.Schedule
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
allMatches.BindTo(ladder.Matches);
|
||||
allMatches.BindCollectionChanged((_, _) => refresh());
|
||||
|
||||
currentMatch.BindTo(ladder.CurrentMatch);
|
||||
currentMatch.BindValueChanged(matchChanged, true);
|
||||
currentMatch.BindValueChanged(_ => refresh(), true);
|
||||
}
|
||||
|
||||
private void matchChanged(ValueChangedEvent<TournamentMatch?> match)
|
||||
private void refresh()
|
||||
{
|
||||
var upcoming = ladder.Matches.Where(p => !p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4);
|
||||
var conditionals = ladder
|
||||
.Matches.Where(p => !p.Completed.Value && (p.Team1.Value == null || p.Team2.Value == null) && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4)
|
||||
.SelectMany(m => m.ConditionalMatches.Where(cp => m.Acronyms.TrueForAll(a => cp.Acronyms.Contains(a))));
|
||||
const int days_for_displays = 4;
|
||||
|
||||
upcoming = upcoming.Concat(conditionals);
|
||||
upcoming = upcoming.OrderBy(p => p.Date.Value).Take(8);
|
||||
IEnumerable<ConditionalTournamentMatch> conditionals =
|
||||
allMatches
|
||||
.Where(m => !m.Completed.Value && (m.Team1.Value == null || m.Team2.Value == null) && Math.Abs(m.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < days_for_displays)
|
||||
.SelectMany(m => m.ConditionalMatches.Where(cp => m.Acronyms.TrueForAll(a => cp.Acronyms.Contains(a))));
|
||||
|
||||
IEnumerable<TournamentMatch> upcoming =
|
||||
allMatches
|
||||
.Where(m => !m.Completed.Value && m.Team1.Value != null && m.Team2.Value != null && Math.Abs(m.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < days_for_displays)
|
||||
.Concat(conditionals)
|
||||
.OrderBy(m => m.Date.Value)
|
||||
.Take(8);
|
||||
|
||||
var recent =
|
||||
allMatches
|
||||
.Where(m => m.Completed.Value && m.Team1.Value != null && m.Team2.Value != null && Math.Abs(m.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < days_for_displays)
|
||||
.OrderByDescending(m => m.Date.Value)
|
||||
.Take(8);
|
||||
|
||||
ScheduleContainer comingUpNext;
|
||||
|
||||
@ -137,12 +154,7 @@ namespace osu.Game.Tournament.Screens.Schedule
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Width = 0.4f,
|
||||
ChildrenEnumerable = ladder.Matches
|
||||
.Where(p => p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null
|
||||
&& Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4)
|
||||
.OrderByDescending(p => p.Date.Value)
|
||||
.Take(8)
|
||||
.Select(p => new ScheduleMatch(p))
|
||||
ChildrenEnumerable = recent.Select(p => new ScheduleMatch(p))
|
||||
},
|
||||
new ScheduleContainer("upcoming matches")
|
||||
{
|
||||
@ -161,7 +173,7 @@ namespace osu.Game.Tournament.Screens.Schedule
|
||||
}
|
||||
};
|
||||
|
||||
if (match.NewValue != null)
|
||||
if (currentMatch.Value != null)
|
||||
{
|
||||
comingUpNext.Child = new FillFlowContainer
|
||||
{
|
||||
@ -170,12 +182,12 @@ namespace osu.Game.Tournament.Screens.Schedule
|
||||
Spacing = new Vector2(30),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ScheduleMatch(match.NewValue, false)
|
||||
new ScheduleMatch(currentMatch.Value, false)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
},
|
||||
new TournamentSpriteTextWithBackground(match.NewValue.Round.Value?.Name.Value ?? string.Empty)
|
||||
new TournamentSpriteTextWithBackground(currentMatch.Value.Round.Value?.Name.Value ?? string.Empty)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
@ -185,7 +197,7 @@ namespace osu.Game.Tournament.Screens.Schedule
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = match.NewValue.Team1.Value?.FullName + " vs " + match.NewValue.Team2.Value?.FullName,
|
||||
Text = currentMatch.Value.Team1.Value?.FullName + " vs " + currentMatch.Value.Team2.Value?.FullName,
|
||||
Font = OsuFont.Torus.With(size: 24, weight: FontWeight.SemiBold)
|
||||
},
|
||||
new FillFlowContainer
|
||||
@ -196,7 +208,7 @@ namespace osu.Game.Tournament.Screens.Schedule
|
||||
Origin = Anchor.CentreLeft,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ScheduleMatchDate(match.NewValue.Date.Value)
|
||||
new ScheduleMatchDate(currentMatch.Value.Date.Value)
|
||||
{
|
||||
Font = OsuFont.Torus.With(size: 24, weight: FontWeight.Regular)
|
||||
}
|
||||
@ -282,6 +294,7 @@ namespace osu.Game.Tournament.Screens.Schedule
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Spacing = new Vector2(0, -6),
|
||||
Margin = new MarginPadding(10)
|
||||
},
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
|
||||
new TeamDisplay(team) { Margin = new MarginPadding { Bottom = 30 } },
|
||||
new RowDisplay("Average Rank:", $"#{team.AverageRank:#,0}"),
|
||||
new RowDisplay("Seed:", team.Seed.Value),
|
||||
new RowDisplay("Last year's placing:", team.LastYearPlacing.Value > 0 ? $"#{team.LastYearPlacing:#,0}" : "0"),
|
||||
new RowDisplay("Last year's placing:", team.LastYearPlacing.Value > 0 ? $"#{team.LastYearPlacing:#,0}" : "N/A"),
|
||||
new Container { Margin = new MarginPadding { Bottom = 30 } },
|
||||
}
|
||||
},
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -48,8 +47,6 @@ namespace osu.Game.Tournament
|
||||
{
|
||||
frameworkConfig.BindWith(FrameworkSetting.WindowedSize, windowSize);
|
||||
|
||||
windowSize.MinValue = new Size(TournamentSceneManager.REQUIRED_WIDTH, TournamentSceneManager.STREAM_AREA_HEIGHT);
|
||||
|
||||
windowMode = frameworkConfig.GetBindable<WindowMode>(FrameworkSetting.WindowMode);
|
||||
|
||||
Add(loadingSpinner = new LoadingSpinner(true, true)
|
||||
|
@ -24,7 +24,10 @@ using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game
|
||||
{
|
||||
public partial class BackgroundBeatmapProcessor : Component
|
||||
/// <summary>
|
||||
/// Performs background updating of data stores at startup.
|
||||
/// </summary>
|
||||
public partial class BackgroundDataStoreProcessor : Component
|
||||
{
|
||||
[Resolved]
|
||||
private RulesetStore rulesetStore { get; set; } = null!;
|
||||
@ -61,7 +64,8 @@ namespace osu.Game
|
||||
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
Logger.Log("Beginning background beatmap processing..");
|
||||
Logger.Log("Beginning background data store processing..");
|
||||
|
||||
checkForOutdatedStarRatings();
|
||||
processBeatmapSetsWithMissingMetrics();
|
||||
processScoresWithMissingStatistics();
|
||||
@ -74,7 +78,7 @@ namespace osu.Game
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.Log("Finished background beatmap processing!");
|
||||
Logger.Log("Finished background data store processing!");
|
||||
});
|
||||
}
|
||||
|
||||
@ -182,7 +186,7 @@ namespace osu.Game
|
||||
|
||||
realmAccess.Run(r =>
|
||||
{
|
||||
foreach (var score in r.All<ScoreInfo>())
|
||||
foreach (var score in r.All<ScoreInfo>().Where(s => !s.BackgroundReprocessingFailed))
|
||||
{
|
||||
if (score.BeatmapInfo != null
|
||||
&& score.Statistics.Sum(kvp => kvp.Value) > 0
|
||||
@ -221,6 +225,7 @@ namespace osu.Game
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log(@$"Failed to populate maximum statistics for {id}: {e}");
|
||||
realmAccess.Write(r => r.Find<ScoreInfo>(id)!.BackgroundReprocessingFailed = true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -230,7 +235,7 @@ namespace osu.Game
|
||||
Logger.Log("Querying for scores that need total score conversion...");
|
||||
|
||||
HashSet<Guid> scoreIds = realmAccess.Run(r => new HashSet<Guid>(r.All<ScoreInfo>()
|
||||
.Where(s => s.BeatmapInfo != null && s.TotalScoreVersion == 30000002)
|
||||
.Where(s => !s.BackgroundReprocessingFailed && s.BeatmapInfo != null && s.TotalScoreVersion == 30000002)
|
||||
.AsEnumerable().Select(s => s.ID)));
|
||||
|
||||
Logger.Log($"Found {scoreIds.Count} scores which require total score conversion.");
|
||||
@ -279,6 +284,7 @@ namespace osu.Game
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Failed to convert total score for {id}: {e}");
|
||||
realmAccess.Write(r => r.Find<ScoreInfo>(id)!.BackgroundReprocessingFailed = true);
|
||||
++failedCount;
|
||||
}
|
||||
}
|
@ -152,6 +152,8 @@ namespace osu.Game.Beatmaps
|
||||
if (archive != null)
|
||||
beatmapSet.Beatmaps.AddRange(createBeatmapDifficulties(beatmapSet, realm));
|
||||
|
||||
beatmapSet.DateAdded = getDateAdded(archive);
|
||||
|
||||
foreach (BeatmapInfo b in beatmapSet.Beatmaps)
|
||||
{
|
||||
b.BeatmapSet = beatmapSet;
|
||||
@ -305,11 +307,36 @@ namespace osu.Game.Beatmaps
|
||||
return new BeatmapSetInfo
|
||||
{
|
||||
OnlineID = beatmap.BeatmapInfo.BeatmapSet?.OnlineID ?? -1,
|
||||
// Metadata = beatmap.Metadata,
|
||||
DateAdded = DateTimeOffset.UtcNow
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the date a given beatmapset has been added to the game.
|
||||
/// For legacy imports, we can use the oldest file write time for any `.osu` file in the directory.
|
||||
/// For any other import types, use "now".
|
||||
/// </summary>
|
||||
private DateTimeOffset getDateAdded(ArchiveReader? reader)
|
||||
{
|
||||
DateTimeOffset dateAdded = DateTimeOffset.UtcNow;
|
||||
|
||||
if (reader is LegacyDirectoryArchiveReader legacyReader)
|
||||
{
|
||||
var beatmaps = reader.Filenames.Where(f => f.EndsWith(".osu", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
dateAdded = File.GetLastWriteTimeUtc(legacyReader.GetFullPath(beatmaps.First()));
|
||||
|
||||
foreach (string beatmapName in beatmaps)
|
||||
{
|
||||
var currentDateAdded = File.GetLastWriteTimeUtc(legacyReader.GetFullPath(beatmapName));
|
||||
|
||||
if (currentDateAdded < dateAdded)
|
||||
dateAdded = currentDateAdded;
|
||||
}
|
||||
}
|
||||
|
||||
return dateAdded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create all required <see cref="BeatmapInfo"/>s for the provided archive.
|
||||
/// </summary>
|
||||
|
@ -1,13 +1,10 @@
|
||||
// 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.IO;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
@ -45,7 +42,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
/// Register dependencies for use with static decoder classes.
|
||||
/// </summary>
|
||||
/// <param name="rulesets">A store containing all available rulesets (used by <see cref="LegacyBeatmapDecoder"/>).</param>
|
||||
public static void RegisterDependencies([NotNull] RulesetStore rulesets)
|
||||
public static void RegisterDependencies(RulesetStore rulesets)
|
||||
{
|
||||
LegacyBeatmapDecoder.RulesetStore = rulesets ?? throw new ArgumentNullException(nameof(rulesets));
|
||||
}
|
||||
@ -63,7 +60,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
throw new IOException(@"Unknown decoder type");
|
||||
|
||||
// start off with the first line of the file
|
||||
string line = stream.PeekLine()?.Trim();
|
||||
string? line = stream.PeekLine()?.Trim();
|
||||
|
||||
while (line != null && line.Length == 0)
|
||||
{
|
||||
|
@ -1,8 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -13,7 +11,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
/// <summary>
|
||||
/// Retrieves the list of combo colours for presentation only.
|
||||
/// </summary>
|
||||
IReadOnlyList<Color4> ComboColours { get; }
|
||||
IReadOnlyList<Color4>? ComboColours { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of custom combo colours.
|
||||
|
@ -1,8 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
#pragma warning disable 618
|
||||
|
||||
using System;
|
||||
@ -36,11 +34,11 @@ namespace osu.Game.Beatmaps.Formats
|
||||
/// </summary>
|
||||
private const double control_point_leniency = 1;
|
||||
|
||||
internal static RulesetStore RulesetStore;
|
||||
internal static RulesetStore? RulesetStore;
|
||||
|
||||
private Beatmap beatmap;
|
||||
private Beatmap beatmap = null!;
|
||||
|
||||
private ConvertHitObjectParser parser;
|
||||
private ConvertHitObjectParser? parser;
|
||||
|
||||
private LegacySampleBank defaultSampleBank;
|
||||
private int defaultSampleVolume = 100;
|
||||
@ -222,7 +220,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
case @"Mode":
|
||||
int rulesetID = Parsing.ParseInt(pair.Value);
|
||||
|
||||
beatmap.BeatmapInfo.Ruleset = RulesetStore.GetRuleset(rulesetID) ?? throw new ArgumentException("Ruleset is not available locally.");
|
||||
beatmap.BeatmapInfo.Ruleset = RulesetStore?.GetRuleset(rulesetID) ?? throw new ArgumentException("Ruleset is not available locally.");
|
||||
|
||||
switch (rulesetID)
|
||||
{
|
||||
|
@ -1,15 +1,12 @@
|
||||
// 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.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
@ -34,8 +31,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
private readonly IBeatmap beatmap;
|
||||
|
||||
[CanBeNull]
|
||||
private readonly ISkin skin;
|
||||
private readonly ISkin? skin;
|
||||
|
||||
private readonly int onlineRulesetID;
|
||||
|
||||
@ -44,7 +40,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The beatmap to encode.</param>
|
||||
/// <param name="skin">The beatmap's skin, used for encoding combo colours.</param>
|
||||
public LegacyBeatmapEncoder(IBeatmap beatmap, [CanBeNull] ISkin skin)
|
||||
public LegacyBeatmapEncoder(IBeatmap beatmap, ISkin? skin)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
this.skin = skin;
|
||||
@ -180,8 +176,8 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
writer.WriteLine("[TimingPoints]");
|
||||
|
||||
SampleControlPoint lastRelevantSamplePoint = null;
|
||||
DifficultyControlPoint lastRelevantDifficultyPoint = null;
|
||||
SampleControlPoint? lastRelevantSamplePoint = null;
|
||||
DifficultyControlPoint? lastRelevantDifficultyPoint = null;
|
||||
|
||||
// In osu!taiko and osu!mania, a scroll speed is stored as "slider velocity" in legacy formats.
|
||||
// In that case, a scrolling speed change is a global effect and per-hit object difficulty control points are ignored.
|
||||
@ -585,7 +581,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
return type;
|
||||
}
|
||||
|
||||
private LegacySampleBank toLegacySampleBank(string sampleBank)
|
||||
private LegacySampleBank toLegacySampleBank(string? sampleBank)
|
||||
{
|
||||
switch (sampleBank?.ToLowerInvariant())
|
||||
{
|
||||
@ -603,7 +599,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
}
|
||||
}
|
||||
|
||||
private int toLegacyCustomSampleBank(HitSampleInfo hitSampleInfo)
|
||||
private int toLegacyCustomSampleBank(HitSampleInfo? hitSampleInfo)
|
||||
{
|
||||
if (hitSampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacy)
|
||||
return legacy.CustomSampleBank;
|
||||
|
@ -1,8 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -19,10 +17,10 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public class LegacyStoryboardDecoder : LegacyDecoder<Storyboard>
|
||||
{
|
||||
private StoryboardSprite storyboardSprite;
|
||||
private CommandTimelineGroup timelineGroup;
|
||||
private StoryboardSprite? storyboardSprite;
|
||||
private CommandTimelineGroup? timelineGroup;
|
||||
|
||||
private Storyboard storyboard;
|
||||
private Storyboard storyboard = null!;
|
||||
|
||||
private readonly Dictionary<string, string> variables = new Dictionary<string, string>();
|
||||
|
||||
|
@ -23,6 +23,9 @@ namespace osu.Game.Collections
|
||||
|
||||
private AudioFilter lowPassFilter = null!;
|
||||
|
||||
protected override string PopInSampleName => @"UI/overlay-big-pop-in";
|
||||
protected override string PopOutSampleName => @"UI/overlay-big-pop-out";
|
||||
|
||||
public ManageCollectionsDialog()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
|
@ -237,6 +237,12 @@ namespace osu.Game.Configuration
|
||||
value: disabledState ? CommonStrings.Disabled.ToLower() : CommonStrings.Enabled.ToLower(),
|
||||
shortcut: LookupKeyBindings(GlobalAction.ToggleGameplayMouseButtons))
|
||||
),
|
||||
new TrackedSetting<bool>(OsuSetting.GameplayLeaderboard, state => new SettingDescription(
|
||||
rawValue: state,
|
||||
name: GlobalActionKeyBindingStrings.ToggleInGameLeaderboard,
|
||||
value: state ? CommonStrings.Enabled.ToLower() : CommonStrings.Disabled.ToLower(),
|
||||
shortcut: LookupKeyBindings(GlobalAction.ToggleInGameLeaderboard))
|
||||
),
|
||||
new TrackedSetting<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode, visibilityMode => new SettingDescription(
|
||||
rawValue: visibilityMode,
|
||||
name: GameplaySettingsStrings.HUDVisibilityMode,
|
||||
|
@ -70,7 +70,22 @@ namespace osu.Game.Database
|
||||
|
||||
hitObject.StartTime = Math.Floor(hitObject.StartTime);
|
||||
|
||||
if (hitObject is not IHasPath hasPath || BezierConverter.CountSegments(hasPath.Path.ControlPoints) <= 1) continue;
|
||||
if (hitObject is not IHasPath hasPath) continue;
|
||||
|
||||
// stable's hit object parsing expects the entire slider to use only one type of curve,
|
||||
// and happens to use the last non-empty curve type read for the entire slider.
|
||||
// this clear of the last control point type handles an edge case
|
||||
// wherein the last control point of an otherwise-single-segment slider path has a different type than previous,
|
||||
// which would lead to sliders being mangled when exported back to stable.
|
||||
// normally, that would be handled by the `BezierConverter.ConvertToModernBezier()` call below,
|
||||
// which outputs a slider path containing only Bezier control points,
|
||||
// but a non-inherited last control point is (rightly) not considered to be starting a new segment,
|
||||
// therefore it would fail to clear the `CountSegments() <= 1` check.
|
||||
// by clearing explicitly we both fix the issue and avoid unnecessary conversions to Bezier.
|
||||
if (hasPath.Path.ControlPoints.Count > 1)
|
||||
hasPath.Path.ControlPoints[^1].Type = null;
|
||||
|
||||
if (BezierConverter.CountSegments(hasPath.Path.ControlPoints) <= 1) continue;
|
||||
|
||||
var newControlPoints = BezierConverter.ConvertToModernBezier(hasPath.Path.ControlPoints);
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace osu.Game.Database
|
||||
// (ie. if an async import finished very recently).
|
||||
Realm.Realm.Write(realm =>
|
||||
{
|
||||
var managed = realm.Find<TModel>(item.ID);
|
||||
var managed = realm.FindWithRefresh<TModel>(item.ID);
|
||||
Debug.Assert(managed != null);
|
||||
operation(managed);
|
||||
|
||||
|
@ -82,8 +82,10 @@ namespace osu.Game.Database
|
||||
/// 30 2023-06-16 Run migration of old lazer scores again. This time with more correct rounding considerations.
|
||||
/// 31 2023-06-26 Add Version and LegacyTotalScore to ScoreInfo, set Version to 30000002 and copy TotalScore into LegacyTotalScore for legacy scores.
|
||||
/// 32 2023-07-09 Populate legacy scores with the ScoreV2 mod (and restore TotalScore to the legacy total for such scores) using replay files.
|
||||
/// 33 2023-08-16 Reset default chat toggle key binding to avoid conflict with newly added leaderboard toggle key binding.
|
||||
/// 34 2023-08-21 Add BackgroundReprocessingFailed flag to ScoreInfo to track upgrade failures.
|
||||
/// </summary>
|
||||
private const int schema_version = 32;
|
||||
private const int schema_version = 34;
|
||||
|
||||
/// <summary>
|
||||
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking realm retrieval during blocking periods.
|
||||
@ -771,6 +773,7 @@ namespace osu.Game.Database
|
||||
break;
|
||||
|
||||
case 8:
|
||||
{
|
||||
// Ctrl -/+ now adjusts UI scale so let's clear any bindings which overlap these combinations.
|
||||
// New defaults will be populated by the key store afterwards.
|
||||
var keyBindings = migration.NewRealm.All<RealmKeyBinding>();
|
||||
@ -784,6 +787,7 @@ namespace osu.Game.Database
|
||||
migration.NewRealm.Remove(decreaseSpeedBinding);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 9:
|
||||
// Pretty pointless to do this as beatmaps aren't really loaded via realm yet, but oh well.
|
||||
@ -838,6 +842,7 @@ namespace osu.Game.Database
|
||||
break;
|
||||
|
||||
case 11:
|
||||
{
|
||||
string keyBindingClassName = getMappedOrOriginalName(typeof(RealmKeyBinding));
|
||||
|
||||
if (!migration.OldRealm.Schema.TryFindObjectSchema(keyBindingClassName, out _))
|
||||
@ -864,6 +869,7 @@ namespace osu.Game.Database
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 14:
|
||||
foreach (var beatmap in migration.NewRealm.All<BeatmapInfo>())
|
||||
@ -1012,6 +1018,19 @@ namespace osu.Game.Database
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 33:
|
||||
{
|
||||
// Clear default bindings for the chat focus toggle,
|
||||
// as they would conflict with the newly-added leaderboard toggle.
|
||||
var keyBindings = migration.NewRealm.All<RealmKeyBinding>();
|
||||
|
||||
var toggleChatBind = keyBindings.FirstOrDefault(bind => bind.ActionInt == (int)GlobalAction.ToggleChatFocus);
|
||||
if (toggleChatBind != null && toggleChatBind.KeyCombination.Keys.SequenceEqual(new[] { InputKey.Tab }))
|
||||
migration.NewRealm.Remove(toggleChatBind);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Log($"Migration completed in {stopwatch.ElapsedMilliseconds}ms");
|
||||
|
@ -8,6 +8,34 @@ namespace osu.Game.Database
|
||||
{
|
||||
public static class RealmExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Performs a <see cref="Realm.Find{T}(System.Nullable{long})"/>.
|
||||
/// If a match was not found, a <see cref="Realm.Refresh"/> is performed before trying a second time.
|
||||
/// This ensures that an instance is found even if the realm requested against was not in a consistent state.
|
||||
/// </summary>
|
||||
/// <param name="realm">The realm to operate on.</param>
|
||||
/// <param name="id">The ID of the entity to find in the realm.</param>
|
||||
/// <typeparam name="T">The type of the entity to find in the realm.</typeparam>
|
||||
/// <returns>
|
||||
/// The retrieved entity of type <typeparamref name="T"/>.
|
||||
/// Can be <see langword="null"/> if the entity is still not found by <paramref name="id"/> even after a refresh.
|
||||
/// </returns>
|
||||
public static T? FindWithRefresh<T>(this Realm realm, Guid id) where T : IRealmObject
|
||||
{
|
||||
var found = realm.Find<T>(id);
|
||||
|
||||
if (found == null)
|
||||
{
|
||||
// It may be that we access this from the update thread before a refresh has taken place.
|
||||
// To ensure that behaviour matches what we'd expect (the object generally *should be* available), force
|
||||
// a refresh to bring in any off-thread changes immediately.
|
||||
realm.Refresh();
|
||||
found = realm.Find<T>(id);
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Perform a write operation against the provided realm instance.
|
||||
/// </summary>
|
||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Database
|
||||
/// <summary>
|
||||
/// Construct a new instance of live realm data.
|
||||
/// </summary>
|
||||
/// <param name="data">The realm data.</param>
|
||||
/// <param name="data">The realm data. Must be managed (see <see cref="IRealmObjectBase.IsManaged"/>).</param>
|
||||
/// <param name="realm">The realm factory the data was sourced from. May be null for an unmanaged object.</param>
|
||||
public RealmLive(T data, RealmAccess realm)
|
||||
: base(data.ID)
|
||||
@ -62,7 +62,7 @@ namespace osu.Game.Database
|
||||
return;
|
||||
}
|
||||
|
||||
perform(retrieveFromID(r));
|
||||
perform(r.FindWithRefresh<T>(ID)!);
|
||||
RealmLiveStatistics.USAGE_ASYNC.Value++;
|
||||
});
|
||||
}
|
||||
@ -84,7 +84,7 @@ namespace osu.Game.Database
|
||||
|
||||
return realm.Run(r =>
|
||||
{
|
||||
var returnData = perform(retrieveFromID(r));
|
||||
var returnData = perform(r.FindWithRefresh<T>(ID)!);
|
||||
RealmLiveStatistics.USAGE_ASYNC.Value++;
|
||||
|
||||
if (returnData is RealmObjectBase realmObject && realmObject.IsManaged)
|
||||
@ -141,25 +141,10 @@ namespace osu.Game.Database
|
||||
}
|
||||
|
||||
dataIsFromUpdateThread = true;
|
||||
data = retrieveFromID(realm.Realm);
|
||||
data = realm.Realm.FindWithRefresh<T>(ID)!;
|
||||
|
||||
RealmLiveStatistics.USAGE_UPDATE_REFETCH.Value++;
|
||||
}
|
||||
|
||||
private T retrieveFromID(Realm realm)
|
||||
{
|
||||
var found = realm.Find<T>(ID);
|
||||
|
||||
if (found == null)
|
||||
{
|
||||
// It may be that we access this from the update thread before a refresh has taken place.
|
||||
// To ensure that behaviour matches what we'd expect (the object *is* available), force
|
||||
// a refresh to bring in any off-thread changes immediately.
|
||||
realm.Refresh();
|
||||
found = realm.Find<T>(ID)!;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
internal static class RealmLiveStatistics
|
||||
|
@ -24,6 +24,7 @@ namespace osu.Game.Graphics.Containers
|
||||
private Sample samplePopOut;
|
||||
protected virtual string PopInSampleName => "UI/overlay-pop-in";
|
||||
protected virtual string PopOutSampleName => "UI/overlay-pop-out";
|
||||
protected virtual double PopInOutSampleBalance => 0;
|
||||
|
||||
protected override bool BlockNonPositionalInput => true;
|
||||
|
||||
@ -133,15 +134,21 @@ namespace osu.Game.Graphics.Containers
|
||||
return;
|
||||
}
|
||||
|
||||
if (didChange)
|
||||
samplePopIn?.Play();
|
||||
if (didChange && samplePopIn != null)
|
||||
{
|
||||
samplePopIn.Balance.Value = PopInOutSampleBalance;
|
||||
samplePopIn.Play();
|
||||
}
|
||||
|
||||
if (BlockScreenWideMouse && DimMainContent) overlayManager?.ShowBlockingOverlay(this);
|
||||
break;
|
||||
|
||||
case Visibility.Hidden:
|
||||
if (didChange)
|
||||
samplePopOut?.Play();
|
||||
if (didChange && samplePopOut != null)
|
||||
{
|
||||
samplePopOut.Balance.Value = PopInOutSampleBalance;
|
||||
samplePopOut.Play();
|
||||
}
|
||||
|
||||
if (BlockScreenWideMouse) overlayManager?.HideBlockingOverlay(this);
|
||||
break;
|
||||
|
@ -2,6 +2,9 @@
|
||||
// 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.Audio.Sample;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -32,6 +35,12 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
protected override bool StartHidden => true;
|
||||
|
||||
private Sample? samplePopIn;
|
||||
private Sample? samplePopOut;
|
||||
|
||||
// required due to LoadAsyncComplete() in `VisibilityContainer` calling PopOut() during load - similar workaround to `OsuDropdownMenu`
|
||||
private bool wasShown;
|
||||
|
||||
public Color4 FirstWaveColour
|
||||
{
|
||||
get => firstWave.Colour;
|
||||
@ -56,6 +65,13 @@ namespace osu.Game.Graphics.Containers
|
||||
set => fourthWave.Colour = value;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
samplePopIn = audio.Samples.Get("UI/wave-pop-in");
|
||||
samplePopOut = audio.Samples.Get("UI/overlay-big-pop-out");
|
||||
}
|
||||
|
||||
public WaveContainer()
|
||||
{
|
||||
Masking = true;
|
||||
@ -110,6 +126,8 @@ namespace osu.Game.Graphics.Containers
|
||||
w.Show();
|
||||
|
||||
contentContainer.MoveToY(0, APPEAR_DURATION, Easing.OutQuint);
|
||||
samplePopIn?.Play();
|
||||
wasShown = true;
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
@ -118,6 +136,9 @@ namespace osu.Game.Graphics.Containers
|
||||
w.Hide();
|
||||
|
||||
contentContainer.MoveToY(2, DISAPPEAR_DURATION, Easing.In);
|
||||
|
||||
if (wasShown)
|
||||
samplePopOut?.Play();
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
|
@ -40,8 +40,14 @@ namespace osu.Game.Graphics.UserInterface
|
||||
AddInternal(hoverClickSounds = new HoverClickSounds());
|
||||
|
||||
updateTextColour();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Item.Action.BindDisabledChanged(_ => updateState(), true);
|
||||
FinishTransforms();
|
||||
}
|
||||
|
||||
private void updateTextColour()
|
||||
|
@ -46,8 +46,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private readonly Container content;
|
||||
private readonly Box hover;
|
||||
|
||||
public OsuAnimatedButton()
|
||||
: base(HoverSampleSet.Button)
|
||||
public OsuAnimatedButton(HoverSampleSet sampleSet = HoverSampleSet.Button)
|
||||
: base(sampleSet)
|
||||
{
|
||||
base.Content.Add(content = new Container
|
||||
{
|
||||
|
@ -14,6 +14,12 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private Sample? sampleOff;
|
||||
private Sample? sampleOn;
|
||||
|
||||
/// <summary>
|
||||
/// Sheared toggle buttons by default play two samples when toggled: a click and a toggle (on/off).
|
||||
/// Sometimes this might be too much. Setting this to <c>false</c> will silence the toggle sound.
|
||||
/// </summary>
|
||||
protected virtual bool PlayToggleSamples => true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this button is currently toggled to an active state.
|
||||
/// </summary>
|
||||
@ -68,10 +74,13 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
sampleClick?.Play();
|
||||
|
||||
if (Active.Value)
|
||||
sampleOn?.Play();
|
||||
else
|
||||
sampleOff?.Play();
|
||||
if (PlayToggleSamples)
|
||||
{
|
||||
if (Active.Value)
|
||||
sampleOn?.Play();
|
||||
else
|
||||
sampleOff?.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => Component.Text;
|
||||
set => Component.Text = value;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -21,6 +23,14 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
private const float fade_duration = 250;
|
||||
private const double scale_duration = 500;
|
||||
|
||||
private Sample? samplePopIn;
|
||||
private Sample? samplePopOut;
|
||||
protected virtual string PopInSampleName => "UI/overlay-pop-in";
|
||||
protected virtual string PopOutSampleName => "UI/overlay-pop-out";
|
||||
|
||||
// required due to LoadAsyncComplete() in `VisibilityContainer` calling PopOut() during load - similar workaround to `OsuDropdownMenu`
|
||||
private bool wasOpened;
|
||||
|
||||
public OsuPopover(bool withPadding = true)
|
||||
{
|
||||
Content.Padding = withPadding ? new MarginPadding(20) : new MarginPadding();
|
||||
@ -38,9 +48,11 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OverlayColourProvider? colourProvider, OsuColour colours)
|
||||
private void load(OverlayColourProvider? colourProvider, OsuColour colours, AudioManager audio)
|
||||
{
|
||||
Background.Colour = Arrow.Colour = colourProvider?.Background4 ?? colours.GreySeaFoamDarker;
|
||||
samplePopIn = audio.Samples.Get(PopInSampleName);
|
||||
samplePopOut = audio.Samples.Get(PopOutSampleName);
|
||||
}
|
||||
|
||||
protected override Drawable CreateArrow() => Empty();
|
||||
@ -49,12 +61,18 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
this.ScaleTo(1, scale_duration, Easing.OutElasticHalf);
|
||||
this.FadeIn(fade_duration, Easing.OutQuint);
|
||||
|
||||
samplePopIn?.Play();
|
||||
wasOpened = true;
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
this.ScaleTo(0.7f, scale_duration, Easing.OutQuint);
|
||||
this.FadeOut(fade_duration, Easing.OutQuint);
|
||||
|
||||
if (wasOpened)
|
||||
samplePopOut?.Play();
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
|
145
osu.Game/Graphics/UserInterfaceV2/SliderWithTextBoxInput.cs
Normal file
145
osu.Game/Graphics/UserInterfaceV2/SliderWithTextBoxInput.cs
Normal file
@ -0,0 +1,145 @@
|
||||
// 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.Globalization;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Utils;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
public partial class SliderWithTextBoxInput<T> : CompositeDrawable, IHasCurrentValue<T>
|
||||
where T : struct, IEquatable<T>, IComparable<T>, IConvertible
|
||||
{
|
||||
/// <summary>
|
||||
/// A custom step value for each key press which actuates a change on this control.
|
||||
/// </summary>
|
||||
public float KeyboardStep
|
||||
{
|
||||
get => slider.KeyboardStep;
|
||||
set => slider.KeyboardStep = value;
|
||||
}
|
||||
|
||||
public Bindable<T> Current
|
||||
{
|
||||
get => slider.Current;
|
||||
set => slider.Current = value;
|
||||
}
|
||||
|
||||
private bool instantaneous;
|
||||
|
||||
/// <summary>
|
||||
/// Whether changes to the slider should instantaneously transfer to the text box (and vice versa).
|
||||
/// If <see langword="false"/>, the transfer will happen on text box commit (explicit, or implicit via focus loss), or on slider drag end.
|
||||
/// </summary>
|
||||
public bool Instantaneous
|
||||
{
|
||||
get => instantaneous;
|
||||
set
|
||||
{
|
||||
instantaneous = value;
|
||||
slider.TransferValueOnCommit = !instantaneous;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly SettingsSlider<T> slider;
|
||||
private readonly LabelledTextBox textBox;
|
||||
|
||||
public SliderWithTextBoxInput(LocalisableString labelText)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(20),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
textBox = new LabelledTextBox
|
||||
{
|
||||
Label = labelText,
|
||||
},
|
||||
slider = new SettingsSlider<T>
|
||||
{
|
||||
TransferValueOnCommit = true,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
textBox.OnCommit += textCommitted;
|
||||
textBox.Current.BindValueChanged(textChanged);
|
||||
|
||||
Current.BindValueChanged(updateTextBoxFromSlider, true);
|
||||
}
|
||||
|
||||
public bool TakeFocus() => GetContainingInputManager().ChangeFocus(textBox);
|
||||
|
||||
private bool updatingFromTextBox;
|
||||
|
||||
private void textChanged(ValueChangedEvent<string> change)
|
||||
{
|
||||
if (!instantaneous) return;
|
||||
|
||||
tryUpdateSliderFromTextBox();
|
||||
}
|
||||
|
||||
private void textCommitted(TextBox t, bool isNew)
|
||||
{
|
||||
tryUpdateSliderFromTextBox();
|
||||
|
||||
// If the attempted update above failed, restore text box to match the slider.
|
||||
Current.TriggerChange();
|
||||
}
|
||||
|
||||
private void tryUpdateSliderFromTextBox()
|
||||
{
|
||||
updatingFromTextBox = true;
|
||||
|
||||
try
|
||||
{
|
||||
switch (slider.Current)
|
||||
{
|
||||
case Bindable<int> bindableInt:
|
||||
bindableInt.Value = int.Parse(textBox.Current.Value);
|
||||
break;
|
||||
|
||||
case Bindable<double> bindableDouble:
|
||||
bindableDouble.Value = double.Parse(textBox.Current.Value);
|
||||
break;
|
||||
|
||||
default:
|
||||
slider.Current.Parse(textBox.Current.Value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore parsing failures.
|
||||
// sane state will eventually be restored by a commit (either explicit, or implicit via focus loss).
|
||||
}
|
||||
|
||||
updatingFromTextBox = false;
|
||||
}
|
||||
|
||||
private void updateTextBoxFromSlider(ValueChangedEvent<T> _)
|
||||
{
|
||||
if (updatingFromTextBox) return;
|
||||
|
||||
decimal decimalValue = slider.Current.Value.ToDecimal(NumberFormatInfo.InvariantInfo);
|
||||
textBox.Text = decimalValue.ToString($@"N{FormatUtils.FindPrecision(decimalValue)}");
|
||||
}
|
||||
}
|
||||
}
|
@ -21,7 +21,9 @@ namespace osu.Game.IO.Archives
|
||||
this.path = Path.GetFullPath(path);
|
||||
}
|
||||
|
||||
public override Stream GetStream(string name) => File.OpenRead(Path.Combine(path, name));
|
||||
public override Stream GetStream(string name) => File.OpenRead(GetFullPath(name));
|
||||
|
||||
public string GetFullPath(string filename) => Path.Combine(path, filename);
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
|
@ -3,33 +3,26 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Localisation;
|
||||
|
||||
namespace osu.Game.Input.Bindings
|
||||
{
|
||||
public partial class GlobalActionContainer : DatabasedKeyBindingContainer<GlobalAction>, IHandleGlobalKeyboardInput
|
||||
public partial class GlobalActionContainer : DatabasedKeyBindingContainer<GlobalAction>, IHandleGlobalKeyboardInput, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
private readonly Drawable? handler;
|
||||
|
||||
private InputManager? parentInputManager;
|
||||
private readonly IKeyBindingHandler<GlobalAction>? handler;
|
||||
|
||||
public GlobalActionContainer(OsuGameBase? game)
|
||||
: base(matchingMode: KeyCombinationMatchingMode.Modifiers)
|
||||
{
|
||||
if (game is IKeyBindingHandler<GlobalAction>)
|
||||
handler = game;
|
||||
if (game is IKeyBindingHandler<GlobalAction> h)
|
||||
handler = h;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
parentInputManager = GetContainingInputManager();
|
||||
}
|
||||
protected override bool Prioritised => true;
|
||||
|
||||
// IMPORTANT: Take care when changing order of the items in the enumerable.
|
||||
// It is used to decide the order of precedence, with the earlier items having higher precedence.
|
||||
@ -105,6 +98,7 @@ namespace osu.Game.Input.Bindings
|
||||
// See https://github.com/ppy/osu-framework/blob/master/osu.Framework/Input/StateChanges/MouseScrollRelativeInput.cs#L37-L38.
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.MouseWheelRight }, GlobalAction.EditorCyclePreviousBeatSnapDivisor),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.MouseWheelLeft }, GlobalAction.EditorCycleNextBeatSnapDivisor),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.R }, GlobalAction.EditorToggleRotateControl),
|
||||
};
|
||||
|
||||
public IEnumerable<KeyBinding> InGameKeyBindings => new[]
|
||||
@ -116,9 +110,10 @@ namespace osu.Game.Input.Bindings
|
||||
new KeyBinding(new[] { InputKey.F3 }, GlobalAction.DecreaseScrollSpeed),
|
||||
new KeyBinding(new[] { InputKey.F4 }, GlobalAction.IncreaseScrollSpeed),
|
||||
new KeyBinding(new[] { InputKey.Shift, InputKey.Tab }, GlobalAction.ToggleInGameInterface),
|
||||
new KeyBinding(InputKey.Tab, GlobalAction.ToggleInGameLeaderboard),
|
||||
new KeyBinding(InputKey.MouseMiddle, GlobalAction.PauseGameplay),
|
||||
new KeyBinding(InputKey.Control, GlobalAction.HoldForHUD),
|
||||
new KeyBinding(InputKey.Tab, GlobalAction.ToggleChatFocus),
|
||||
new KeyBinding(InputKey.Enter, GlobalAction.ToggleChatFocus),
|
||||
new KeyBinding(InputKey.F1, GlobalAction.SaveReplay),
|
||||
new KeyBinding(InputKey.F2, GlobalAction.ExportReplay),
|
||||
};
|
||||
@ -159,20 +154,9 @@ namespace osu.Game.Input.Bindings
|
||||
new KeyBinding(InputKey.F3, GlobalAction.MusicPlay)
|
||||
};
|
||||
|
||||
protected override IEnumerable<Drawable> KeyBindingInputQueue
|
||||
{
|
||||
get
|
||||
{
|
||||
// To ensure the global actions are handled with priority, this GlobalActionContainer is actually placed after game content.
|
||||
// It does not contain children as expected, so we need to forward the NonPositionalInputQueue from the parent input manager to correctly
|
||||
// allow the whole game to handle these actions.
|
||||
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e) => handler?.OnPressed(e) == true;
|
||||
|
||||
// An eventual solution to this hack is to create localised action containers for individual components like SongSelect, but this will take some rearranging.
|
||||
var inputQueue = parentInputManager?.NonPositionalInputQueue ?? base.KeyBindingInputQueue;
|
||||
|
||||
return handler != null ? inputQueue.Prepend(handler) : inputQueue;
|
||||
}
|
||||
}
|
||||
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e) => handler?.OnReleased(e);
|
||||
}
|
||||
|
||||
public enum GlobalAction
|
||||
@ -204,7 +188,6 @@ namespace osu.Game.Input.Bindings
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleMute))]
|
||||
ToggleMute,
|
||||
|
||||
// In-Game Keybindings
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SkipCutscene))]
|
||||
SkipCutscene,
|
||||
|
||||
@ -232,7 +215,6 @@ namespace osu.Game.Input.Bindings
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.QuickExit))]
|
||||
QuickExit,
|
||||
|
||||
// Game-wide beatmap music controller keybindings
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.MusicNext))]
|
||||
MusicNext,
|
||||
|
||||
@ -260,7 +242,6 @@ namespace osu.Game.Input.Bindings
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.PauseGameplay))]
|
||||
PauseGameplay,
|
||||
|
||||
// Editor
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorSetupMode))]
|
||||
EditorSetupMode,
|
||||
|
||||
@ -285,7 +266,6 @@ namespace osu.Game.Input.Bindings
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleInGameInterface))]
|
||||
ToggleInGameInterface,
|
||||
|
||||
// Song select keybindings
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleModSelection))]
|
||||
ToggleModSelection,
|
||||
|
||||
@ -378,5 +358,11 @@ namespace osu.Game.Input.Bindings
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleReplaySettings))]
|
||||
ToggleReplaySettings,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleInGameLeaderboard))]
|
||||
ToggleInGameLeaderboard,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorToggleRotateControl))]
|
||||
EditorToggleRotateControl,
|
||||
}
|
||||
}
|
||||
|
@ -219,6 +219,11 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString ToggleInGameInterface => new TranslatableString(getKey(@"toggle_in_game_interface"), @"Toggle in-game interface");
|
||||
|
||||
/// <summary>
|
||||
/// "Toggle in-game leaderboard"
|
||||
/// </summary>
|
||||
public static LocalisableString ToggleInGameLeaderboard => new TranslatableString(getKey(@"toggle_in_game_leaderboard"), @"Toggle in-game leaderboard");
|
||||
|
||||
/// <summary>
|
||||
/// "Toggle mod select"
|
||||
/// </summary>
|
||||
@ -339,6 +344,11 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString ExportReplay => new TranslatableString(getKey(@"export_replay"), @"Export replay");
|
||||
|
||||
/// <summary>
|
||||
/// "Toggle rotate control"
|
||||
/// </summary>
|
||||
public static LocalisableString EditorToggleRotateControl => new TranslatableString(getKey(@"editor_toggle_rotate_control"), @"Toggle rotate control");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
||||
|
19
osu.Game/Localisation/OnlinePlayStrings.cs
Normal file
19
osu.Game/Localisation/OnlinePlayStrings.cs
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Localisation;
|
||||
|
||||
namespace osu.Game.Localisation
|
||||
{
|
||||
public static class OnlinePlayStrings
|
||||
{
|
||||
private const string prefix = @"osu.Game.Resources.Localisation.OnlinePlay";
|
||||
|
||||
/// <summary>
|
||||
/// "Playlist durations longer than 2 weeks require an active osu!supporter tag."
|
||||
/// </summary>
|
||||
public static LocalisableString SupporterOnlyDurationNotice => new TranslatableString(getKey(@"supporter_only_duration_notice"), @"Playlist durations longer than 2 weeks require an active osu!supporter tag.");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ namespace osu.Game.Online.API
|
||||
|
||||
public Bindable<APIUser> LocalUser { get; } = new Bindable<APIUser>(new APIUser
|
||||
{
|
||||
Username = @"Dummy",
|
||||
Username = @"Local user",
|
||||
Id = DUMMY_USER_ID,
|
||||
});
|
||||
|
||||
|
@ -14,6 +14,6 @@ namespace osu.Game.Online.API.Requests
|
||||
|
||||
protected override string FileExtension => ".osr";
|
||||
|
||||
protected override string Target => $@"scores/{Model.Ruleset.ShortName}/{Model.OnlineID}/download";
|
||||
protected override string Target => $@"scores/{Model.OnlineID}/download";
|
||||
}
|
||||
}
|
||||
|
@ -182,8 +182,6 @@ namespace osu.Game.Online.Chat
|
||||
private readonly Message message;
|
||||
private readonly Channel channel;
|
||||
|
||||
public override bool IsImportant => false;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, ChatOverlay chatOverlay, INotificationOverlay notificationOverlay)
|
||||
{
|
||||
|
@ -1025,7 +1025,7 @@ namespace osu.Game
|
||||
|
||||
loadComponentSingleFile(CreateHighPerformanceSession(), Add);
|
||||
|
||||
loadComponentSingleFile(new BackgroundBeatmapProcessor(), Add);
|
||||
loadComponentSingleFile(new BackgroundDataStoreProcessor(), Add);
|
||||
|
||||
Add(difficultyRecommender);
|
||||
Add(externalLinkOpener = new ExternalLinkOpener());
|
||||
|
@ -392,17 +392,18 @@ namespace osu.Game
|
||||
{
|
||||
SafeAreaOverrideEdges = SafeAreaOverrideEdges,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = CreateScalingContainer().WithChildren(new Drawable[]
|
||||
Child = CreateScalingContainer().WithChild(globalBindings = new GlobalActionContainer(this)
|
||||
{
|
||||
(GlobalCursorDisplay = new GlobalCursorDisplay
|
||||
Children = new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}).WithChild(content = new OsuTooltipContainer(GlobalCursorDisplay.MenuCursor)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}),
|
||||
// to avoid positional input being blocked by children, ensure the GlobalActionContainer is above everything.
|
||||
globalBindings = new GlobalActionContainer(this)
|
||||
(GlobalCursorDisplay = new GlobalCursorDisplay
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}).WithChild(content = new OsuTooltipContainer(GlobalCursorDisplay.MenuCursor)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}),
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -55,6 +55,9 @@ namespace osu.Game.Overlays
|
||||
private const float side_bar_width = 190;
|
||||
private const float chat_bar_height = 60;
|
||||
|
||||
protected override string PopInSampleName => @"UI/overlay-big-pop-in";
|
||||
protected override string PopOutSampleName => @"UI/overlay-big-pop-out";
|
||||
|
||||
[Resolved]
|
||||
private OsuConfigManager config { get; set; } = null!;
|
||||
|
||||
|
@ -20,6 +20,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
private const float transition_time = 400;
|
||||
|
||||
protected override double PopInOutSampleBalance => OsuGameBase.SFX_STEREO_STRENGTH;
|
||||
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||
|
||||
|
@ -18,6 +18,8 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public partial class AddPresetButton : ShearedToggleButton, IHasPopover
|
||||
{
|
||||
protected override bool PlayToggleSamples => false;
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; } = null!;
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user