mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 21:02:54 +08:00
Merge branch 'master' into mania-bonus-refactor
This commit is contained in:
commit
d2a3f14d5b
@ -7,7 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.8" />
|
<PackageReference Include="BenchmarkDotNet" Version="0.13.9" />
|
||||||
<PackageReference Include="nunit" Version="3.13.3" />
|
<PackageReference Include="nunit" Version="3.13.3" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
|
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// 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 osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Catch.Beatmaps;
|
using osu.Game.Rulesets.Catch.Beatmaps;
|
||||||
@ -16,5 +17,13 @@ namespace osu.Game.Rulesets.Catch.Mods
|
|||||||
var catchProcessor = (CatchBeatmapProcessor)beatmapProcessor;
|
var catchProcessor = (CatchBeatmapProcessor)beatmapProcessor;
|
||||||
catchProcessor.HardRockOffsets = true;
|
catchProcessor.HardRockOffsets = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void ApplyToDifficulty(BeatmapDifficulty difficulty)
|
||||||
|
{
|
||||||
|
base.ApplyToDifficulty(difficulty);
|
||||||
|
|
||||||
|
difficulty.CircleSize = Math.Min(difficulty.CircleSize * 1.3f, 10.0f); // CS uses a custom 1.3 ratio.
|
||||||
|
difficulty.ApproachRate = Math.Min(difficulty.ApproachRate * ADJUST_RATIO, 10.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
111
osu.Game.Rulesets.Osu.Tests/SpinFramesGenerator.cs
Normal file
111
osu.Game.Rulesets.Osu.Tests/SpinFramesGenerator.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
// 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.Osu.Replays;
|
||||||
|
using osu.Game.Rulesets.Replays;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
|
{
|
||||||
|
public class SpinFramesGenerator
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A small amount to spin beyond a given angle to mitigate floating-point precision errors.
|
||||||
|
/// </summary>
|
||||||
|
public const float SPIN_ERROR = MathF.PI / 8;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The offset from the centre of the spinner at which to spin.
|
||||||
|
/// </summary>
|
||||||
|
private const float centre_spin_offset = 50;
|
||||||
|
|
||||||
|
private readonly double startTime;
|
||||||
|
private readonly float startAngle;
|
||||||
|
private readonly List<(float deltaAngle, double duration)> sequences = new List<(float deltaAngle, double duration)>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new <see cref="SpinFramesGenerator"/> that can be used to generate spinner spin frames.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="startTime">The time at which to start spinning.</param>
|
||||||
|
/// <param name="startAngle">The angle, in radians, at which to start spinning from. Defaults to the positive-y-axis.</param>
|
||||||
|
public SpinFramesGenerator(double startTime, float startAngle = -MathF.PI / 2f)
|
||||||
|
{
|
||||||
|
this.startTime = startTime;
|
||||||
|
this.startAngle = startAngle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs a single spin.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="delta">The amount of degrees to spin.</param>
|
||||||
|
/// <param name="duration">The time to spend to perform the spin.</param>
|
||||||
|
/// <returns>This <see cref="SpinFramesGenerator"/>.</returns>
|
||||||
|
public SpinFramesGenerator Spin(float delta, double duration)
|
||||||
|
{
|
||||||
|
sequences.Add((delta / 360 * 2 * MathF.PI, duration));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs the replay frames.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The replay frames.</returns>
|
||||||
|
public List<ReplayFrame> Build()
|
||||||
|
{
|
||||||
|
List<ReplayFrame> frames = new List<ReplayFrame>();
|
||||||
|
|
||||||
|
double lastTime = startTime;
|
||||||
|
float lastAngle = startAngle;
|
||||||
|
int lastDirection = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < sequences.Count; i++)
|
||||||
|
{
|
||||||
|
var seq = sequences[i];
|
||||||
|
|
||||||
|
int seqDirection = Math.Sign(seq.deltaAngle);
|
||||||
|
float seqError = SPIN_ERROR * seqDirection;
|
||||||
|
|
||||||
|
if (seqDirection == lastDirection)
|
||||||
|
{
|
||||||
|
// Spinning in the same direction, but the error was already added in the last rotation.
|
||||||
|
seqError = 0;
|
||||||
|
}
|
||||||
|
else if (lastDirection != 0)
|
||||||
|
{
|
||||||
|
// Spinning in a different direction, we need to account for the error of the start angle, so double it.
|
||||||
|
seqError *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
double seqStartTime = lastTime;
|
||||||
|
double seqEndTime = lastTime + seq.duration;
|
||||||
|
float seqStartAngle = lastAngle;
|
||||||
|
float seqEndAngle = seqStartAngle + seq.deltaAngle + seqError;
|
||||||
|
|
||||||
|
// Intermediate spin frames.
|
||||||
|
for (; lastTime < seqEndTime; lastTime += 10)
|
||||||
|
frames.Add(new OsuReplayFrame(lastTime, calcOffsetAt((lastTime - seqStartTime) / (seqEndTime - seqStartTime), seqStartAngle, seqEndAngle), OsuAction.LeftButton));
|
||||||
|
|
||||||
|
// Final frame at the end of the current spin.
|
||||||
|
frames.Add(new OsuReplayFrame(seqEndTime, calcOffsetAt(1, seqStartAngle, seqEndAngle), OsuAction.LeftButton));
|
||||||
|
|
||||||
|
lastTime = seqEndTime;
|
||||||
|
lastAngle = seqEndAngle;
|
||||||
|
lastDirection = seqDirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Key release frame.
|
||||||
|
if (frames.Count > 0)
|
||||||
|
frames.Add(new OsuReplayFrame(frames[^1].Time, ((OsuReplayFrame)frames[^1]).Position));
|
||||||
|
|
||||||
|
return frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Vector2 calcOffsetAt(double p, float startAngle, float endAngle)
|
||||||
|
{
|
||||||
|
float angle = startAngle + (endAngle - startAngle) * (float)p;
|
||||||
|
return new Vector2(256, 192) + centre_spin_offset * new Vector2(MathF.Cos(angle), MathF.Sin(angle));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -356,15 +356,16 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
performTest(hitObjects, new List<ReplayFrame>
|
List<ReplayFrame> frames = new List<ReplayFrame>
|
||||||
{
|
{
|
||||||
new OsuReplayFrame { Time = time_spinner - 90, 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 } },
|
frames.AddRange(new SpinFramesGenerator(time_spinner + 10)
|
||||||
new OsuReplayFrame { Time = time_spinner + 40, Position = new Vector2(256, 212), Actions = { OsuAction.RightButton } },
|
.Spin(360, 500)
|
||||||
new OsuReplayFrame { Time = time_spinner + 50, Position = new Vector2(236, 192), Actions = { OsuAction.RightButton } },
|
.Build());
|
||||||
});
|
|
||||||
|
performTest(hitObjects, frames);
|
||||||
|
|
||||||
addJudgementAssert(hitObjects[0], HitResult.Great);
|
addJudgementAssert(hitObjects[0], HitResult.Great);
|
||||||
addJudgementAssert(hitObjects[1], HitResult.Meh);
|
addJudgementAssert(hitObjects[1], HitResult.Meh);
|
||||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddStep("rotate some", () => dho.RotationTracker.AddRotation(180));
|
AddStep("rotate some", () => dho.RotationTracker.AddRotation(180));
|
||||||
AddAssert("rotation is set", () => dho.Result.RateAdjustedRotation == 180);
|
AddAssert("rotation is set", () => dho.Result.TotalRotation == 180);
|
||||||
|
|
||||||
AddStep("apply new spinner", () => dho.Apply(prepareObject(new Spinner
|
AddStep("apply new spinner", () => dho.Apply(prepareObject(new Spinner
|
||||||
{
|
{
|
||||||
@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
Duration = 1000,
|
Duration = 1000,
|
||||||
})));
|
})));
|
||||||
|
|
||||||
AddAssert("rotation is reset", () => dho.Result.RateAdjustedRotation == 0);
|
AddAssert("rotation is reset", () => dho.Result.TotalRotation == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Spinner prepareObject(Spinner circle)
|
private Spinner prepareObject(Spinner circle)
|
||||||
|
290
osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerInput.cs
Normal file
290
osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerInput.cs
Normal file
@ -0,0 +1,290 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Screens;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Replays;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Osu.Replays;
|
||||||
|
using osu.Game.Rulesets.Replays;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Storyboards;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
|
{
|
||||||
|
public partial class TestSceneSpinnerInput : RateAdjustedBeatmapTestScene
|
||||||
|
{
|
||||||
|
private const int centre_x = 256;
|
||||||
|
private const int centre_y = 192;
|
||||||
|
private const double time_spinner_start = 1500;
|
||||||
|
private const double time_spinner_end = 8000;
|
||||||
|
|
||||||
|
private readonly List<JudgementResult> judgementResults = new List<JudgementResult>();
|
||||||
|
|
||||||
|
private ScoreAccessibleReplayPlayer currentPlayer = null!;
|
||||||
|
private ManualClock? manualClock;
|
||||||
|
|
||||||
|
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard? storyboard = null)
|
||||||
|
{
|
||||||
|
return manualClock == null
|
||||||
|
? base.CreateWorkingBeatmap(beatmap, storyboard)
|
||||||
|
: new ClockBackedTestWorkingBeatmap(beatmap, storyboard, new FramedClock(manualClock), Audio);
|
||||||
|
}
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup() => Schedule(() =>
|
||||||
|
{
|
||||||
|
manualClock = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// While off-centre, vibrates backwards and forwards on the x-axis, from centre-50 to centre+50, every 50ms.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
[Ignore("An upcoming implementation will fix this case")]
|
||||||
|
public void TestVibrateWithoutSpinningOffCentre()
|
||||||
|
{
|
||||||
|
List<ReplayFrame> frames = new List<ReplayFrame>();
|
||||||
|
|
||||||
|
const int vibrate_time = 50;
|
||||||
|
const float y_pos = centre_y - 50;
|
||||||
|
|
||||||
|
int direction = -1;
|
||||||
|
|
||||||
|
for (double i = time_spinner_start; i <= time_spinner_end; i += vibrate_time)
|
||||||
|
{
|
||||||
|
frames.Add(new OsuReplayFrame(i, new Vector2(centre_x + direction * 50, y_pos), OsuAction.LeftButton));
|
||||||
|
frames.Add(new OsuReplayFrame(i + vibrate_time, new Vector2(centre_x - direction * 50, y_pos), OsuAction.LeftButton));
|
||||||
|
|
||||||
|
direction *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
performTest(frames);
|
||||||
|
|
||||||
|
assertTicksHit(0);
|
||||||
|
assertSpinnerHit(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// While centred on the slider, vibrates backwards and forwards on the x-axis, from centre-50 to centre+50, every 50ms.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
[Ignore("An upcoming implementation will fix this case")]
|
||||||
|
public void TestVibrateWithoutSpinningOnCentre()
|
||||||
|
{
|
||||||
|
List<ReplayFrame> frames = new List<ReplayFrame>();
|
||||||
|
|
||||||
|
const int vibrate_time = 50;
|
||||||
|
|
||||||
|
int direction = -1;
|
||||||
|
|
||||||
|
for (double i = time_spinner_start; i <= time_spinner_end; i += vibrate_time)
|
||||||
|
{
|
||||||
|
frames.Add(new OsuReplayFrame(i, new Vector2(centre_x + direction * 50, centre_y), OsuAction.LeftButton));
|
||||||
|
frames.Add(new OsuReplayFrame(i + vibrate_time, new Vector2(centre_x - direction * 50, centre_y), OsuAction.LeftButton));
|
||||||
|
|
||||||
|
direction *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
performTest(frames);
|
||||||
|
|
||||||
|
assertTicksHit(0);
|
||||||
|
assertSpinnerHit(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Spins in a single direction.
|
||||||
|
/// </summary>
|
||||||
|
[TestCase(180, 0)]
|
||||||
|
[TestCase(-180, 0)]
|
||||||
|
[TestCase(360, 1)]
|
||||||
|
[TestCase(-360, 1)]
|
||||||
|
[TestCase(540, 1)]
|
||||||
|
[TestCase(-540, 1)]
|
||||||
|
[TestCase(720, 2)]
|
||||||
|
[TestCase(-720, 2)]
|
||||||
|
public void TestSpinSingleDirection(float amount, int expectedTicks)
|
||||||
|
{
|
||||||
|
performTest(new SpinFramesGenerator(time_spinner_start)
|
||||||
|
.Spin(amount, 500)
|
||||||
|
.Build());
|
||||||
|
|
||||||
|
assertTicksHit(expectedTicks);
|
||||||
|
assertSpinnerHit(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Spin half-way clockwise then perform one full spin counter-clockwise.
|
||||||
|
/// No ticks should be hit since the total rotation is -0.5 (0.5 CW + 1 CCW = 0.5 CCW).
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
[Ignore("An upcoming implementation will fix this case")]
|
||||||
|
public void TestSpinHalfBothDirections()
|
||||||
|
{
|
||||||
|
performTest(new SpinFramesGenerator(time_spinner_start)
|
||||||
|
.Spin(180, 500) // Rotate to +0.5.
|
||||||
|
.Spin(-360, 500) // Rotate to -0.5
|
||||||
|
.Build());
|
||||||
|
|
||||||
|
assertTicksHit(0);
|
||||||
|
assertSpinnerHit(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Spin in one direction then spin in the other.
|
||||||
|
/// </summary>
|
||||||
|
[TestCase(180, -540, 1)]
|
||||||
|
[TestCase(-180, 540, 1)]
|
||||||
|
[TestCase(180, -900, 2)]
|
||||||
|
[TestCase(-180, 900, 2)]
|
||||||
|
[Ignore("An upcoming implementation will fix this case")]
|
||||||
|
public void TestSpinOneDirectionThenChangeDirection(float direction1, float direction2, int expectedTicks)
|
||||||
|
{
|
||||||
|
performTest(new SpinFramesGenerator(time_spinner_start)
|
||||||
|
.Spin(direction1, 500)
|
||||||
|
.Spin(direction2, 500)
|
||||||
|
.Build());
|
||||||
|
|
||||||
|
assertTicksHit(expectedTicks);
|
||||||
|
assertSpinnerHit(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[Ignore("An upcoming implementation will fix this case")]
|
||||||
|
public void TestRewind()
|
||||||
|
{
|
||||||
|
AddStep("set manual clock", () => manualClock = new ManualClock { Rate = 1 });
|
||||||
|
|
||||||
|
List<ReplayFrame> frames = new SpinFramesGenerator(time_spinner_start)
|
||||||
|
.Spin(360, 500) // 2000ms -> 1 full CW spin
|
||||||
|
.Spin(-180, 500) // 2500ms -> 0.5 CCW spins
|
||||||
|
.Spin(90, 500) // 3000ms -> 0.25 CW spins
|
||||||
|
.Spin(450, 500) // 3500ms -> 1 full CW spin
|
||||||
|
.Spin(180, 500) // 4000ms -> 0.5 CW spins
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
loadPlayer(frames);
|
||||||
|
|
||||||
|
GameplayClockContainer clock = null!;
|
||||||
|
DrawableRuleset drawableRuleset = null!;
|
||||||
|
AddStep("get gameplay objects", () =>
|
||||||
|
{
|
||||||
|
clock = currentPlayer.ChildrenOfType<GameplayClockContainer>().Single();
|
||||||
|
drawableRuleset = currentPlayer.ChildrenOfType<DrawableRuleset>().Single();
|
||||||
|
});
|
||||||
|
|
||||||
|
addSeekStep(frames.Last().Time);
|
||||||
|
|
||||||
|
DrawableSpinner drawableSpinner = null!;
|
||||||
|
AddUntilStep("get spinner", () => (drawableSpinner = currentPlayer.ChildrenOfType<DrawableSpinner>().Single()) != null);
|
||||||
|
|
||||||
|
assertTotalRotation(4000, 900);
|
||||||
|
assertTotalRotation(3750, 810);
|
||||||
|
assertTotalRotation(3500, 720);
|
||||||
|
assertTotalRotation(3250, 530);
|
||||||
|
assertTotalRotation(3000, 540);
|
||||||
|
assertTotalRotation(2750, 540);
|
||||||
|
assertTotalRotation(2500, 540);
|
||||||
|
assertTotalRotation(2250, 360);
|
||||||
|
assertTotalRotation(2000, 180);
|
||||||
|
assertTotalRotation(1500, 0);
|
||||||
|
|
||||||
|
void assertTotalRotation(double time, float expected)
|
||||||
|
{
|
||||||
|
addSeekStep(time);
|
||||||
|
AddAssert($"total rotation @ {time} is {expected}", () => drawableSpinner.Result.TotalRotation,
|
||||||
|
() => Is.EqualTo(expected).Within(MathHelper.RadiansToDegrees(SpinFramesGenerator.SPIN_ERROR * 2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void addSeekStep(double time)
|
||||||
|
{
|
||||||
|
AddStep($"seek to {time}", () => clock.Seek(time));
|
||||||
|
AddUntilStep("wait for seek to finish", () => drawableRuleset.FrameStableClock.CurrentTime, () => Is.EqualTo(time));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertTicksHit(int count)
|
||||||
|
{
|
||||||
|
AddAssert($"{count} ticks hit", () => judgementResults.Where(r => r.HitObject is SpinnerTick).Count(r => r.IsHit), () => Is.EqualTo(count));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertSpinnerHit(bool shouldBeHit)
|
||||||
|
{
|
||||||
|
AddAssert($"spinner is {(shouldBeHit ? "hit" : "missed")}", () => judgementResults.Single(r => r.HitObject is Spinner).IsHit, () => Is.EqualTo(shouldBeHit));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadPlayer(List<ReplayFrame> frames)
|
||||||
|
{
|
||||||
|
AddStep("load player", () =>
|
||||||
|
{
|
||||||
|
Beatmap.Value = CreateWorkingBeatmap(new Beatmap<OsuHitObject>
|
||||||
|
{
|
||||||
|
HitObjects =
|
||||||
|
{
|
||||||
|
new Spinner
|
||||||
|
{
|
||||||
|
StartTime = time_spinner_start,
|
||||||
|
EndTime = time_spinner_end,
|
||||||
|
Position = new Vector2(centre_x, centre_y)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
BeatmapInfo =
|
||||||
|
{
|
||||||
|
Difficulty = new BeatmapDifficulty(),
|
||||||
|
Ruleset = new OsuRuleset().RulesetInfo
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } });
|
||||||
|
|
||||||
|
p.OnLoadComplete += _ =>
|
||||||
|
{
|
||||||
|
p.ScoreProcessor.NewJudgement += result =>
|
||||||
|
{
|
||||||
|
if (currentPlayer == p) judgementResults.Add(result);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
LoadScreen(currentPlayer = p);
|
||||||
|
judgementResults.Clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("Beatmap at 0", () => Beatmap.Value.Track.CurrentTime == 0);
|
||||||
|
AddUntilStep("Wait until player is loaded", () => currentPlayer.IsCurrentScreen());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performTest(List<ReplayFrame> frames)
|
||||||
|
{
|
||||||
|
loadPlayer(frames);
|
||||||
|
AddUntilStep("Wait for completion", () => currentPlayer.ScoreProcessor.HasCompleted.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private partial class ScoreAccessibleReplayPlayer : ReplayPlayer
|
||||||
|
{
|
||||||
|
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
|
||||||
|
|
||||||
|
protected override bool PauseOnFocusLost => false;
|
||||||
|
|
||||||
|
public ScoreAccessibleReplayPlayer(Score score)
|
||||||
|
: base(score, new PlayerConfiguration
|
||||||
|
{
|
||||||
|
AllowPause = false,
|
||||||
|
ShowResults = false,
|
||||||
|
})
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
// 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.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
@ -11,14 +10,12 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Replays;
|
using osu.Game.Replays;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Replays;
|
|
||||||
using osu.Game.Rulesets.Osu.UI;
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
using osu.Game.Rulesets.Replays;
|
using osu.Game.Rulesets.Replays;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Tests
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
{
|
{
|
||||||
@ -59,26 +56,9 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
AddAssert("all max judgements", () => judgementResults.All(result => result.Type == result.Judgement.MaxResult));
|
AddAssert("all max judgements", () => judgementResults.All(result => result.Type == result.Judgement.MaxResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<ReplayFrame> generateReplay(int spins)
|
private static List<ReplayFrame> generateReplay(int spins) => new SpinFramesGenerator(time_spinner_start)
|
||||||
{
|
.Spin(spins * 360, time_spinner_end - time_spinner_start)
|
||||||
var replayFrames = new List<ReplayFrame>();
|
.Build();
|
||||||
|
|
||||||
const int frames_per_spin = 30;
|
|
||||||
|
|
||||||
for (int i = 0; i < spins * frames_per_spin; ++i)
|
|
||||||
{
|
|
||||||
float totalProgress = i / (float)(spins * frames_per_spin);
|
|
||||||
float spinProgress = (i % frames_per_spin) / (float)frames_per_spin;
|
|
||||||
double time = time_spinner_start + (time_spinner_end - time_spinner_start) * totalProgress;
|
|
||||||
float posX = MathF.Cos(2 * MathF.PI * spinProgress);
|
|
||||||
float posY = MathF.Sin(2 * MathF.PI * spinProgress);
|
|
||||||
Vector2 finalPos = OsuPlayfield.BASE_SIZE / 2 + new Vector2(posX, posY) * 50;
|
|
||||||
|
|
||||||
replayFrames.Add(new OsuReplayFrame(time, finalPos, OsuAction.LeftButton));
|
|
||||||
}
|
|
||||||
|
|
||||||
return replayFrames;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void performTest(List<ReplayFrame> frames)
|
private void performTest(List<ReplayFrame> frames)
|
||||||
{
|
{
|
||||||
|
@ -63,11 +63,11 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
trackerRotationTolerance = Math.Abs(drawableSpinner.RotationTracker.Rotation * 0.1f);
|
trackerRotationTolerance = Math.Abs(drawableSpinner.RotationTracker.Rotation * 0.1f);
|
||||||
});
|
});
|
||||||
AddAssert("is disc rotation not almost 0", () => drawableSpinner.RotationTracker.Rotation, () => Is.Not.EqualTo(0).Within(100));
|
AddAssert("is disc rotation not almost 0", () => drawableSpinner.RotationTracker.Rotation, () => Is.Not.EqualTo(0).Within(100));
|
||||||
AddAssert("is disc rotation absolute not almost 0", () => drawableSpinner.Result.RateAdjustedRotation, () => Is.Not.EqualTo(0).Within(100));
|
AddAssert("is disc rotation absolute not almost 0", () => drawableSpinner.Result.TotalRotation, () => Is.Not.EqualTo(0).Within(100));
|
||||||
|
|
||||||
addSeekStep(0);
|
addSeekStep(0);
|
||||||
AddAssert("is disc rotation almost 0", () => drawableSpinner.RotationTracker.Rotation, () => Is.EqualTo(0).Within(trackerRotationTolerance));
|
AddAssert("is disc rotation almost 0", () => drawableSpinner.RotationTracker.Rotation, () => Is.EqualTo(0).Within(trackerRotationTolerance));
|
||||||
AddAssert("is disc rotation absolute almost 0", () => drawableSpinner.Result.RateAdjustedRotation, () => Is.EqualTo(0).Within(100));
|
AddAssert("is disc rotation absolute almost 0", () => drawableSpinner.Result.TotalRotation, () => Is.EqualTo(0).Within(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -82,7 +82,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
finalTrackerRotation = drawableSpinner.RotationTracker.Rotation;
|
finalTrackerRotation = drawableSpinner.RotationTracker.Rotation;
|
||||||
trackerRotationTolerance = Math.Abs(finalTrackerRotation * 0.05f);
|
trackerRotationTolerance = Math.Abs(finalTrackerRotation * 0.05f);
|
||||||
});
|
});
|
||||||
AddStep("retrieve cumulative disc rotation", () => finalCumulativeTrackerRotation = drawableSpinner.Result.RateAdjustedRotation);
|
AddStep("retrieve cumulative disc rotation", () => finalCumulativeTrackerRotation = drawableSpinner.Result.TotalRotation);
|
||||||
|
|
||||||
addSeekStep(spinner_start_time + 2500);
|
addSeekStep(spinner_start_time + 2500);
|
||||||
AddAssert("disc rotation rewound",
|
AddAssert("disc rotation rewound",
|
||||||
@ -92,13 +92,13 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
() => drawableSpinner.RotationTracker.Rotation, () => Is.EqualTo(finalTrackerRotation / 2).Within(trackerRotationTolerance));
|
() => drawableSpinner.RotationTracker.Rotation, () => Is.EqualTo(finalTrackerRotation / 2).Within(trackerRotationTolerance));
|
||||||
AddAssert("is cumulative rotation rewound",
|
AddAssert("is cumulative rotation rewound",
|
||||||
// cumulative rotation is not damped, so we're treating it as the "ground truth" and allowing a comparatively smaller margin of error.
|
// cumulative rotation is not damped, so we're treating it as the "ground truth" and allowing a comparatively smaller margin of error.
|
||||||
() => drawableSpinner.Result.RateAdjustedRotation, () => Is.EqualTo(finalCumulativeTrackerRotation / 2).Within(100));
|
() => drawableSpinner.Result.TotalRotation, () => Is.EqualTo(finalCumulativeTrackerRotation / 2).Within(100));
|
||||||
|
|
||||||
addSeekStep(spinner_start_time + 5000);
|
addSeekStep(spinner_start_time + 5000);
|
||||||
AddAssert("is disc rotation almost same",
|
AddAssert("is disc rotation almost same",
|
||||||
() => drawableSpinner.RotationTracker.Rotation, () => Is.EqualTo(finalTrackerRotation).Within(trackerRotationTolerance));
|
() => drawableSpinner.RotationTracker.Rotation, () => Is.EqualTo(finalTrackerRotation).Within(trackerRotationTolerance));
|
||||||
AddAssert("is cumulative rotation almost same",
|
AddAssert("is cumulative rotation almost same",
|
||||||
() => drawableSpinner.Result.RateAdjustedRotation, () => Is.EqualTo(finalCumulativeTrackerRotation).Within(100));
|
() => drawableSpinner.Result.TotalRotation, () => Is.EqualTo(finalCumulativeTrackerRotation).Within(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -135,7 +135,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
// multipled by 2 to nullify the score multiplier. (autoplay mod selected)
|
// multipled by 2 to nullify the score multiplier. (autoplay mod selected)
|
||||||
long totalScore = ((ScoreExposedPlayer)Player).ScoreProcessor.TotalScore.Value * 2;
|
long totalScore = ((ScoreExposedPlayer)Player).ScoreProcessor.TotalScore.Value * 2;
|
||||||
return totalScore == (int)(drawableSpinner.Result.RateAdjustedRotation / 360) * new SpinnerTick().CreateJudgement().MaxNumericResult;
|
return totalScore == (int)(drawableSpinner.Result.TotalRotation / 360) * new SpinnerTick().CreateJudgement().MaxNumericResult;
|
||||||
});
|
});
|
||||||
|
|
||||||
addSeekStep(0);
|
addSeekStep(0);
|
||||||
|
@ -284,15 +284,16 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
performTest(hitObjects, new List<ReplayFrame>
|
List<ReplayFrame> frames = new List<ReplayFrame>
|
||||||
{
|
{
|
||||||
new OsuReplayFrame { Time = time_spinner - 100, Position = positionCircle, Actions = { OsuAction.LeftButton } },
|
new OsuReplayFrame { Time = time_spinner - 100, 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 } },
|
frames.AddRange(new SpinFramesGenerator(time_spinner + 10)
|
||||||
new OsuReplayFrame { Time = time_spinner + 40, Position = new Vector2(256, 212), Actions = { OsuAction.RightButton } },
|
.Spin(360, 500)
|
||||||
new OsuReplayFrame { Time = time_spinner + 50, Position = new Vector2(236, 192), Actions = { OsuAction.RightButton } },
|
.Build());
|
||||||
});
|
|
||||||
|
performTest(hitObjects, frames);
|
||||||
|
|
||||||
addJudgementAssert(hitObjects[0], HitResult.Great);
|
addJudgementAssert(hitObjects[0], HitResult.Great);
|
||||||
addJudgementAssert(hitObjects[1], HitResult.Great);
|
addJudgementAssert(hitObjects[1], HitResult.Great);
|
||||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Osu.Judgements
|
|||||||
/// If Double Time is active instead (with a speed multiplier of 1.5x),
|
/// If Double Time is active instead (with a speed multiplier of 1.5x),
|
||||||
/// in the same scenario the property will return 720 * 1.5 = 1080.
|
/// in the same scenario the property will return 720 * 1.5 = 1080.
|
||||||
/// </example>
|
/// </example>
|
||||||
public float RateAdjustedRotation;
|
public float TotalRotation;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Time instant at which the spin was started (the first user input which caused an increase in spin).
|
/// Time instant at which the spin was started (the first user input which caused an increase in spin).
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
@ -22,5 +23,13 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
OsuHitObjectGenerationUtils.ReflectVerticallyAlongPlayfield(osuObject);
|
OsuHitObjectGenerationUtils.ReflectVerticallyAlongPlayfield(osuObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void ApplyToDifficulty(BeatmapDifficulty difficulty)
|
||||||
|
{
|
||||||
|
base.ApplyToDifficulty(difficulty);
|
||||||
|
|
||||||
|
difficulty.CircleSize = Math.Min(difficulty.CircleSize * 1.3f, 10.0f); // CS uses a custom 1.3 ratio.
|
||||||
|
difficulty.ApproachRate = Math.Min(difficulty.ApproachRate * ADJUST_RATIO, 10.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
// these become implicitly hit.
|
// these become implicitly hit.
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return Math.Clamp(Result.RateAdjustedRotation / 360 / HitObject.SpinsRequired, 0, 1);
|
return Math.Clamp(Result.TotalRotation / 360 / HitObject.SpinsRequired, 0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
// don't update after end time to avoid the rate display dropping during fade out.
|
// don't update after end time to avoid the rate display dropping during fade out.
|
||||||
// this shouldn't be limited to StartTime as it causes weirdness with the underlying calculation, which is expecting updates during that period.
|
// this shouldn't be limited to StartTime as it causes weirdness with the underlying calculation, which is expecting updates during that period.
|
||||||
if (Time.Current <= HitObject.EndTime)
|
if (Time.Current <= HitObject.EndTime)
|
||||||
spmCalculator.SetRotation(Result.RateAdjustedRotation);
|
spmCalculator.SetRotation(Result.TotalRotation);
|
||||||
|
|
||||||
updateBonusScore();
|
updateBonusScore();
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
if (ticks.Count == 0)
|
if (ticks.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int spins = (int)(Result.RateAdjustedRotation / 360);
|
int spins = (int)(Result.TotalRotation / 360);
|
||||||
|
|
||||||
if (spins < completedFullSpins)
|
if (spins < completedFullSpins)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
int rotations = (int)(drawableSpinner.Result.RateAdjustedRotation / 360);
|
int rotations = (int)(drawableSpinner.Result.TotalRotation / 360);
|
||||||
|
|
||||||
if (wholeRotationCount == rotations) return false;
|
if (wholeRotationCount == rotations) return false;
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
int rotations = (int)(drawableSpinner.Result.RateAdjustedRotation / 360);
|
int rotations = (int)(drawableSpinner.Result.TotalRotation / 360);
|
||||||
|
|
||||||
if (wholeRotationCount == rotations) return false;
|
if (wholeRotationCount == rotations) return false;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// 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 osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
@ -22,11 +23,10 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
|
|
||||||
private readonly DrawableSpinner drawableSpinner;
|
private readonly DrawableSpinner drawableSpinner;
|
||||||
|
|
||||||
private Vector2 mousePosition;
|
private Vector2? mousePosition;
|
||||||
|
private float? lastAngle;
|
||||||
|
|
||||||
private float lastAngle;
|
|
||||||
private float currentRotation;
|
private float currentRotation;
|
||||||
|
|
||||||
private bool rotationTransferred;
|
private bool rotationTransferred;
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
@ -63,17 +63,23 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
float thisAngle = -MathUtils.RadiansToDegrees(MathF.Atan2(mousePosition.X - DrawSize.X / 2, mousePosition.Y - DrawSize.Y / 2));
|
|
||||||
|
|
||||||
float delta = thisAngle - lastAngle;
|
if (mousePosition is Vector2 pos)
|
||||||
|
{
|
||||||
|
float thisAngle = -MathUtils.RadiansToDegrees(MathF.Atan2(pos.X - DrawSize.X / 2, pos.Y - DrawSize.Y / 2));
|
||||||
|
float delta = lastAngle == null ? 0 : thisAngle - lastAngle.Value;
|
||||||
|
|
||||||
|
// Normalise the delta to -180 .. 180
|
||||||
|
if (delta > 180) delta -= 360;
|
||||||
|
if (delta < -180) delta += 360;
|
||||||
|
|
||||||
if (Tracking)
|
if (Tracking)
|
||||||
AddRotation(delta);
|
AddRotation(delta);
|
||||||
|
|
||||||
lastAngle = thisAngle;
|
lastAngle = thisAngle;
|
||||||
|
}
|
||||||
|
|
||||||
IsSpinning.Value = isSpinnableTime && Math.Abs(currentRotation - Rotation) > 10f;
|
IsSpinning.Value = isSpinnableTime && Math.Abs(currentRotation - Rotation) > 10f;
|
||||||
|
|
||||||
Rotation = (float)Interpolation.Damp(Rotation, currentRotation, 0.99, Math.Abs(Time.Elapsed));
|
Rotation = (float)Interpolation.Damp(Rotation, currentRotation, 0.99, Math.Abs(Time.Elapsed));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,41 +89,37 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Will be a no-op if not a valid time to spin.
|
/// Will be a no-op if not a valid time to spin.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="angle">The delta angle.</param>
|
/// <param name="delta">The delta angle.</param>
|
||||||
public void AddRotation(float angle)
|
public void AddRotation(float delta)
|
||||||
{
|
{
|
||||||
if (!isSpinnableTime)
|
if (!isSpinnableTime)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!rotationTransferred)
|
if (!rotationTransferred)
|
||||||
{
|
{
|
||||||
currentRotation = Rotation * 2;
|
currentRotation = Rotation;
|
||||||
rotationTransferred = true;
|
rotationTransferred = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (angle > 180)
|
currentRotation += delta;
|
||||||
{
|
|
||||||
lastAngle += 360;
|
double rate = gameplayClock?.GetTrueGameplayRate() ?? Clock.Rate;
|
||||||
angle -= 360;
|
|
||||||
}
|
Debug.Assert(Math.Abs(delta) <= 180);
|
||||||
else if (-angle > 180)
|
|
||||||
{
|
|
||||||
lastAngle -= 360;
|
|
||||||
angle += 360;
|
|
||||||
}
|
|
||||||
|
|
||||||
currentRotation += angle;
|
|
||||||
// rate has to be applied each frame, because it's not guaranteed to be constant throughout playback
|
// rate has to be applied each frame, because it's not guaranteed to be constant throughout playback
|
||||||
// (see: ModTimeRamp)
|
// (see: ModTimeRamp)
|
||||||
drawableSpinner.Result.RateAdjustedRotation += (float)(Math.Abs(angle) * (gameplayClock?.GetTrueGameplayRate() ?? Clock.Rate));
|
drawableSpinner.Result.TotalRotation += (float)(Math.Abs(delta) * rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetState(DrawableHitObject obj)
|
private void resetState(DrawableHitObject obj)
|
||||||
{
|
{
|
||||||
Tracking = false;
|
Tracking = false;
|
||||||
IsSpinning.Value = false;
|
IsSpinning.Value = false;
|
||||||
mousePosition = default;
|
mousePosition = null;
|
||||||
lastAngle = currentRotation = Rotation = 0;
|
lastAngle = null;
|
||||||
|
currentRotation = 0;
|
||||||
|
Rotation = 0;
|
||||||
rotationTransferred = false;
|
rotationTransferred = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,10 +46,10 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
switch (osuComponent.Component)
|
switch (osuComponent.Component)
|
||||||
{
|
{
|
||||||
case OsuSkinComponents.FollowPoint:
|
case OsuSkinComponents.FollowPoint:
|
||||||
return this.GetAnimation("followpoint", true, true, true, startAtCurrentTime: false);
|
return this.GetAnimation("followpoint", true, true, true, startAtCurrentTime: false, maxSize: new Vector2(OsuHitObject.OBJECT_RADIUS * 2, OsuHitObject.OBJECT_RADIUS));
|
||||||
|
|
||||||
case OsuSkinComponents.SliderScorePoint:
|
case OsuSkinComponents.SliderScorePoint:
|
||||||
return this.GetAnimation("sliderscorepoint", false, false);
|
return this.GetAnimation("sliderscorepoint", false, false, maxSize: OsuHitObject.OBJECT_DIMENSIONS);
|
||||||
|
|
||||||
case OsuSkinComponents.SliderFollowCircle:
|
case OsuSkinComponents.SliderFollowCircle:
|
||||||
var followCircleContent = this.GetAnimation("sliderfollowcircle", true, true, true, maxSize: MAX_FOLLOW_CIRCLE_AREA_SIZE);
|
var followCircleContent = this.GetAnimation("sliderfollowcircle", true, true, true, maxSize: MAX_FOLLOW_CIRCLE_AREA_SIZE);
|
||||||
|
@ -72,12 +72,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestStoryboardExitDuringOutroStillExits()
|
public void TestStoryboardExitDuringOutroProgressesToResults()
|
||||||
{
|
{
|
||||||
CreateTest();
|
CreateTest();
|
||||||
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
||||||
AddStep("exit via pause", () => Player.ExitViaPause());
|
AddStep("exit via pause", () => Player.ExitViaPause());
|
||||||
AddAssert("player exited", () => !Player.IsCurrentScreen() && Player.GetChildScreen() == null);
|
AddUntilStep("reached results screen", () => Stack.CurrentScreen is ResultsScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(false)]
|
[TestCase(false)]
|
||||||
@ -171,7 +171,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddStep("disable storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, false));
|
AddStep("disable storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, false));
|
||||||
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
||||||
AddStep("exit via pause", () => Player.ExitViaPause());
|
AddStep("exit via pause", () => Player.ExitViaPause());
|
||||||
AddAssert("player exited", () => Stack.CurrentScreen == null);
|
AddUntilStep("reached results screen", () => Stack.CurrentScreen is ResultsScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -215,6 +215,24 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
AddAssert("retry count is 1", () => player.RestartCount == 1);
|
AddAssert("retry count is 1", () => player.RestartCount == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRetryImmediatelyAfterCompletion()
|
||||||
|
{
|
||||||
|
var getOriginalPlayer = playToCompletion();
|
||||||
|
|
||||||
|
AddStep("attempt to retry", () => getOriginalPlayer().ChildrenOfType<HotkeyRetryOverlay>().First().Action());
|
||||||
|
AddUntilStep("wait for player", () => Game.ScreenStack.CurrentScreen != getOriginalPlayer() && Game.ScreenStack.CurrentScreen is Player);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestExitImmediatelyAfterCompletion()
|
||||||
|
{
|
||||||
|
var player = playToCompletion();
|
||||||
|
|
||||||
|
AddStep("attempt to exit", () => player().ChildrenOfType<HotkeyExitOverlay>().First().Action());
|
||||||
|
AddUntilStep("wait for results", () => Game.ScreenStack.CurrentScreen is ResultsScreen);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestRetryFromResults()
|
public void TestRetryFromResults()
|
||||||
{
|
{
|
||||||
@ -778,6 +796,13 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Func<Player> playToResults()
|
private Func<Player> playToResults()
|
||||||
|
{
|
||||||
|
var player = playToCompletion();
|
||||||
|
AddUntilStep("wait for results", () => (Game.ScreenStack.CurrentScreen as ResultsScreen)?.IsLoaded == true);
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Func<Player> playToCompletion()
|
||||||
{
|
{
|
||||||
Player player = null;
|
Player player = null;
|
||||||
|
|
||||||
@ -803,7 +828,8 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
|
|
||||||
AddUntilStep("wait for track playing", () => beatmap().Track.IsRunning);
|
AddUntilStep("wait for track playing", () => beatmap().Track.IsRunning);
|
||||||
AddStep("seek to near end", () => player.ChildrenOfType<GameplayClockContainer>().First().Seek(beatmap().Beatmap.HitObjects[^1].StartTime - 1000));
|
AddStep("seek to near end", () => player.ChildrenOfType<GameplayClockContainer>().First().Seek(beatmap().Beatmap.HitObjects[^1].StartTime - 1000));
|
||||||
AddUntilStep("wait for pass", () => (Game.ScreenStack.CurrentScreen as ResultsScreen)?.IsLoaded == true);
|
AddUntilStep("wait for complete", () => player.GameplayState.HasPassed);
|
||||||
|
|
||||||
return () => player;
|
return () => player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.Settings.Sections.Input;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Settings
|
||||||
|
{
|
||||||
|
public partial class TestSceneKeyBindingConflictPopover : OsuTestScene
|
||||||
|
{
|
||||||
|
[Cached]
|
||||||
|
private OverlayColourProvider colourProvider { get; set; } = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAppearance()
|
||||||
|
{
|
||||||
|
ButtonWithConflictPopover button = null!;
|
||||||
|
|
||||||
|
AddStep("create content", () =>
|
||||||
|
{
|
||||||
|
Child = new PopoverContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Child = button = new ButtonWithConflictPopover
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Text = "Open popover",
|
||||||
|
Width = 300
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
AddStep("show popover", () => button.TriggerClick());
|
||||||
|
}
|
||||||
|
|
||||||
|
private partial class ButtonWithConflictPopover : RoundedButton, IHasPopover
|
||||||
|
{
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
Action = this.ShowPopover;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Popover GetPopover() => new KeyBindingConflictPopover(
|
||||||
|
new KeyBindingRow.KeyBindingConflictInfo(
|
||||||
|
new KeyBindingRow.ConflictingKeyBinding(Guid.NewGuid(), OsuAction.LeftButton, KeyCombination.FromKey(Key.X), new KeyCombination(InputKey.None)),
|
||||||
|
new KeyBindingRow.ConflictingKeyBinding(Guid.NewGuid(), OsuAction.RightButton, KeyCombination.FromKey(Key.Z), KeyCombination.FromKey(Key.X))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,8 +10,12 @@ using osu.Framework.Testing;
|
|||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
|
using osu.Game.Localisation;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Overlays.Settings.Sections.Input;
|
using osu.Game.Overlays.Settings.Sections.Input;
|
||||||
|
using osu.Game.Rulesets.Taiko;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Settings
|
namespace osu.Game.Tests.Visual.Settings
|
||||||
@ -154,7 +158,9 @@ namespace osu.Game.Tests.Visual.Settings
|
|||||||
|
|
||||||
clickClearButton();
|
clickClearButton();
|
||||||
|
|
||||||
AddAssert("first binding cleared", () => string.IsNullOrEmpty(multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().First().Text.Text.ToString()));
|
AddAssert("first binding cleared",
|
||||||
|
() => multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().First().Text.Text,
|
||||||
|
() => Is.EqualTo(InputSettingsStrings.ActionHasNoKeyBinding));
|
||||||
|
|
||||||
AddStep("click second binding", () =>
|
AddStep("click second binding", () =>
|
||||||
{
|
{
|
||||||
@ -166,7 +172,9 @@ namespace osu.Game.Tests.Visual.Settings
|
|||||||
|
|
||||||
clickClearButton();
|
clickClearButton();
|
||||||
|
|
||||||
AddAssert("second binding cleared", () => string.IsNullOrEmpty(multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1).Text.Text.ToString()));
|
AddAssert("second binding cleared",
|
||||||
|
() => multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1).Text.Text,
|
||||||
|
() => Is.EqualTo(InputSettingsStrings.ActionHasNoKeyBinding));
|
||||||
|
|
||||||
void clickClearButton()
|
void clickClearButton()
|
||||||
{
|
{
|
||||||
@ -207,7 +215,7 @@ namespace osu.Game.Tests.Visual.Settings
|
|||||||
AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType<RevertToDefaultButton<bool>>().First().Alpha == 0);
|
AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType<RevertToDefaultButton<bool>>().First().Alpha == 0);
|
||||||
|
|
||||||
AddAssert("binding cleared",
|
AddAssert("binding cleared",
|
||||||
() => settingsKeyBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(0).KeyBinding.KeyCombination.Equals(settingsKeyBindingRow.Defaults.ElementAt(0)));
|
() => settingsKeyBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(0).KeyBinding.Value.KeyCombination.Equals(settingsKeyBindingRow.Defaults.ElementAt(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -237,7 +245,7 @@ namespace osu.Game.Tests.Visual.Settings
|
|||||||
AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType<RevertToDefaultButton<bool>>().First().Alpha == 0);
|
AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType<RevertToDefaultButton<bool>>().First().Alpha == 0);
|
||||||
|
|
||||||
AddAssert("binding cleared",
|
AddAssert("binding cleared",
|
||||||
() => settingsKeyBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(0).KeyBinding.KeyCombination.Equals(settingsKeyBindingRow.Defaults.ElementAt(0)));
|
() => settingsKeyBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(0).KeyBinding.Value.KeyCombination.Equals(settingsKeyBindingRow.Defaults.ElementAt(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -288,6 +296,106 @@ namespace osu.Game.Tests.Visual.Settings
|
|||||||
AddUntilStep("all reset section bindings buttons shown", () => panel.ChildrenOfType<ResetButton>().All(button => button.Alpha == 1));
|
AddUntilStep("all reset section bindings buttons shown", () => panel.ChildrenOfType<ResetButton>().All(button => button.Alpha == 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestBindingConflictResolvedByRollback()
|
||||||
|
{
|
||||||
|
AddStep("reset taiko section to default", () =>
|
||||||
|
{
|
||||||
|
var section = panel.ChildrenOfType<VariantBindingsSubsection>().First(section => new TaikoRuleset().RulesetInfo.Equals(section.Ruleset));
|
||||||
|
section.ChildrenOfType<ResetButton>().Single().TriggerClick();
|
||||||
|
});
|
||||||
|
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
|
||||||
|
AddUntilStep("wait for collapsed", () => panel.ChildrenOfType<SettingsSidebar>().Single().Expanded.Value, () => Is.False);
|
||||||
|
scrollToAndStartBinding("Left (rim)");
|
||||||
|
AddStep("attempt to bind M1 to two keys", () => InputManager.Click(MouseButton.Left));
|
||||||
|
|
||||||
|
KeyBindingConflictPopover popover = null;
|
||||||
|
AddUntilStep("wait for popover", () => popover = panel.ChildrenOfType<KeyBindingConflictPopover>().SingleOrDefault(), () => Is.Not.Null);
|
||||||
|
AddStep("click first button", () => popover.ChildrenOfType<RoundedButton>().First().TriggerClick());
|
||||||
|
checkBinding("Left (centre)", "M1");
|
||||||
|
checkBinding("Left (rim)", "M2");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestBindingConflictResolvedByOverwrite()
|
||||||
|
{
|
||||||
|
AddStep("reset taiko section to default", () =>
|
||||||
|
{
|
||||||
|
var section = panel.ChildrenOfType<VariantBindingsSubsection>().First(section => new TaikoRuleset().RulesetInfo.Equals(section.Ruleset));
|
||||||
|
section.ChildrenOfType<ResetButton>().Single().TriggerClick();
|
||||||
|
});
|
||||||
|
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
|
||||||
|
AddUntilStep("wait for collapsed", () => panel.ChildrenOfType<SettingsSidebar>().Single().Expanded.Value, () => Is.False);
|
||||||
|
scrollToAndStartBinding("Left (rim)");
|
||||||
|
AddStep("attempt to bind M1 to two keys", () => InputManager.Click(MouseButton.Left));
|
||||||
|
|
||||||
|
KeyBindingConflictPopover popover = null;
|
||||||
|
AddUntilStep("wait for popover", () => popover = panel.ChildrenOfType<KeyBindingConflictPopover>().SingleOrDefault(), () => Is.Not.Null);
|
||||||
|
AddStep("click second button", () => popover.ChildrenOfType<RoundedButton>().ElementAt(1).TriggerClick());
|
||||||
|
checkBinding("Left (centre)", InputSettingsStrings.ActionHasNoKeyBinding.ToString());
|
||||||
|
checkBinding("Left (rim)", "M1");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestBindingConflictCausedByResetToDefaultOfSingleRow()
|
||||||
|
{
|
||||||
|
AddStep("reset taiko section to default", () =>
|
||||||
|
{
|
||||||
|
var section = panel.ChildrenOfType<VariantBindingsSubsection>().First(section => new TaikoRuleset().RulesetInfo.Equals(section.Ruleset));
|
||||||
|
section.ChildrenOfType<ResetButton>().Single().TriggerClick();
|
||||||
|
});
|
||||||
|
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
|
||||||
|
AddUntilStep("wait for collapsed", () => panel.ChildrenOfType<SettingsSidebar>().Single().Expanded.Value, () => Is.False);
|
||||||
|
scrollToAndStartBinding("Left (centre)");
|
||||||
|
AddStep("clear binding", () =>
|
||||||
|
{
|
||||||
|
var row = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text.ToString() == "Left (centre)"));
|
||||||
|
row.ChildrenOfType<KeyBindingRow.ClearButton>().Single().TriggerClick();
|
||||||
|
});
|
||||||
|
scrollToAndStartBinding("Left (rim)");
|
||||||
|
AddStep("bind M1", () => InputManager.Click(MouseButton.Left));
|
||||||
|
|
||||||
|
AddStep("reset Left (centre) to default", () =>
|
||||||
|
{
|
||||||
|
var row = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text.ToString() == "Left (centre)"));
|
||||||
|
row.ChildrenOfType<RevertToDefaultButton<bool>>().Single().TriggerClick();
|
||||||
|
});
|
||||||
|
|
||||||
|
KeyBindingConflictPopover popover = null;
|
||||||
|
AddUntilStep("wait for popover", () => popover = panel.ChildrenOfType<KeyBindingConflictPopover>().SingleOrDefault(), () => Is.Not.Null);
|
||||||
|
AddStep("click second button", () => popover.ChildrenOfType<RoundedButton>().ElementAt(1).TriggerClick());
|
||||||
|
checkBinding("Left (centre)", "M1");
|
||||||
|
checkBinding("Left (rim)", InputSettingsStrings.ActionHasNoKeyBinding.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestResettingEntireSectionDoesNotCauseBindingConflicts()
|
||||||
|
{
|
||||||
|
AddStep("reset taiko section to default", () =>
|
||||||
|
{
|
||||||
|
var section = panel.ChildrenOfType<VariantBindingsSubsection>().First(section => new TaikoRuleset().RulesetInfo.Equals(section.Ruleset));
|
||||||
|
section.ChildrenOfType<ResetButton>().Single().TriggerClick();
|
||||||
|
});
|
||||||
|
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
|
||||||
|
AddUntilStep("wait for collapsed", () => panel.ChildrenOfType<SettingsSidebar>().Single().Expanded.Value, () => Is.False);
|
||||||
|
scrollToAndStartBinding("Left (centre)");
|
||||||
|
AddStep("clear binding", () =>
|
||||||
|
{
|
||||||
|
var row = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text.ToString() == "Left (centre)"));
|
||||||
|
row.ChildrenOfType<KeyBindingRow.ClearButton>().Single().TriggerClick();
|
||||||
|
});
|
||||||
|
scrollToAndStartBinding("Left (rim)");
|
||||||
|
AddStep("bind M1", () => InputManager.Click(MouseButton.Left));
|
||||||
|
|
||||||
|
AddStep("reset taiko section to default", () =>
|
||||||
|
{
|
||||||
|
var section = panel.ChildrenOfType<VariantBindingsSubsection>().First(section => new TaikoRuleset().RulesetInfo.Equals(section.Ruleset));
|
||||||
|
section.ChildrenOfType<ResetButton>().Single().TriggerClick();
|
||||||
|
});
|
||||||
|
AddWaitStep("wait a bit", 3);
|
||||||
|
AddUntilStep("conflict popover not shown", () => panel.ChildrenOfType<KeyBindingConflictPopover>().SingleOrDefault(), () => Is.Null);
|
||||||
|
}
|
||||||
|
|
||||||
private void checkBinding(string name, string keyName)
|
private void checkBinding(string name, string keyName)
|
||||||
{
|
{
|
||||||
AddAssert($"Check {name} is bound to {keyName}", () =>
|
AddAssert($"Check {name} is bound to {keyName}", () =>
|
||||||
|
60
osu.Game.Tests/Visual/Settings/TestSceneKeyBindingRow.cs
Normal file
60
osu.Game.Tests/Visual/Settings/TestSceneKeyBindingRow.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.Settings.Sections.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Settings
|
||||||
|
{
|
||||||
|
public partial class TestSceneKeyBindingRow : OsuTestScene
|
||||||
|
{
|
||||||
|
[Cached]
|
||||||
|
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestChangesAfterConstruction()
|
||||||
|
{
|
||||||
|
KeyBindingRow row = null!;
|
||||||
|
|
||||||
|
AddStep("create row", () => Child = new Container
|
||||||
|
{
|
||||||
|
Width = 500,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Child = row = new KeyBindingRow(GlobalAction.Back)
|
||||||
|
{
|
||||||
|
Defaults = new[]
|
||||||
|
{
|
||||||
|
new KeyCombination(InputKey.Escape),
|
||||||
|
new KeyCombination(InputKey.ExtraMouseButton1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("change key bindings", () =>
|
||||||
|
{
|
||||||
|
row.KeyBindings.Add(new RealmKeyBinding(GlobalAction.Back, new KeyCombination(InputKey.Escape)));
|
||||||
|
row.KeyBindings.Add(new RealmKeyBinding(GlobalAction.Back, new KeyCombination(InputKey.ExtraMouseButton1)));
|
||||||
|
});
|
||||||
|
AddUntilStep("revert to default button not shown", () => row.ChildrenOfType<RevertToDefaultButton<bool>>().Single().Alpha, () => Is.Zero);
|
||||||
|
|
||||||
|
AddStep("change key bindings", () =>
|
||||||
|
{
|
||||||
|
row.KeyBindings.Clear();
|
||||||
|
row.KeyBindings.Add(new RealmKeyBinding(GlobalAction.Back, new KeyCombination(InputKey.X)));
|
||||||
|
row.KeyBindings.Add(new RealmKeyBinding(GlobalAction.Back, new KeyCombination(InputKey.Z)));
|
||||||
|
row.KeyBindings.Add(new RealmKeyBinding(GlobalAction.Back, new KeyCombination(InputKey.I)));
|
||||||
|
});
|
||||||
|
AddUntilStep("revert to default button not shown", () => row.ChildrenOfType<RevertToDefaultButton<bool>>().Single().Alpha, () => Is.Not.Zero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,11 +5,13 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
@ -31,6 +33,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
public double TimeToCompleteProgress { get; set; } = 2000;
|
public double TimeToCompleteProgress { get; set; } = 2000;
|
||||||
|
|
||||||
|
private readonly UserLookupCache userLookupCache = new TestUserLookupCache();
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp() => Schedule(() =>
|
public void SetUp() => Schedule(() =>
|
||||||
{
|
{
|
||||||
@ -60,6 +64,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddStep(@"simple #2", sendAmazingNotification);
|
AddStep(@"simple #2", sendAmazingNotification);
|
||||||
AddStep(@"progress #1", sendUploadProgress);
|
AddStep(@"progress #1", sendUploadProgress);
|
||||||
AddStep(@"progress #2", sendDownloadProgress);
|
AddStep(@"progress #2", sendDownloadProgress);
|
||||||
|
AddStep(@"User notification", sendUserNotification);
|
||||||
|
|
||||||
checkProgressingCount(2);
|
checkProgressingCount(2);
|
||||||
|
|
||||||
@ -537,6 +542,16 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
progressingNotifications.Add(n);
|
progressingNotifications.Add(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendUserNotification()
|
||||||
|
{
|
||||||
|
var user = userLookupCache.GetUserAsync(0).GetResultSafely();
|
||||||
|
if (user == null) return;
|
||||||
|
|
||||||
|
var n = new UserAvatarNotification(user, $"{user.Username} invited you to a multiplayer match!");
|
||||||
|
|
||||||
|
notificationOverlay.Post(n);
|
||||||
|
}
|
||||||
|
|
||||||
private void sendUploadProgress()
|
private void sendUploadProgress()
|
||||||
{
|
{
|
||||||
var n = new ProgressNotification
|
var n = new ProgressNotification
|
||||||
|
@ -82,7 +82,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
|||||||
new TourneyButton
|
new TourneyButton
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
BackgroundColour = colours.Pink3,
|
BackgroundColour = colours.DangerousButtonColour,
|
||||||
Text = "Clear all",
|
Text = "Clear all",
|
||||||
Action = () =>
|
Action = () =>
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,13 @@ namespace osu.Game.Collections
|
|||||||
public DrawableCollectionListItem(Live<BeatmapCollection> item, bool isCreated)
|
public DrawableCollectionListItem(Live<BeatmapCollection> item, bool isCreated)
|
||||||
: base(item)
|
: base(item)
|
||||||
{
|
{
|
||||||
ShowDragHandle.Value = item.IsManaged;
|
// For now we don't support rearranging and always use alphabetical sort.
|
||||||
|
// Change this to:
|
||||||
|
//
|
||||||
|
// ShowDragHandle.Value = item.IsManaged;
|
||||||
|
//
|
||||||
|
// if we want to support user sorting (but changes will need to be made to realm to persist).
|
||||||
|
ShowDragHandle.Value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Drawable CreateContent() => new ItemContent(Model);
|
protected override Drawable CreateContent() => new ItemContent(Model);
|
||||||
|
@ -397,5 +397,7 @@ namespace osu.Game.Graphics
|
|||||||
|
|
||||||
public Color4 SpotlightColour => Green2;
|
public Color4 SpotlightColour => Green2;
|
||||||
public Color4 FeaturedArtistColour => Blue2;
|
public Color4 FeaturedArtistColour => Blue2;
|
||||||
|
|
||||||
|
public Color4 DangerousButtonColour => Pink3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
BackgroundColour = colours.PinkDark;
|
BackgroundColour = colours.DangerousButtonColour;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,11 @@ namespace osu.Game.Localisation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString ViewBeatmap => new TranslatableString(getKey(@"view_beatmap"), @"View beatmap");
|
public static LocalisableString ViewBeatmap => new TranslatableString(getKey(@"view_beatmap"), @"View beatmap");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Invite player"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString InvitePlayer => new TranslatableString(getKey(@"invite_player"), @"Invite player");
|
||||||
|
|
||||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,26 @@ namespace osu.Game.Localisation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString KeyBindingPanelDescription => new TranslatableString(getKey(@"key_binding_panel_description"), @"Customise your keys!");
|
public static LocalisableString KeyBindingPanelDescription => new TranslatableString(getKey(@"key_binding_panel_description"), @"Customise your keys!");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "The binding you've selected conflicts with another existing binding."
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString KeyBindingConflictDetected => new TranslatableString(getKey(@"key_binding_conflict_detected"), @"The binding you've selected conflicts with another existing binding.");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Keep existing"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString KeepExistingBinding => new TranslatableString(getKey(@"keep_existing_binding"), @"Keep existing");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Apply new"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString ApplyNewBinding => new TranslatableString(getKey(@"apply_new_binding"), @"Apply new");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "(none)"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString ActionHasNoKeyBinding => new TranslatableString(getKey(@"action_has_no_key_binding"), @"(none)");
|
||||||
|
|
||||||
private static string getKey(string key) => $"{prefix}:{key}";
|
private static string getKey(string key) => $"{prefix}:{key}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,11 @@ Please try changing your audio device to a working setting.");
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString YourNameWasMentioned(string username) => new TranslatableString(getKey(@"your_name_was_mentioned"), @"Your name was mentioned in chat by '{0}'. Click to find out why!", username);
|
public static LocalisableString YourNameWasMentioned(string username) => new TranslatableString(getKey(@"your_name_was_mentioned"), @"Your name was mentioned in chat by '{0}'. Click to find out why!", username);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "{0} invited you to the multiplayer match "{1}"! Click to join."
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString InvitedYouToTheMultiplayer(string username, string roomName) => new TranslatableString(getKey(@"invited_you_to_the_multiplayer"), @"{0} invited you to the multiplayer match ""{1}""! Click to join.", username, roomName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// "You do not have the beatmap for this replay."
|
/// "You do not have the beatmap for this replay."
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -14,6 +14,16 @@ namespace osu.Game.Localisation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString SupporterOnlyDurationNotice => new TranslatableString(getKey(@"supporter_only_duration_notice"), @"Playlist durations longer than 2 weeks require an active osu!supporter tag.");
|
public static LocalisableString SupporterOnlyDurationNotice => new TranslatableString(getKey(@"supporter_only_duration_notice"), @"Playlist durations longer than 2 weeks require an active osu!supporter tag.");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Can't invite this user as you have blocked them or they have blocked you."
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString InviteFailedUserBlocked => new TranslatableString(getKey(@"cant_invite_this_user_as"), @"Can't invite this user as you have blocked them or they have blocked you.");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Can't invite this user as they have opted out of non-friend communications."
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString InviteFailedUserOptOut => new TranslatableString(getKey(@"cant_invite_this_user_as1"), @"Can't invite this user as they have opted out of non-friend communications.");
|
||||||
|
|
||||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,14 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
/// <param name="user">The user.</param>
|
/// <param name="user">The user.</param>
|
||||||
Task UserKicked(MultiplayerRoomUser user);
|
Task UserKicked(MultiplayerRoomUser user);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Signals that the local user has been invited into a multiplayer room.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="invitedBy">Id of user that invited the player.</param>
|
||||||
|
/// <param name="roomID">Id of the room the user got invited to.</param>
|
||||||
|
/// <param name="password">Password to join the room.</param>
|
||||||
|
Task Invited(int invitedBy, long roomID, string password);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Signal that the host of the room has changed.
|
/// Signal that the host of the room has changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -99,5 +99,13 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="playlistItemId">The item to remove.</param>
|
/// <param name="playlistItemId">The item to remove.</param>
|
||||||
Task RemovePlaylistItem(long playlistItemId);
|
Task RemovePlaylistItem(long playlistItemId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invites a player to the current room.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId">The user to invite.</param>
|
||||||
|
/// <exception cref="UserBlockedException">The user has blocked or has been blocked by the invited user.</exception>
|
||||||
|
/// <exception cref="UserBlocksPMsException">The invited user does not accept private messages.</exception>
|
||||||
|
Task InvitePlayer(int userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ using osu.Game.Overlays.Notifications;
|
|||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
|
using osu.Game.Localisation;
|
||||||
|
|
||||||
namespace osu.Game.Online.Multiplayer
|
namespace osu.Game.Online.Multiplayer
|
||||||
{
|
{
|
||||||
@ -30,6 +31,8 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
{
|
{
|
||||||
public Action<Notification>? PostNotification { protected get; set; }
|
public Action<Notification>? PostNotification { protected get; set; }
|
||||||
|
|
||||||
|
public Action<Room, string>? PresentMatch { protected get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when any change occurs to the multiplayer room.
|
/// Invoked when any change occurs to the multiplayer room.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -260,6 +263,8 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
|
|
||||||
protected abstract Task LeaveRoomInternal();
|
protected abstract Task LeaveRoomInternal();
|
||||||
|
|
||||||
|
public abstract Task InvitePlayer(int userId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Change the current <see cref="MultiplayerRoom"/> settings.
|
/// Change the current <see cref="MultiplayerRoom"/> settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -440,6 +445,38 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
return handleUserLeft(user, UserKicked);
|
return handleUserLeft(user, UserKicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async Task IMultiplayerClient.Invited(int invitedBy, long roomID, string password)
|
||||||
|
{
|
||||||
|
APIUser? apiUser = await userLookupCache.GetUserAsync(invitedBy).ConfigureAwait(false);
|
||||||
|
Room? apiRoom = await getRoomAsync(roomID).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (apiUser == null || apiRoom == null) return;
|
||||||
|
|
||||||
|
PostNotification?.Invoke(
|
||||||
|
new UserAvatarNotification(apiUser, NotificationsStrings.InvitedYouToTheMultiplayer(apiUser.Username, apiRoom.Name.Value))
|
||||||
|
{
|
||||||
|
Activated = () =>
|
||||||
|
{
|
||||||
|
PresentMatch?.Invoke(apiRoom, password);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
Task<Room?> getRoomAsync(long id)
|
||||||
|
{
|
||||||
|
TaskCompletionSource<Room?> taskCompletionSource = new TaskCompletionSource<Room?>();
|
||||||
|
|
||||||
|
var request = new GetRoomRequest(id);
|
||||||
|
request.Success += room => taskCompletionSource.TrySetResult(room);
|
||||||
|
request.Failure += _ => taskCompletionSource.TrySetResult(null);
|
||||||
|
|
||||||
|
API.Queue(request);
|
||||||
|
|
||||||
|
return taskCompletionSource.Task;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void addUserToAPIRoom(MultiplayerRoomUser user)
|
private void addUserToAPIRoom(MultiplayerRoomUser user)
|
||||||
{
|
{
|
||||||
Debug.Assert(APIRoom != null);
|
Debug.Assert(APIRoom != null);
|
||||||
|
@ -12,6 +12,8 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
|
using osu.Game.Overlays.Notifications;
|
||||||
|
using osu.Game.Localisation;
|
||||||
|
|
||||||
namespace osu.Game.Online.Multiplayer
|
namespace osu.Game.Online.Multiplayer
|
||||||
{
|
{
|
||||||
@ -50,6 +52,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
connection.On<MultiplayerRoomUser>(nameof(IMultiplayerClient.UserJoined), ((IMultiplayerClient)this).UserJoined);
|
connection.On<MultiplayerRoomUser>(nameof(IMultiplayerClient.UserJoined), ((IMultiplayerClient)this).UserJoined);
|
||||||
connection.On<MultiplayerRoomUser>(nameof(IMultiplayerClient.UserLeft), ((IMultiplayerClient)this).UserLeft);
|
connection.On<MultiplayerRoomUser>(nameof(IMultiplayerClient.UserLeft), ((IMultiplayerClient)this).UserLeft);
|
||||||
connection.On<MultiplayerRoomUser>(nameof(IMultiplayerClient.UserKicked), ((IMultiplayerClient)this).UserKicked);
|
connection.On<MultiplayerRoomUser>(nameof(IMultiplayerClient.UserKicked), ((IMultiplayerClient)this).UserKicked);
|
||||||
|
connection.On<int, long, string>(nameof(IMultiplayerClient.Invited), ((IMultiplayerClient)this).Invited);
|
||||||
connection.On<int>(nameof(IMultiplayerClient.HostChanged), ((IMultiplayerClient)this).HostChanged);
|
connection.On<int>(nameof(IMultiplayerClient.HostChanged), ((IMultiplayerClient)this).HostChanged);
|
||||||
connection.On<MultiplayerRoomSettings>(nameof(IMultiplayerClient.SettingsChanged), ((IMultiplayerClient)this).SettingsChanged);
|
connection.On<MultiplayerRoomSettings>(nameof(IMultiplayerClient.SettingsChanged), ((IMultiplayerClient)this).SettingsChanged);
|
||||||
connection.On<int, MultiplayerUserState>(nameof(IMultiplayerClient.UserStateChanged), ((IMultiplayerClient)this).UserStateChanged);
|
connection.On<int, MultiplayerUserState>(nameof(IMultiplayerClient.UserStateChanged), ((IMultiplayerClient)this).UserStateChanged);
|
||||||
@ -106,6 +109,32 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
return connection.InvokeAsync(nameof(IMultiplayerServer.LeaveRoom));
|
return connection.InvokeAsync(nameof(IMultiplayerServer.LeaveRoom));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override async Task InvitePlayer(int userId)
|
||||||
|
{
|
||||||
|
if (!IsConnected.Value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Debug.Assert(connection != null);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await connection.InvokeAsync(nameof(IMultiplayerServer.InvitePlayer), userId).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (HubException exception)
|
||||||
|
{
|
||||||
|
switch (exception.GetHubExceptionMessage())
|
||||||
|
{
|
||||||
|
case UserBlockedException.MESSAGE:
|
||||||
|
PostNotification?.Invoke(new SimpleErrorNotification { Text = OnlinePlayStrings.InviteFailedUserBlocked });
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UserBlocksPMsException.MESSAGE:
|
||||||
|
PostNotification?.Invoke(new SimpleErrorNotification { Text = OnlinePlayStrings.InviteFailedUserOptOut });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override Task TransferHost(int userId)
|
public override Task TransferHost(int userId)
|
||||||
{
|
{
|
||||||
if (!IsConnected.Value)
|
if (!IsConnected.Value)
|
||||||
|
25
osu.Game/Online/Multiplayer/UserBlockedException.cs
Normal file
25
osu.Game/Online/Multiplayer/UserBlockedException.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// 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.Runtime.Serialization;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.Multiplayer
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class UserBlockedException : HubException
|
||||||
|
{
|
||||||
|
public const string MESSAGE = @"Cannot perform action due to user being blocked.";
|
||||||
|
|
||||||
|
public UserBlockedException()
|
||||||
|
: base(MESSAGE)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected UserBlockedException(SerializationInfo info, StreamingContext context)
|
||||||
|
: base(info, context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
osu.Game/Online/Multiplayer/UserBlocksPMsException.cs
Normal file
25
osu.Game/Online/Multiplayer/UserBlocksPMsException.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// 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.Runtime.Serialization;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.Multiplayer
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class UserBlocksPMsException : HubException
|
||||||
|
{
|
||||||
|
public const string MESSAGE = "Cannot perform action because user has disabled non-friend communications.";
|
||||||
|
|
||||||
|
public UserBlocksPMsException()
|
||||||
|
: base(MESSAGE)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected UserBlocksPMsException(SerializationInfo info, StreamingContext context)
|
||||||
|
: base(info, context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -46,6 +46,7 @@ using osu.Game.IO;
|
|||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
using osu.Game.Online;
|
using osu.Game.Online;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.BeatmapListing;
|
using osu.Game.Overlays.BeatmapListing;
|
||||||
using osu.Game.Overlays.Music;
|
using osu.Game.Overlays.Music;
|
||||||
@ -58,6 +59,7 @@ using osu.Game.Rulesets.Mods;
|
|||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.Menu;
|
using osu.Game.Screens.Menu;
|
||||||
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
@ -643,6 +645,24 @@ namespace osu.Game
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Join a multiplayer match immediately.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="room">The room to join.</param>
|
||||||
|
/// <param name="password">The password to join the room, if any is given.</param>
|
||||||
|
public void PresentMultiplayerMatch(Room room, string password)
|
||||||
|
{
|
||||||
|
PerformFromScreen(screen =>
|
||||||
|
{
|
||||||
|
if (!(screen is Multiplayer multiplayer))
|
||||||
|
screen.Push(multiplayer = new Multiplayer());
|
||||||
|
|
||||||
|
multiplayer.Join(room, password);
|
||||||
|
});
|
||||||
|
// TODO: We should really be able to use `validScreens: new[] { typeof(Multiplayer) }` here
|
||||||
|
// but `PerformFromScreen` doesn't understand nested stacks.
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Present a score's replay immediately.
|
/// Present a score's replay immediately.
|
||||||
/// The user should have already requested this interactively.
|
/// The user should have already requested this interactively.
|
||||||
@ -853,6 +873,7 @@ namespace osu.Game
|
|||||||
ScoreManager.PresentImport = items => PresentScore(items.First().Value);
|
ScoreManager.PresentImport = items => PresentScore(items.First().Value);
|
||||||
|
|
||||||
MultiplayerClient.PostNotification = n => Notifications.Post(n);
|
MultiplayerClient.PostNotification = n => Notifications.Post(n);
|
||||||
|
MultiplayerClient.PresentMatch = PresentMultiplayerMatch;
|
||||||
|
|
||||||
// make config aware of how to lookup skins for on-screen display purposes.
|
// make config aware of how to lookup skins for on-screen display purposes.
|
||||||
// if this becomes a more common thing, tracked settings should be reconsidered to allow local DI.
|
// if this becomes a more common thing, tracked settings should be reconsidered to allow local DI.
|
||||||
|
@ -119,7 +119,7 @@ namespace osu.Game.Overlays.Dashboard
|
|||||||
{
|
{
|
||||||
users.GetUserAsync(userId).ContinueWith(task =>
|
users.GetUserAsync(userId).ContinueWith(task =>
|
||||||
{
|
{
|
||||||
var user = task.GetResultSafely();
|
APIUser user = task.GetResultSafely();
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return;
|
return;
|
||||||
@ -130,6 +130,9 @@ namespace osu.Game.Overlays.Dashboard
|
|||||||
if (!playingUsers.Contains(user.Id))
|
if (!playingUsers.Contains(user.Id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// TODO: remove this once online state is being updated more correctly.
|
||||||
|
user.IsOnline = true;
|
||||||
|
|
||||||
userFlow.Add(createUserPanel(user));
|
userFlow.Add(createUserPanel(user));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -65,7 +65,7 @@ namespace osu.Game.Overlays.FirstRunSetup
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
BackgroundColour = colours.Pink3,
|
BackgroundColour = colours.DangerousButtonColour,
|
||||||
Text = FirstRunSetupOverlayStrings.ClassicDefaults,
|
Text = FirstRunSetupOverlayStrings.ClassicDefaults,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Action = applyClassic
|
Action = applyClassic
|
||||||
|
@ -113,7 +113,8 @@ namespace osu.Game.Overlays
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new NotificationSection(AccountsStrings.NotificationsTitle, new[] { typeof(SimpleNotification) }),
|
// The main section adds as a catch-all for notifications which don't group into other sections.
|
||||||
|
new NotificationSection(AccountsStrings.NotificationsTitle),
|
||||||
new NotificationSection(NotificationsStrings.RunningTasks, new[] { typeof(ProgressNotification) }),
|
new NotificationSection(NotificationsStrings.RunningTasks, new[] { typeof(ProgressNotification) }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -205,7 +206,8 @@ namespace osu.Game.Overlays
|
|||||||
var ourType = notification.GetType();
|
var ourType = notification.GetType();
|
||||||
int depth = notification.DisplayOnTop ? -runningDepth : runningDepth;
|
int depth = notification.DisplayOnTop ? -runningDepth : runningDepth;
|
||||||
|
|
||||||
var section = sections.Children.First(s => s.AcceptedNotificationTypes.Any(accept => accept.IsAssignableFrom(ourType)));
|
var section = sections.Children.FirstOrDefault(s => s.AcceptedNotificationTypes?.Any(accept => accept.IsAssignableFrom(ourType)) == true)
|
||||||
|
?? sections.First();
|
||||||
|
|
||||||
section.Add(notification, depth);
|
section.Add(notification, depth);
|
||||||
|
|
||||||
|
@ -53,6 +53,8 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
public virtual string PopInSampleName => "UI/notification-default";
|
public virtual string PopInSampleName => "UI/notification-default";
|
||||||
public virtual string PopOutSampleName => "UI/overlay-pop-out";
|
public virtual string PopOutSampleName => "UI/overlay-pop-out";
|
||||||
|
|
||||||
|
protected const float CORNER_RADIUS = 6;
|
||||||
|
|
||||||
protected NotificationLight Light;
|
protected NotificationLight Light;
|
||||||
|
|
||||||
protected Container IconContent;
|
protected Container IconContent;
|
||||||
@ -128,7 +130,7 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
}.WithChild(MainContent = new Container
|
}.WithChild(MainContent = new Container
|
||||||
{
|
{
|
||||||
CornerRadius = 6,
|
CornerRadius = CORNER_RADIUS,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
@ -473,10 +475,9 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
base.Colour = value;
|
base.Colour = value;
|
||||||
pulsateLayer.EdgeEffect = new EdgeEffectParameters
|
pulsateLayer.EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
Colour = ((Color4)value).Opacity(0.5f), //todo: avoid cast
|
Colour = ((Color4)value).Opacity(0.18f),
|
||||||
Type = EdgeEffectType.Glow,
|
Type = EdgeEffectType.Glow,
|
||||||
Radius = 12,
|
Radius = 14,
|
||||||
Roundness = 12,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,17 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
notifications.Insert((int)position, notification);
|
notifications.Insert((int)position, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Type> AcceptedNotificationTypes { get; }
|
/// <summary>
|
||||||
|
/// Enumerable of notification types accepted in this section.
|
||||||
|
/// If <see langword="null"/>, the section accepts any and all notifications.
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<Type>? AcceptedNotificationTypes { get; }
|
||||||
|
|
||||||
private readonly LocalisableString titleText;
|
private readonly LocalisableString titleText;
|
||||||
|
|
||||||
public NotificationSection(LocalisableString title, IEnumerable<Type> acceptedNotificationTypes)
|
public NotificationSection(LocalisableString title, IEnumerable<Type>? acceptedNotificationTypes = null)
|
||||||
{
|
{
|
||||||
AcceptedNotificationTypes = acceptedNotificationTypes.ToArray();
|
AcceptedNotificationTypes = acceptedNotificationTypes?.ToArray();
|
||||||
|
|
||||||
titleText = title;
|
titleText = title;
|
||||||
}
|
}
|
||||||
|
74
osu.Game/Overlays/Notifications/UserAvatarNotification.cs
Normal file
74
osu.Game/Overlays/Notifications/UserAvatarNotification.cs
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
// 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.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osu.Game.Users.Drawables;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Notifications
|
||||||
|
{
|
||||||
|
public partial class UserAvatarNotification : Notification
|
||||||
|
{
|
||||||
|
private LocalisableString text;
|
||||||
|
|
||||||
|
public override LocalisableString Text
|
||||||
|
{
|
||||||
|
get => text;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
text = value;
|
||||||
|
if (textDrawable != null)
|
||||||
|
textDrawable.Text = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextFlowContainer? textDrawable;
|
||||||
|
|
||||||
|
private readonly APIUser user;
|
||||||
|
|
||||||
|
public UserAvatarNotification(APIUser user, LocalisableString text)
|
||||||
|
{
|
||||||
|
this.user = user;
|
||||||
|
Text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IconUsage CloseButtonIcon => FontAwesome.Solid.Times;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours, OverlayColourProvider colourProvider)
|
||||||
|
{
|
||||||
|
Light.Colour = colours.Orange2;
|
||||||
|
|
||||||
|
Content.Add(textDrawable = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14, weight: FontWeight.Medium))
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Text = text
|
||||||
|
});
|
||||||
|
|
||||||
|
IconContent.Masking = true;
|
||||||
|
IconContent.CornerRadius = CORNER_RADIUS;
|
||||||
|
|
||||||
|
IconContent.AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = colourProvider.Background5,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
LoadComponentAsync(new DrawableAvatar(user)
|
||||||
|
{
|
||||||
|
FillMode = FillMode.Fill,
|
||||||
|
}, IconContent.Add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Settings
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
BackgroundColour = colours.Pink3;
|
BackgroundColour = colours.DangerousButtonColour;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,301 @@
|
|||||||
|
// 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.Extensions;
|
||||||
|
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.Framework.Localisation;
|
||||||
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
|
using osu.Game.Localisation;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Settings.Sections.Input
|
||||||
|
{
|
||||||
|
public partial class KeyBindingConflictPopover : OsuPopover
|
||||||
|
{
|
||||||
|
public Action? BindingConflictResolved { get; init; }
|
||||||
|
|
||||||
|
private ConflictingKeyBindingPreview newPreview = null!;
|
||||||
|
private ConflictingKeyBindingPreview existingPreview = null!;
|
||||||
|
private HoverableRoundedButton keepExistingButton = null!;
|
||||||
|
private HoverableRoundedButton applyNewButton = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private RealmAccess realm { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; } = null!;
|
||||||
|
|
||||||
|
private readonly KeyBindingRow.KeyBindingConflictInfo conflictInfo;
|
||||||
|
|
||||||
|
protected override string PopInSampleName => @"UI/generic-error";
|
||||||
|
|
||||||
|
public KeyBindingConflictPopover(KeyBindingRow.KeyBindingConflictInfo conflictInfo)
|
||||||
|
{
|
||||||
|
this.conflictInfo = conflictInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
Child = new FillFlowContainer
|
||||||
|
{
|
||||||
|
Width = 250,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Spacing = new Vector2(10),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuTextFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Text = InputSettingsStrings.KeyBindingConflictDetected,
|
||||||
|
Margin = new MarginPadding { Bottom = 10 }
|
||||||
|
},
|
||||||
|
existingPreview = new ConflictingKeyBindingPreview(
|
||||||
|
conflictInfo.Existing.Action,
|
||||||
|
conflictInfo.Existing.CombinationWhenChosen,
|
||||||
|
conflictInfo.Existing.CombinationWhenNotChosen),
|
||||||
|
newPreview = new ConflictingKeyBindingPreview(
|
||||||
|
conflictInfo.New.Action,
|
||||||
|
conflictInfo.New.CombinationWhenChosen,
|
||||||
|
conflictInfo.New.CombinationWhenNotChosen),
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Margin = new MarginPadding { Top = 10 },
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
keepExistingButton = new HoverableRoundedButton
|
||||||
|
{
|
||||||
|
Text = InputSettingsStrings.KeepExistingBinding,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Width = 0.48f,
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Action = Hide
|
||||||
|
},
|
||||||
|
applyNewButton = new HoverableRoundedButton
|
||||||
|
{
|
||||||
|
Text = InputSettingsStrings.ApplyNewBinding,
|
||||||
|
BackgroundColour = colours.DangerousButtonColour,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Width = 0.48f,
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
Action = applyNew
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyNew()
|
||||||
|
{
|
||||||
|
// only "apply new" needs to cause actual realm changes, since the flow in `KeyBindingsSubsection` does not actually make db changes
|
||||||
|
// if it detects a binding conflict.
|
||||||
|
// the temporary visual changes will be reverted by calling `Hide()` / `BindingConflictResolved`.
|
||||||
|
realm.Write(r =>
|
||||||
|
{
|
||||||
|
var existingBinding = r.Find<RealmKeyBinding>(conflictInfo.Existing.ID);
|
||||||
|
existingBinding!.KeyCombinationString = conflictInfo.Existing.CombinationWhenNotChosen.ToString();
|
||||||
|
|
||||||
|
var newBinding = r.Find<RealmKeyBinding>(conflictInfo.New.ID);
|
||||||
|
newBinding!.KeyCombinationString = conflictInfo.Existing.CombinationWhenChosen.ToString();
|
||||||
|
});
|
||||||
|
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PopOut()
|
||||||
|
{
|
||||||
|
base.PopOut();
|
||||||
|
|
||||||
|
// workaround for `VisibilityContainer.PopOut()` being called in `LoadAsyncComplete()`
|
||||||
|
if (IsLoaded)
|
||||||
|
BindingConflictResolved?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
keepExistingButton.IsHoveredBindable.BindValueChanged(_ => updatePreviews());
|
||||||
|
applyNewButton.IsHoveredBindable.BindValueChanged(_ => updatePreviews());
|
||||||
|
updatePreviews();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePreviews()
|
||||||
|
{
|
||||||
|
if (!keepExistingButton.IsHovered && !applyNewButton.IsHovered)
|
||||||
|
{
|
||||||
|
existingPreview.IsChosen.Value = newPreview.IsChosen.Value = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
existingPreview.IsChosen.Value = keepExistingButton.IsHovered;
|
||||||
|
newPreview.IsChosen.Value = applyNewButton.IsHovered;
|
||||||
|
}
|
||||||
|
|
||||||
|
private partial class ConflictingKeyBindingPreview : CompositeDrawable
|
||||||
|
{
|
||||||
|
private readonly object action;
|
||||||
|
private readonly KeyCombination combinationWhenChosen;
|
||||||
|
private readonly KeyCombination combinationWhenNotChosen;
|
||||||
|
|
||||||
|
private OsuSpriteText newBindingText = null!;
|
||||||
|
|
||||||
|
public Bindable<bool?> IsChosen { get; } = new Bindable<bool?>();
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private ReadableKeyCombinationProvider keyCombinationProvider { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; } = null!;
|
||||||
|
|
||||||
|
public ConflictingKeyBindingPreview(object action, KeyCombination combinationWhenChosen, KeyCombination combinationWhenNotChosen)
|
||||||
|
{
|
||||||
|
this.action = action;
|
||||||
|
this.combinationWhenChosen = combinationWhenChosen;
|
||||||
|
this.combinationWhenNotChosen = combinationWhenNotChosen;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OverlayColourProvider colourProvider)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
|
InternalChild = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
CornerRadius = 5,
|
||||||
|
Masking = true,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = colourProvider.Background5
|
||||||
|
},
|
||||||
|
new GridContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
|
||||||
|
ColumnDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(),
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
},
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = action.GetLocalisableDescription(),
|
||||||
|
Margin = new MarginPadding(7.5f),
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
CornerRadius = 5,
|
||||||
|
Masking = true,
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
X = -5,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = colourProvider.Background6
|
||||||
|
},
|
||||||
|
Empty().With(d => d.Width = 80), // poor man's min-width
|
||||||
|
newBindingText = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.Numeric.With(size: 10),
|
||||||
|
Margin = new MarginPadding(5),
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
IsChosen.BindValueChanged(_ => updateState(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateState()
|
||||||
|
{
|
||||||
|
LocalisableString keyCombinationText;
|
||||||
|
|
||||||
|
switch (IsChosen.Value)
|
||||||
|
{
|
||||||
|
case true:
|
||||||
|
keyCombinationText = keyCombinationProvider.GetReadableString(combinationWhenChosen);
|
||||||
|
newBindingText.Colour = colours.Green1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case false:
|
||||||
|
keyCombinationText = keyCombinationProvider.GetReadableString(combinationWhenNotChosen);
|
||||||
|
newBindingText.Colour = colours.Red1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case null:
|
||||||
|
keyCombinationText = keyCombinationProvider.GetReadableString(combinationWhenChosen);
|
||||||
|
newBindingText.Colour = Colour4.White;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LocalisableString.IsNullOrEmpty(keyCombinationText))
|
||||||
|
keyCombinationText = InputSettingsStrings.ActionHasNoKeyBinding;
|
||||||
|
|
||||||
|
newBindingText.Text = keyCombinationText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private partial class HoverableRoundedButton : RoundedButton
|
||||||
|
{
|
||||||
|
public BindableBool IsHoveredBindable { get; set; } = new BindableBool();
|
||||||
|
|
||||||
|
protected override bool OnHover(HoverEvent e)
|
||||||
|
{
|
||||||
|
IsHoveredBindable.Value = IsHovered;
|
||||||
|
return base.OnHover(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
|
{
|
||||||
|
IsHoveredBindable.Value = IsHovered;
|
||||||
|
base.OnHoverLost(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,6 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Extensions.ObjectExtensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
@ -19,15 +18,13 @@ using osu.Framework.Input.Bindings;
|
|||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Graphics.UserInterfaceV2;
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
using osu.Game.Input;
|
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Settings.Sections.Input
|
namespace osu.Game.Overlays.Settings.Sections.Input
|
||||||
@ -37,13 +34,22 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when the binding of this row is updated with a change being written.
|
/// Invoked when the binding of this row is updated with a change being written.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<KeyBindingRow>? BindingUpdated { get; set; }
|
public KeyBindingUpdated? BindingUpdated { get; set; }
|
||||||
|
|
||||||
|
public delegate void KeyBindingUpdated(KeyBindingRow sender, KeyBindingUpdatedEventArgs args);
|
||||||
|
|
||||||
|
public Func<List<RealmKeyBinding>> GetAllSectionBindings { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether left and right mouse button clicks should be included in the edited bindings.
|
/// Whether left and right mouse button clicks should be included in the edited bindings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AllowMainMouseButtons { get; init; }
|
public bool AllowMainMouseButtons { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The bindings to display in this row.
|
||||||
|
/// </summary>
|
||||||
|
public BindableList<RealmKeyBinding> KeyBindings { get; } = new BindableList<RealmKeyBinding>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default key bindings for this row.
|
/// The default key bindings for this row.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -65,20 +71,22 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
|
|
||||||
public bool FilteringActive { get; set; }
|
public bool FilteringActive { get; set; }
|
||||||
|
|
||||||
public IEnumerable<LocalisableString> FilterTerms => bindings.Select(b => (LocalisableString)keyCombinationProvider.GetReadableString(b.KeyCombination)).Prepend(text.Text);
|
public IEnumerable<LocalisableString> FilterTerms => KeyBindings.Select(b => (LocalisableString)keyCombinationProvider.GetReadableString(b.KeyCombination)).Prepend(text.Text);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private readonly object action;
|
public readonly object Action;
|
||||||
private readonly IEnumerable<RealmKeyBinding> bindings;
|
|
||||||
|
|
||||||
private Bindable<bool> isDefault { get; } = new BindableBool(true);
|
private Bindable<bool> isDefault { get; } = new BindableBool(true);
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private ReadableKeyCombinationProvider keyCombinationProvider { get; set; } = null!;
|
private RealmAccess realm { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private RealmAccess realm { get; set; } = null!;
|
private RulesetStore rulesets { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private ReadableKeyCombinationProvider keyCombinationProvider { get; set; } = null!;
|
||||||
|
|
||||||
private Container content = null!;
|
private Container content = null!;
|
||||||
|
|
||||||
@ -101,11 +109,9 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
/// Creates a new <see cref="KeyBindingRow"/>.
|
/// Creates a new <see cref="KeyBindingRow"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="action">The action that this row contains bindings for.</param>
|
/// <param name="action">The action that this row contains bindings for.</param>
|
||||||
/// <param name="bindings">The keybindings to display in this row.</param>
|
public KeyBindingRow(object action)
|
||||||
public KeyBindingRow(object action, List<RealmKeyBinding> bindings)
|
|
||||||
{
|
{
|
||||||
this.action = action;
|
Action = action;
|
||||||
this.bindings = bindings;
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
@ -161,7 +167,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
},
|
},
|
||||||
text = new OsuSpriteText
|
text = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = action.GetLocalisableDescription(),
|
Text = Action.GetLocalisableDescription(),
|
||||||
Margin = new MarginPadding(1.5f * padding),
|
Margin = new MarginPadding(1.5f * padding),
|
||||||
},
|
},
|
||||||
buttons = new FillFlowContainer<KeyButton>
|
buttons = new FillFlowContainer<KeyButton>
|
||||||
@ -191,10 +197,11 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var b in bindings)
|
KeyBindings.BindCollectionChanged((_, _) =>
|
||||||
buttons.Add(new KeyButton(b));
|
{
|
||||||
|
Scheduler.AddOnce(updateButtons);
|
||||||
updateIsDefaultValue();
|
updateIsDefaultValue();
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RestoreDefaults()
|
public void RestoreDefaults()
|
||||||
@ -206,7 +213,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
var button = buttons[i++];
|
var button = buttons[i++];
|
||||||
button.UpdateKeyCombination(d);
|
button.UpdateKeyCombination(d);
|
||||||
|
|
||||||
updateStoreFromButton(button);
|
tryPersistKeyBinding(button.KeyBinding.Value, advanceToNextBinding: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
isDefault.Value = true;
|
isDefault.Value = true;
|
||||||
@ -226,8 +233,6 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool isModifier(Key k) => k < Key.F1;
|
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e) => true;
|
protected override bool OnClick(ClickEvent e) => true;
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
@ -300,6 +305,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
if (!isModifier(e.Key)) finalise();
|
if (!isModifier(e.Key)) finalise();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
bool isModifier(Key k) => k < Key.F1;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnKeyUp(KeyUpEvent e)
|
protected override void OnKeyUp(KeyUpEvent e)
|
||||||
@ -409,6 +416,18 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
finalise();
|
finalise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateButtons()
|
||||||
|
{
|
||||||
|
if (buttons.Count > KeyBindings.Count)
|
||||||
|
buttons.RemoveRange(buttons.Skip(KeyBindings.Count).ToArray(), true);
|
||||||
|
|
||||||
|
while (buttons.Count < KeyBindings.Count)
|
||||||
|
buttons.Add(new KeyButton());
|
||||||
|
|
||||||
|
foreach (var (button, binding) in buttons.Zip(KeyBindings))
|
||||||
|
button.KeyBinding.Value = binding;
|
||||||
|
}
|
||||||
|
|
||||||
private void clear()
|
private void clear()
|
||||||
{
|
{
|
||||||
if (bindTarget == null)
|
if (bindTarget == null)
|
||||||
@ -418,21 +437,19 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
finalise(false);
|
finalise(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finalise(bool hasChanged = true)
|
private void finalise(bool advanceToNextBinding = true)
|
||||||
{
|
{
|
||||||
if (bindTarget != null)
|
if (bindTarget != null)
|
||||||
{
|
{
|
||||||
updateStoreFromButton(bindTarget);
|
|
||||||
|
|
||||||
updateIsDefaultValue();
|
updateIsDefaultValue();
|
||||||
|
|
||||||
bindTarget.IsBinding = false;
|
bindTarget.IsBinding = false;
|
||||||
|
var bindingToPersist = bindTarget.KeyBinding.Value;
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
// schedule to ensure we don't instantly get focus back on next OnMouseClick (see AcceptFocus impl.)
|
// schedule to ensure we don't instantly get focus back on next OnMouseClick (see AcceptFocus impl.)
|
||||||
bindTarget = null;
|
bindTarget = null;
|
||||||
if (hasChanged)
|
tryPersistKeyBinding(bindingToPersist, advanceToNextBinding);
|
||||||
BindingUpdated?.Invoke(this);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,6 +478,28 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
base.OnFocusLost(e);
|
base.OnFocusLost(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void tryPersistKeyBinding(RealmKeyBinding keyBinding, bool advanceToNextBinding)
|
||||||
|
{
|
||||||
|
List<RealmKeyBinding> bindings = GetAllSectionBindings();
|
||||||
|
RealmKeyBinding? existingBinding = keyBinding.KeyCombination.Equals(new KeyCombination(InputKey.None))
|
||||||
|
? null
|
||||||
|
: bindings.FirstOrDefault(other => other.ID != keyBinding.ID && other.KeyCombination.Equals(keyBinding.KeyCombination));
|
||||||
|
|
||||||
|
if (existingBinding == null)
|
||||||
|
{
|
||||||
|
realm.WriteAsync(r => r.Find<RealmKeyBinding>(keyBinding.ID)!.KeyCombinationString = keyBinding.KeyCombination.ToString());
|
||||||
|
BindingUpdated?.Invoke(this, new KeyBindingUpdatedEventArgs(bindingConflictResolved: false, advanceToNextBinding));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var keyBindingBeforeUpdate = bindings.Single(other => other.ID == keyBinding.ID);
|
||||||
|
|
||||||
|
showBindingConflictPopover(
|
||||||
|
new KeyBindingConflictInfo(
|
||||||
|
new ConflictingKeyBinding(existingBinding.ID, existingBinding.GetAction(rulesets), existingBinding.KeyCombination, new KeyCombination(InputKey.None)),
|
||||||
|
new ConflictingKeyBinding(keyBindingBeforeUpdate.ID, Action, keyBinding.KeyCombination, keyBindingBeforeUpdate.KeyCombination)));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the bind target to the currently hovered key button or the first if clicked anywhere else.
|
/// Updates the bind target to the currently hovered key button or the first if clicked anywhere else.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -471,12 +510,9 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
if (bindTarget != null) bindTarget.IsBinding = true;
|
if (bindTarget != null) bindTarget.IsBinding = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateStoreFromButton(KeyButton button) =>
|
|
||||||
realm.WriteAsync(r => r.Find<RealmKeyBinding>(button.KeyBinding.ID)!.KeyCombinationString = button.KeyBinding.KeyCombinationString);
|
|
||||||
|
|
||||||
private void updateIsDefaultValue()
|
private void updateIsDefaultValue()
|
||||||
{
|
{
|
||||||
isDefault.Value = bindings.Select(b => b.KeyCombination).SequenceEqual(Defaults);
|
isDefault.Value = KeyBindings.Select(b => b.KeyCombination).SequenceEqual(Defaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
private partial class CancelButton : RoundedButton
|
private partial class CancelButton : RoundedButton
|
||||||
@ -496,144 +532,5 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
Size = new Vector2(80, 20);
|
Size = new Vector2(80, 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class KeyButton : Container
|
|
||||||
{
|
|
||||||
public readonly RealmKeyBinding KeyBinding;
|
|
||||||
|
|
||||||
private readonly Box box;
|
|
||||||
public readonly OsuSpriteText Text;
|
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private ReadableKeyCombinationProvider keyCombinationProvider { get; set; } = null!;
|
|
||||||
|
|
||||||
private bool isBinding;
|
|
||||||
|
|
||||||
public bool IsBinding
|
|
||||||
{
|
|
||||||
get => isBinding;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value == isBinding) return;
|
|
||||||
|
|
||||||
isBinding = value;
|
|
||||||
|
|
||||||
updateHoverState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public KeyButton(RealmKeyBinding keyBinding)
|
|
||||||
{
|
|
||||||
if (keyBinding.IsManaged)
|
|
||||||
throw new ArgumentException("Key binding should not be attached as we make temporary changes", nameof(keyBinding));
|
|
||||||
|
|
||||||
KeyBinding = keyBinding;
|
|
||||||
|
|
||||||
Margin = new MarginPadding(padding);
|
|
||||||
|
|
||||||
Masking = true;
|
|
||||||
CornerRadius = padding;
|
|
||||||
|
|
||||||
Height = height;
|
|
||||||
AutoSizeAxes = Axes.X;
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
AlwaysPresent = true,
|
|
||||||
Width = 80,
|
|
||||||
Height = height,
|
|
||||||
},
|
|
||||||
box = new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
Text = new OsuSpriteText
|
|
||||||
{
|
|
||||||
Font = OsuFont.Numeric.With(size: 10),
|
|
||||||
Margin = new MarginPadding(5),
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
},
|
|
||||||
new HoverSounds()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
keyCombinationProvider.KeymapChanged += updateKeyCombinationText;
|
|
||||||
updateKeyCombinationText();
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
updateHoverState();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
|
||||||
{
|
|
||||||
updateHoverState();
|
|
||||||
return base.OnHover(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
|
||||||
{
|
|
||||||
updateHoverState();
|
|
||||||
base.OnHoverLost(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateHoverState()
|
|
||||||
{
|
|
||||||
if (isBinding)
|
|
||||||
{
|
|
||||||
box.FadeColour(colourProvider.Light2, transition_time, Easing.OutQuint);
|
|
||||||
Text.FadeColour(Color4.Black, transition_time, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
box.FadeColour(IsHovered ? colourProvider.Light4 : colourProvider.Background6, transition_time, Easing.OutQuint);
|
|
||||||
Text.FadeColour(IsHovered ? Color4.Black : Color4.White, transition_time, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Update from a key combination, only allowing a single non-modifier key to be specified.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fullState">A <see cref="KeyCombination"/> generated from the full input state.</param>
|
|
||||||
/// <param name="triggerKey">The key which triggered this update, and should be used as the binding.</param>
|
|
||||||
public void UpdateKeyCombination(KeyCombination fullState, InputKey triggerKey) =>
|
|
||||||
UpdateKeyCombination(new KeyCombination(fullState.Keys.Where(KeyCombination.IsModifierKey).Append(triggerKey)));
|
|
||||||
|
|
||||||
public void UpdateKeyCombination(KeyCombination newCombination)
|
|
||||||
{
|
|
||||||
if (KeyBinding.RulesetName != null && !RealmKeyBindingStore.CheckValidForGameplay(newCombination))
|
|
||||||
return;
|
|
||||||
|
|
||||||
KeyBinding.KeyCombination = newCombination;
|
|
||||||
updateKeyCombinationText();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateKeyCombinationText()
|
|
||||||
{
|
|
||||||
Scheduler.AddOnce(updateText);
|
|
||||||
|
|
||||||
void updateText() => Text.Text = keyCombinationProvider.GetReadableString(KeyBinding.KeyCombination);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
|
||||||
{
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
|
|
||||||
if (keyCombinationProvider.IsNotNull())
|
|
||||||
keyCombinationProvider.KeymapChanged -= updateKeyCombinationText;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,78 @@
|
|||||||
|
// 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.Diagnostics;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Settings.Sections.Input
|
||||||
|
{
|
||||||
|
public partial class KeyBindingRow : IHasPopover
|
||||||
|
{
|
||||||
|
private KeyBindingConflictInfo? pendingKeyBindingConflict;
|
||||||
|
|
||||||
|
public Popover GetPopover()
|
||||||
|
{
|
||||||
|
Debug.Assert(pendingKeyBindingConflict != null);
|
||||||
|
return new KeyBindingConflictPopover(pendingKeyBindingConflict)
|
||||||
|
{
|
||||||
|
BindingConflictResolved = () => BindingUpdated?.Invoke(this, new KeyBindingUpdatedEventArgs(bindingConflictResolved: true, canAdvanceToNextBinding: false))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showBindingConflictPopover(KeyBindingConflictInfo conflictInfo)
|
||||||
|
{
|
||||||
|
pendingKeyBindingConflict = conflictInfo;
|
||||||
|
this.ShowPopover();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains information about the key binding conflict to be resolved.
|
||||||
|
/// </summary>
|
||||||
|
public class KeyBindingConflictInfo
|
||||||
|
{
|
||||||
|
public ConflictingKeyBinding Existing { get; }
|
||||||
|
public ConflictingKeyBinding New { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains information about the key binding conflict to be resolved.
|
||||||
|
/// </summary>
|
||||||
|
public KeyBindingConflictInfo(ConflictingKeyBinding existingBinding, ConflictingKeyBinding newBinding)
|
||||||
|
{
|
||||||
|
Existing = existingBinding;
|
||||||
|
New = newBinding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ConflictingKeyBinding
|
||||||
|
{
|
||||||
|
public Guid ID { get; }
|
||||||
|
public object Action { get; }
|
||||||
|
public KeyCombination CombinationWhenChosen { get; }
|
||||||
|
public KeyCombination CombinationWhenNotChosen { get; }
|
||||||
|
|
||||||
|
public ConflictingKeyBinding(Guid id, object action, KeyCombination combinationWhenChosen, KeyCombination combinationWhenNotChosen)
|
||||||
|
{
|
||||||
|
ID = id;
|
||||||
|
Action = action;
|
||||||
|
CombinationWhenChosen = combinationWhenChosen;
|
||||||
|
CombinationWhenNotChosen = combinationWhenNotChosen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class KeyBindingUpdatedEventArgs
|
||||||
|
{
|
||||||
|
public bool BindingConflictResolved { get; }
|
||||||
|
public bool CanAdvanceToNextBinding { get; }
|
||||||
|
|
||||||
|
public KeyBindingUpdatedEventArgs(bool bindingConflictResolved, bool canAdvanceToNextBinding)
|
||||||
|
{
|
||||||
|
BindingConflictResolved = bindingConflictResolved;
|
||||||
|
CanAdvanceToNextBinding = canAdvanceToNextBinding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,183 @@
|
|||||||
|
// 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.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
|
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.Framework.Localisation;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Input;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
|
using osu.Game.Localisation;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Settings.Sections.Input
|
||||||
|
{
|
||||||
|
public partial class KeyBindingRow
|
||||||
|
{
|
||||||
|
public partial class KeyButton : Container
|
||||||
|
{
|
||||||
|
public Bindable<RealmKeyBinding> KeyBinding { get; } = new Bindable<RealmKeyBinding>();
|
||||||
|
|
||||||
|
private readonly Box box;
|
||||||
|
public readonly OsuSpriteText Text;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private ReadableKeyCombinationProvider keyCombinationProvider { get; set; } = null!;
|
||||||
|
|
||||||
|
private bool isBinding;
|
||||||
|
|
||||||
|
public bool IsBinding
|
||||||
|
{
|
||||||
|
get => isBinding;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == isBinding) return;
|
||||||
|
|
||||||
|
isBinding = value;
|
||||||
|
|
||||||
|
updateHoverState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeyButton()
|
||||||
|
{
|
||||||
|
Margin = new MarginPadding(padding);
|
||||||
|
|
||||||
|
Masking = true;
|
||||||
|
CornerRadius = padding;
|
||||||
|
|
||||||
|
Height = height;
|
||||||
|
AutoSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
AlwaysPresent = true,
|
||||||
|
Width = 80,
|
||||||
|
Height = height,
|
||||||
|
},
|
||||||
|
box = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
Text = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.Numeric.With(size: 10),
|
||||||
|
Margin = new MarginPadding(5),
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
},
|
||||||
|
new HoverSounds()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
KeyBinding.BindValueChanged(_ =>
|
||||||
|
{
|
||||||
|
if (KeyBinding.Value.IsManaged)
|
||||||
|
throw new ArgumentException("Key binding should not be attached as we make temporary changes", nameof(KeyBinding));
|
||||||
|
|
||||||
|
updateKeyCombinationText();
|
||||||
|
});
|
||||||
|
keyCombinationProvider.KeymapChanged += updateKeyCombinationText;
|
||||||
|
updateKeyCombinationText();
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
updateHoverState();
|
||||||
|
FinishTransforms(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(HoverEvent e)
|
||||||
|
{
|
||||||
|
updateHoverState();
|
||||||
|
return base.OnHover(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
|
{
|
||||||
|
updateHoverState();
|
||||||
|
base.OnHoverLost(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateHoverState()
|
||||||
|
{
|
||||||
|
if (isBinding)
|
||||||
|
{
|
||||||
|
box.FadeColour(colourProvider.Light2, transition_time, Easing.OutQuint);
|
||||||
|
Text.FadeColour(Color4.Black, transition_time, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
box.FadeColour(IsHovered ? colourProvider.Light4 : colourProvider.Background6, transition_time, Easing.OutQuint);
|
||||||
|
Text.FadeColour(IsHovered ? Color4.Black : Color4.White, transition_time, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update from a key combination, only allowing a single non-modifier key to be specified.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fullState">A <see cref="KeyCombination"/> generated from the full input state.</param>
|
||||||
|
/// <param name="triggerKey">The key which triggered this update, and should be used as the binding.</param>
|
||||||
|
public void UpdateKeyCombination(KeyCombination fullState, InputKey triggerKey) =>
|
||||||
|
UpdateKeyCombination(new KeyCombination(fullState.Keys.Where(KeyCombination.IsModifierKey).Append(triggerKey)));
|
||||||
|
|
||||||
|
public void UpdateKeyCombination(KeyCombination newCombination)
|
||||||
|
{
|
||||||
|
if (KeyBinding.Value.RulesetName != null && !RealmKeyBindingStore.CheckValidForGameplay(newCombination))
|
||||||
|
return;
|
||||||
|
|
||||||
|
KeyBinding.Value.KeyCombination = newCombination;
|
||||||
|
updateKeyCombinationText();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateKeyCombinationText()
|
||||||
|
{
|
||||||
|
Scheduler.AddOnce(updateText);
|
||||||
|
|
||||||
|
void updateText()
|
||||||
|
{
|
||||||
|
LocalisableString keyCombinationString = keyCombinationProvider.GetReadableString(KeyBinding.Value.KeyCombination);
|
||||||
|
float alpha = 1;
|
||||||
|
|
||||||
|
if (LocalisableString.IsNullOrEmpty(keyCombinationString))
|
||||||
|
{
|
||||||
|
keyCombinationString = InputSettingsStrings.ActionHasNoKeyBinding;
|
||||||
|
alpha = 0.4f;
|
||||||
|
}
|
||||||
|
|
||||||
|
Text.Text = keyCombinationString;
|
||||||
|
Text.Alpha = alpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
if (keyCombinationProvider.IsNotNull())
|
||||||
|
keyCombinationProvider.KeymapChanged -= updateKeyCombinationText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
@ -27,46 +26,83 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
|
|
||||||
protected IEnumerable<KeyBinding> Defaults { get; init; } = Array.Empty<KeyBinding>();
|
protected IEnumerable<KeyBinding> Defaults { get; init; } = Array.Empty<KeyBinding>();
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private RealmAccess realm { get; set; } = null!;
|
||||||
|
|
||||||
protected KeyBindingsSubsection()
|
protected KeyBindingsSubsection()
|
||||||
{
|
{
|
||||||
FlowContent.Spacing = new Vector2(0, 3);
|
FlowContent.Spacing = new Vector2(0, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(RealmAccess realm)
|
private void load()
|
||||||
{
|
{
|
||||||
var bindings = realm.Run(r => GetKeyBindings(r).Detach());
|
var bindings = getAllBindings();
|
||||||
|
|
||||||
foreach (var defaultGroup in Defaults.GroupBy(d => d.Action))
|
foreach (var defaultGroup in Defaults.GroupBy(d => d.Action))
|
||||||
{
|
{
|
||||||
int intKey = (int)defaultGroup.Key;
|
int intKey = (int)defaultGroup.Key;
|
||||||
|
|
||||||
// one row per valid action.
|
var row = CreateKeyBindingRow(defaultGroup.Key, defaultGroup)
|
||||||
Add(CreateKeyBindingRow(
|
.With(row =>
|
||||||
defaultGroup.Key,
|
{
|
||||||
bindings.Where(b => b.ActionInt.Equals(intKey)).ToList(),
|
row.BindingUpdated = onBindingUpdated;
|
||||||
defaultGroup)
|
row.GetAllSectionBindings = getAllBindings;
|
||||||
.With(row => row.BindingUpdated = onBindingUpdated));
|
});
|
||||||
|
row.KeyBindings.AddRange(bindings.Where(b => b.ActionInt.Equals(intKey)));
|
||||||
|
Add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
Add(new ResetButton
|
Add(new ResetButton
|
||||||
{
|
{
|
||||||
Action = () => Children.OfType<KeyBindingRow>().ForEach(k => k.RestoreDefaults())
|
Action = () =>
|
||||||
|
{
|
||||||
|
realm.Write(r =>
|
||||||
|
{
|
||||||
|
// can't use `RestoreDefaults()` for each key binding row here as it might trigger binding conflicts along the way.
|
||||||
|
foreach (var row in Children.OfType<KeyBindingRow>())
|
||||||
|
{
|
||||||
|
foreach (var (currentBinding, defaultBinding) in row.KeyBindings.Zip(row.Defaults))
|
||||||
|
r.Find<RealmKeyBinding>(currentBinding.ID)!.KeyCombinationString = defaultBinding.ToString();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
reloadAllBindings();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract IEnumerable<RealmKeyBinding> GetKeyBindings(Realm realm);
|
protected abstract IEnumerable<RealmKeyBinding> GetKeyBindings(Realm realm);
|
||||||
|
|
||||||
protected virtual KeyBindingRow CreateKeyBindingRow(object action, IEnumerable<RealmKeyBinding> keyBindings, IEnumerable<KeyBinding> defaults)
|
private List<RealmKeyBinding> getAllBindings() => realm.Run(r =>
|
||||||
=> new KeyBindingRow(action, keyBindings.ToList())
|
{
|
||||||
|
r.Refresh();
|
||||||
|
return GetKeyBindings(r).Detach();
|
||||||
|
});
|
||||||
|
|
||||||
|
protected virtual KeyBindingRow CreateKeyBindingRow(object action, IEnumerable<KeyBinding> defaults)
|
||||||
|
=> new KeyBindingRow(action)
|
||||||
{
|
{
|
||||||
AllowMainMouseButtons = false,
|
AllowMainMouseButtons = false,
|
||||||
Defaults = defaults.Select(d => d.KeyCombination),
|
Defaults = defaults.Select(d => d.KeyCombination),
|
||||||
};
|
};
|
||||||
|
|
||||||
private void onBindingUpdated(KeyBindingRow sender)
|
private void reloadAllBindings()
|
||||||
{
|
{
|
||||||
if (AutoAdvanceTarget)
|
var bindings = getAllBindings();
|
||||||
|
|
||||||
|
foreach (var row in Children.OfType<KeyBindingRow>())
|
||||||
|
{
|
||||||
|
row.KeyBindings.Clear();
|
||||||
|
row.KeyBindings.AddRange(bindings.Where(b => b.ActionInt.Equals((int)row.Action)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onBindingUpdated(KeyBindingRow sender, KeyBindingRow.KeyBindingUpdatedEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.BindingConflictResolved)
|
||||||
|
reloadAllBindings();
|
||||||
|
|
||||||
|
if (AutoAdvanceTarget && args.CanAdvanceToNextBinding)
|
||||||
{
|
{
|
||||||
var next = Children.SkipWhile(c => c != sender).Skip(1).FirstOrDefault();
|
var next = Children.SkipWhile(c => c != sender).Skip(1).FirstOrDefault();
|
||||||
if (next != null)
|
if (next != null)
|
||||||
|
@ -39,8 +39,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
.Where(b => b.RulesetName == rulesetName && b.Variant == variant);
|
.Where(b => b.RulesetName == rulesetName && b.Variant == variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override KeyBindingRow CreateKeyBindingRow(object action, IEnumerable<RealmKeyBinding> keyBindings, IEnumerable<KeyBinding> defaults)
|
protected override KeyBindingRow CreateKeyBindingRow(object action, IEnumerable<KeyBinding> defaults)
|
||||||
=> new KeyBindingRow(action, keyBindings.ToList())
|
=> new KeyBindingRow(action)
|
||||||
{
|
{
|
||||||
AllowMainMouseButtons = true,
|
AllowMainMouseButtons = true,
|
||||||
Defaults = defaults.Select(d => d.KeyCombination),
|
Defaults = defaults.Select(d => d.KeyCombination),
|
||||||
|
@ -14,6 +14,7 @@ using osu.Framework.Extensions.Color4Extensions;
|
|||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -106,7 +107,10 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Add(SectionsContainer = new SettingsSectionsContainer
|
Add(new PopoverContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Child = SectionsContainer = new SettingsSectionsContainer
|
||||||
{
|
{
|
||||||
Masking = true,
|
Masking = true,
|
||||||
EdgeEffect = new EdgeEffectParameters
|
EdgeEffect = new EdgeEffectParameters
|
||||||
@ -139,6 +143,7 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Footer = CreateFooter().With(f => f.Alpha = 0)
|
Footer = CreateFooter().With(f => f.Alpha = 0)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (showSidebar)
|
if (showSidebar)
|
||||||
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Scoring;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Difficulty
|
namespace osu.Game.Rulesets.Difficulty
|
||||||
{
|
{
|
||||||
@ -45,22 +44,6 @@ namespace osu.Game.Rulesets.Difficulty
|
|||||||
[JsonProperty("max_combo", Order = -2)]
|
[JsonProperty("max_combo", Order = -2)]
|
||||||
public int MaxCombo { get; set; }
|
public int MaxCombo { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The accuracy portion of the legacy (ScoreV1) total score.
|
|
||||||
/// </summary>
|
|
||||||
public int LegacyAccuracyScore { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The combo-multiplied portion of the legacy (ScoreV1) total score.
|
|
||||||
/// </summary>
|
|
||||||
public int LegacyComboScore { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A ratio of <c>new_bonus_score / old_bonus_score</c> for converting the bonus score of legacy scores to the new scoring.
|
|
||||||
/// This is made up of all judgements that would be <see cref="HitResult.SmallBonus"/> or <see cref="HitResult.LargeBonus"/>.
|
|
||||||
/// </summary>
|
|
||||||
public double LegacyBonusScoreRatio { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates new <see cref="DifficultyAttributes"/>.
|
/// Creates new <see cref="DifficultyAttributes"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -18,17 +18,16 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
public override LocalisableString Description => "Everything just got a bit harder...";
|
public override LocalisableString Description => "Everything just got a bit harder...";
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModDifficultyAdjust) };
|
public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModDifficultyAdjust) };
|
||||||
|
|
||||||
|
protected const float ADJUST_RATIO = 1.4f;
|
||||||
|
|
||||||
public void ReadFromDifficulty(IBeatmapDifficultyInfo difficulty)
|
public void ReadFromDifficulty(IBeatmapDifficultyInfo difficulty)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ApplyToDifficulty(BeatmapDifficulty difficulty)
|
public virtual void ApplyToDifficulty(BeatmapDifficulty difficulty)
|
||||||
{
|
{
|
||||||
const float ratio = 1.4f;
|
difficulty.DrainRate = Math.Min(difficulty.DrainRate * ADJUST_RATIO, 10.0f);
|
||||||
difficulty.CircleSize = Math.Min(difficulty.CircleSize * 1.3f, 10.0f); // CS uses a custom 1.3 ratio.
|
difficulty.OverallDifficulty = Math.Min(difficulty.OverallDifficulty * ADJUST_RATIO, 10.0f);
|
||||||
difficulty.ApproachRate = Math.Min(difficulty.ApproachRate * ratio, 10.0f);
|
|
||||||
difficulty.DrainRate = Math.Min(difficulty.DrainRate * ratio, 10.0f);
|
|
||||||
difficulty.OverallDifficulty = Math.Min(difficulty.OverallDifficulty * ratio, 10.0f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,7 +500,11 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
{
|
{
|
||||||
if (beatmaps.QueryBeatmap(b => b.OnlineID == beatmap.OnlineID) is BeatmapInfo local && !local.BeatmapSet.AsNonNull().DeletePending)
|
if (beatmaps.QueryBeatmap(b => b.OnlineID == beatmap.OnlineID) is BeatmapInfo local && !local.BeatmapSet.AsNonNull().DeletePending)
|
||||||
{
|
{
|
||||||
var collectionItems = realm.Realm.All<BeatmapCollection>().AsEnumerable().Select(c => new CollectionToggleMenuItem(c.ToLive(realm), beatmap)).Cast<OsuMenuItem>().ToList();
|
var collectionItems = realm.Realm.All<BeatmapCollection>()
|
||||||
|
.OrderBy(c => c.Name)
|
||||||
|
.AsEnumerable()
|
||||||
|
.Select(c => new CollectionToggleMenuItem(c.ToLive(realm), beatmap)).Cast<OsuMenuItem>().ToList();
|
||||||
|
|
||||||
if (manageCollectionsDialog != null)
|
if (manageCollectionsDialog != null)
|
||||||
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, manageCollectionsDialog.Show));
|
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, manageCollectionsDialog.Show));
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
sampleJoinFail = audio.Samples.Get(@"UI/password-fail");
|
sampleJoinFail = audio.Samples.Get(@"UI/generic-error");
|
||||||
|
|
||||||
joinButton.Action = performJoin;
|
joinButton.Action = performJoin;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using osu.Framework.Extensions.ObjectExtensions;
|
|||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Screens.OnlinePlay.Components;
|
using osu.Game.Screens.OnlinePlay.Components;
|
||||||
using osu.Game.Screens.OnlinePlay.Lounge;
|
using osu.Game.Screens.OnlinePlay.Lounge;
|
||||||
|
|
||||||
@ -90,6 +91,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
|
|
||||||
protected override LoungeSubScreen CreateLounge() => new MultiplayerLoungeSubScreen();
|
protected override LoungeSubScreen CreateLounge() => new MultiplayerLoungeSubScreen();
|
||||||
|
|
||||||
|
public void Join(Room room, string? password) => Schedule(() => Lounge.Join(room, password));
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
@ -26,14 +26,17 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
[Cached]
|
[Cached]
|
||||||
protected readonly OverlayColourProvider ColourProvider = new OverlayColourProvider(OverlayColourScheme.Plum);
|
protected readonly OverlayColourProvider ColourProvider = new OverlayColourProvider(OverlayColourScheme.Plum);
|
||||||
|
|
||||||
|
public IScreen CurrentSubScreen => screenStack.CurrentScreen;
|
||||||
|
|
||||||
public override bool CursorVisible => (screenStack?.CurrentScreen as IOnlinePlaySubScreen)?.CursorVisible ?? true;
|
public override bool CursorVisible => (screenStack?.CurrentScreen as IOnlinePlaySubScreen)?.CursorVisible ?? true;
|
||||||
|
|
||||||
// this is required due to PlayerLoader eventually being pushed to the main stack
|
// this is required due to PlayerLoader eventually being pushed to the main stack
|
||||||
// while leases may be taken out by a subscreen.
|
// while leases may be taken out by a subscreen.
|
||||||
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
||||||
|
|
||||||
|
protected LoungeSubScreen Lounge { get; private set; }
|
||||||
|
|
||||||
private MultiplayerWaveContainer waves;
|
private MultiplayerWaveContainer waves;
|
||||||
private LoungeSubScreen loungeSubScreen;
|
|
||||||
private ScreenStack screenStack;
|
private ScreenStack screenStack;
|
||||||
|
|
||||||
[Cached(Type = typeof(IRoomManager))]
|
[Cached(Type = typeof(IRoomManager))]
|
||||||
@ -89,7 +92,7 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
screenStack.ScreenPushed += screenPushed;
|
screenStack.ScreenPushed += screenPushed;
|
||||||
screenStack.ScreenExited += screenExited;
|
screenStack.ScreenExited += screenExited;
|
||||||
|
|
||||||
screenStack.Push(loungeSubScreen = CreateLounge());
|
screenStack.Push(Lounge = CreateLounge());
|
||||||
|
|
||||||
apiState.BindTo(API.State);
|
apiState.BindTo(API.State);
|
||||||
apiState.BindValueChanged(onlineStateChanged, true);
|
apiState.BindValueChanged(onlineStateChanged, true);
|
||||||
@ -120,10 +123,10 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
|
|
||||||
Mods.SetDefault();
|
Mods.SetDefault();
|
||||||
|
|
||||||
if (loungeSubScreen.IsCurrentScreen())
|
if (Lounge.IsCurrentScreen())
|
||||||
loungeSubScreen.OnEntering(e);
|
Lounge.OnEntering(e);
|
||||||
else
|
else
|
||||||
loungeSubScreen.MakeCurrent();
|
Lounge.MakeCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnResuming(ScreenTransitionEvent e)
|
public override void OnResuming(ScreenTransitionEvent e)
|
||||||
@ -224,8 +227,6 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
((IBindable<UserActivity>)Activity).BindTo(newOsuScreen.Activity);
|
((IBindable<UserActivity>)Activity).BindTo(newOsuScreen.Activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IScreen CurrentSubScreen => screenStack.CurrentScreen;
|
|
||||||
|
|
||||||
protected abstract string ScreenTitle { get; }
|
protected abstract string ScreenTitle { get; }
|
||||||
|
|
||||||
protected virtual RoomManager CreateRoomManager() => new RoomManager();
|
protected virtual RoomManager CreateRoomManager() => new RoomManager();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// 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 osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
@ -78,22 +79,25 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
if (PlayInitialIncreaseAnimation)
|
if (PlayInitialIncreaseAnimation)
|
||||||
startInitialAnimation();
|
startInitialAnimation();
|
||||||
else
|
else
|
||||||
Current.Value = 1;
|
Current.Value = health.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startInitialAnimation()
|
private void startInitialAnimation()
|
||||||
{
|
{
|
||||||
|
if (Current.Value >= health.Value)
|
||||||
|
return;
|
||||||
|
|
||||||
// TODO: this should run in gameplay time, including showing a larger increase when skipping.
|
// TODO: this should run in gameplay time, including showing a larger increase when skipping.
|
||||||
// TODO: it should also start increasing relative to the first hitobject.
|
// TODO: it should also start increasing relative to the first hitobject.
|
||||||
const double increase_delay = 150;
|
const double increase_delay = 150;
|
||||||
|
|
||||||
initialIncrease = Scheduler.AddDelayed(() =>
|
initialIncrease = Scheduler.AddDelayed(() =>
|
||||||
{
|
{
|
||||||
double newValue = Current.Value + 0.05f;
|
double newValue = Math.Min(Current.Value + 0.05f, health.Value);
|
||||||
this.TransformBindableTo(Current, newValue, increase_delay);
|
this.TransformBindableTo(Current, newValue, increase_delay);
|
||||||
Scheduler.AddOnce(Flash);
|
Scheduler.AddOnce(Flash);
|
||||||
|
|
||||||
if (newValue >= 1)
|
if (newValue >= health.Value)
|
||||||
finishInitialAnimation();
|
finishInitialAnimation();
|
||||||
}, increase_delay, true);
|
}, increase_delay, true);
|
||||||
}
|
}
|
||||||
|
@ -279,8 +279,10 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
if (!this.IsCurrentScreen()) return;
|
if (!this.IsCurrentScreen()) return;
|
||||||
|
|
||||||
|
if (PerformExit(false))
|
||||||
|
// The hotkey overlay dims the screen.
|
||||||
|
// If the operation succeeds, we want to make sure we stay dimmed to keep continuity.
|
||||||
fadeOut(true);
|
fadeOut(true);
|
||||||
PerformExit(false);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -298,8 +300,10 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
if (!this.IsCurrentScreen()) return;
|
if (!this.IsCurrentScreen()) return;
|
||||||
|
|
||||||
|
if (Restart(true))
|
||||||
|
// The hotkey overlay dims the screen.
|
||||||
|
// If the operation succeeds, we want to make sure we stay dimmed to keep continuity.
|
||||||
fadeOut(true);
|
fadeOut(true);
|
||||||
Restart(true);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -565,20 +569,9 @@ namespace osu.Game.Screens.Play
|
|||||||
/// Whether the pause or fail dialog should be shown before performing an exit.
|
/// Whether the pause or fail dialog should be shown before performing an exit.
|
||||||
/// If <see langword="true"/> and a dialog is not yet displayed, the exit will be blocked and the relevant dialog will display instead.
|
/// If <see langword="true"/> and a dialog is not yet displayed, the exit will be blocked and the relevant dialog will display instead.
|
||||||
/// </param>
|
/// </param>
|
||||||
protected void PerformExit(bool showDialogFirst)
|
/// <returns>Whether this call resulted in a final exit.</returns>
|
||||||
|
protected bool PerformExit(bool showDialogFirst)
|
||||||
{
|
{
|
||||||
// there is a chance that an exit request occurs after the transition to results has already started.
|
|
||||||
// even in such a case, the user has shown intent, so forcefully return to this screen (to proceed with the upwards exit process).
|
|
||||||
if (!this.IsCurrentScreen())
|
|
||||||
{
|
|
||||||
ValidForResume = false;
|
|
||||||
|
|
||||||
// in the potential case that this instance has already been exited, this is required to avoid a crash.
|
|
||||||
if (this.GetChildScreen() != null)
|
|
||||||
this.MakeCurrent();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool pauseOrFailDialogVisible =
|
bool pauseOrFailDialogVisible =
|
||||||
PauseOverlay.State.Value == Visibility.Visible || FailOverlay.State.Value == Visibility.Visible;
|
PauseOverlay.State.Value == Visibility.Visible || FailOverlay.State.Value == Visibility.Visible;
|
||||||
|
|
||||||
@ -588,7 +581,7 @@ namespace osu.Game.Screens.Play
|
|||||||
if (ValidForResume && GameplayState.HasFailed)
|
if (ValidForResume && GameplayState.HasFailed)
|
||||||
{
|
{
|
||||||
failAnimationContainer.FinishTransforms(true);
|
failAnimationContainer.FinishTransforms(true);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// even if this call has requested a dialog, there is a chance the current player mode doesn't support pausing.
|
// even if this call has requested a dialog, there is a chance the current player mode doesn't support pausing.
|
||||||
@ -597,16 +590,24 @@ namespace osu.Game.Screens.Play
|
|||||||
// in the case a dialog needs to be shown, attempt to pause and show it.
|
// in the case a dialog needs to be shown, attempt to pause and show it.
|
||||||
// this may fail (see internal checks in Pause()) but the fail cases are temporary, so don't fall through to Exit().
|
// this may fail (see internal checks in Pause()) but the fail cases are temporary, so don't fall through to Exit().
|
||||||
Pause();
|
Pause();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if an exit has been requested, cancel any pending completion (the user has shown intention to exit).
|
// Matching osu!stable behaviour, if the results screen is pending and the user requests an exit,
|
||||||
resultsDisplayDelegate?.Cancel();
|
// show the results instead.
|
||||||
|
if (GameplayState.HasPassed && !isRestarting)
|
||||||
|
{
|
||||||
|
progressToResults(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// import current score if possible.
|
// import current score if possible.
|
||||||
prepareAndImportScoreAsync();
|
prepareAndImportScoreAsync();
|
||||||
|
|
||||||
|
// Screen may not be current if a restart has been performed.
|
||||||
|
if (this.IsCurrentScreen())
|
||||||
|
{
|
||||||
// The actual exit is performed if
|
// The actual exit is performed if
|
||||||
// - the pause / fail dialog was not requested
|
// - the pause / fail dialog was not requested
|
||||||
// - the pause / fail dialog was requested but is already displayed (user showing intention to exit).
|
// - the pause / fail dialog was requested but is already displayed (user showing intention to exit).
|
||||||
@ -614,6 +615,9 @@ namespace osu.Game.Screens.Play
|
|||||||
this.Exit();
|
this.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void performUserRequestedSkip()
|
private void performUserRequestedSkip()
|
||||||
{
|
{
|
||||||
// user requested skip
|
// user requested skip
|
||||||
@ -660,10 +664,11 @@ namespace osu.Game.Screens.Play
|
|||||||
/// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks>
|
/// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="quickRestart">Whether a quick restart was requested (skipping intro etc.).</param>
|
/// <param name="quickRestart">Whether a quick restart was requested (skipping intro etc.).</param>
|
||||||
public void Restart(bool quickRestart = false)
|
/// <returns>Whether this call resulted in a restart.</returns>
|
||||||
|
public bool Restart(bool quickRestart = false)
|
||||||
{
|
{
|
||||||
if (!Configuration.AllowRestart)
|
if (!Configuration.AllowRestart)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
isRestarting = true;
|
isRestarting = true;
|
||||||
|
|
||||||
@ -673,7 +678,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
RestartRequested?.Invoke(quickRestart);
|
RestartRequested?.Invoke(quickRestart);
|
||||||
|
|
||||||
PerformExit(false);
|
return PerformExit(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -729,9 +734,6 @@ namespace osu.Game.Screens.Play
|
|||||||
// is no chance that a user could return to the (already completed) Player instance from a child screen.
|
// is no chance that a user could return to the (already completed) Player instance from a child screen.
|
||||||
ValidForResume = false;
|
ValidForResume = false;
|
||||||
|
|
||||||
if (!Configuration.ShowResults)
|
|
||||||
return;
|
|
||||||
|
|
||||||
bool storyboardStillRunning = DimmableStoryboard.ContentDisplayed && !DimmableStoryboard.HasStoryboardEnded.Value;
|
bool storyboardStillRunning = DimmableStoryboard.ContentDisplayed && !DimmableStoryboard.HasStoryboardEnded.Value;
|
||||||
|
|
||||||
// If the current beatmap has a storyboard, this method will be called again on storyboard completion.
|
// If the current beatmap has a storyboard, this method will be called again on storyboard completion.
|
||||||
@ -754,10 +756,16 @@ namespace osu.Game.Screens.Play
|
|||||||
/// <param name="withDelay">Whether a minimum delay (<see cref="RESULTS_DISPLAY_DELAY"/>) should be added before the screen is displayed.</param>
|
/// <param name="withDelay">Whether a minimum delay (<see cref="RESULTS_DISPLAY_DELAY"/>) should be added before the screen is displayed.</param>
|
||||||
private void progressToResults(bool withDelay)
|
private void progressToResults(bool withDelay)
|
||||||
{
|
{
|
||||||
resultsDisplayDelegate?.Cancel();
|
if (!Configuration.ShowResults)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Setting this early in the process means that even if something were to go wrong in the order of events following, there
|
||||||
|
// is no chance that a user could return to the (already completed) Player instance from a child screen.
|
||||||
|
ValidForResume = false;
|
||||||
|
|
||||||
double delay = withDelay ? RESULTS_DISPLAY_DELAY : 0;
|
double delay = withDelay ? RESULTS_DISPLAY_DELAY : 0;
|
||||||
|
|
||||||
|
resultsDisplayDelegate?.Cancel();
|
||||||
resultsDisplayDelegate = new ScheduledDelegate(() =>
|
resultsDisplayDelegate = new ScheduledDelegate(() =>
|
||||||
{
|
{
|
||||||
if (prepareScoreForDisplayTask == null)
|
if (prepareScoreForDisplayTask == null)
|
||||||
@ -1200,9 +1208,12 @@ namespace osu.Game.Screens.Play
|
|||||||
float fadeOutDuration = instant ? 0 : 250;
|
float fadeOutDuration = instant ? 0 : 250;
|
||||||
this.FadeOut(fadeOutDuration);
|
this.FadeOut(fadeOutDuration);
|
||||||
|
|
||||||
|
if (this.IsCurrentScreen())
|
||||||
|
{
|
||||||
ApplyToBackground(b => b.IgnoreUserSettings.Value = true);
|
ApplyToBackground(b => b.IgnoreUserSettings.Value = true);
|
||||||
storyboardReplacesBackground.Value = false;
|
storyboardReplacesBackground.Value = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -414,6 +414,8 @@ namespace osu.Game.Screens.Play
|
|||||||
quickRestart = quickRestartRequested;
|
quickRestart = quickRestartRequested;
|
||||||
hideOverlays = true;
|
hideOverlays = true;
|
||||||
ValidForResume = true;
|
ValidForResume = true;
|
||||||
|
|
||||||
|
this.MakeCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void contentIn()
|
private void contentIn()
|
||||||
|
@ -233,7 +233,11 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
if (beatmapInfo.OnlineID > 0 && beatmapOverlay != null)
|
if (beatmapInfo.OnlineID > 0 && beatmapOverlay != null)
|
||||||
items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => beatmapOverlay.FetchAndShowBeatmap(beatmapInfo.OnlineID)));
|
items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => beatmapOverlay.FetchAndShowBeatmap(beatmapInfo.OnlineID)));
|
||||||
|
|
||||||
var collectionItems = realm.Realm.All<BeatmapCollection>().AsEnumerable().Select(c => new CollectionToggleMenuItem(c.ToLive(realm), beatmapInfo)).Cast<OsuMenuItem>().ToList();
|
var collectionItems = realm.Realm.All<BeatmapCollection>()
|
||||||
|
.OrderBy(c => c.Name)
|
||||||
|
.AsEnumerable()
|
||||||
|
.Select(c => new CollectionToggleMenuItem(c.ToLive(realm), beatmapInfo)).Cast<OsuMenuItem>().ToList();
|
||||||
|
|
||||||
if (manageCollectionsDialog != null)
|
if (manageCollectionsDialog != null)
|
||||||
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, manageCollectionsDialog.Show));
|
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, manageCollectionsDialog.Show));
|
||||||
|
|
||||||
|
@ -225,7 +225,12 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
if (beatmapSet.OnlineID > 0 && viewDetails != null)
|
if (beatmapSet.OnlineID > 0 && viewDetails != null)
|
||||||
items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => viewDetails(beatmapSet.OnlineID)));
|
items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => viewDetails(beatmapSet.OnlineID)));
|
||||||
|
|
||||||
var collectionItems = realm.Realm.All<BeatmapCollection>().AsEnumerable().Select(createCollectionMenuItem).ToList();
|
var collectionItems = realm.Realm.All<BeatmapCollection>()
|
||||||
|
.OrderBy(c => c.Name)
|
||||||
|
.AsEnumerable()
|
||||||
|
.Select(createCollectionMenuItem)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
if (manageCollectionsDialog != null)
|
if (manageCollectionsDialog != null)
|
||||||
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, manageCollectionsDialog.Show));
|
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, manageCollectionsDialog.Show));
|
||||||
|
|
||||||
|
@ -263,6 +263,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Task InvitePlayer(int userId)
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
public override Task TransferHost(int userId)
|
public override Task TransferHost(int userId)
|
||||||
{
|
{
|
||||||
userId = clone(userId);
|
userId = clone(userId);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -18,6 +19,7 @@ using osu.Game.Online.API.Requests.Responses;
|
|||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
|
|
||||||
namespace osu.Game.Users
|
namespace osu.Game.Users
|
||||||
{
|
{
|
||||||
@ -61,6 +63,9 @@ namespace osu.Game.Users
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
protected OsuColour Colours { get; private set; } = null!;
|
protected OsuColour Colours { get; private set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private MultiplayerClient? multiplayerClient { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -117,6 +122,16 @@ namespace osu.Game.Users
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
// TODO: uncomment this once lazer / osu-web is updating online states
|
||||||
|
// User.IsOnline &&
|
||||||
|
multiplayerClient?.Room != null &&
|
||||||
|
multiplayerClient.Room.Users.All(u => u.UserID != User.Id)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
items.Add(new OsuMenuItem(ContextMenuStrings.InvitePlayer, MenuItemType.Standard, () => multiplayerClient.InvitePlayer(User.Id)));
|
||||||
|
}
|
||||||
|
|
||||||
return items.ToArray();
|
return items.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,13 @@
|
|||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="AutoMapper" Version="12.0.1" />
|
<PackageReference Include="AutoMapper" Version="12.0.1" />
|
||||||
<PackageReference Include="DiffPlex" Version="1.7.1" />
|
<PackageReference Include="DiffPlex" Version="1.7.1" />
|
||||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.53" />
|
<PackageReference Include="HtmlAgilityPack" Version="1.11.54" />
|
||||||
<PackageReference Include="Humanizer" Version="2.14.1" />
|
<PackageReference Include="Humanizer" Version="2.14.1" />
|
||||||
<PackageReference Include="MessagePack" Version="2.5.124" />
|
<PackageReference Include="MessagePack" Version="2.5.129" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.11" />
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.12" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="7.0.11" />
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="7.0.12" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="7.0.11" />
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="7.0.12" />
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="7.0.11" />
|
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="7.0.12" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Toolkit.HighPerformance" Version="7.1.2" />
|
<PackageReference Include="Microsoft.Toolkit.HighPerformance" Version="7.1.2" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
@ -37,9 +37,9 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Realm" Version="11.5.0" />
|
<PackageReference Include="Realm" Version="11.5.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2023.1012.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2023.1012.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.1003.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.1014.0" />
|
||||||
<PackageReference Include="Sentry" Version="3.39.1" />
|
<PackageReference Include="Sentry" Version="3.40.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.33.0" />
|
<PackageReference Include="SharpCompress" Version="0.34.1" />
|
||||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||||
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.6" />
|
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.6" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
|
Loading…
Reference in New Issue
Block a user