mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 00:53:21 +08:00
Merge remote-tracking branch 'origin/master' into lasy_ruleset_loading
This commit is contained in:
commit
1c547afd15
@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="CatchRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset">
|
<configuration default="false" name="CatchRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset">
|
||||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Catch.Tests/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Catch.Tests.dll" />
|
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Catch.Tests/bin/Debug/netcoreapp3.0/osu.Game.Rulesets.Catch.Tests.dll" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Catch.Tests" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Catch.Tests" />
|
||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
@ -12,7 +12,7 @@
|
|||||||
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v2.2" />
|
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.0" />
|
||||||
<browser url="http://localhost:5000" />
|
<browser url="http://localhost:5000" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Build" enabled="true" />
|
<option name="Build" enabled="true" />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="ManiaRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset">
|
<configuration default="false" name="ManiaRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset">
|
||||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Mania.Tests/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Mania.Tests.dll" />
|
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Mania.Tests/bin/Debug/netcoreapp3.0/osu.Game.Rulesets.Mania.Tests.dll" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Mania.Tests" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Mania.Tests" />
|
||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
@ -12,7 +12,7 @@
|
|||||||
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v2.2" />
|
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.0" />
|
||||||
<browser url="http://localhost:5000" />
|
<browser url="http://localhost:5000" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Build" enabled="true" />
|
<option name="Build" enabled="true" />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="OsuRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset">
|
<configuration default="false" name="OsuRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset">
|
||||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Osu.Tests/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Osu.Tests.dll" />
|
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Osu.Tests/bin/Debug/netcoreapp3.0/osu.Game.Rulesets.Osu.Tests.dll" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Osu.Tests" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Osu.Tests" />
|
||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
@ -12,7 +12,7 @@
|
|||||||
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v2.2" />
|
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.0" />
|
||||||
<browser url="http://localhost:5000" />
|
<browser url="http://localhost:5000" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Build" enabled="true" />
|
<option name="Build" enabled="true" />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="TaikoRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset">
|
<configuration default="false" name="TaikoRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset">
|
||||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Taiko.Tests/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Taiko.Tests.dll" />
|
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Taiko.Tests/bin/Debug/netcoreapp3.0/osu.Game.Rulesets.Taiko.Tests.dll" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Taiko.Tests" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Taiko.Tests" />
|
||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
@ -12,7 +12,7 @@
|
|||||||
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v2.2" />
|
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.0" />
|
||||||
<browser url="http://localhost:5000" />
|
<browser url="http://localhost:5000" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Build" enabled="true" />
|
<option name="Build" enabled="true" />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="Tournament" type="DotNetProject" factoryName=".NET Project" folderName="Tournament">
|
<configuration default="false" name="Tournament" type="DotNetProject" factoryName=".NET Project" folderName="Tournament">
|
||||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Desktop/bin/Debug/netcoreapp2.2/osu!.dll" />
|
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Desktop/bin/Debug/netcoreapp3.0/osu!.dll" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="--tournament" />
|
<option name="PROGRAM_PARAMETERS" value="--tournament" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Desktop" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Desktop" />
|
||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
@ -12,7 +12,7 @@
|
|||||||
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v2.2" />
|
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.0" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Build" enabled="true" />
|
<option name="Build" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="osu!" type="DotNetProject" factoryName=".NET Project" folderName="osu!">
|
<configuration default="false" name="osu!" type="DotNetProject" factoryName=".NET Project" folderName="osu!">
|
||||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Desktop/bin/Debug/netcoreapp2.2/osu!.dll" />
|
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Desktop/bin/Debug/netcoreapp3.0/osu!.dll" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Desktop" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Desktop" />
|
||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
@ -12,7 +12,7 @@
|
|||||||
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v2.2" />
|
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.0" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Build" enabled="true" />
|
<option name="Build" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="osu! (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="osu!">
|
<configuration default="false" name="osu! (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="osu!">
|
||||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Tests/bin/Debug/netcoreapp2.2/osu.Game.Tests.dll" />
|
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Tests/bin/Debug/netcoreapp3.0/osu.Game.Tests.dll" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Tests" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Tests" />
|
||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
@ -12,7 +12,7 @@
|
|||||||
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v2.2" />
|
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.0" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Build" enabled="true" />
|
<option name="Build" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
|
32
.vscode/launch.json
vendored
32
.vscode/launch.json
vendored
@ -6,13 +6,13 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp2.2/osu!.dll"
|
"${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp3.0/osu!.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build osu! (Debug)",
|
"preLaunchTask": "Build osu! (Debug)",
|
||||||
"linux": {
|
"linux": {
|
||||||
"env": {
|
"env": {
|
||||||
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp2.2:${env:LD_LIBRARY_PATH}"
|
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp3.0:${env:LD_LIBRARY_PATH}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"console": "internalConsole"
|
"console": "internalConsole"
|
||||||
@ -23,13 +23,13 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp2.2/osu!.dll"
|
"${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp3.0/osu!.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build osu! (Release)",
|
"preLaunchTask": "Build osu! (Release)",
|
||||||
"linux": {
|
"linux": {
|
||||||
"env": {
|
"env": {
|
||||||
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp2.2:${env:LD_LIBRARY_PATH}"
|
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp3.0:${env:LD_LIBRARY_PATH}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"console": "internalConsole"
|
"console": "internalConsole"
|
||||||
@ -40,13 +40,13 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/osu.Game.Tests/bin/Debug/netcoreapp2.2/osu.Game.Tests.dll"
|
"${workspaceRoot}/osu.Game.Tests/bin/Debug/netcoreapp3.0/osu.Game.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build tests (Debug)",
|
"preLaunchTask": "Build tests (Debug)",
|
||||||
"linux": {
|
"linux": {
|
||||||
"env": {
|
"env": {
|
||||||
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Game.Tests/bin/Debug/netcoreapp2.2:${env:LD_LIBRARY_PATH}"
|
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Game.Tests/bin/Debug/netcoreapp3.0:${env:LD_LIBRARY_PATH}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"console": "internalConsole"
|
"console": "internalConsole"
|
||||||
@ -56,13 +56,13 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/osu.Game.Tests/bin/Release/netcoreapp2.2/osu.Game.Tests.dll"
|
"${workspaceRoot}/osu.Game.Tests/bin/Release/netcoreapp3.0/osu.Game.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build tests (Release)",
|
"preLaunchTask": "Build tests (Release)",
|
||||||
"linux": {
|
"linux": {
|
||||||
"env": {
|
"env": {
|
||||||
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Game.Tests/bin/Release/netcoreapp2.2:${env:LD_LIBRARY_PATH}"
|
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Game.Tests/bin/Release/netcoreapp3.0:${env:LD_LIBRARY_PATH}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"console": "internalConsole"
|
"console": "internalConsole"
|
||||||
@ -73,14 +73,14 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp2.2/osu!.dll",
|
"${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp3.0/osu!.dll",
|
||||||
"--tournament"
|
"--tournament"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build osu! (Debug)",
|
"preLaunchTask": "Build osu! (Debug)",
|
||||||
"linux": {
|
"linux": {
|
||||||
"env": {
|
"env": {
|
||||||
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp2.2:${env:LD_LIBRARY_PATH}"
|
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp3.0:${env:LD_LIBRARY_PATH}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"console": "internalConsole"
|
"console": "internalConsole"
|
||||||
@ -91,14 +91,14 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp2.2/osu!.dll",
|
"${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp3.0/osu!.dll",
|
||||||
"--tournament"
|
"--tournament"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build osu! (Release)",
|
"preLaunchTask": "Build osu! (Release)",
|
||||||
"linux": {
|
"linux": {
|
||||||
"env": {
|
"env": {
|
||||||
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp2.2:${env:LD_LIBRARY_PATH}"
|
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp3.0:${env:LD_LIBRARY_PATH}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"console": "internalConsole"
|
"console": "internalConsole"
|
||||||
@ -109,14 +109,14 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/osu.Game.Tournament.Tests/bin/Debug/netcoreapp2.2/osu.Game.Tournament.Tests.dll",
|
"${workspaceRoot}/osu.Game.Tournament.Tests/bin/Debug/netcoreapp3.0/osu.Game.Tournament.Tests.dll",
|
||||||
"--tournament"
|
"--tournament"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build tournament tests (Debug)",
|
"preLaunchTask": "Build tournament tests (Debug)",
|
||||||
"linux": {
|
"linux": {
|
||||||
"env": {
|
"env": {
|
||||||
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Game.Tournament.Tests/bin/Debug/netcoreapp2.2:${env:LD_LIBRARY_PATH}"
|
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Game.Tournament.Tests/bin/Debug/netcoreapp3.0:${env:LD_LIBRARY_PATH}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"console": "internalConsole"
|
"console": "internalConsole"
|
||||||
@ -127,14 +127,14 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/osu.Game.Tournament.Tests/bin/Debug/netcoreapp2.2/osu.Game.Tournament.Tests.dll",
|
"${workspaceRoot}/osu.Game.Tournament.Tests/bin/Debug/netcoreapp3.0/osu.Game.Tournament.Tests.dll",
|
||||||
"--tournament"
|
"--tournament"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build tournament tests (Release)",
|
"preLaunchTask": "Build tournament tests (Release)",
|
||||||
"linux": {
|
"linux": {
|
||||||
"env": {
|
"env": {
|
||||||
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Game.Tournament.Tests/bin/Debug/netcoreapp2.2:${env:LD_LIBRARY_PATH}"
|
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Game.Tournament.Tests/bin/Debug/netcoreapp3.0:${env:LD_LIBRARY_PATH}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"console": "internalConsole"
|
"console": "internalConsole"
|
||||||
|
2
.vscode/tasks.json
vendored
2
.vscode/tasks.json
vendored
@ -95,7 +95,7 @@
|
|||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Restore (netcoreapp2.2)",
|
"label": "Restore (netcoreapp3.0)",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "dotnet",
|
"command": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
|
16
Gemfile.lock
16
Gemfile.lock
@ -18,7 +18,7 @@ GEM
|
|||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
dotenv (2.7.5)
|
dotenv (2.7.5)
|
||||||
emoji_regex (1.0.1)
|
emoji_regex (1.0.1)
|
||||||
excon (0.66.0)
|
excon (0.67.0)
|
||||||
faraday (0.15.4)
|
faraday (0.15.4)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
faraday-cookie_jar (0.0.6)
|
faraday-cookie_jar (0.0.6)
|
||||||
@ -27,7 +27,7 @@ GEM
|
|||||||
faraday_middleware (0.13.1)
|
faraday_middleware (0.13.1)
|
||||||
faraday (>= 0.7.4, < 1.0)
|
faraday (>= 0.7.4, < 1.0)
|
||||||
fastimage (2.1.7)
|
fastimage (2.1.7)
|
||||||
fastlane (2.131.0)
|
fastlane (2.133.0)
|
||||||
CFPropertyList (>= 2.3, < 4.0.0)
|
CFPropertyList (>= 2.3, < 4.0.0)
|
||||||
addressable (>= 2.3, < 3.0.0)
|
addressable (>= 2.3, < 3.0.0)
|
||||||
babosa (>= 1.0.2, < 2.0.0)
|
babosa (>= 1.0.2, < 2.0.0)
|
||||||
@ -37,9 +37,9 @@ GEM
|
|||||||
dotenv (>= 2.1.1, < 3.0.0)
|
dotenv (>= 2.1.1, < 3.0.0)
|
||||||
emoji_regex (>= 0.1, < 2.0)
|
emoji_regex (>= 0.1, < 2.0)
|
||||||
excon (>= 0.45.0, < 1.0.0)
|
excon (>= 0.45.0, < 1.0.0)
|
||||||
faraday (~> 0.9)
|
faraday (< 0.16.0)
|
||||||
faraday-cookie_jar (~> 0.0.6)
|
faraday-cookie_jar (~> 0.0.6)
|
||||||
faraday_middleware (~> 0.9)
|
faraday_middleware (< 0.16.0)
|
||||||
fastimage (>= 2.1.0, < 3.0.0)
|
fastimage (>= 2.1.0, < 3.0.0)
|
||||||
gh_inspector (>= 1.1.2, < 2.0.0)
|
gh_inspector (>= 1.1.2, < 2.0.0)
|
||||||
google-api-client (>= 0.21.2, < 0.24.0)
|
google-api-client (>= 0.21.2, < 0.24.0)
|
||||||
@ -52,7 +52,7 @@ GEM
|
|||||||
multipart-post (~> 2.0.0)
|
multipart-post (~> 2.0.0)
|
||||||
plist (>= 3.1.0, < 4.0.0)
|
plist (>= 3.1.0, < 4.0.0)
|
||||||
public_suffix (~> 2.0.0)
|
public_suffix (~> 2.0.0)
|
||||||
rubyzip (>= 1.2.2, < 2.0.0)
|
rubyzip (>= 1.3.0, < 2.0.0)
|
||||||
security (= 0.1.3)
|
security (= 0.1.3)
|
||||||
simctl (~> 1.6.3)
|
simctl (~> 1.6.3)
|
||||||
slack-notifier (>= 2.0.0, < 3.0.0)
|
slack-notifier (>= 2.0.0, < 3.0.0)
|
||||||
@ -102,7 +102,7 @@ GEM
|
|||||||
memoist (0.16.0)
|
memoist (0.16.0)
|
||||||
mime-types (3.3)
|
mime-types (3.3)
|
||||||
mime-types-data (~> 3.2015)
|
mime-types-data (~> 3.2015)
|
||||||
mime-types-data (3.2019.0904)
|
mime-types-data (3.2019.1009)
|
||||||
mini_magick (4.9.5)
|
mini_magick (4.9.5)
|
||||||
mini_portile2 (2.4.0)
|
mini_portile2 (2.4.0)
|
||||||
multi_json (1.13.1)
|
multi_json (1.13.1)
|
||||||
@ -121,9 +121,9 @@ GEM
|
|||||||
uber (< 0.2.0)
|
uber (< 0.2.0)
|
||||||
retriable (3.1.2)
|
retriable (3.1.2)
|
||||||
rouge (2.0.7)
|
rouge (2.0.7)
|
||||||
rubyzip (1.2.4)
|
rubyzip (1.3.0)
|
||||||
security (0.1.3)
|
security (0.1.3)
|
||||||
signet (0.11.0)
|
signet (0.12.0)
|
||||||
addressable (~> 2.3)
|
addressable (~> 2.3)
|
||||||
faraday (~> 0.9)
|
faraday (~> 0.9)
|
||||||
jwt (>= 1.5, < 3.0)
|
jwt (>= 1.5, < 3.0)
|
||||||
|
@ -18,7 +18,7 @@ Detailed changelogs are published on the [official osu! site](https://osu.ppy.sh
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- A desktop platform with the [.NET Core SDK 2.2](https://www.microsoft.com/net/learn/get-started) or higher installed.
|
- A desktop platform with the [.NET Core SDK 3.0](https://www.microsoft.com/net/learn/get-started) or higher installed.
|
||||||
- When running on linux, please have a system-wide ffmpeg installation available to support video decoding.
|
- When running on linux, please have a system-wide ffmpeg installation available to support video decoding.
|
||||||
- When running on Windows 7 or 8.1, **[additional prerequisites](https://docs.microsoft.com/en-us/dotnet/core/windows-prerequisites?tabs=netcore2x)** may be required to correctly run .NET Core applications if your operating system is not up-to-date with the latest service packs.
|
- When running on Windows 7 or 8.1, **[additional prerequisites](https://docs.microsoft.com/en-us/dotnet/core/windows-prerequisites?tabs=netcore2x)** may be required to correctly run .NET Core applications if your operating system is not up-to-date with the latest service packs.
|
||||||
- When working with the codebase, we recommend using an IDE with intellisense and syntax highlighting, such as [Visual Studio 2017+](https://visualstudio.microsoft.com/vs/), [Jetbrains Rider](https://www.jetbrains.com/rider/) or [Visual Studio Code](https://code.visualstudio.com/).
|
- When working with the codebase, we recommend using an IDE with intellisense and syntax highlighting, such as [Visual Studio 2017+](https://visualstudio.microsoft.com/vs/), [Jetbrains Rider](https://www.jetbrains.com/rider/) or [Visual Studio Code](https://code.visualstudio.com/).
|
||||||
@ -78,7 +78,7 @@ On Linux, the environment variable `LD_LIBRARY_PATH` must point to the build dir
|
|||||||
For example, you can run osu! with the following command:
|
For example, you can run osu! with the following command:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
LD_LIBRARY_PATH="$(pwd)/osu.Desktop/bin/Debug/netcoreapp2.2" dotnet run --project osu.Desktop
|
LD_LIBRARY_PATH="$(pwd)/osu.Desktop/bin/Debug/netcoreapp3.0" dotnet run --project osu.Desktop
|
||||||
```
|
```
|
||||||
|
|
||||||
### Testing with resource/framework modifications
|
### Testing with resource/framework modifications
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
clone_depth: 1
|
clone_depth: 1
|
||||||
version: '{branch}-{build}'
|
version: '{branch}-{build}'
|
||||||
image: Previous Visual Studio 2017
|
image: Visual Studio 2019 Preview
|
||||||
test: off
|
test: off
|
||||||
build_script:
|
build_script:
|
||||||
- cmd: PowerShell -Version 2.0 .\build.ps1
|
- cmd: PowerShell -Version 2.0 .\build.ps1
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
clone_depth: 1
|
clone_depth: 1
|
||||||
version: '{build}'
|
version: '{build}'
|
||||||
image: Previous Visual Studio 2017
|
image: Visual Studio 2019 Preview
|
||||||
test: off
|
test: off
|
||||||
skip_non_tags: true
|
skip_non_tags: true
|
||||||
build_script:
|
build_script:
|
||||||
|
63
build.ps1
Normal file → Executable file
63
build.ps1
Normal file → Executable file
@ -1,39 +1,5 @@
|
|||||||
##########################################################################
|
|
||||||
# This is a customized Cake bootstrapper script for PowerShell.
|
|
||||||
##########################################################################
|
|
||||||
|
|
||||||
<#
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
This is a Powershell script to bootstrap a Cake build.
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
This Powershell script restores NuGet tools (including Cake)
|
|
||||||
and execute your Cake build script with the parameters you provide.
|
|
||||||
|
|
||||||
.PARAMETER Script
|
|
||||||
The build script to execute.
|
|
||||||
.PARAMETER Target
|
|
||||||
The build script target to run.
|
|
||||||
.PARAMETER Configuration
|
|
||||||
The build configuration to use.
|
|
||||||
.PARAMETER Verbosity
|
|
||||||
Specifies the amount of information to be displayed.
|
|
||||||
.PARAMETER ShowDescription
|
|
||||||
Shows description about tasks.
|
|
||||||
.PARAMETER DryRun
|
|
||||||
Performs a dry run.
|
|
||||||
.PARAMETER ScriptArgs
|
|
||||||
Remaining arguments are added here.
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://cakebuild.net
|
|
||||||
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
Param(
|
Param(
|
||||||
[string]$Script = "build.cake",
|
|
||||||
[string]$Target,
|
[string]$Target,
|
||||||
[string]$Configuration,
|
[string]$Configuration,
|
||||||
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
|
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
|
||||||
@ -45,27 +11,8 @@ Param(
|
|||||||
[string[]]$ScriptArgs
|
[string[]]$ScriptArgs
|
||||||
)
|
)
|
||||||
|
|
||||||
Write-Host "Preparing to run build script..."
|
|
||||||
|
|
||||||
# Determine the script root for resolving other paths.
|
|
||||||
if(!$PSScriptRoot) {
|
|
||||||
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
|
|
||||||
}
|
|
||||||
|
|
||||||
# Resolve the paths for resources used for debugging.
|
|
||||||
$BUILD_DIR = Join-Path $PSScriptRoot "build"
|
|
||||||
$TOOLS_DIR = Join-Path $BUILD_DIR "tools"
|
|
||||||
$CAKE_CSPROJ = Join-Path $BUILD_DIR "cakebuild.csproj"
|
|
||||||
|
|
||||||
# Install the required tools locally.
|
|
||||||
Write-Host "Restoring cake tools..."
|
|
||||||
Invoke-Expression "dotnet restore `"$CAKE_CSPROJ`" --packages `"$TOOLS_DIR`"" | Out-Null
|
|
||||||
|
|
||||||
# Find the Cake executable
|
|
||||||
$CAKE_EXECUTABLE = (Get-ChildItem -Path "$TOOLS_DIR/cake.coreclr/" -Filter Cake.dll -Recurse).FullName
|
|
||||||
|
|
||||||
# Build Cake arguments
|
# Build Cake arguments
|
||||||
$cakeArguments = @("$Script");
|
$cakeArguments = "";
|
||||||
if ($Target) { $cakeArguments += "-target=$Target" }
|
if ($Target) { $cakeArguments += "-target=$Target" }
|
||||||
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
|
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
|
||||||
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
|
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
|
||||||
@ -74,9 +21,7 @@ if ($DryRun) { $cakeArguments += "-dryrun" }
|
|||||||
if ($Experimental) { $cakeArguments += "-experimental" }
|
if ($Experimental) { $cakeArguments += "-experimental" }
|
||||||
$cakeArguments += $ScriptArgs
|
$cakeArguments += $ScriptArgs
|
||||||
|
|
||||||
# Start Cake
|
dotnet tool install Cake.Tool --global --version 0.35.0
|
||||||
Write-Host "Running build script..."
|
dotnet cake ./build/build.cake --bootstrap
|
||||||
Push-Location -Path $BUILD_DIR
|
dotnet cake ./build/build.cake $cakeArguments
|
||||||
Invoke-Expression "dotnet `"$CAKE_EXECUTABLE`" $cakeArguments"
|
|
||||||
Pop-Location
|
|
||||||
exit $LASTEXITCODE
|
exit $LASTEXITCODE
|
29
build.sh
29
build.sh
@ -1,18 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
echo "Installing Cake.Tool..."
|
||||||
|
dotnet tool install Cake.Tool --global --version 0.35.0
|
||||||
##########################################################################
|
|
||||||
# This is a customized Cake bootstrapper script for Shell.
|
|
||||||
##########################################################################
|
|
||||||
|
|
||||||
echo "Preparing to run build script..."
|
|
||||||
|
|
||||||
cd build
|
|
||||||
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
|
||||||
TOOLS_DIR=$SCRIPT_DIR/tools
|
|
||||||
CAKE_BINARY_PATH=$TOOLS_DIR/"cake.coreclr"
|
|
||||||
|
|
||||||
SCRIPT="build.cake"
|
|
||||||
CAKE_CSPROJ=$SCRIPT_DIR/"cakebuild.csproj"
|
|
||||||
|
|
||||||
# Parse arguments.
|
# Parse arguments.
|
||||||
CAKE_ARGUMENTS=()
|
CAKE_ARGUMENTS=()
|
||||||
@ -25,14 +12,6 @@ for i in "$@"; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
# Install the required tools locally.
|
|
||||||
echo "Restoring cake tools..."
|
|
||||||
dotnet restore $CAKE_CSPROJ --packages $TOOLS_DIR > /dev/null 2>&1
|
|
||||||
|
|
||||||
# Search for the CakeBuild binary.
|
|
||||||
CAKE_BINARY=$(find $CAKE_BINARY_PATH -name "Cake.dll")
|
|
||||||
|
|
||||||
# Start Cake
|
|
||||||
echo "Running build script..."
|
echo "Running build script..."
|
||||||
|
dotnet cake ./build/build.cake --bootstrap
|
||||||
dotnet "$CAKE_BINARY" $SCRIPT "${CAKE_ARGUMENTS[@]}"
|
dotnet cake ./build/build.cake "${CAKE_ARGUMENTS[@]}"
|
@ -1,5 +1,5 @@
|
|||||||
#addin "nuget:?package=CodeFileSanity&version=0.0.21"
|
#addin "nuget:?package=CodeFileSanity&version=0.0.33"
|
||||||
#addin "nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2019.1.1"
|
#addin "nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2019.2.1"
|
||||||
#tool "nuget:?package=NVika.MSBuild&version=1.0.1"
|
#tool "nuget:?package=NVika.MSBuild&version=1.0.1"
|
||||||
var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First();
|
var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First();
|
||||||
|
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<PackAsTool>true</PackAsTool>
|
|
||||||
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Cake" Version="0.34.1" />
|
|
||||||
<PackageReference Include="Cake.CoreCLR" Version="0.34.1" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
@ -61,7 +61,7 @@
|
|||||||
<Reference Include="Java.Interop" />
|
<Reference Include="Java.Interop" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.913.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.924.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1011.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Import Project="..\osu.Game.props" />
|
<Import Project="..\osu.Game.props" />
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Catch.Tests.dll"
|
"${workspaceRoot}/bin/Debug/netcoreapp3.0/osu.Game.Rulesets.Catch.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Debug)",
|
"preLaunchTask": "Build (Debug)",
|
||||||
@ -20,7 +20,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Release/netcoreapp2.2/osu.Game.Rulesets.Catch.Tests.dll"
|
"${workspaceRoot}/bin/Release/netcoreapp3.0/osu.Game.Rulesets.Catch.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Release)",
|
"preLaunchTask": "Build (Release)",
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="Project References">
|
<ItemGroup Label="Project References">
|
||||||
<ProjectReference Include="..\osu.Game.Rulesets.Catch\osu.Game.Rulesets.Catch.csproj" />
|
<ProjectReference Include="..\osu.Game.Rulesets.Catch\osu.Game.Rulesets.Catch.csproj" />
|
||||||
|
@ -93,7 +93,7 @@ namespace osu.Game.Rulesets.Catch.Objects
|
|||||||
Scale = 1.0f - 0.7f * (difficulty.CircleSize - 5) / 5;
|
Scale = 1.0f - 0.7f * (difficulty.CircleSize - 5) / 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => null;
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum FruitVisualRepresentation
|
public enum FruitVisualRepresentation
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Mania.Tests.dll"
|
"${workspaceRoot}/bin/Debug/netcoreapp3.0/osu.Game.Rulesets.Mania.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Debug)",
|
"preLaunchTask": "Build (Debug)",
|
||||||
@ -20,7 +20,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Release/netcoreapp2.2/osu.Game.Rulesets.Mania.Tests.dll"
|
"${workspaceRoot}/bin/Release/netcoreapp3.0/osu.Game.Rulesets.Mania.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Release)",
|
"preLaunchTask": "Build (Release)",
|
||||||
|
@ -27,8 +27,13 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
[Cached(typeof(IReadOnlyList<Mod>))]
|
[Cached(typeof(IReadOnlyList<Mod>))]
|
||||||
private IReadOnlyList<Mod> mods { get; set; } = Array.Empty<Mod>();
|
private IReadOnlyList<Mod> mods { get; set; } = Array.Empty<Mod>();
|
||||||
|
|
||||||
|
[Cached(typeof(IScrollingInfo))]
|
||||||
|
private IScrollingInfo scrollingInfo;
|
||||||
|
|
||||||
protected ManiaPlacementBlueprintTestScene()
|
protected ManiaPlacementBlueprintTestScene()
|
||||||
{
|
{
|
||||||
|
scrollingInfo = ((ScrollingTestContainer)HitObjectContainer).ScrollingInfo;
|
||||||
|
|
||||||
Add(column = new Column(0)
|
Add(column = new Column(0)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
@ -36,15 +41,8 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
AccentColour = Color4.OrangeRed,
|
AccentColour = Color4.OrangeRed,
|
||||||
Clock = new FramedClock(new StopwatchClock()), // No scroll
|
Clock = new FramedClock(new StopwatchClock()), // No scroll
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
AddStep("change direction", () => ((ScrollingTestContainer)HitObjectContainer).Flip());
|
||||||
{
|
|
||||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
||||||
|
|
||||||
dependencies.CacheAs(((ScrollingTestContainer)HitObjectContainer).ScrollingInfo);
|
|
||||||
|
|
||||||
return dependencies;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Container CreateHitObjectContainer() => new ScrollingTestContainer(ScrollingDirection.Down) { RelativeSizeAxes = Axes.Both };
|
protected override Container CreateHitObjectContainer() => new ScrollingTestContainer(ScrollingDirection.Down) { RelativeSizeAxes = Axes.Both };
|
||||||
|
@ -6,7 +6,6 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Edit;
|
|
||||||
using osu.Game.Rulesets.Mania.Edit.Blueprints;
|
using osu.Game.Rulesets.Mania.Edit.Blueprints;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||||
@ -39,6 +38,8 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
AccentColour = { Value = OsuColour.Gray(0.3f) }
|
AccentColour = { Value = OsuColour.Gray(0.3f) }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AddBlueprint(new HoldNoteSelectionBlueprint(drawableObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
@ -51,7 +52,5 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
nested.Y = (float)(-finalPosition * content.DrawHeight);
|
nested.Y = (float)(-finalPosition * content.DrawHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override SelectionBlueprint CreateBlueprint() => new HoldNoteSelectionBlueprint(drawableObject);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Rulesets.Edit;
|
|
||||||
using osu.Game.Rulesets.Mania.Edit.Blueprints;
|
using osu.Game.Rulesets.Mania.Edit.Blueprints;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||||
@ -17,8 +16,6 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
{
|
{
|
||||||
public class TestSceneNoteSelectionBlueprint : ManiaSelectionBlueprintTestScene
|
public class TestSceneNoteSelectionBlueprint : ManiaSelectionBlueprintTestScene
|
||||||
{
|
{
|
||||||
private readonly DrawableNote drawableObject;
|
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content ?? base.Content;
|
protected override Container<Drawable> Content => content ?? base.Content;
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
|
|
||||||
@ -27,6 +24,8 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
var note = new Note { Column = 0 };
|
var note = new Note { Column = 0 };
|
||||||
note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||||
|
|
||||||
|
DrawableNote drawableObject;
|
||||||
|
|
||||||
base.Content.Child = content = new ScrollingTestContainer(ScrollingDirection.Down)
|
base.Content.Child = content = new ScrollingTestContainer(ScrollingDirection.Down)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
@ -34,8 +33,8 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
Size = new Vector2(50, 20),
|
Size = new Vector2(50, 20),
|
||||||
Child = drawableObject = new DrawableNote(note)
|
Child = drawableObject = new DrawableNote(note)
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
protected override SelectionBlueprint CreateBlueprint() => new NoteSelectionBlueprint(drawableObject);
|
AddBlueprint(new NoteSelectionBlueprint(drawableObject));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="Project References">
|
<ItemGroup Label="Project References">
|
||||||
<ProjectReference Include="..\osu.Game.Rulesets.Mania\osu.Game.Rulesets.Mania.csproj" />
|
<ProjectReference Include="..\osu.Game.Rulesets.Mania\osu.Game.Rulesets.Mania.csproj" />
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input.Events;
|
|
||||||
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
|
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -49,13 +48,13 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
|
|
||||||
private double originalStartTime;
|
private double originalStartTime;
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
public override void UpdatePosition(Vector2 screenSpacePosition)
|
||||||
{
|
{
|
||||||
base.OnMouseMove(e);
|
base.UpdatePosition(screenSpacePosition);
|
||||||
|
|
||||||
if (PlacementBegun)
|
if (PlacementBegun)
|
||||||
{
|
{
|
||||||
var endTime = TimeAt(e.ScreenSpaceMousePosition);
|
var endTime = TimeAt(screenSpacePosition);
|
||||||
|
|
||||||
HitObject.StartTime = endTime < originalStartTime ? endTime : originalStartTime;
|
HitObject.StartTime = endTime < originalStartTime ? endTime : originalStartTime;
|
||||||
HitObject.Duration = Math.Abs(endTime - originalStartTime);
|
HitObject.Duration = Math.Abs(endTime - originalStartTime);
|
||||||
@ -65,10 +64,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
headPiece.Width = tailPiece.Width = SnappedWidth;
|
headPiece.Width = tailPiece.Width = SnappedWidth;
|
||||||
headPiece.X = tailPiece.X = SnappedMousePosition.X;
|
headPiece.X = tailPiece.X = SnappedMousePosition.X;
|
||||||
|
|
||||||
originalStartTime = HitObject.StartTime = TimeAt(e.ScreenSpaceMousePosition);
|
originalStartTime = HitObject.StartTime = TimeAt(screenSpacePosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,19 +62,18 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
return base.OnMouseUp(e);
|
return base.OnMouseUp(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
public override void UpdatePosition(Vector2 screenSpacePosition)
|
||||||
{
|
{
|
||||||
if (!PlacementBegun)
|
if (!PlacementBegun)
|
||||||
Column = ColumnAt(e.ScreenSpaceMousePosition);
|
Column = ColumnAt(screenSpacePosition);
|
||||||
|
|
||||||
if (Column == null) return false;
|
if (Column == null) return;
|
||||||
|
|
||||||
SnappedWidth = Column.DrawWidth;
|
SnappedWidth = Column.DrawWidth;
|
||||||
|
|
||||||
// Snap to the column
|
// Snap to the column
|
||||||
var parentPos = Parent.ToLocalSpace(Column.ToScreenSpace(new Vector2(Column.DrawWidth / 2, 0)));
|
var parentPos = Parent.ToLocalSpace(Column.ToScreenSpace(new Vector2(Column.DrawWidth / 2, 0)));
|
||||||
SnappedMousePosition = new Vector2(parentPos.X, e.MousePosition.Y);
|
SnappedMousePosition = new Vector2(parentPos.X, Parent.ToLocalSpace(screenSpacePosition).Y);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double TimeAt(Vector2 screenSpacePosition)
|
protected double TimeAt(Vector2 screenSpacePosition)
|
||||||
@ -86,7 +85,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
|
|
||||||
// If we're scrolling downwards, a position of 0 is actually further away from the hit target
|
// If we're scrolling downwards, a position of 0 is actually further away from the hit target
|
||||||
// so we need to flip the vertical coordinate in the hitobject container's space
|
// so we need to flip the vertical coordinate in the hitobject container's space
|
||||||
var hitObjectPos = Column.HitObjectContainer.ToLocalSpace(applyPositionOffset(screenSpacePosition, false)).Y;
|
var hitObjectPos = mouseToHitObjectPosition(Column.HitObjectContainer.ToLocalSpace(screenSpacePosition)).Y;
|
||||||
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
|
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
|
||||||
hitObjectPos = hitObjectContainer.DrawHeight - hitObjectPos;
|
hitObjectPos = hitObjectContainer.DrawHeight - hitObjectPos;
|
||||||
|
|
||||||
@ -103,16 +102,58 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
scrollingInfo.TimeRange.Value,
|
scrollingInfo.TimeRange.Value,
|
||||||
Column.HitObjectContainer.DrawHeight);
|
Column.HitObjectContainer.DrawHeight);
|
||||||
|
|
||||||
return applyPositionOffset(Column.HitObjectContainer.ToSpaceOfOtherDrawable(new Vector2(0, pos), Parent), true).Y;
|
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
|
||||||
|
pos = Column.HitObjectContainer.DrawHeight - pos;
|
||||||
|
|
||||||
|
return hitObjectToMousePosition(Column.HitObjectContainer.ToSpaceOfOtherDrawable(new Vector2(0, pos), Parent)).Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Column ColumnAt(Vector2 screenSpacePosition)
|
protected Column ColumnAt(Vector2 screenSpacePosition)
|
||||||
=> composer.ColumnAt(applyPositionOffset(screenSpacePosition, false));
|
=> composer.ColumnAt(screenSpacePosition);
|
||||||
|
|
||||||
private Vector2 applyPositionOffset(Vector2 position, bool reverse)
|
/// <summary>
|
||||||
|
/// Converts a mouse position to a hitobject position.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Blueprints are centred on the mouse position, such that the hitobject position is anchored at the top or bottom of the blueprint depending on the scroll direction.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="mousePosition">The mouse position.</param>
|
||||||
|
/// <returns>The resulting hitobject position, acnhored at the top or bottom of the blueprint depending on the scroll direction.</returns>
|
||||||
|
private Vector2 mouseToHitObjectPosition(Vector2 mousePosition)
|
||||||
{
|
{
|
||||||
position.Y += (scrollingInfo.Direction.Value == ScrollingDirection.Up && !reverse ? -1 : 1) * NotePiece.NOTE_HEIGHT / 2;
|
switch (scrollingInfo.Direction.Value)
|
||||||
return position;
|
{
|
||||||
|
case ScrollingDirection.Up:
|
||||||
|
mousePosition.Y -= NotePiece.NOTE_HEIGHT / 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScrollingDirection.Down:
|
||||||
|
mousePosition.Y += NotePiece.NOTE_HEIGHT / 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mousePosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a hitobject position to a mouse position.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hitObjectPosition">The hitobject position.</param>
|
||||||
|
/// <returns>The resulting mouse position, anchored at the centre of the hitobject.</returns>
|
||||||
|
private Vector2 hitObjectToMousePosition(Vector2 hitObjectPosition)
|
||||||
|
{
|
||||||
|
switch (scrollingInfo.Direction.Value)
|
||||||
|
{
|
||||||
|
case ScrollingDirection.Up:
|
||||||
|
hitObjectPosition.Y += NotePiece.NOTE_HEIGHT / 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScrollingDirection.Down:
|
||||||
|
hitObjectPosition.Y -= NotePiece.NOTE_HEIGHT / 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hitObjectPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
public Vector2 ScreenSpaceDragPosition { get; private set; }
|
public Vector2 ScreenSpaceDragPosition { get; private set; }
|
||||||
public Vector2 DragPosition { get; private set; }
|
public Vector2 DragPosition { get; private set; }
|
||||||
|
|
||||||
protected new DrawableManiaHitObject HitObject => (DrawableManiaHitObject)base.HitObject;
|
public new DrawableManiaHitObject HitObject => (DrawableManiaHitObject)base.HitObject;
|
||||||
|
|
||||||
protected IClock EditorClock { get; private set; }
|
protected IClock EditorClock { get; private set; }
|
||||||
|
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Input.Events;
|
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Rulesets.Edit;
|
|
||||||
using osu.Game.Rulesets.Mania.Edit.Blueprints;
|
using osu.Game.Rulesets.Mania.Edit.Blueprints;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
@ -31,13 +29,16 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
editorClock = clock;
|
editorClock = clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void HandleDrag(SelectionBlueprint blueprint, DragEvent dragEvent)
|
public override void HandleMovement(MoveSelectionEvent moveEvent)
|
||||||
{
|
{
|
||||||
adjustOrigins((ManiaSelectionBlueprint)blueprint);
|
var maniaBlueprint = (ManiaSelectionBlueprint)moveEvent.Blueprint;
|
||||||
performDragMovement(dragEvent);
|
int lastColumn = maniaBlueprint.HitObject.HitObject.Column;
|
||||||
performColumnMovement(dragEvent);
|
|
||||||
|
|
||||||
base.HandleDrag(blueprint, dragEvent);
|
adjustOrigins(maniaBlueprint);
|
||||||
|
performDragMovement(moveEvent);
|
||||||
|
performColumnMovement(lastColumn, moveEvent);
|
||||||
|
|
||||||
|
base.HandleMovement(moveEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -62,7 +63,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
b.HitObject.Y += movementDelta;
|
b.HitObject.Y += movementDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performDragMovement(DragEvent dragEvent)
|
private void performDragMovement(MoveSelectionEvent moveEvent)
|
||||||
{
|
{
|
||||||
foreach (var b in SelectedBlueprints)
|
foreach (var b in SelectedBlueprints)
|
||||||
{
|
{
|
||||||
@ -72,7 +73,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
|
|
||||||
// Using the hitobject position is required since AdjustPosition can be invoked multiple times per frame
|
// Using the hitobject position is required since AdjustPosition can be invoked multiple times per frame
|
||||||
// without the position having been updated by the parenting ScrollingHitObjectContainer
|
// without the position having been updated by the parenting ScrollingHitObjectContainer
|
||||||
hitObject.Y += dragEvent.Delta.Y;
|
hitObject.Y += moveEvent.InstantDelta.Y;
|
||||||
|
|
||||||
float targetPosition;
|
float targetPosition;
|
||||||
|
|
||||||
@ -94,14 +95,13 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performColumnMovement(DragEvent dragEvent)
|
private void performColumnMovement(int lastColumn, MoveSelectionEvent moveEvent)
|
||||||
{
|
{
|
||||||
var lastColumn = composer.ColumnAt(dragEvent.ScreenSpaceLastMousePosition);
|
var currentColumn = composer.ColumnAt(moveEvent.ScreenSpacePosition);
|
||||||
var currentColumn = composer.ColumnAt(dragEvent.ScreenSpaceMousePosition);
|
if (currentColumn == null)
|
||||||
if (lastColumn == null || currentColumn == null)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int columnDelta = currentColumn.Index - lastColumn.Index;
|
int columnDelta = currentColumn.Index - lastColumn;
|
||||||
if (columnDelta == 0)
|
if (columnDelta == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -101,6 +101,6 @@ namespace osu.Game.Rulesets.Mania.Objects
|
|||||||
|
|
||||||
public override Judgement CreateJudgement() => new HoldNoteJudgement();
|
public override Judgement CreateJudgement() => new HoldNoteJudgement();
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => null;
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,6 @@ namespace osu.Game.Rulesets.Mania.Objects
|
|||||||
{
|
{
|
||||||
public override Judgement CreateJudgement() => new HoldNoteTickJudgement();
|
public override Judgement CreateJudgement() => new HoldNoteTickJudgement();
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => null;
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Osu.Tests.dll"
|
"${workspaceRoot}/bin/Debug/netcoreapp3.0/osu.Game.Rulesets.Osu.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Debug)",
|
"preLaunchTask": "Build (Debug)",
|
||||||
@ -20,7 +20,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Release/netcoreapp2.2/osu.Game.Rulesets.Osu.Tests.dll"
|
"${workspaceRoot}/bin/Release/netcoreapp3.0/osu.Game.Rulesets.Osu.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Release)",
|
"preLaunchTask": "Build (Release)",
|
||||||
|
@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.IO;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
@ -21,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
public void TestStacking()
|
public void TestStacking()
|
||||||
{
|
{
|
||||||
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(beatmap_data)))
|
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(beatmap_data)))
|
||||||
using (var reader = new StreamReader(stream))
|
using (var reader = new LineBufferedReader(stream))
|
||||||
{
|
{
|
||||||
var beatmap = Decoder.GetDecoder<Beatmap>(reader).Decode(reader);
|
var beatmap = Decoder.GetDecoder<Beatmap>(reader).Decode(reader);
|
||||||
var converted = new TestWorkingBeatmap(beatmap).GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty<Mod>());
|
var converted = new TestWorkingBeatmap(beatmap).GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty<Mod>());
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Rulesets.Edit;
|
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
|
||||||
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
@ -14,16 +15,51 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
public class TestSceneHitCircleSelectionBlueprint : SelectionBlueprintTestScene
|
public class TestSceneHitCircleSelectionBlueprint : SelectionBlueprintTestScene
|
||||||
{
|
{
|
||||||
private readonly DrawableHitCircle drawableObject;
|
private HitCircle hitCircle;
|
||||||
|
private DrawableHitCircle drawableObject;
|
||||||
|
private TestBlueprint blueprint;
|
||||||
|
|
||||||
public TestSceneHitCircleSelectionBlueprint()
|
[SetUp]
|
||||||
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
var hitCircle = new HitCircle { Position = new Vector2(256, 192) };
|
Clear();
|
||||||
|
|
||||||
|
hitCircle = new HitCircle { Position = new Vector2(256, 192) };
|
||||||
hitCircle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 });
|
hitCircle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 });
|
||||||
|
|
||||||
Add(drawableObject = new DrawableHitCircle(hitCircle));
|
Add(drawableObject = new DrawableHitCircle(hitCircle));
|
||||||
|
AddBlueprint(blueprint = new TestBlueprint(drawableObject));
|
||||||
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestInitialState()
|
||||||
|
{
|
||||||
|
AddAssert("blueprint positioned over hitobject", () => blueprint.CirclePiece.Position == hitCircle.Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override SelectionBlueprint CreateBlueprint() => new HitCircleSelectionBlueprint(drawableObject);
|
[Test]
|
||||||
|
public void TestMoveHitObject()
|
||||||
|
{
|
||||||
|
AddStep("move hitobject", () => hitCircle.Position = new Vector2(300, 225));
|
||||||
|
AddAssert("blueprint positioned over hitobject", () => blueprint.CirclePiece.Position == hitCircle.Position);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMoveAfterApplyingDefaults()
|
||||||
|
{
|
||||||
|
AddStep("apply defaults", () => hitCircle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 }));
|
||||||
|
AddStep("move hitobject", () => hitCircle.Position = new Vector2(300, 225));
|
||||||
|
AddAssert("blueprint positioned over hitobject", () => blueprint.CirclePiece.Position == hitCircle.Position);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestBlueprint : HitCircleSelectionBlueprint
|
||||||
|
{
|
||||||
|
public new HitCirclePiece CirclePiece => base.CirclePiece;
|
||||||
|
|
||||||
|
public TestBlueprint(DrawableHitCircle hitCircle)
|
||||||
|
: base(hitCircle)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Rulesets.Edit;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders;
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
@ -29,11 +31,16 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
typeof(PathControlPointPiece)
|
typeof(PathControlPointPiece)
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly DrawableSlider drawableObject;
|
private Slider slider;
|
||||||
|
private DrawableSlider drawableObject;
|
||||||
|
private TestSliderBlueprint blueprint;
|
||||||
|
|
||||||
public TestSceneSliderSelectionBlueprint()
|
[SetUp]
|
||||||
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
var slider = new Slider
|
Clear();
|
||||||
|
|
||||||
|
slider = new Slider
|
||||||
{
|
{
|
||||||
Position = new Vector2(256, 192),
|
Position = new Vector2(256, 192),
|
||||||
Path = new SliderPath(PathType.Bezier, new[]
|
Path = new SliderPath(PathType.Bezier, new[]
|
||||||
@ -47,8 +54,71 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 });
|
slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 });
|
||||||
|
|
||||||
Add(drawableObject = new DrawableSlider(slider));
|
Add(drawableObject = new DrawableSlider(slider));
|
||||||
|
AddBlueprint(blueprint = new TestSliderBlueprint(drawableObject));
|
||||||
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestInitialState()
|
||||||
|
{
|
||||||
|
checkPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override SelectionBlueprint CreateBlueprint() => new SliderSelectionBlueprint(drawableObject);
|
[Test]
|
||||||
|
public void TestMoveHitObject()
|
||||||
|
{
|
||||||
|
moveHitObject();
|
||||||
|
checkPositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMoveAfterApplyingDefaults()
|
||||||
|
{
|
||||||
|
AddStep("apply defaults", () => slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 }));
|
||||||
|
moveHitObject();
|
||||||
|
checkPositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void moveHitObject()
|
||||||
|
{
|
||||||
|
AddStep("move hitobject", () =>
|
||||||
|
{
|
||||||
|
slider.Position = new Vector2(300, 225);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkPositions()
|
||||||
|
{
|
||||||
|
AddAssert("body positioned correctly", () => blueprint.BodyPiece.Position == slider.Position);
|
||||||
|
|
||||||
|
AddAssert("head positioned correctly",
|
||||||
|
() => Precision.AlmostEquals(blueprint.HeadBlueprint.CirclePiece.ScreenSpaceDrawQuad.Centre, drawableObject.HeadCircle.ScreenSpaceDrawQuad.Centre));
|
||||||
|
|
||||||
|
AddAssert("tail positioned correctly",
|
||||||
|
() => Precision.AlmostEquals(blueprint.TailBlueprint.CirclePiece.ScreenSpaceDrawQuad.Centre, drawableObject.TailCircle.ScreenSpaceDrawQuad.Centre));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestSliderBlueprint : SliderSelectionBlueprint
|
||||||
|
{
|
||||||
|
public new SliderBodyPiece BodyPiece => base.BodyPiece;
|
||||||
|
public new TestSliderCircleBlueprint HeadBlueprint => (TestSliderCircleBlueprint)base.HeadBlueprint;
|
||||||
|
public new TestSliderCircleBlueprint TailBlueprint => (TestSliderCircleBlueprint)base.TailBlueprint;
|
||||||
|
|
||||||
|
public TestSliderBlueprint(DrawableSlider slider)
|
||||||
|
: base(slider)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override SliderCircleSelectionBlueprint CreateCircleSelectionBlueprint(DrawableSlider slider, SliderPosition position) => new TestSliderCircleBlueprint(slider, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestSliderCircleBlueprint : SliderCircleSelectionBlueprint
|
||||||
|
{
|
||||||
|
public new HitCirclePiece CirclePiece => base.CirclePiece;
|
||||||
|
|
||||||
|
public TestSliderCircleBlueprint(DrawableSlider slider, SliderPosition position)
|
||||||
|
: base(slider, position)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Rulesets.Edit;
|
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners;
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
@ -25,8 +24,6 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
typeof(SpinnerPiece)
|
typeof(SpinnerPiece)
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly DrawableSpinner drawableSpinner;
|
|
||||||
|
|
||||||
public TestSceneSpinnerSelectionBlueprint()
|
public TestSceneSpinnerSelectionBlueprint()
|
||||||
{
|
{
|
||||||
var spinner = new Spinner
|
var spinner = new Spinner
|
||||||
@ -35,16 +32,19 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
StartTime = -1000,
|
StartTime = -1000,
|
||||||
EndTime = 2000
|
EndTime = 2000
|
||||||
};
|
};
|
||||||
|
|
||||||
spinner.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 });
|
spinner.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 });
|
||||||
|
|
||||||
|
DrawableSpinner drawableSpinner;
|
||||||
|
|
||||||
Add(new Container
|
Add(new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Size = new Vector2(0.5f),
|
Size = new Vector2(0.5f),
|
||||||
Child = drawableSpinner = new DrawableSpinner(spinner)
|
Child = drawableSpinner = new DrawableSpinner(spinner)
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
protected override SelectionBlueprint CreateBlueprint() => new SpinnerSelectionBlueprint(drawableSpinner) { Size = new Vector2(0.5f) };
|
AddBlueprint(new SpinnerSelectionBlueprint(drawableSpinner) { Size = new Vector2(0.5f) });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="Project References">
|
<ItemGroup Label="Project References">
|
||||||
<ProjectReference Include="..\osu.Game.Rulesets.Osu\osu.Game.Rulesets.Osu.csproj" />
|
<ProjectReference Include="..\osu.Game.Rulesets.Osu\osu.Game.Rulesets.Osu.csproj" />
|
||||||
|
25
osu.Game.Rulesets.Osu/Edit/Blueprints/BlueprintPiece.cs
Normal file
25
osu.Game.Rulesets.Osu/Edit/Blueprints/BlueprintPiece.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A piece of a selection or placement blueprint which visualises an <see cref="OsuHitObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type of <see cref="OsuHitObject"/> which this <see cref="BlueprintPiece{T}"/> visualises.</typeparam>
|
||||||
|
public abstract class BlueprintPiece<T> : CompositeDrawable
|
||||||
|
where T : OsuHitObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Updates this <see cref="BlueprintPiece{T}"/> using the properties of a <see cref="OsuHitObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hitObject">The <see cref="OsuHitObject"/> to reference properties from.</param>
|
||||||
|
public virtual void UpdateFrom(T hitObject)
|
||||||
|
{
|
||||||
|
Position = hitObject.Position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,18 +10,13 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components
|
||||||
{
|
{
|
||||||
public class HitCirclePiece : HitObjectPiece
|
public class HitCirclePiece : BlueprintPiece<HitCircle>
|
||||||
{
|
{
|
||||||
private readonly HitCircle hitCircle;
|
public HitCirclePiece()
|
||||||
|
|
||||||
public HitCirclePiece(HitCircle hitCircle)
|
|
||||||
: base(hitCircle)
|
|
||||||
{
|
{
|
||||||
this.hitCircle = hitCircle;
|
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
||||||
Scale = new Vector2(hitCircle.Scale);
|
|
||||||
CornerRadius = Size.X / 2;
|
CornerRadius = Size.X / 2;
|
||||||
|
|
||||||
InternalChild = new RingPiece();
|
InternalChild = new RingPiece();
|
||||||
@ -31,12 +26,13 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components
|
|||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
Colour = colours.Yellow;
|
Colour = colours.Yellow;
|
||||||
|
|
||||||
PositionBindable.BindValueChanged(_ => UpdatePosition(), true);
|
|
||||||
StackHeightBindable.BindValueChanged(_ => UpdatePosition());
|
|
||||||
ScaleBindable.BindValueChanged(scale => Scale = new Vector2(scale.NewValue), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void UpdatePosition() => Position = hitCircle.StackedPosition;
|
public override void UpdateFrom(HitCircle hitObject)
|
||||||
|
{
|
||||||
|
base.UpdateFrom(hitObject);
|
||||||
|
|
||||||
|
Scale = new Vector2(hitObject.Scale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,18 +13,19 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
|
|||||||
{
|
{
|
||||||
public new HitCircle HitObject => (HitCircle)base.HitObject;
|
public new HitCircle HitObject => (HitCircle)base.HitObject;
|
||||||
|
|
||||||
|
private readonly HitCirclePiece circlePiece;
|
||||||
|
|
||||||
public HitCirclePlacementBlueprint()
|
public HitCirclePlacementBlueprint()
|
||||||
: base(new HitCircle())
|
: base(new HitCircle())
|
||||||
{
|
{
|
||||||
InternalChild = new HitCirclePiece(HitObject);
|
InternalChild = circlePiece = new HitCirclePiece();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.Update();
|
||||||
|
|
||||||
// Fixes a 1-frame position discrepancy due to the first mouse move event happening in the next frame
|
circlePiece.UpdateFrom(HitObject);
|
||||||
HitObject.Position = Parent?.ToLocalSpace(GetContainingInputManager().CurrentState.Mouse.Position) ?? Vector2.Zero;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
@ -34,10 +35,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
public override void UpdatePosition(Vector2 screenSpacePosition)
|
||||||
{
|
{
|
||||||
HitObject.Position = e.MousePosition;
|
HitObject.Position = ToLocalSpace(screenSpacePosition);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,21 @@ using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
|
||||||
{
|
{
|
||||||
public class HitCircleSelectionBlueprint : OsuSelectionBlueprint
|
public class HitCircleSelectionBlueprint : OsuSelectionBlueprint<HitCircle>
|
||||||
{
|
{
|
||||||
|
protected readonly HitCirclePiece CirclePiece;
|
||||||
|
|
||||||
public HitCircleSelectionBlueprint(DrawableHitCircle hitCircle)
|
public HitCircleSelectionBlueprint(DrawableHitCircle hitCircle)
|
||||||
: base(hitCircle)
|
: base(hitCircle)
|
||||||
{
|
{
|
||||||
InternalChild = new HitCirclePiece((HitCircle)hitCircle.HitObject);
|
InternalChild = CirclePiece = new HitCirclePiece();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
CirclePiece.UpdateFrom(HitObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A piece of a blueprint which responds to changes in the state of a <see cref="OsuHitObject"/>.
|
|
||||||
/// </summary>
|
|
||||||
public abstract class HitObjectPiece : CompositeDrawable
|
|
||||||
{
|
|
||||||
protected readonly IBindable<Vector2> PositionBindable = new Bindable<Vector2>();
|
|
||||||
protected readonly IBindable<int> StackHeightBindable = new Bindable<int>();
|
|
||||||
protected readonly IBindable<float> ScaleBindable = new Bindable<float>();
|
|
||||||
|
|
||||||
private readonly OsuHitObject hitObject;
|
|
||||||
|
|
||||||
protected HitObjectPiece(OsuHitObject hitObject)
|
|
||||||
{
|
|
||||||
this.hitObject = hitObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
PositionBindable.BindTo(hitObject.PositionBindable);
|
|
||||||
StackHeightBindable.BindTo(hitObject.StackHeightBindable);
|
|
||||||
ScaleBindable.BindTo(hitObject.ScaleBindable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,11 +7,12 @@ using osu.Game.Rulesets.Osu.Objects;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints
|
||||||
{
|
{
|
||||||
public class OsuSelectionBlueprint : SelectionBlueprint
|
public abstract class OsuSelectionBlueprint<T> : SelectionBlueprint
|
||||||
|
where T : OsuHitObject
|
||||||
{
|
{
|
||||||
protected OsuHitObject OsuObject => (OsuHitObject)HitObject.HitObject;
|
protected new T HitObject => (T)base.HitObject.HitObject;
|
||||||
|
|
||||||
public OsuSelectionBlueprint(DrawableHitObject hitObject)
|
protected OsuSelectionBlueprint(DrawableHitObject hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A piece of a blueprint which responds to changes in the state of a <see cref="Slider"/>.
|
|
||||||
/// </summary>
|
|
||||||
public abstract class SliderPiece : HitObjectPiece
|
|
||||||
{
|
|
||||||
protected readonly IBindable<SliderPath> PathBindable = new Bindable<SliderPath>();
|
|
||||||
|
|
||||||
private readonly Slider slider;
|
|
||||||
|
|
||||||
protected SliderPiece(Slider slider)
|
|
||||||
: base(slider)
|
|
||||||
{
|
|
||||||
this.slider = slider;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
PathBindable.BindTo(slider.PathBindable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,7 +14,7 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||||
{
|
{
|
||||||
public class PathControlPointPiece : CompositeDrawable
|
public class PathControlPointPiece : BlueprintPiece<Slider>
|
||||||
{
|
{
|
||||||
private readonly Slider slider;
|
private readonly Slider slider;
|
||||||
private readonly int index;
|
private readonly int index;
|
||||||
|
@ -1,35 +1,29 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||||
{
|
{
|
||||||
public class PathControlPointVisualiser : SliderPiece
|
public class PathControlPointVisualiser : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly Slider slider;
|
private readonly Slider slider;
|
||||||
|
|
||||||
private readonly Container<PathControlPointPiece> pieces;
|
private readonly Container<PathControlPointPiece> pieces;
|
||||||
|
|
||||||
public PathControlPointVisualiser(Slider slider)
|
public PathControlPointVisualiser(Slider slider)
|
||||||
: base(slider)
|
|
||||||
{
|
{
|
||||||
this.slider = slider;
|
this.slider = slider;
|
||||||
|
|
||||||
InternalChild = pieces = new Container<PathControlPointPiece> { RelativeSizeAxes = Axes.Both };
|
InternalChild = pieces = new Container<PathControlPointPiece> { RelativeSizeAxes = Axes.Both };
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
protected override void Update()
|
||||||
private void load()
|
|
||||||
{
|
{
|
||||||
PathBindable.BindValueChanged(_ => updatePathControlPoints(), true);
|
base.Update();
|
||||||
}
|
|
||||||
|
|
||||||
private void updatePathControlPoints()
|
|
||||||
{
|
|
||||||
while (slider.Path.ControlPoints.Length > pieces.Count)
|
while (slider.Path.ControlPoints.Length > pieces.Count)
|
||||||
pieces.Add(new PathControlPointPiece(slider, pieces.Count));
|
pieces.Add(new PathControlPointPiece(slider, pieces.Count));
|
||||||
while (slider.Path.ControlPoints.Length < pieces.Count)
|
while (slider.Path.ControlPoints.Length < pieces.Count)
|
||||||
|
@ -11,19 +11,15 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||||
{
|
{
|
||||||
public class SliderBodyPiece : SliderPiece
|
public class SliderBodyPiece : BlueprintPiece<Slider>
|
||||||
{
|
{
|
||||||
private readonly Slider slider;
|
|
||||||
private readonly ManualSliderBody body;
|
private readonly ManualSliderBody body;
|
||||||
|
|
||||||
public SliderBodyPiece(Slider slider)
|
public SliderBodyPiece()
|
||||||
: base(slider)
|
|
||||||
{
|
{
|
||||||
this.slider = slider;
|
|
||||||
|
|
||||||
InternalChild = body = new ManualSliderBody
|
InternalChild = body = new ManualSliderBody
|
||||||
{
|
{
|
||||||
AccentColour = Color4.Transparent,
|
AccentColour = Color4.Transparent
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,19 +27,16 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
body.BorderColour = colours.Yellow;
|
body.BorderColour = colours.Yellow;
|
||||||
|
|
||||||
PositionBindable.BindValueChanged(_ => updatePosition(), true);
|
|
||||||
ScaleBindable.BindValueChanged(scale => body.PathRadius = scale.NewValue * OsuHitObject.OBJECT_RADIUS, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePosition() => Position = slider.StackedPosition;
|
public override void UpdateFrom(Slider hitObject)
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
{
|
||||||
base.Update();
|
base.UpdateFrom(hitObject);
|
||||||
|
|
||||||
|
body.PathRadius = hitObject.Scale * OsuHitObject.OBJECT_RADIUS;
|
||||||
|
|
||||||
var vertices = new List<Vector2>();
|
var vertices = new List<Vector2>();
|
||||||
slider.Path.GetPathToProgress(vertices, 0, 1);
|
hitObject.Path.GetPathToProgress(vertices, 0, 1);
|
||||||
|
|
||||||
body.SetVertices(vertices);
|
body.SetVertices(vertices);
|
||||||
|
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
|
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|
||||||
{
|
|
||||||
public class SliderCirclePiece : HitCirclePiece
|
|
||||||
{
|
|
||||||
private readonly IBindable<SliderPath> pathBindable = new Bindable<SliderPath>();
|
|
||||||
|
|
||||||
private readonly Slider slider;
|
|
||||||
private readonly SliderPosition position;
|
|
||||||
|
|
||||||
public SliderCirclePiece(Slider slider, SliderPosition position)
|
|
||||||
: base(slider.HeadCircle)
|
|
||||||
{
|
|
||||||
this.slider = slider;
|
|
||||||
this.position = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
pathBindable.BindTo(slider.PathBindable);
|
|
||||||
pathBindable.BindValueChanged(_ => UpdatePosition(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdatePosition()
|
|
||||||
{
|
|
||||||
switch (position)
|
|
||||||
{
|
|
||||||
case SliderPosition.Start:
|
|
||||||
Position = slider.StackedPosition + slider.Path.PositionAt(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SliderPosition.End:
|
|
||||||
Position = slider.StackedPosition + slider.Path.PositionAt(1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +1,34 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||||
{
|
{
|
||||||
public class SliderCircleSelectionBlueprint : OsuSelectionBlueprint
|
public class SliderCircleSelectionBlueprint : OsuSelectionBlueprint<Slider>
|
||||||
{
|
{
|
||||||
public SliderCircleSelectionBlueprint(DrawableOsuHitObject hitObject, Slider slider, SliderPosition position)
|
protected readonly HitCirclePiece CirclePiece;
|
||||||
: base(hitObject)
|
|
||||||
|
private readonly SliderPosition position;
|
||||||
|
|
||||||
|
public SliderCircleSelectionBlueprint(DrawableSlider slider, SliderPosition position)
|
||||||
|
: base(slider)
|
||||||
{
|
{
|
||||||
InternalChild = new SliderCirclePiece(slider, position);
|
this.position = position;
|
||||||
|
InternalChild = CirclePiece = new HitCirclePiece();
|
||||||
|
|
||||||
Select();
|
Select();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
CirclePiece.UpdateFrom(position == SliderPosition.Start ? HitObject.HeadCircle : HitObject.TailCircle);
|
||||||
|
}
|
||||||
|
|
||||||
// Todo: This is temporary, since the slider circle masks don't do anything special yet. In the future they will handle input.
|
// Todo: This is temporary, since the slider circle masks don't do anything special yet. In the future they will handle input.
|
||||||
public override bool HandlePositionalInput => false;
|
public override bool HandlePositionalInput => false;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ using osu.Game.Graphics;
|
|||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -21,6 +22,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
{
|
{
|
||||||
public new Objects.Slider HitObject => (Objects.Slider)base.HitObject;
|
public new Objects.Slider HitObject => (Objects.Slider)base.HitObject;
|
||||||
|
|
||||||
|
private SliderBodyPiece bodyPiece;
|
||||||
|
private HitCirclePiece headCirclePiece;
|
||||||
|
private HitCirclePiece tailCirclePiece;
|
||||||
|
|
||||||
private readonly List<Segment> segments = new List<Segment>();
|
private readonly List<Segment> segments = new List<Segment>();
|
||||||
private Vector2 cursor;
|
private Vector2 cursor;
|
||||||
|
|
||||||
@ -38,37 +43,27 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
{
|
{
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new SliderBodyPiece(HitObject),
|
bodyPiece = new SliderBodyPiece(),
|
||||||
new SliderCirclePiece(HitObject, SliderPosition.Start),
|
headCirclePiece = new HitCirclePiece(),
|
||||||
new SliderCirclePiece(HitObject, SliderPosition.End),
|
tailCirclePiece = new HitCirclePiece(),
|
||||||
new PathControlPointVisualiser(HitObject),
|
new PathControlPointVisualiser(HitObject),
|
||||||
};
|
};
|
||||||
|
|
||||||
setState(PlacementState.Initial);
|
setState(PlacementState.Initial);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
public override void UpdatePosition(Vector2 screenSpacePosition)
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
// Fixes a 1-frame position discrepancy due to the first mouse move event happening in the next frame
|
|
||||||
HitObject.Position = Parent?.ToLocalSpace(GetContainingInputManager().CurrentState.Mouse.Position) ?? Vector2.Zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case PlacementState.Initial:
|
case PlacementState.Initial:
|
||||||
HitObject.Position = e.MousePosition;
|
HitObject.Position = ToLocalSpace(screenSpacePosition);
|
||||||
return true;
|
break;
|
||||||
|
|
||||||
case PlacementState.Body:
|
case PlacementState.Body:
|
||||||
cursor = e.MousePosition - HitObject.Position;
|
cursor = ToLocalSpace(screenSpacePosition) - HitObject.Position;
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
@ -130,6 +125,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
{
|
{
|
||||||
var newControlPoints = segments.SelectMany(s => s.ControlPoints).Concat(cursor.Yield()).ToArray();
|
var newControlPoints = segments.SelectMany(s => s.ControlPoints).Concat(cursor.Yield()).ToArray();
|
||||||
HitObject.Path = new SliderPath(newControlPoints.Length > 2 ? PathType.Bezier : PathType.Linear, newControlPoints);
|
HitObject.Path = new SliderPath(newControlPoints.Length > 2 ? PathType.Bezier : PathType.Linear, newControlPoints);
|
||||||
|
|
||||||
|
bodyPiece.UpdateFrom(HitObject);
|
||||||
|
headCirclePiece.UpdateFrom(HitObject.HeadCircle);
|
||||||
|
tailCirclePiece.UpdateFrom(HitObject.TailCircle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setState(PlacementState newState)
|
private void setState(PlacementState newState)
|
||||||
|
@ -9,9 +9,11 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||||
{
|
{
|
||||||
public class SliderSelectionBlueprint : OsuSelectionBlueprint
|
public class SliderSelectionBlueprint : OsuSelectionBlueprint<Slider>
|
||||||
{
|
{
|
||||||
private readonly SliderCircleSelectionBlueprint headBlueprint;
|
protected readonly SliderBodyPiece BodyPiece;
|
||||||
|
protected readonly SliderCircleSelectionBlueprint HeadBlueprint;
|
||||||
|
protected readonly SliderCircleSelectionBlueprint TailBlueprint;
|
||||||
|
|
||||||
public SliderSelectionBlueprint(DrawableSlider slider)
|
public SliderSelectionBlueprint(DrawableSlider slider)
|
||||||
: base(slider)
|
: base(slider)
|
||||||
@ -20,13 +22,22 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new SliderBodyPiece(sliderObject),
|
BodyPiece = new SliderBodyPiece(),
|
||||||
headBlueprint = new SliderCircleSelectionBlueprint(slider.HeadCircle, sliderObject, SliderPosition.Start),
|
HeadBlueprint = CreateCircleSelectionBlueprint(slider, SliderPosition.Start),
|
||||||
new SliderCircleSelectionBlueprint(slider.TailCircle, sliderObject, SliderPosition.End),
|
TailBlueprint = CreateCircleSelectionBlueprint(slider, SliderPosition.End),
|
||||||
new PathControlPointVisualiser(sliderObject),
|
new PathControlPointVisualiser(sliderObject),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Vector2 SelectionPoint => headBlueprint.SelectionPoint;
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
BodyPiece.UpdateFrom(HitObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Vector2 SelectionPoint => HeadBlueprint.SelectionPoint;
|
||||||
|
|
||||||
|
protected virtual SliderCircleSelectionBlueprint CreateCircleSelectionBlueprint(DrawableSlider slider, SliderPosition position) => new SliderCircleSelectionBlueprint(slider, position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,17 +12,13 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components
|
||||||
{
|
{
|
||||||
public class SpinnerPiece : HitObjectPiece
|
public class SpinnerPiece : BlueprintPiece<Spinner>
|
||||||
{
|
{
|
||||||
private readonly Spinner spinner;
|
|
||||||
private readonly CircularContainer circle;
|
private readonly CircularContainer circle;
|
||||||
private readonly RingPiece ring;
|
private readonly RingPiece ring;
|
||||||
|
|
||||||
public SpinnerPiece(Spinner spinner)
|
public SpinnerPiece()
|
||||||
: base(spinner)
|
|
||||||
{
|
{
|
||||||
this.spinner = spinner;
|
|
||||||
|
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
@ -44,21 +40,20 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components
|
|||||||
Origin = Anchor.Centre
|
Origin = Anchor.Centre
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ring.Scale = new Vector2(spinner.Scale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
Colour = colours.Yellow;
|
Colour = colours.Yellow;
|
||||||
|
|
||||||
PositionBindable.BindValueChanged(_ => updatePosition(), true);
|
|
||||||
StackHeightBindable.BindValueChanged(_ => updatePosition());
|
|
||||||
ScaleBindable.BindValueChanged(scale => ring.Scale = new Vector2(scale.NewValue), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePosition() => Position = spinner.Position;
|
public override void UpdateFrom(Spinner hitObject)
|
||||||
|
{
|
||||||
|
base.UpdateFrom(hitObject);
|
||||||
|
|
||||||
|
ring.Scale = new Vector2(hitObject.Scale);
|
||||||
|
}
|
||||||
|
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => circle.ReceivePositionalInputAt(screenSpacePos);
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => circle.ReceivePositionalInputAt(screenSpacePos);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using osu.Game.Rulesets.Edit;
|
|||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Osu.UI;
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
|
||||||
{
|
{
|
||||||
@ -21,7 +22,14 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
|
|||||||
public SpinnerPlacementBlueprint()
|
public SpinnerPlacementBlueprint()
|
||||||
: base(new Spinner { Position = OsuPlayfield.BASE_SIZE / 2 })
|
: base(new Spinner { Position = OsuPlayfield.BASE_SIZE / 2 })
|
||||||
{
|
{
|
||||||
InternalChild = piece = new SpinnerPiece(HitObject) { Alpha = 0.5f };
|
InternalChild = piece = new SpinnerPiece { Alpha = 0.5f };
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
piece.UpdateFrom(HitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
@ -43,5 +51,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void UpdatePosition(Vector2 screenSpacePosition)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,21 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
|
||||||
{
|
{
|
||||||
public class SpinnerSelectionBlueprint : OsuSelectionBlueprint
|
public class SpinnerSelectionBlueprint : OsuSelectionBlueprint<Spinner>
|
||||||
{
|
{
|
||||||
private readonly SpinnerPiece piece;
|
private readonly SpinnerPiece piece;
|
||||||
|
|
||||||
public SpinnerSelectionBlueprint(DrawableSpinner spinner)
|
public SpinnerSelectionBlueprint(DrawableSpinner spinner)
|
||||||
: base(spinner)
|
: base(spinner)
|
||||||
{
|
{
|
||||||
InternalChild = piece = new SpinnerPiece((Spinner)spinner.HitObject);
|
InternalChild = piece = new SpinnerPiece();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
piece.UpdateFrom(HitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => piece.ReceivePositionalInputAt(screenSpacePos);
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => piece.ReceivePositionalInputAt(screenSpacePos);
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Input.Events;
|
|
||||||
using osu.Game.Rulesets.Edit;
|
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
|
|
||||||
@ -11,7 +9,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
{
|
{
|
||||||
public class OsuSelectionHandler : SelectionHandler
|
public class OsuSelectionHandler : SelectionHandler
|
||||||
{
|
{
|
||||||
public override void HandleDrag(SelectionBlueprint blueprint, DragEvent dragEvent)
|
public override void HandleMovement(MoveSelectionEvent moveEvent)
|
||||||
{
|
{
|
||||||
foreach (var h in SelectedHitObjects.OfType<OsuHitObject>())
|
foreach (var h in SelectedHitObjects.OfType<OsuHitObject>())
|
||||||
{
|
{
|
||||||
@ -21,10 +19,10 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
h.Position += dragEvent.Delta;
|
h.Position += moveEvent.InstantDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.HandleDrag(blueprint, dragEvent);
|
base.HandleMovement(moveEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
positionBindable.BindValueChanged(_ => updatePosition());
|
positionBindable.BindValueChanged(_ => updatePosition());
|
||||||
pathBindable.BindValueChanged(_ => updatePosition(), true);
|
pathBindable.BindValueChanged(_ => updatePosition(), true);
|
||||||
|
|
||||||
|
// TODO: This has no drawable content. Support for skins should be added.
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||||
|
@ -30,6 +30,6 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
|
|
||||||
public override Judgement CreateJudgement() => new OsuJudgement();
|
public override Judgement CreateJudgement() => new OsuJudgement();
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => null;
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,13 +54,13 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
{
|
{
|
||||||
base.Position = value;
|
base.Position = value;
|
||||||
|
|
||||||
|
endPositionCache.Invalidate();
|
||||||
|
|
||||||
if (HeadCircle != null)
|
if (HeadCircle != null)
|
||||||
HeadCircle.Position = value;
|
HeadCircle.Position = value;
|
||||||
|
|
||||||
if (TailCircle != null)
|
if (TailCircle != null)
|
||||||
TailCircle.Position = EndPosition;
|
TailCircle.Position = EndPosition;
|
||||||
|
|
||||||
endPositionCache.Invalidate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,6 +205,6 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
|
|
||||||
public override Judgement CreateJudgement() => new OsuJudgement();
|
public override Judgement CreateJudgement() => new OsuJudgement();
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => null;
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,6 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
|
|
||||||
public override Judgement CreateJudgement() => new OsuSliderTailJudgement();
|
public override Judgement CreateJudgement() => new OsuSliderTailJudgement();
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => null;
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,6 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
|
|
||||||
public override Judgement CreateJudgement() => new OsuJudgement();
|
public override Judgement CreateJudgement() => new OsuJudgement();
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => null;
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,6 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
|
|
||||||
public override Judgement CreateJudgement() => new OsuJudgement();
|
public override Judgement CreateJudgement() => new OsuJudgement();
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => null;
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,11 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
private void load(OsuRulesetConfigManager config)
|
private void load(OsuRulesetConfigManager config)
|
||||||
{
|
{
|
||||||
config?.BindWith(OsuRulesetSetting.ShowCursorTrail, showTrail);
|
config?.BindWith(OsuRulesetSetting.ShowCursorTrail, showTrail);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
showTrail.BindValueChanged(v => cursorTrail.FadeTo(v.NewValue ? 1 : 0, 200), true);
|
showTrail.BindValueChanged(v => cursorTrail.FadeTo(v.NewValue ? 1 : 0, 200), true);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Taiko.Tests.dll"
|
"${workspaceRoot}/bin/Debug/netcoreapp3.0/osu.Game.Rulesets.Taiko.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Debug)",
|
"preLaunchTask": "Build (Debug)",
|
||||||
@ -20,7 +20,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Release/netcoreapp2.2/osu.Game.Rulesets.Taiko.Tests.dll"
|
"${workspaceRoot}/bin/Release/netcoreapp3.0/osu.Game.Rulesets.Taiko.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Release)",
|
"preLaunchTask": "Build (Release)",
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="Project References">
|
<ItemGroup Label="Project References">
|
||||||
<ProjectReference Include="..\osu.Game.Rulesets.Taiko\osu.Game.Rulesets.Taiko.csproj" />
|
<ProjectReference Include="..\osu.Game.Rulesets.Taiko\osu.Game.Rulesets.Taiko.csproj" />
|
||||||
|
@ -88,6 +88,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
|
|
||||||
public override Judgement CreateJudgement() => new TaikoDrumRollJudgement();
|
public override Judgement CreateJudgement() => new TaikoDrumRollJudgement();
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => null;
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
|
|
||||||
public override Judgement CreateJudgement() => new TaikoDrumRollTickJudgement();
|
public override Judgement CreateJudgement() => new TaikoDrumRollTickJudgement();
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => null;
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
{
|
{
|
||||||
public override Judgement CreateJudgement() => new TaikoStrongJudgement();
|
public override Judgement CreateJudgement() => new TaikoStrongJudgement();
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => null;
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
|
|
||||||
public override Judgement CreateJudgement() => new TaikoSwellJudgement();
|
public override Judgement CreateJudgement() => new TaikoSwellJudgement();
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => null;
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
{
|
{
|
||||||
public override Judgement CreateJudgement() => new TaikoSwellTickJudgement();
|
public override Judgement CreateJudgement() => new TaikoSwellTickJudgement();
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => null;
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
154
osu.Game.Tests/Beatmaps/EditorBeatmapTest.cs
Normal file
154
osu.Game.Tests/Beatmaps/EditorBeatmapTest.cs
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
// 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 Microsoft.EntityFrameworkCore.Internal;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Screens.Edit;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Beatmaps
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class EditorBeatmapTest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Tests that the addition event is correctly invoked after a hitobject is added.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestHitObjectAddEvent()
|
||||||
|
{
|
||||||
|
var editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
||||||
|
|
||||||
|
HitObject addedObject = null;
|
||||||
|
editorBeatmap.HitObjectAdded += h => addedObject = h;
|
||||||
|
|
||||||
|
var hitCircle = new HitCircle();
|
||||||
|
|
||||||
|
editorBeatmap.Add(hitCircle);
|
||||||
|
Assert.That(addedObject, Is.EqualTo(hitCircle));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests that the removal event is correctly invoked after a hitobject is removed.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void HitObjectRemoveEvent()
|
||||||
|
{
|
||||||
|
var hitCircle = new HitCircle();
|
||||||
|
var editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap { HitObjects = { hitCircle } });
|
||||||
|
|
||||||
|
HitObject removedObject = null;
|
||||||
|
editorBeatmap.HitObjectRemoved += h => removedObject = h;
|
||||||
|
|
||||||
|
editorBeatmap.Remove(hitCircle);
|
||||||
|
Assert.That(removedObject, Is.EqualTo(hitCircle));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests that the changed event is correctly invoked after the start time of a hitobject is changed.
|
||||||
|
/// This tests for hitobjects which were already present before the editor beatmap was constructed.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestInitialHitObjectStartTimeChangeEvent()
|
||||||
|
{
|
||||||
|
var hitCircle = new HitCircle();
|
||||||
|
var editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap { HitObjects = { hitCircle } });
|
||||||
|
|
||||||
|
HitObject changedObject = null;
|
||||||
|
editorBeatmap.StartTimeChanged += h => changedObject = h;
|
||||||
|
|
||||||
|
hitCircle.StartTime = 1000;
|
||||||
|
Assert.That(changedObject, Is.EqualTo(hitCircle));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests that the changed event is correctly invoked after the start time of a hitobject is changed.
|
||||||
|
/// This tests for hitobjects which were added to an existing editor beatmap.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestAddedHitObjectStartTimeChangeEvent()
|
||||||
|
{
|
||||||
|
var editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
||||||
|
|
||||||
|
HitObject changedObject = null;
|
||||||
|
editorBeatmap.StartTimeChanged += h => changedObject = h;
|
||||||
|
|
||||||
|
var hitCircle = new HitCircle();
|
||||||
|
|
||||||
|
editorBeatmap.Add(hitCircle);
|
||||||
|
Assert.That(changedObject, Is.Null);
|
||||||
|
|
||||||
|
hitCircle.StartTime = 1000;
|
||||||
|
Assert.That(changedObject, Is.EqualTo(hitCircle));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests that the channged event is not invoked after a hitobject is removed from the beatmap/
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestRemovedHitObjectStartTimeChangeEvent()
|
||||||
|
{
|
||||||
|
var hitCircle = new HitCircle();
|
||||||
|
var editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap { HitObjects = { hitCircle } });
|
||||||
|
|
||||||
|
HitObject changedObject = null;
|
||||||
|
editorBeatmap.StartTimeChanged += h => changedObject = h;
|
||||||
|
|
||||||
|
editorBeatmap.Remove(hitCircle);
|
||||||
|
Assert.That(changedObject, Is.Null);
|
||||||
|
|
||||||
|
hitCircle.StartTime = 1000;
|
||||||
|
Assert.That(changedObject, Is.Null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests that an added hitobject is correctly inserted to preserve the sorting order of the beatmap.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestAddHitObjectInMiddle()
|
||||||
|
{
|
||||||
|
var editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap
|
||||||
|
{
|
||||||
|
HitObjects =
|
||||||
|
{
|
||||||
|
new HitCircle(),
|
||||||
|
new HitCircle { StartTime = 1000 },
|
||||||
|
new HitCircle { StartTime = 1000 },
|
||||||
|
new HitCircle { StartTime = 2000 },
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var hitCircle = new HitCircle { StartTime = 1000 };
|
||||||
|
editorBeatmap.Add(hitCircle);
|
||||||
|
Assert.That(editorBeatmap.HitObjects.Count(h => h == hitCircle), Is.EqualTo(1));
|
||||||
|
Assert.That(editorBeatmap.HitObjects.IndexOf(hitCircle), Is.EqualTo(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests that the beatmap remains correctly sorted after the start time of a hitobject is changed.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestResortWhenStartTimeChanged()
|
||||||
|
{
|
||||||
|
var hitCircle = new HitCircle { StartTime = 1000 };
|
||||||
|
var editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap
|
||||||
|
{
|
||||||
|
HitObjects =
|
||||||
|
{
|
||||||
|
new HitCircle(),
|
||||||
|
new HitCircle { StartTime = 1000 },
|
||||||
|
new HitCircle { StartTime = 1000 },
|
||||||
|
hitCircle,
|
||||||
|
new HitCircle { StartTime = 2000 },
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
hitCircle.StartTime = 0;
|
||||||
|
Assert.That(editorBeatmap.HitObjects.Count(h => h == hitCircle), Is.EqualTo(1));
|
||||||
|
Assert.That(editorBeatmap.HitObjects.IndexOf(hitCircle), Is.EqualTo(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
|
using osu.Game.IO;
|
||||||
using osu.Game.Rulesets.Catch.Beatmaps;
|
using osu.Game.Rulesets.Catch.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
@ -30,13 +31,9 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
public void TestDecodeBeatmapVersion()
|
public void TestDecodeBeatmapVersion()
|
||||||
{
|
{
|
||||||
using (var resStream = TestResources.OpenResource("beatmap-version.osu"))
|
using (var resStream = TestResources.OpenResource("beatmap-version.osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var decoder = Decoder.GetDecoder<Beatmap>(stream);
|
var decoder = Decoder.GetDecoder<Beatmap>(stream);
|
||||||
|
|
||||||
stream.BaseStream.Position = 0;
|
|
||||||
stream.DiscardBufferedData();
|
|
||||||
|
|
||||||
var working = new TestWorkingBeatmap(decoder.Decode(stream));
|
var working = new TestWorkingBeatmap(decoder.Decode(stream));
|
||||||
|
|
||||||
Assert.AreEqual(6, working.BeatmapInfo.BeatmapVersion);
|
Assert.AreEqual(6, working.BeatmapInfo.BeatmapVersion);
|
||||||
@ -51,7 +48,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var beatmap = decoder.Decode(stream);
|
var beatmap = decoder.Decode(stream);
|
||||||
var beatmapInfo = beatmap.BeatmapInfo;
|
var beatmapInfo = beatmap.BeatmapInfo;
|
||||||
@ -75,7 +72,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder();
|
var decoder = new LegacyBeatmapDecoder();
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var beatmapInfo = decoder.Decode(stream).BeatmapInfo;
|
var beatmapInfo = decoder.Decode(stream).BeatmapInfo;
|
||||||
|
|
||||||
@ -101,7 +98,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder();
|
var decoder = new LegacyBeatmapDecoder();
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var beatmap = decoder.Decode(stream);
|
var beatmap = decoder.Decode(stream);
|
||||||
var beatmapInfo = beatmap.BeatmapInfo;
|
var beatmapInfo = beatmap.BeatmapInfo;
|
||||||
@ -126,7 +123,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder();
|
var decoder = new LegacyBeatmapDecoder();
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var difficulty = decoder.Decode(stream).BeatmapInfo.BaseDifficulty;
|
var difficulty = decoder.Decode(stream).BeatmapInfo.BaseDifficulty;
|
||||||
|
|
||||||
@ -145,7 +142,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var beatmap = decoder.Decode(stream);
|
var beatmap = decoder.Decode(stream);
|
||||||
var metadata = beatmap.Metadata;
|
var metadata = beatmap.Metadata;
|
||||||
@ -164,7 +161,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var beatmap = decoder.Decode(stream);
|
var beatmap = decoder.Decode(stream);
|
||||||
var controlPoints = beatmap.ControlPointInfo;
|
var controlPoints = beatmap.ControlPointInfo;
|
||||||
@ -239,7 +236,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("overlapping-control-points.osu"))
|
using (var resStream = TestResources.OpenResource("overlapping-control-points.osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var controlPoints = decoder.Decode(stream).ControlPointInfo;
|
var controlPoints = decoder.Decode(stream).ControlPointInfo;
|
||||||
|
|
||||||
@ -271,7 +268,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacySkinDecoder();
|
var decoder = new LegacySkinDecoder();
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var comboColors = decoder.Decode(stream).ComboColours;
|
var comboColors = decoder.Decode(stream).ComboColours;
|
||||||
|
|
||||||
@ -297,7 +294,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder();
|
var decoder = new LegacyBeatmapDecoder();
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("hitobject-combo-offset.osu"))
|
using (var resStream = TestResources.OpenResource("hitobject-combo-offset.osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var beatmap = decoder.Decode(stream);
|
var beatmap = decoder.Decode(stream);
|
||||||
|
|
||||||
@ -320,7 +317,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder();
|
var decoder = new LegacyBeatmapDecoder();
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("hitobject-combo-offset.osu"))
|
using (var resStream = TestResources.OpenResource("hitobject-combo-offset.osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var beatmap = decoder.Decode(stream);
|
var beatmap = decoder.Decode(stream);
|
||||||
|
|
||||||
@ -343,7 +340,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var hitObjects = decoder.Decode(stream).HitObjects;
|
var hitObjects = decoder.Decode(stream).HitObjects;
|
||||||
|
|
||||||
@ -371,7 +368,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("controlpoint-custom-samplebank.osu"))
|
using (var resStream = TestResources.OpenResource("controlpoint-custom-samplebank.osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var hitObjects = decoder.Decode(stream).HitObjects;
|
var hitObjects = decoder.Decode(stream).HitObjects;
|
||||||
|
|
||||||
@ -393,7 +390,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("hitobject-custom-samplebank.osu"))
|
using (var resStream = TestResources.OpenResource("hitobject-custom-samplebank.osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var hitObjects = decoder.Decode(stream).HitObjects;
|
var hitObjects = decoder.Decode(stream).HitObjects;
|
||||||
|
|
||||||
@ -411,7 +408,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("hitobject-file-samples.osu"))
|
using (var resStream = TestResources.OpenResource("hitobject-file-samples.osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var hitObjects = decoder.Decode(stream).HitObjects;
|
var hitObjects = decoder.Decode(stream).HitObjects;
|
||||||
|
|
||||||
@ -431,7 +428,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("slider-samples.osu"))
|
using (var resStream = TestResources.OpenResource("slider-samples.osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var hitObjects = decoder.Decode(stream).HitObjects;
|
var hitObjects = decoder.Decode(stream).HitObjects;
|
||||||
|
|
||||||
@ -475,7 +472,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("hitobject-no-addition-bank.osu"))
|
using (var resStream = TestResources.OpenResource("hitobject-no-addition-bank.osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var hitObjects = decoder.Decode(stream).HitObjects;
|
var hitObjects = decoder.Decode(stream).HitObjects;
|
||||||
|
|
||||||
@ -489,10 +486,132 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
using (var badResStream = TestResources.OpenResource("invalid-events.osu"))
|
using (var badResStream = TestResources.OpenResource("invalid-events.osu"))
|
||||||
using (var badStream = new StreamReader(badResStream))
|
using (var badStream = new LineBufferedReader(badResStream))
|
||||||
{
|
{
|
||||||
Assert.DoesNotThrow(() => decoder.Decode(badStream));
|
Assert.DoesNotThrow(() => decoder.Decode(badStream));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFallbackDecoderForCorruptedHeader()
|
||||||
|
{
|
||||||
|
Decoder<Beatmap> decoder = null;
|
||||||
|
Beatmap beatmap = null;
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("corrupted-header.osu"))
|
||||||
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
|
{
|
||||||
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
||||||
|
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
|
||||||
|
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
|
||||||
|
Assert.IsNotNull(beatmap);
|
||||||
|
Assert.AreEqual("Beatmap with corrupted header", beatmap.Metadata.Title);
|
||||||
|
Assert.AreEqual("Evil Hacker", beatmap.Metadata.AuthorString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFallbackDecoderForMissingHeader()
|
||||||
|
{
|
||||||
|
Decoder<Beatmap> decoder = null;
|
||||||
|
Beatmap beatmap = null;
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("missing-header.osu"))
|
||||||
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
|
{
|
||||||
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
||||||
|
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
|
||||||
|
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
|
||||||
|
Assert.IsNotNull(beatmap);
|
||||||
|
Assert.AreEqual("Beatmap with no header", beatmap.Metadata.Title);
|
||||||
|
Assert.AreEqual("Incredibly Evil Hacker", beatmap.Metadata.AuthorString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDecodeFileWithEmptyLinesAtStart()
|
||||||
|
{
|
||||||
|
Decoder<Beatmap> decoder = null;
|
||||||
|
Beatmap beatmap = null;
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("empty-lines-at-start.osu"))
|
||||||
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
|
{
|
||||||
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
||||||
|
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
|
||||||
|
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
|
||||||
|
Assert.IsNotNull(beatmap);
|
||||||
|
Assert.AreEqual("Empty lines at start", beatmap.Metadata.Title);
|
||||||
|
Assert.AreEqual("Edge Case Hunter", beatmap.Metadata.AuthorString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDecodeFileWithEmptyLinesAndNoHeader()
|
||||||
|
{
|
||||||
|
Decoder<Beatmap> decoder = null;
|
||||||
|
Beatmap beatmap = null;
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("empty-line-instead-of-header.osu"))
|
||||||
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
|
{
|
||||||
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
||||||
|
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
|
||||||
|
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
|
||||||
|
Assert.IsNotNull(beatmap);
|
||||||
|
Assert.AreEqual("The dog ate the file header", beatmap.Metadata.Title);
|
||||||
|
Assert.AreEqual("Why does this keep happening", beatmap.Metadata.AuthorString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDecodeFileWithContentImmediatelyAfterHeader()
|
||||||
|
{
|
||||||
|
Decoder<Beatmap> decoder = null;
|
||||||
|
Beatmap beatmap = null;
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("no-empty-line-after-header.osu"))
|
||||||
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
|
{
|
||||||
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
||||||
|
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
|
||||||
|
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
|
||||||
|
Assert.IsNotNull(beatmap);
|
||||||
|
Assert.AreEqual("No empty line delimiting header from contents", beatmap.Metadata.Title);
|
||||||
|
Assert.AreEqual("Edge Case Hunter", beatmap.Metadata.AuthorString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDecodeEmptyFile()
|
||||||
|
{
|
||||||
|
using (var resStream = new MemoryStream())
|
||||||
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
|
{
|
||||||
|
Assert.Throws<IOException>(() => Decoder.GetDecoder<Beatmap>(stream));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAllowFallbackDecoderOverwrite()
|
||||||
|
{
|
||||||
|
Decoder<Beatmap> decoder = null;
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("corrupted-header.osu"))
|
||||||
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
|
{
|
||||||
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
||||||
|
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.DoesNotThrow(LegacyDifficultyCalculatorBeatmapDecoder.Register);
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("corrupted-header.osu"))
|
||||||
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
|
{
|
||||||
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
||||||
|
Assert.IsInstanceOf<LegacyDifficultyCalculatorBeatmapDecoder>(decoder);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
|
using osu.Game.IO;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Beatmaps.Formats
|
namespace osu.Game.Tests.Beatmaps.Formats
|
||||||
@ -18,7 +18,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LineLoggingDecoder(14);
|
var decoder = new LineLoggingDecoder(14);
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("comments.osu"))
|
using (var resStream = TestResources.OpenResource("comments.osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
decoder.Decode(stream);
|
decoder.Decode(stream);
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
|
using osu.Game.IO;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyStoryboardDecoder();
|
var decoder = new LegacyStoryboardDecoder();
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("Himeringo - Yotsuya-san ni Yoroshiku (RLC) [Winber1's Extreme].osu"))
|
using (var resStream = TestResources.OpenResource("Himeringo - Yotsuya-san ni Yoroshiku (RLC) [Winber1's Extreme].osu"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var storyboard = decoder.Decode(stream);
|
var storyboard = decoder.Decode(stream);
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new LegacyStoryboardDecoder();
|
var decoder = new LegacyStoryboardDecoder();
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("variable-with-suffix.osb"))
|
using (var resStream = TestResources.OpenResource("variable-with-suffix.osb"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var storyboard = decoder.Decode(stream);
|
var storyboard = decoder.Decode(stream);
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ using NUnit.Framework;
|
|||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
|
using osu.Game.IO;
|
||||||
using osu.Game.IO.Serialization;
|
using osu.Game.IO.Serialization;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -148,13 +149,13 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
private Beatmap decode(string filename, out Beatmap jsonDecoded)
|
private Beatmap decode(string filename, out Beatmap jsonDecoded)
|
||||||
{
|
{
|
||||||
using (var stream = TestResources.OpenResource(filename))
|
using (var stream = TestResources.OpenResource(filename))
|
||||||
using (var sr = new StreamReader(stream))
|
using (var sr = new LineBufferedReader(stream))
|
||||||
{
|
{
|
||||||
var legacyDecoded = new LegacyBeatmapDecoder { ApplyOffsets = false }.Decode(sr);
|
var legacyDecoded = new LegacyBeatmapDecoder { ApplyOffsets = false }.Decode(sr);
|
||||||
|
|
||||||
using (var ms = new MemoryStream())
|
using (var ms = new MemoryStream())
|
||||||
using (var sw = new StreamWriter(ms))
|
using (var sw = new StreamWriter(ms))
|
||||||
using (var sr2 = new StreamReader(ms))
|
using (var sr2 = new LineBufferedReader(ms))
|
||||||
{
|
{
|
||||||
sw.Write(legacyDecoded.Serialize());
|
sw.Write(legacyDecoded.Serialize());
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
public async Task TestImportWhenClosed()
|
public async Task TestImportWhenClosed()
|
||||||
{
|
{
|
||||||
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportWhenClosed"))
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportWhenClosed)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -46,7 +46,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
public async Task TestImportThenDelete()
|
public async Task TestImportThenDelete()
|
||||||
{
|
{
|
||||||
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportThenDelete"))
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportThenDelete)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -67,7 +67,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
public async Task TestImportThenImport()
|
public async Task TestImportThenImport()
|
||||||
{
|
{
|
||||||
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportThenImport"))
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportThenImport)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -94,7 +94,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
public async Task TestImportCorruptThenImport()
|
public async Task TestImportCorruptThenImport()
|
||||||
{
|
{
|
||||||
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportThenImport"))
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportCorruptThenImport)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -136,7 +136,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
public async Task TestRollbackOnFailure()
|
public async Task TestRollbackOnFailure()
|
||||||
{
|
{
|
||||||
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestRollbackOnFailure"))
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestRollbackOnFailure)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -171,7 +171,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
|
|
||||||
var breakTemp = TestResources.GetTestBeatmapForImport();
|
var breakTemp = TestResources.GetTestBeatmapForImport();
|
||||||
|
|
||||||
MemoryStream brokenOsu = new MemoryStream(new byte[] { 1, 3, 3, 7 });
|
MemoryStream brokenOsu = new MemoryStream();
|
||||||
MemoryStream brokenOsz = new MemoryStream(File.ReadAllBytes(breakTemp));
|
MemoryStream brokenOsz = new MemoryStream(File.ReadAllBytes(breakTemp));
|
||||||
|
|
||||||
File.Delete(breakTemp);
|
File.Delete(breakTemp);
|
||||||
@ -213,7 +213,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
public async Task TestImportThenImportDifferentHash()
|
public async Task TestImportThenImportDifferentHash()
|
||||||
{
|
{
|
||||||
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportThenImportDifferentHash"))
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportThenImportDifferentHash)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -244,7 +244,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
public async Task TestImportThenDeleteThenImport()
|
public async Task TestImportThenDeleteThenImport()
|
||||||
{
|
{
|
||||||
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportThenDeleteThenImport"))
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportThenDeleteThenImport)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -272,7 +272,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
public async Task TestImportThenDeleteThenImportWithOnlineIDMismatch(bool set)
|
public async Task TestImportThenDeleteThenImportWithOnlineIDMismatch(bool set)
|
||||||
{
|
{
|
||||||
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost($"TestImportThenDeleteThenImport-{set}"))
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost($"{nameof(TestImportThenDeleteThenImportWithOnlineIDMismatch)}-{set}"))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -306,7 +306,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
public async Task TestImportWithDuplicateBeatmapIDs()
|
public async Task TestImportWithDuplicateBeatmapIDs()
|
||||||
{
|
{
|
||||||
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportWithDuplicateBeatmapID"))
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportWithDuplicateBeatmapIDs)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -392,7 +392,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
[Test]
|
[Test]
|
||||||
public async Task TestImportWhenFileOpen()
|
public async Task TestImportWhenFileOpen()
|
||||||
{
|
{
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportWhenFileOpen"))
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportWhenFileOpen)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -414,7 +414,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
[Test]
|
[Test]
|
||||||
public async Task TestImportNestedStructure()
|
public async Task TestImportNestedStructure()
|
||||||
{
|
{
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportNestedStructure"))
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportNestedStructure)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -456,9 +456,63 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<BeatmapSetInfo> LoadOszIntoOsu(OsuGameBase osu, string path = null)
|
[Test]
|
||||||
|
public async Task TestImportWithIgnoredDirectoryInArchive()
|
||||||
{
|
{
|
||||||
var temp = path ?? TestResources.GetTestBeatmapForImport();
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestImportWithIgnoredDirectoryInArchive)))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var osu = loadOsu(host);
|
||||||
|
|
||||||
|
var temp = TestResources.GetTestBeatmapForImport();
|
||||||
|
|
||||||
|
string extractedFolder = $"{temp}_extracted";
|
||||||
|
string dataFolder = Path.Combine(extractedFolder, "actual_data");
|
||||||
|
string resourceForkFolder = Path.Combine(extractedFolder, "__MACOSX");
|
||||||
|
string resourceForkFilePath = Path.Combine(resourceForkFolder, ".extracted");
|
||||||
|
|
||||||
|
Directory.CreateDirectory(dataFolder);
|
||||||
|
Directory.CreateDirectory(resourceForkFolder);
|
||||||
|
|
||||||
|
using (var resourceForkFile = File.CreateText(resourceForkFilePath))
|
||||||
|
{
|
||||||
|
resourceForkFile.WriteLine("adding content so that it's not empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var zip = ZipArchive.Open(temp))
|
||||||
|
zip.WriteToDirectory(dataFolder);
|
||||||
|
|
||||||
|
using (var zip = ZipArchive.Create())
|
||||||
|
{
|
||||||
|
zip.AddAllFromDirectory(extractedFolder);
|
||||||
|
zip.SaveTo(temp, new ZipWriterOptions(CompressionType.Deflate));
|
||||||
|
}
|
||||||
|
|
||||||
|
var imported = await osu.Dependencies.Get<BeatmapManager>().Import(temp);
|
||||||
|
|
||||||
|
ensureLoaded(osu);
|
||||||
|
|
||||||
|
Assert.IsFalse(imported.Files.Any(f => f.Filename.Contains("__MACOSX")), "Files contain resource fork folder, which should be ignored");
|
||||||
|
Assert.IsFalse(imported.Files.Any(f => f.Filename.Contains("actual_data")), "Files contain common subfolder");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Directory.Delete(extractedFolder, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
host.Exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<BeatmapSetInfo> LoadOszIntoOsu(OsuGameBase osu, string path = null, bool virtualTrack = false)
|
||||||
|
{
|
||||||
|
var temp = path ?? TestResources.GetTestBeatmapForImport(virtualTrack);
|
||||||
|
|
||||||
var manager = osu.Dependencies.Get<BeatmapManager>();
|
var manager = osu.Dependencies.Get<BeatmapManager>();
|
||||||
|
|
||||||
|
125
osu.Game.Tests/Beatmaps/IO/LineBufferedReaderTest.cs
Normal file
125
osu.Game.Tests/Beatmaps/IO/LineBufferedReaderTest.cs
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
// 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.IO;
|
||||||
|
using System.Text;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Game.IO;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Beatmaps.IO
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class LineBufferedReaderTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestReadLineByLine()
|
||||||
|
{
|
||||||
|
const string contents = "line 1\rline 2\nline 3";
|
||||||
|
|
||||||
|
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents)))
|
||||||
|
using (var bufferedReader = new LineBufferedReader(stream))
|
||||||
|
{
|
||||||
|
Assert.AreEqual("line 1", bufferedReader.ReadLine());
|
||||||
|
Assert.AreEqual("line 2", bufferedReader.ReadLine());
|
||||||
|
Assert.AreEqual("line 3", bufferedReader.ReadLine());
|
||||||
|
Assert.IsNull(bufferedReader.ReadLine());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestPeekLineOnce()
|
||||||
|
{
|
||||||
|
const string contents = "line 1\r\npeek this\nline 3";
|
||||||
|
|
||||||
|
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents)))
|
||||||
|
using (var bufferedReader = new LineBufferedReader(stream))
|
||||||
|
{
|
||||||
|
Assert.AreEqual("line 1", bufferedReader.ReadLine());
|
||||||
|
Assert.AreEqual("peek this", bufferedReader.PeekLine());
|
||||||
|
Assert.AreEqual("peek this", bufferedReader.ReadLine());
|
||||||
|
Assert.AreEqual("line 3", bufferedReader.ReadLine());
|
||||||
|
Assert.IsNull(bufferedReader.ReadLine());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestPeekLineMultipleTimes()
|
||||||
|
{
|
||||||
|
const string contents = "peek this once\nline 2\rpeek this a lot";
|
||||||
|
|
||||||
|
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents)))
|
||||||
|
using (var bufferedReader = new LineBufferedReader(stream))
|
||||||
|
{
|
||||||
|
Assert.AreEqual("peek this once", bufferedReader.PeekLine());
|
||||||
|
Assert.AreEqual("peek this once", bufferedReader.ReadLine());
|
||||||
|
Assert.AreEqual("line 2", bufferedReader.ReadLine());
|
||||||
|
Assert.AreEqual("peek this a lot", bufferedReader.PeekLine());
|
||||||
|
Assert.AreEqual("peek this a lot", bufferedReader.PeekLine());
|
||||||
|
Assert.AreEqual("peek this a lot", bufferedReader.PeekLine());
|
||||||
|
Assert.AreEqual("peek this a lot", bufferedReader.ReadLine());
|
||||||
|
Assert.IsNull(bufferedReader.ReadLine());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestPeekLineAtEndOfStream()
|
||||||
|
{
|
||||||
|
const string contents = "first line\r\nsecond line";
|
||||||
|
|
||||||
|
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents)))
|
||||||
|
using (var bufferedReader = new LineBufferedReader(stream))
|
||||||
|
{
|
||||||
|
Assert.AreEqual("first line", bufferedReader.ReadLine());
|
||||||
|
Assert.AreEqual("second line", bufferedReader.ReadLine());
|
||||||
|
Assert.IsNull(bufferedReader.PeekLine());
|
||||||
|
Assert.IsNull(bufferedReader.ReadLine());
|
||||||
|
Assert.IsNull(bufferedReader.PeekLine());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestPeekReadLineOnEmptyStream()
|
||||||
|
{
|
||||||
|
using (var stream = new MemoryStream())
|
||||||
|
using (var bufferedReader = new LineBufferedReader(stream))
|
||||||
|
{
|
||||||
|
Assert.IsNull(bufferedReader.PeekLine());
|
||||||
|
Assert.IsNull(bufferedReader.ReadLine());
|
||||||
|
Assert.IsNull(bufferedReader.ReadLine());
|
||||||
|
Assert.IsNull(bufferedReader.PeekLine());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestReadToEndNoPeeks()
|
||||||
|
{
|
||||||
|
const string contents = "first line\r\nsecond line";
|
||||||
|
|
||||||
|
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents)))
|
||||||
|
using (var bufferedReader = new LineBufferedReader(stream))
|
||||||
|
{
|
||||||
|
Assert.AreEqual(contents, bufferedReader.ReadToEnd());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestReadToEndAfterReadsAndPeeks()
|
||||||
|
{
|
||||||
|
const string contents = "this line is gone\rthis one shouldn't be\r\nthese ones\ndefinitely not";
|
||||||
|
|
||||||
|
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents)))
|
||||||
|
using (var bufferedReader = new LineBufferedReader(stream))
|
||||||
|
{
|
||||||
|
Assert.AreEqual("this line is gone", bufferedReader.ReadLine());
|
||||||
|
Assert.AreEqual("this one shouldn't be", bufferedReader.PeekLine());
|
||||||
|
|
||||||
|
var endingLines = bufferedReader.ReadToEnd().Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
Assert.AreEqual(3, endingLines.Length);
|
||||||
|
Assert.AreEqual("this one shouldn't be", endingLines[0]);
|
||||||
|
Assert.AreEqual("these ones", endingLines[1]);
|
||||||
|
Assert.AreEqual("definitely not", endingLines[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ using NUnit.Framework;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
|
using osu.Game.IO;
|
||||||
using osu.Game.IO.Archives;
|
using osu.Game.IO.Archives;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Beatmaps.IO
|
namespace osu.Game.Tests.Beatmaps.IO
|
||||||
@ -50,7 +51,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
|
|
||||||
Beatmap beatmap;
|
Beatmap beatmap;
|
||||||
|
|
||||||
using (var stream = new StreamReader(reader.GetStream("Soleily - Renatus (Deif) [Platter].osu")))
|
using (var stream = new LineBufferedReader(reader.GetStream("Soleily - Renatus (Deif) [Platter].osu")))
|
||||||
beatmap = Decoder.GetDecoder<Beatmap>(stream).Decode(stream);
|
beatmap = Decoder.GetDecoder<Beatmap>(stream).Decode(stream);
|
||||||
|
|
||||||
var meta = beatmap.Metadata;
|
var meta = beatmap.Metadata;
|
||||||
|
@ -11,13 +11,13 @@ namespace osu.Game.Tests.Resources
|
|||||||
{
|
{
|
||||||
public static Stream OpenResource(string name) => new DllResourceStore("osu.Game.Tests.dll").GetStream($"Resources/{name}");
|
public static Stream OpenResource(string name) => new DllResourceStore("osu.Game.Tests.dll").GetStream($"Resources/{name}");
|
||||||
|
|
||||||
public static Stream GetTestBeatmapStream() => new DllResourceStore("osu.Game.Resources.dll").GetStream("Beatmaps/241526 Soleily - Renatus.osz");
|
public static Stream GetTestBeatmapStream(bool virtualTrack = false) => new DllResourceStore("osu.Game.Resources.dll").GetStream($"Beatmaps/241526 Soleily - Renatus{(virtualTrack ? "_virtual" : "")}.osz");
|
||||||
|
|
||||||
public static string GetTestBeatmapForImport()
|
public static string GetTestBeatmapForImport(bool virtualTrack = false)
|
||||||
{
|
{
|
||||||
var temp = Path.GetTempFileName() + ".osz";
|
var temp = Path.GetTempFileName() + ".osz";
|
||||||
|
|
||||||
using (var stream = GetTestBeatmapStream())
|
using (var stream = GetTestBeatmapStream(virtualTrack))
|
||||||
using (var newFile = File.Create(temp))
|
using (var newFile = File.Create(temp))
|
||||||
stream.CopyTo(newFile);
|
stream.CopyTo(newFile);
|
||||||
|
|
||||||
|
5
osu.Game.Tests/Resources/corrupted-header.osu
Normal file
5
osu.Game.Tests/Resources/corrupted-header.osu
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
ow computerosu file format v14
|
||||||
|
|
||||||
|
[Metadata]
|
||||||
|
Title: Beatmap with corrupted header
|
||||||
|
Creator: Evil Hacker
|
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
|
[Metadata]
|
||||||
|
Title: The dog ate the file header
|
||||||
|
Creator: Why does this keep happening
|
8
osu.Game.Tests/Resources/empty-lines-at-start.osu
Normal file
8
osu.Game.Tests/Resources/empty-lines-at-start.osu
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
osu file format v14
|
||||||
|
|
||||||
|
[Metadata]
|
||||||
|
Title: Empty lines at start
|
||||||
|
Creator: Edge Case Hunter
|
4
osu.Game.Tests/Resources/missing-header.osu
Normal file
4
osu.Game.Tests/Resources/missing-header.osu
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[Metadata]
|
||||||
|
|
||||||
|
Title: Beatmap with no header
|
||||||
|
Creator: Incredibly Evil Hacker
|
4
osu.Game.Tests/Resources/no-empty-line-after-header.osu
Normal file
4
osu.Game.Tests/Resources/no-empty-line-after-header.osu
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
osu file format v14
|
||||||
|
[Metadata]
|
||||||
|
Title: No empty line delimiting header from contents
|
||||||
|
Creator: Edge Case Hunter
|
@ -2,8 +2,8 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Game.IO;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -20,7 +20,7 @@ namespace osu.Game.Tests.Skins
|
|||||||
var decoder = new LegacySkinDecoder();
|
var decoder = new LegacySkinDecoder();
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource(hasColours ? "skin.ini" : "skin-empty.ini"))
|
using (var resStream = TestResources.OpenResource(hasColours ? "skin.ini" : "skin-empty.ini"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var comboColors = decoder.Decode(stream).ComboColours;
|
var comboColors = decoder.Decode(stream).ComboColours;
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ namespace osu.Game.Tests.Skins
|
|||||||
var decoder = new LegacySkinDecoder();
|
var decoder = new LegacySkinDecoder();
|
||||||
|
|
||||||
using (var resStream = TestResources.OpenResource("skin.ini"))
|
using (var resStream = TestResources.OpenResource("skin.ini"))
|
||||||
using (var stream = new StreamReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var config = decoder.Decode(stream);
|
var config = decoder.Decode(stream);
|
||||||
|
|
||||||
|
213
osu.Game.Tests/Visual/Editor/TestSceneBeatSnapGrid.cs
Normal file
213
osu.Game.Tests/Visual/Editor/TestSceneBeatSnapGrid.cs
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Screens.Edit;
|
||||||
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Editor
|
||||||
|
{
|
||||||
|
public class TestSceneBeatSnapGrid : EditorClockTestScene
|
||||||
|
{
|
||||||
|
private const double beat_length = 100;
|
||||||
|
private static readonly Vector2 grid_position = new Vector2(512, 384);
|
||||||
|
|
||||||
|
[Cached(typeof(IEditorBeatmap))]
|
||||||
|
private readonly EditorBeatmap<OsuHitObject> editorBeatmap;
|
||||||
|
|
||||||
|
private TestBeatSnapGrid grid;
|
||||||
|
|
||||||
|
public TestSceneBeatSnapGrid()
|
||||||
|
{
|
||||||
|
editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
||||||
|
editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beat_length });
|
||||||
|
|
||||||
|
createGrid();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup() => Schedule(() =>
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
|
||||||
|
editorBeatmap.ControlPointInfo.TimingPoints.Clear();
|
||||||
|
editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beat_length });
|
||||||
|
|
||||||
|
BeatDivisor.Value = 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
[TestCase(1)]
|
||||||
|
[TestCase(2)]
|
||||||
|
[TestCase(3)]
|
||||||
|
[TestCase(4)]
|
||||||
|
[TestCase(6)]
|
||||||
|
[TestCase(8)]
|
||||||
|
[TestCase(12)]
|
||||||
|
[TestCase(16)]
|
||||||
|
public void TestInitialBeatDivisor(int divisor)
|
||||||
|
{
|
||||||
|
AddStep($"set beat divisor = {divisor}", () => BeatDivisor.Value = divisor);
|
||||||
|
createGrid();
|
||||||
|
|
||||||
|
float expectedDistance = (float)beat_length / divisor;
|
||||||
|
AddAssert($"spacing is {expectedDistance}", () => Precision.AlmostEquals(grid.DistanceSpacing, expectedDistance));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestChangeBeatDivisor()
|
||||||
|
{
|
||||||
|
createGrid();
|
||||||
|
AddStep("set beat divisor = 2", () => BeatDivisor.Value = 2);
|
||||||
|
|
||||||
|
const float expected_distance = (float)beat_length / 2;
|
||||||
|
AddAssert($"spacing is {expected_distance}", () => Precision.AlmostEquals(grid.DistanceSpacing, expected_distance));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(100)]
|
||||||
|
[TestCase(200)]
|
||||||
|
public void TestBeatLength(double beatLength)
|
||||||
|
{
|
||||||
|
AddStep($"set beat length = {beatLength}", () =>
|
||||||
|
{
|
||||||
|
editorBeatmap.ControlPointInfo.TimingPoints.Clear();
|
||||||
|
editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beatLength });
|
||||||
|
});
|
||||||
|
|
||||||
|
createGrid();
|
||||||
|
AddAssert($"spacing is {beatLength}", () => Precision.AlmostEquals(grid.DistanceSpacing, beatLength));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(1)]
|
||||||
|
[TestCase(2)]
|
||||||
|
public void TestGridVelocity(float velocity)
|
||||||
|
{
|
||||||
|
createGrid(g => g.Velocity = velocity);
|
||||||
|
|
||||||
|
float expectedDistance = (float)beat_length * velocity;
|
||||||
|
AddAssert($"spacing is {expectedDistance}", () => Precision.AlmostEquals(grid.DistanceSpacing, expectedDistance));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestGetSnappedTime()
|
||||||
|
{
|
||||||
|
createGrid();
|
||||||
|
|
||||||
|
Vector2 snapPosition = Vector2.Zero;
|
||||||
|
AddStep("get first tick position", () => snapPosition = grid_position + new Vector2((float)beat_length, 0));
|
||||||
|
AddAssert("snap time is 1 beat away", () => Precision.AlmostEquals(beat_length, grid.GetSnapTime(snapPosition), 0.01));
|
||||||
|
|
||||||
|
createGrid(g => g.Velocity = 2, "with velocity = 2");
|
||||||
|
AddAssert("snap time is now 0.5 beats away", () => Precision.AlmostEquals(beat_length / 2, grid.GetSnapTime(snapPosition), 0.01));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createGrid(Action<TestBeatSnapGrid> func = null, string description = null)
|
||||||
|
{
|
||||||
|
AddStep($"create grid {description ?? string.Empty}", () =>
|
||||||
|
{
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.SlateGray
|
||||||
|
},
|
||||||
|
grid = new TestBeatSnapGrid(new HitObject(), grid_position)
|
||||||
|
};
|
||||||
|
|
||||||
|
func?.Invoke(grid);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestBeatSnapGrid : BeatSnapGrid
|
||||||
|
{
|
||||||
|
public new float Velocity = 1;
|
||||||
|
|
||||||
|
public new float DistanceSpacing => base.DistanceSpacing;
|
||||||
|
|
||||||
|
public TestBeatSnapGrid(HitObject hitObject, Vector2 centrePosition)
|
||||||
|
: base(hitObject, centrePosition)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateContent(Vector2 centrePosition)
|
||||||
|
{
|
||||||
|
AddInternal(new Circle
|
||||||
|
{
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(5),
|
||||||
|
Position = centrePosition
|
||||||
|
});
|
||||||
|
|
||||||
|
int beatIndex = 0;
|
||||||
|
|
||||||
|
for (float s = centrePosition.X + DistanceSpacing; s <= DrawWidth; s += DistanceSpacing, beatIndex++)
|
||||||
|
{
|
||||||
|
AddInternal(new Circle
|
||||||
|
{
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(5, 10),
|
||||||
|
Position = new Vector2(s, centrePosition.Y),
|
||||||
|
Colour = GetColourForBeatIndex(beatIndex)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
beatIndex = 0;
|
||||||
|
|
||||||
|
for (float s = centrePosition.X - DistanceSpacing; s >= 0; s -= DistanceSpacing, beatIndex++)
|
||||||
|
{
|
||||||
|
AddInternal(new Circle
|
||||||
|
{
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(5, 10),
|
||||||
|
Position = new Vector2(s, centrePosition.Y),
|
||||||
|
Colour = GetColourForBeatIndex(beatIndex)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
beatIndex = 0;
|
||||||
|
|
||||||
|
for (float s = centrePosition.Y + DistanceSpacing; s <= DrawHeight; s += DistanceSpacing, beatIndex++)
|
||||||
|
{
|
||||||
|
AddInternal(new Circle
|
||||||
|
{
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(10, 5),
|
||||||
|
Position = new Vector2(centrePosition.X, s),
|
||||||
|
Colour = GetColourForBeatIndex(beatIndex)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
beatIndex = 0;
|
||||||
|
|
||||||
|
for (float s = centrePosition.Y - DistanceSpacing; s >= 0; s -= DistanceSpacing, beatIndex++)
|
||||||
|
{
|
||||||
|
AddInternal(new Circle
|
||||||
|
{
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(10, 5),
|
||||||
|
Position = new Vector2(centrePosition.X, s),
|
||||||
|
Colour = GetColourForBeatIndex(beatIndex)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override float GetVelocity(double time, ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||||
|
=> Velocity;
|
||||||
|
|
||||||
|
public override Vector2 GetSnapPosition(Vector2 screenSpacePosition)
|
||||||
|
=> Vector2.Zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
@ -11,10 +9,8 @@ using osu.Game.Screens.Edit.Compose;
|
|||||||
namespace osu.Game.Tests.Visual.Editor
|
namespace osu.Game.Tests.Visual.Editor
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneEditorCompose : EditorClockTestScene
|
public class TestSceneComposeScreen : EditorClockTestScene
|
||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(ComposeScreen) };
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
@ -127,14 +127,47 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
exitAndConfirm();
|
exitAndConfirm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestExitFromFailedGameplay()
|
||||||
|
{
|
||||||
|
AddUntilStep("wait for fail", () => Player.HasFailed);
|
||||||
|
AddStep("exit", () => Player.Exit());
|
||||||
|
|
||||||
|
confirmExited();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestQuickRetryFromFailedGameplay()
|
||||||
|
{
|
||||||
|
AddUntilStep("wait for fail", () => Player.HasFailed);
|
||||||
|
AddStep("quick retry", () => Player.GameplayClockContainer.OfType<HotkeyRetryOverlay>().First().Action?.Invoke());
|
||||||
|
|
||||||
|
confirmExited();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestQuickExitFromFailedGameplay()
|
||||||
|
{
|
||||||
|
AddUntilStep("wait for fail", () => Player.HasFailed);
|
||||||
|
AddStep("quick exit", () => Player.GameplayClockContainer.OfType<HotkeyExitOverlay>().First().Action?.Invoke());
|
||||||
|
|
||||||
|
confirmExited();
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestExitFromGameplay()
|
public void TestExitFromGameplay()
|
||||||
{
|
{
|
||||||
AddStep("exit", () => Player.Exit());
|
AddStep("exit", () => Player.Exit());
|
||||||
|
|
||||||
confirmPaused();
|
confirmExited();
|
||||||
|
}
|
||||||
|
|
||||||
exitAndConfirm();
|
[Test]
|
||||||
|
public void TestQuickExitFromGameplay()
|
||||||
|
{
|
||||||
|
AddStep("quick exit", () => Player.GameplayClockContainer.OfType<HotkeyExitOverlay>().First().Action?.Invoke());
|
||||||
|
|
||||||
|
confirmExited();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -7,10 +7,16 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -18,25 +24,49 @@ using osu.Game.Scoring;
|
|||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Screens.Play.PlayerSettings;
|
using osu.Game.Screens.Play.PlayerSettings;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
public class TestScenePlayerLoader : ManualInputManagerTestScene
|
public class TestScenePlayerLoader : ManualInputManagerTestScene
|
||||||
{
|
{
|
||||||
private TestPlayerLoader loader;
|
private TestPlayerLoader loader;
|
||||||
private OsuScreenStack stack;
|
private TestPlayerLoaderContainer container;
|
||||||
|
private TestPlayer player;
|
||||||
|
|
||||||
[SetUp]
|
[Resolved]
|
||||||
public void Setup() => Schedule(() =>
|
private AudioManager audioManager { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private SessionStatics sessionStatics { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the input manager child to a new test player loader container instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="interactive">If the test player should behave like the production one.</param>
|
||||||
|
/// <param name="beforeLoadAction">An action to run before player load but after bindable leases are returned.</param>
|
||||||
|
/// <param name="afterLoadAction">An action to run after container load.</param>
|
||||||
|
public void ResetPlayer(bool interactive, Action beforeLoadAction = null, Action afterLoadAction = null)
|
||||||
{
|
{
|
||||||
InputManager.Child = stack = new OsuScreenStack { RelativeSizeAxes = Axes.Both };
|
audioManager.Volume.SetDefault();
|
||||||
|
|
||||||
|
InputManager.Clear();
|
||||||
|
|
||||||
|
beforeLoadAction?.Invoke();
|
||||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||||
});
|
|
||||||
|
InputManager.Child = container = new TestPlayerLoaderContainer(
|
||||||
|
loader = new TestPlayerLoader(() =>
|
||||||
|
{
|
||||||
|
afterLoadAction?.Invoke();
|
||||||
|
return player = new TestPlayer(interactive, interactive);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestBlockLoadViaMouseMovement()
|
public void TestBlockLoadViaMouseMovement()
|
||||||
{
|
{
|
||||||
AddStep("load dummy beatmap", () => stack.Push(loader = new TestPlayerLoader(() => new TestPlayer(false, false))));
|
AddStep("load dummy beatmap", () => ResetPlayer(false));
|
||||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||||
AddRepeatStep("move mouse", () => InputManager.MoveMouseTo(loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft + (loader.VisualSettings.ScreenSpaceDrawQuad.BottomRight - loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft) * RNG.NextSingle()), 20);
|
AddRepeatStep("move mouse", () => InputManager.MoveMouseTo(loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft + (loader.VisualSettings.ScreenSpaceDrawQuad.BottomRight - loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft) * RNG.NextSingle()), 20);
|
||||||
AddAssert("loader still active", () => loader.IsCurrentScreen());
|
AddAssert("loader still active", () => loader.IsCurrentScreen());
|
||||||
@ -46,16 +76,17 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestLoadContinuation()
|
public void TestLoadContinuation()
|
||||||
{
|
{
|
||||||
Player player = null;
|
|
||||||
SlowLoadPlayer slowPlayer = null;
|
SlowLoadPlayer slowPlayer = null;
|
||||||
|
|
||||||
AddStep("load dummy beatmap", () => stack.Push(loader = new TestPlayerLoader(() => player = new TestPlayer(false, false))));
|
AddStep("load dummy beatmap", () => ResetPlayer(false));
|
||||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||||
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
||||||
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen());
|
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen());
|
||||||
AddStep("load slow dummy beatmap", () =>
|
AddStep("load slow dummy beatmap", () =>
|
||||||
{
|
{
|
||||||
stack.Push(loader = new TestPlayerLoader(() => slowPlayer = new SlowLoadPlayer(false, false)));
|
InputManager.Child = container = new TestPlayerLoaderContainer(
|
||||||
|
loader = new TestPlayerLoader(() => slowPlayer = new SlowLoadPlayer(false, false)));
|
||||||
|
|
||||||
Scheduler.AddDelayed(() => slowPlayer.AllowLoad.Set(), 5000);
|
Scheduler.AddDelayed(() => slowPlayer.AllowLoad.Set(), 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -65,16 +96,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestModReinstantiation()
|
public void TestModReinstantiation()
|
||||||
{
|
{
|
||||||
TestPlayer player = null;
|
|
||||||
TestMod gameMod = null;
|
TestMod gameMod = null;
|
||||||
TestMod playerMod1 = null;
|
TestMod playerMod1 = null;
|
||||||
TestMod playerMod2 = null;
|
TestMod playerMod2 = null;
|
||||||
|
|
||||||
AddStep("load player", () =>
|
AddStep("load player", () => { ResetPlayer(true, () => Mods.Value = new[] { gameMod = new TestMod() }); });
|
||||||
{
|
|
||||||
Mods.Value = new[] { gameMod = new TestMod() };
|
|
||||||
stack.Push(loader = new TestPlayerLoader(() => player = new TestPlayer()));
|
|
||||||
});
|
|
||||||
|
|
||||||
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
|
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
|
||||||
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
||||||
@ -97,6 +123,75 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddAssert("player mods applied", () => playerMod2.Applied);
|
AddAssert("player mods applied", () => playerMod2.Applied);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMutedNotificationMasterVolume() => addVolumeSteps("master volume", () => audioManager.Volume.Value = 0, null, () => audioManager.Volume.IsDefault);
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMutedNotificationTrackVolume() => addVolumeSteps("music volume", () => audioManager.VolumeTrack.Value = 0, null, () => audioManager.VolumeTrack.IsDefault);
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMutedNotificationMuteButton() => addVolumeSteps("mute button", null, () => container.VolumeOverlay.IsMuted.Value = true, () => !container.VolumeOverlay.IsMuted.Value);
|
||||||
|
|
||||||
|
/// <remarks>
|
||||||
|
/// Created for avoiding copy pasting code for the same steps.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="volumeName">What part of the volume system is checked</param>
|
||||||
|
/// <param name="beforeLoad">The action to be invoked to set the volume before loading</param>
|
||||||
|
/// <param name="afterLoad">The action to be invoked to set the volume after loading</param>
|
||||||
|
/// <param name="assert">The function to be invoked and checked</param>
|
||||||
|
private void addVolumeSteps(string volumeName, Action beforeLoad, Action afterLoad, Func<bool> assert)
|
||||||
|
{
|
||||||
|
AddStep("reset notification lock", () => sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce).Value = false);
|
||||||
|
|
||||||
|
AddStep("load player", () => ResetPlayer(false, beforeLoad, afterLoad));
|
||||||
|
AddUntilStep("wait for player", () => player.IsLoaded);
|
||||||
|
|
||||||
|
AddAssert("check for notification", () => container.NotificationOverlay.UnreadCount.Value == 1);
|
||||||
|
AddStep("click notification", () =>
|
||||||
|
{
|
||||||
|
var scrollContainer = (OsuScrollContainer)container.NotificationOverlay.Children.Last();
|
||||||
|
var flowContainer = scrollContainer.Children.OfType<FillFlowContainer<NotificationSection>>().First();
|
||||||
|
var notification = flowContainer.First();
|
||||||
|
|
||||||
|
InputManager.MoveMouseTo(notification);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("check " + volumeName, assert);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestPlayerLoaderContainer : Container
|
||||||
|
{
|
||||||
|
[Cached]
|
||||||
|
public readonly NotificationOverlay NotificationOverlay;
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
public readonly VolumeOverlay VolumeOverlay;
|
||||||
|
|
||||||
|
public TestPlayerLoaderContainer(IScreen screen)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuScreenStack(screen)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
NotificationOverlay = new NotificationOverlay
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
},
|
||||||
|
VolumeOverlay = new VolumeOverlay
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopLeft,
|
||||||
|
Origin = Anchor.TopLeft,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class TestPlayerLoader : PlayerLoader
|
private class TestPlayerLoader : PlayerLoader
|
||||||
{
|
{
|
||||||
public new VisualSettings VisualSettings => base.VisualSettings;
|
public new VisualSettings VisualSettings => base.VisualSettings;
|
||||||
|
@ -5,12 +5,15 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio.Track;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
@ -18,7 +21,9 @@ using osu.Game.Overlays;
|
|||||||
using osu.Game.Overlays.Mods;
|
using osu.Game.Overlays.Mods;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.Menu;
|
using osu.Game.Screens.Menu;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
|
using osu.Game.Tests.Beatmaps.IO;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -31,11 +36,11 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
private const float click_padding = 25;
|
private const float click_padding = 25;
|
||||||
|
|
||||||
private GameHost host;
|
private GameHost host;
|
||||||
private TestOsuGame osuGame;
|
private TestOsuGame game;
|
||||||
|
|
||||||
private Vector2 backButtonPosition => osuGame.ToScreenSpace(new Vector2(click_padding, osuGame.LayoutRectangle.Bottom - click_padding));
|
private Vector2 backButtonPosition => game.ToScreenSpace(new Vector2(click_padding, game.LayoutRectangle.Bottom - click_padding));
|
||||||
|
|
||||||
private Vector2 optionsButtonPosition => osuGame.ToScreenSpace(new Vector2(click_padding, click_padding));
|
private Vector2 optionsButtonPosition => game.ToScreenSpace(new Vector2(click_padding, click_padding));
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(GameHost host)
|
private void load(GameHost host)
|
||||||
@ -54,23 +59,23 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
{
|
{
|
||||||
AddStep("Create new game instance", () =>
|
AddStep("Create new game instance", () =>
|
||||||
{
|
{
|
||||||
if (osuGame != null)
|
if (game != null)
|
||||||
{
|
{
|
||||||
Remove(osuGame);
|
Remove(game);
|
||||||
osuGame.Dispose();
|
game.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
osuGame = new TestOsuGame(LocalStorage, API);
|
game = new TestOsuGame(LocalStorage, API);
|
||||||
osuGame.SetHost(host);
|
game.SetHost(host);
|
||||||
|
|
||||||
// todo: this can be removed once we can run audio trakcs without a device present
|
// todo: this can be removed once we can run audio trakcs without a device present
|
||||||
// see https://github.com/ppy/osu/issues/1302
|
// see https://github.com/ppy/osu/issues/1302
|
||||||
osuGame.LocalConfig.Set(OsuSetting.IntroSequence, IntroSequence.Circles);
|
game.LocalConfig.Set(OsuSetting.IntroSequence, IntroSequence.Circles);
|
||||||
|
|
||||||
Add(osuGame);
|
Add(game);
|
||||||
});
|
});
|
||||||
AddUntilStep("Wait for load", () => osuGame.IsLoaded);
|
AddUntilStep("Wait for load", () => game.IsLoaded);
|
||||||
AddUntilStep("Wait for intro", () => osuGame.ScreenStack.CurrentScreen is IntroScreen);
|
AddUntilStep("Wait for intro", () => game.ScreenStack.CurrentScreen is IntroScreen);
|
||||||
confirmAtMainMenu();
|
confirmAtMainMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,11 +87,43 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
pushAndConfirm(() => songSelect = new TestSongSelect());
|
pushAndConfirm(() => songSelect = new TestSongSelect());
|
||||||
AddStep("Show mods overlay", () => songSelect.ModSelectOverlay.Show());
|
AddStep("Show mods overlay", () => songSelect.ModSelectOverlay.Show());
|
||||||
AddAssert("Overlay was shown", () => songSelect.ModSelectOverlay.State.Value == Visibility.Visible);
|
AddAssert("Overlay was shown", () => songSelect.ModSelectOverlay.State.Value == Visibility.Visible);
|
||||||
AddStep("Press escape", () => pressAndRelease(Key.Escape));
|
pushEscape();
|
||||||
AddAssert("Overlay was hidden", () => songSelect.ModSelectOverlay.State.Value == Visibility.Hidden);
|
AddAssert("Overlay was hidden", () => songSelect.ModSelectOverlay.State.Value == Visibility.Hidden);
|
||||||
exitViaEscapeAndConfirm();
|
exitViaEscapeAndConfirm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(true)]
|
||||||
|
[TestCase(false)]
|
||||||
|
public void TestSongContinuesAfterExitPlayer(bool withUserPause)
|
||||||
|
{
|
||||||
|
Player player = null;
|
||||||
|
|
||||||
|
WorkingBeatmap beatmap() => game.Beatmap.Value;
|
||||||
|
Track track() => beatmap().Track;
|
||||||
|
|
||||||
|
pushAndConfirm(() => new TestSongSelect());
|
||||||
|
|
||||||
|
AddStep("import beatmap", () => ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).Wait());
|
||||||
|
|
||||||
|
AddUntilStep("wait for selected", () => !game.Beatmap.IsDefault);
|
||||||
|
|
||||||
|
if (withUserPause)
|
||||||
|
AddStep("pause", () => game.Dependencies.Get<MusicController>().Stop());
|
||||||
|
|
||||||
|
AddStep("press enter", () => pressAndRelease(Key.Enter));
|
||||||
|
|
||||||
|
AddUntilStep("wait for player", () => (player = game.ScreenStack.CurrentScreen as Player) != null);
|
||||||
|
AddUntilStep("wait for fail", () => player.HasFailed);
|
||||||
|
|
||||||
|
AddUntilStep("wait for track stop", () => !track().IsRunning);
|
||||||
|
AddAssert("Ensure time before preview point", () => track().CurrentTime < beatmap().Metadata.PreviewTime);
|
||||||
|
|
||||||
|
pushEscape();
|
||||||
|
|
||||||
|
AddUntilStep("wait for track playing", () => track().IsRunning);
|
||||||
|
AddAssert("Ensure time wasn't reset to preview point", () => track().CurrentTime < beatmap().Metadata.PreviewTime);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestExitSongSelectWithClick()
|
public void TestExitSongSelectWithClick()
|
||||||
{
|
{
|
||||||
@ -98,7 +135,7 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
AddStep("Move mouse to backButton", () => InputManager.MoveMouseTo(backButtonPosition));
|
AddStep("Move mouse to backButton", () => InputManager.MoveMouseTo(backButtonPosition));
|
||||||
|
|
||||||
// BackButton handles hover using its child button, so this checks whether or not any of BackButton's children are hovered.
|
// BackButton handles hover using its child button, so this checks whether or not any of BackButton's children are hovered.
|
||||||
AddUntilStep("Back button is hovered", () => InputManager.HoveredDrawables.Any(d => d.Parent == osuGame.BackButton));
|
AddUntilStep("Back button is hovered", () => InputManager.HoveredDrawables.Any(d => d.Parent == game.BackButton));
|
||||||
|
|
||||||
AddStep("Click back button", () => InputManager.Click(MouseButton.Left));
|
AddStep("Click back button", () => InputManager.Click(MouseButton.Left));
|
||||||
AddUntilStep("Overlay was hidden", () => songSelect.ModSelectOverlay.State.Value == Visibility.Hidden);
|
AddUntilStep("Overlay was hidden", () => songSelect.ModSelectOverlay.State.Value == Visibility.Hidden);
|
||||||
@ -122,25 +159,28 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestOpenOptionsAndExitWithEscape()
|
public void TestOpenOptionsAndExitWithEscape()
|
||||||
{
|
{
|
||||||
AddUntilStep("Wait for options to load", () => osuGame.Settings.IsLoaded);
|
AddUntilStep("Wait for options to load", () => game.Settings.IsLoaded);
|
||||||
AddStep("Enter menu", () => pressAndRelease(Key.Enter));
|
AddStep("Enter menu", () => pressAndRelease(Key.Enter));
|
||||||
AddStep("Move mouse to options overlay", () => InputManager.MoveMouseTo(optionsButtonPosition));
|
AddStep("Move mouse to options overlay", () => InputManager.MoveMouseTo(optionsButtonPosition));
|
||||||
AddStep("Click options overlay", () => InputManager.Click(MouseButton.Left));
|
AddStep("Click options overlay", () => InputManager.Click(MouseButton.Left));
|
||||||
AddAssert("Options overlay was opened", () => osuGame.Settings.State.Value == Visibility.Visible);
|
AddAssert("Options overlay was opened", () => game.Settings.State.Value == Visibility.Visible);
|
||||||
AddStep("Hide options overlay using escape", () => pressAndRelease(Key.Escape));
|
AddStep("Hide options overlay using escape", () => pressAndRelease(Key.Escape));
|
||||||
AddAssert("Options overlay was closed", () => osuGame.Settings.State.Value == Visibility.Hidden);
|
AddAssert("Options overlay was closed", () => game.Settings.State.Value == Visibility.Hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pushAndConfirm(Func<Screen> newScreen)
|
private void pushAndConfirm(Func<Screen> newScreen)
|
||||||
{
|
{
|
||||||
Screen screen = null;
|
Screen screen = null;
|
||||||
AddStep("Push new screen", () => osuGame.ScreenStack.Push(screen = newScreen()));
|
AddStep("Push new screen", () => game.ScreenStack.Push(screen = newScreen()));
|
||||||
AddUntilStep("Wait for new screen", () => osuGame.ScreenStack.CurrentScreen == screen && screen.IsLoaded);
|
AddUntilStep("Wait for new screen", () => game.ScreenStack.CurrentScreen == screen && screen.IsLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void pushEscape() =>
|
||||||
|
AddStep("Press escape", () => pressAndRelease(Key.Escape));
|
||||||
|
|
||||||
private void exitViaEscapeAndConfirm()
|
private void exitViaEscapeAndConfirm()
|
||||||
{
|
{
|
||||||
AddStep("Press escape", () => pressAndRelease(Key.Escape));
|
pushEscape();
|
||||||
confirmAtMainMenu();
|
confirmAtMainMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +191,7 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
confirmAtMainMenu();
|
confirmAtMainMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void confirmAtMainMenu() => AddUntilStep("Wait for main menu", () => osuGame.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded);
|
private void confirmAtMainMenu() => AddUntilStep("Wait for main menu", () => game.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded);
|
||||||
|
|
||||||
private void pressAndRelease(Key key)
|
private void pressAndRelease(Key key)
|
||||||
{
|
{
|
||||||
@ -169,6 +209,8 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
|
|
||||||
public new OsuConfigManager LocalConfig => base.LocalConfig;
|
public new OsuConfigManager LocalConfig => base.LocalConfig;
|
||||||
|
|
||||||
|
public new Bindable<WorkingBeatmap> Beatmap => base.Beatmap;
|
||||||
|
|
||||||
protected override Loader CreateLoader() => new TestLoader();
|
protected override Loader CreateLoader() => new TestLoader();
|
||||||
|
|
||||||
public TestOsuGame(Storage storage, IAPIProvider api)
|
public TestOsuGame(Storage storage, IAPIProvider api)
|
||||||
|
39
osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs
Normal file
39
osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// 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.Overlays.Comments;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Online
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestSceneCommentsHeader : OsuTestScene
|
||||||
|
{
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
|
{
|
||||||
|
typeof(CommentsHeader),
|
||||||
|
typeof(HeaderButton),
|
||||||
|
typeof(SortTabControl),
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly Bindable<CommentsSortCriteria> sort = new Bindable<CommentsSortCriteria>();
|
||||||
|
private readonly BindableBool showDeleted = new BindableBool();
|
||||||
|
|
||||||
|
public TestSceneCommentsHeader()
|
||||||
|
{
|
||||||
|
Add(new CommentsHeader
|
||||||
|
{
|
||||||
|
Sort = { BindTarget = sort },
|
||||||
|
ShowDeleted = { BindTarget = showDeleted }
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("Trigger ShowDeleted", () => showDeleted.Value = !showDeleted.Value);
|
||||||
|
AddStep("Select old", () => sort.Value = CommentsSortCriteria.Old);
|
||||||
|
AddStep("Select new", () => sort.Value = CommentsSortCriteria.New);
|
||||||
|
AddStep("Select top", () => sort.Value = CommentsSortCriteria.Top);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -32,6 +32,12 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Id = 4,
|
Id = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private readonly User longUsernameUser = new User
|
||||||
|
{
|
||||||
|
Username = "Very Long Long Username",
|
||||||
|
Id = 5,
|
||||||
|
};
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private ChannelManager channelManager = new ChannelManager();
|
private ChannelManager channelManager = new ChannelManager();
|
||||||
|
|
||||||
@ -99,6 +105,12 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Sender = admin,
|
Sender = admin,
|
||||||
Content = "Okay okay, calm down guys. Let's do this!"
|
Content = "Okay okay, calm down guys. Let's do this!"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
AddStep("message from long username", () => testChannel.AddNewMessages(new Message(sequence++)
|
||||||
|
{
|
||||||
|
Sender = longUsernameUser,
|
||||||
|
Content = "Hi guys, my new username is lit!"
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,15 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
|
||||||
}, api.IsLoggedIn));
|
}, api.IsLoggedIn));
|
||||||
|
|
||||||
|
AddStep("Show bancho", () => profile.ShowUser(new User
|
||||||
|
{
|
||||||
|
Username = @"BanchoBot",
|
||||||
|
Id = 3,
|
||||||
|
IsBot = true,
|
||||||
|
Country = new Country { FullName = @"Saint Helena", FlagName = @"SH" },
|
||||||
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c4.jpg"
|
||||||
|
}, api.IsLoggedIn));
|
||||||
|
|
||||||
AddStep("Hide", profile.Hide);
|
AddStep("Hide", profile.Hide);
|
||||||
AddStep("Show without reload", profile.Show);
|
AddStep("Show without reload", profile.Show);
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,353 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test keyboard traversal
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestTraversal()
|
||||||
|
{
|
||||||
|
loadBeatmaps();
|
||||||
|
|
||||||
|
advanceSelection(direction: 1, diff: false);
|
||||||
|
waitForSelection(1, 1);
|
||||||
|
|
||||||
|
advanceSelection(direction: 1, diff: true);
|
||||||
|
waitForSelection(1, 2);
|
||||||
|
|
||||||
|
advanceSelection(direction: -1, diff: false);
|
||||||
|
waitForSelection(set_count, 1);
|
||||||
|
|
||||||
|
advanceSelection(direction: -1, diff: true);
|
||||||
|
waitForSelection(set_count - 1, 3);
|
||||||
|
|
||||||
|
advanceSelection(diff: false);
|
||||||
|
advanceSelection(diff: false);
|
||||||
|
waitForSelection(1, 2);
|
||||||
|
|
||||||
|
advanceSelection(direction: -1, diff: true);
|
||||||
|
advanceSelection(direction: -1, diff: true);
|
||||||
|
waitForSelection(set_count, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test filtering
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestFiltering()
|
||||||
|
{
|
||||||
|
loadBeatmaps();
|
||||||
|
|
||||||
|
// basic filtering
|
||||||
|
|
||||||
|
setSelected(1, 1);
|
||||||
|
|
||||||
|
AddStep("Filter", () => carousel.Filter(new FilterCriteria { SearchText = "set #3!" }, false));
|
||||||
|
checkVisibleItemCount(diff: false, count: 1);
|
||||||
|
checkVisibleItemCount(diff: true, count: 3);
|
||||||
|
waitForSelection(3, 1);
|
||||||
|
|
||||||
|
advanceSelection(diff: true, count: 4);
|
||||||
|
waitForSelection(3, 2);
|
||||||
|
|
||||||
|
AddStep("Un-filter (debounce)", () => carousel.Filter(new FilterCriteria()));
|
||||||
|
AddUntilStep("Wait for debounce", () => !carousel.PendingFilterTask);
|
||||||
|
checkVisibleItemCount(diff: false, count: set_count);
|
||||||
|
checkVisibleItemCount(diff: true, count: 3);
|
||||||
|
|
||||||
|
// test filtering some difficulties (and keeping current beatmap set selected).
|
||||||
|
|
||||||
|
setSelected(1, 2);
|
||||||
|
AddStep("Filter some difficulties", () => carousel.Filter(new FilterCriteria { SearchText = "Normal" }, false));
|
||||||
|
waitForSelection(1, 1);
|
||||||
|
|
||||||
|
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
||||||
|
waitForSelection(1, 1);
|
||||||
|
|
||||||
|
AddStep("Filter all", () => carousel.Filter(new FilterCriteria { SearchText = "Dingo" }, false));
|
||||||
|
|
||||||
|
checkVisibleItemCount(false, 0);
|
||||||
|
checkVisibleItemCount(true, 0);
|
||||||
|
AddAssert("Selection is null", () => currentSelection == null);
|
||||||
|
|
||||||
|
advanceSelection(true);
|
||||||
|
AddAssert("Selection is null", () => currentSelection == null);
|
||||||
|
|
||||||
|
advanceSelection(false);
|
||||||
|
AddAssert("Selection is null", () => currentSelection == null);
|
||||||
|
|
||||||
|
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
||||||
|
|
||||||
|
AddAssert("Selection is non-null", () => currentSelection != null);
|
||||||
|
|
||||||
|
setSelected(1, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFilterRange()
|
||||||
|
{
|
||||||
|
loadBeatmaps();
|
||||||
|
|
||||||
|
// buffer the selection
|
||||||
|
setSelected(3, 2);
|
||||||
|
|
||||||
|
setSelected(1, 3);
|
||||||
|
|
||||||
|
AddStep("Apply a range filter", () => carousel.Filter(new FilterCriteria
|
||||||
|
{
|
||||||
|
SearchText = "#3",
|
||||||
|
StarDifficulty = new FilterCriteria.OptionalRange<double>
|
||||||
|
{
|
||||||
|
Min = 2,
|
||||||
|
Max = 5.5,
|
||||||
|
IsLowerInclusive = true
|
||||||
|
}
|
||||||
|
}, false));
|
||||||
|
|
||||||
|
// should reselect the buffered selection.
|
||||||
|
waitForSelection(3, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test random non-repeating algorithm
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestRandom()
|
||||||
|
{
|
||||||
|
loadBeatmaps();
|
||||||
|
|
||||||
|
setSelected(1, 1);
|
||||||
|
|
||||||
|
nextRandom();
|
||||||
|
ensureRandomDidntRepeat();
|
||||||
|
nextRandom();
|
||||||
|
ensureRandomDidntRepeat();
|
||||||
|
nextRandom();
|
||||||
|
ensureRandomDidntRepeat();
|
||||||
|
|
||||||
|
prevRandom();
|
||||||
|
ensureRandomFetchSuccess();
|
||||||
|
prevRandom();
|
||||||
|
ensureRandomFetchSuccess();
|
||||||
|
|
||||||
|
nextRandom();
|
||||||
|
ensureRandomDidntRepeat();
|
||||||
|
nextRandom();
|
||||||
|
ensureRandomDidntRepeat();
|
||||||
|
|
||||||
|
nextRandom();
|
||||||
|
AddAssert("ensure repeat", () => selectedSets.Contains(carousel.SelectedBeatmapSet));
|
||||||
|
|
||||||
|
AddStep("Add set with 100 difficulties", () => carousel.UpdateBeatmapSet(createTestBeatmapSetWithManyDifficulties(set_count + 1)));
|
||||||
|
AddStep("Filter Extra", () => carousel.Filter(new FilterCriteria { SearchText = "Extra 10" }, false));
|
||||||
|
checkInvisibleDifficultiesUnselectable();
|
||||||
|
checkInvisibleDifficultiesUnselectable();
|
||||||
|
checkInvisibleDifficultiesUnselectable();
|
||||||
|
checkInvisibleDifficultiesUnselectable();
|
||||||
|
checkInvisibleDifficultiesUnselectable();
|
||||||
|
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test adding and removing beatmap sets
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestAddRemove()
|
||||||
|
{
|
||||||
|
loadBeatmaps();
|
||||||
|
|
||||||
|
AddStep("Add new set", () => carousel.UpdateBeatmapSet(createTestBeatmapSet(set_count + 1)));
|
||||||
|
AddStep("Add new set", () => carousel.UpdateBeatmapSet(createTestBeatmapSet(set_count + 2)));
|
||||||
|
|
||||||
|
checkVisibleItemCount(false, set_count + 2);
|
||||||
|
|
||||||
|
AddStep("Remove set", () => carousel.RemoveBeatmapSet(createTestBeatmapSet(set_count + 2)));
|
||||||
|
|
||||||
|
checkVisibleItemCount(false, set_count + 1);
|
||||||
|
|
||||||
|
setSelected(set_count + 1, 1);
|
||||||
|
|
||||||
|
AddStep("Remove set", () => carousel.RemoveBeatmapSet(createTestBeatmapSet(set_count + 1)));
|
||||||
|
|
||||||
|
checkVisibleItemCount(false, set_count);
|
||||||
|
|
||||||
|
waitForSelection(set_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test sorting
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestSorting()
|
||||||
|
{
|
||||||
|
loadBeatmaps();
|
||||||
|
|
||||||
|
AddStep("Sort by author", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Author }, false));
|
||||||
|
AddAssert("Check zzzzz is at bottom", () => carousel.BeatmapSets.Last().Metadata.AuthorString == "zzzzz");
|
||||||
|
AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false));
|
||||||
|
AddAssert($"Check #{set_count} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Title.EndsWith($"#{set_count}!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSortingWithFiltered()
|
||||||
|
{
|
||||||
|
List<BeatmapSetInfo> sets = new List<BeatmapSetInfo>();
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
var set = createTestBeatmapSet(i);
|
||||||
|
set.Beatmaps[0].StarDifficulty = 3 - i;
|
||||||
|
set.Beatmaps[2].StarDifficulty = 6 + i;
|
||||||
|
sets.Add(set);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadBeatmaps(sets);
|
||||||
|
|
||||||
|
AddStep("Filter to normal", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty, SearchText = "Normal" }, false));
|
||||||
|
AddAssert("Check first set at end", () => carousel.BeatmapSets.First() == sets.Last());
|
||||||
|
AddAssert("Check last set at start", () => carousel.BeatmapSets.Last() == sets.First());
|
||||||
|
|
||||||
|
AddStep("Filter to insane", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty, SearchText = "Insane" }, false));
|
||||||
|
AddAssert("Check first set at start", () => carousel.BeatmapSets.First() == sets.First());
|
||||||
|
AddAssert("Check last set at end", () => carousel.BeatmapSets.Last() == sets.Last());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRemoveAll()
|
||||||
|
{
|
||||||
|
loadBeatmaps();
|
||||||
|
|
||||||
|
setSelected(2, 1);
|
||||||
|
AddAssert("Selection is non-null", () => currentSelection != null);
|
||||||
|
|
||||||
|
AddStep("Remove selected", () => carousel.RemoveBeatmapSet(carousel.SelectedBeatmapSet));
|
||||||
|
waitForSelection(2);
|
||||||
|
|
||||||
|
AddStep("Remove first", () => carousel.RemoveBeatmapSet(carousel.BeatmapSets.First()));
|
||||||
|
AddStep("Remove first", () => carousel.RemoveBeatmapSet(carousel.BeatmapSets.First()));
|
||||||
|
waitForSelection(1);
|
||||||
|
|
||||||
|
AddUntilStep("Remove all", () =>
|
||||||
|
{
|
||||||
|
if (!carousel.BeatmapSets.Any()) return true;
|
||||||
|
|
||||||
|
carousel.RemoveBeatmapSet(carousel.BeatmapSets.Last());
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
checkNoSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestEmptyTraversal()
|
||||||
|
{
|
||||||
|
loadBeatmaps(new List<BeatmapSetInfo>());
|
||||||
|
|
||||||
|
advanceSelection(direction: 1, diff: false);
|
||||||
|
checkNoSelection();
|
||||||
|
|
||||||
|
advanceSelection(direction: 1, diff: true);
|
||||||
|
checkNoSelection();
|
||||||
|
|
||||||
|
advanceSelection(direction: -1, diff: false);
|
||||||
|
checkNoSelection();
|
||||||
|
|
||||||
|
advanceSelection(direction: -1, diff: true);
|
||||||
|
checkNoSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestHiding()
|
||||||
|
{
|
||||||
|
BeatmapSetInfo hidingSet = createTestBeatmapSet(1);
|
||||||
|
hidingSet.Beatmaps[1].Hidden = true;
|
||||||
|
|
||||||
|
loadBeatmaps(new List<BeatmapSetInfo> { hidingSet });
|
||||||
|
|
||||||
|
setSelected(1, 1);
|
||||||
|
|
||||||
|
checkVisibleItemCount(true, 2);
|
||||||
|
advanceSelection(true);
|
||||||
|
waitForSelection(1, 3);
|
||||||
|
|
||||||
|
setHidden(3);
|
||||||
|
waitForSelection(1, 1);
|
||||||
|
|
||||||
|
setHidden(2, false);
|
||||||
|
advanceSelection(true);
|
||||||
|
waitForSelection(1, 2);
|
||||||
|
|
||||||
|
setHidden(1);
|
||||||
|
waitForSelection(1, 2);
|
||||||
|
|
||||||
|
setHidden(2);
|
||||||
|
checkNoSelection();
|
||||||
|
|
||||||
|
void setHidden(int diff, bool hidden = true)
|
||||||
|
{
|
||||||
|
AddStep((hidden ? "" : "un") + $"hide diff {diff}", () =>
|
||||||
|
{
|
||||||
|
hidingSet.Beatmaps[diff - 1].Hidden = hidden;
|
||||||
|
carousel.UpdateBeatmapSet(hidingSet);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSelectingFilteredRuleset()
|
||||||
|
{
|
||||||
|
var testMixed = createTestBeatmapSet(set_count + 1);
|
||||||
|
AddStep("add mixed ruleset beatmapset", () =>
|
||||||
|
{
|
||||||
|
for (int i = 0; i <= 2; i++)
|
||||||
|
{
|
||||||
|
testMixed.Beatmaps[i].Ruleset = rulesets.AvailableRulesets.ElementAt(i);
|
||||||
|
testMixed.Beatmaps[i].RulesetID = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
carousel.UpdateBeatmapSet(testMixed);
|
||||||
|
});
|
||||||
|
AddStep("filter to ruleset 0", () =>
|
||||||
|
carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(0) }, false));
|
||||||
|
AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testMixed.Beatmaps[1], false));
|
||||||
|
AddAssert("unfiltered beatmap selected", () => carousel.SelectedBeatmap.Equals(testMixed.Beatmaps[0]));
|
||||||
|
|
||||||
|
AddStep("remove mixed set", () =>
|
||||||
|
{
|
||||||
|
carousel.RemoveBeatmapSet(testMixed);
|
||||||
|
testMixed = null;
|
||||||
|
});
|
||||||
|
var testSingle = createTestBeatmapSet(set_count + 2);
|
||||||
|
testSingle.Beatmaps.ForEach(b =>
|
||||||
|
{
|
||||||
|
b.Ruleset = rulesets.AvailableRulesets.ElementAt(1);
|
||||||
|
b.RulesetID = b.Ruleset.ID ?? 1;
|
||||||
|
});
|
||||||
|
AddStep("add single ruleset beatmapset", () => carousel.UpdateBeatmapSet(testSingle));
|
||||||
|
AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testSingle.Beatmaps[0], false));
|
||||||
|
checkNoSelection();
|
||||||
|
AddStep("remove single ruleset set", () => carousel.RemoveBeatmapSet(testSingle));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCarouselRootIsRandom()
|
||||||
|
{
|
||||||
|
List<BeatmapSetInfo> manySets = new List<BeatmapSetInfo>();
|
||||||
|
|
||||||
|
for (int i = 1; i <= 50; i++)
|
||||||
|
manySets.Add(createTestBeatmapSet(i));
|
||||||
|
|
||||||
|
loadBeatmaps(manySets);
|
||||||
|
|
||||||
|
advanceSelection(direction: 1, diff: false);
|
||||||
|
checkNonmatchingFilter();
|
||||||
|
checkNonmatchingFilter();
|
||||||
|
checkNonmatchingFilter();
|
||||||
|
checkNonmatchingFilter();
|
||||||
|
checkNonmatchingFilter();
|
||||||
|
AddAssert("Selection was random", () => eagerSelectedIDs.Count > 1);
|
||||||
|
}
|
||||||
|
|
||||||
private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets = null)
|
private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets = null)
|
||||||
{
|
{
|
||||||
if (beatmapSets == null)
|
if (beatmapSets == null)
|
||||||
@ -82,8 +429,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
private void ensureRandomFetchSuccess() =>
|
private void ensureRandomFetchSuccess() =>
|
||||||
AddAssert("ensure prev random fetch worked", () => selectedSets.Peek() == carousel.SelectedBeatmapSet);
|
AddAssert("ensure prev random fetch worked", () => selectedSets.Peek() == carousel.SelectedBeatmapSet);
|
||||||
|
|
||||||
private void checkSelected(int set, int? diff = null) =>
|
private void waitForSelection(int set, int? diff = null) =>
|
||||||
AddAssert($"selected is set{set}{(diff.HasValue ? $" diff{diff.Value}" : "")}", () =>
|
AddUntilStep($"selected is set{set}{(diff.HasValue ? $" diff{diff.Value}" : "")}", () =>
|
||||||
{
|
{
|
||||||
if (diff != null)
|
if (diff != null)
|
||||||
return carousel.SelectedBeatmap == carousel.BeatmapSets.Skip(set - 1).First().Beatmaps.Skip(diff.Value - 1).First();
|
return carousel.SelectedBeatmap == carousel.BeatmapSets.Skip(set - 1).First().Beatmaps.Skip(diff.Value - 1).First();
|
||||||
@ -159,317 +506,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Test keyboard traversal
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void TestTraversal()
|
|
||||||
{
|
|
||||||
loadBeatmaps();
|
|
||||||
|
|
||||||
advanceSelection(direction: 1, diff: false);
|
|
||||||
checkSelected(1, 1);
|
|
||||||
|
|
||||||
advanceSelection(direction: 1, diff: true);
|
|
||||||
checkSelected(1, 2);
|
|
||||||
|
|
||||||
advanceSelection(direction: -1, diff: false);
|
|
||||||
checkSelected(set_count, 1);
|
|
||||||
|
|
||||||
advanceSelection(direction: -1, diff: true);
|
|
||||||
checkSelected(set_count - 1, 3);
|
|
||||||
|
|
||||||
advanceSelection(diff: false);
|
|
||||||
advanceSelection(diff: false);
|
|
||||||
checkSelected(1, 2);
|
|
||||||
|
|
||||||
advanceSelection(direction: -1, diff: true);
|
|
||||||
advanceSelection(direction: -1, diff: true);
|
|
||||||
checkSelected(set_count, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Test filtering
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void TestFiltering()
|
|
||||||
{
|
|
||||||
loadBeatmaps();
|
|
||||||
|
|
||||||
// basic filtering
|
|
||||||
|
|
||||||
setSelected(1, 1);
|
|
||||||
|
|
||||||
AddStep("Filter", () => carousel.Filter(new FilterCriteria { SearchText = "set #3!" }, false));
|
|
||||||
checkVisibleItemCount(diff: false, count: 1);
|
|
||||||
checkVisibleItemCount(diff: true, count: 3);
|
|
||||||
checkSelected(3, 1);
|
|
||||||
|
|
||||||
advanceSelection(diff: true, count: 4);
|
|
||||||
checkSelected(3, 2);
|
|
||||||
|
|
||||||
AddStep("Un-filter (debounce)", () => carousel.Filter(new FilterCriteria()));
|
|
||||||
AddUntilStep("Wait for debounce", () => !carousel.PendingFilterTask);
|
|
||||||
checkVisibleItemCount(diff: false, count: set_count);
|
|
||||||
checkVisibleItemCount(diff: true, count: 3);
|
|
||||||
|
|
||||||
// test filtering some difficulties (and keeping current beatmap set selected).
|
|
||||||
|
|
||||||
setSelected(1, 2);
|
|
||||||
AddStep("Filter some difficulties", () => carousel.Filter(new FilterCriteria { SearchText = "Normal" }, false));
|
|
||||||
checkSelected(1, 1);
|
|
||||||
|
|
||||||
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
|
||||||
checkSelected(1, 1);
|
|
||||||
|
|
||||||
AddStep("Filter all", () => carousel.Filter(new FilterCriteria { SearchText = "Dingo" }, false));
|
|
||||||
|
|
||||||
checkVisibleItemCount(false, 0);
|
|
||||||
checkVisibleItemCount(true, 0);
|
|
||||||
AddAssert("Selection is null", () => currentSelection == null);
|
|
||||||
|
|
||||||
advanceSelection(true);
|
|
||||||
AddAssert("Selection is null", () => currentSelection == null);
|
|
||||||
|
|
||||||
advanceSelection(false);
|
|
||||||
AddAssert("Selection is null", () => currentSelection == null);
|
|
||||||
|
|
||||||
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
|
||||||
|
|
||||||
AddAssert("Selection is non-null", () => currentSelection != null);
|
|
||||||
|
|
||||||
setSelected(1, 3);
|
|
||||||
AddStep("Apply a range filter", () => carousel.Filter(new FilterCriteria
|
|
||||||
{
|
|
||||||
SearchText = "#3",
|
|
||||||
StarDifficulty = new FilterCriteria.OptionalRange<double>
|
|
||||||
{
|
|
||||||
Min = 2,
|
|
||||||
Max = 5.5,
|
|
||||||
IsLowerInclusive = true
|
|
||||||
}
|
|
||||||
}, false));
|
|
||||||
checkSelected(3, 2);
|
|
||||||
|
|
||||||
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Test random non-repeating algorithm
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void TestRandom()
|
|
||||||
{
|
|
||||||
loadBeatmaps();
|
|
||||||
|
|
||||||
setSelected(1, 1);
|
|
||||||
|
|
||||||
nextRandom();
|
|
||||||
ensureRandomDidntRepeat();
|
|
||||||
nextRandom();
|
|
||||||
ensureRandomDidntRepeat();
|
|
||||||
nextRandom();
|
|
||||||
ensureRandomDidntRepeat();
|
|
||||||
|
|
||||||
prevRandom();
|
|
||||||
ensureRandomFetchSuccess();
|
|
||||||
prevRandom();
|
|
||||||
ensureRandomFetchSuccess();
|
|
||||||
|
|
||||||
nextRandom();
|
|
||||||
ensureRandomDidntRepeat();
|
|
||||||
nextRandom();
|
|
||||||
ensureRandomDidntRepeat();
|
|
||||||
|
|
||||||
nextRandom();
|
|
||||||
AddAssert("ensure repeat", () => selectedSets.Contains(carousel.SelectedBeatmapSet));
|
|
||||||
|
|
||||||
AddStep("Add set with 100 difficulties", () => carousel.UpdateBeatmapSet(createTestBeatmapSetWithManyDifficulties(set_count + 1)));
|
|
||||||
AddStep("Filter Extra", () => carousel.Filter(new FilterCriteria { SearchText = "Extra 10" }, false));
|
|
||||||
checkInvisibleDifficultiesUnselectable();
|
|
||||||
checkInvisibleDifficultiesUnselectable();
|
|
||||||
checkInvisibleDifficultiesUnselectable();
|
|
||||||
checkInvisibleDifficultiesUnselectable();
|
|
||||||
checkInvisibleDifficultiesUnselectable();
|
|
||||||
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Test adding and removing beatmap sets
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void TestAddRemove()
|
|
||||||
{
|
|
||||||
loadBeatmaps();
|
|
||||||
|
|
||||||
AddStep("Add new set", () => carousel.UpdateBeatmapSet(createTestBeatmapSet(set_count + 1)));
|
|
||||||
AddStep("Add new set", () => carousel.UpdateBeatmapSet(createTestBeatmapSet(set_count + 2)));
|
|
||||||
|
|
||||||
checkVisibleItemCount(false, set_count + 2);
|
|
||||||
|
|
||||||
AddStep("Remove set", () => carousel.RemoveBeatmapSet(createTestBeatmapSet(set_count + 2)));
|
|
||||||
|
|
||||||
checkVisibleItemCount(false, set_count + 1);
|
|
||||||
|
|
||||||
setSelected(set_count + 1, 1);
|
|
||||||
|
|
||||||
AddStep("Remove set", () => carousel.RemoveBeatmapSet(createTestBeatmapSet(set_count + 1)));
|
|
||||||
|
|
||||||
checkVisibleItemCount(false, set_count);
|
|
||||||
|
|
||||||
checkSelected(set_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Test sorting
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void TestSorting()
|
|
||||||
{
|
|
||||||
loadBeatmaps();
|
|
||||||
|
|
||||||
AddStep("Sort by author", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Author }, false));
|
|
||||||
AddAssert("Check zzzzz is at bottom", () => carousel.BeatmapSets.Last().Metadata.AuthorString == "zzzzz");
|
|
||||||
AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false));
|
|
||||||
AddAssert($"Check #{set_count} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Title.EndsWith($"#{set_count}!"));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestRemoveAll()
|
|
||||||
{
|
|
||||||
loadBeatmaps();
|
|
||||||
|
|
||||||
setSelected(2, 1);
|
|
||||||
AddAssert("Selection is non-null", () => currentSelection != null);
|
|
||||||
|
|
||||||
AddStep("Remove selected", () => carousel.RemoveBeatmapSet(carousel.SelectedBeatmapSet));
|
|
||||||
checkSelected(2);
|
|
||||||
|
|
||||||
AddStep("Remove first", () => carousel.RemoveBeatmapSet(carousel.BeatmapSets.First()));
|
|
||||||
AddStep("Remove first", () => carousel.RemoveBeatmapSet(carousel.BeatmapSets.First()));
|
|
||||||
checkSelected(1);
|
|
||||||
|
|
||||||
AddUntilStep("Remove all", () =>
|
|
||||||
{
|
|
||||||
if (!carousel.BeatmapSets.Any()) return true;
|
|
||||||
|
|
||||||
carousel.RemoveBeatmapSet(carousel.BeatmapSets.Last());
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
checkNoSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestEmptyTraversal()
|
|
||||||
{
|
|
||||||
loadBeatmaps(new List<BeatmapSetInfo>());
|
|
||||||
|
|
||||||
advanceSelection(direction: 1, diff: false);
|
|
||||||
checkNoSelection();
|
|
||||||
|
|
||||||
advanceSelection(direction: 1, diff: true);
|
|
||||||
checkNoSelection();
|
|
||||||
|
|
||||||
advanceSelection(direction: -1, diff: false);
|
|
||||||
checkNoSelection();
|
|
||||||
|
|
||||||
advanceSelection(direction: -1, diff: true);
|
|
||||||
checkNoSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestHiding()
|
|
||||||
{
|
|
||||||
BeatmapSetInfo hidingSet = createTestBeatmapSet(1);
|
|
||||||
hidingSet.Beatmaps[1].Hidden = true;
|
|
||||||
|
|
||||||
loadBeatmaps(new List<BeatmapSetInfo> { hidingSet });
|
|
||||||
|
|
||||||
setSelected(1, 1);
|
|
||||||
|
|
||||||
checkVisibleItemCount(true, 2);
|
|
||||||
advanceSelection(true);
|
|
||||||
checkSelected(1, 3);
|
|
||||||
|
|
||||||
setHidden(3);
|
|
||||||
checkSelected(1, 1);
|
|
||||||
|
|
||||||
setHidden(2, false);
|
|
||||||
advanceSelection(true);
|
|
||||||
checkSelected(1, 2);
|
|
||||||
|
|
||||||
setHidden(1);
|
|
||||||
checkSelected(1, 2);
|
|
||||||
|
|
||||||
setHidden(2);
|
|
||||||
checkNoSelection();
|
|
||||||
|
|
||||||
void setHidden(int diff, bool hidden = true)
|
|
||||||
{
|
|
||||||
AddStep((hidden ? "" : "un") + $"hide diff {diff}", () =>
|
|
||||||
{
|
|
||||||
hidingSet.Beatmaps[diff - 1].Hidden = hidden;
|
|
||||||
carousel.UpdateBeatmapSet(hidingSet);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestSelectingFilteredRuleset()
|
|
||||||
{
|
|
||||||
var testMixed = createTestBeatmapSet(set_count + 1);
|
|
||||||
AddStep("add mixed ruleset beatmapset", () =>
|
|
||||||
{
|
|
||||||
for (int i = 0; i <= 2; i++)
|
|
||||||
{
|
|
||||||
testMixed.Beatmaps[i].Ruleset = rulesets.AvailableRulesets.ElementAt(i);
|
|
||||||
testMixed.Beatmaps[i].RulesetID = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
carousel.UpdateBeatmapSet(testMixed);
|
|
||||||
});
|
|
||||||
AddStep("filter to ruleset 0", () =>
|
|
||||||
carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(0) }, false));
|
|
||||||
AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testMixed.Beatmaps[1], false));
|
|
||||||
AddAssert("unfiltered beatmap selected", () => carousel.SelectedBeatmap.Equals(testMixed.Beatmaps[0]));
|
|
||||||
|
|
||||||
AddStep("remove mixed set", () =>
|
|
||||||
{
|
|
||||||
carousel.RemoveBeatmapSet(testMixed);
|
|
||||||
testMixed = null;
|
|
||||||
});
|
|
||||||
var testSingle = createTestBeatmapSet(set_count + 2);
|
|
||||||
testSingle.Beatmaps.ForEach(b =>
|
|
||||||
{
|
|
||||||
b.Ruleset = rulesets.AvailableRulesets.ElementAt(1);
|
|
||||||
b.RulesetID = b.Ruleset.ID ?? 1;
|
|
||||||
});
|
|
||||||
AddStep("add single ruleset beatmapset", () => carousel.UpdateBeatmapSet(testSingle));
|
|
||||||
AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testSingle.Beatmaps[0], false));
|
|
||||||
checkNoSelection();
|
|
||||||
AddStep("remove single ruleset set", () => carousel.RemoveBeatmapSet(testSingle));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestCarouselRootIsRandom()
|
|
||||||
{
|
|
||||||
List<BeatmapSetInfo> manySets = new List<BeatmapSetInfo>();
|
|
||||||
|
|
||||||
for (int i = 1; i <= 50; i++)
|
|
||||||
manySets.Add(createTestBeatmapSet(i));
|
|
||||||
|
|
||||||
loadBeatmaps(manySets);
|
|
||||||
|
|
||||||
advanceSelection(direction: 1, diff: false);
|
|
||||||
checkNonmatchingFilter();
|
|
||||||
checkNonmatchingFilter();
|
|
||||||
checkNonmatchingFilter();
|
|
||||||
checkNonmatchingFilter();
|
|
||||||
checkNonmatchingFilter();
|
|
||||||
AddAssert("Selection was random", () => eagerSelectedIDs.Count > 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private BeatmapSetInfo createTestBeatmapSet(int id)
|
private BeatmapSetInfo createTestBeatmapSet(int id)
|
||||||
{
|
{
|
||||||
return new BeatmapSetInfo
|
return new BeatmapSetInfo
|
||||||
|
@ -75,7 +75,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
testBeatmapLabels(instance);
|
testBeatmapLabels(instance);
|
||||||
|
|
||||||
// TODO: adjust cases once more info is shown for other gamemodes
|
|
||||||
switch (instance)
|
switch (instance)
|
||||||
{
|
{
|
||||||
case OsuRuleset _:
|
case OsuRuleset _:
|
||||||
@ -99,8 +98,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testNullBeatmap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testBeatmapLabels(Ruleset ruleset)
|
private void testBeatmapLabels(Ruleset ruleset)
|
||||||
@ -117,7 +114,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddAssert("check info labels count", () => infoWedge.Info.InfoLabelContainer.Children.Count == expectedCount);
|
AddAssert("check info labels count", () => infoWedge.Info.InfoLabelContainer.Children.Count == expectedCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testNullBeatmap()
|
[Test]
|
||||||
|
public void TestNullBeatmap()
|
||||||
{
|
{
|
||||||
selectBeatmap(null);
|
selectBeatmap(null);
|
||||||
AddAssert("check empty version", () => string.IsNullOrEmpty(infoWedge.Info.VersionLabel.Text));
|
AddAssert("check empty version", () => string.IsNullOrEmpty(infoWedge.Info.VersionLabel.Text));
|
||||||
@ -127,6 +125,12 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddAssert("check no info labels", () => !infoWedge.Info.InfoLabelContainer.Children.Any());
|
AddAssert("check no info labels", () => !infoWedge.Info.InfoLabelContainer.Children.Any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestTruncation()
|
||||||
|
{
|
||||||
|
selectBeatmap(createLongMetadata());
|
||||||
|
}
|
||||||
|
|
||||||
private void selectBeatmap([CanBeNull] IBeatmap b)
|
private void selectBeatmap([CanBeNull] IBeatmap b)
|
||||||
{
|
{
|
||||||
BeatmapInfoWedge.BufferedWedgeInfo infoBefore = null;
|
BeatmapInfoWedge.BufferedWedgeInfo infoBefore = null;
|
||||||
@ -166,6 +170,25 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IBeatmap createLongMetadata()
|
||||||
|
{
|
||||||
|
return new Beatmap
|
||||||
|
{
|
||||||
|
BeatmapInfo = new BeatmapInfo
|
||||||
|
{
|
||||||
|
Metadata = new BeatmapMetadata
|
||||||
|
{
|
||||||
|
AuthorString = "WWWWWWWWWWWWWWW",
|
||||||
|
Artist = "Verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long Artist",
|
||||||
|
Source = "Verrrrry long Source",
|
||||||
|
Title = "Verrrrry long Title"
|
||||||
|
},
|
||||||
|
Version = "Verrrrrrrrrrrrrrrrrrrrrrrrrrrrry long Version",
|
||||||
|
Status = BeatmapSetOnlineStatus.Graveyard,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private class TestBeatmapInfoWedge : BeatmapInfoWedge
|
private class TestBeatmapInfoWedge : BeatmapInfoWedge
|
||||||
{
|
{
|
||||||
public new BufferedWedgeInfo Info => base.Info;
|
public new BufferedWedgeInfo Info => base.Info;
|
||||||
|
@ -18,8 +18,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
overlay.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, Color4.Purple, null, Key.Number1);
|
overlay.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, Color4.Purple, null, Key.Number1);
|
||||||
overlay.AddButton(@"Clear", @"local scores", FontAwesome.Solid.Eraser, Color4.Purple, null, Key.Number2);
|
overlay.AddButton(@"Clear", @"local scores", FontAwesome.Solid.Eraser, Color4.Purple, null, Key.Number2);
|
||||||
overlay.AddButton(@"Edit", @"Beatmap", FontAwesome.Solid.PencilAlt, Color4.Yellow, null, Key.Number3);
|
overlay.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, Color4.Pink, null, Key.Number3);
|
||||||
overlay.AddButton(@"Delete", @"Beatmap", FontAwesome.Solid.Trash, Color4.Pink, null, Key.Number4, float.MaxValue);
|
overlay.AddButton(@"Edit", @"beatmap", FontAwesome.Solid.PencilAlt, Color4.Yellow, null, Key.Number4);
|
||||||
|
|
||||||
Add(overlay);
|
Add(overlay);
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ using osu.Framework.Platform;
|
|||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
@ -34,6 +35,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
|
|
||||||
|
private MusicController music;
|
||||||
|
|
||||||
private WorkingBeatmap defaultBeatmap;
|
private WorkingBeatmap defaultBeatmap;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
@ -79,6 +82,11 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
||||||
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, defaultBeatmap = Beatmap.Default));
|
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, defaultBeatmap = Beatmap.Default));
|
||||||
|
|
||||||
|
Dependencies.Cache(music = new MusicController());
|
||||||
|
|
||||||
|
// required to get bindables attached
|
||||||
|
Add(music);
|
||||||
|
|
||||||
Beatmap.SetDefault();
|
Beatmap.SetDefault();
|
||||||
|
|
||||||
Dependencies.Cache(config = new OsuConfigManager(LocalStorage));
|
Dependencies.Cache(config = new OsuConfigManager(LocalStorage));
|
||||||
@ -93,6 +101,57 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
manager?.Delete(manager.GetAllUsableBeatmapSets());
|
manager?.Delete(manager.GetAllUsableBeatmapSets());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAudioResuming()
|
||||||
|
{
|
||||||
|
createSongSelect();
|
||||||
|
|
||||||
|
addRulesetImportStep(0);
|
||||||
|
addRulesetImportStep(0);
|
||||||
|
|
||||||
|
checkMusicPlaying(true);
|
||||||
|
AddStep("select first", () => songSelect.Carousel.SelectBeatmap(songSelect.Carousel.BeatmapSets.First().Beatmaps.First()));
|
||||||
|
checkMusicPlaying(true);
|
||||||
|
|
||||||
|
AddStep("manual pause", () => music.TogglePause());
|
||||||
|
checkMusicPlaying(false);
|
||||||
|
AddStep("select next difficulty", () => songSelect.Carousel.SelectNext(skipDifficulties: false));
|
||||||
|
checkMusicPlaying(false);
|
||||||
|
|
||||||
|
AddStep("select next set", () => songSelect.Carousel.SelectNext());
|
||||||
|
checkMusicPlaying(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(false)]
|
||||||
|
[TestCase(true)]
|
||||||
|
public void TestAudioRemainsCorrectOnRulesetChange(bool rulesetsInSameBeatmap)
|
||||||
|
{
|
||||||
|
createSongSelect();
|
||||||
|
|
||||||
|
// start with non-osu! to avoid convert confusion
|
||||||
|
changeRuleset(1);
|
||||||
|
|
||||||
|
if (rulesetsInSameBeatmap)
|
||||||
|
AddStep("import multi-ruleset map", () =>
|
||||||
|
{
|
||||||
|
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.ID != 2).ToArray();
|
||||||
|
manager.Import(createTestBeatmapSet(0, usableRulesets)).Wait();
|
||||||
|
});
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addRulesetImportStep(1);
|
||||||
|
addRulesetImportStep(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
checkMusicPlaying(true);
|
||||||
|
|
||||||
|
AddStep("manual pause", () => music.TogglePause());
|
||||||
|
checkMusicPlaying(false);
|
||||||
|
|
||||||
|
changeRuleset(0);
|
||||||
|
checkMusicPlaying(!rulesetsInSameBeatmap);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDummy()
|
public void TestDummy()
|
||||||
{
|
{
|
||||||
@ -128,12 +187,10 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[Ignore("needs fixing")]
|
|
||||||
public void TestImportUnderDifferentRuleset()
|
public void TestImportUnderDifferentRuleset()
|
||||||
{
|
{
|
||||||
createSongSelect();
|
createSongSelect();
|
||||||
changeRuleset(2);
|
addRulesetImportStep(2);
|
||||||
addRulesetImportStep(0);
|
|
||||||
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmap == null);
|
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmap == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,6 +281,9 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
private static int importId;
|
private static int importId;
|
||||||
private int getImportId() => ++importId;
|
private int getImportId() => ++importId;
|
||||||
|
|
||||||
|
private void checkMusicPlaying(bool playing) =>
|
||||||
|
AddUntilStep($"music {(playing ? "" : "not ")}playing", () => music.IsPlaying == playing);
|
||||||
|
|
||||||
private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.Acronym))}", () => Mods.Value = mods);
|
private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.Acronym))}", () => Mods.Value = mods);
|
||||||
|
|
||||||
private void changeRuleset(int id) => AddStep($"change ruleset to {id}", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == id));
|
private void changeRuleset(int id) => AddStep($"change ruleset to {id}", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == id));
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
// 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.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
|
{
|
||||||
|
public class TestSceneLabelledSwitchButton : OsuTestScene
|
||||||
|
{
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
|
{
|
||||||
|
typeof(LabelledSwitchButton),
|
||||||
|
typeof(SwitchButton)
|
||||||
|
};
|
||||||
|
|
||||||
|
[TestCase(false)]
|
||||||
|
[TestCase(true)]
|
||||||
|
public void TestSwitchButton(bool hasDescription) => createSwitchButton(hasDescription);
|
||||||
|
|
||||||
|
private void createSwitchButton(bool hasDescription = false)
|
||||||
|
{
|
||||||
|
AddStep("create component", () =>
|
||||||
|
{
|
||||||
|
LabelledSwitchButton component;
|
||||||
|
|
||||||
|
Child = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Width = 500,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Child = component = new LabelledSwitchButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
component.Label = "a sample component";
|
||||||
|
component.Description = hasDescription ? "this text describes the component" : string.Empty;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
osu.Game.Tests/Visual/UserInterface/TestSceneSwitchButton.cs
Normal file
44
osu.Game.Tests/Visual/UserInterface/TestSceneSwitchButton.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 NUnit.Framework;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
|
{
|
||||||
|
public class TestSceneSwitchButton : ManualInputManagerTestScene
|
||||||
|
{
|
||||||
|
private SwitchButton switchButton;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup() => Schedule(() =>
|
||||||
|
{
|
||||||
|
Child = switchButton = new SwitchButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestChangeThroughInput()
|
||||||
|
{
|
||||||
|
AddStep("move to switch button", () => InputManager.MoveMouseTo(switchButton));
|
||||||
|
AddStep("click on", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddStep("click off", () => InputManager.Click(MouseButton.Left));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestChangeThroughBindable()
|
||||||
|
{
|
||||||
|
BindableBool bindable = null;
|
||||||
|
|
||||||
|
AddStep("bind bindable", () => switchButton.Current.BindTo(bindable = new BindableBool()));
|
||||||
|
AddStep("toggle bindable", () => bindable.Toggle());
|
||||||
|
AddStep("toggle bindable", () => bindable.Toggle());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user