mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 10:03:05 +08:00
Merge branch 'master' into beatmap-card/extra-wip
This commit is contained in:
commit
c6d0b5d200
@ -27,10 +27,10 @@
|
||||
]
|
||||
},
|
||||
"ppy.localisationanalyser.tools": {
|
||||
"version": "2021.725.0",
|
||||
"version": "2021.1210.0",
|
||||
"commands": [
|
||||
"localisation"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Contributing Guidelines
|
||||
|
||||
Thank you for showing interest in the development of osu!lazer! We aim to provide a good collaborating environment for everyone involved, and as such have decided to list some of the most important things to keep in mind in the process. The guidelines below have been chosen based on past experience.
|
||||
Thank you for showing interest in the development of osu!. We aim to provide a good collaborating environment for everyone involved, and as such have decided to list some of the most important things to keep in mind in the process. The guidelines below have been chosen based on past experience.
|
||||
|
||||
These are not "official rules" *per se*, but following them will help everyone deal with things in the most efficient manner.
|
||||
|
||||
@ -32,7 +32,7 @@ Issues, bug reports and feature suggestions are welcomed, though please keep in
|
||||
|
||||
* **Provide more information when asked to do so.**
|
||||
|
||||
Sometimes when a bug is more elusive or complicated, none of the information listed above will pinpoint a concrete cause of the problem. In this case we will most likely ask you for additional info, such as a Windows Event Log dump or a copy of your local lazer database (`client.db`). Providing that information is beneficial to both parties - we can track down the problem better, and hopefully fix it for you at some point once we know where it is!
|
||||
Sometimes when a bug is more elusive or complicated, none of the information listed above will pinpoint a concrete cause of the problem. In this case we will most likely ask you for additional info, such as a Windows Event Log dump or a copy of your local osu! database (`client.db`). Providing that information is beneficial to both parties - we can track down the problem better, and hopefully fix it for you at some point once we know where it is!
|
||||
|
||||
* **When submitting a feature proposal, please describe it in the most understandable way you can.**
|
||||
|
||||
@ -54,7 +54,7 @@ Issues, bug reports and feature suggestions are welcomed, though please keep in
|
||||
|
||||
We also welcome pull requests from unaffiliated contributors. The [issue tracker](https://github.com/ppy/osu/issues) should provide plenty of issues that you can work on; we also mark issues that we think would be good for newcomers with the [`good-first-issue`](https://github.com/ppy/osu/issues?q=is%3Aissue+is%3Aopen+label%3Agood-first-issue) label.
|
||||
|
||||
However, do keep in mind that the core team is committed to bringing osu!lazer up to par with stable first and foremost, so depending on what your contribution concerns, it might not be merged and released right away. Our approach to managing issues and their priorities is described [in the wiki](https://github.com/ppy/osu/wiki/Project-management).
|
||||
However, do keep in mind that the core team is committed to bringing osu!(lazer) up to par with osu!(stable) first and foremost, so depending on what your contribution concerns, it might not be merged and released right away. Our approach to managing issues and their priorities is described [in the wiki](https://github.com/ppy/osu/wiki/Project-management).
|
||||
|
||||
Here are some key things to note before jumping in:
|
||||
|
||||
@ -128,7 +128,7 @@ Here are some key things to note before jumping in:
|
||||
|
||||
* **Don't mistake criticism of code for criticism of your person.**
|
||||
|
||||
As mentioned before, we are highly committed to quality when it comes to the lazer project. This means that contributions from less experienced community members can take multiple rounds of review to get to a mergeable state. We try our utmost best to never conflate a person with the code they authored, and to keep the discussion focused on the code at all times. Please consider our comments and requests a learning experience, and don't treat it as a personal attack.
|
||||
As mentioned before, we are highly committed to quality when it comes to the osu! project. This means that contributions from less experienced community members can take multiple rounds of review to get to a mergeable state. We try our utmost best to never conflate a person with the code they authored, and to keep the discussion focused on the code at all times. Please consider our comments and requests a learning experience, and don't treat it as a personal attack.
|
||||
|
||||
* **Feel free to reach out for help.**
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
A free-to-win rhythm game. Rhythm is just a *click* away!
|
||||
|
||||
The future of [osu!](https://osu.ppy.sh) and the beginning of an open era! Currently known by and released under the codename "*lazer*". As in sharper than cutting-edge.
|
||||
The future of [osu!](https://osu.ppy.sh) and the beginning of an open era! Currently known by and released under the release codename "*lazer*". As in sharper than cutting-edge.
|
||||
|
||||
## Status
|
||||
|
||||
|
@ -51,8 +51,8 @@
|
||||
<Reference Include="Java.Interop" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.1203.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.1207.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.1215.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.1217.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Transitive Dependencies">
|
||||
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->
|
||||
|
@ -70,7 +70,9 @@ namespace osu.Desktop
|
||||
if (!string.IsNullOrEmpty(stableInstallPath) && checkExists(stableInstallPath))
|
||||
return stableInstallPath;
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"osu!");
|
||||
@ -113,7 +115,7 @@ namespace osu.Desktop
|
||||
base.LoadComplete();
|
||||
|
||||
if (!noVersionOverlay)
|
||||
LoadComponentAsync(versionManager = new VersionManager { Depth = int.MinValue }, Add);
|
||||
LoadComponentAsync(versionManager = new VersionManager { Depth = int.MinValue }, ScreenContainer.Add);
|
||||
|
||||
LoadComponentAsync(new DiscordRichPresence(), Add);
|
||||
|
||||
|
@ -90,7 +90,6 @@ namespace osu.Desktop
|
||||
Logger.Log("Starting legacy IPC provider...");
|
||||
legacyIpc = new LegacyTcpIpcProvider();
|
||||
legacyIpc.Bind();
|
||||
legacyIpc.StartAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -27,6 +27,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
[TestCase("hardrock-repeat-slider", new[] { typeof(CatchModHardRock) })]
|
||||
[TestCase("hardrock-spinner", new[] { typeof(CatchModHardRock) })]
|
||||
[TestCase("right-bound-hr-offset", new[] { typeof(CatchModHardRock) })]
|
||||
[TestCase("basic-hyperdash")]
|
||||
public new void Test(string name, params Type[] mods) => base.Test(name, mods);
|
||||
|
||||
protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject)
|
||||
@ -70,6 +71,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
HitObject = hitObject;
|
||||
startTime = 0;
|
||||
position = 0;
|
||||
hyperDash = false;
|
||||
}
|
||||
|
||||
private double startTime;
|
||||
@ -88,8 +90,17 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
set => position = value;
|
||||
}
|
||||
|
||||
private bool hyperDash;
|
||||
|
||||
public bool HyperDash
|
||||
{
|
||||
get => (HitObject as PalpableCatchHitObject)?.HyperDash ?? hyperDash;
|
||||
set => hyperDash = value;
|
||||
}
|
||||
|
||||
public bool Equals(ConvertValue other)
|
||||
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
|
||||
&& Precision.AlmostEquals(Position, other.Position, conversion_lenience);
|
||||
&& Precision.AlmostEquals(Position, other.Position, conversion_lenience)
|
||||
&& HyperDash == other.HyperDash;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,19 @@
|
||||
{
|
||||
"Mappings": [{
|
||||
"StartTime": 369,
|
||||
"Objects": [{
|
||||
"StartTime": 369,
|
||||
"Position": 0,
|
||||
"HyperDash": true
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 450,
|
||||
"Objects": [{
|
||||
"StartTime": 450,
|
||||
"Position": 512,
|
||||
"HyperDash": false
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
osu file format v14
|
||||
|
||||
[General]
|
||||
StackLeniency: 0.7
|
||||
Mode: 2
|
||||
|
||||
[Difficulty]
|
||||
HPDrainRate:6
|
||||
CircleSize:4
|
||||
OverallDifficulty:9.6
|
||||
ApproachRate:9.6
|
||||
SliderMultiplier:1.9
|
||||
SliderTickRate:1
|
||||
|
||||
[TimingPoints]
|
||||
2169,266.666666666667,4,2,1,70,1,0
|
||||
|
||||
|
||||
[HitObjects]
|
||||
0,192,369,1,0,0:0:0:0:
|
||||
512,192,450,1,0,0:0:0:0:
|
@ -3,147 +3,183 @@
|
||||
"StartTime": 369,
|
||||
"Objects": [{
|
||||
"StartTime": 369,
|
||||
"Position": 177
|
||||
"Position": 177,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 450,
|
||||
"Position": 216.539276
|
||||
"Position": 216.539276,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 532,
|
||||
"Position": 256.5667
|
||||
"Position": 256.5667,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 614,
|
||||
"Position": 296.594116
|
||||
"Position": 296.594116,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 696,
|
||||
"Position": 336.621521
|
||||
"Position": 336.621521,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 778,
|
||||
"Position": 376.99762
|
||||
"Position": 376.99762,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 860,
|
||||
"Position": 337.318878
|
||||
"Position": 337.318878,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 942,
|
||||
"Position": 297.291443
|
||||
"Position": 297.291443,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1024,
|
||||
"Position": 257.264038
|
||||
"Position": 257.264038,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1106,
|
||||
"Position": 217.2366
|
||||
"Position": 217.2366,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1188,
|
||||
"Position": 177
|
||||
"Position": 177,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1270,
|
||||
"Position": 216.818192
|
||||
"Position": 216.818192,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1352,
|
||||
"Position": 256.8456
|
||||
"Position": 256.8456,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1434,
|
||||
"Position": 296.873047
|
||||
"Position": 296.873047,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1516,
|
||||
"Position": 336.900452
|
||||
"Position": 336.900452,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1598,
|
||||
"Position": 376.99762
|
||||
"Position": 376.99762,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1680,
|
||||
"Position": 337.039948
|
||||
"Position": 337.039948,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1762,
|
||||
"Position": 297.0125
|
||||
"Position": 297.0125,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1844,
|
||||
"Position": 256.9851
|
||||
"Position": 256.9851,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1926,
|
||||
"Position": 216.957672
|
||||
"Position": 216.957672,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 2008,
|
||||
"Position": 177
|
||||
"Position": 177,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 2090,
|
||||
"Position": 217.097137
|
||||
"Position": 217.097137,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 2172,
|
||||
"Position": 257.124573
|
||||
"Position": 257.124573,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 2254,
|
||||
"Position": 297.152
|
||||
"Position": 297.152,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 2336,
|
||||
"Position": 337.179443
|
||||
"Position": 337.179443,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 2418,
|
||||
"Position": 376.99762
|
||||
"Position": 376.99762,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 2500,
|
||||
"Position": 336.760956
|
||||
"Position": 336.760956,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 2582,
|
||||
"Position": 296.733643
|
||||
"Position": 296.733643,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 2664,
|
||||
"Position": 256.7062
|
||||
"Position": 256.7062,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 2746,
|
||||
"Position": 216.678772
|
||||
"Position": 216.678772,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 2828,
|
||||
"Position": 177
|
||||
"Position": 177,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 2909,
|
||||
"Position": 216.887909
|
||||
"Position": 216.887909,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 2991,
|
||||
"Position": 256.915344
|
||||
"Position": 256.915344,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 3073,
|
||||
"Position": 296.942749
|
||||
"Position": 296.942749,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 3155,
|
||||
"Position": 336.970184
|
||||
"Position": 336.970184,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 3237,
|
||||
"Position": 376.99762
|
||||
"Position": 376.99762,
|
||||
"HyperDash": false
|
||||
}
|
||||
]
|
||||
}]
|
||||
|
@ -3,71 +3,88 @@
|
||||
"StartTime": 369,
|
||||
"Objects": [{
|
||||
"StartTime": 369,
|
||||
"Position": 65
|
||||
"Position": 65,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 450,
|
||||
"Position": 482
|
||||
"Position": 482,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 532,
|
||||
"Position": 164
|
||||
"Position": 164,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 614,
|
||||
"Position": 315
|
||||
"Position": 315,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 696,
|
||||
"Position": 145
|
||||
"Position": 145,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 778,
|
||||
"Position": 159
|
||||
"Position": 159,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 860,
|
||||
"Position": 310
|
||||
"Position": 310,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 942,
|
||||
"Position": 441
|
||||
"Position": 441,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1024,
|
||||
"Position": 428
|
||||
"Position": 428,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1106,
|
||||
"Position": 243
|
||||
"Position": 243,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1188,
|
||||
"Position": 422
|
||||
"Position": 422,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1270,
|
||||
"Position": 481
|
||||
"Position": 481,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1352,
|
||||
"Position": 104
|
||||
"Position": 104,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1434,
|
||||
"Position": 473
|
||||
"Position": 473,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1516,
|
||||
"Position": 135
|
||||
"Position": 135,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1598,
|
||||
"Position": 360
|
||||
"Position": 360,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 1680,
|
||||
"Position": 123
|
||||
"Position": 123,
|
||||
"HyperDash": false
|
||||
}
|
||||
]
|
||||
}]
|
||||
|
@ -3,231 +3,264 @@
|
||||
"StartTime": 369,
|
||||
"Objects": [{
|
||||
"StartTime": 369,
|
||||
"Position": 258
|
||||
"Position": 258,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 450,
|
||||
"Objects": [{
|
||||
"StartTime": 450,
|
||||
"Position": 254
|
||||
"Position": 254,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 532,
|
||||
"Objects": [{
|
||||
"StartTime": 532,
|
||||
"Position": 241
|
||||
"Position": 241,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 614,
|
||||
"Objects": [{
|
||||
"StartTime": 614,
|
||||
"Position": 238
|
||||
"Position": 238,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 696,
|
||||
"Objects": [{
|
||||
"StartTime": 696,
|
||||
"Position": 238
|
||||
"Position": 238,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 778,
|
||||
"Objects": [{
|
||||
"StartTime": 778,
|
||||
"Position": 278
|
||||
"Position": 278,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 860,
|
||||
"Objects": [{
|
||||
"StartTime": 860,
|
||||
"Position": 238
|
||||
"Position": 238,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 942,
|
||||
"Objects": [{
|
||||
"StartTime": 942,
|
||||
"Position": 278
|
||||
"Position": 278,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 1024,
|
||||
"Objects": [{
|
||||
"StartTime": 1024,
|
||||
"Position": 238
|
||||
"Position": 238,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 1106,
|
||||
"Objects": [{
|
||||
"StartTime": 1106,
|
||||
"Position": 278
|
||||
"Position": 278,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 1188,
|
||||
"Objects": [{
|
||||
"StartTime": 1188,
|
||||
"Position": 278
|
||||
"Position": 278,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 1270,
|
||||
"Objects": [{
|
||||
"StartTime": 1270,
|
||||
"Position": 278
|
||||
"Position": 278,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 1352,
|
||||
"Objects": [{
|
||||
"StartTime": 1352,
|
||||
"Position": 238
|
||||
"Position": 238,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 1434,
|
||||
"Objects": [{
|
||||
"StartTime": 1434,
|
||||
"Position": 258
|
||||
"Position": 258,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 1516,
|
||||
"Objects": [{
|
||||
"StartTime": 1516,
|
||||
"Position": 253
|
||||
"Position": 253,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 1598,
|
||||
"Objects": [{
|
||||
"StartTime": 1598,
|
||||
"Position": 238
|
||||
"Position": 238,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 1680,
|
||||
"Objects": [{
|
||||
"StartTime": 1680,
|
||||
"Position": 260
|
||||
"Position": 260,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 1762,
|
||||
"Objects": [{
|
||||
"StartTime": 1762,
|
||||
"Position": 238
|
||||
"Position": 238,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 1844,
|
||||
"Objects": [{
|
||||
"StartTime": 1844,
|
||||
"Position": 278
|
||||
"Position": 278,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 1926,
|
||||
"Objects": [{
|
||||
"StartTime": 1926,
|
||||
"Position": 278
|
||||
"Position": 278,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 2008,
|
||||
"Objects": [{
|
||||
"StartTime": 2008,
|
||||
"Position": 238
|
||||
"Position": 238,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 2090,
|
||||
"Objects": [{
|
||||
"StartTime": 2090,
|
||||
"Position": 238
|
||||
"Position": 238,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 2172,
|
||||
"Objects": [{
|
||||
"StartTime": 2172,
|
||||
"Position": 243
|
||||
"Position": 243,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 2254,
|
||||
"Objects": [{
|
||||
"StartTime": 2254,
|
||||
"Position": 278
|
||||
"Position": 278,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 2336,
|
||||
"Objects": [{
|
||||
"StartTime": 2336,
|
||||
"Position": 278
|
||||
"Position": 278,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 2418,
|
||||
"Objects": [{
|
||||
"StartTime": 2418,
|
||||
"Position": 238
|
||||
"Position": 238,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 2500,
|
||||
"Objects": [{
|
||||
"StartTime": 2500,
|
||||
"Position": 258
|
||||
"Position": 258,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 2582,
|
||||
"Objects": [{
|
||||
"StartTime": 2582,
|
||||
"Position": 256
|
||||
"Position": 256,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 2664,
|
||||
"Objects": [{
|
||||
"StartTime": 2664,
|
||||
"Position": 242
|
||||
"Position": 242,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 2746,
|
||||
"Objects": [{
|
||||
"StartTime": 2746,
|
||||
"Position": 238
|
||||
"Position": 238,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 2828,
|
||||
"Objects": [{
|
||||
"StartTime": 2828,
|
||||
"Position": 238
|
||||
"Position": 238,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 2909,
|
||||
"Objects": [{
|
||||
"StartTime": 2909,
|
||||
"Position": 271
|
||||
"Position": 271,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 2991,
|
||||
"Objects": [{
|
||||
"StartTime": 2991,
|
||||
"Position": 254
|
||||
"Position": 254,
|
||||
"HyperDash": false
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
@ -3,14 +3,16 @@
|
||||
"StartTime": 3368,
|
||||
"Objects": [{
|
||||
"StartTime": 3368,
|
||||
"Position": 374
|
||||
"Position": 374,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 3501,
|
||||
"Objects": [{
|
||||
"StartTime": 3501,
|
||||
"Position": 446
|
||||
"Position": 446,
|
||||
"HyperDash": false
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
@ -1 +1,71 @@
|
||||
{"Mappings":[{"StartTime":19184.0,"Objects":[{"StartTime":19184.0,"Position":320.0},{"StartTime":19263.0,"Position":311.730255},{"StartTime":19343.0,"Position":324.6205},{"StartTime":19423.0,"Position":343.0907},{"StartTime":19503.0,"Position":372.2917},{"StartTime":19582.0,"Position":385.194733},{"StartTime":19662.0,"Position":379.0426},{"StartTime":19742.0,"Position":385.1066},{"StartTime":19822.0,"Position":391.624664},{"StartTime":19919.0,"Position":386.27832},{"StartTime":20016.0,"Position":380.117035},{"StartTime":20113.0,"Position":381.664154},{"StartTime":20247.0,"Position":370.872864}]}]}
|
||||
{
|
||||
"Mappings": [{
|
||||
"StartTime": 19184,
|
||||
"Objects": [{
|
||||
"StartTime": 19184,
|
||||
"Position": 320,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19263,
|
||||
"Position": 311.730255,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19343,
|
||||
"Position": 324.6205,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19423,
|
||||
"Position": 343.0907,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19503,
|
||||
"Position": 372.2917,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19582,
|
||||
"Position": 385.194733,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19662,
|
||||
"Position": 379.0426,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19742,
|
||||
"Position": 385.1066,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19822,
|
||||
"Position": 391.624664,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19919,
|
||||
"Position": 386.27832,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 20016,
|
||||
"Position": 380.117035,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 20113,
|
||||
"Position": 381.664154,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 20247,
|
||||
"Position": 370.872864,
|
||||
"HyperDash": false
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
@ -3,18 +3,21 @@
|
||||
"StartTime": 2589,
|
||||
"Objects": [{
|
||||
"StartTime": 2589,
|
||||
"Position": 256
|
||||
"Position": 256,
|
||||
"HyperDash": false
|
||||
}]
|
||||
},
|
||||
{
|
||||
"StartTime": 2915,
|
||||
"Objects": [{
|
||||
"StartTime": 2915,
|
||||
"Position": 65
|
||||
"Position": 65,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 2916,
|
||||
"Position": 482
|
||||
"Position": 482,
|
||||
"HyperDash": false
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -22,11 +25,13 @@
|
||||
"StartTime": 3078,
|
||||
"Objects": [{
|
||||
"StartTime": 3078,
|
||||
"Position": 164
|
||||
"Position": 164,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 3079,
|
||||
"Position": 315
|
||||
"Position": 315,
|
||||
"HyperDash": false
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -34,11 +39,13 @@
|
||||
"StartTime": 3241,
|
||||
"Objects": [{
|
||||
"StartTime": 3241,
|
||||
"Position": 145
|
||||
"Position": 145,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 3242,
|
||||
"Position": 159
|
||||
"Position": 159,
|
||||
"HyperDash": false
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -46,11 +53,13 @@
|
||||
"StartTime": 3404,
|
||||
"Objects": [{
|
||||
"StartTime": 3404,
|
||||
"Position": 310
|
||||
"Position": 310,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 3405,
|
||||
"Position": 441
|
||||
"Position": 441,
|
||||
"HyperDash": false
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -58,7 +67,8 @@
|
||||
"StartTime": 5197,
|
||||
"Objects": [{
|
||||
"StartTime": 5197,
|
||||
"Position": 256
|
||||
"Position": 256,
|
||||
"HyperDash": false
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
@ -3,71 +3,88 @@
|
||||
"StartTime": 18500,
|
||||
"Objects": [{
|
||||
"StartTime": 18500,
|
||||
"Position": 65
|
||||
"Position": 65,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 18559,
|
||||
"Position": 482
|
||||
"Position": 482,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 18618,
|
||||
"Position": 164
|
||||
"Position": 164,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 18678,
|
||||
"Position": 315
|
||||
"Position": 315,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 18737,
|
||||
"Position": 145
|
||||
"Position": 145,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 18796,
|
||||
"Position": 159
|
||||
"Position": 159,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 18856,
|
||||
"Position": 310
|
||||
"Position": 310,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 18915,
|
||||
"Position": 441
|
||||
"Position": 441,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 18975,
|
||||
"Position": 428
|
||||
"Position": 428,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19034,
|
||||
"Position": 243
|
||||
"Position": 243,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19093,
|
||||
"Position": 422
|
||||
"Position": 422,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19153,
|
||||
"Position": 481
|
||||
"Position": 481,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19212,
|
||||
"Position": 104
|
||||
"Position": 104,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19271,
|
||||
"Position": 473
|
||||
"Position": 473,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19331,
|
||||
"Position": 135
|
||||
"Position": 135,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19390,
|
||||
"Position": 360
|
||||
"Position": 360,
|
||||
"HyperDash": false
|
||||
},
|
||||
{
|
||||
"StartTime": 19450,
|
||||
"Position": 123
|
||||
"Position": 123,
|
||||
"HyperDash": false
|
||||
}
|
||||
]
|
||||
}]
|
||||
|
@ -56,13 +56,13 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
[Test]
|
||||
public void TestDefaultSkin()
|
||||
{
|
||||
AddStep("set default skin", () => skins.CurrentSkinInfo.Value = DefaultSkin.CreateInfo().ToLive());
|
||||
AddStep("set default skin", () => skins.CurrentSkinInfo.Value = DefaultSkin.CreateInfo().ToLiveUnmanaged());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLegacySkin()
|
||||
{
|
||||
AddStep("set legacy skin", () => skins.CurrentSkinInfo.Value = DefaultLegacySkin.CreateInfo().ToLive());
|
||||
AddStep("set legacy skin", () => skins.CurrentSkinInfo.Value = DefaultLegacySkin.CreateInfo().ToLiveUnmanaged());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,49 +11,65 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
|
||||
{
|
||||
public class OsuDifficultyHitObject : DifficultyHitObject
|
||||
{
|
||||
private const int normalized_radius = 50; // Change radius to 50 to make 100 the diameter. Easier for mental maths.
|
||||
private const int normalised_radius = 50; // Change radius to 50 to make 100 the diameter. Easier for mental maths.
|
||||
private const int min_delta_time = 25;
|
||||
private const float maximum_slider_radius = normalized_radius * 2.4f;
|
||||
private const float assumed_slider_radius = normalized_radius * 1.8f;
|
||||
private const float maximum_slider_radius = normalised_radius * 2.4f;
|
||||
private const float assumed_slider_radius = normalised_radius * 1.8f;
|
||||
|
||||
protected new OsuHitObject BaseObject => (OsuHitObject)base.BaseObject;
|
||||
|
||||
/// <summary>
|
||||
/// Normalized distance from the end position of the previous <see cref="OsuDifficultyHitObject"/> to the start position of this <see cref="OsuDifficultyHitObject"/>.
|
||||
/// Milliseconds elapsed since the start time of the previous <see cref="OsuDifficultyHitObject"/>, with a minimum of 25ms.
|
||||
/// </summary>
|
||||
public double JumpDistance { get; private set; }
|
||||
public readonly double StrainTime;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum distance from the end position of the previous <see cref="OsuDifficultyHitObject"/> to the start position of this <see cref="OsuDifficultyHitObject"/>.
|
||||
/// Normalised distance from the "lazy" end position of the previous <see cref="OsuDifficultyHitObject"/> to the start position of this <see cref="OsuDifficultyHitObject"/>.
|
||||
/// <para>
|
||||
/// The "lazy" end position is the position at which the cursor ends up if the previous hitobject is followed with as minimal movement as possible (i.e. on the edge of slider follow circles).
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public double MovementDistance { get; private set; }
|
||||
public double LazyJumpDistance { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Normalized distance between the start and end position of the previous <see cref="OsuDifficultyHitObject"/>.
|
||||
/// Normalised shortest distance to consider for a jump between the previous <see cref="OsuDifficultyHitObject"/> and this <see cref="OsuDifficultyHitObject"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is bounded from above by <see cref="LazyJumpDistance"/>, and is smaller than the former if a more natural path is able to be taken through the previous <see cref="OsuDifficultyHitObject"/>.
|
||||
/// </remarks>
|
||||
/// <example>
|
||||
/// Suppose a linear slider - circle pattern.
|
||||
/// <br />
|
||||
/// Following the slider lazily (see: <see cref="LazyJumpDistance"/>) will result in underestimating the true end position of the slider as being closer towards the start position.
|
||||
/// As a result, <see cref="LazyJumpDistance"/> overestimates the jump distance because the player is able to take a more natural path by following through the slider to its end,
|
||||
/// such that the jump is felt as only starting from the slider's true end position.
|
||||
/// <br />
|
||||
/// Now consider a slider - circle pattern where the circle is stacked along the path inside the slider.
|
||||
/// In this case, the lazy end position correctly estimates the true end position of the slider and provides the more natural movement path.
|
||||
/// </example>
|
||||
public double MinimumJumpDistance { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time taken to travel through <see cref="MinimumJumpDistance"/>, with a minimum value of 25ms.
|
||||
/// </summary>
|
||||
public double MinimumJumpTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Normalised distance between the start and end position of this <see cref="OsuDifficultyHitObject"/>.
|
||||
/// </summary>
|
||||
public double TravelDistance { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time taken to travel through <see cref="TravelDistance"/>, with a minimum value of 25ms for a non-zero distance.
|
||||
/// </summary>
|
||||
public double TravelTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Angle the player has to take to hit this <see cref="OsuDifficultyHitObject"/>.
|
||||
/// Calculated as the angle between the circles (current-2, current-1, current).
|
||||
/// </summary>
|
||||
public double? Angle { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Milliseconds elapsed since the end time of the previous <see cref="OsuDifficultyHitObject"/>, with a minimum of 25ms.
|
||||
/// </summary>
|
||||
public double MovementTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Milliseconds elapsed since the start time of the previous <see cref="OsuDifficultyHitObject"/> to the end time of the same previous <see cref="OsuDifficultyHitObject"/>, with a minimum of 25ms.
|
||||
/// </summary>
|
||||
public double TravelTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Milliseconds elapsed since the start time of the previous <see cref="OsuDifficultyHitObject"/>, with a minimum of 25ms.
|
||||
/// </summary>
|
||||
public readonly double StrainTime;
|
||||
|
||||
private readonly OsuHitObject lastLastObject;
|
||||
private readonly OsuHitObject lastObject;
|
||||
|
||||
@ -71,12 +87,19 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
|
||||
|
||||
private void setDistances(double clockRate)
|
||||
{
|
||||
if (BaseObject is Slider currentSlider)
|
||||
{
|
||||
computeSliderCursorPosition(currentSlider);
|
||||
TravelDistance = currentSlider.LazyTravelDistance;
|
||||
TravelTime = Math.Max(currentSlider.LazyTravelTime / clockRate, min_delta_time);
|
||||
}
|
||||
|
||||
// We don't need to calculate either angle or distance when one of the last->curr objects is a spinner
|
||||
if (BaseObject is Spinner || lastObject is Spinner)
|
||||
return;
|
||||
|
||||
// We will scale distances by this factor, so we can assume a uniform CircleSize among beatmaps.
|
||||
float scalingFactor = normalized_radius / (float)BaseObject.Radius;
|
||||
float scalingFactor = normalised_radius / (float)BaseObject.Radius;
|
||||
|
||||
if (BaseObject.Radius < 30)
|
||||
{
|
||||
@ -85,29 +108,40 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
|
||||
}
|
||||
|
||||
Vector2 lastCursorPosition = getEndCursorPosition(lastObject);
|
||||
JumpDistance = (BaseObject.StackedPosition * scalingFactor - lastCursorPosition * scalingFactor).Length;
|
||||
|
||||
LazyJumpDistance = (BaseObject.StackedPosition * scalingFactor - lastCursorPosition * scalingFactor).Length;
|
||||
MinimumJumpTime = StrainTime;
|
||||
MinimumJumpDistance = LazyJumpDistance;
|
||||
|
||||
if (lastObject is Slider lastSlider)
|
||||
{
|
||||
computeSliderCursorPosition(lastSlider);
|
||||
TravelDistance = lastSlider.LazyTravelDistance;
|
||||
TravelTime = Math.Max(lastSlider.LazyTravelTime / clockRate, min_delta_time);
|
||||
MovementTime = Math.Max(StrainTime - TravelTime, min_delta_time);
|
||||
double lastTravelTime = Math.Max(lastSlider.LazyTravelTime / clockRate, min_delta_time);
|
||||
MinimumJumpTime = Math.Max(StrainTime - lastTravelTime, min_delta_time);
|
||||
|
||||
//
|
||||
// There are two types of slider-to-object patterns to consider in order to better approximate the real movement a player will take to jump between the hitobjects.
|
||||
//
|
||||
// 1. The anti-flow pattern, where players cut the slider short in order to move to the next hitobject.
|
||||
//
|
||||
// <======o==> ← slider
|
||||
// | ← most natural jump path
|
||||
// o ← a follow-up hitcircle
|
||||
//
|
||||
// In this case the most natural jump path is approximated by LazyJumpDistance.
|
||||
//
|
||||
// 2. The flow pattern, where players follow through the slider to its visual extent into the next hitobject.
|
||||
//
|
||||
// <======o==>---o
|
||||
// ↑
|
||||
// most natural jump path
|
||||
//
|
||||
// In this case the most natural jump path is better approximated by a new distance called "tailJumpDistance" - the distance between the slider's tail and the next hitobject.
|
||||
//
|
||||
// Thus, the player is assumed to jump the minimum of these two distances in all cases.
|
||||
//
|
||||
|
||||
// Jump distance from the slider tail to the next object, as opposed to the lazy position of JumpDistance.
|
||||
float tailJumpDistance = Vector2.Subtract(lastSlider.TailCircle.StackedPosition, BaseObject.StackedPosition).Length * scalingFactor;
|
||||
|
||||
// For hitobjects which continue in the direction of the slider, the player will normally follow through the slider,
|
||||
// such that they're not jumping from the lazy position but rather from very close to (or the end of) the slider.
|
||||
// In such cases, a leniency is applied by also considering the jump distance from the tail of the slider, and taking the minimum jump distance.
|
||||
// Additional distance is removed based on position of jump relative to slider follow circle radius.
|
||||
// JumpDistance is the leniency distance beyond the assumed_slider_radius. tailJumpDistance is maximum_slider_radius since the full distance of radial leniency is still possible.
|
||||
MovementDistance = Math.Max(0, Math.Min(JumpDistance - (maximum_slider_radius - assumed_slider_radius), tailJumpDistance - maximum_slider_radius));
|
||||
}
|
||||
else
|
||||
{
|
||||
MovementTime = StrainTime;
|
||||
MovementDistance = JumpDistance;
|
||||
MinimumJumpDistance = Math.Max(0, Math.Min(LazyJumpDistance - (maximum_slider_radius - assumed_slider_radius), tailJumpDistance - maximum_slider_radius));
|
||||
}
|
||||
|
||||
if (lastLastObject != null && !(lastLastObject is Spinner))
|
||||
@ -139,7 +173,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
|
||||
|
||||
slider.LazyEndPosition = slider.StackedPosition + slider.Path.PositionAt(endTimeMin); // temporary lazy end position until a real result can be derived.
|
||||
var currCursorPosition = slider.StackedPosition;
|
||||
double scalingFactor = normalized_radius / slider.Radius; // lazySliderDistance is coded to be sensitive to scaling, this makes the maths easier with the thresholds being used.
|
||||
double scalingFactor = normalised_radius / slider.Radius; // lazySliderDistance is coded to be sensitive to scaling, this makes the maths easier with the thresholds being used.
|
||||
|
||||
for (int i = 1; i < slider.NestedHitObjects.Count; i++)
|
||||
{
|
||||
@ -167,7 +201,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
|
||||
else if (currMovementObj is SliderRepeat)
|
||||
{
|
||||
// For a slider repeat, assume a tighter movement threshold to better assess repeat sliders.
|
||||
requiredMovement = normalized_radius;
|
||||
requiredMovement = normalised_radius;
|
||||
}
|
||||
|
||||
if (currMovementLength > requiredMovement)
|
||||
|
@ -44,24 +44,24 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
var osuLastLastObj = (OsuDifficultyHitObject)Previous[1];
|
||||
|
||||
// Calculate the velocity to the current hitobject, which starts with a base distance / time assuming the last object is a hitcircle.
|
||||
double currVelocity = osuCurrObj.JumpDistance / osuCurrObj.StrainTime;
|
||||
double currVelocity = osuCurrObj.LazyJumpDistance / osuCurrObj.StrainTime;
|
||||
|
||||
// But if the last object is a slider, then we extend the travel velocity through the slider into the current object.
|
||||
if (osuLastObj.BaseObject is Slider && withSliders)
|
||||
{
|
||||
double movementVelocity = osuCurrObj.MovementDistance / osuCurrObj.MovementTime; // calculate the movement velocity from slider end to current object
|
||||
double travelVelocity = osuCurrObj.TravelDistance / osuCurrObj.TravelTime; // calculate the slider velocity from slider head to slider end.
|
||||
double travelVelocity = osuLastObj.TravelDistance / osuLastObj.TravelTime; // calculate the slider velocity from slider head to slider end.
|
||||
double movementVelocity = osuCurrObj.MinimumJumpDistance / osuCurrObj.MinimumJumpTime; // calculate the movement velocity from slider end to current object
|
||||
|
||||
currVelocity = Math.Max(currVelocity, movementVelocity + travelVelocity); // take the larger total combined velocity.
|
||||
}
|
||||
|
||||
// As above, do the same for the previous hitobject.
|
||||
double prevVelocity = osuLastObj.JumpDistance / osuLastObj.StrainTime;
|
||||
double prevVelocity = osuLastObj.LazyJumpDistance / osuLastObj.StrainTime;
|
||||
|
||||
if (osuLastLastObj.BaseObject is Slider && withSliders)
|
||||
{
|
||||
double movementVelocity = osuLastObj.MovementDistance / osuLastObj.MovementTime;
|
||||
double travelVelocity = osuLastObj.TravelDistance / osuLastObj.TravelTime;
|
||||
double travelVelocity = osuLastLastObj.TravelDistance / osuLastLastObj.TravelTime;
|
||||
double movementVelocity = osuLastObj.MinimumJumpDistance / osuLastObj.MinimumJumpTime;
|
||||
|
||||
prevVelocity = Math.Max(prevVelocity, movementVelocity + travelVelocity);
|
||||
}
|
||||
@ -94,7 +94,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
acuteAngleBonus *= calcAcuteAngleBonus(lastAngle) // Multiply by previous angle, we don't want to buff unless this is a wiggle type pattern.
|
||||
* Math.Min(angleBonus, 125 / osuCurrObj.StrainTime) // The maximum velocity we buff is equal to 125 / strainTime
|
||||
* Math.Pow(Math.Sin(Math.PI / 2 * Math.Min(1, (100 - osuCurrObj.StrainTime) / 25)), 2) // scale buff from 150 bpm 1/4 to 200 bpm 1/4
|
||||
* Math.Pow(Math.Sin(Math.PI / 2 * (Math.Clamp(osuCurrObj.JumpDistance, 50, 100) - 50) / 50), 2); // Buff distance exceeding 50 (radius) up to 100 (diameter).
|
||||
* Math.Pow(Math.Sin(Math.PI / 2 * (Math.Clamp(osuCurrObj.LazyJumpDistance, 50, 100) - 50) / 50), 2); // Buff distance exceeding 50 (radius) up to 100 (diameter).
|
||||
}
|
||||
|
||||
// Penalize wide angles if they're repeated, reducing the penalty as the lastAngle gets more acute.
|
||||
@ -107,8 +107,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
if (Math.Max(prevVelocity, currVelocity) != 0)
|
||||
{
|
||||
// We want to use the average velocity over the whole object when awarding differences, not the individual jump and slider path velocities.
|
||||
prevVelocity = (osuLastObj.JumpDistance + osuLastObj.TravelDistance) / osuLastObj.StrainTime;
|
||||
currVelocity = (osuCurrObj.JumpDistance + osuCurrObj.TravelDistance) / osuCurrObj.StrainTime;
|
||||
prevVelocity = (osuLastObj.LazyJumpDistance + osuLastLastObj.TravelDistance) / osuLastObj.StrainTime;
|
||||
currVelocity = (osuCurrObj.LazyJumpDistance + osuLastObj.TravelDistance) / osuCurrObj.StrainTime;
|
||||
|
||||
// Scale with ratio of difference compared to 0.5 * max dist.
|
||||
double distRatio = Math.Pow(Math.Sin(Math.PI / 2 * Math.Abs(prevVelocity - currVelocity) / Math.Max(prevVelocity, currVelocity)), 2);
|
||||
@ -119,7 +119,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
// Reward for % distance slowed down compared to previous, paying attention to not award overlap
|
||||
double nonOverlapVelocityBuff = Math.Abs(prevVelocity - currVelocity)
|
||||
// do not award overlap
|
||||
* Math.Pow(Math.Sin(Math.PI / 2 * Math.Min(1, Math.Min(osuCurrObj.JumpDistance, osuLastObj.JumpDistance) / 100)), 2);
|
||||
* Math.Pow(Math.Sin(Math.PI / 2 * Math.Min(1, Math.Min(osuCurrObj.LazyJumpDistance, osuLastObj.LazyJumpDistance) / 100)), 2);
|
||||
|
||||
// Choose the largest bonus, multiplied by ratio.
|
||||
velocityChangeBonus = Math.Max(overlapVelocityBuff, nonOverlapVelocityBuff) * distRatio;
|
||||
@ -128,10 +128,10 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
velocityChangeBonus *= Math.Pow(Math.Min(osuCurrObj.StrainTime, osuLastObj.StrainTime) / Math.Max(osuCurrObj.StrainTime, osuLastObj.StrainTime), 2);
|
||||
}
|
||||
|
||||
if (osuCurrObj.TravelTime != 0)
|
||||
if (osuLastObj.TravelTime != 0)
|
||||
{
|
||||
// Reward sliders based on velocity.
|
||||
sliderBonus = osuCurrObj.TravelDistance / osuCurrObj.TravelTime;
|
||||
sliderBonus = osuLastObj.TravelDistance / osuLastObj.TravelTime;
|
||||
}
|
||||
|
||||
// Add in acute angle bonus or wide angle bonus + velocity change bonus, whichever is larger.
|
||||
|
@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
smallDistNerf = Math.Min(1.0, jumpDistance / 75.0);
|
||||
|
||||
// We also want to nerf stacks so that only the first object of the stack is accounted for.
|
||||
double stackNerf = Math.Min(1.0, (osuPrevious.JumpDistance / scalingFactor) / 25.0);
|
||||
double stackNerf = Math.Min(1.0, (osuPrevious.LazyJumpDistance / scalingFactor) / 25.0);
|
||||
|
||||
result += Math.Pow(0.8, i) * stackNerf * scalingFactor * jumpDistance / cumulativeStrainTime;
|
||||
}
|
||||
|
@ -55,73 +55,75 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
|
||||
bool firstDeltaSwitch = false;
|
||||
|
||||
for (int i = Previous.Count - 2; i > 0; i--)
|
||||
int rhythmStart = 0;
|
||||
|
||||
while (rhythmStart < Previous.Count - 2 && current.StartTime - Previous[rhythmStart].StartTime < history_time_max)
|
||||
rhythmStart++;
|
||||
|
||||
for (int i = rhythmStart; i > 0; i--)
|
||||
{
|
||||
OsuDifficultyHitObject currObj = (OsuDifficultyHitObject)Previous[i - 1];
|
||||
OsuDifficultyHitObject prevObj = (OsuDifficultyHitObject)Previous[i];
|
||||
OsuDifficultyHitObject lastObj = (OsuDifficultyHitObject)Previous[i + 1];
|
||||
|
||||
double currHistoricalDecay = Math.Max(0, (history_time_max - (current.StartTime - currObj.StartTime))) / history_time_max; // scales note 0 to 1 from history to now
|
||||
double currHistoricalDecay = (history_time_max - (current.StartTime - currObj.StartTime)) / history_time_max; // scales note 0 to 1 from history to now
|
||||
|
||||
if (currHistoricalDecay != 0)
|
||||
currHistoricalDecay = Math.Min((double)(Previous.Count - i) / Previous.Count, currHistoricalDecay); // either we're limited by time or limited by object count.
|
||||
|
||||
double currDelta = currObj.StrainTime;
|
||||
double prevDelta = prevObj.StrainTime;
|
||||
double lastDelta = lastObj.StrainTime;
|
||||
double currRatio = 1.0 + 6.0 * Math.Min(0.5, Math.Pow(Math.Sin(Math.PI / (Math.Min(prevDelta, currDelta) / Math.Max(prevDelta, currDelta))), 2)); // fancy function to calculate rhythmbonuses.
|
||||
|
||||
double windowPenalty = Math.Min(1, Math.Max(0, Math.Abs(prevDelta - currDelta) - greatWindow * 0.6) / (greatWindow * 0.6));
|
||||
|
||||
windowPenalty = Math.Min(1, windowPenalty);
|
||||
|
||||
double effectiveRatio = windowPenalty * currRatio;
|
||||
|
||||
if (firstDeltaSwitch)
|
||||
{
|
||||
currHistoricalDecay = Math.Min((double)(Previous.Count - i) / Previous.Count, currHistoricalDecay); // either we're limited by time or limited by object count.
|
||||
|
||||
double currDelta = currObj.StrainTime;
|
||||
double prevDelta = prevObj.StrainTime;
|
||||
double lastDelta = lastObj.StrainTime;
|
||||
double currRatio = 1.0 + 6.0 * Math.Min(0.5, Math.Pow(Math.Sin(Math.PI / (Math.Min(prevDelta, currDelta) / Math.Max(prevDelta, currDelta))), 2)); // fancy function to calculate rhythmbonuses.
|
||||
|
||||
double windowPenalty = Math.Min(1, Math.Max(0, Math.Abs(prevDelta - currDelta) - greatWindow * 0.6) / (greatWindow * 0.6));
|
||||
|
||||
windowPenalty = Math.Min(1, windowPenalty);
|
||||
|
||||
double effectiveRatio = windowPenalty * currRatio;
|
||||
|
||||
if (firstDeltaSwitch)
|
||||
if (!(prevDelta > 1.25 * currDelta || prevDelta * 1.25 < currDelta))
|
||||
{
|
||||
if (!(prevDelta > 1.25 * currDelta || prevDelta * 1.25 < currDelta))
|
||||
{
|
||||
if (islandSize < 7)
|
||||
islandSize++; // island is still progressing, count size.
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Previous[i - 1].BaseObject is Slider) // bpm change is into slider, this is easy acc window
|
||||
effectiveRatio *= 0.125;
|
||||
|
||||
if (Previous[i].BaseObject is Slider) // bpm change was from a slider, this is easier typically than circle -> circle
|
||||
effectiveRatio *= 0.25;
|
||||
|
||||
if (previousIslandSize == islandSize) // repeated island size (ex: triplet -> triplet)
|
||||
effectiveRatio *= 0.25;
|
||||
|
||||
if (previousIslandSize % 2 == islandSize % 2) // repeated island polartiy (2 -> 4, 3 -> 5)
|
||||
effectiveRatio *= 0.50;
|
||||
|
||||
if (lastDelta > prevDelta + 10 && prevDelta > currDelta + 10) // previous increase happened a note ago, 1/1->1/2-1/4, dont want to buff this.
|
||||
effectiveRatio *= 0.125;
|
||||
|
||||
rhythmComplexitySum += Math.Sqrt(effectiveRatio * startRatio) * currHistoricalDecay * Math.Sqrt(4 + islandSize) / 2 * Math.Sqrt(4 + previousIslandSize) / 2;
|
||||
|
||||
startRatio = effectiveRatio;
|
||||
|
||||
previousIslandSize = islandSize; // log the last island size.
|
||||
|
||||
if (prevDelta * 1.25 < currDelta) // we're slowing down, stop counting
|
||||
firstDeltaSwitch = false; // if we're speeding up, this stays true and we keep counting island size.
|
||||
|
||||
islandSize = 1;
|
||||
}
|
||||
if (islandSize < 7)
|
||||
islandSize++; // island is still progressing, count size.
|
||||
}
|
||||
else if (prevDelta > 1.25 * currDelta) // we want to be speeding up.
|
||||
else
|
||||
{
|
||||
// Begin counting island until we change speed again.
|
||||
firstDeltaSwitch = true;
|
||||
if (Previous[i - 1].BaseObject is Slider) // bpm change is into slider, this is easy acc window
|
||||
effectiveRatio *= 0.125;
|
||||
|
||||
if (Previous[i].BaseObject is Slider) // bpm change was from a slider, this is easier typically than circle -> circle
|
||||
effectiveRatio *= 0.25;
|
||||
|
||||
if (previousIslandSize == islandSize) // repeated island size (ex: triplet -> triplet)
|
||||
effectiveRatio *= 0.25;
|
||||
|
||||
if (previousIslandSize % 2 == islandSize % 2) // repeated island polartiy (2 -> 4, 3 -> 5)
|
||||
effectiveRatio *= 0.50;
|
||||
|
||||
if (lastDelta > prevDelta + 10 && prevDelta > currDelta + 10) // previous increase happened a note ago, 1/1->1/2-1/4, dont want to buff this.
|
||||
effectiveRatio *= 0.125;
|
||||
|
||||
rhythmComplexitySum += Math.Sqrt(effectiveRatio * startRatio) * currHistoricalDecay * Math.Sqrt(4 + islandSize) / 2 * Math.Sqrt(4 + previousIslandSize) / 2;
|
||||
|
||||
startRatio = effectiveRatio;
|
||||
|
||||
previousIslandSize = islandSize; // log the last island size.
|
||||
|
||||
if (prevDelta * 1.25 < currDelta) // we're slowing down, stop counting
|
||||
firstDeltaSwitch = false; // if we're speeding up, this stays true and we keep counting island size.
|
||||
|
||||
islandSize = 1;
|
||||
}
|
||||
}
|
||||
else if (prevDelta > 1.25 * currDelta) // we want to be speeding up.
|
||||
{
|
||||
// Begin counting island until we change speed again.
|
||||
firstDeltaSwitch = true;
|
||||
startRatio = effectiveRatio;
|
||||
islandSize = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return Math.Sqrt(4 + rhythmComplexitySum * rhythm_multiplier) / 2; //produces multiplier that can be applied to strain. range [1, infinity) (not really though)
|
||||
@ -154,7 +156,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
if (strainTime < min_speed_bonus)
|
||||
speedBonus = 1 + 0.75 * Math.Pow((min_speed_bonus - strainTime) / speed_balancing_factor, 2);
|
||||
|
||||
double distance = Math.Min(single_spacing_threshold, osuCurrObj.TravelDistance + osuCurrObj.MovementDistance);
|
||||
double travelDistance = osuPrevObj?.TravelDistance ?? 0;
|
||||
double distance = Math.Min(single_spacing_threshold, travelDistance + osuCurrObj.MinimumJumpDistance);
|
||||
|
||||
return (speedBonus + speedBonus * Math.Pow(distance / single_spacing_threshold, 3.5)) / strainTime;
|
||||
}
|
||||
|
@ -3,8 +3,10 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Input.StateChanges.Events;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu
|
||||
@ -39,6 +41,19 @@ namespace osu.Game.Rulesets.Osu
|
||||
return base.Handle(e);
|
||||
}
|
||||
|
||||
protected override bool HandleMouseTouchStateChange(TouchStateChangeEvent e)
|
||||
{
|
||||
if (!AllowUserCursorMovement)
|
||||
{
|
||||
// Still allow for forwarding of the "touch" part, but replace the positional data with that of the mouse.
|
||||
// Primarily relied upon by the "autopilot" osu! mod.
|
||||
var touch = new Touch(e.Touch.Source, CurrentState.Mouse.Position);
|
||||
e = new TouchStateChangeEvent(e.State, e.Input, touch, e.IsActive, null);
|
||||
}
|
||||
|
||||
return base.HandleMouseTouchStateChange(e);
|
||||
}
|
||||
|
||||
private class OsuKeyBindingContainer : RulesetKeyBindingContainer
|
||||
{
|
||||
public bool AllowUserPresses = true;
|
||||
|
@ -62,7 +62,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
public void TestCultureInvariance()
|
||||
{
|
||||
var ruleset = new OsuRuleset().RulesetInfo;
|
||||
var scoreInfo = new TestScoreInfo(ruleset);
|
||||
var scoreInfo = TestResources.CreateTestScoreInfo(ruleset);
|
||||
var beatmap = new TestBeatmap(ruleset);
|
||||
var score = new Score
|
||||
{
|
||||
|
@ -1022,7 +1022,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
||||
{
|
||||
return ImportScoreTest.LoadScoreIntoOsu(osu, new ScoreInfo
|
||||
{
|
||||
OnlineScoreID = 2,
|
||||
OnlineID = 2,
|
||||
BeatmapInfo = beatmapInfo,
|
||||
BeatmapInfoID = beatmapInfo.ID
|
||||
}, new ImportScoreTest.TestArchiveReader());
|
||||
|
@ -809,7 +809,7 @@ namespace osu.Game.Tests.Database
|
||||
// TODO: reimplement when we have score support in realm.
|
||||
// return ImportScoreTest.LoadScoreIntoOsu(osu, new ScoreInfo
|
||||
// {
|
||||
// OnlineScoreID = 2,
|
||||
// OnlineID = 2,
|
||||
// Beatmap = beatmap,
|
||||
// BeatmapInfoID = beatmap.ID
|
||||
// }, new ImportScoreTest.TestArchiveReader());
|
||||
|
@ -6,6 +6,7 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Models;
|
||||
using Realms;
|
||||
@ -21,14 +22,41 @@ namespace osu.Game.Tests.Database
|
||||
{
|
||||
RunTestWithRealm((realmFactory, _) =>
|
||||
{
|
||||
ILive<RealmBeatmap> beatmap = realmFactory.CreateContext().Write(r => r.Add(new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata()))).ToLive();
|
||||
ILive<RealmBeatmap> beatmap = realmFactory.CreateContext().Write(r => r.Add(new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata()))).ToLive(realmFactory);
|
||||
|
||||
ILive<RealmBeatmap> beatmap2 = realmFactory.CreateContext().All<RealmBeatmap>().First().ToLive();
|
||||
ILive<RealmBeatmap> beatmap2 = realmFactory.CreateContext().All<RealmBeatmap>().First().ToLive(realmFactory);
|
||||
|
||||
Assert.AreEqual(beatmap, beatmap2);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAccessAfterStorageMigrate()
|
||||
{
|
||||
RunTestWithRealm((realmFactory, storage) =>
|
||||
{
|
||||
var beatmap = new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata());
|
||||
|
||||
ILive<RealmBeatmap> liveBeatmap;
|
||||
|
||||
using (var context = realmFactory.CreateContext())
|
||||
{
|
||||
context.Write(r => r.Add(beatmap));
|
||||
|
||||
liveBeatmap = beatmap.ToLive(realmFactory);
|
||||
}
|
||||
|
||||
using (var migratedStorage = new TemporaryNativeStorage("realm-test-migration-target"))
|
||||
{
|
||||
migratedStorage.DeleteDirectory(string.Empty);
|
||||
|
||||
storage.Migrate(migratedStorage);
|
||||
|
||||
Assert.IsFalse(liveBeatmap.PerformRead(l => l.Hidden));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAccessAfterAttach()
|
||||
{
|
||||
@ -36,7 +64,7 @@ namespace osu.Game.Tests.Database
|
||||
{
|
||||
var beatmap = new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata());
|
||||
|
||||
var liveBeatmap = beatmap.ToLive();
|
||||
var liveBeatmap = beatmap.ToLive(realmFactory);
|
||||
|
||||
using (var context = realmFactory.CreateContext())
|
||||
context.Write(r => r.Add(beatmap));
|
||||
@ -49,7 +77,7 @@ namespace osu.Game.Tests.Database
|
||||
public void TestAccessNonManaged()
|
||||
{
|
||||
var beatmap = new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata());
|
||||
var liveBeatmap = beatmap.ToLive();
|
||||
var liveBeatmap = beatmap.ToLiveUnmanaged();
|
||||
|
||||
Assert.IsFalse(beatmap.Hidden);
|
||||
Assert.IsFalse(liveBeatmap.Value.Hidden);
|
||||
@ -74,7 +102,7 @@ namespace osu.Game.Tests.Database
|
||||
{
|
||||
var beatmap = threadContext.Write(r => r.Add(new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata())));
|
||||
|
||||
liveBeatmap = beatmap.ToLive();
|
||||
liveBeatmap = beatmap.ToLive(realmFactory);
|
||||
}
|
||||
}, TaskCreationOptions.LongRunning | TaskCreationOptions.HideScheduler).Wait();
|
||||
|
||||
@ -103,7 +131,7 @@ namespace osu.Game.Tests.Database
|
||||
{
|
||||
var beatmap = threadContext.Write(r => r.Add(new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata())));
|
||||
|
||||
liveBeatmap = beatmap.ToLive();
|
||||
liveBeatmap = beatmap.ToLive(realmFactory);
|
||||
}
|
||||
}, TaskCreationOptions.LongRunning | TaskCreationOptions.HideScheduler).Wait();
|
||||
|
||||
@ -123,7 +151,7 @@ namespace osu.Game.Tests.Database
|
||||
RunTestWithRealm((realmFactory, _) =>
|
||||
{
|
||||
var beatmap = new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata());
|
||||
var liveBeatmap = beatmap.ToLive();
|
||||
var liveBeatmap = beatmap.ToLive(realmFactory);
|
||||
|
||||
Assert.DoesNotThrow(() =>
|
||||
{
|
||||
@ -145,7 +173,7 @@ namespace osu.Game.Tests.Database
|
||||
{
|
||||
var beatmap = threadContext.Write(r => r.Add(new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata())));
|
||||
|
||||
liveBeatmap = beatmap.ToLive();
|
||||
liveBeatmap = beatmap.ToLive(realmFactory);
|
||||
}
|
||||
}, TaskCreationOptions.LongRunning | TaskCreationOptions.HideScheduler).Wait();
|
||||
|
||||
@ -183,7 +211,7 @@ namespace osu.Game.Tests.Database
|
||||
{
|
||||
var beatmap = threadContext.Write(r => r.Add(new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata())));
|
||||
|
||||
liveBeatmap = beatmap.ToLive();
|
||||
liveBeatmap = beatmap.ToLive(realmFactory);
|
||||
}
|
||||
}, TaskCreationOptions.LongRunning | TaskCreationOptions.HideScheduler).Wait();
|
||||
|
||||
@ -222,7 +250,7 @@ namespace osu.Game.Tests.Database
|
||||
// not just a refresh from the resolved Live.
|
||||
threadContext.Write(r => r.Add(new RealmBeatmap(ruleset, new RealmBeatmapDifficulty(), new RealmBeatmapMetadata())));
|
||||
|
||||
liveBeatmap = beatmap.ToLive();
|
||||
liveBeatmap = beatmap.ToLive(realmFactory);
|
||||
}
|
||||
}, TaskCreationOptions.LongRunning | TaskCreationOptions.HideScheduler).Wait();
|
||||
|
||||
|
@ -10,6 +10,7 @@ using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Models;
|
||||
|
||||
#nullable enable
|
||||
@ -27,15 +28,16 @@ namespace osu.Game.Tests.Database
|
||||
storage.DeleteDirectory(string.Empty);
|
||||
}
|
||||
|
||||
protected void RunTestWithRealm(Action<RealmContextFactory, Storage> testAction, [CallerMemberName] string caller = "")
|
||||
protected void RunTestWithRealm(Action<RealmContextFactory, OsuStorage> testAction, [CallerMemberName] string caller = "")
|
||||
{
|
||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(caller))
|
||||
{
|
||||
host.Run(new RealmTestGame(() =>
|
||||
{
|
||||
var testStorage = storage.GetStorageForDirectory(caller);
|
||||
// ReSharper disable once AccessToDisposedClosure
|
||||
var testStorage = new OsuStorage(host, storage.GetStorageForDirectory(caller));
|
||||
|
||||
using (var realmFactory = new RealmContextFactory(testStorage, caller))
|
||||
using (var realmFactory = new RealmContextFactory(testStorage, "client"))
|
||||
{
|
||||
Logger.Log($"Running test using realm file {testStorage.GetFullPath(realmFactory.Filename)}");
|
||||
testAction(realmFactory, testStorage);
|
||||
@ -58,7 +60,7 @@ namespace osu.Game.Tests.Database
|
||||
{
|
||||
var testStorage = storage.GetStorageForDirectory(caller);
|
||||
|
||||
using (var realmFactory = new RealmContextFactory(testStorage, caller))
|
||||
using (var realmFactory = new RealmContextFactory(testStorage, "client"))
|
||||
{
|
||||
Logger.Log($"Running test using realm file {testStorage.GetFullPath(realmFactory.Filename)}");
|
||||
await testAction(realmFactory, testStorage);
|
||||
|
@ -52,6 +52,45 @@ namespace osu.Game.Tests.Database
|
||||
Assert.That(queryCount(GlobalAction.Select), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDefaultsPopulationRemovesExcess()
|
||||
{
|
||||
Assert.That(queryCount(), Is.EqualTo(0));
|
||||
|
||||
KeyBindingContainer testContainer = new TestKeyBindingContainer();
|
||||
|
||||
// Add some excess bindings for an action which only supports 1.
|
||||
using (var realm = realmContextFactory.CreateContext())
|
||||
using (var transaction = realm.BeginWrite())
|
||||
{
|
||||
realm.Add(new RealmKeyBinding
|
||||
{
|
||||
Action = GlobalAction.Back,
|
||||
KeyCombination = new KeyCombination(InputKey.A)
|
||||
});
|
||||
|
||||
realm.Add(new RealmKeyBinding
|
||||
{
|
||||
Action = GlobalAction.Back,
|
||||
KeyCombination = new KeyCombination(InputKey.S)
|
||||
});
|
||||
|
||||
realm.Add(new RealmKeyBinding
|
||||
{
|
||||
Action = GlobalAction.Back,
|
||||
KeyCombination = new KeyCombination(InputKey.D)
|
||||
});
|
||||
|
||||
transaction.Commit();
|
||||
}
|
||||
|
||||
Assert.That(queryCount(GlobalAction.Back), Is.EqualTo(3));
|
||||
|
||||
keyBindingStore.Register(testContainer, Enumerable.Empty<RulesetInfo>());
|
||||
|
||||
Assert.That(queryCount(GlobalAction.Back), Is.EqualTo(1));
|
||||
}
|
||||
|
||||
private int queryCount(GlobalAction? match = null)
|
||||
{
|
||||
using (var realm = realmContextFactory.CreateContext())
|
||||
|
@ -15,6 +15,7 @@ using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@ -220,6 +221,7 @@ namespace osu.Game.Tests.Gameplay
|
||||
public AudioManager AudioManager => Audio;
|
||||
public IResourceStore<byte[]> Files => null;
|
||||
public new IResourceStore<byte[]> Resources => base.Resources;
|
||||
public RealmContextFactory RealmContextFactory => null;
|
||||
public IResourceStore<TextureUpload> CreateTextureLoaderStore(IResourceStore<byte[]> underlyingStore) => null;
|
||||
|
||||
#endregion
|
||||
|
@ -45,8 +45,6 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
|
||||
AddRepeatStep("add some users", () => Client.AddUser(new APIUser { Id = id++ }), 5);
|
||||
checkPlayingUserCount(0);
|
||||
|
||||
AddAssert("playlist item is available", () => Client.CurrentMatchPlayingItem.Value != null);
|
||||
|
||||
changeState(3, MultiplayerUserState.WaitingForLoad);
|
||||
checkPlayingUserCount(3);
|
||||
|
||||
@ -64,8 +62,6 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
|
||||
|
||||
AddStep("leave room", () => Client.LeaveRoom());
|
||||
checkPlayingUserCount(0);
|
||||
|
||||
AddAssert("playlist item is null", () => Client.CurrentMatchPlayingItem.Value == null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
90
osu.Game.Tests/Online/Chat/MessageNotifierTest.cs
Normal file
90
osu.Game.Tests/Online/Chat/MessageNotifierTest.cs
Normal file
@ -0,0 +1,90 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Online.Chat;
|
||||
|
||||
namespace osu.Game.Tests.Online.Chat
|
||||
{
|
||||
[TestFixture]
|
||||
public class MessageNotifierTest
|
||||
{
|
||||
[Test]
|
||||
public void TestContainsUsernameMidlinePositive()
|
||||
{
|
||||
Assert.IsTrue(MessageNotifier.CheckContainsUsername("This is a test message", "Test"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsUsernameStartOfLinePositive()
|
||||
{
|
||||
Assert.IsTrue(MessageNotifier.CheckContainsUsername("Test message", "Test"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsUsernameEndOfLinePositive()
|
||||
{
|
||||
Assert.IsTrue(MessageNotifier.CheckContainsUsername("This is a test", "Test"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsUsernameMidlineNegative()
|
||||
{
|
||||
Assert.IsFalse(MessageNotifier.CheckContainsUsername("This is a testmessage for notifications", "Test"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsUsernameStartOfLineNegative()
|
||||
{
|
||||
Assert.IsFalse(MessageNotifier.CheckContainsUsername("Testmessage", "Test"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsUsernameEndOfLineNegative()
|
||||
{
|
||||
Assert.IsFalse(MessageNotifier.CheckContainsUsername("This is a notificationtest", "Test"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsUsernameBetweenInterpunction()
|
||||
{
|
||||
Assert.IsTrue(MessageNotifier.CheckContainsUsername("Hello 'test'-message", "Test"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsUsernameUnicode()
|
||||
{
|
||||
Assert.IsTrue(MessageNotifier.CheckContainsUsername("Test \u0460\u0460 message", "\u0460\u0460"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsUsernameUnicodeNegative()
|
||||
{
|
||||
Assert.IsFalse(MessageNotifier.CheckContainsUsername("Test ha\u0460\u0460o message", "\u0460\u0460"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsUsernameSpecialCharactersPositive()
|
||||
{
|
||||
Assert.IsTrue(MessageNotifier.CheckContainsUsername("Test [#^-^#] message", "[#^-^#]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsUsernameSpecialCharactersNegative()
|
||||
{
|
||||
Assert.IsFalse(MessageNotifier.CheckContainsUsername("Test pad[#^-^#]oru message", "[#^-^#]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsUsernameAtSign()
|
||||
{
|
||||
Assert.IsTrue(MessageNotifier.CheckContainsUsername("@username hi", "username"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContainsUsernameColon()
|
||||
{
|
||||
Assert.IsTrue(MessageNotifier.CheckContainsUsername("username: hi", "username"));
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,6 @@ using osu.Game.Online.Solo;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Difficulty;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
@ -94,7 +93,7 @@ namespace osu.Game.Tests.Online
|
||||
[Test]
|
||||
public void TestDeserialiseSubmittableScoreWithEmptyMods()
|
||||
{
|
||||
var score = new SubmittableScore(new ScoreInfo { Ruleset = new OsuRuleset().RulesetInfo });
|
||||
var score = new SubmittableScore(new ScoreInfo());
|
||||
|
||||
var deserialised = JsonConvert.DeserializeObject<SubmittableScore>(JsonConvert.SerializeObject(score));
|
||||
|
||||
@ -106,7 +105,6 @@ namespace osu.Game.Tests.Online
|
||||
{
|
||||
var score = new SubmittableScore(new ScoreInfo
|
||||
{
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
Mods = new Mod[] { new OsuModDoubleTime { SpeedChange = { Value = 2 } } }
|
||||
});
|
||||
|
||||
|
@ -114,18 +114,23 @@ namespace osu.Game.Tests.Online
|
||||
public void TestTrackerRespectsChecksum()
|
||||
{
|
||||
AddStep("allow importing", () => beatmaps.AllowImport.SetResult(true));
|
||||
AddStep("import beatmap", () => beatmaps.Import(testBeatmapFile).Wait());
|
||||
addAvailabilityCheckStep("initially locally available", BeatmapAvailability.LocallyAvailable);
|
||||
|
||||
AddStep("import altered beatmap", () =>
|
||||
{
|
||||
beatmaps.Import(TestResources.GetTestBeatmapForImport(true)).Wait();
|
||||
});
|
||||
addAvailabilityCheckStep("state still not downloaded", BeatmapAvailability.NotDownloaded);
|
||||
addAvailabilityCheckStep("state not downloaded", BeatmapAvailability.NotDownloaded);
|
||||
|
||||
AddStep("recreate tracker", () => Child = availabilityTracker = new OnlinePlayBeatmapAvailabilityTracker
|
||||
{
|
||||
SelectedItem = { BindTarget = selectedItem }
|
||||
});
|
||||
addAvailabilityCheckStep("state not downloaded as well", BeatmapAvailability.NotDownloaded);
|
||||
|
||||
AddStep("reimport original beatmap", () => beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).Wait());
|
||||
addAvailabilityCheckStep("locally available after re-import", BeatmapAvailability.LocallyAvailable);
|
||||
}
|
||||
|
||||
private void addAvailabilityCheckStep(string description, Func<BeatmapAvailability> expected)
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using NUnit.Framework;
|
||||
@ -12,8 +13,12 @@ using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Tests.Resources
|
||||
{
|
||||
@ -137,5 +142,63 @@ namespace osu.Game.Tests.Resources
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a test score model.
|
||||
/// </summary>
|
||||
/// <param name="ruleset">The ruleset for which the score was set against.</param>
|
||||
/// <returns></returns>
|
||||
public static ScoreInfo CreateTestScoreInfo(RulesetInfo ruleset = null) =>
|
||||
CreateTestScoreInfo(CreateTestBeatmapSetInfo(1, new[] { ruleset ?? new OsuRuleset().RulesetInfo }).Beatmaps.First());
|
||||
|
||||
/// <summary>
|
||||
/// Create a test score model.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The beatmap for which the score was set against.</param>
|
||||
/// <returns></returns>
|
||||
public static ScoreInfo CreateTestScoreInfo(BeatmapInfo beatmap) => new ScoreInfo
|
||||
{
|
||||
User = new APIUser
|
||||
{
|
||||
Id = 2,
|
||||
Username = "peppy",
|
||||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
},
|
||||
BeatmapInfo = beatmap,
|
||||
Ruleset = beatmap.Ruleset,
|
||||
RulesetID = beatmap.Ruleset.ID ?? 0,
|
||||
Mods = new Mod[] { new TestModHardRock(), new TestModDoubleTime() },
|
||||
TotalScore = 2845370,
|
||||
Accuracy = 0.95,
|
||||
MaxCombo = 999,
|
||||
Position = 1,
|
||||
Rank = ScoreRank.S,
|
||||
Date = DateTimeOffset.Now,
|
||||
Statistics = new Dictionary<HitResult, int>
|
||||
{
|
||||
[HitResult.Miss] = 1,
|
||||
[HitResult.Meh] = 50,
|
||||
[HitResult.Ok] = 100,
|
||||
[HitResult.Good] = 200,
|
||||
[HitResult.Great] = 300,
|
||||
[HitResult.Perfect] = 320,
|
||||
[HitResult.SmallTickHit] = 50,
|
||||
[HitResult.SmallTickMiss] = 25,
|
||||
[HitResult.LargeTickHit] = 100,
|
||||
[HitResult.LargeTickMiss] = 50,
|
||||
[HitResult.SmallBonus] = 10,
|
||||
[HitResult.SmallBonus] = 50
|
||||
},
|
||||
};
|
||||
|
||||
private class TestModHardRock : ModHardRock
|
||||
{
|
||||
public override double ScoreMultiplier => 1;
|
||||
}
|
||||
|
||||
private class TestModDoubleTime : ModDoubleTime
|
||||
{
|
||||
public override double ScoreMultiplier => 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Tests.Scores.IO
|
||||
Combo = 250,
|
||||
User = new APIUser { Username = "Test user" },
|
||||
Date = DateTimeOffset.Now,
|
||||
OnlineScoreID = 12345,
|
||||
OnlineID = 12345,
|
||||
};
|
||||
|
||||
var imported = await LoadScoreIntoOsu(osu, toImport);
|
||||
@ -52,7 +52,7 @@ namespace osu.Game.Tests.Scores.IO
|
||||
Assert.AreEqual(toImport.Combo, imported.Combo);
|
||||
Assert.AreEqual(toImport.User.Username, imported.User.Username);
|
||||
Assert.AreEqual(toImport.Date, imported.Date);
|
||||
Assert.AreEqual(toImport.OnlineScoreID, imported.OnlineScoreID);
|
||||
Assert.AreEqual(toImport.OnlineID, imported.OnlineID);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -163,12 +163,12 @@ namespace osu.Game.Tests.Scores.IO
|
||||
{
|
||||
var osu = LoadOsuIntoHost(host, true);
|
||||
|
||||
await LoadScoreIntoOsu(osu, new ScoreInfo { OnlineScoreID = 2 }, new TestArchiveReader());
|
||||
await LoadScoreIntoOsu(osu, new ScoreInfo { OnlineID = 2 }, new TestArchiveReader());
|
||||
|
||||
var scoreManager = osu.Dependencies.Get<ScoreManager>();
|
||||
|
||||
// Note: A new score reference is used here since the import process mutates the original object to set an ID
|
||||
Assert.That(scoreManager.IsAvailableLocally(new ScoreInfo { OnlineScoreID = 2 }));
|
||||
Assert.That(scoreManager.IsAvailableLocally(new ScoreInfo { OnlineID = 2 }));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -44,24 +44,6 @@ namespace osu.Game.Tests.Scores.IO
|
||||
Assert.That(score1, Is.EqualTo(score2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNonMatchingByHash()
|
||||
{
|
||||
ScoreInfo score1 = new ScoreInfo { Hash = "a" };
|
||||
ScoreInfo score2 = new ScoreInfo { Hash = "b" };
|
||||
|
||||
Assert.That(score1, Is.Not.EqualTo(score2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMatchingByHash()
|
||||
{
|
||||
ScoreInfo score1 = new ScoreInfo { Hash = "a" };
|
||||
ScoreInfo score2 = new ScoreInfo { Hash = "a" };
|
||||
|
||||
Assert.That(score1, Is.EqualTo(score2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNonMatchingByNull()
|
||||
{
|
||||
|
@ -5,8 +5,11 @@ using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
@ -15,6 +18,7 @@ using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
@ -22,8 +26,7 @@ namespace osu.Game.Tests.Visual.Background
|
||||
public class TestSceneBackgroundScreenDefault : OsuTestScene
|
||||
{
|
||||
private BackgroundScreenStack stack;
|
||||
private BackgroundScreenDefault screen;
|
||||
|
||||
private TestBackgroundScreenDefault screen;
|
||||
private Graphics.Backgrounds.Background getCurrentBackground() => screen.ChildrenOfType<Graphics.Backgrounds.Background>().FirstOrDefault();
|
||||
|
||||
[Resolved]
|
||||
@ -36,10 +39,95 @@ namespace osu.Game.Tests.Visual.Background
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("create background stack", () => Child = stack = new BackgroundScreenStack());
|
||||
AddStep("push default screen", () => stack.Push(screen = new BackgroundScreenDefault(false)));
|
||||
AddStep("push default screen", () => stack.Push(screen = new TestBackgroundScreenDefault()));
|
||||
AddUntilStep("wait for screen to load", () => screen.IsCurrentScreen());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBeatmapBackgroundTracksBeatmap()
|
||||
{
|
||||
setSupporter(true);
|
||||
setSourceMode(BackgroundSource.Beatmap);
|
||||
|
||||
AddStep("change beatmap", () => Beatmap.Value = createTestWorkingBeatmapWithUniqueBackground());
|
||||
AddAssert("background changed", () => screen.CheckLastLoadChange() == true);
|
||||
|
||||
Graphics.Backgrounds.Background last = null;
|
||||
|
||||
AddUntilStep("wait for beatmap background to be loaded", () => getCurrentBackground()?.GetType() == typeof(BeatmapBackground));
|
||||
AddStep("store background", () => last = getCurrentBackground());
|
||||
|
||||
AddStep("change beatmap", () => Beatmap.Value = createTestWorkingBeatmapWithUniqueBackground());
|
||||
|
||||
AddUntilStep("wait for beatmap background to change", () => screen.CheckLastLoadChange() == true);
|
||||
|
||||
AddUntilStep("background is new beatmap background", () => last != getCurrentBackground());
|
||||
AddStep("store background", () => last = getCurrentBackground());
|
||||
|
||||
AddStep("change beatmap", () => Beatmap.Value = createTestWorkingBeatmapWithUniqueBackground());
|
||||
|
||||
AddUntilStep("wait for beatmap background to change", () => screen.CheckLastLoadChange() == true);
|
||||
AddUntilStep("background is new beatmap background", () => last != getCurrentBackground());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBeatmapBackgroundTracksBeatmapWhenSuspended()
|
||||
{
|
||||
setSupporter(true);
|
||||
setSourceMode(BackgroundSource.Beatmap);
|
||||
|
||||
AddStep("change beatmap", () => Beatmap.Value = createTestWorkingBeatmapWithUniqueBackground());
|
||||
AddAssert("background changed", () => screen.CheckLastLoadChange() == true);
|
||||
AddUntilStep("wait for beatmap background to be loaded", () => getCurrentBackground()?.GetType() == typeof(BeatmapBackground));
|
||||
|
||||
BackgroundScreenBeatmap nestedScreen = null;
|
||||
|
||||
// of note, this needs to be a type that doesn't match BackgroundScreenDefault else it is silently not pushed by the background stack.
|
||||
AddStep("push new background to stack", () => stack.Push(nestedScreen = new BackgroundScreenBeatmap(Beatmap.Value)));
|
||||
AddUntilStep("wait for screen to load", () => nestedScreen.IsLoaded && nestedScreen.IsCurrentScreen());
|
||||
|
||||
AddAssert("top level background hasn't changed yet", () => screen.CheckLastLoadChange() == null);
|
||||
|
||||
AddStep("change beatmap", () => Beatmap.Value = createTestWorkingBeatmapWithUniqueBackground());
|
||||
|
||||
AddAssert("top level background hasn't changed yet", () => screen.CheckLastLoadChange() == null);
|
||||
|
||||
AddStep("pop screen back to top level", () => screen.MakeCurrent());
|
||||
|
||||
AddAssert("top level background changed", () => screen.CheckLastLoadChange() == true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBeatmapBackgroundIgnoresNoChangeWhenSuspended()
|
||||
{
|
||||
BackgroundScreenBeatmap nestedScreen = null;
|
||||
WorkingBeatmap originalWorking = null;
|
||||
|
||||
setSupporter(true);
|
||||
setSourceMode(BackgroundSource.Beatmap);
|
||||
|
||||
AddStep("change beatmap", () => originalWorking = Beatmap.Value = createTestWorkingBeatmapWithUniqueBackground());
|
||||
AddAssert("background changed", () => screen.CheckLastLoadChange() == true);
|
||||
AddUntilStep("wait for beatmap background to be loaded", () => getCurrentBackground()?.GetType() == typeof(BeatmapBackground));
|
||||
|
||||
// of note, this needs to be a type that doesn't match BackgroundScreenDefault else it is silently not pushed by the background stack.
|
||||
AddStep("push new background to stack", () => stack.Push(nestedScreen = new BackgroundScreenBeatmap(Beatmap.Value)));
|
||||
AddUntilStep("wait for screen to load", () => nestedScreen.IsLoaded && nestedScreen.IsCurrentScreen());
|
||||
|
||||
// we're testing a case where scheduling may be used to avoid issues, so ensure the scheduler is no longer running.
|
||||
AddUntilStep("wait for top level not alive", () => !screen.IsAlive);
|
||||
|
||||
AddStep("change beatmap", () => Beatmap.Value = createTestWorkingBeatmapWithUniqueBackground());
|
||||
AddStep("change beatmap back", () => Beatmap.Value = originalWorking);
|
||||
|
||||
AddAssert("top level background hasn't changed yet", () => screen.CheckLastLoadChange() == null);
|
||||
|
||||
AddStep("pop screen back to top level", () => screen.MakeCurrent());
|
||||
|
||||
AddStep("top level screen is current", () => screen.IsCurrentScreen());
|
||||
AddAssert("top level background reused existing", () => screen.CheckLastLoadChange() == false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBackgroundTypeSwitch()
|
||||
{
|
||||
@ -78,36 +166,24 @@ namespace osu.Game.Tests.Visual.Background
|
||||
[TestCase(BackgroundSource.Skin, typeof(SkinBackground))]
|
||||
public void TestBackgroundDoesntReloadOnNoChange(BackgroundSource source, Type backgroundType)
|
||||
{
|
||||
Graphics.Backgrounds.Background last = null;
|
||||
|
||||
setSourceMode(source);
|
||||
setSupporter(true);
|
||||
if (source == BackgroundSource.Skin)
|
||||
setCustomSkin();
|
||||
|
||||
AddUntilStep("wait for beatmap background to be loaded", () => (last = getCurrentBackground())?.GetType() == backgroundType);
|
||||
AddUntilStep("wait for beatmap background to be loaded", () => (getCurrentBackground())?.GetType() == backgroundType);
|
||||
AddAssert("next doesn't load new background", () => screen.Next() == false);
|
||||
|
||||
// doesn't really need to be checked but might as well.
|
||||
AddWaitStep("wait a bit", 5);
|
||||
AddUntilStep("ensure same background instance", () => last == getCurrentBackground());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBackgroundCyclingOnDefaultSkin([Values] bool supporter)
|
||||
{
|
||||
Graphics.Backgrounds.Background last = null;
|
||||
|
||||
setSourceMode(BackgroundSource.Skin);
|
||||
setSupporter(supporter);
|
||||
setDefaultSkin();
|
||||
|
||||
AddUntilStep("wait for beatmap background to be loaded", () => (last = getCurrentBackground())?.GetType() == typeof(Graphics.Backgrounds.Background));
|
||||
AddUntilStep("wait for beatmap background to be loaded", () => (getCurrentBackground())?.GetType() == typeof(Graphics.Backgrounds.Background));
|
||||
AddAssert("next cycles background", () => screen.Next());
|
||||
|
||||
// doesn't really need to be checked but might as well.
|
||||
AddWaitStep("wait a bit", 5);
|
||||
AddUntilStep("ensure different background instance", () => last != getCurrentBackground());
|
||||
}
|
||||
|
||||
private void setSourceMode(BackgroundSource source) =>
|
||||
@ -120,10 +196,46 @@ namespace osu.Game.Tests.Visual.Background
|
||||
Id = API.LocalUser.Value.Id + 1,
|
||||
});
|
||||
|
||||
private WorkingBeatmap createTestWorkingBeatmapWithUniqueBackground() => new UniqueBackgroundTestWorkingBeatmap(Audio);
|
||||
|
||||
private class TestBackgroundScreenDefault : BackgroundScreenDefault
|
||||
{
|
||||
private bool? lastLoadTriggerCausedChange;
|
||||
|
||||
public TestBackgroundScreenDefault()
|
||||
: base(false)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Next()
|
||||
{
|
||||
bool didChange = base.Next();
|
||||
lastLoadTriggerCausedChange = didChange;
|
||||
return didChange;
|
||||
}
|
||||
|
||||
public bool? CheckLastLoadChange()
|
||||
{
|
||||
bool? lastChange = lastLoadTriggerCausedChange;
|
||||
lastLoadTriggerCausedChange = null;
|
||||
return lastChange;
|
||||
}
|
||||
}
|
||||
|
||||
private class UniqueBackgroundTestWorkingBeatmap : TestWorkingBeatmap
|
||||
{
|
||||
public UniqueBackgroundTestWorkingBeatmap(AudioManager audioManager)
|
||||
: base(new Beatmap(), null, audioManager)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Texture GetBackground() => new Texture(1, 1);
|
||||
}
|
||||
|
||||
private void setCustomSkin()
|
||||
{
|
||||
// feign a skin switch. this doesn't do anything except force CurrentSkin to become a LegacySkin.
|
||||
AddStep("set custom skin", () => skins.CurrentSkinInfo.Value = new SkinInfo().ToLive());
|
||||
AddStep("set custom skin", () => skins.CurrentSkinInfo.Value = new SkinInfo().ToLiveUnmanaged());
|
||||
}
|
||||
|
||||
private void setDefaultSkin() => AddStep("set default skin", () => skins.CurrentSkinInfo.SetDefault());
|
||||
|
@ -18,7 +18,6 @@ using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Scoring;
|
||||
@ -28,7 +27,6 @@ using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -229,12 +227,7 @@ namespace osu.Game.Tests.Visual.Background
|
||||
|
||||
FadeAccessibleResults results = null;
|
||||
|
||||
AddStep("Transition to Results", () => player.Push(results = new FadeAccessibleResults(new ScoreInfo
|
||||
{
|
||||
User = new APIUser { Username = "osu!" },
|
||||
BeatmapInfo = new TestBeatmap(Ruleset.Value).BeatmapInfo,
|
||||
Ruleset = Ruleset.Value,
|
||||
})));
|
||||
AddStep("Transition to Results", () => player.Push(results = new FadeAccessibleResults(TestResources.CreateTestScoreInfo())));
|
||||
|
||||
AddUntilStep("Wait for results is current", () => results.IsCurrentScreen());
|
||||
|
||||
|
@ -6,12 +6,12 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Beatmaps.Drawables.Cards;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API;
|
||||
@ -19,11 +19,10 @@ using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Beatmaps
|
||||
{
|
||||
public class TestSceneBeatmapCard : OsuTestScene
|
||||
public class TestSceneBeatmapCard : OsuManualInputManagerTestScene
|
||||
{
|
||||
/// <summary>
|
||||
/// All cards on this scene use a common online ID to ensure that map download, preview tracks, etc. can be tested manually with online sources.
|
||||
@ -254,14 +253,32 @@ namespace osu.Game.Tests.Visual.Beatmaps
|
||||
public void TestNormal()
|
||||
{
|
||||
createTestCase(beatmapSetInfo => new BeatmapCard(beatmapSetInfo));
|
||||
}
|
||||
|
||||
AddToggleStep("toggle expanded state", expanded =>
|
||||
{
|
||||
var card = this.ChildrenOfType<BeatmapCard>().Last();
|
||||
if (!card.Expanded.Disabled)
|
||||
card.Expanded.Value = expanded;
|
||||
});
|
||||
AddToggleStep("disable/enable expansion", disabled => this.ChildrenOfType<BeatmapCard>().ForEach(card => card.Expanded.Disabled = disabled));
|
||||
[Test]
|
||||
public void TestHoverState()
|
||||
{
|
||||
AddStep("create cards", () => Child = createContent(OverlayColourScheme.Blue, s => new BeatmapCard(s)));
|
||||
|
||||
AddStep("Hover card", () => InputManager.MoveMouseTo(firstCard()));
|
||||
AddWaitStep("wait for potential state change", 5);
|
||||
AddAssert("card is not expanded", () => !firstCard().Expanded.Value);
|
||||
|
||||
AddStep("Hover spectrum display", () => InputManager.MoveMouseTo(firstCard().ChildrenOfType<DifficultySpectrumDisplay>().Single()));
|
||||
AddUntilStep("card is expanded", () => firstCard().Expanded.Value);
|
||||
|
||||
AddStep("Hover difficulty content", () => InputManager.MoveMouseTo(firstCard().ChildrenOfType<BeatmapCardDifficultyList>().Single()));
|
||||
AddWaitStep("wait for potential state change", 5);
|
||||
AddAssert("card is still expanded", () => firstCard().Expanded.Value);
|
||||
|
||||
AddStep("Hover main content again", () => InputManager.MoveMouseTo(firstCard()));
|
||||
AddWaitStep("wait for potential state change", 5);
|
||||
AddAssert("card is still expanded", () => firstCard().Expanded.Value);
|
||||
|
||||
AddStep("Hover away", () => InputManager.MoveMouseTo(this.ChildrenOfType<BeatmapCard>().Last()));
|
||||
AddUntilStep("card is not expanded", () => !firstCard().Expanded.Value);
|
||||
|
||||
BeatmapCard firstCard() => this.ChildrenOfType<BeatmapCard>().First();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osu.Game.Screens.Edit;
|
||||
@ -44,6 +45,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
protected override void LoadEditor()
|
||||
{
|
||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(importedBeatmapSet.Beatmaps.First(b => b.RulesetID == 0));
|
||||
SelectedMods.Value = new[] { new ModCinema() };
|
||||
base.LoadEditor();
|
||||
}
|
||||
|
||||
@ -67,6 +69,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
var background = this.ChildrenOfType<BackgroundScreenBeatmap>().Single();
|
||||
return background.Colour == Color4.DarkGray && background.BlurAmount.Value == 0;
|
||||
});
|
||||
AddAssert("no mods selected", () => SelectedMods.Value.Count == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
AddStep("setup skins", () =>
|
||||
{
|
||||
skinManager.CurrentSkinInfo.Value = gameCurrentSkin.ToLive();
|
||||
skinManager.CurrentSkinInfo.Value = gameCurrentSkin.ToLiveUnmanaged();
|
||||
currentBeatmapSkin = getBeatmapSkin();
|
||||
});
|
||||
});
|
||||
|
@ -26,6 +26,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddAssert("total number of results == 1", () =>
|
||||
{
|
||||
var score = new ScoreInfo();
|
||||
|
||||
((FailPlayer)Player).ScoreProcessor.PopulateScore(score);
|
||||
|
||||
return score.Statistics.Values.Sum() == 1;
|
||||
|
@ -85,11 +85,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
loopGroup.Scale.Add(Easing.None, -20000, -18000, 0, 1);
|
||||
|
||||
var target = addEventToLoop ? loopGroup : sprite.TimelineGroup;
|
||||
target.Alpha.Add(Easing.None, firstStoryboardEvent, firstStoryboardEvent + 500, 0, 1);
|
||||
double targetTime = addEventToLoop ? 20000 : 0;
|
||||
target.Alpha.Add(Easing.None, targetTime + firstStoryboardEvent, targetTime + firstStoryboardEvent + 500, 0, 1);
|
||||
|
||||
// these should be ignored due to being in the future.
|
||||
sprite.TimelineGroup.Alpha.Add(Easing.None, 18000, 20000, 0, 1);
|
||||
loopGroup.Alpha.Add(Easing.None, 18000, 20000, 0, 1);
|
||||
loopGroup.Alpha.Add(Easing.None, 38000, 40000, 0, 1);
|
||||
|
||||
storyboard.GetLayer("Background").Add(sprite);
|
||||
|
||||
|
@ -251,7 +251,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestMutedNotificationMuteButton()
|
||||
{
|
||||
addVolumeSteps("mute button", () => volumeOverlay.IsMuted.Value = true, () => !volumeOverlay.IsMuted.Value);
|
||||
addVolumeSteps("mute button", () =>
|
||||
{
|
||||
// Importantly, in the case the volume is muted but the user has a volume level set, it should be retained.
|
||||
audioManager.VolumeTrack.Value = 0.5f;
|
||||
volumeOverlay.IsMuted.Value = true;
|
||||
}, () => !volumeOverlay.IsMuted.Value && audioManager.VolumeTrack.Value == 0.5f);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
|
@ -164,7 +164,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private ScoreInfo getScoreInfo(bool replayAvailable)
|
||||
{
|
||||
return new APIScoreInfo
|
||||
return new APIScore
|
||||
{
|
||||
OnlineID = 2553163309,
|
||||
RulesetID = 0,
|
||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestFirstItemSelectedByDefault()
|
||||
{
|
||||
AddAssert("first item selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
|
||||
AddAssert("first item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -27,13 +27,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
addItem(() => OtherBeatmap);
|
||||
AddAssert("playlist has 2 items", () => Client.APIRoom?.Playlist.Count == 2);
|
||||
AddAssert("last playlist item is different", () => Client.APIRoom?.Playlist[1].Beatmap.Value.OnlineID == OtherBeatmap.OnlineID);
|
||||
|
||||
addItem(() => InitialBeatmap);
|
||||
AddAssert("playlist has 3 items", () => Client.APIRoom?.Playlist.Count == 3);
|
||||
AddAssert("last playlist item is different", () => Client.APIRoom?.Playlist[2].Beatmap.Value.OnlineID == InitialBeatmap.OnlineID);
|
||||
|
||||
AddAssert("first item still selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
|
||||
AddAssert("first item still selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -43,7 +41,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
AddAssert("playlist has only one item", () => Client.APIRoom?.Playlist.Count == 1);
|
||||
AddAssert("playlist item is expired", () => Client.APIRoom?.Playlist[0].Expired == true);
|
||||
AddAssert("last item selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
|
||||
AddAssert("last item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -55,12 +53,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
RunGameplay();
|
||||
|
||||
AddAssert("first item expired", () => Client.APIRoom?.Playlist[0].Expired == true);
|
||||
AddAssert("next item selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[1].ID);
|
||||
AddAssert("next item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[1].ID);
|
||||
|
||||
RunGameplay();
|
||||
|
||||
AddAssert("second item expired", () => Client.APIRoom?.Playlist[1].Expired == true);
|
||||
AddAssert("next item selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[2].ID);
|
||||
AddAssert("next item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[2].ID);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -74,22 +72,22 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
AddStep("change queue mode", () => Client.ChangeSettings(queueMode: QueueMode.HostOnly));
|
||||
AddAssert("playlist has 3 items", () => Client.APIRoom?.Playlist.Count == 3);
|
||||
AddAssert("playlist item is the other beatmap", () => Client.CurrentMatchPlayingItem.Value?.BeatmapID == OtherBeatmap.OnlineID);
|
||||
AddAssert("playlist item is not expired", () => Client.APIRoom?.Playlist[1].Expired == false);
|
||||
AddAssert("item 2 is not expired", () => Client.APIRoom?.Playlist[1].Expired == false);
|
||||
AddAssert("current item is the other beatmap", () => Client.Room?.Settings.PlaylistItemId == 2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCorrectItemSelectedAfterNewItemAdded()
|
||||
{
|
||||
addItem(() => OtherBeatmap);
|
||||
AddAssert("selected beatmap is initial beatmap", () => Beatmap.Value.BeatmapInfo.OnlineID == InitialBeatmap.OnlineID);
|
||||
AddUntilStep("selected beatmap is initial beatmap", () => Beatmap.Value.BeatmapInfo.OnlineID == InitialBeatmap.OnlineID);
|
||||
}
|
||||
|
||||
private void addItem(Func<BeatmapInfo> beatmap)
|
||||
{
|
||||
AddStep("click edit button", () =>
|
||||
AddStep("click add button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerMatchSubScreen>().Single().AddOrEditPlaylistButton);
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerMatchSubScreen.AddItemButton>().Single());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
@ -48,7 +49,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestNonEditableNonSelectable()
|
||||
{
|
||||
createPlaylist(false, false);
|
||||
createPlaylist();
|
||||
|
||||
moveToItem(0);
|
||||
assertHandleVisibility(0, false);
|
||||
@ -61,7 +62,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestEditable()
|
||||
{
|
||||
createPlaylist(true, false);
|
||||
createPlaylist(p =>
|
||||
{
|
||||
p.AllowReordering = true;
|
||||
p.AllowDeletion = true;
|
||||
});
|
||||
|
||||
moveToItem(0);
|
||||
assertHandleVisibility(0, true);
|
||||
@ -74,7 +79,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestMarkInvalid()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
createPlaylist(p =>
|
||||
{
|
||||
p.AllowReordering = true;
|
||||
p.AllowDeletion = true;
|
||||
p.AllowSelection = true;
|
||||
});
|
||||
|
||||
AddStep("mark item 0 as invalid", () => playlist.Items[0].MarkInvalid());
|
||||
|
||||
@ -87,7 +97,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestSelectable()
|
||||
{
|
||||
createPlaylist(false, true);
|
||||
createPlaylist(p => p.AllowSelection = true);
|
||||
|
||||
moveToItem(0);
|
||||
assertHandleVisibility(0, false);
|
||||
@ -101,7 +111,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestEditableSelectable()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
createPlaylist(p =>
|
||||
{
|
||||
p.AllowReordering = true;
|
||||
p.AllowDeletion = true;
|
||||
p.AllowSelection = true;
|
||||
});
|
||||
|
||||
moveToItem(0);
|
||||
assertHandleVisibility(0, true);
|
||||
@ -115,7 +130,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestSelectionNotLostAfterRearrangement()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
createPlaylist(p =>
|
||||
{
|
||||
p.AllowReordering = true;
|
||||
p.AllowDeletion = true;
|
||||
p.AllowSelection = true;
|
||||
});
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
@ -128,95 +148,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddAssert("item 1 is selected", () => playlist.SelectedItem.Value == playlist.Items[1]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestItemRemovedOnDeletion()
|
||||
{
|
||||
PlaylistItem selectedItem = null;
|
||||
|
||||
createPlaylist(true, true);
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("retrieve selection", () => selectedItem = playlist.SelectedItem.Value);
|
||||
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("item removed", () => !playlist.Items.Contains(selectedItem));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNextItemSelectedAfterDeletion()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("item 0 is selected", () => playlist.SelectedItem.Value == playlist.Items[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLastItemSelectedAfterLastItemDeleted()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
|
||||
AddWaitStep("wait for flow", 5); // Items may take 1 update frame to flow. A wait count of 5 is guaranteed to result in the flow being updated as desired.
|
||||
AddStep("scroll to bottom", () => playlist.ChildrenOfType<ScrollContainer<Drawable>>().First().ScrollToEnd(false));
|
||||
|
||||
moveToItem(19);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
moveToDeleteButton(19);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("item 18 is selected", () => playlist.SelectedItem.Value == playlist.Items[18]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectionResetWhenAllItemsDeleted()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
|
||||
AddStep("remove all but one item", () =>
|
||||
{
|
||||
playlist.Items.RemoveRange(1, playlist.Items.Count - 1);
|
||||
});
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("no item selected", () => playlist.SelectedItem.Value == null);
|
||||
}
|
||||
|
||||
// Todo: currently not possible due to bindable list shortcomings (https://github.com/ppy/osu-framework/issues/3081)
|
||||
// [Test]
|
||||
public void TestNextItemSelectedAfterExternalDeletion()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("remove item 0", () => playlist.Items.RemoveAt(0));
|
||||
|
||||
AddAssert("item 0 is selected", () => playlist.SelectedItem.Value == playlist.Items[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChangeBeatmapAndRemove()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
|
||||
AddStep("change beatmap of first item", () => playlist.Items[0].BeatmapID = 30);
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDownloadButtonHiddenWhenBeatmapExists()
|
||||
{
|
||||
@ -224,7 +155,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
AddStep("import beatmap", () => manager.Import(beatmap.BeatmapSet).Wait());
|
||||
|
||||
createPlaylist(beatmap);
|
||||
createPlaylistWithBeatmaps(beatmap);
|
||||
|
||||
assertDownloadButtonVisible(false);
|
||||
|
||||
@ -247,7 +178,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
var byChecksum = CreateAPIBeatmap();
|
||||
byChecksum.Checksum = "1337"; // Some random checksum that does not exist locally.
|
||||
|
||||
createPlaylist(byOnlineId, byChecksum);
|
||||
createPlaylistWithBeatmaps(byOnlineId, byChecksum);
|
||||
|
||||
AddAssert("download buttons shown", () => playlist.ChildrenOfType<BeatmapDownloadButton>().All(d => d.IsPresent));
|
||||
}
|
||||
@ -261,7 +192,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
beatmap.BeatmapSet.HasExplicitContent = true;
|
||||
|
||||
createPlaylist(beatmap);
|
||||
createPlaylistWithBeatmaps(beatmap);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -269,7 +200,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
AddStep("create playlist", () =>
|
||||
{
|
||||
Child = playlist = new TestPlaylist(false, false)
|
||||
Child = playlist = new TestPlaylist
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -312,11 +243,22 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[TestCase(true)]
|
||||
public void TestWithOwner(bool withOwner)
|
||||
{
|
||||
createPlaylist(false, false, withOwner);
|
||||
createPlaylist(p => p.ShowItemOwners = withOwner);
|
||||
|
||||
AddAssert("owner visible", () => playlist.ChildrenOfType<UpdateableAvatar>().All(a => a.IsPresent == withOwner));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestWithAllButtonsEnabled()
|
||||
{
|
||||
createPlaylist(p =>
|
||||
{
|
||||
p.AllowDeletion = true;
|
||||
p.AllowShowingResults = true;
|
||||
p.AllowEditing = true;
|
||||
});
|
||||
}
|
||||
|
||||
private void moveToItem(int index, Vector2? offset = null)
|
||||
=> AddStep($"move mouse to item {index}", () => InputManager.MoveMouseTo(playlist.ChildrenOfType<DifficultyIcon>().ElementAt(index), offset));
|
||||
|
||||
@ -326,12 +268,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
InputManager.MoveMouseTo(item.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>.PlaylistItemHandle>().Single(), offset);
|
||||
});
|
||||
|
||||
private void moveToDeleteButton(int index, Vector2? offset = null) => AddStep($"move mouse to delete button {index}", () =>
|
||||
{
|
||||
var item = playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>>().ElementAt(index);
|
||||
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0), offset);
|
||||
});
|
||||
|
||||
private void assertHandleVisibility(int index, bool visible)
|
||||
=> AddAssert($"handle {index} {(visible ? "is" : "is not")} visible",
|
||||
() => (playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>.PlaylistItemHandle>().ElementAt(index).Alpha > 0) == visible);
|
||||
@ -340,17 +276,19 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
=> AddAssert($"delete button {index} {(visible ? "is" : "is not")} visible",
|
||||
() => (playlist.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(2 + index * 2).Alpha > 0) == visible);
|
||||
|
||||
private void createPlaylist(bool allowEdit, bool allowSelection, bool showItemOwner = false)
|
||||
private void createPlaylist(Action<TestPlaylist> setupPlaylist = null)
|
||||
{
|
||||
AddStep("create playlist", () =>
|
||||
{
|
||||
Child = playlist = new TestPlaylist(allowEdit, allowSelection, showItemOwner)
|
||||
Child = playlist = new TestPlaylist
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(500, 300)
|
||||
};
|
||||
|
||||
setupPlaylist?.Invoke(playlist);
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
playlist.Items.Add(new PlaylistItem
|
||||
@ -386,11 +324,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddUntilStep("wait for items to load", () => playlist.ItemMap.Values.All(i => i.IsLoaded));
|
||||
}
|
||||
|
||||
private void createPlaylist(params IBeatmapInfo[] beatmaps)
|
||||
private void createPlaylistWithBeatmaps(params IBeatmapInfo[] beatmaps)
|
||||
{
|
||||
AddStep("create playlist", () =>
|
||||
{
|
||||
Child = playlist = new TestPlaylist(false, false)
|
||||
Child = playlist = new TestPlaylist
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -423,11 +361,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
private class TestPlaylist : DrawableRoomPlaylist
|
||||
{
|
||||
public new IReadOnlyDictionary<PlaylistItem, RearrangeableListItem<PlaylistItem>> ItemMap => base.ItemMap;
|
||||
|
||||
public TestPlaylist(bool allowEdit, bool allowSelection, bool showItemOwner = false)
|
||||
: base(allowEdit, allowSelection, showItemOwner: showItemOwner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,9 @@ using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens.OnlinePlay;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
@ -19,7 +21,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestFirstItemSelectedByDefault()
|
||||
{
|
||||
AddAssert("first item selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
|
||||
AddAssert("first item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -27,7 +29,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
selectNewItem(() => InitialBeatmap);
|
||||
|
||||
AddAssert("playlist item still selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
|
||||
AddAssert("playlist item still selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -35,7 +37,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
selectNewItem(() => OtherBeatmap);
|
||||
|
||||
AddAssert("playlist item still selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
|
||||
AddAssert("playlist item still selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -46,7 +48,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddAssert("playlist contains two items", () => Client.APIRoom?.Playlist.Count == 2);
|
||||
AddAssert("first playlist item expired", () => Client.APIRoom?.Playlist[0].Expired == true);
|
||||
AddAssert("second playlist item not expired", () => Client.APIRoom?.Playlist[1].Expired == false);
|
||||
AddAssert("second playlist item selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[1].ID);
|
||||
AddAssert("second playlist item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[1].ID);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -74,11 +76,25 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddUntilStep("api room updated", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAddItemsAsHost()
|
||||
{
|
||||
addItem(() => OtherBeatmap);
|
||||
|
||||
AddAssert("playlist contains two items", () => Client.APIRoom?.Playlist.Count == 2);
|
||||
}
|
||||
|
||||
private void selectNewItem(Func<BeatmapInfo> beatmap)
|
||||
{
|
||||
AddUntilStep("wait for playlist panels to load", () =>
|
||||
{
|
||||
var queueList = this.ChildrenOfType<MultiplayerQueueList>().Single();
|
||||
return queueList.ChildrenOfType<DrawableRoomPlaylistItem>().Count() == queueList.Items.Count;
|
||||
});
|
||||
|
||||
AddStep("click edit button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerMatchSubScreen>().Single().AddOrEditPlaylistButton);
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistEditButton>().First());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
@ -88,7 +104,20 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddStep("select other beatmap", () => ((Screens.Select.SongSelect)CurrentSubScreen).FinaliseSelection(otherBeatmap = beatmap()));
|
||||
|
||||
AddUntilStep("wait for return to match", () => CurrentSubScreen is MultiplayerMatchSubScreen);
|
||||
AddUntilStep("selected item is new beatmap", () => Client.CurrentMatchPlayingItem.Value?.Beatmap.Value?.OnlineID == otherBeatmap.OnlineID);
|
||||
AddUntilStep("selected item is new beatmap", () => (CurrentSubScreen as MultiplayerMatchSubScreen)?.SelectedItem.Value?.BeatmapID == otherBeatmap.OnlineID);
|
||||
}
|
||||
|
||||
private void addItem(Func<BeatmapInfo> beatmap)
|
||||
{
|
||||
AddStep("click add button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerMatchSubScreen.AddItemButton>().Single());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for song select", () => CurrentSubScreen is Screens.Select.SongSelect select && select.BeatmapSetsLoaded);
|
||||
AddStep("select other beatmap", () => ((Screens.Select.SongSelect)CurrentSubScreen).FinaliseSelection(beatmap()));
|
||||
AddUntilStep("wait for return to match", () => CurrentSubScreen is MultiplayerMatchSubScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Match;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Screens.Spectate;
|
||||
@ -391,9 +393,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("set user ready", () => client.ChangeState(MultiplayerUserState.Ready));
|
||||
AddStep("delete beatmap", () => beatmaps.Delete(importedSet));
|
||||
pressReadyButton();
|
||||
|
||||
AddStep("delete beatmap", () => beatmaps.Delete(importedSet));
|
||||
AddUntilStep("user state is idle", () => client.LocalUser?.State == MultiplayerUserState.Idle);
|
||||
}
|
||||
|
||||
@ -413,11 +415,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}
|
||||
});
|
||||
|
||||
pressReadyButton();
|
||||
|
||||
AddStep("Enter song select", () =>
|
||||
{
|
||||
var currentSubScreen = ((Screens.OnlinePlay.Multiplayer.Multiplayer)multiplayerScreenStack.CurrentScreen).CurrentSubScreen;
|
||||
|
||||
((MultiplayerMatchSubScreen)currentSubScreen).SelectBeatmap();
|
||||
((MultiplayerMatchSubScreen)currentSubScreen).OpenSongSelection(client.Room?.Settings.PlaylistItemId);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for song select", () => this.ChildrenOfType<MultiplayerMatchSongSelect>().FirstOrDefault()?.BeatmapSetsLoaded == true);
|
||||
@ -593,20 +596,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}
|
||||
});
|
||||
|
||||
AddUntilStep("wait for ready button to be enabled", () => readyButton.ChildrenOfType<OsuButton>().Single().Enabled.Value);
|
||||
|
||||
AddStep("click ready button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(readyButton);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for player to be ready", () => client.Room?.Users[0].State == MultiplayerUserState.Ready);
|
||||
AddUntilStep("wait for ready button to be enabled", () => readyButton.ChildrenOfType<OsuButton>().Single().Enabled.Value);
|
||||
|
||||
AddStep("click start button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddUntilStep("wait for player", () => multiplayerScreenStack.CurrentScreen is Player);
|
||||
enterGameplay();
|
||||
|
||||
// Gameplay runs in real-time, so we need to incrementally check if gameplay has finished in order to not time out.
|
||||
for (double i = 1000; i < TestResources.QUICK_BEATMAP_LENGTH; i += 1000)
|
||||
@ -666,7 +656,173 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
});
|
||||
}
|
||||
|
||||
private MultiplayerReadyButton readyButton => this.ChildrenOfType<MultiplayerReadyButton>().Single();
|
||||
[Test]
|
||||
public void TestSpectatingStateResetOnBackButtonDuringGameplay()
|
||||
{
|
||||
createRoom(() => new Room
|
||||
{
|
||||
Name = { Value = "Test Room" },
|
||||
QueueMode = { Value = QueueMode.AllPlayers },
|
||||
Playlist =
|
||||
{
|
||||
new PlaylistItem
|
||||
{
|
||||
Beatmap = { Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo },
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("set spectating state", () => client.ChangeUserState(API.LocalUser.Value.OnlineID, MultiplayerUserState.Spectating));
|
||||
AddUntilStep("state set to spectating", () => client.LocalUser?.State == MultiplayerUserState.Spectating);
|
||||
|
||||
AddStep("join other user", () => client.AddUser(new APIUser { Id = 1234 }));
|
||||
AddStep("set other user ready", () => client.ChangeUserState(1234, MultiplayerUserState.Ready));
|
||||
|
||||
pressReadyButton(1234);
|
||||
AddUntilStep("wait for gameplay", () => (multiplayerScreenStack.CurrentScreen as MultiSpectatorScreen)?.IsLoaded == true);
|
||||
|
||||
AddStep("press back button and exit", () =>
|
||||
{
|
||||
multiplayerScreenStack.OnBackButton();
|
||||
multiplayerScreenStack.Exit();
|
||||
});
|
||||
|
||||
AddUntilStep("wait for return to match subscreen", () => multiplayerScreenStack.MultiplayerScreen.IsCurrentScreen());
|
||||
AddUntilStep("user state is idle", () => client.LocalUser?.State == MultiplayerUserState.Idle);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSpectatingStateNotResetOnBackButtonOutsideOfGameplay()
|
||||
{
|
||||
createRoom(() => new Room
|
||||
{
|
||||
Name = { Value = "Test Room" },
|
||||
QueueMode = { Value = QueueMode.AllPlayers },
|
||||
Playlist =
|
||||
{
|
||||
new PlaylistItem
|
||||
{
|
||||
Beatmap = { Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo },
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("set spectating state", () => client.ChangeUserState(API.LocalUser.Value.OnlineID, MultiplayerUserState.Spectating));
|
||||
AddUntilStep("state set to spectating", () => client.LocalUser?.State == MultiplayerUserState.Spectating);
|
||||
|
||||
AddStep("join other user", () => client.AddUser(new APIUser { Id = 1234 }));
|
||||
AddStep("set other user ready", () => client.ChangeUserState(1234, MultiplayerUserState.Ready));
|
||||
|
||||
pressReadyButton(1234);
|
||||
AddUntilStep("wait for gameplay", () => (multiplayerScreenStack.CurrentScreen as MultiSpectatorScreen)?.IsLoaded == true);
|
||||
AddStep("set other user loaded", () => client.ChangeUserState(1234, MultiplayerUserState.Loaded));
|
||||
AddStep("set other user finished play", () => client.ChangeUserState(1234, MultiplayerUserState.FinishedPlay));
|
||||
|
||||
AddStep("press back button and exit", () =>
|
||||
{
|
||||
multiplayerScreenStack.OnBackButton();
|
||||
multiplayerScreenStack.Exit();
|
||||
});
|
||||
|
||||
AddUntilStep("wait for return to match subscreen", () => multiplayerScreenStack.MultiplayerScreen.IsCurrentScreen());
|
||||
AddWaitStep("wait for possible state change", 5);
|
||||
AddUntilStep("user state is spectating", () => client.LocalUser?.State == MultiplayerUserState.Spectating);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestItemAddedByOtherUserDuringGameplay()
|
||||
{
|
||||
createRoom(() => new Room
|
||||
{
|
||||
Name = { Value = "Test Room" },
|
||||
QueueMode = { Value = QueueMode.AllPlayers },
|
||||
Playlist =
|
||||
{
|
||||
new PlaylistItem
|
||||
{
|
||||
Beatmap = { Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo },
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
enterGameplay();
|
||||
|
||||
AddStep("join other user", () => client.AddUser(new APIUser { Id = 1234 }));
|
||||
AddStep("add item as other user", () => client.AddUserPlaylistItem(1234, new MultiplayerPlaylistItem(new PlaylistItem
|
||||
{
|
||||
BeatmapID = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo.OnlineID ?? -1
|
||||
})));
|
||||
|
||||
AddUntilStep("item arrived in playlist", () => client.Room?.Playlist.Count == 2);
|
||||
|
||||
AddStep("exit gameplay as initial user", () => multiplayerScreenStack.MultiplayerScreen.MakeCurrent());
|
||||
AddUntilStep("queue contains item", () => this.ChildrenOfType<MultiplayerQueueList>().Single().Items.Single().ID == 2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestItemAddedAndDeletedByOtherUserDuringGameplay()
|
||||
{
|
||||
createRoom(() => new Room
|
||||
{
|
||||
Name = { Value = "Test Room" },
|
||||
QueueMode = { Value = QueueMode.AllPlayers },
|
||||
Playlist =
|
||||
{
|
||||
new PlaylistItem
|
||||
{
|
||||
Beatmap = { Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo },
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
enterGameplay();
|
||||
|
||||
AddStep("join other user", () => client.AddUser(new APIUser { Id = 1234 }));
|
||||
AddStep("add item as other user", () => client.AddUserPlaylistItem(1234, new MultiplayerPlaylistItem(new PlaylistItem
|
||||
{
|
||||
BeatmapID = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo.OnlineID ?? -1
|
||||
})));
|
||||
|
||||
AddUntilStep("item arrived in playlist", () => client.Room?.Playlist.Count == 2);
|
||||
|
||||
AddStep("delete item as other user", () => client.RemoveUserPlaylistItem(1234, 2));
|
||||
AddUntilStep("item removed from playlist", () => client.Room?.Playlist.Count == 1);
|
||||
|
||||
AddStep("exit gameplay as initial user", () => multiplayerScreenStack.MultiplayerScreen.MakeCurrent());
|
||||
AddUntilStep("queue is empty", () => this.ChildrenOfType<MultiplayerQueueList>().Single().Items.Count == 0);
|
||||
}
|
||||
|
||||
private void enterGameplay()
|
||||
{
|
||||
pressReadyButton();
|
||||
pressReadyButton();
|
||||
AddUntilStep("wait for player", () => multiplayerScreenStack.CurrentScreen is Player);
|
||||
}
|
||||
|
||||
private ReadyButton readyButton => this.ChildrenOfType<ReadyButton>().Single();
|
||||
|
||||
private void pressReadyButton(int? playingUserId = null)
|
||||
{
|
||||
AddUntilStep("wait for ready button to be enabled", () => readyButton.Enabled.Value);
|
||||
|
||||
MultiplayerUserState lastState = MultiplayerUserState.Idle;
|
||||
MultiplayerRoomUser user = null;
|
||||
|
||||
AddStep("click ready button", () =>
|
||||
{
|
||||
user = playingUserId == null ? client.LocalUser : client.Room?.Users.Single(u => u.UserID == playingUserId);
|
||||
lastState = user?.State ?? MultiplayerUserState.Idle;
|
||||
|
||||
InputManager.MoveMouseTo(readyButton);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for state change", () => user?.State != lastState);
|
||||
}
|
||||
|
||||
private void createRoom(Func<Room> room)
|
||||
{
|
||||
|
@ -179,7 +179,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
public new BeatmapCarousel Carousel => base.Carousel;
|
||||
|
||||
public TestMultiplayerMatchSongSelect(Room room, WorkingBeatmap beatmap = null, RulesetInfo ruleset = null)
|
||||
: base(room, beatmap, ruleset)
|
||||
: base(room, null, beatmap, ruleset)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using NUnit.Framework;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||
|
||||
@ -27,7 +28,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
AddStep("initialise gameplay", () =>
|
||||
{
|
||||
Stack.Push(player = new MultiplayerPlayer(Client.APIRoom, Client.CurrentMatchPlayingItem.Value, Client.Room?.Users.ToArray()));
|
||||
Stack.Push(player = new MultiplayerPlayer(Client.APIRoom, new PlaylistItem
|
||||
{
|
||||
Beatmap = { Value = Beatmap.Value.BeatmapInfo },
|
||||
Ruleset = { Value = Beatmap.Value.BeatmapInfo.Ruleset }
|
||||
}, Client.Room?.Users.ToArray()));
|
||||
});
|
||||
|
||||
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen() && player.IsLoaded);
|
||||
|
@ -0,0 +1,164 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.OnlinePlay;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneMultiplayerQueueList : MultiplayerTestScene
|
||||
{
|
||||
private readonly Bindable<PlaylistItem> selectedItem = new Bindable<PlaylistItem>();
|
||||
|
||||
[Cached(typeof(UserLookupCache))]
|
||||
private readonly TestUserLookupCache userLookupCache = new TestUserLookupCache();
|
||||
|
||||
private MultiplayerQueueList playlist;
|
||||
private BeatmapManager beatmaps;
|
||||
private RulesetStore rulesets;
|
||||
private BeatmapSetInfo importedSet;
|
||||
private BeatmapInfo importedBeatmap;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host, AudioManager audio)
|
||||
{
|
||||
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
||||
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
|
||||
}
|
||||
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
|
||||
AddStep("create playlist", () =>
|
||||
{
|
||||
selectedItem.Value = null;
|
||||
|
||||
Child = playlist = new MultiplayerQueueList
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(500, 300),
|
||||
SelectedItem = { BindTarget = selectedItem },
|
||||
Items = { BindTarget = Client.APIRoom!.Playlist }
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("import beatmap", () =>
|
||||
{
|
||||
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).Wait();
|
||||
importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
|
||||
importedBeatmap = importedSet.Beatmaps.First(b => b.RulesetID == 0);
|
||||
});
|
||||
|
||||
AddStep("change to all players mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDeleteButtonAlwaysVisibleForHost()
|
||||
{
|
||||
AddStep("set all players queue mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers }));
|
||||
AddUntilStep("wait for queue mode change", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers);
|
||||
|
||||
addPlaylistItem(() => API.LocalUser.Value.OnlineID);
|
||||
assertDeleteButtonVisibility(1, true);
|
||||
addPlaylistItem(() => 1234);
|
||||
assertDeleteButtonVisibility(2, true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDeleteButtonOnlyVisibleForItemOwnerIfNotHost()
|
||||
{
|
||||
AddStep("set all players queue mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers }));
|
||||
AddUntilStep("wait for queue mode change", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers);
|
||||
|
||||
AddStep("join other user", () => Client.AddUser(new APIUser { Id = 1234 }));
|
||||
AddStep("set other user as host", () => Client.TransferHost(1234));
|
||||
|
||||
addPlaylistItem(() => API.LocalUser.Value.OnlineID);
|
||||
assertDeleteButtonVisibility(1, true);
|
||||
addPlaylistItem(() => 1234);
|
||||
assertDeleteButtonVisibility(2, false);
|
||||
|
||||
AddStep("set local user as host", () => Client.TransferHost(API.LocalUser.Value.OnlineID));
|
||||
assertDeleteButtonVisibility(1, true);
|
||||
assertDeleteButtonVisibility(2, true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCurrentItemDoesNotHaveDeleteButton()
|
||||
{
|
||||
AddStep("set all players queue mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers }));
|
||||
AddUntilStep("wait for queue mode change", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers);
|
||||
|
||||
addPlaylistItem(() => API.LocalUser.Value.OnlineID);
|
||||
|
||||
AddStep("select item 0", () => selectedItem.Value = playlist.ChildrenOfType<RearrangeableListItem<PlaylistItem>>().ElementAt(0).Model);
|
||||
assertDeleteButtonVisibility(0, false);
|
||||
assertDeleteButtonVisibility(1, true);
|
||||
|
||||
AddStep("select item 1", () => selectedItem.Value = playlist.ChildrenOfType<RearrangeableListItem<PlaylistItem>>().ElementAt(1).Model);
|
||||
assertDeleteButtonVisibility(0, true);
|
||||
assertDeleteButtonVisibility(1, false);
|
||||
}
|
||||
|
||||
private void addPlaylistItem(Func<int> userId)
|
||||
{
|
||||
long itemId = -1;
|
||||
|
||||
AddStep("add playlist item", () =>
|
||||
{
|
||||
MultiplayerPlaylistItem item = new MultiplayerPlaylistItem(new PlaylistItem
|
||||
{
|
||||
Beatmap = { Value = importedBeatmap },
|
||||
BeatmapID = importedBeatmap.OnlineID ?? -1,
|
||||
});
|
||||
|
||||
Client.AddUserPlaylistItem(userId(), item);
|
||||
|
||||
itemId = item.ID;
|
||||
});
|
||||
|
||||
AddUntilStep("item arrived in playlist", () => playlist.ChildrenOfType<RearrangeableListItem<PlaylistItem>>().Any(i => i.Model.ID == itemId));
|
||||
}
|
||||
|
||||
private void deleteItem(int index)
|
||||
{
|
||||
OsuRearrangeableListItem<PlaylistItem> item = null;
|
||||
|
||||
AddStep($"move mouse to delete button {index}", () =>
|
||||
{
|
||||
item = playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>>().ElementAt(index);
|
||||
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0));
|
||||
});
|
||||
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddUntilStep("item removed from playlist", () => !playlist.ChildrenOfType<RearrangeableListItem<PlaylistItem>>().Contains(item));
|
||||
}
|
||||
|
||||
private void assertDeleteButtonVisibility(int index, bool visible)
|
||||
=> AddUntilStep($"delete button {index} {(visible ? "is" : "is not")} visible",
|
||||
() => (playlist.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(index).Alpha > 0) == visible);
|
||||
}
|
||||
}
|
@ -1,13 +1,11 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
@ -22,20 +20,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
var rulesetInfo = new OsuRuleset().RulesetInfo;
|
||||
var beatmapInfo = CreateBeatmap(rulesetInfo).BeatmapInfo;
|
||||
|
||||
var score = new ScoreInfo
|
||||
{
|
||||
Rank = ScoreRank.B,
|
||||
TotalScore = 987654,
|
||||
Accuracy = 0.8,
|
||||
MaxCombo = 500,
|
||||
Combo = 250,
|
||||
BeatmapInfo = beatmapInfo,
|
||||
User = new APIUser { Username = "Test user" },
|
||||
Date = DateTimeOffset.Now,
|
||||
OnlineScoreID = 12345,
|
||||
Ruleset = rulesetInfo,
|
||||
};
|
||||
var score = TestResources.CreateTestScoreInfo(beatmapInfo);
|
||||
|
||||
PlaylistItem playlistItem = new PlaylistItem
|
||||
{
|
||||
|
@ -1,15 +1,13 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
@ -26,20 +24,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
var rulesetInfo = new OsuRuleset().RulesetInfo;
|
||||
var beatmapInfo = CreateBeatmap(rulesetInfo).BeatmapInfo;
|
||||
|
||||
var score = new ScoreInfo
|
||||
{
|
||||
Rank = ScoreRank.B,
|
||||
TotalScore = 987654,
|
||||
Accuracy = 0.8,
|
||||
MaxCombo = 500,
|
||||
Combo = 250,
|
||||
BeatmapInfo = beatmapInfo,
|
||||
User = new APIUser { Username = "Test user" },
|
||||
Date = DateTimeOffset.Now,
|
||||
OnlineScoreID = 12345,
|
||||
Ruleset = rulesetInfo,
|
||||
};
|
||||
var score = TestResources.CreateTestScoreInfo(beatmapInfo);
|
||||
|
||||
PlaylistItem playlistItem = new PlaylistItem
|
||||
{
|
||||
|
@ -0,0 +1,188 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Screens.OnlinePlay;
|
||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestScenePlaylistsRoomSettingsPlaylist : OsuManualInputManagerTestScene
|
||||
{
|
||||
private TestPlaylist playlist;
|
||||
|
||||
[Cached(typeof(UserLookupCache))]
|
||||
private readonly TestUserLookupCache userLookupCache = new TestUserLookupCache();
|
||||
|
||||
[Test]
|
||||
public void TestItemRemovedOnDeletion()
|
||||
{
|
||||
PlaylistItem selectedItem = null;
|
||||
|
||||
createPlaylist();
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("retrieve selection", () => selectedItem = playlist.SelectedItem.Value);
|
||||
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("item removed", () => !playlist.Items.Contains(selectedItem));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNextItemSelectedAfterDeletion()
|
||||
{
|
||||
createPlaylist();
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("item 0 is selected", () => playlist.SelectedItem.Value == playlist.Items[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLastItemSelectedAfterLastItemDeleted()
|
||||
{
|
||||
createPlaylist();
|
||||
|
||||
AddWaitStep("wait for flow", 5); // Items may take 1 update frame to flow. A wait count of 5 is guaranteed to result in the flow being updated as desired.
|
||||
AddStep("scroll to bottom", () => playlist.ChildrenOfType<ScrollContainer<Drawable>>().First().ScrollToEnd(false));
|
||||
|
||||
moveToItem(19);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
moveToDeleteButton(19);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("item 18 is selected", () => playlist.SelectedItem.Value == playlist.Items[18]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectionResetWhenAllItemsDeleted()
|
||||
{
|
||||
createPlaylist();
|
||||
|
||||
AddStep("remove all but one item", () =>
|
||||
{
|
||||
playlist.Items.RemoveRange(1, playlist.Items.Count - 1);
|
||||
});
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("no item selected", () => playlist.SelectedItem.Value == null);
|
||||
}
|
||||
|
||||
// Todo: currently not possible due to bindable list shortcomings (https://github.com/ppy/osu-framework/issues/3081)
|
||||
// [Test]
|
||||
public void TestNextItemSelectedAfterExternalDeletion()
|
||||
{
|
||||
createPlaylist();
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("remove item 0", () => playlist.Items.RemoveAt(0));
|
||||
|
||||
AddAssert("item 0 is selected", () => playlist.SelectedItem.Value == playlist.Items[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChangeBeatmapAndRemove()
|
||||
{
|
||||
createPlaylist();
|
||||
|
||||
AddStep("change beatmap of first item", () => playlist.Items[0].BeatmapID = 30);
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
}
|
||||
|
||||
private void moveToItem(int index, Vector2? offset = null)
|
||||
=> AddStep($"move mouse to item {index}", () => InputManager.MoveMouseTo(playlist.ChildrenOfType<DifficultyIcon>().ElementAt(index), offset));
|
||||
|
||||
private void moveToDeleteButton(int index, Vector2? offset = null) => AddStep($"move mouse to delete button {index}", () =>
|
||||
{
|
||||
var item = playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>>().ElementAt(index);
|
||||
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0), offset);
|
||||
});
|
||||
|
||||
private void createPlaylist()
|
||||
{
|
||||
AddStep("create playlist", () =>
|
||||
{
|
||||
Child = playlist = new TestPlaylist
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(500, 300)
|
||||
};
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
playlist.Items.Add(new PlaylistItem
|
||||
{
|
||||
ID = i,
|
||||
OwnerID = 2,
|
||||
Beatmap =
|
||||
{
|
||||
Value = i % 2 == 1
|
||||
? new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo
|
||||
: new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Artist = "Artist",
|
||||
Author = new APIUser { Username = "Creator name here" },
|
||||
Title = "Long title used to check background colour",
|
||||
},
|
||||
BeatmapSet = new BeatmapSetInfo()
|
||||
}
|
||||
},
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||
RequiredMods =
|
||||
{
|
||||
new OsuModHardRock(),
|
||||
new OsuModDoubleTime(),
|
||||
new OsuModAutoplay()
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
AddUntilStep("wait for items to load", () => playlist.ItemMap.Values.All(i => i.IsLoaded));
|
||||
}
|
||||
|
||||
private class TestPlaylist : PlaylistsRoomSettingsPlaylist
|
||||
{
|
||||
public new IReadOnlyDictionary<PlaylistItem, RearrangeableListItem<PlaylistItem>> ItemMap => base.ItemMap;
|
||||
|
||||
public TestPlaylist()
|
||||
{
|
||||
AllowSelection = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -128,7 +128,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
imported = Game.ScoreManager.Import(new ScoreInfo
|
||||
{
|
||||
Hash = Guid.NewGuid().ToString(),
|
||||
OnlineScoreID = i,
|
||||
OnlineID = i,
|
||||
BeatmapInfo = beatmap.Beatmaps.First(),
|
||||
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
||||
}).Result.Value;
|
||||
|
@ -393,6 +393,25 @@ namespace osu.Game.Tests.Visual.Online
|
||||
channelManager.CurrentChannel.Value.Type == ChannelType.PM && channelManager.CurrentChannel.Value.Users.Single().Username == "some body");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultiplayerChannelIsNotShown()
|
||||
{
|
||||
Channel multiplayerChannel = null;
|
||||
|
||||
AddStep("join multiplayer channel", () => channelManager.JoinChannel(multiplayerChannel = new Channel(new APIUser())
|
||||
{
|
||||
Name = "#mp_1",
|
||||
Type = ChannelType.Multiplayer,
|
||||
}));
|
||||
|
||||
AddAssert("channel joined", () => channelManager.JoinedChannels.Contains(multiplayerChannel));
|
||||
AddAssert("channel not present in overlay", () => !chatOverlay.TabMap.ContainsKey(multiplayerChannel));
|
||||
AddAssert("multiplayer channel is not current", () => channelManager.CurrentChannel.Value != multiplayerChannel);
|
||||
|
||||
AddStep("leave channel", () => channelManager.LeaveChannel(multiplayerChannel));
|
||||
AddAssert("channel left", () => !channelManager.JoinedChannels.Contains(multiplayerChannel));
|
||||
}
|
||||
|
||||
private void pressChannelHotkey(int number)
|
||||
{
|
||||
var channelKey = Key.Number0 + number;
|
||||
|
@ -47,9 +47,9 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
var allScores = new APIScoresCollection
|
||||
{
|
||||
Scores = new List<APIScoreInfo>
|
||||
Scores = new List<APIScore>
|
||||
{
|
||||
new APIScoreInfo
|
||||
new APIScore
|
||||
{
|
||||
User = new APIUser
|
||||
{
|
||||
@ -74,7 +74,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
TotalScore = 1234567890,
|
||||
Accuracy = 1,
|
||||
},
|
||||
new APIScoreInfo
|
||||
new APIScore
|
||||
{
|
||||
User = new APIUser
|
||||
{
|
||||
@ -98,7 +98,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
TotalScore = 1234789,
|
||||
Accuracy = 0.9997,
|
||||
},
|
||||
new APIScoreInfo
|
||||
new APIScore
|
||||
{
|
||||
User = new APIUser
|
||||
{
|
||||
@ -121,7 +121,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
TotalScore = 12345678,
|
||||
Accuracy = 0.9854,
|
||||
},
|
||||
new APIScoreInfo
|
||||
new APIScore
|
||||
{
|
||||
User = new APIUser
|
||||
{
|
||||
@ -143,7 +143,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
TotalScore = 1234567,
|
||||
Accuracy = 0.8765,
|
||||
},
|
||||
new APIScoreInfo
|
||||
new APIScore
|
||||
{
|
||||
User = new APIUser
|
||||
{
|
||||
@ -166,7 +166,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
var myBestScore = new APIScoreWithPosition
|
||||
{
|
||||
Score = new APIScoreInfo
|
||||
Score = new APIScore
|
||||
{
|
||||
User = new APIUser
|
||||
{
|
||||
@ -189,7 +189,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
var myBestScoreWithNullPosition = new APIScoreWithPosition
|
||||
{
|
||||
Score = new APIScoreInfo
|
||||
Score = new APIScore
|
||||
{
|
||||
User = new APIUser
|
||||
{
|
||||
@ -212,9 +212,9 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
var oneScore = new APIScoresCollection
|
||||
{
|
||||
Scores = new List<APIScoreInfo>
|
||||
Scores = new List<APIScore>
|
||||
{
|
||||
new APIScoreInfo
|
||||
new APIScore
|
||||
{
|
||||
User = new APIUser
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public TestSceneUserProfileScores()
|
||||
{
|
||||
var firstScore = new APIScoreInfo
|
||||
var firstScore = new APIScore
|
||||
{
|
||||
PP = 1047.21,
|
||||
Rank = ScoreRank.SH,
|
||||
@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Accuracy = 0.9813
|
||||
};
|
||||
|
||||
var secondScore = new APIScoreInfo
|
||||
var secondScore = new APIScore
|
||||
{
|
||||
PP = 134.32,
|
||||
Rank = ScoreRank.A,
|
||||
@ -64,7 +64,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Accuracy = 0.998546
|
||||
};
|
||||
|
||||
var thirdScore = new APIScoreInfo
|
||||
var thirdScore = new APIScore
|
||||
{
|
||||
PP = 96.83,
|
||||
Rank = ScoreRank.S,
|
||||
@ -81,7 +81,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Accuracy = 0.9726
|
||||
};
|
||||
|
||||
var noPPScore = new APIScoreInfo
|
||||
var noPPScore = new APIScore
|
||||
{
|
||||
Rank = ScoreRank.B,
|
||||
Beatmap = new APIBeatmap
|
||||
|
@ -22,14 +22,17 @@ using osu.Game.Scoring;
|
||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
public class TestScenePlaylistsResultsScreen : ScreenTestScene
|
||||
{
|
||||
private const int scores_per_result = 10;
|
||||
private const int real_user_position = 200;
|
||||
|
||||
private TestResultsScreen resultsScreen;
|
||||
|
||||
private int currentScoreId;
|
||||
private bool requestComplete;
|
||||
private int totalCount;
|
||||
@ -37,7 +40,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
currentScoreId = 0;
|
||||
currentScoreId = 1;
|
||||
requestComplete = false;
|
||||
totalCount = 0;
|
||||
bindHandler();
|
||||
@ -50,13 +53,17 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
|
||||
AddStep("bind user score info handler", () =>
|
||||
{
|
||||
userScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { OnlineScoreID = currentScoreId++ };
|
||||
userScore = TestResources.CreateTestScoreInfo();
|
||||
userScore.OnlineID = currentScoreId++;
|
||||
|
||||
bindHandler(userScore: userScore);
|
||||
});
|
||||
|
||||
createResults(() => userScore);
|
||||
|
||||
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineScoreID == userScore.OnlineScoreID).State == PanelState.Expanded);
|
||||
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineID == userScore.OnlineID).State == PanelState.Expanded);
|
||||
AddAssert($"score panel position is {real_user_position}",
|
||||
() => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineID == userScore.OnlineID).ScorePosition.Value == real_user_position);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -74,14 +81,16 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
|
||||
AddStep("bind user score info handler", () =>
|
||||
{
|
||||
userScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { OnlineScoreID = currentScoreId++ };
|
||||
userScore = TestResources.CreateTestScoreInfo();
|
||||
userScore.OnlineID = currentScoreId++;
|
||||
|
||||
bindHandler(true, userScore);
|
||||
});
|
||||
|
||||
createResults(() => userScore);
|
||||
|
||||
AddAssert("more than 1 panel displayed", () => this.ChildrenOfType<ScorePanel>().Count() > 1);
|
||||
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineScoreID == userScore.OnlineScoreID).State == PanelState.Expanded);
|
||||
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineID == userScore.OnlineID).State == PanelState.Expanded);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -123,7 +132,9 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
|
||||
AddStep("bind user score info handler", () =>
|
||||
{
|
||||
userScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { OnlineScoreID = currentScoreId++ };
|
||||
userScore = TestResources.CreateTestScoreInfo();
|
||||
userScore.OnlineID = currentScoreId++;
|
||||
|
||||
bindHandler(userScore: userScore);
|
||||
});
|
||||
|
||||
@ -230,12 +241,12 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
var multiplayerUserScore = new MultiplayerScore
|
||||
{
|
||||
ID = (int)(userScore.OnlineScoreID ?? currentScoreId++),
|
||||
ID = (int)(userScore.OnlineID > 0 ? userScore.OnlineID : currentScoreId++),
|
||||
Accuracy = userScore.Accuracy,
|
||||
EndedAt = userScore.Date,
|
||||
Passed = userScore.Passed,
|
||||
Rank = userScore.Rank,
|
||||
Position = 200,
|
||||
Position = real_user_position,
|
||||
MaxCombo = userScore.MaxCombo,
|
||||
TotalScore = userScore.TotalScore,
|
||||
User = userScore.User,
|
||||
|
@ -15,9 +15,11 @@ using osu.Game.Database;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osu.Game.Tests.Visual.OnlinePlay;
|
||||
using osuTK.Input;
|
||||
|
||||
@ -112,37 +114,80 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
[Test]
|
||||
public void TestBeatmapUpdatedOnReImport()
|
||||
{
|
||||
BeatmapSetInfo importedSet = null;
|
||||
string realHash = null;
|
||||
int realOnlineId = 0;
|
||||
int realOnlineSetId = 0;
|
||||
|
||||
AddStep("import altered beatmap", () =>
|
||||
AddStep("store real beatmap values", () =>
|
||||
{
|
||||
IBeatmap beatmap = CreateBeatmap(new OsuRuleset().RulesetInfo);
|
||||
|
||||
beatmap.BeatmapInfo.BaseDifficulty.CircleSize = 1;
|
||||
|
||||
// intentionally increment online IDs to clash with import below.
|
||||
beatmap.BeatmapInfo.OnlineID++;
|
||||
beatmap.BeatmapInfo.BeatmapSet.OnlineID++;
|
||||
|
||||
importedSet = manager.Import(beatmap.BeatmapInfo.BeatmapSet).Result.Value;
|
||||
realHash = importedBeatmap.Value.Beatmaps[0].MD5Hash;
|
||||
realOnlineId = importedBeatmap.Value.Beatmaps[0].OnlineID ?? -1;
|
||||
realOnlineSetId = importedBeatmap.Value.OnlineID ?? -1;
|
||||
});
|
||||
|
||||
AddStep("import modified beatmap", () =>
|
||||
{
|
||||
var modifiedBeatmap = new TestBeatmap(new OsuRuleset().RulesetInfo)
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
OnlineID = realOnlineId,
|
||||
BeatmapSet =
|
||||
{
|
||||
OnlineID = realOnlineSetId
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
modifiedBeatmap.HitObjects.Clear();
|
||||
modifiedBeatmap.HitObjects.Add(new HitCircle { StartTime = 5000 });
|
||||
|
||||
manager.Import(modifiedBeatmap.BeatmapInfo.BeatmapSet).Wait();
|
||||
});
|
||||
|
||||
// Create the room using the real beatmap values.
|
||||
setupAndCreateRoom(room =>
|
||||
{
|
||||
room.Name.Value = "my awesome room";
|
||||
room.Host.Value = API.LocalUser.Value;
|
||||
room.Playlist.Add(new PlaylistItem
|
||||
{
|
||||
Beatmap = { Value = importedSet.Beatmaps[0] },
|
||||
Beatmap =
|
||||
{
|
||||
Value = new BeatmapInfo
|
||||
{
|
||||
MD5Hash = realHash,
|
||||
OnlineID = realOnlineId,
|
||||
BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
OnlineID = realOnlineSetId,
|
||||
}
|
||||
}
|
||||
},
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo }
|
||||
});
|
||||
});
|
||||
|
||||
AddAssert("match has altered beatmap", () => match.Beatmap.Value.Beatmap.Difficulty.CircleSize == 1);
|
||||
AddAssert("match has default beatmap", () => match.Beatmap.IsDefault);
|
||||
|
||||
importBeatmap();
|
||||
AddStep("reimport original beatmap", () =>
|
||||
{
|
||||
var originalBeatmap = new TestBeatmap(new OsuRuleset().RulesetInfo)
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
OnlineID = realOnlineId,
|
||||
BeatmapSet =
|
||||
{
|
||||
OnlineID = realOnlineSetId
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
AddAssert("match has original beatmap", () => match.Beatmap.Value.Beatmap.Difficulty.CircleSize != 1);
|
||||
manager.Import(originalBeatmap.BeatmapInfo.BeatmapSet).Wait();
|
||||
});
|
||||
|
||||
AddUntilStep("match has correct beatmap", () => realHash == match.Beatmap.Value.BeatmapInfo.MD5Hash);
|
||||
}
|
||||
|
||||
private void setupAndCreateRoom(Action<Room> room)
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -13,6 +14,7 @@ using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Screens.Ranking.Contracted;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Ranking
|
||||
@ -22,13 +24,18 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestShowPanel()
|
||||
{
|
||||
AddStep("show example score", () => showPanel(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), new TestScoreInfo(new OsuRuleset().RulesetInfo)));
|
||||
AddStep("show example score", () => showPanel(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), TestResources.CreateTestScoreInfo()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestExcessMods()
|
||||
{
|
||||
AddStep("show excess mods score", () => showPanel(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), new TestScoreInfo(new OsuRuleset().RulesetInfo, true)));
|
||||
AddStep("show excess mods score", () =>
|
||||
{
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.Mods = score.BeatmapInfo.Ruleset.CreateInstance().CreateAllMods().ToArray();
|
||||
showPanel(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), score);
|
||||
});
|
||||
}
|
||||
|
||||
private void showPanel(WorkingBeatmap workingBeatmap, ScoreInfo score)
|
||||
|
@ -20,6 +20,7 @@ using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Screens.Ranking.Expanded;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Ranking
|
||||
@ -34,21 +35,21 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
{
|
||||
var author = new APIUser { Username = "mapper_name" };
|
||||
|
||||
AddStep("show example score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo)
|
||||
{
|
||||
BeatmapInfo = createTestBeatmap(author)
|
||||
}));
|
||||
AddStep("show example score", () => showPanel(TestResources.CreateTestScoreInfo(createTestBeatmap(author))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestExcessMods()
|
||||
{
|
||||
var author = new APIUser { Username = "mapper_name" };
|
||||
|
||||
AddStep("show excess mods score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo, true)
|
||||
AddStep("show excess mods score", () =>
|
||||
{
|
||||
BeatmapInfo = createTestBeatmap(author)
|
||||
}));
|
||||
var author = new APIUser { Username = "mapper_name" };
|
||||
|
||||
var score = TestResources.CreateTestScoreInfo(createTestBeatmap(author));
|
||||
score.Mods = score.BeatmapInfo.Ruleset.CreateInstance().CreateAllMods().ToArray();
|
||||
|
||||
showPanel(score);
|
||||
});
|
||||
|
||||
AddAssert("mapper name present", () => this.ChildrenOfType<OsuSpriteText>().Any(spriteText => spriteText.Current.Value == "mapper_name"));
|
||||
}
|
||||
@ -56,10 +57,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestMapWithUnknownMapper()
|
||||
{
|
||||
AddStep("show example score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo)
|
||||
{
|
||||
BeatmapInfo = createTestBeatmap(new APIUser())
|
||||
}));
|
||||
AddStep("show example score", () => showPanel(TestResources.CreateTestScoreInfo(createTestBeatmap(new APIUser()))));
|
||||
|
||||
AddAssert("mapped by text not present", () =>
|
||||
this.ChildrenOfType<OsuSpriteText>().All(spriteText => !containsAny(spriteText.Text.ToString(), "mapped", "by")));
|
||||
@ -77,12 +75,12 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
var mods = new Mod[] { ruleset.GetAutoplayMod() };
|
||||
var beatmap = createTestBeatmap(new APIUser());
|
||||
|
||||
showPanel(new TestScoreInfo(ruleset.RulesetInfo)
|
||||
{
|
||||
Mods = mods,
|
||||
BeatmapInfo = beatmap,
|
||||
Date = default,
|
||||
});
|
||||
var score = TestResources.CreateTestScoreInfo(beatmap);
|
||||
|
||||
score.Mods = mods;
|
||||
score.Date = default;
|
||||
|
||||
showPanel(score);
|
||||
});
|
||||
|
||||
AddAssert("play time not displayed", () => !this.ChildrenOfType<ExpandedPanelMiddleContent.PlayedOnText>().Any());
|
||||
|
@ -5,8 +5,8 @@ using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Ranking.Expanded;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Ranking
|
||||
@ -27,7 +27,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4Extensions.FromHex("#444"),
|
||||
},
|
||||
new ExpandedPanelTopContent(new TestScoreInfo(new OsuRuleset().RulesetInfo).User),
|
||||
new ExpandedPanelTopContent(TestResources.CreateTestScoreInfo().User),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -15,12 +15,12 @@ using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Screens.Ranking.Statistics;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
@ -72,11 +72,10 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
{
|
||||
TestResultsScreen screen = null;
|
||||
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo)
|
||||
{
|
||||
Accuracy = accuracy,
|
||||
Rank = rank
|
||||
};
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
|
||||
score.Accuracy = accuracy;
|
||||
score.Rank = rank;
|
||||
|
||||
AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen(score)));
|
||||
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
||||
@ -204,7 +203,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
{
|
||||
DelayedFetchResultsScreen screen = null;
|
||||
|
||||
AddStep("load results", () => Child = new TestResultsContainer(screen = new DelayedFetchResultsScreen(new TestScoreInfo(new OsuRuleset().RulesetInfo), 3000)));
|
||||
AddStep("load results", () => Child = new TestResultsContainer(screen = new DelayedFetchResultsScreen(TestResources.CreateTestScoreInfo(), 3000)));
|
||||
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
||||
AddStep("click expanded panel", () =>
|
||||
{
|
||||
@ -237,9 +236,9 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
AddAssert("download button is enabled", () => screen.ChildrenOfType<DownloadButton>().Last().Enabled.Value);
|
||||
}
|
||||
|
||||
private TestResultsScreen createResultsScreen(ScoreInfo score = null) => new TestResultsScreen(score ?? new TestScoreInfo(new OsuRuleset().RulesetInfo));
|
||||
private TestResultsScreen createResultsScreen(ScoreInfo score = null) => new TestResultsScreen(score ?? TestResources.CreateTestScoreInfo());
|
||||
|
||||
private UnrankedSoloResultsScreen createUnrankedSoloResultsScreen() => new UnrankedSoloResultsScreen(new TestScoreInfo(new OsuRuleset().RulesetInfo));
|
||||
private UnrankedSoloResultsScreen createUnrankedSoloResultsScreen() => new UnrankedSoloResultsScreen(TestResources.CreateTestScoreInfo());
|
||||
|
||||
private class TestResultsContainer : Container
|
||||
{
|
||||
@ -282,7 +281,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.TotalScore += 10 - i;
|
||||
score.Hash = $"test{i}";
|
||||
scores.Add(score);
|
||||
@ -316,7 +315,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.TotalScore += 10 - i;
|
||||
scores.Add(score);
|
||||
}
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Ranking
|
||||
{
|
||||
@ -17,7 +17,9 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestDRank()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.5, Rank = ScoreRank.D };
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.Accuracy = 0.5;
|
||||
score.Rank = ScoreRank.D;
|
||||
|
||||
addPanelStep(score);
|
||||
}
|
||||
@ -25,7 +27,9 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestCRank()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.75, Rank = ScoreRank.C };
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.Accuracy = 0.75;
|
||||
score.Rank = ScoreRank.C;
|
||||
|
||||
addPanelStep(score);
|
||||
}
|
||||
@ -33,7 +37,9 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestBRank()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.85, Rank = ScoreRank.B };
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.Accuracy = 0.85;
|
||||
score.Rank = ScoreRank.B;
|
||||
|
||||
addPanelStep(score);
|
||||
}
|
||||
@ -41,7 +47,9 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestARank()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.925, Rank = ScoreRank.A };
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.Accuracy = 0.925;
|
||||
score.Rank = ScoreRank.A;
|
||||
|
||||
addPanelStep(score);
|
||||
}
|
||||
@ -49,7 +57,9 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestSRank()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.975, Rank = ScoreRank.S };
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.Accuracy = 0.975;
|
||||
score.Rank = ScoreRank.S;
|
||||
|
||||
addPanelStep(score);
|
||||
}
|
||||
@ -57,7 +67,9 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestAlmostSSRank()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.9999, Rank = ScoreRank.S };
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.Accuracy = 0.9999;
|
||||
score.Rank = ScoreRank.S;
|
||||
|
||||
addPanelStep(score);
|
||||
}
|
||||
@ -65,7 +77,9 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestSSRank()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 1, Rank = ScoreRank.X };
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.Accuracy = 1;
|
||||
score.Rank = ScoreRank.X;
|
||||
|
||||
addPanelStep(score);
|
||||
}
|
||||
@ -73,7 +87,9 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestAllHitResults()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Statistics = { [HitResult.Perfect] = 350, [HitResult.Ok] = 200 } };
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.Statistics[HitResult.Perfect] = 350;
|
||||
score.Statistics[HitResult.Ok] = 200;
|
||||
|
||||
addPanelStep(score);
|
||||
}
|
||||
@ -81,7 +97,9 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestContractedPanel()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.925, Rank = ScoreRank.A };
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.Accuracy = 0.925;
|
||||
score.Rank = ScoreRank.A;
|
||||
|
||||
addPanelStep(score, PanelState.Contracted);
|
||||
}
|
||||
@ -89,7 +107,9 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestExpandAndContract()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.925, Rank = ScoreRank.A };
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.Accuracy = 0.925;
|
||||
score.Rank = ScoreRank.A;
|
||||
|
||||
addPanelStep(score, PanelState.Contracted);
|
||||
AddWaitStep("wait for transition", 10);
|
||||
|
@ -7,9 +7,9 @@ using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Ranking
|
||||
@ -29,14 +29,14 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
{
|
||||
createListStep(() => new ScorePanelList
|
||||
{
|
||||
SelectedScore = { Value = new TestScoreInfo(new OsuRuleset().RulesetInfo) }
|
||||
SelectedScore = { Value = TestResources.CreateTestScoreInfo() }
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAddPanelAfterSelectingScore()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
|
||||
createListStep(() => new ScorePanelList
|
||||
{
|
||||
@ -52,7 +52,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestAddPanelBeforeSelectingScore()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
|
||||
createListStep(() => new ScorePanelList());
|
||||
|
||||
@ -75,7 +75,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
AddStep("add many scores", () =>
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
list.AddScore(new TestScoreInfo(new OsuRuleset().RulesetInfo));
|
||||
list.AddScore(TestResources.CreateTestScoreInfo());
|
||||
});
|
||||
|
||||
assertFirstPanelCentred();
|
||||
@ -84,7 +84,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestAddManyScoresAfterExpandedPanel()
|
||||
{
|
||||
var initialScore = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
||||
var initialScore = TestResources.CreateTestScoreInfo();
|
||||
|
||||
createListStep(() => new ScorePanelList());
|
||||
|
||||
@ -97,7 +97,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
AddStep("add many scores", () =>
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
list.AddScore(new TestScoreInfo(new OsuRuleset().RulesetInfo) { TotalScore = initialScore.TotalScore - i - 1 });
|
||||
list.AddScore(createScoreForTotalScore(initialScore.TotalScore - i - 1));
|
||||
});
|
||||
|
||||
assertScoreState(initialScore, true);
|
||||
@ -107,7 +107,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestAddManyScoresBeforeExpandedPanel()
|
||||
{
|
||||
var initialScore = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
||||
var initialScore = TestResources.CreateTestScoreInfo();
|
||||
|
||||
createListStep(() => new ScorePanelList());
|
||||
|
||||
@ -120,7 +120,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
AddStep("add scores", () =>
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
list.AddScore(new TestScoreInfo(new OsuRuleset().RulesetInfo) { TotalScore = initialScore.TotalScore + i + 1 });
|
||||
list.AddScore(createScoreForTotalScore(initialScore.TotalScore + i + 1));
|
||||
});
|
||||
|
||||
assertScoreState(initialScore, true);
|
||||
@ -130,7 +130,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestAddManyPanelsOnBothSidesOfExpandedPanel()
|
||||
{
|
||||
var initialScore = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
||||
var initialScore = TestResources.CreateTestScoreInfo();
|
||||
|
||||
createListStep(() => new ScorePanelList());
|
||||
|
||||
@ -143,10 +143,10 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
AddStep("add scores after", () =>
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
list.AddScore(new TestScoreInfo(new OsuRuleset().RulesetInfo) { TotalScore = initialScore.TotalScore - i - 1 });
|
||||
list.AddScore(createScoreForTotalScore(initialScore.TotalScore - i - 1));
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
list.AddScore(new TestScoreInfo(new OsuRuleset().RulesetInfo) { TotalScore = initialScore.TotalScore + i + 1 });
|
||||
list.AddScore(createScoreForTotalScore(initialScore.TotalScore + i + 1));
|
||||
});
|
||||
|
||||
assertScoreState(initialScore, true);
|
||||
@ -156,11 +156,11 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestSelectMultipleScores()
|
||||
{
|
||||
var firstScore = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
||||
var secondScore = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
||||
var firstScore = TestResources.CreateTestScoreInfo();
|
||||
var secondScore = TestResources.CreateTestScoreInfo();
|
||||
|
||||
firstScore.User.Username = "A";
|
||||
secondScore.User.Username = "B";
|
||||
firstScore.UserString = "A";
|
||||
secondScore.UserString = "B";
|
||||
|
||||
createListStep(() => new ScorePanelList());
|
||||
|
||||
@ -190,7 +190,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestAddScoreImmediately()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
|
||||
createListStep(() =>
|
||||
{
|
||||
@ -206,9 +206,14 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestKeyboardNavigation()
|
||||
{
|
||||
var lowestScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { MaxCombo = 100 };
|
||||
var middleScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { MaxCombo = 200 };
|
||||
var highestScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { MaxCombo = 300 };
|
||||
var lowestScore = TestResources.CreateTestScoreInfo();
|
||||
lowestScore.MaxCombo = 100;
|
||||
|
||||
var middleScore = TestResources.CreateTestScoreInfo();
|
||||
middleScore.MaxCombo = 200;
|
||||
|
||||
var highestScore = TestResources.CreateTestScoreInfo();
|
||||
highestScore.MaxCombo = 300;
|
||||
|
||||
createListStep(() => new ScorePanelList());
|
||||
|
||||
@ -270,6 +275,13 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
assertExpandedPanelCentred();
|
||||
}
|
||||
|
||||
private ScoreInfo createScoreForTotalScore(long totalScore)
|
||||
{
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.TotalScore = totalScore;
|
||||
return score;
|
||||
}
|
||||
|
||||
private void createListStep(Func<ScorePanelList> creationFunc)
|
||||
{
|
||||
AddStep("create list", () => Child = list = creationFunc().With(d =>
|
||||
|
@ -6,11 +6,11 @@ using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Ranking.Statistics;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Ranking
|
||||
@ -20,10 +20,8 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestScoreWithTimeStatistics()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo)
|
||||
{
|
||||
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents()
|
||||
};
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents();
|
||||
|
||||
loadPanel(score);
|
||||
}
|
||||
@ -31,10 +29,8 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestScoreWithPositionStatistics()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo)
|
||||
{
|
||||
HitEvents = createPositionDistributedHitEvents()
|
||||
};
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.HitEvents = createPositionDistributedHitEvents();
|
||||
|
||||
loadPanel(score);
|
||||
}
|
||||
@ -42,7 +38,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestScoreWithoutStatistics()
|
||||
{
|
||||
loadPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo));
|
||||
loadPanel(TestResources.CreateTestScoreInfo());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -835,12 +835,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
// this beatmap change should be overridden by the present.
|
||||
Beatmap.Value = manager.GetWorkingBeatmap(getSwitchBeatmap());
|
||||
|
||||
songSelect.PresentScore(new ScoreInfo
|
||||
{
|
||||
User = new APIUser { Username = "woo" },
|
||||
BeatmapInfo = getPresentBeatmap(),
|
||||
Ruleset = getPresentBeatmap().Ruleset
|
||||
});
|
||||
songSelect.PresentScore(TestResources.CreateTestScoreInfo(getPresentBeatmap()));
|
||||
});
|
||||
|
||||
AddUntilStep("wait for results screen presented", () => !songSelect.IsCurrentScreen());
|
||||
|
@ -61,7 +61,7 @@ namespace osu.Game.Tests.Visual
|
||||
((DummyAPIAccess)api).HandleRequest = request => multiplayerScreen.RequestsHandler.HandleRequest(request, api.LocalUser.Value, game);
|
||||
}
|
||||
|
||||
public override bool OnBackButton() => multiplayerScreen.OnBackButton();
|
||||
public override bool OnBackButton() => (screenStack.CurrentScreen as OsuScreen)?.OnBackButton() ?? base.OnBackButton();
|
||||
|
||||
public override bool OnExiting(IScreen next)
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
var score = new ScoreInfo
|
||||
{
|
||||
OnlineScoreID = i,
|
||||
OnlineID = i,
|
||||
BeatmapInfo = beatmapInfo,
|
||||
BeatmapInfoID = beatmapInfo.ID,
|
||||
Accuracy = RNG.NextDouble(),
|
||||
@ -163,7 +163,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
});
|
||||
|
||||
AddUntilStep("wait for fetch", () => leaderboard.Scores != null);
|
||||
AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineScoreID != scoreBeingDeleted.OnlineScoreID));
|
||||
AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineID != scoreBeingDeleted.OnlineID));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -171,7 +171,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
AddStep("delete top score", () => scoreManager.Delete(importedScores[0]));
|
||||
AddUntilStep("wait for fetch", () => leaderboard.Scores != null);
|
||||
AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineScoreID != importedScores[0].OnlineScoreID));
|
||||
AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineID != importedScores[0].OnlineID));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
public const float TRANSITION_DURATION = 400;
|
||||
public const float CORNER_RADIUS = 10;
|
||||
|
||||
public Bindable<bool> Expanded { get; } = new BindableBool();
|
||||
public IBindable<bool> Expanded { get; }
|
||||
|
||||
private const float width = 408;
|
||||
private const float height = 100;
|
||||
@ -64,9 +64,11 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
public BeatmapCard(APIBeatmapSet beatmapSet)
|
||||
public BeatmapCard(APIBeatmapSet beatmapSet, bool allowExpansion = true)
|
||||
: base(HoverSampleSet.Submit)
|
||||
{
|
||||
Expanded = new BindableBool { Disabled = !allowExpansion };
|
||||
|
||||
this.beatmapSet = beatmapSet;
|
||||
favouriteState = new Bindable<BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount));
|
||||
downloadTracker = new BeatmapDownloadTracker(beatmapSet);
|
||||
@ -282,15 +284,15 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
{
|
||||
Hovered = _ =>
|
||||
{
|
||||
content.ScheduleShow();
|
||||
content.ExpandAfterDelay();
|
||||
return false;
|
||||
},
|
||||
Unhovered = _ =>
|
||||
{
|
||||
// This hide should only trigger if the expanded content has not shown yet.
|
||||
// ie. if the user has not shown intent to want to see it (quickly moved over the info row area).
|
||||
// Handles the case where a user has not shown explicit intent to view expanded info.
|
||||
// ie. quickly moved over the info row area but didn't remain within it.
|
||||
if (!Expanded.Value)
|
||||
content.ScheduleHide();
|
||||
content.CancelExpand();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -366,8 +368,6 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
content.ScheduleHide();
|
||||
|
||||
updateState();
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
@ -31,7 +31,9 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
set => dropdownScroll.Child = value;
|
||||
}
|
||||
|
||||
public Bindable<bool> Expanded { get; } = new BindableBool();
|
||||
public IBindable<bool> Expanded => expanded;
|
||||
|
||||
private readonly BindableBool expanded = new BindableBool();
|
||||
|
||||
private readonly Box background;
|
||||
private readonly Container content;
|
||||
@ -54,7 +56,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
AutoSizeAxes = Axes.Y,
|
||||
CornerRadius = BeatmapCard.CORNER_RADIUS,
|
||||
Masking = true,
|
||||
Unhovered = _ => checkForHide(),
|
||||
Unhovered = _ => updateFromHoverChange(),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
@ -76,10 +78,10 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
Alpha = 0,
|
||||
Hovered = _ =>
|
||||
{
|
||||
keep();
|
||||
updateFromHoverChange();
|
||||
return true;
|
||||
},
|
||||
Unhovered = _ => checkForHide(),
|
||||
Unhovered = _ => updateFromHoverChange(),
|
||||
Child = dropdownScroll = new ExpandedContentScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -119,51 +121,20 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
|
||||
private ScheduledDelegate? scheduledExpandedChange;
|
||||
|
||||
public void ScheduleShow()
|
||||
{
|
||||
scheduledExpandedChange?.Cancel();
|
||||
if (Expanded.Disabled || Expanded.Value)
|
||||
return;
|
||||
public void ExpandAfterDelay() => queueExpandedStateChange(true, 100);
|
||||
|
||||
scheduledExpandedChange = Scheduler.AddDelayed(() =>
|
||||
{
|
||||
if (!Expanded.Disabled)
|
||||
Expanded.Value = true;
|
||||
}, 100);
|
||||
}
|
||||
public void CancelExpand() => scheduledExpandedChange?.Cancel();
|
||||
|
||||
public void ScheduleHide()
|
||||
{
|
||||
scheduledExpandedChange?.Cancel();
|
||||
if (Expanded.Disabled || !Expanded.Value)
|
||||
return;
|
||||
private void updateFromHoverChange() =>
|
||||
queueExpandedStateChange(content.IsHovered || dropdownContent.IsHovered, 100);
|
||||
|
||||
scheduledExpandedChange = Scheduler.AddDelayed(() =>
|
||||
{
|
||||
if (!Expanded.Disabled)
|
||||
Expanded.Value = false;
|
||||
}, 500);
|
||||
}
|
||||
|
||||
private void checkForHide()
|
||||
{
|
||||
if (Expanded.Disabled)
|
||||
return;
|
||||
|
||||
if (content.IsHovered || dropdownContent.IsHovered)
|
||||
return;
|
||||
|
||||
scheduledExpandedChange?.Cancel();
|
||||
Expanded.Value = false;
|
||||
}
|
||||
|
||||
private void keep()
|
||||
private void queueExpandedStateChange(bool newState, int delay = 0)
|
||||
{
|
||||
if (Expanded.Disabled)
|
||||
return;
|
||||
|
||||
scheduledExpandedChange?.Cancel();
|
||||
Expanded.Value = true;
|
||||
scheduledExpandedChange = Scheduler.AddDelayed(() => expanded.Value = newState, delay);
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
|
@ -298,7 +298,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
{
|
||||
Hovered = _ =>
|
||||
{
|
||||
content.ScheduleShow();
|
||||
content.ExpandAfterDelay();
|
||||
return false;
|
||||
},
|
||||
Unhovered = _ =>
|
||||
@ -306,7 +306,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
// This hide should only trigger if the expanded content has not shown yet.
|
||||
// ie. if the user has not shown intent to want to see it (quickly moved over the info row area).
|
||||
if (!Expanded.Value)
|
||||
content.ScheduleHide();
|
||||
content.CancelExpand();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -384,8 +384,6 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
content.ScheduleHide();
|
||||
|
||||
updateState();
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ using osu.Framework.Platform;
|
||||
using osu.Framework.Statistics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Storyboards;
|
||||
@ -108,6 +109,7 @@ namespace osu.Game.Beatmaps
|
||||
TextureStore IBeatmapResourceProvider.LargeTextureStore => largeTextureStore;
|
||||
ITrackStore IBeatmapResourceProvider.Tracks => trackStore;
|
||||
AudioManager IStorageResourceProvider.AudioManager => audioManager;
|
||||
RealmContextFactory IStorageResourceProvider.RealmContextFactory => null;
|
||||
IResourceStore<byte[]> IStorageResourceProvider.Files => files;
|
||||
IResourceStore<byte[]> IStorageResourceProvider.Resources => resources;
|
||||
IResourceStore<TextureUpload> IStorageResourceProvider.CreateTextureLoaderStore(IResourceStore<byte[]> underlyingStore) => host?.CreateTextureLoaderStore(underlyingStore);
|
||||
|
@ -147,7 +147,7 @@ namespace osu.Game.Database
|
||||
|
||||
modelBuilder.Entity<BeatmapInfo>().HasOne(b => b.BaseDifficulty);
|
||||
|
||||
modelBuilder.Entity<ScoreInfo>().HasIndex(b => b.OnlineScoreID).IsUnique();
|
||||
modelBuilder.Entity<ScoreInfo>().HasIndex(b => b.OnlineID).IsUnique();
|
||||
}
|
||||
|
||||
private class OsuDbLoggerFactory : ILoggerFactory
|
||||
|
@ -24,13 +24,17 @@ namespace osu.Game.Database
|
||||
/// </summary>
|
||||
private readonly T data;
|
||||
|
||||
private readonly RealmContextFactory realmFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a new instance of live realm data.
|
||||
/// </summary>
|
||||
/// <param name="data">The realm data.</param>
|
||||
public RealmLive(T data)
|
||||
/// <param name="realmFactory">The realm factory the data was sourced from. May be null for an unmanaged object.</param>
|
||||
public RealmLive(T data, RealmContextFactory realmFactory)
|
||||
{
|
||||
this.data = data;
|
||||
this.realmFactory = realmFactory;
|
||||
|
||||
ID = data.ID;
|
||||
}
|
||||
@ -47,7 +51,7 @@ namespace osu.Game.Database
|
||||
return;
|
||||
}
|
||||
|
||||
using (var realm = Realm.GetInstance(data.Realm.Config))
|
||||
using (var realm = realmFactory.CreateContext())
|
||||
perform(realm.Find<T>(ID));
|
||||
}
|
||||
|
||||
@ -58,12 +62,12 @@ namespace osu.Game.Database
|
||||
public TReturn PerformRead<TReturn>(Func<T, TReturn> perform)
|
||||
{
|
||||
if (typeof(RealmObjectBase).IsAssignableFrom(typeof(TReturn)))
|
||||
throw new InvalidOperationException($"Realm live objects should not exit the scope of {nameof(PerformRead)}.");
|
||||
throw new InvalidOperationException(@$"Realm live objects should not exit the scope of {nameof(PerformRead)}.");
|
||||
|
||||
if (!IsManaged)
|
||||
return perform(data);
|
||||
|
||||
using (var realm = Realm.GetInstance(data.Realm.Config))
|
||||
using (var realm = realmFactory.CreateContext())
|
||||
return perform(realm.Find<T>(ID));
|
||||
}
|
||||
|
||||
@ -74,7 +78,7 @@ namespace osu.Game.Database
|
||||
public void PerformWrite(Action<T> perform)
|
||||
{
|
||||
if (!IsManaged)
|
||||
throw new InvalidOperationException("Can't perform writes on a non-managed underlying value");
|
||||
throw new InvalidOperationException(@"Can't perform writes on a non-managed underlying value");
|
||||
|
||||
PerformRead(t =>
|
||||
{
|
||||
@ -94,11 +98,7 @@ namespace osu.Game.Database
|
||||
if (!ThreadSafety.IsUpdateThread)
|
||||
throw new InvalidOperationException($"Can't use {nameof(Value)} on managed objects from non-update threads");
|
||||
|
||||
// When using Value, we rely on garbage collection for the realm instance used to retrieve the instance.
|
||||
// As we are sure that this is on the update thread, there should always be an open and constantly refreshing realm instance to ensure file size growth is a non-issue.
|
||||
var realm = Realm.GetInstance(data.Realm.Config);
|
||||
|
||||
return realm.Find<T>(ID);
|
||||
return realmFactory.Context.Find<T>(ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
44
osu.Game/Database/RealmLiveUnmanaged.cs
Normal file
44
osu.Game/Database/RealmLiveUnmanaged.cs
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using Realms;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a method of working with unmanaged realm objects.
|
||||
/// Usually used for testing purposes where the instance is never required to be managed.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The underlying object type.</typeparam>
|
||||
public class RealmLiveUnmanaged<T> : ILive<T> where T : RealmObjectBase, IHasGuidPrimaryKey
|
||||
{
|
||||
/// <summary>
|
||||
/// Construct a new instance of live realm data.
|
||||
/// </summary>
|
||||
/// <param name="data">The realm data.</param>
|
||||
public RealmLiveUnmanaged(T data)
|
||||
{
|
||||
Value = data;
|
||||
}
|
||||
|
||||
public bool Equals(ILive<T>? other) => ID == other?.ID;
|
||||
|
||||
public Guid ID => Value.ID;
|
||||
|
||||
public void PerformRead(Action<T> perform) => perform(Value);
|
||||
|
||||
public TReturn PerformRead<TReturn>(Func<T, TReturn> perform) => perform(Value);
|
||||
|
||||
public void PerformWrite(Action<T> perform) => throw new InvalidOperationException(@"Can't perform writes on a non-managed underlying value");
|
||||
|
||||
public bool IsManaged => false;
|
||||
|
||||
/// <summary>
|
||||
/// The original live data used to create this instance.
|
||||
/// </summary>
|
||||
public T Value { get; }
|
||||
}
|
||||
}
|
@ -53,16 +53,28 @@ namespace osu.Game.Database
|
||||
return mapper.Map<T>(item);
|
||||
}
|
||||
|
||||
public static List<ILive<T>> ToLive<T>(this IEnumerable<T> realmList)
|
||||
public static List<ILive<T>> ToLiveUnmanaged<T>(this IEnumerable<T> realmList)
|
||||
where T : RealmObject, IHasGuidPrimaryKey
|
||||
{
|
||||
return realmList.Select(l => new RealmLive<T>(l)).Cast<ILive<T>>().ToList();
|
||||
return realmList.Select(l => new RealmLiveUnmanaged<T>(l)).Cast<ILive<T>>().ToList();
|
||||
}
|
||||
|
||||
public static ILive<T> ToLive<T>(this T realmObject)
|
||||
public static ILive<T> ToLiveUnmanaged<T>(this T realmObject)
|
||||
where T : RealmObject, IHasGuidPrimaryKey
|
||||
{
|
||||
return new RealmLive<T>(realmObject);
|
||||
return new RealmLiveUnmanaged<T>(realmObject);
|
||||
}
|
||||
|
||||
public static List<ILive<T>> ToLive<T>(this IEnumerable<T> realmList, RealmContextFactory realmContextFactory)
|
||||
where T : RealmObject, IHasGuidPrimaryKey
|
||||
{
|
||||
return realmList.Select(l => new RealmLive<T>(l, realmContextFactory)).Cast<ILive<T>>().ToList();
|
||||
}
|
||||
|
||||
public static ILive<T> ToLive<T>(this T realmObject, RealmContextFactory realmContextFactory)
|
||||
where T : RealmObject, IHasGuidPrimaryKey
|
||||
{
|
||||
return new RealmLive<T>(realmObject, realmContextFactory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -104,6 +104,14 @@ namespace osu.Game.Extensions
|
||||
/// <returns>Whether online IDs match. If either instance is missing an online ID, this will return false.</returns>
|
||||
public static bool MatchesOnlineID(this APIUser? instance, APIUser? other) => matchesOnlineID(instance, other);
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the online ID of two <see cref="IScoreInfo"/>s match.
|
||||
/// </summary>
|
||||
/// <param name="instance">The instance to compare.</param>
|
||||
/// <param name="other">The other instance to compare against.</param>
|
||||
/// <returns>Whether online IDs match. If either instance is missing an online ID, this will return false.</returns>
|
||||
public static bool MatchesOnlineID(this IScoreInfo? instance, IScoreInfo? other) => matchesOnlineID(instance, other);
|
||||
|
||||
private static bool matchesOnlineID(this IHasOnlineID<long>? instance, IHasOnlineID<long>? other)
|
||||
{
|
||||
if (instance == null || other == null)
|
||||
|
@ -72,18 +72,21 @@ namespace osu.Game.Graphics.Cursor
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
// only trigger animation for main mouse buttons
|
||||
activeCursor.Scale = new Vector2(1);
|
||||
activeCursor.ScaleTo(0.90f, 800, Easing.OutQuint);
|
||||
|
||||
activeCursor.AdditiveLayer.Alpha = 0;
|
||||
activeCursor.AdditiveLayer.FadeInFromZero(800, Easing.OutQuint);
|
||||
|
||||
if (cursorRotate.Value && dragRotationState != DragRotationState.Rotating)
|
||||
if (State.Value == Visibility.Visible)
|
||||
{
|
||||
// if cursor is already rotating don't reset its rotate origin
|
||||
dragRotationState = DragRotationState.DragStarted;
|
||||
positionMouseDown = e.MousePosition;
|
||||
// only trigger animation for main mouse buttons
|
||||
activeCursor.Scale = new Vector2(1);
|
||||
activeCursor.ScaleTo(0.90f, 800, Easing.OutQuint);
|
||||
|
||||
activeCursor.AdditiveLayer.Alpha = 0;
|
||||
activeCursor.AdditiveLayer.FadeInFromZero(800, Easing.OutQuint);
|
||||
|
||||
if (cursorRotate.Value && dragRotationState != DragRotationState.Rotating)
|
||||
{
|
||||
// if cursor is already rotating don't reset its rotate origin
|
||||
dragRotationState = DragRotationState.DragStarted;
|
||||
positionMouseDown = e.MousePosition;
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnMouseDown(e);
|
||||
|
@ -65,8 +65,10 @@ namespace osu.Game.Graphics
|
||||
|
||||
public void SetContent(DateTimeOffset date)
|
||||
{
|
||||
dateText.Text = $"{date:d MMMM yyyy} ";
|
||||
timeText.Text = $"{date:HH:mm:ss \"UTC\"z}";
|
||||
DateTimeOffset localDate = date.ToLocalTime();
|
||||
|
||||
dateText.Text = $"{localDate:d MMMM yyyy} ";
|
||||
timeText.Text = $"{localDate:HH:mm:ss \"UTC\"z}";
|
||||
}
|
||||
|
||||
public void Move(Vector2 pos) => Position = pos;
|
||||
|
@ -1,10 +1,12 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Extensions;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuNumberBox : OsuTextBox
|
||||
{
|
||||
protected override bool CanAddCharacter(char character) => char.IsNumber(character);
|
||||
protected override bool CanAddCharacter(char character) => character.IsAsciiDigit();
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.IO
|
||||
{
|
||||
@ -24,6 +25,11 @@ namespace osu.Game.IO
|
||||
/// </summary>
|
||||
IResourceStore<byte[]> Resources { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Access realm.
|
||||
/// </summary>
|
||||
RealmContextFactory RealmContextFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a texture loader store based on an underlying data store.
|
||||
/// </summary>
|
||||
|
@ -81,20 +81,37 @@ namespace osu.Game.Input
|
||||
// compare counts in database vs defaults for each action type.
|
||||
foreach (var defaultsForAction in defaults.GroupBy(k => k.Action))
|
||||
{
|
||||
// avoid performing redundant queries when the database is empty and needs to be re-filled.
|
||||
int existingCount = existingBindings.Count(k => k.RulesetName == rulesetName && k.Variant == variant && k.ActionInt == (int)defaultsForAction.Key);
|
||||
IEnumerable<RealmKeyBinding> existing = existingBindings.Where(k =>
|
||||
k.RulesetName == rulesetName
|
||||
&& k.Variant == variant
|
||||
&& k.ActionInt == (int)defaultsForAction.Key);
|
||||
|
||||
if (defaultsForAction.Count() <= existingCount)
|
||||
continue;
|
||||
int defaultsCount = defaultsForAction.Count();
|
||||
int existingCount = existing.Count();
|
||||
|
||||
// insert any defaults which are missing.
|
||||
realm.Add(defaultsForAction.Skip(existingCount).Select(k => new RealmKeyBinding
|
||||
if (defaultsCount > existingCount)
|
||||
{
|
||||
KeyCombinationString = k.KeyCombination.ToString(),
|
||||
ActionInt = (int)k.Action,
|
||||
RulesetName = rulesetName,
|
||||
Variant = variant
|
||||
}));
|
||||
// insert any defaults which are missing.
|
||||
realm.Add(defaultsForAction.Skip(existingCount).Select(k => new RealmKeyBinding
|
||||
{
|
||||
KeyCombinationString = k.KeyCombination.ToString(),
|
||||
ActionInt = (int)k.Action,
|
||||
RulesetName = rulesetName,
|
||||
Variant = variant
|
||||
}));
|
||||
}
|
||||
else if (defaultsCount < existingCount)
|
||||
{
|
||||
// generally this shouldn't happen, but if the user has more key bindings for an action than we expect,
|
||||
// remove the last entries until the count matches for sanity.
|
||||
foreach (var k in existing.TakeLast(existingCount - defaultsCount).ToArray())
|
||||
{
|
||||
realm.Remove(k);
|
||||
|
||||
// Remove from the local flattened/cached list so future lookups don't query now deleted rows.
|
||||
existingBindings.Remove(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetUserScoresRequest : PaginatedAPIRequest<List<APIScoreInfo>>
|
||||
public class GetUserScoresRequest : PaginatedAPIRequest<List<APIScore>>
|
||||
{
|
||||
private readonly long userId;
|
||||
private readonly ScoreType type;
|
||||
|
@ -13,10 +13,11 @@ using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Scoring.Legacy;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
public class APIScoreInfo : IScoreInfo
|
||||
public class APIScore : IScoreInfo
|
||||
{
|
||||
[JsonProperty(@"score")]
|
||||
public long TotalScore { get; set; }
|
||||
@ -101,7 +102,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
BeatmapInfo = beatmap,
|
||||
User = User,
|
||||
Accuracy = Accuracy,
|
||||
OnlineScoreID = OnlineID,
|
||||
OnlineID = OnlineID,
|
||||
Date = Date,
|
||||
PP = PP,
|
||||
RulesetID = RulesetID,
|
||||
@ -150,6 +151,11 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
public IRulesetInfo Ruleset => new RulesetInfo { OnlineID = RulesetID };
|
||||
IEnumerable<INamedFileUsage> IHasNamedFiles.Files => throw new NotImplementedException();
|
||||
|
||||
#region Implementation of IScoreInfo
|
||||
|
||||
IBeatmapInfo IScoreInfo.Beatmap => Beatmap;
|
||||
IUser IScoreInfo.User => User;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
public int? Position;
|
||||
|
||||
[JsonProperty(@"score")]
|
||||
public APIScoreInfo Score;
|
||||
public APIScore Score;
|
||||
|
||||
public ScoreInfo CreateScoreInfo(RulesetStore rulesets, BeatmapInfo beatmap = null)
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
public class APIScoresCollection
|
||||
{
|
||||
[JsonProperty(@"scores")]
|
||||
public List<APIScoreInfo> Scores;
|
||||
public List<APIScore> Scores;
|
||||
|
||||
[JsonProperty(@"userScore")]
|
||||
public APIScoreWithPosition UserScore;
|
||||
|
@ -1,10 +1,10 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -120,16 +120,21 @@ namespace osu.Game.Online.Chat
|
||||
|
||||
private void checkForMentions(Channel channel, Message message)
|
||||
{
|
||||
if (!notifyOnUsername.Value || !checkContainsUsername(message.Content, localUser.Value.Username)) return;
|
||||
if (!notifyOnUsername.Value || !CheckContainsUsername(message.Content, localUser.Value.Username)) return;
|
||||
|
||||
notifications.Post(new MentionNotification(message.Sender.Username, channel));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if <paramref name="message"/> contains <paramref name="username"/>.
|
||||
/// Checks if <paramref name="message"/> mentions <paramref name="username"/>.
|
||||
/// This will match against the case where underscores are used instead of spaces (which is how osu-stable handles usernames with spaces).
|
||||
/// </summary>
|
||||
private static bool checkContainsUsername(string message, string username) => message.Contains(username, StringComparison.OrdinalIgnoreCase) || message.Contains(username.Replace(' ', '_'), StringComparison.OrdinalIgnoreCase);
|
||||
public static bool CheckContainsUsername(string message, string username)
|
||||
{
|
||||
string fullName = Regex.Escape(username);
|
||||
string underscoreName = Regex.Escape(username.Replace(' ', '_'));
|
||||
return Regex.IsMatch(message, $@"(^|\W)({fullName}|{underscoreName})($|\W)", RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
public class PrivateMessageNotification : OpenChannelNotification
|
||||
{
|
||||
|
@ -111,7 +111,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = user.Id == api.LocalUser.Value.Id && allowHighlight ? colour.Green : Color4.Black,
|
||||
Colour = user.OnlineID == api.LocalUser.Value.Id && allowHighlight ? colour.Green : Color4.Black,
|
||||
Alpha = background_alpha,
|
||||
},
|
||||
},
|
||||
|
@ -77,10 +77,27 @@ namespace osu.Game.Online.Multiplayer
|
||||
/// <exception cref="InvalidStateException">If an attempt to start the game occurs when the game's (or users') state disallows it.</exception>
|
||||
Task StartMatch();
|
||||
|
||||
/// <summary>
|
||||
/// Aborts an ongoing gameplay load.
|
||||
/// </summary>
|
||||
Task AbortGameplay();
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the playlist.
|
||||
/// </summary>
|
||||
/// <param name="item">The item to add.</param>
|
||||
Task AddPlaylistItem(MultiplayerPlaylistItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Edits an existing playlist item with new values.
|
||||
/// </summary>
|
||||
/// <param name="item">The item to edit, containing new properties. Must have an ID.</param>
|
||||
Task EditPlaylistItem(MultiplayerPlaylistItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the playlist.
|
||||
/// </summary>
|
||||
/// <param name="playlistItemId">The item to remove.</param>
|
||||
Task RemovePlaylistItem(long playlistItemId);
|
||||
}
|
||||
}
|
||||
|
@ -95,8 +95,6 @@ namespace osu.Game.Online.Multiplayer
|
||||
|
||||
protected readonly BindableList<int> PlayingUserIds = new BindableList<int>();
|
||||
|
||||
public readonly Bindable<PlaylistItem?> CurrentMatchPlayingItem = new Bindable<PlaylistItem?>();
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="MultiplayerRoomUser"/> corresponding to the local player, if available.
|
||||
/// </summary>
|
||||
@ -162,9 +160,6 @@ namespace osu.Game.Online.Multiplayer
|
||||
var joinedRoom = await JoinRoom(room.RoomID.Value.Value, password ?? room.Password.Value).ConfigureAwait(false);
|
||||
Debug.Assert(joinedRoom != null);
|
||||
|
||||
// Populate playlist items.
|
||||
var playlistItems = await Task.WhenAll(joinedRoom.Playlist.Select(item => createPlaylistItem(item, item.ID == joinedRoom.Settings.PlaylistItemId))).ConfigureAwait(false);
|
||||
|
||||
// Populate users.
|
||||
Debug.Assert(joinedRoom.Users != null);
|
||||
await Task.WhenAll(joinedRoom.Users.Select(PopulateUser)).ConfigureAwait(false);
|
||||
@ -176,7 +171,7 @@ namespace osu.Game.Online.Multiplayer
|
||||
APIRoom = room;
|
||||
|
||||
APIRoom.Playlist.Clear();
|
||||
APIRoom.Playlist.AddRange(playlistItems);
|
||||
APIRoom.Playlist.AddRange(joinedRoom.Playlist.Select(createPlaylistItem));
|
||||
|
||||
Debug.Assert(LocalUser != null);
|
||||
addUserToAPIRoom(LocalUser);
|
||||
@ -219,7 +214,6 @@ namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
APIRoom = null;
|
||||
Room = null;
|
||||
CurrentMatchPlayingItem.Value = null;
|
||||
PlayingUserIds.Clear();
|
||||
|
||||
RoomUpdated?.Invoke();
|
||||
@ -333,8 +327,14 @@ namespace osu.Game.Online.Multiplayer
|
||||
|
||||
public abstract Task StartMatch();
|
||||
|
||||
public abstract Task AbortGameplay();
|
||||
|
||||
public abstract Task AddPlaylistItem(MultiplayerPlaylistItem item);
|
||||
|
||||
public abstract Task EditPlaylistItem(MultiplayerPlaylistItem item);
|
||||
|
||||
public abstract Task RemovePlaylistItem(long playlistItemId);
|
||||
|
||||
Task IMultiplayerClient.RoomStateChanged(MultiplayerRoomState state)
|
||||
{
|
||||
if (Room == null)
|
||||
@ -473,28 +473,7 @@ namespace osu.Game.Online.Multiplayer
|
||||
Debug.Assert(APIRoom != null);
|
||||
Debug.Assert(Room != null);
|
||||
|
||||
Scheduler.Add(() =>
|
||||
{
|
||||
// ensure the new selected item is populated immediately.
|
||||
var playlistItem = APIRoom.Playlist.Single(p => p.ID == newSettings.PlaylistItemId);
|
||||
|
||||
if (playlistItem != null)
|
||||
{
|
||||
GetAPIBeatmap(playlistItem.BeatmapID).ContinueWith(b =>
|
||||
{
|
||||
// Should be called outside of the `Scheduler` logic (and specifically accessing `Exception`) to suppress an exception from firing outwards.
|
||||
bool success = b.Exception == null;
|
||||
|
||||
Scheduler.Add(() =>
|
||||
{
|
||||
if (success)
|
||||
playlistItem.Beatmap.Value = b.Result;
|
||||
|
||||
updateLocalRoomSettings(newSettings);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
Scheduler.Add(() => updateLocalRoomSettings(newSettings));
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
@ -649,12 +628,10 @@ namespace osu.Game.Online.Multiplayer
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task PlaylistItemAdded(MultiplayerPlaylistItem item)
|
||||
public Task PlaylistItemAdded(MultiplayerPlaylistItem item)
|
||||
{
|
||||
if (Room == null)
|
||||
return;
|
||||
|
||||
var playlistItem = await createPlaylistItem(item, true).ConfigureAwait(false);
|
||||
return Task.CompletedTask;
|
||||
|
||||
Scheduler.Add(() =>
|
||||
{
|
||||
@ -664,11 +641,13 @@ namespace osu.Game.Online.Multiplayer
|
||||
Debug.Assert(APIRoom != null);
|
||||
|
||||
Room.Playlist.Add(item);
|
||||
APIRoom.Playlist.Add(playlistItem);
|
||||
APIRoom.Playlist.Add(createPlaylistItem(item));
|
||||
|
||||
ItemAdded?.Invoke(item);
|
||||
RoomUpdated?.Invoke();
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task PlaylistItemRemoved(long playlistItemId)
|
||||
@ -693,12 +672,10 @@ namespace osu.Game.Online.Multiplayer
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task PlaylistItemChanged(MultiplayerPlaylistItem item)
|
||||
public Task PlaylistItemChanged(MultiplayerPlaylistItem item)
|
||||
{
|
||||
if (Room == null)
|
||||
return;
|
||||
|
||||
var playlistItem = await createPlaylistItem(item, true).ConfigureAwait(false);
|
||||
return Task.CompletedTask;
|
||||
|
||||
Scheduler.Add(() =>
|
||||
{
|
||||
@ -711,15 +688,13 @@ namespace osu.Game.Online.Multiplayer
|
||||
|
||||
int existingIndex = APIRoom.Playlist.IndexOf(APIRoom.Playlist.Single(existing => existing.ID == item.ID));
|
||||
APIRoom.Playlist.RemoveAt(existingIndex);
|
||||
APIRoom.Playlist.Insert(existingIndex, playlistItem);
|
||||
|
||||
// If the currently-selected item was the one that got replaced, update the selected item to the new one.
|
||||
if (CurrentMatchPlayingItem.Value?.ID == playlistItem.ID)
|
||||
CurrentMatchPlayingItem.Value = playlistItem;
|
||||
APIRoom.Playlist.Insert(existingIndex, createPlaylistItem(item));
|
||||
|
||||
ItemChanged?.Invoke(item);
|
||||
RoomUpdated?.Invoke();
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -748,12 +723,11 @@ namespace osu.Game.Online.Multiplayer
|
||||
APIRoom.Password.Value = Room.Settings.Password;
|
||||
APIRoom.Type.Value = Room.Settings.MatchType;
|
||||
APIRoom.QueueMode.Value = Room.Settings.QueueMode;
|
||||
RoomUpdated?.Invoke();
|
||||
|
||||
CurrentMatchPlayingItem.Value = APIRoom.Playlist.SingleOrDefault(p => p.ID == settings.PlaylistItemId);
|
||||
RoomUpdated?.Invoke();
|
||||
}
|
||||
|
||||
private async Task<PlaylistItem> createPlaylistItem(MultiplayerPlaylistItem item, bool populateBeatmapImmediately)
|
||||
private PlaylistItem createPlaylistItem(MultiplayerPlaylistItem item)
|
||||
{
|
||||
var ruleset = Rulesets.GetRuleset(item.RulesetID);
|
||||
|
||||
@ -775,9 +749,6 @@ namespace osu.Game.Online.Multiplayer
|
||||
playlistItem.RequiredMods.AddRange(item.RequiredMods.Select(m => m.ToMod(rulesetInstance)));
|
||||
playlistItem.AllowedMods.AddRange(item.AllowedMods.Select(m => m.ToMod(rulesetInstance)));
|
||||
|
||||
if (populateBeatmapImmediately)
|
||||
playlistItem.Beatmap.Value = await GetAPIBeatmap(item.BeatmapID).ConfigureAwait(false);
|
||||
|
||||
return playlistItem;
|
||||
}
|
||||
|
||||
@ -787,7 +758,7 @@ namespace osu.Game.Online.Multiplayer
|
||||
/// <param name="beatmapId">The beatmap ID.</param>
|
||||
/// <param name="cancellationToken">A token to cancel the request.</param>
|
||||
/// <returns>The <see cref="APIBeatmap"/> retrieval task.</returns>
|
||||
protected abstract Task<APIBeatmap> GetAPIBeatmap(int beatmapId, CancellationToken cancellationToken = default);
|
||||
public abstract Task<APIBeatmap> GetAPIBeatmap(int beatmapId, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// For the provided user ID, update whether the user is included in <see cref="CurrentMatchPlayingUserIds"/>.
|
||||
|
@ -154,6 +154,14 @@ namespace osu.Game.Online.Multiplayer
|
||||
return connection.InvokeAsync(nameof(IMultiplayerServer.StartMatch));
|
||||
}
|
||||
|
||||
public override Task AbortGameplay()
|
||||
{
|
||||
if (!IsConnected.Value)
|
||||
return Task.CompletedTask;
|
||||
|
||||
return connection.InvokeAsync(nameof(IMultiplayerServer.AbortGameplay));
|
||||
}
|
||||
|
||||
public override Task AddPlaylistItem(MultiplayerPlaylistItem item)
|
||||
{
|
||||
if (!IsConnected.Value)
|
||||
@ -162,7 +170,23 @@ namespace osu.Game.Online.Multiplayer
|
||||
return connection.InvokeAsync(nameof(IMultiplayerServer.AddPlaylistItem), item);
|
||||
}
|
||||
|
||||
protected override Task<APIBeatmap> GetAPIBeatmap(int beatmapId, CancellationToken cancellationToken = default)
|
||||
public override Task EditPlaylistItem(MultiplayerPlaylistItem item)
|
||||
{
|
||||
if (!IsConnected.Value)
|
||||
return Task.CompletedTask;
|
||||
|
||||
return connection.InvokeAsync(nameof(IMultiplayerServer.EditPlaylistItem), item);
|
||||
}
|
||||
|
||||
public override Task RemovePlaylistItem(long playlistItemId)
|
||||
{
|
||||
if (!IsConnected.Value)
|
||||
return Task.CompletedTask;
|
||||
|
||||
return connection.InvokeAsync(nameof(IMultiplayerServer.RemovePlaylistItem), playlistItemId);
|
||||
}
|
||||
|
||||
public override Task<APIBeatmap> GetAPIBeatmap(int beatmapId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return beatmapLookupCache.GetBeatmapAsync(beatmapId, cancellationToken);
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ namespace osu.Game.Online.Rooms
|
||||
public MultiplayerPlaylistItem(PlaylistItem item)
|
||||
{
|
||||
ID = item.ID;
|
||||
OwnerID = item.OwnerID;
|
||||
BeatmapID = item.BeatmapID;
|
||||
BeatmapChecksum = item.Beatmap.Value?.MD5Hash ?? string.Empty;
|
||||
RulesetID = item.RulesetID;
|
||||
|
@ -69,7 +69,7 @@ namespace osu.Game.Online.Rooms
|
||||
|
||||
var scoreInfo = new ScoreInfo
|
||||
{
|
||||
OnlineScoreID = ID,
|
||||
OnlineID = ID,
|
||||
TotalScore = TotalScore,
|
||||
MaxCombo = MaxCombo,
|
||||
BeatmapInfo = beatmap,
|
||||
|
@ -40,6 +40,11 @@ namespace osu.Game.Online.Rooms
|
||||
|
||||
private BeatmapDownloadTracker downloadTracker;
|
||||
|
||||
/// <summary>
|
||||
/// The beatmap matching the required hash (and providing a final <see cref="BeatmapAvailability.LocallyAvailable"/> state).
|
||||
/// </summary>
|
||||
private BeatmapInfo matchingHash;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
@ -71,13 +76,34 @@ namespace osu.Game.Online.Rooms
|
||||
progressUpdate = Scheduler.AddDelayed(updateAvailability, progressUpdate == null ? 0 : 500);
|
||||
}, true);
|
||||
}, true);
|
||||
|
||||
// These events are needed for a fringe case where a modified/altered beatmap is imported with matching OnlineIDs.
|
||||
// During the import process this will cause the existing beatmap set to be silently deleted and replaced with the new one.
|
||||
// This is not exposed to us via `BeatmapDownloadTracker` so we have to take it into our own hands (as we care about the hash matching).
|
||||
beatmapManager.ItemUpdated += itemUpdated;
|
||||
beatmapManager.ItemRemoved += itemRemoved;
|
||||
}
|
||||
|
||||
private void itemUpdated(BeatmapSetInfo item) => Schedule(() =>
|
||||
{
|
||||
if (matchingHash?.BeatmapSet.ID == item.ID || SelectedItem.Value?.Beatmap.Value.BeatmapSet?.OnlineID == item.OnlineID)
|
||||
updateAvailability();
|
||||
});
|
||||
|
||||
private void itemRemoved(BeatmapSetInfo item) => Schedule(() =>
|
||||
{
|
||||
if (matchingHash?.BeatmapSet.ID == item.ID)
|
||||
updateAvailability();
|
||||
});
|
||||
|
||||
private void updateAvailability()
|
||||
{
|
||||
if (downloadTracker == null)
|
||||
return;
|
||||
|
||||
// will be repopulated below if still valid.
|
||||
matchingHash = null;
|
||||
|
||||
switch (downloadTracker.State.Value)
|
||||
{
|
||||
case DownloadState.NotDownloaded:
|
||||
@ -93,7 +119,9 @@ namespace osu.Game.Online.Rooms
|
||||
break;
|
||||
|
||||
case DownloadState.LocallyAvailable:
|
||||
bool hashMatches = checkHashValidity();
|
||||
matchingHash = findMatchingHash();
|
||||
|
||||
bool hashMatches = matchingHash != null;
|
||||
|
||||
availability.Value = hashMatches ? BeatmapAvailability.LocallyAvailable() : BeatmapAvailability.NotDownloaded();
|
||||
|
||||
@ -108,12 +136,23 @@ namespace osu.Game.Online.Rooms
|
||||
}
|
||||
}
|
||||
|
||||
private bool checkHashValidity()
|
||||
private BeatmapInfo findMatchingHash()
|
||||
{
|
||||
int onlineId = SelectedItem.Value.Beatmap.Value.OnlineID;
|
||||
string checksum = SelectedItem.Value.Beatmap.Value.MD5Hash;
|
||||
|
||||
return beatmapManager.QueryBeatmap(b => b.OnlineID == onlineId && b.MD5Hash == checksum && !b.BeatmapSet.DeletePending) != null;
|
||||
return beatmapManager.QueryBeatmap(b => b.OnlineID == onlineId && b.MD5Hash == checksum && !b.BeatmapSet.DeletePending);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (beatmapManager != null)
|
||||
{
|
||||
beatmapManager.ItemUpdated -= itemUpdated;
|
||||
beatmapManager.ItemRemoved -= itemRemoved;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ namespace osu.Game.Online.Rooms
|
||||
|
||||
req.ContentType = "application/json";
|
||||
req.Method = HttpMethod.Put;
|
||||
req.Timeout = 30000;
|
||||
|
||||
req.AddRaw(JsonConvert.SerializeObject(score, new JsonSerializerSettings
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
@ -35,7 +36,7 @@ namespace osu.Game.Online
|
||||
var scoreInfo = new ScoreInfo
|
||||
{
|
||||
ID = TrackedItem.ID,
|
||||
OnlineScoreID = TrackedItem.OnlineScoreID
|
||||
OnlineID = TrackedItem.OnlineID
|
||||
};
|
||||
|
||||
if (Manager.IsAvailableLocally(scoreInfo))
|
||||
@ -113,7 +114,7 @@ namespace osu.Game.Online
|
||||
UpdateState(DownloadState.NotDownloaded);
|
||||
});
|
||||
|
||||
private bool checkEquality(IScoreInfo x, IScoreInfo y) => x.OnlineID == y.OnlineID;
|
||||
private bool checkEquality(IScoreInfo x, IScoreInfo y) => x.MatchesOnlineID(y);
|
||||
|
||||
#region Disposal
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user