mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Merge branch 'master' into mod-overlay/columns
This commit is contained in:
@ -394,6 +394,7 @@ namespace osu.Game.Rulesets.Mania
|
|||||||
{
|
{
|
||||||
new StatisticItem(string.Empty, () => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
new StatisticItem(string.Empty, () => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||||
{
|
{
|
||||||
|
new AverageHitError(score.HitEvents),
|
||||||
new UnstableRate(score.HitEvents)
|
new UnstableRate(score.HitEvents)
|
||||||
}), true)
|
}), true)
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using osu.Framework.Utils;
|
|||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
@ -72,7 +73,11 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
EditorClock.Seek(slider.StartTime);
|
EditorClock.Seek(slider.StartTime);
|
||||||
EditorBeatmap.SelectedHitObjects.Add(slider);
|
EditorBeatmap.SelectedHitObjects.Add(slider);
|
||||||
});
|
});
|
||||||
AddStep("change beat divisor", () => beatDivisor.Value = 3);
|
AddStep("change beat divisor", () =>
|
||||||
|
{
|
||||||
|
beatDivisor.ValidDivisors.Value = BeatDivisorPresetCollection.TRIPLETS;
|
||||||
|
beatDivisor.Value = 3;
|
||||||
|
});
|
||||||
|
|
||||||
convertToStream();
|
convertToStream();
|
||||||
|
|
||||||
|
@ -314,6 +314,7 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
{
|
{
|
||||||
new StatisticItem(string.Empty, () => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
new StatisticItem(string.Empty, () => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||||
{
|
{
|
||||||
|
new AverageHitError(timedHitEvents),
|
||||||
new UnstableRate(timedHitEvents)
|
new UnstableRate(timedHitEvents)
|
||||||
}), true)
|
}), true)
|
||||||
}
|
}
|
||||||
|
@ -237,6 +237,7 @@ namespace osu.Game.Rulesets.Taiko
|
|||||||
{
|
{
|
||||||
new StatisticItem(string.Empty, () => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
new StatisticItem(string.Empty, () => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||||
{
|
{
|
||||||
|
new AverageHitError(timedHitEvents),
|
||||||
new UnstableRate(timedHitEvents)
|
new UnstableRate(timedHitEvents)
|
||||||
}), true)
|
}), true)
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
@ -18,6 +20,33 @@ namespace osu.Game.Tests.Database
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class RealmSubscriptionRegistrationTests : RealmTest
|
public class RealmSubscriptionRegistrationTests : RealmTest
|
||||||
{
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestSubscriptionWithAsyncWrite()
|
||||||
|
{
|
||||||
|
ChangeSet? lastChanges = null;
|
||||||
|
|
||||||
|
RunTestWithRealm((realm, _) =>
|
||||||
|
{
|
||||||
|
var registration = realm.RegisterForNotifications(r => r.All<BeatmapSetInfo>(), onChanged);
|
||||||
|
|
||||||
|
realm.Run(r => r.Refresh());
|
||||||
|
|
||||||
|
// Without forcing the write onto its own thread, realm will internally run the operation synchronously, which can cause a deadlock with `WaitSafely`.
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await realm.WriteAsync(r => r.Add(TestResources.CreateTestBeatmapSetInfo()));
|
||||||
|
}).WaitSafely();
|
||||||
|
|
||||||
|
realm.Run(r => r.Refresh());
|
||||||
|
|
||||||
|
Assert.That(lastChanges?.InsertedIndices, Has.One.Items);
|
||||||
|
|
||||||
|
registration.Dispose();
|
||||||
|
});
|
||||||
|
|
||||||
|
void onChanged(IRealmCollection<BeatmapSetInfo> sender, ChangeSet? changes, Exception error) => lastChanges = changes;
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestSubscriptionWithContextLoss()
|
public void TestSubscriptionWithContextLoss()
|
||||||
{
|
{
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
@ -20,30 +22,31 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
private BeatDivisorControl beatDivisorControl;
|
private BeatDivisorControl beatDivisorControl;
|
||||||
private BindableBeatDivisor bindableBeatDivisor;
|
private BindableBeatDivisor bindableBeatDivisor;
|
||||||
|
|
||||||
private SliderBar<int> tickSliderBar;
|
private SliderBar<int> tickSliderBar => beatDivisorControl.ChildrenOfType<SliderBar<int>>().Single();
|
||||||
private EquilateralTriangle tickMarkerHead;
|
private EquilateralTriangle tickMarkerHead => tickSliderBar.ChildrenOfType<EquilateralTriangle>().Single();
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp() => Schedule(() =>
|
public void SetUp() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Child = beatDivisorControl = new BeatDivisorControl(bindableBeatDivisor = new BindableBeatDivisor(16))
|
Child = new PopoverContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Origin = Anchor.Centre,
|
Child = beatDivisorControl = new BeatDivisorControl(bindableBeatDivisor = new BindableBeatDivisor(16))
|
||||||
Size = new Vector2(90, 90)
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(90, 90)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
tickSliderBar = beatDivisorControl.ChildrenOfType<SliderBar<int>>().Single();
|
|
||||||
tickMarkerHead = tickSliderBar.ChildrenOfType<EquilateralTriangle>().Single();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestBindableBeatDivisor()
|
public void TestBindableBeatDivisor()
|
||||||
{
|
{
|
||||||
AddRepeatStep("move previous", () => bindableBeatDivisor.Previous(), 4);
|
AddRepeatStep("move previous", () => bindableBeatDivisor.Previous(), 2);
|
||||||
AddAssert("divisor is 4", () => bindableBeatDivisor.Value == 4);
|
AddAssert("divisor is 4", () => bindableBeatDivisor.Value == 4);
|
||||||
AddRepeatStep("move next", () => bindableBeatDivisor.Next(), 3);
|
AddRepeatStep("move next", () => bindableBeatDivisor.Next(), 1);
|
||||||
AddAssert("divisor is 12", () => bindableBeatDivisor.Value == 12);
|
AddAssert("divisor is 12", () => bindableBeatDivisor.Value == 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -79,5 +82,115 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
sliderDrawQuad.Centre.Y
|
sliderDrawQuad.Centre.Y
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestBeatChevronNavigation()
|
||||||
|
{
|
||||||
|
switchBeatSnap(1);
|
||||||
|
assertBeatSnap(1);
|
||||||
|
|
||||||
|
switchBeatSnap(3);
|
||||||
|
assertBeatSnap(8);
|
||||||
|
|
||||||
|
switchBeatSnap(-1);
|
||||||
|
assertBeatSnap(4);
|
||||||
|
|
||||||
|
switchBeatSnap(-3);
|
||||||
|
assertBeatSnap(16);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestBeatPresetNavigation()
|
||||||
|
{
|
||||||
|
assertPreset(BeatDivisorType.Common);
|
||||||
|
|
||||||
|
switchPresets(1);
|
||||||
|
assertPreset(BeatDivisorType.Triplets);
|
||||||
|
|
||||||
|
switchPresets(1);
|
||||||
|
assertPreset(BeatDivisorType.Common);
|
||||||
|
|
||||||
|
switchPresets(-1);
|
||||||
|
assertPreset(BeatDivisorType.Triplets);
|
||||||
|
|
||||||
|
switchPresets(-1);
|
||||||
|
assertPreset(BeatDivisorType.Common);
|
||||||
|
|
||||||
|
setDivisorViaInput(3);
|
||||||
|
assertPreset(BeatDivisorType.Triplets);
|
||||||
|
|
||||||
|
setDivisorViaInput(8);
|
||||||
|
assertPreset(BeatDivisorType.Common);
|
||||||
|
|
||||||
|
setDivisorViaInput(15);
|
||||||
|
assertPreset(BeatDivisorType.Custom, 15);
|
||||||
|
|
||||||
|
switchBeatSnap(-1);
|
||||||
|
assertBeatSnap(5);
|
||||||
|
|
||||||
|
switchBeatSnap(-1);
|
||||||
|
assertBeatSnap(3);
|
||||||
|
|
||||||
|
setDivisorViaInput(5);
|
||||||
|
assertPreset(BeatDivisorType.Custom, 15);
|
||||||
|
|
||||||
|
switchPresets(1);
|
||||||
|
assertPreset(BeatDivisorType.Common);
|
||||||
|
|
||||||
|
switchPresets(-1);
|
||||||
|
assertPreset(BeatDivisorType.Triplets);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void switchBeatSnap(int direction) => AddRepeatStep($"move snap {(direction > 0 ? "forward" : "backward")}", () =>
|
||||||
|
{
|
||||||
|
int chevronIndex = direction > 0 ? 1 : 0;
|
||||||
|
var chevronButton = beatDivisorControl.ChildrenOfType<BeatDivisorControl.ChevronButton>().ElementAt(chevronIndex);
|
||||||
|
InputManager.MoveMouseTo(chevronButton);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
}, Math.Abs(direction));
|
||||||
|
|
||||||
|
private void assertBeatSnap(int expected) => AddAssert($"beat snap is {expected}",
|
||||||
|
() => bindableBeatDivisor.Value == expected);
|
||||||
|
|
||||||
|
private void switchPresets(int direction) => AddRepeatStep($"move presets {(direction > 0 ? "forward" : "backward")}", () =>
|
||||||
|
{
|
||||||
|
int chevronIndex = direction > 0 ? 3 : 2;
|
||||||
|
var chevronButton = beatDivisorControl.ChildrenOfType<BeatDivisorControl.ChevronButton>().ElementAt(chevronIndex);
|
||||||
|
InputManager.MoveMouseTo(chevronButton);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
}, Math.Abs(direction));
|
||||||
|
|
||||||
|
private void assertPreset(BeatDivisorType type, int? maxDivisor = null)
|
||||||
|
{
|
||||||
|
AddAssert($"preset is {type}", () => bindableBeatDivisor.ValidDivisors.Value.Type == type);
|
||||||
|
|
||||||
|
if (type == BeatDivisorType.Custom)
|
||||||
|
{
|
||||||
|
Debug.Assert(maxDivisor != null);
|
||||||
|
AddAssert($"max divisor is {maxDivisor}", () => bindableBeatDivisor.ValidDivisors.Value.Presets.Max() == maxDivisor.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDivisorViaInput(int divisor)
|
||||||
|
{
|
||||||
|
AddStep("open divisor input popover", () =>
|
||||||
|
{
|
||||||
|
var button = beatDivisorControl.ChildrenOfType<BeatDivisorControl.DivisorDisplay>().Single();
|
||||||
|
InputManager.MoveMouseTo(button);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
BeatDivisorControl.CustomDivisorPopover popover = null;
|
||||||
|
AddUntilStep("wait for popover", () => (popover = this.ChildrenOfType<BeatDivisorControl.CustomDivisorPopover>().SingleOrDefault()) != null && popover.IsLoaded);
|
||||||
|
AddStep($"set divisor to {divisor}", () =>
|
||||||
|
{
|
||||||
|
var textBox = popover.ChildrenOfType<TextBox>().Single();
|
||||||
|
InputManager.MoveMouseTo(textBox);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
textBox.Text = divisor.ToString();
|
||||||
|
InputManager.Key(Key.Enter);
|
||||||
|
});
|
||||||
|
AddUntilStep("wait for dismiss", () => !this.ChildrenOfType<BeatDivisorControl.CustomDivisorPopover>().Any());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,13 @@ using osu.Game.Database;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Difficulty;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
|
using osu.Game.Screens.Ranking.Expanded.Statistics;
|
||||||
using osu.Game.Screens.Ranking.Statistics;
|
using osu.Game.Screens.Ranking.Statistics;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -256,6 +259,23 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
AddAssert("download button is enabled", () => screen.ChildrenOfType<DownloadButton>().Last().Enabled.Value);
|
AddAssert("download button is enabled", () => screen.ChildrenOfType<DownloadButton>().Last().Enabled.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRulesetWithNoPerformanceCalculator()
|
||||||
|
{
|
||||||
|
var ruleset = new RulesetWithNoPerformanceCalculator();
|
||||||
|
var score = TestResources.CreateTestScoreInfo(ruleset.RulesetInfo);
|
||||||
|
|
||||||
|
AddStep("load results", () => Child = new TestResultsContainer(createResultsScreen(score)));
|
||||||
|
AddUntilStep("wait for load", () => this.ChildrenOfType<ScorePanelList>().Single().AllPanelsVisible);
|
||||||
|
|
||||||
|
AddAssert("PP displayed as 0", () =>
|
||||||
|
{
|
||||||
|
var performance = this.ChildrenOfType<PerformanceStatistic>().Single();
|
||||||
|
var counter = performance.ChildrenOfType<StatisticCounter>().Single();
|
||||||
|
return counter.Current.Value == 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private TestResultsScreen createResultsScreen(ScoreInfo score = null) => new TestResultsScreen(score ?? TestResources.CreateTestScoreInfo());
|
private TestResultsScreen createResultsScreen(ScoreInfo score = null) => new TestResultsScreen(score ?? TestResources.CreateTestScoreInfo());
|
||||||
|
|
||||||
private UnrankedSoloResultsScreen createUnrankedSoloResultsScreen() => new UnrankedSoloResultsScreen(TestResources.CreateTestScoreInfo());
|
private UnrankedSoloResultsScreen createUnrankedSoloResultsScreen() => new UnrankedSoloResultsScreen(TestResources.CreateTestScoreInfo());
|
||||||
@ -367,5 +387,10 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
RetryOverlay = InternalChildren.OfType<HotkeyRetryOverlay>().SingleOrDefault();
|
RetryOverlay = InternalChildren.OfType<HotkeyRetryOverlay>().SingleOrDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class RulesetWithNoPerformanceCalculator : OsuRuleset
|
||||||
|
{
|
||||||
|
public override PerformanceCalculator CreatePerformanceCalculator(DifficultyAttributes attributes, ScoreInfo score) => null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
50
osu.Game.Tournament.Tests/Components/TestSceneSongBar.cs
Normal file
50
osu.Game.Tournament.Tests/Components/TestSceneSongBar.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
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 class TestSceneSongBar : OsuTestScene
|
||||||
|
{
|
||||||
|
[Cached]
|
||||||
|
private readonly LadderInfo ladder = new LadderInfo();
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSongBar()
|
||||||
|
{
|
||||||
|
SongBar songBar = null;
|
||||||
|
|
||||||
|
AddStep("create bar", () => Child = songBar = new SongBar
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre
|
||||||
|
});
|
||||||
|
AddUntilStep("wait for loaded", () => songBar.IsLoaded);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
songBar.Beatmap = 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -186,7 +186,7 @@ namespace osu.Game.Tournament.Components
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new DiffPiece(stats),
|
new DiffPiece(stats),
|
||||||
new DiffPiece(("Star Rating", $"{beatmap.StarRating:0.#}{srExtra}"))
|
new DiffPiece(("Star Rating", $"{beatmap.StarRating:0.##}{srExtra}"))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
|
@ -24,9 +24,6 @@ namespace osu.Game.Tournament.Components
|
|||||||
|
|
||||||
private readonly string mod;
|
private readonly string mod;
|
||||||
|
|
||||||
private const float horizontal_padding = 10;
|
|
||||||
private const float vertical_padding = 10;
|
|
||||||
|
|
||||||
public const float HEIGHT = 50;
|
public const float HEIGHT = 50;
|
||||||
|
|
||||||
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
|
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
|
||||||
|
@ -164,7 +164,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
int closestDivisor = 0;
|
int closestDivisor = 0;
|
||||||
double closestTime = double.MaxValue;
|
double closestTime = double.MaxValue;
|
||||||
|
|
||||||
foreach (int divisor in BindableBeatDivisor.VALID_DIVISORS)
|
foreach (int divisor in BindableBeatDivisor.PREDEFINED_DIVISORS)
|
||||||
{
|
{
|
||||||
double distanceFromSnap = Math.Abs(time - getClosestSnappedTime(timingPoint, time, divisor));
|
double distanceFromSnap = Math.Abs(time - getClosestSnappedTime(timingPoint, time, divisor));
|
||||||
|
|
||||||
|
@ -8,20 +8,21 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Development;
|
using osu.Framework.Development;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Statistics;
|
using osu.Framework.Statistics;
|
||||||
using osu.Game.Configuration;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Models;
|
using osu.Game.Models;
|
||||||
using osu.Game.Skinning;
|
|
||||||
using osu.Game.Stores;
|
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osu.Game.Stores;
|
||||||
using Realms;
|
using Realms;
|
||||||
using Realms.Exceptions;
|
using Realms.Exceptions;
|
||||||
|
|
||||||
@ -85,6 +86,14 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
private static readonly GlobalStatistic<int> total_subscriptions = GlobalStatistics.Get<int>(@"Realm", @"Subscriptions");
|
private static readonly GlobalStatistic<int> total_subscriptions = GlobalStatistics.Get<int>(@"Realm", @"Subscriptions");
|
||||||
|
|
||||||
|
private static readonly GlobalStatistic<int> total_reads_update = GlobalStatistics.Get<int>(@"Realm", @"Reads (Update)");
|
||||||
|
|
||||||
|
private static readonly GlobalStatistic<int> total_reads_async = GlobalStatistics.Get<int>(@"Realm", @"Reads (Async)");
|
||||||
|
|
||||||
|
private static readonly GlobalStatistic<int> total_writes_update = GlobalStatistics.Get<int>(@"Realm", @"Writes (Update)");
|
||||||
|
|
||||||
|
private static readonly GlobalStatistic<int> total_writes_async = GlobalStatistics.Get<int>(@"Realm", @"Writes (Async)");
|
||||||
|
|
||||||
private readonly object realmLock = new object();
|
private readonly object realmLock = new object();
|
||||||
|
|
||||||
private Realm? updateRealm;
|
private Realm? updateRealm;
|
||||||
@ -213,8 +222,12 @@ namespace osu.Game.Database
|
|||||||
public T Run<T>(Func<Realm, T> action)
|
public T Run<T>(Func<Realm, T> action)
|
||||||
{
|
{
|
||||||
if (ThreadSafety.IsUpdateThread)
|
if (ThreadSafety.IsUpdateThread)
|
||||||
|
{
|
||||||
|
total_reads_update.Value++;
|
||||||
return action(Realm);
|
return action(Realm);
|
||||||
|
}
|
||||||
|
|
||||||
|
total_reads_async.Value++;
|
||||||
using (var realm = getRealmInstance())
|
using (var realm = getRealmInstance())
|
||||||
return action(realm);
|
return action(realm);
|
||||||
}
|
}
|
||||||
@ -226,9 +239,13 @@ namespace osu.Game.Database
|
|||||||
public void Run(Action<Realm> action)
|
public void Run(Action<Realm> action)
|
||||||
{
|
{
|
||||||
if (ThreadSafety.IsUpdateThread)
|
if (ThreadSafety.IsUpdateThread)
|
||||||
|
{
|
||||||
|
total_reads_update.Value++;
|
||||||
action(Realm);
|
action(Realm);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
total_reads_async.Value++;
|
||||||
using (var realm = getRealmInstance())
|
using (var realm = getRealmInstance())
|
||||||
action(realm);
|
action(realm);
|
||||||
}
|
}
|
||||||
@ -241,14 +258,30 @@ namespace osu.Game.Database
|
|||||||
public void Write(Action<Realm> action)
|
public void Write(Action<Realm> action)
|
||||||
{
|
{
|
||||||
if (ThreadSafety.IsUpdateThread)
|
if (ThreadSafety.IsUpdateThread)
|
||||||
|
{
|
||||||
|
total_writes_update.Value++;
|
||||||
Realm.Write(action);
|
Realm.Write(action);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
total_writes_async.Value++;
|
||||||
|
|
||||||
using (var realm = getRealmInstance())
|
using (var realm = getRealmInstance())
|
||||||
realm.Write(action);
|
realm.Write(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write changes to realm asynchronously, guaranteeing order of execution.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="action">The work to run.</param>
|
||||||
|
public async Task WriteAsync(Action<Realm> action)
|
||||||
|
{
|
||||||
|
total_writes_async.Value++;
|
||||||
|
using (var realm = getRealmInstance())
|
||||||
|
await realm.WriteAsync(action);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Subscribe to a realm collection and begin watching for asynchronous changes.
|
/// Subscribe to a realm collection and begin watching for asynchronous changes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -22,6 +22,16 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
return 10 * standardDeviation(timeOffsets);
|
return 10 * standardDeviation(timeOffsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calculates the average hit offset/error for a sequence of <see cref="HitEvent"/>s, where negative numbers mean the user hit too early on average.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// A non-null <see langword="double"/> value if unstable rate could be calculated,
|
||||||
|
/// and <see langword="null"/> if unstable rate cannot be calculated due to <paramref name="hitEvents"/> being empty.
|
||||||
|
/// </returns>
|
||||||
|
public static double? CalculateAverageHitError(this IEnumerable<HitEvent> hitEvents) =>
|
||||||
|
hitEvents.Where(affectsUnstableRate).Select(ev => ev.TimeOffset).Average();
|
||||||
|
|
||||||
private static bool affectsUnstableRate(HitEvent e) => !(e.HitObject.HitWindows is HitWindows.EmptyHitWindows) && e.Result.IsHit();
|
private static bool affectsUnstableRate(HitEvent e) => !(e.HitObject.HitWindows is HitWindows.EmptyHitWindows) && e.Result.IsHit();
|
||||||
|
|
||||||
private static double? standardDeviation(double[] timeOffsets)
|
private static double? standardDeviation(double[] timeOffsets)
|
||||||
|
@ -1,46 +1,64 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit
|
namespace osu.Game.Screens.Edit
|
||||||
{
|
{
|
||||||
public class BindableBeatDivisor : BindableInt
|
public class BindableBeatDivisor : BindableInt
|
||||||
{
|
{
|
||||||
public static readonly int[] VALID_DIVISORS = { 1, 2, 3, 4, 6, 8, 12, 16 };
|
public static readonly int[] PREDEFINED_DIVISORS = { 1, 2, 3, 4, 6, 8, 12, 16 };
|
||||||
|
|
||||||
|
public Bindable<BeatDivisorPresetCollection> ValidDivisors { get; } = new Bindable<BeatDivisorPresetCollection>(BeatDivisorPresetCollection.COMMON);
|
||||||
|
|
||||||
public BindableBeatDivisor(int value = 1)
|
public BindableBeatDivisor(int value = 1)
|
||||||
: base(value)
|
: base(value)
|
||||||
{
|
{
|
||||||
|
ValidDivisors.BindValueChanged(_ => updateBindableProperties(), true);
|
||||||
|
BindValueChanged(_ => ensureValidDivisor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Next() => Value = VALID_DIVISORS[Math.Min(VALID_DIVISORS.Length - 1, Array.IndexOf(VALID_DIVISORS, Value) + 1)];
|
private void updateBindableProperties()
|
||||||
|
|
||||||
public void Previous() => Value = VALID_DIVISORS[Math.Max(0, Array.IndexOf(VALID_DIVISORS, Value) - 1)];
|
|
||||||
|
|
||||||
public override int Value
|
|
||||||
{
|
{
|
||||||
get => base.Value;
|
ensureValidDivisor();
|
||||||
set
|
|
||||||
{
|
|
||||||
if (!VALID_DIVISORS.Contains(value))
|
|
||||||
{
|
|
||||||
// If it doesn't match, value will be 0, but will be clamped to the valid range via DefaultMinValue
|
|
||||||
value = Array.FindLast(VALID_DIVISORS, d => d < value);
|
|
||||||
}
|
|
||||||
|
|
||||||
base.Value = value;
|
MinValue = ValidDivisors.Value.Presets.Min();
|
||||||
}
|
MaxValue = ValidDivisors.Value.Presets.Max();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ensureValidDivisor()
|
||||||
|
{
|
||||||
|
if (!ValidDivisors.Value.Presets.Contains(Value))
|
||||||
|
Value = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Next()
|
||||||
|
{
|
||||||
|
var presets = ValidDivisors.Value.Presets;
|
||||||
|
Value = presets.Cast<int?>().SkipWhile(preset => preset != Value).ElementAtOrDefault(1) ?? presets[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Previous()
|
||||||
|
{
|
||||||
|
var presets = ValidDivisors.Value.Presets;
|
||||||
|
Value = presets.Cast<int?>().TakeWhile(preset => preset != Value).LastOrDefault() ?? presets[^1];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override int DefaultMinValue => VALID_DIVISORS.First();
|
|
||||||
protected override int DefaultMaxValue => VALID_DIVISORS.Last();
|
|
||||||
protected override int DefaultPrecision => 1;
|
protected override int DefaultPrecision => 1;
|
||||||
|
|
||||||
|
public override void BindTo(Bindable<int> them)
|
||||||
|
{
|
||||||
|
// bind to valid divisors first (if applicable) to ensure correct transfer of the actual divisor.
|
||||||
|
if (them is BindableBeatDivisor otherBeatDivisor)
|
||||||
|
ValidDivisors.BindTo(otherBeatDivisor.ValidDivisors);
|
||||||
|
|
||||||
|
base.BindTo(them);
|
||||||
|
}
|
||||||
|
|
||||||
protected override Bindable<int> CreateInstance() => new BindableBeatDivisor();
|
protected override Bindable<int> CreateInstance() => new BindableBeatDivisor();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -92,7 +110,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
int beat = index % beatDivisor;
|
int beat = index % beatDivisor;
|
||||||
|
|
||||||
foreach (int divisor in BindableBeatDivisor.VALID_DIVISORS)
|
foreach (int divisor in PREDEFINED_DIVISORS)
|
||||||
{
|
{
|
||||||
if ((beat * divisor) % beatDivisor == 0)
|
if ((beat * divisor) % beatDivisor == 0)
|
||||||
return divisor;
|
return divisor;
|
||||||
|
@ -2,19 +2,26 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Humanizer;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -62,7 +69,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = Color4.Black
|
Colour = Color4.Black
|
||||||
},
|
},
|
||||||
new TickSliderBar(beatDivisor, BindableBeatDivisor.VALID_DIVISORS)
|
new TickSliderBar(beatDivisor)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
}
|
}
|
||||||
@ -84,7 +91,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding { Horizontal = 5 },
|
|
||||||
Child = new GridContainer
|
Child = new GridContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -92,13 +98,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
{
|
{
|
||||||
new DivisorButton
|
new ChevronButton
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.ChevronLeft,
|
Icon = FontAwesome.Solid.ChevronLeft,
|
||||||
Action = beatDivisor.Previous
|
Action = beatDivisor.Previous
|
||||||
},
|
},
|
||||||
new DivisorText(beatDivisor),
|
new DivisorDisplay { BeatDivisor = { BindTarget = beatDivisor } },
|
||||||
new DivisorButton
|
new ChevronButton
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.ChevronRight,
|
Icon = FontAwesome.Solid.ChevronRight,
|
||||||
Action = beatDivisor.Next
|
Action = beatDivisor.Next
|
||||||
@ -121,49 +127,233 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
new TextFlowContainer(s => s.Font = s.Font.With(size: 14))
|
new TextFlowContainer(s => s.Font = s.Font.With(size: 14))
|
||||||
{
|
{
|
||||||
Padding = new MarginPadding { Horizontal = 15 },
|
Padding = new MarginPadding { Horizontal = 15 },
|
||||||
Text = "beat snap divisor",
|
Text = "beat snap",
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
TextAnchor = Anchor.TopCentre
|
TextAnchor = Anchor.TopCentre
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = colours.Gray4
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Child = new GridContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new ChevronButton
|
||||||
|
{
|
||||||
|
Icon = FontAwesome.Solid.ChevronLeft,
|
||||||
|
Action = () => cycleDivisorType(-1)
|
||||||
|
},
|
||||||
|
new DivisorTypeText { BeatDivisor = { BindTarget = beatDivisor } },
|
||||||
|
new ChevronButton
|
||||||
|
{
|
||||||
|
Icon = FontAwesome.Solid.ChevronRight,
|
||||||
|
Action = () => cycleDivisorType(1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ColumnDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(GridSizeMode.Absolute, 20),
|
||||||
|
new Dimension(),
|
||||||
|
new Dimension(GridSizeMode.Absolute, 20)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
RowDimensions = new[]
|
RowDimensions = new[]
|
||||||
{
|
{
|
||||||
new Dimension(GridSizeMode.Absolute, 30),
|
new Dimension(GridSizeMode.Absolute, 30),
|
||||||
new Dimension(GridSizeMode.Absolute, 25),
|
new Dimension(GridSizeMode.Absolute, 20),
|
||||||
|
new Dimension(GridSizeMode.Absolute, 15)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DivisorText : SpriteText
|
private void cycleDivisorType(int direction)
|
||||||
{
|
{
|
||||||
private readonly Bindable<int> beatDivisor = new Bindable<int>();
|
Debug.Assert(Math.Abs(direction) == 1);
|
||||||
|
int nextDivisorType = (int)beatDivisor.ValidDivisors.Value.Type + direction;
|
||||||
|
if (nextDivisorType > (int)BeatDivisorType.Triplets)
|
||||||
|
nextDivisorType = (int)BeatDivisorType.Common;
|
||||||
|
else if (nextDivisorType < (int)BeatDivisorType.Common)
|
||||||
|
nextDivisorType = (int)BeatDivisorType.Triplets;
|
||||||
|
|
||||||
public DivisorText(BindableBeatDivisor beatDivisor)
|
switch ((BeatDivisorType)nextDivisorType)
|
||||||
{
|
{
|
||||||
this.beatDivisor.BindTo(beatDivisor);
|
case BeatDivisorType.Common:
|
||||||
|
beatDivisor.ValidDivisors.Value = BeatDivisorPresetCollection.COMMON;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BeatDivisorType.Triplets:
|
||||||
|
beatDivisor.ValidDivisors.Value = BeatDivisorPresetCollection.TRIPLETS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BeatDivisorType.Custom:
|
||||||
|
beatDivisor.ValidDivisors.Value = BeatDivisorPresetCollection.Custom(beatDivisor.ValidDivisors.Value.Presets.Max());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class DivisorDisplay : OsuAnimatedButton, IHasPopover
|
||||||
|
{
|
||||||
|
public BindableBeatDivisor BeatDivisor { get; } = new BindableBeatDivisor();
|
||||||
|
|
||||||
|
private readonly OsuSpriteText divisorText;
|
||||||
|
|
||||||
|
public DivisorDisplay()
|
||||||
|
{
|
||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
Add(divisorText = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.Default.With(size: 20),
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Margin = new MarginPadding
|
||||||
|
{
|
||||||
|
Horizontal = 5
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Action = this.ShowPopover;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
Colour = colours.BlueLighter;
|
divisorText.Colour = colours.BlueLighter;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
beatDivisor.BindValueChanged(val => Text = $"1/{val.NewValue}", true);
|
updateState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateState()
|
||||||
|
{
|
||||||
|
BeatDivisor.BindValueChanged(val => divisorText.Text = $"1/{val.NewValue}", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Popover GetPopover() => new CustomDivisorPopover
|
||||||
|
{
|
||||||
|
BeatDivisor = { BindTarget = BeatDivisor }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class CustomDivisorPopover : OsuPopover
|
||||||
|
{
|
||||||
|
public BindableBeatDivisor BeatDivisor { get; } = new BindableBeatDivisor();
|
||||||
|
|
||||||
|
private readonly OsuNumberBox divisorTextBox;
|
||||||
|
|
||||||
|
public CustomDivisorPopover()
|
||||||
|
{
|
||||||
|
Child = new FillFlowContainer
|
||||||
|
{
|
||||||
|
Width = 150,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Spacing = new Vector2(10),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
divisorTextBox = new OsuNumberBox
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
PlaceholderText = "Beat divisor"
|
||||||
|
},
|
||||||
|
new OsuTextFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Text = "Related divisors will be added to the list of presets."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
BeatDivisor.BindValueChanged(_ => updateState(), true);
|
||||||
|
divisorTextBox.OnCommit += (_, __) => setPresets();
|
||||||
|
|
||||||
|
Schedule(() => GetContainingInputManager().ChangeFocus(divisorTextBox));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPresets()
|
||||||
|
{
|
||||||
|
if (!int.TryParse(divisorTextBox.Text, out int divisor) || divisor < 1 || divisor > 64)
|
||||||
|
{
|
||||||
|
updateState();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!BeatDivisor.ValidDivisors.Value.Presets.Contains(divisor))
|
||||||
|
{
|
||||||
|
if (BeatDivisorPresetCollection.COMMON.Presets.Contains(divisor))
|
||||||
|
BeatDivisor.ValidDivisors.Value = BeatDivisorPresetCollection.COMMON;
|
||||||
|
else if (BeatDivisorPresetCollection.TRIPLETS.Presets.Contains(divisor))
|
||||||
|
BeatDivisor.ValidDivisors.Value = BeatDivisorPresetCollection.TRIPLETS;
|
||||||
|
else
|
||||||
|
BeatDivisor.ValidDivisors.Value = BeatDivisorPresetCollection.Custom(divisor);
|
||||||
|
}
|
||||||
|
|
||||||
|
BeatDivisor.Value = divisor;
|
||||||
|
|
||||||
|
this.HidePopover();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateState()
|
||||||
|
{
|
||||||
|
divisorTextBox.Text = BeatDivisor.Value.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DivisorButton : IconButton
|
private class DivisorTypeText : OsuSpriteText
|
||||||
{
|
{
|
||||||
public DivisorButton()
|
public BindableBeatDivisor BeatDivisor { get; } = new BindableBeatDivisor();
|
||||||
|
|
||||||
|
public DivisorTypeText()
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre;
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
|
Font = OsuFont.Default.With(size: 14);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
BeatDivisor.ValidDivisors.BindValueChanged(val => Text = val.NewValue.Type.Humanize(LetterCasing.LowerCase), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class ChevronButton : IconButton
|
||||||
|
{
|
||||||
|
public ChevronButton()
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
@ -192,20 +382,27 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
private OsuColour colours { get; set; }
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
private readonly BindableBeatDivisor beatDivisor;
|
private readonly BindableBeatDivisor beatDivisor;
|
||||||
private readonly int[] availableDivisors;
|
|
||||||
|
|
||||||
public TickSliderBar(BindableBeatDivisor beatDivisor, params int[] divisors)
|
public TickSliderBar(BindableBeatDivisor beatDivisor)
|
||||||
{
|
{
|
||||||
CurrentNumber.BindTo(this.beatDivisor = beatDivisor);
|
CurrentNumber.BindTo(this.beatDivisor = beatDivisor);
|
||||||
availableDivisors = divisors;
|
|
||||||
|
|
||||||
Padding = new MarginPadding { Horizontal = 5 };
|
Padding = new MarginPadding { Horizontal = 5 };
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
protected override void LoadComplete()
|
||||||
private void load()
|
|
||||||
{
|
{
|
||||||
foreach (int t in availableDivisors)
|
base.LoadComplete();
|
||||||
|
|
||||||
|
beatDivisor.ValidDivisors.BindValueChanged(_ => updateDivisors(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDivisors()
|
||||||
|
{
|
||||||
|
ClearInternal();
|
||||||
|
CurrentNumber.ValueChanged -= moveMarker;
|
||||||
|
|
||||||
|
foreach (int t in beatDivisor.ValidDivisors.Value.Presets)
|
||||||
{
|
{
|
||||||
AddInternal(new Tick
|
AddInternal(new Tick
|
||||||
{
|
{
|
||||||
@ -218,17 +415,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
AddInternal(marker = new Marker());
|
AddInternal(marker = new Marker());
|
||||||
|
CurrentNumber.ValueChanged += moveMarker;
|
||||||
|
CurrentNumber.TriggerChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
private void moveMarker(ValueChangedEvent<int> divisor)
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
marker.MoveToX(getMappedPosition(divisor.NewValue), 100, Easing.OutQuint);
|
||||||
|
marker.Flash();
|
||||||
CurrentNumber.BindValueChanged(div =>
|
|
||||||
{
|
|
||||||
marker.MoveToX(getMappedPosition(div.NewValue), 100, Easing.OutQuint);
|
|
||||||
marker.Flash();
|
|
||||||
}, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateValue(float value)
|
protected override void UpdateValue(float value)
|
||||||
@ -289,11 +483,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
// copied from SliderBar so we can do custom spacing logic.
|
// copied from SliderBar so we can do custom spacing logic.
|
||||||
float xPosition = (ToLocalSpace(screenSpaceMousePosition).X - RangePadding) / UsableWidth;
|
float xPosition = (ToLocalSpace(screenSpaceMousePosition).X - RangePadding) / UsableWidth;
|
||||||
|
|
||||||
CurrentNumber.Value = availableDivisors.OrderBy(d => Math.Abs(getMappedPosition(d) - xPosition)).First();
|
CurrentNumber.Value = beatDivisor.ValidDivisors.Value.Presets.OrderBy(d => Math.Abs(getMappedPosition(d) - xPosition)).First();
|
||||||
OnUserChange(Current.Value);
|
OnUserChange(Current.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getMappedPosition(float divisor) => MathF.Pow((divisor - 1) / (availableDivisors.Last() - 1), 0.90f);
|
private float getMappedPosition(float divisor) => MathF.Pow((divisor - 1) / (beatDivisor.ValidDivisors.Value.Presets.Last() - 1), 0.90f);
|
||||||
|
|
||||||
private class Tick : CompositeDrawable
|
private class Tick : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Compose.Components
|
||||||
|
{
|
||||||
|
public class BeatDivisorPresetCollection
|
||||||
|
{
|
||||||
|
public BeatDivisorType Type { get; }
|
||||||
|
public IReadOnlyList<int> Presets { get; }
|
||||||
|
|
||||||
|
private BeatDivisorPresetCollection(BeatDivisorType type, IEnumerable<int> presets)
|
||||||
|
{
|
||||||
|
Type = type;
|
||||||
|
Presets = presets.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly BeatDivisorPresetCollection COMMON = new BeatDivisorPresetCollection(BeatDivisorType.Common, new[] { 1, 2, 4, 8, 16 });
|
||||||
|
|
||||||
|
public static readonly BeatDivisorPresetCollection TRIPLETS = new BeatDivisorPresetCollection(BeatDivisorType.Triplets, new[] { 1, 3, 6, 12 });
|
||||||
|
|
||||||
|
public static BeatDivisorPresetCollection Custom(int maxDivisor)
|
||||||
|
{
|
||||||
|
var presets = new List<int>();
|
||||||
|
|
||||||
|
for (int candidate = 1; candidate <= Math.Sqrt(maxDivisor); ++candidate)
|
||||||
|
{
|
||||||
|
if (maxDivisor % candidate != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
presets.Add(candidate);
|
||||||
|
presets.Add(maxDivisor / candidate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BeatDivisorPresetCollection(BeatDivisorType.Custom, presets.Distinct().OrderBy(d => d));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
osu.Game/Screens/Edit/Compose/Components/BeatDivisorType.cs
Normal file
23
osu.Game/Screens/Edit/Compose/Components/BeatDivisorType.cs
Normal file
@ -0,0 +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.
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Compose.Components
|
||||||
|
{
|
||||||
|
public enum BeatDivisorType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Most common divisors, all with denominators being powers of two.
|
||||||
|
/// </summary>
|
||||||
|
Common,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Divisors with denominators divisible by 3.
|
||||||
|
/// </summary>
|
||||||
|
Triplets,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fully arbitrary/custom beat divisors.
|
||||||
|
/// </summary>
|
||||||
|
Custom,
|
||||||
|
}
|
||||||
|
}
|
@ -31,7 +31,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; }
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
private static readonly int highest_divisor = BindableBeatDivisor.VALID_DIVISORS.Last();
|
private static readonly int highest_divisor = BindableBeatDivisor.PREDEFINED_DIVISORS.Last();
|
||||||
|
|
||||||
public TimelineTickDisplay()
|
public TimelineTickDisplay()
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
performanceCache.CalculatePerformanceAsync(score, cancellationTokenSource.Token)
|
performanceCache.CalculatePerformanceAsync(score, cancellationTokenSource.Token)
|
||||||
.ContinueWith(t => Schedule(() => setPerformanceValue(t.GetResultSafely().Total)), cancellationTokenSource.Token);
|
.ContinueWith(t => Schedule(() => setPerformanceValue(t.GetResultSafely()?.Total)), cancellationTokenSource.Token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
27
osu.Game/Screens/Ranking/Statistics/AverageHitError.cs
Normal file
27
osu.Game/Screens/Ranking/Statistics/AverageHitError.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// 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 osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Ranking.Statistics
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Displays the unstable rate statistic for a given play.
|
||||||
|
/// </summary>
|
||||||
|
public class AverageHitError : SimpleStatisticItem<double?>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates and computes an <see cref="AverageHitError"/> statistic.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hitEvents">Sequence of <see cref="HitEvent"/>s to calculate the unstable rate based on.</param>
|
||||||
|
public AverageHitError(IEnumerable<HitEvent> hitEvents)
|
||||||
|
: base("Average Hit Error")
|
||||||
|
{
|
||||||
|
Value = hitEvents.CalculateAverageHitError();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string DisplayValue(double? value) => value == null ? "(not available)" : $"{Math.Abs(value.Value):N2} ms {(value.Value < 0 ? "early" : "late")}";
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,8 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- Generated via osu.Framework.iOS/generate-symbol-strip-flags.sh -->
|
<!-- Generated via osu.Framework.iOS/generate-symbol-strip-flags.sh -->
|
||||||
<GeneratedMtouchSymbolStripFlags>--nosymbolstrip=BASS_FX_BPM_BeatCallbackReset --nosymbolstrip=BASS_FX_BPM_BeatCallbackSet --nosymbolstrip=BASS_FX_BPM_BeatDecodeGet --nosymbolstrip=BASS_FX_BPM_BeatFree --nosymbolstrip=BASS_FX_BPM_BeatGetParameters --nosymbolstrip=BASS_FX_BPM_BeatSetParameters --nosymbolstrip=BASS_FX_BPM_CallbackReset --nosymbolstrip=BASS_FX_BPM_CallbackSet --nosymbolstrip=BASS_FX_BPM_DecodeGet --nosymbolstrip=BASS_FX_BPM_Free --nosymbolstrip=BASS_FX_BPM_Translate --nosymbolstrip=BASS_FX_GetVersion --nosymbolstrip=BASS_FX_ReverseCreate --nosymbolstrip=BASS_FX_ReverseGetSource --nosymbolstrip=BASS_FX_TempoCreate --nosymbolstrip=BASS_FX_TempoGetRateRatio --nosymbolstrip=BASS_FX_TempoGetSource --nosymbolstrip=BASS_Mixer_ChannelFlags --nosymbolstrip=BASS_Mixer_ChannelGetData --nosymbolstrip=BASS_Mixer_ChannelGetEnvelopePos --nosymbolstrip=BASS_Mixer_ChannelGetLevel --nosymbolstrip=BASS_Mixer_ChannelGetLevelEx --nosymbolstrip=BASS_Mixer_ChannelGetMatrix --nosymbolstrip=BASS_Mixer_ChannelGetMixer --nosymbolstrip=BASS_Mixer_ChannelGetPosition --nosymbolstrip=BASS_Mixer_ChannelGetPositionEx --nosymbolstrip=BASS_Mixer_ChannelIsActive --nosymbolstrip=BASS_Mixer_ChannelRemove --nosymbolstrip=BASS_Mixer_ChannelRemoveSync --nosymbolstrip=BASS_Mixer_ChannelSetEnvelope --nosymbolstrip=BASS_Mixer_ChannelSetEnvelopePos --nosymbolstrip=BASS_Mixer_ChannelSetMatrix --nosymbolstrip=BASS_Mixer_ChannelSetMatrixEx --nosymbolstrip=BASS_Mixer_ChannelSetPosition --nosymbolstrip=BASS_Mixer_ChannelSetSync --nosymbolstrip=BASS_Mixer_GetVersion --nosymbolstrip=BASS_Mixer_StreamAddChannel --nosymbolstrip=BASS_Mixer_StreamAddChannelEx --nosymbolstrip=BASS_Mixer_StreamCreate --nosymbolstrip=BASS_Mixer_StreamGetChannels --nosymbolstrip=BASS_Split_StreamCreate --nosymbolstrip=BASS_Split_StreamGetAvailable --nosymbolstrip=BASS_Split_StreamGetSource --nosymbolstrip=BASS_Split_StreamGetSplits --nosymbolstrip=BASS_Split_StreamReset --nosymbolstrip=BASS_Split_StreamResetEx</GeneratedMtouchSymbolStripFlags>
|
<GeneratedMtouchSymbolStripFlags>--nosymbolstrip=BASS_FX_BPM_BeatCallbackReset --nosymbolstrip=BASS_FX_BPM_BeatCallbackSet --nosymbolstrip=BASS_FX_BPM_BeatDecodeGet --nosymbolstrip=BASS_FX_BPM_BeatFree --nosymbolstrip=BASS_FX_BPM_BeatGetParameters --nosymbolstrip=BASS_FX_BPM_BeatSetParameters --nosymbolstrip=BASS_FX_BPM_CallbackReset --nosymbolstrip=BASS_FX_BPM_CallbackSet --nosymbolstrip=BASS_FX_BPM_DecodeGet --nosymbolstrip=BASS_FX_BPM_Free --nosymbolstrip=BASS_FX_BPM_Translate --nosymbolstrip=BASS_FX_GetVersion --nosymbolstrip=BASS_FX_ReverseCreate --nosymbolstrip=BASS_FX_ReverseGetSource --nosymbolstrip=BASS_FX_TempoCreate --nosymbolstrip=BASS_FX_TempoGetRateRatio --nosymbolstrip=BASS_FX_TempoGetSource --nosymbolstrip=BASS_Mixer_ChannelFlags --nosymbolstrip=BASS_Mixer_ChannelGetData --nosymbolstrip=BASS_Mixer_ChannelGetEnvelopePos --nosymbolstrip=BASS_Mixer_ChannelGetLevel --nosymbolstrip=BASS_Mixer_ChannelGetLevelEx --nosymbolstrip=BASS_Mixer_ChannelGetMatrix --nosymbolstrip=BASS_Mixer_ChannelGetMixer --nosymbolstrip=BASS_Mixer_ChannelGetPosition --nosymbolstrip=BASS_Mixer_ChannelGetPositionEx --nosymbolstrip=BASS_Mixer_ChannelIsActive --nosymbolstrip=BASS_Mixer_ChannelRemove --nosymbolstrip=BASS_Mixer_ChannelRemoveSync --nosymbolstrip=BASS_Mixer_ChannelSetEnvelope --nosymbolstrip=BASS_Mixer_ChannelSetEnvelopePos --nosymbolstrip=BASS_Mixer_ChannelSetMatrix --nosymbolstrip=BASS_Mixer_ChannelSetMatrixEx --nosymbolstrip=BASS_Mixer_ChannelSetPosition --nosymbolstrip=BASS_Mixer_ChannelSetSync --nosymbolstrip=BASS_Mixer_GetVersion --nosymbolstrip=BASS_Mixer_StreamAddChannel --nosymbolstrip=BASS_Mixer_StreamAddChannelEx --nosymbolstrip=BASS_Mixer_StreamCreate --nosymbolstrip=BASS_Mixer_StreamGetChannels --nosymbolstrip=BASS_Split_StreamCreate --nosymbolstrip=BASS_Split_StreamGetAvailable --nosymbolstrip=BASS_Split_StreamGetSource --nosymbolstrip=BASS_Split_StreamGetSplits --nosymbolstrip=BASS_Split_StreamReset --nosymbolstrip=BASS_Split_StreamResetEx</GeneratedMtouchSymbolStripFlags>
|
||||||
<MtouchExtraArgs>--nolinkaway $(GeneratedMtouchSymbolStripFlags)</MtouchExtraArgs>
|
<!-- Disable mono-cil-strip (nostrip) to avoid random attributes potentially stripped out from certain members. -->
|
||||||
|
<MtouchExtraArgs>--nolinkaway --nostrip $(GeneratedMtouchSymbolStripFlags)</MtouchExtraArgs>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
|
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
Reference in New Issue
Block a user