From 4a5a453c7f442cfddf5a166c260051bf0f0bec39 Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 23 Jul 2018 21:28:56 +0200 Subject: [PATCH 01/61] Create an inital cake buildscript --- .gitignore | 4 + build.cake | 47 +++++++++ build.ps1 | 236 ++++++++++++++++++++++++++++++++++++++++++ build.sh | 117 +++++++++++++++++++++ cake.config | 2 + tools/packages.config | 4 + 6 files changed, 410 insertions(+) create mode 100644 build.cake create mode 100644 build.ps1 create mode 100644 build.sh create mode 100644 cake.config create mode 100644 tools/packages.config diff --git a/.gitignore b/.gitignore index 5138e940ed..be43e1a79c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,10 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs +### Cake ### +tools/* +!tools/packages.config + # Build results bin/[Dd]ebug/ [Dd]ebugPublic/ diff --git a/build.cake b/build.cake new file mode 100644 index 0000000000..ca005279ad --- /dev/null +++ b/build.cake @@ -0,0 +1,47 @@ +#tool Microsoft.TestPlatform.Portable + +/////////////////////////////////////////////////////////////////////////////// +// ARGUMENTS +/////////////////////////////////////////////////////////////////////////////// + +var target = Argument("target", "Test"); +var framework = Argument("framework", "net471"); +var configuration = Argument("configuration", "Debug"); + +var osuDesktop = new FilePath("./osu.Desktop/osu.Desktop.csproj"); + +var testProjects = new [] { + new FilePath("./osu.Game.Tests/osu.Game.Tests.csproj"), + new FilePath("./osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj"), + new FilePath("./osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj"), + new FilePath("./osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj"), + new FilePath("./osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj"), +}; + +/////////////////////////////////////////////////////////////////////////////// +// TASKS +/////////////////////////////////////////////////////////////////////////////// + +Task("Compile") +.Does(() => { + DotNetCoreBuild(osuDesktop.FullPath, new DotNetCoreBuildSettings { + Framework = framework, + Configuration = "Debug" + }); +}); + +Task("CompileTests") +.DoesForEach(testProjects, testProject => { + DotNetCoreBuild(testProject.FullPath, new DotNetCoreBuildSettings { + Framework = framework + }); +}); + + +Task("Test") +.IsDependentOn("CompileTests") +.Does(() => { + VSTest($"./*.Tests/bin/{configuration}/{framework}/**/*Tests.exe"); +}); + +RunTarget(target); \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000000..dc42c4595a --- /dev/null +++ b/build.ps1 @@ -0,0 +1,236 @@ +########################################################################## +# This is the Cake bootstrapper script for PowerShell. +# This file was downloaded from https://github.com/cake-build/resources +# Feel free to change this file to fit your needs. +########################################################################## + +<# + +.SYNOPSIS +This is a Powershell script to bootstrap a Cake build. + +.DESCRIPTION +This Powershell script will download NuGet if missing, restore 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 Experimental +Uses the nightly builds of the Roslyn script engine. +.PARAMETER Mono +Uses the Mono Compiler rather than the Roslyn script engine. +.PARAMETER SkipToolPackageRestore +Skips restoring of packages. +.PARAMETER ScriptArgs +Remaining arguments are added here. + +.LINK +https://cakebuild.net + +#> + +[CmdletBinding()] +Param( + [string]$Script = "build.cake", + [string]$Target, + [string]$Configuration, + [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] + [string]$Verbosity, + [switch]$ShowDescription, + [Alias("WhatIf", "Noop")] + [switch]$DryRun, + [switch]$Experimental, + [switch]$Mono, + [switch]$SkipToolPackageRestore, + [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] + [string[]]$ScriptArgs +) + +[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null +function MD5HashFile([string] $filePath) +{ + if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) + { + return $null + } + + [System.IO.Stream] $file = $null; + [System.Security.Cryptography.MD5] $md5 = $null; + try + { + $md5 = [System.Security.Cryptography.MD5]::Create() + $file = [System.IO.File]::OpenRead($filePath) + return [System.BitConverter]::ToString($md5.ComputeHash($file)) + } + finally + { + if ($file -ne $null) + { + $file.Dispose() + } + } +} + +function GetProxyEnabledWebClient +{ + $wc = New-Object System.Net.WebClient + $proxy = [System.Net.WebRequest]::GetSystemWebProxy() + $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials + $wc.Proxy = $proxy + return $wc +} + +Write-Host "Preparing to run build script..." + +if(!$PSScriptRoot){ + $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent +} + +$TOOLS_DIR = Join-Path $PSScriptRoot "tools" +$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins" +$MODULES_DIR = Join-Path $TOOLS_DIR "Modules" +$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" +$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" +$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" +$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" +$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" +$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config" +$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config" + +# Make sure tools folder exists +if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { + Write-Verbose -Message "Creating tools directory..." + New-Item -Path $TOOLS_DIR -Type directory | out-null +} + +# Make sure that packages.config exist. +if (!(Test-Path $PACKAGES_CONFIG)) { + Write-Verbose -Message "Downloading packages.config..." + try { + $wc = GetProxyEnabledWebClient + $wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) + } catch { + Throw "Could not download packages.config." + } +} + +# Try find NuGet.exe in path if not exists +if (!(Test-Path $NUGET_EXE)) { + Write-Verbose -Message "Trying to find nuget.exe in PATH..." + $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) } + $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 + if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { + Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." + $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName + } +} + +# Try download NuGet.exe if not exists +if (!(Test-Path $NUGET_EXE)) { + Write-Verbose -Message "Downloading NuGet.exe..." + try { + $wc = GetProxyEnabledWebClient + $wc.DownloadFile($NUGET_URL, $NUGET_EXE) + } catch { + Throw "Could not download NuGet.exe." + } +} + +# Save nuget.exe path to environment to be available to child processed +$ENV:NUGET_EXE = $NUGET_EXE + +# Restore tools from NuGet? +if(-Not $SkipToolPackageRestore.IsPresent) { + Push-Location + Set-Location $TOOLS_DIR + + # Check for changes in packages.config and remove installed tools if true. + [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) + if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or + ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { + Write-Verbose -Message "Missing or changed package.config hash..." + Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery | + Remove-Item -Recurse + } + + Write-Verbose -Message "Restoring tools from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occurred while restoring NuGet tools." + } + else + { + $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" + } + Write-Verbose -Message ($NuGetOutput | out-string) + + Pop-Location +} + +# Restore addins from NuGet +if (Test-Path $ADDINS_PACKAGES_CONFIG) { + Push-Location + Set-Location $ADDINS_DIR + + Write-Verbose -Message "Restoring addins from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occurred while restoring NuGet addins." + } + + Write-Verbose -Message ($NuGetOutput | out-string) + + Pop-Location +} + +# Restore modules from NuGet +if (Test-Path $MODULES_PACKAGES_CONFIG) { + Push-Location + Set-Location $MODULES_DIR + + Write-Verbose -Message "Restoring modules from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occurred while restoring NuGet modules." + } + + Write-Verbose -Message ($NuGetOutput | out-string) + + Pop-Location +} + +# Make sure that Cake has been installed. +if (!(Test-Path $CAKE_EXE)) { + Throw "Could not find Cake.exe at $CAKE_EXE" +} + + + +# Build Cake arguments +$cakeArguments = @("$Script"); +if ($Target) { $cakeArguments += "-target=$Target" } +if ($Configuration) { $cakeArguments += "-configuration=$Configuration" } +if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" } +if ($ShowDescription) { $cakeArguments += "-showdescription" } +if ($DryRun) { $cakeArguments += "-dryrun" } +if ($Experimental) { $cakeArguments += "-experimental" } +if ($Mono) { $cakeArguments += "-mono" } +$cakeArguments += $ScriptArgs + +# Start Cake +Write-Host "Running build script..." +&$CAKE_EXE $cakeArguments +exit $LASTEXITCODE diff --git a/build.sh b/build.sh new file mode 100644 index 0000000000..b9e12527f1 --- /dev/null +++ b/build.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash + +########################################################################## +# This is the Cake bootstrapper script for Linux and OS X. +# This file was downloaded from https://github.com/cake-build/resources +# Feel free to change this file to fit your needs. +########################################################################## + +# Define directories. +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +TOOLS_DIR=$SCRIPT_DIR/tools +ADDINS_DIR=$TOOLS_DIR/Addins +MODULES_DIR=$TOOLS_DIR/Modules +NUGET_EXE=$TOOLS_DIR/nuget.exe +CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe +PACKAGES_CONFIG=$TOOLS_DIR/packages.config +PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum +ADDINS_PACKAGES_CONFIG=$ADDINS_DIR/packages.config +MODULES_PACKAGES_CONFIG=$MODULES_DIR/packages.config + +# Define md5sum or md5 depending on Linux/OSX +MD5_EXE= +if [[ "$(uname -s)" == "Darwin" ]]; then + MD5_EXE="md5 -r" +else + MD5_EXE="md5sum" +fi + +# Define default arguments. +SCRIPT="build.cake" +CAKE_ARGUMENTS=() + +# Parse arguments. +for i in "$@"; do + case $1 in + -s|--script) SCRIPT="$2"; shift ;; + --) shift; CAKE_ARGUMENTS+=("$@"); break ;; + *) CAKE_ARGUMENTS+=("$1") ;; + esac + shift +done + +# Make sure the tools folder exist. +if [ ! -d "$TOOLS_DIR" ]; then + mkdir "$TOOLS_DIR" +fi + +# Make sure that packages.config exist. +if [ ! -f "$TOOLS_DIR/packages.config" ]; then + echo "Downloading packages.config..." + curl -Lsfo "$TOOLS_DIR/packages.config" https://cakebuild.net/download/bootstrapper/packages + if [ $? -ne 0 ]; then + echo "An error occurred while downloading packages.config." + exit 1 + fi +fi + +# Download NuGet if it does not exist. +if [ ! -f "$NUGET_EXE" ]; then + echo "Downloading NuGet..." + curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe + if [ $? -ne 0 ]; then + echo "An error occurred while downloading nuget.exe." + exit 1 + fi +fi + +# Restore tools from NuGet. +pushd "$TOOLS_DIR" >/dev/null +if [ ! -f "$PACKAGES_CONFIG_MD5" ] || [ "$( cat "$PACKAGES_CONFIG_MD5" | sed 's/\r$//' )" != "$( $MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' )" ]; then + find . -type d ! -name . ! -name 'Cake.Bakery' | xargs rm -rf +fi + +mono "$NUGET_EXE" install -ExcludeVersion +if [ $? -ne 0 ]; then + echo "Could not restore NuGet tools." + exit 1 +fi + +$MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' >| "$PACKAGES_CONFIG_MD5" + +popd >/dev/null + +# Restore addins from NuGet. +if [ -f "$ADDINS_PACKAGES_CONFIG" ]; then + pushd "$ADDINS_DIR" >/dev/null + + mono "$NUGET_EXE" install -ExcludeVersion + if [ $? -ne 0 ]; then + echo "Could not restore NuGet addins." + exit 1 + fi + + popd >/dev/null +fi + +# Restore modules from NuGet. +if [ -f "$MODULES_PACKAGES_CONFIG" ]; then + pushd "$MODULES_DIR" >/dev/null + + mono "$NUGET_EXE" install -ExcludeVersion + if [ $? -ne 0 ]; then + echo "Could not restore NuGet modules." + exit 1 + fi + + popd >/dev/null +fi + +# Make sure that Cake has been installed. +if [ ! -f "$CAKE_EXE" ]; then + echo "Could not find Cake.exe at '$CAKE_EXE'." + exit 1 +fi + +# Start Cake +exec mono "$CAKE_EXE" $SCRIPT "${CAKE_ARGUMENTS[@]}" diff --git a/cake.config b/cake.config new file mode 100644 index 0000000000..9dbafb5e95 --- /dev/null +++ b/cake.config @@ -0,0 +1,2 @@ +[Nuget] +UseInProcessClient=false \ No newline at end of file diff --git a/tools/packages.config b/tools/packages.config new file mode 100644 index 0000000000..227ecd9e52 --- /dev/null +++ b/tools/packages.config @@ -0,0 +1,4 @@ + + + + From 91ca245c584921864a44f15b9c8934147c53d469 Mon Sep 17 00:00:00 2001 From: miterosan Date: Thu, 26 Jul 2018 03:40:28 +0200 Subject: [PATCH 02/61] Allow testing --- build.cake | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/build.cake b/build.cake index ca005279ad..07d2e7df03 100644 --- a/build.cake +++ b/build.cake @@ -1,22 +1,14 @@ -#tool Microsoft.TestPlatform.Portable - /////////////////////////////////////////////////////////////////////////////// // ARGUMENTS /////////////////////////////////////////////////////////////////////////////// -var target = Argument("target", "Test"); +var target = Argument("target", "Build"); var framework = Argument("framework", "net471"); -var configuration = Argument("configuration", "Debug"); +var configuration = Argument("configuration", "Release"); var osuDesktop = new FilePath("./osu.Desktop/osu.Desktop.csproj"); -var testProjects = new [] { - new FilePath("./osu.Game.Tests/osu.Game.Tests.csproj"), - new FilePath("./osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj"), - new FilePath("./osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj"), - new FilePath("./osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj"), - new FilePath("./osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj"), -}; +var testProjects = GetFiles("**/*.Tests.csproj"); /////////////////////////////////////////////////////////////////////////////// // TASKS @@ -26,22 +18,23 @@ Task("Compile") .Does(() => { DotNetCoreBuild(osuDesktop.FullPath, new DotNetCoreBuildSettings { Framework = framework, - Configuration = "Debug" + Configuration = configuration }); }); -Task("CompileTests") -.DoesForEach(testProjects, testProject => { - DotNetCoreBuild(testProject.FullPath, new DotNetCoreBuildSettings { - Framework = framework - }); -}); - - Task("Test") -.IsDependentOn("CompileTests") -.Does(() => { - VSTest($"./*.Tests/bin/{configuration}/{framework}/**/*Tests.exe"); +.ContinueOnError() +.DoesForEach(testProjects, testProject => { + DotNetCoreTest(testProject.FullPath, new DotNetCoreTestSettings {3 + Framework = framework, + Configuration = configuration, + Logger = $"trx;LogFileName={testProject.GetFilename()}.trx", + ResultsDirectory = "./TestResults/" + }); }); +Task("Build") +.IsDependentOn("Compile") +.IsDependentOn("Test"); + RunTarget(target); \ No newline at end of file From 6a661d1766e473e0a013cafe5b227a7723f59a59 Mon Sep 17 00:00:00 2001 From: miterosan Date: Sun, 29 Jul 2018 20:49:26 +0200 Subject: [PATCH 03/61] Prepare inspect code --- build.cake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build.cake b/build.cake index 07d2e7df03..98ad292d7b 100644 --- a/build.cake +++ b/build.cake @@ -1,3 +1,5 @@ +#tool "nuget:?package=JetBrains.ReSharper.CommandLineTools" + /////////////////////////////////////////////////////////////////////////////// // ARGUMENTS /////////////////////////////////////////////////////////////////////////////// @@ -25,7 +27,7 @@ Task("Compile") Task("Test") .ContinueOnError() .DoesForEach(testProjects, testProject => { - DotNetCoreTest(testProject.FullPath, new DotNetCoreTestSettings {3 + DotNetCoreTest(testProject.FullPath, new DotNetCoreTestSettings { Framework = framework, Configuration = configuration, Logger = $"trx;LogFileName={testProject.GetFilename()}.trx", @@ -33,6 +35,11 @@ Task("Test") }); }); +Task("InspectCode") +.Does(() => { + +}); + Task("Build") .IsDependentOn("Compile") .IsDependentOn("Test"); From aef824b13dda77cad2c27946106a8b87e24a3df3 Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 30 Jul 2018 02:12:39 +0200 Subject: [PATCH 04/61] Also analyze the code for spaces and warnings. --- .gitignore | 1 + appveyor.yml | 22 +++------------------- build.cake | 22 ++++++++++++++++++++-- cake.config | 2 -- inspectcodereport.xml | 18 ++++++++++++++++++ 5 files changed, 42 insertions(+), 23 deletions(-) delete mode 100644 cake.config create mode 100644 inspectcodereport.xml diff --git a/.gitignore b/.gitignore index be43e1a79c..26a8752b66 100644 --- a/.gitignore +++ b/.gitignore @@ -102,6 +102,7 @@ $tf/ _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user +inspectcode # JustCode is a .NET coding add-in .JustCode diff --git a/appveyor.yml b/appveyor.yml index 7c08eb9e9c..68c6725d0c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,24 +1,8 @@ clone_depth: 1 version: '{branch}-{build}' image: Visual Studio 2017 -configuration: Debug -cache: - - C:\ProgramData\chocolatey\bin -> appveyor.yml - - C:\ProgramData\chocolatey\lib -> appveyor.yml +test: off install: - cmd: git submodule update --init --recursive --depth=5 - - cmd: choco install resharper-clt -y - - cmd: choco install nvika -y - - cmd: appveyor DownloadFile https://github.com/peppy/CodeFileSanity/releases/download/v0.2.5/CodeFileSanity.exe -before_build: - - cmd: CodeFileSanity.exe - - cmd: nuget restore -verbosity quiet -environment: - TargetFramework: net471 -build: - project: osu.sln - parallel: true - verbosity: minimal -after_build: - - cmd: inspectcode --o="inspectcodereport.xml" --projects:osu.Game* --caches-home="inspectcode" osu.sln > NUL - - cmd: NVika parsereport "inspectcodereport.xml" --treatwarningsaserrors +build_script: +- cmd: PowerShell -Version 2.0 .\build.ps1 diff --git a/build.cake b/build.cake index 98ad292d7b..6d11aade77 100644 --- a/build.cake +++ b/build.cake @@ -1,4 +1,7 @@ #tool "nuget:?package=JetBrains.ReSharper.CommandLineTools" +#tool "nuget:?package=NVika.MSBuild" +var NVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); +var CodeFileSanityToolPath = DownloadFile("https://github.com/peppy/CodeFileSanity/releases/download/v0.2.5/CodeFileSanity.exe"); /////////////////////////////////////////////////////////////////////////////// // ARGUMENTS @@ -9,7 +12,7 @@ var framework = Argument("framework", "net471"); var configuration = Argument("configuration", "Release"); var osuDesktop = new FilePath("./osu.Desktop/osu.Desktop.csproj"); - +var osuSolution = new FilePath("./osu.sln"); var testProjects = GetFiles("**/*.Tests.csproj"); /////////////////////////////////////////////////////////////////////////////// @@ -37,11 +40,26 @@ Task("Test") Task("InspectCode") .Does(() => { - + InspectCode(osuSolution, new InspectCodeSettings { + CachesHome = "inspectcode", + OutputFile = "inspectcodereport.xml", + }); + + StartProcess(NVikaToolPath, @"parsereport ""inspectcodereport.xml"" --treatwarningsaserrors"); +}); + +Task("CodeFileSanity") +.Does(() => { + var result = StartProcess(CodeFileSanityToolPath); + + if (result != 0) + throw new Exception("Code sanity failed."); }); Task("Build") +.IsDependentOn("CodeFileSanity") .IsDependentOn("Compile") +.IsDependentOn("InspectCode") .IsDependentOn("Test"); RunTarget(target); \ No newline at end of file diff --git a/cake.config b/cake.config deleted file mode 100644 index 9dbafb5e95..0000000000 --- a/cake.config +++ /dev/null @@ -1,2 +0,0 @@ -[Nuget] -UseInProcessClient=false \ No newline at end of file diff --git a/inspectcodereport.xml b/inspectcodereport.xml new file mode 100644 index 0000000000..f4b531f547 --- /dev/null +++ b/inspectcodereport.xml @@ -0,0 +1,18 @@ + + + + + osu.sln + + Solution + + + + + + + + + + + \ No newline at end of file From 8652c48c1801421fbe65369322d1845551198ce3 Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 30 Jul 2018 02:23:31 +0200 Subject: [PATCH 05/61] Restore nuget before analyzing the binaries. --- build.cake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.cake b/build.cake index 6d11aade77..304037f486 100644 --- a/build.cake +++ b/build.cake @@ -38,7 +38,11 @@ Task("Test") }); }); +Task("Restore Nuget") +.Does(() => NuGetRestore(osuSolution)); + Task("InspectCode") +.IsDependentOn("Restore Nuget") .Does(() => { InspectCode(osuSolution, new InspectCodeSettings { CachesHome = "inspectcode", From 9e477140c1ca3e8c012ea2ca4d805886fcbc0948 Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 30 Jul 2018 21:45:15 +0200 Subject: [PATCH 06/61] Build against netcoreapp2.1 instead of net471 --- build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cake b/build.cake index 304037f486..6f512b8628 100644 --- a/build.cake +++ b/build.cake @@ -8,7 +8,7 @@ var CodeFileSanityToolPath = DownloadFile("https://github.com/peppy/CodeFileSani /////////////////////////////////////////////////////////////////////////////// var target = Argument("target", "Build"); -var framework = Argument("framework", "net471"); +var framework = Argument("framework", "netcoreapp2.1"); var configuration = Argument("configuration", "Release"); var osuDesktop = new FilePath("./osu.Desktop/osu.Desktop.csproj"); From 1b779dae779a469f80d42cbe91c903e0a2bd562c Mon Sep 17 00:00:00 2001 From: miterosan Date: Sat, 4 Aug 2018 00:01:17 +0200 Subject: [PATCH 07/61] Use CodeFileSanity as a cake addin. --- build.cake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build.cake b/build.cake index 6f512b8628..160db5148e 100644 --- a/build.cake +++ b/build.cake @@ -1,7 +1,7 @@ #tool "nuget:?package=JetBrains.ReSharper.CommandLineTools" #tool "nuget:?package=NVika.MSBuild" +#addin "nuget:?package=CodeFileSanity" var NVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); -var CodeFileSanityToolPath = DownloadFile("https://github.com/peppy/CodeFileSanity/releases/download/v0.2.5/CodeFileSanity.exe"); /////////////////////////////////////////////////////////////////////////////// // ARGUMENTS @@ -54,10 +54,10 @@ Task("InspectCode") Task("CodeFileSanity") .Does(() => { - var result = StartProcess(CodeFileSanityToolPath); - - if (result != 0) - throw new Exception("Code sanity failed."); + ValidateCodeSanity(new ValidateCodeSanitySettings { + RootDirectory = ".", + IsAppveyorBuild = AppVeyor.IsRunningOnAppVeyor + }); }); Task("Build") From 309e74afac74dfb7420e69995e5173ba832389f4 Mon Sep 17 00:00:00 2001 From: miterosan Date: Sat, 4 Aug 2018 00:02:31 +0200 Subject: [PATCH 08/61] Move compile to the correct task. The dotnetcore... commands all contain compiling. --- build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cake b/build.cake index 160db5148e..e945115570 100644 --- a/build.cake +++ b/build.cake @@ -43,6 +43,7 @@ Task("Restore Nuget") Task("InspectCode") .IsDependentOn("Restore Nuget") +.IsDependentOn("Compile") .Does(() => { InspectCode(osuSolution, new InspectCodeSettings { CachesHome = "inspectcode", @@ -62,7 +63,6 @@ Task("CodeFileSanity") Task("Build") .IsDependentOn("CodeFileSanity") -.IsDependentOn("Compile") .IsDependentOn("InspectCode") .IsDependentOn("Test"); From 2ce64104a40a4cdd0554697e74d5201de19c560c Mon Sep 17 00:00:00 2001 From: miterosan Date: Sat, 4 Aug 2018 00:03:03 +0200 Subject: [PATCH 09/61] :V JetBrains.ReSharper.CommandLineTools is an addin and not a tool --- build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cake b/build.cake index e945115570..20b2685351 100644 --- a/build.cake +++ b/build.cake @@ -1,4 +1,4 @@ -#tool "nuget:?package=JetBrains.ReSharper.CommandLineTools" +#addin "nuget:?package=JetBrains.ReSharper.CommandLineTools" #tool "nuget:?package=NVika.MSBuild" #addin "nuget:?package=CodeFileSanity" var NVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); From e69e225ad3332808a0a5b325b7206772f78e2bee Mon Sep 17 00:00:00 2001 From: miterosan Date: Sun, 5 Aug 2018 21:08:11 +0200 Subject: [PATCH 10/61] Use coreclr instead of .framework. --- tools/packages.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/packages.config b/tools/packages.config index 227ecd9e52..e37e9304d5 100644 --- a/tools/packages.config +++ b/tools/packages.config @@ -1,4 +1,4 @@ - + From abe10741e6892344b7691ef7fceaa1f3b2648728 Mon Sep 17 00:00:00 2001 From: miterosan Date: Sun, 5 Aug 2018 21:45:14 +0200 Subject: [PATCH 11/61] Use netcore cake --- build.ps1 | 168 ++---------------------------------------------------- 1 file changed, 5 insertions(+), 163 deletions(-) diff --git a/build.ps1 b/build.ps1 index dc42c4595a..e923331793 100644 --- a/build.ps1 +++ b/build.ps1 @@ -25,12 +25,6 @@ Specifies the amount of information to be displayed. Shows description about tasks. .PARAMETER DryRun Performs a dry run. -.PARAMETER Experimental -Uses the nightly builds of the Roslyn script engine. -.PARAMETER Mono -Uses the Mono Compiler rather than the Roslyn script engine. -.PARAMETER SkipToolPackageRestore -Skips restoring of packages. .PARAMETER ScriptArgs Remaining arguments are added here. @@ -49,47 +43,10 @@ Param( [switch]$ShowDescription, [Alias("WhatIf", "Noop")] [switch]$DryRun, - [switch]$Experimental, - [switch]$Mono, - [switch]$SkipToolPackageRestore, [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] [string[]]$ScriptArgs ) -[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null -function MD5HashFile([string] $filePath) -{ - if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) - { - return $null - } - - [System.IO.Stream] $file = $null; - [System.Security.Cryptography.MD5] $md5 = $null; - try - { - $md5 = [System.Security.Cryptography.MD5]::Create() - $file = [System.IO.File]::OpenRead($filePath) - return [System.BitConverter]::ToString($md5.ComputeHash($file)) - } - finally - { - if ($file -ne $null) - { - $file.Dispose() - } - } -} - -function GetProxyEnabledWebClient -{ - $wc = New-Object System.Net.WebClient - $proxy = [System.Net.WebRequest]::GetSystemWebProxy() - $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials - $wc.Proxy = $proxy - return $wc -} - Write-Host "Preparing to run build script..." if(!$PSScriptRoot){ @@ -97,127 +54,12 @@ if(!$PSScriptRoot){ } $TOOLS_DIR = Join-Path $PSScriptRoot "tools" -$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins" -$MODULES_DIR = Join-Path $TOOLS_DIR "Modules" -$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" -$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" -$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" -$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" -$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config" -$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config" - -# Make sure tools folder exists -if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { - Write-Verbose -Message "Creating tools directory..." - New-Item -Path $TOOLS_DIR -Type directory | out-null -} - -# Make sure that packages.config exist. -if (!(Test-Path $PACKAGES_CONFIG)) { - Write-Verbose -Message "Downloading packages.config..." - try { - $wc = GetProxyEnabledWebClient - $wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) - } catch { - Throw "Could not download packages.config." - } -} - -# Try find NuGet.exe in path if not exists -if (!(Test-Path $NUGET_EXE)) { - Write-Verbose -Message "Trying to find nuget.exe in PATH..." - $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) } - $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 - if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { - Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." - $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName - } -} - -# Try download NuGet.exe if not exists -if (!(Test-Path $NUGET_EXE)) { - Write-Verbose -Message "Downloading NuGet.exe..." - try { - $wc = GetProxyEnabledWebClient - $wc.DownloadFile($NUGET_URL, $NUGET_EXE) - } catch { - Throw "Could not download NuGet.exe." - } -} - -# Save nuget.exe path to environment to be available to child processed -$ENV:NUGET_EXE = $NUGET_EXE - -# Restore tools from NuGet? -if(-Not $SkipToolPackageRestore.IsPresent) { - Push-Location - Set-Location $TOOLS_DIR - - # Check for changes in packages.config and remove installed tools if true. - [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) - if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or - ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { - Write-Verbose -Message "Missing or changed package.config hash..." - Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery | - Remove-Item -Recurse - } - - Write-Verbose -Message "Restoring tools from NuGet..." - $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" - - if ($LASTEXITCODE -ne 0) { - Throw "An error occurred while restoring NuGet tools." - } - else - { - $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" - } - Write-Verbose -Message ($NuGetOutput | out-string) - - Pop-Location -} - -# Restore addins from NuGet -if (Test-Path $ADDINS_PACKAGES_CONFIG) { - Push-Location - Set-Location $ADDINS_DIR - - Write-Verbose -Message "Restoring addins from NuGet..." - $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`"" - - if ($LASTEXITCODE -ne 0) { - Throw "An error occurred while restoring NuGet addins." - } - - Write-Verbose -Message ($NuGetOutput | out-string) - - Pop-Location -} - -# Restore modules from NuGet -if (Test-Path $MODULES_PACKAGES_CONFIG) { - Push-Location - Set-Location $MODULES_DIR - - Write-Verbose -Message "Restoring modules from NuGet..." - $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`"" - - if ($LASTEXITCODE -ne 0) { - Throw "An error occurred while restoring NuGet modules." - } - - Write-Verbose -Message ($NuGetOutput | out-string) - - Pop-Location -} - -# Make sure that Cake has been installed. -if (!(Test-Path $CAKE_EXE)) { - Throw "Could not find Cake.exe at $CAKE_EXE" -} +$CAKE_CSPROJ = Join-Path $TOOLS_DIR "cake.csproj" +Invoke-Expression "dotnet restore `"$CAKE_CSPROJ`" --packages `"$TOOLS_DIR`"" +# Find the Cake executable +$CAKE_EXECUTABLE = (Get-ChildItem -Path ./tools/cake.coreclr/ -Filter Cake.dll -Recurse).FullName # Build Cake arguments $cakeArguments = @("$Script"); @@ -232,5 +74,5 @@ $cakeArguments += $ScriptArgs # Start Cake Write-Host "Running build script..." -&$CAKE_EXE $cakeArguments +Invoke-Expression "dotnet `"$CAKE_EXECUTABLE`" $cakeArguments" exit $LASTEXITCODE From cefabf14d9418a381c9d4956654c02038c528229 Mon Sep 17 00:00:00 2001 From: miterosan Date: Sun, 5 Aug 2018 21:46:28 +0200 Subject: [PATCH 12/61] Linux users can use powershell on, linux --- build.sh | 117 ------------------------------------------------------- 1 file changed, 117 deletions(-) delete mode 100644 build.sh diff --git a/build.sh b/build.sh deleted file mode 100644 index b9e12527f1..0000000000 --- a/build.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env bash - -########################################################################## -# This is the Cake bootstrapper script for Linux and OS X. -# This file was downloaded from https://github.com/cake-build/resources -# Feel free to change this file to fit your needs. -########################################################################## - -# Define directories. -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -TOOLS_DIR=$SCRIPT_DIR/tools -ADDINS_DIR=$TOOLS_DIR/Addins -MODULES_DIR=$TOOLS_DIR/Modules -NUGET_EXE=$TOOLS_DIR/nuget.exe -CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe -PACKAGES_CONFIG=$TOOLS_DIR/packages.config -PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum -ADDINS_PACKAGES_CONFIG=$ADDINS_DIR/packages.config -MODULES_PACKAGES_CONFIG=$MODULES_DIR/packages.config - -# Define md5sum or md5 depending on Linux/OSX -MD5_EXE= -if [[ "$(uname -s)" == "Darwin" ]]; then - MD5_EXE="md5 -r" -else - MD5_EXE="md5sum" -fi - -# Define default arguments. -SCRIPT="build.cake" -CAKE_ARGUMENTS=() - -# Parse arguments. -for i in "$@"; do - case $1 in - -s|--script) SCRIPT="$2"; shift ;; - --) shift; CAKE_ARGUMENTS+=("$@"); break ;; - *) CAKE_ARGUMENTS+=("$1") ;; - esac - shift -done - -# Make sure the tools folder exist. -if [ ! -d "$TOOLS_DIR" ]; then - mkdir "$TOOLS_DIR" -fi - -# Make sure that packages.config exist. -if [ ! -f "$TOOLS_DIR/packages.config" ]; then - echo "Downloading packages.config..." - curl -Lsfo "$TOOLS_DIR/packages.config" https://cakebuild.net/download/bootstrapper/packages - if [ $? -ne 0 ]; then - echo "An error occurred while downloading packages.config." - exit 1 - fi -fi - -# Download NuGet if it does not exist. -if [ ! -f "$NUGET_EXE" ]; then - echo "Downloading NuGet..." - curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe - if [ $? -ne 0 ]; then - echo "An error occurred while downloading nuget.exe." - exit 1 - fi -fi - -# Restore tools from NuGet. -pushd "$TOOLS_DIR" >/dev/null -if [ ! -f "$PACKAGES_CONFIG_MD5" ] || [ "$( cat "$PACKAGES_CONFIG_MD5" | sed 's/\r$//' )" != "$( $MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' )" ]; then - find . -type d ! -name . ! -name 'Cake.Bakery' | xargs rm -rf -fi - -mono "$NUGET_EXE" install -ExcludeVersion -if [ $? -ne 0 ]; then - echo "Could not restore NuGet tools." - exit 1 -fi - -$MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' >| "$PACKAGES_CONFIG_MD5" - -popd >/dev/null - -# Restore addins from NuGet. -if [ -f "$ADDINS_PACKAGES_CONFIG" ]; then - pushd "$ADDINS_DIR" >/dev/null - - mono "$NUGET_EXE" install -ExcludeVersion - if [ $? -ne 0 ]; then - echo "Could not restore NuGet addins." - exit 1 - fi - - popd >/dev/null -fi - -# Restore modules from NuGet. -if [ -f "$MODULES_PACKAGES_CONFIG" ]; then - pushd "$MODULES_DIR" >/dev/null - - mono "$NUGET_EXE" install -ExcludeVersion - if [ $? -ne 0 ]; then - echo "Could not restore NuGet modules." - exit 1 - fi - - popd >/dev/null -fi - -# Make sure that Cake has been installed. -if [ ! -f "$CAKE_EXE" ]; then - echo "Could not find Cake.exe at '$CAKE_EXE'." - exit 1 -fi - -# Start Cake -exec mono "$CAKE_EXE" $SCRIPT "${CAKE_ARGUMENTS[@]}" From fce2be9dc7118db2caa6a32729f9fb709d4f68bd Mon Sep 17 00:00:00 2001 From: miterosan Date: Sun, 5 Aug 2018 22:24:52 +0200 Subject: [PATCH 13/61] Allow running inspect core with cakeclr. Sadly window only because nvika and resharper cmd tools require net45. --- build.cake | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/build.cake b/build.cake index 20b2685351..a341e93a0b 100644 --- a/build.cake +++ b/build.cake @@ -1,7 +1,7 @@ +#addin "nuget:?package=CodeFileSanity" #addin "nuget:?package=JetBrains.ReSharper.CommandLineTools" #tool "nuget:?package=NVika.MSBuild" -#addin "nuget:?package=CodeFileSanity" -var NVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); +#tool "nuget:?package=NuGet.CommandLine" /////////////////////////////////////////////////////////////////////////////// // ARGUMENTS @@ -38,13 +38,17 @@ Task("Test") }); }); -Task("Restore Nuget") -.Does(() => NuGetRestore(osuSolution)); - +// windows only because both inspectcore and nvike depend on net45 +// will be ignored on linux Task("InspectCode") -.IsDependentOn("Restore Nuget") +.WithCriteria(IsRunningOnWindows()) .IsDependentOn("Compile") .Does(() => { + var NVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); + var NugetToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First(); + + StartProcess(NugetToolPath, $"restore {osuSolution}"); + InspectCode(osuSolution, new InspectCodeSettings { CachesHome = "inspectcode", OutputFile = "inspectcodereport.xml", From 90c08a447e4741efaa1f0db6a4285c02bab38655 Mon Sep 17 00:00:00 2001 From: miterosan Date: Sun, 5 Aug 2018 22:26:32 +0200 Subject: [PATCH 14/61] Add inspectcodereport to the gitignore --- .gitignore | 2 ++ inspectcodereport.xml | 18 ------------------ 2 files changed, 2 insertions(+), 18 deletions(-) delete mode 100644 inspectcodereport.xml diff --git a/.gitignore b/.gitignore index 26a8752b66..78986dee1d 100644 --- a/.gitignore +++ b/.gitignore @@ -262,3 +262,5 @@ paket-files/ __pycache__/ *.pyc Staging/ + +inspectcodereport.xml diff --git a/inspectcodereport.xml b/inspectcodereport.xml deleted file mode 100644 index f4b531f547..0000000000 --- a/inspectcodereport.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - osu.sln - - Solution - - - - - - - - - - - \ No newline at end of file From b430cf34e73760e136cebc4f87045826b76557be Mon Sep 17 00:00:00 2001 From: miterosan Date: Sun, 5 Aug 2018 22:27:51 +0200 Subject: [PATCH 15/61] remove unfnished comment. --- build.cake | 1 - 1 file changed, 1 deletion(-) diff --git a/build.cake b/build.cake index a341e93a0b..60219d4fb0 100644 --- a/build.cake +++ b/build.cake @@ -39,7 +39,6 @@ Task("Test") }); // windows only because both inspectcore and nvike depend on net45 -// will be ignored on linux Task("InspectCode") .WithCriteria(IsRunningOnWindows()) .IsDependentOn("Compile") From 580d478dc80bafbbe39eede20ff1e9f6dc234dc6 Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 6 Aug 2018 22:50:23 +0200 Subject: [PATCH 16/61] Allow running on mono if possible. (non windows) --- build.cake | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/build.cake b/build.cake index 60219d4fb0..28c314a41b 100644 --- a/build.cake +++ b/build.cake @@ -1,4 +1,4 @@ -#addin "nuget:?package=CodeFileSanity" +#addin "nuget:http://localhost:8081/repository/hm?package=CodeFileSanity&version=1.0.10" #addin "nuget:?package=JetBrains.ReSharper.CommandLineTools" #tool "nuget:?package=NVika.MSBuild" #tool "nuget:?package=NuGet.CommandLine" @@ -38,24 +38,48 @@ Task("Test") }); }); -// windows only because both inspectcore and nvike depend on net45 Task("InspectCode") -.WithCriteria(IsRunningOnWindows()) .IsDependentOn("Compile") .Does(() => { - var NVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); - var NugetToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First(); + var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); + var nugetToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First(); - StartProcess(NugetToolPath, $"restore {osuSolution}"); + if (!IsRunningOnWindows()) { + RunInpectCodeInMono(nVikaToolPath, nugetToolPath); + return; + } + + StartProcess(nugetToolPath, $"restore {osuSolution}"); InspectCode(osuSolution, new InspectCodeSettings { CachesHome = "inspectcode", OutputFile = "inspectcodereport.xml", }); - StartProcess(NVikaToolPath, @"parsereport ""inspectcodereport.xml"" --treatwarningsaserrors"); + StartProcess(nVikaToolPath, @"parsereport ""inspectcodereport.xml"" --treatwarningsaserrors"); }); +void RunInpectCodeInMono(FilePath nugetToolPath, FilePath nVikaToolPath) { + var inspectcodeToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First(); + + if (!FileExists("mono")) { + Information("Running on an os other than windows and mono is not installed. Skipping InpectCode."); + return; + } + + StartProcess("mono", $"{nugetToolPath} restore {osuSolution}"); + + StartProcess("mono", @"--o=""inspectcodereport.xml"" --caches-home=""inspectcode"" "); + + InspectCode(osuSolution, new InspectCodeSettings { + CachesHome = "inspectcode", + OutputFile = "inspectcodereport.xml", + + }); + + StartProcess("mono", $@"{nVikaToolPath} parsereport ""inspectcodereport.xml"" --treatwarningsaserrors"); +} + Task("CodeFileSanity") .Does(() => { ValidateCodeSanity(new ValidateCodeSanitySettings { From 058a6d9e13b9d91275326fa0508fc776a128df28 Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 6 Aug 2018 23:14:51 +0200 Subject: [PATCH 17/61] Add cake.csproj --- .gitignore | 1 + tools/cake.csproj | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 tools/cake.csproj diff --git a/.gitignore b/.gitignore index 78986dee1d..c75c19f9f5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ ### Cake ### tools/* !tools/packages.config +!tools/cake.csproj # Build results bin/[Dd]ebug/ diff --git a/tools/cake.csproj b/tools/cake.csproj new file mode 100644 index 0000000000..06692627d2 --- /dev/null +++ b/tools/cake.csproj @@ -0,0 +1,9 @@ + + + Exe + netcoreapp2.0 + + + + + \ No newline at end of file From 2b293add9ecfa22d65dbed2d2b22db68a4c04558 Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 6 Aug 2018 23:36:24 +0200 Subject: [PATCH 18/61] Use the correct tool executable. Better mono detection --- build.cake | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/build.cake b/build.cake index 28c314a41b..98add57062 100644 --- a/build.cake +++ b/build.cake @@ -45,7 +45,7 @@ Task("InspectCode") var nugetToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First(); if (!IsRunningOnWindows()) { - RunInpectCodeInMono(nVikaToolPath, nugetToolPath); + RunInpectCodeInMono(nugetToolPath, nVikaToolPath); return; } @@ -62,20 +62,14 @@ Task("InspectCode") void RunInpectCodeInMono(FilePath nugetToolPath, FilePath nVikaToolPath) { var inspectcodeToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First(); - if (!FileExists("mono")) { + if (!StartProcess("mono", "--version") != 0) { Information("Running on an os other than windows and mono is not installed. Skipping InpectCode."); return; } StartProcess("mono", $"{nugetToolPath} restore {osuSolution}"); - StartProcess("mono", @"--o=""inspectcodereport.xml"" --caches-home=""inspectcode"" "); - - InspectCode(osuSolution, new InspectCodeSettings { - CachesHome = "inspectcode", - OutputFile = "inspectcodereport.xml", - - }); + StartProcess("mono", $@"{inspectcodeToolPath} --o=""inspectcodereport.xml"" --caches-home=""inspectcode"" "); StartProcess("mono", $@"{nVikaToolPath} parsereport ""inspectcodereport.xml"" --treatwarningsaserrors"); } From de6c25c052a24beb621a2089a5b1aada6b1d561f Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 6 Aug 2018 23:37:47 +0200 Subject: [PATCH 19/61] rm bad sign --- build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cake b/build.cake index 98add57062..8fdf04d827 100644 --- a/build.cake +++ b/build.cake @@ -62,7 +62,7 @@ Task("InspectCode") void RunInpectCodeInMono(FilePath nugetToolPath, FilePath nVikaToolPath) { var inspectcodeToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First(); - if (!StartProcess("mono", "--version") != 0) { + if (StartProcess("mono", "--version") != 0) { Information("Running on an os other than windows and mono is not installed. Skipping InpectCode."); return; } From 8ed8efd06dea56957f2aabfe690654bcac0a5a1a Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 6 Aug 2018 23:46:08 +0200 Subject: [PATCH 20/61] silent the test for mono --- build.cake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.cake b/build.cake index 8fdf04d827..c52523908f 100644 --- a/build.cake +++ b/build.cake @@ -62,7 +62,12 @@ Task("InspectCode") void RunInpectCodeInMono(FilePath nugetToolPath, FilePath nVikaToolPath) { var inspectcodeToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First(); - if (StartProcess("mono", "--version") != 0) { + var testMonoArguments = new ProcessArgumentBuilder(); + testMonoArguments.AppendSwitch("version", ""); + + if (StartProcess("mono", new ProcessSettings { + Silent = true, Arguments = testMonoArguments } + ) != 0) { Information("Running on an os other than windows and mono is not installed. Skipping InpectCode."); return; } From b98611dd8ffee7db45e4221437661c3637887fd9 Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 6 Aug 2018 23:47:48 +0200 Subject: [PATCH 21/61] minus minus --- build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cake b/build.cake index c52523908f..4c5eb92948 100644 --- a/build.cake +++ b/build.cake @@ -63,7 +63,7 @@ void RunInpectCodeInMono(FilePath nugetToolPath, FilePath nVikaToolPath) { var inspectcodeToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First(); var testMonoArguments = new ProcessArgumentBuilder(); - testMonoArguments.AppendSwitch("version", ""); + testMonoArguments.AppendSwitch("--version", ""); if (StartProcess("mono", new ProcessSettings { Silent = true, Arguments = testMonoArguments } From 7c6ae73be1e82c3a4d5de5fce613ffd1a2273953 Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 6 Aug 2018 23:53:09 +0200 Subject: [PATCH 22/61] adjust the path to the commandline tools --- build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cake b/build.cake index 4c5eb92948..ceebbf3d83 100644 --- a/build.cake +++ b/build.cake @@ -60,7 +60,7 @@ Task("InspectCode") }); void RunInpectCodeInMono(FilePath nugetToolPath, FilePath nVikaToolPath) { - var inspectcodeToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First(); + var inspectcodeToolPath = GetFiles("./tools/Addins/JetBrains.Resharper.CommandLineTools.*/**/inspectcode.exe").First(); var testMonoArguments = new ProcessArgumentBuilder(); testMonoArguments.AppendSwitch("--version", ""); From 1a03ef13f4dd29556c629907902425206d4df135 Mon Sep 17 00:00:00 2001 From: miterosan Date: Tue, 7 Aug 2018 22:36:52 +0200 Subject: [PATCH 23/61] Revert "Allow running on mono if possible. (non windows)" https://youtrack.jetbrains.com/issue/RSRP-410004 This reverts commit 580d478dc80bafbbe39eede20ff1e9f6dc234dc6. --- build.cake | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/build.cake b/build.cake index ceebbf3d83..6a06f843db 100644 --- a/build.cake +++ b/build.cake @@ -1,4 +1,4 @@ -#addin "nuget:http://localhost:8081/repository/hm?package=CodeFileSanity&version=1.0.10" +#addin "nuget:?package=CodeFileSanity" #addin "nuget:?package=JetBrains.ReSharper.CommandLineTools" #tool "nuget:?package=NVika.MSBuild" #tool "nuget:?package=NuGet.CommandLine" @@ -38,17 +38,14 @@ Task("Test") }); }); +// windows only because both inspectcore and nvika depend on net45 Task("InspectCode") +.WithCriteria(IsRunningOnWindows()) .IsDependentOn("Compile") .Does(() => { var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); var nugetToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First(); - if (!IsRunningOnWindows()) { - RunInpectCodeInMono(nugetToolPath, nVikaToolPath); - return; - } - StartProcess(nugetToolPath, $"restore {osuSolution}"); InspectCode(osuSolution, new InspectCodeSettings { @@ -59,26 +56,6 @@ Task("InspectCode") StartProcess(nVikaToolPath, @"parsereport ""inspectcodereport.xml"" --treatwarningsaserrors"); }); -void RunInpectCodeInMono(FilePath nugetToolPath, FilePath nVikaToolPath) { - var inspectcodeToolPath = GetFiles("./tools/Addins/JetBrains.Resharper.CommandLineTools.*/**/inspectcode.exe").First(); - - var testMonoArguments = new ProcessArgumentBuilder(); - testMonoArguments.AppendSwitch("--version", ""); - - if (StartProcess("mono", new ProcessSettings { - Silent = true, Arguments = testMonoArguments } - ) != 0) { - Information("Running on an os other than windows and mono is not installed. Skipping InpectCode."); - return; - } - - StartProcess("mono", $"{nugetToolPath} restore {osuSolution}"); - - StartProcess("mono", $@"{inspectcodeToolPath} --o=""inspectcodereport.xml"" --caches-home=""inspectcode"" "); - - StartProcess("mono", $@"{nVikaToolPath} parsereport ""inspectcodereport.xml"" --treatwarningsaserrors"); -} - Task("CodeFileSanity") .Does(() => { ValidateCodeSanity(new ValidateCodeSanitySettings { From 2763f0be6bbc8fbbbc37878f40b9e1ee55422ff7 Mon Sep 17 00:00:00 2001 From: miterosan Date: Thu, 9 Aug 2018 20:45:34 +0200 Subject: [PATCH 24/61] Remove the usage of windows nuget restore and replace it with dotnet restore --- build.cake | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/build.cake b/build.cake index 6a06f843db..6508150a3b 100644 --- a/build.cake +++ b/build.cake @@ -1,7 +1,6 @@ #addin "nuget:?package=CodeFileSanity" #addin "nuget:?package=JetBrains.ReSharper.CommandLineTools" #tool "nuget:?package=NVika.MSBuild" -#tool "nuget:?package=NuGet.CommandLine" /////////////////////////////////////////////////////////////////////////////// // ARGUMENTS @@ -44,9 +43,8 @@ Task("InspectCode") .IsDependentOn("Compile") .Does(() => { var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); - var nugetToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First(); - - StartProcess(nugetToolPath, $"restore {osuSolution}"); + + DotNetCoreRestore(osuSolution.FullPath); InspectCode(osuSolution, new InspectCodeSettings { CachesHome = "inspectcode", From 399d456edb7e06ccd892fbb66aa03439be208c13 Mon Sep 17 00:00:00 2001 From: miterosan Date: Tue, 11 Sep 2018 21:49:10 +0200 Subject: [PATCH 25/61] Pin the addin and tool versions down. --- build.cake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.cake b/build.cake index 6508150a3b..4f6883cab0 100644 --- a/build.cake +++ b/build.cake @@ -1,6 +1,6 @@ -#addin "nuget:?package=CodeFileSanity" -#addin "nuget:?package=JetBrains.ReSharper.CommandLineTools" -#tool "nuget:?package=NVika.MSBuild" +#addin "nuget:?package=CodeFileSanity&version=0.0.21" +#addin "nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2018.2.2" +#tool "nuget:?package=NVika.MSBuild&version=1.0.1" /////////////////////////////////////////////////////////////////////////////// // ARGUMENTS From 2e91b86e00a47249df5a56f757ed0be0466d78c7 Mon Sep 17 00:00:00 2001 From: miterosan Date: Tue, 11 Sep 2018 22:07:14 +0200 Subject: [PATCH 26/61] Remove Redundant parentheses --- osu.Game/Storyboards/CommandTimeline.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Storyboards/CommandTimeline.cs b/osu.Game/Storyboards/CommandTimeline.cs index 7de0756dbd..8a032064d3 100644 --- a/osu.Game/Storyboards/CommandTimeline.cs +++ b/osu.Game/Storyboards/CommandTimeline.cs @@ -16,10 +16,10 @@ namespace osu.Game.Storyboards public bool HasCommands => commands.Count > 0; private Cached startTimeBacking; - public double StartTime => startTimeBacking.IsValid ? startTimeBacking : (startTimeBacking.Value = HasCommands ? commands.Min(c => c.StartTime) : double.MinValue); + public double StartTime => startTimeBacking.IsValid ? startTimeBacking : startTimeBacking.Value = HasCommands ? commands.Min(c => c.StartTime) : double.MinValue; private Cached endTimeBacking; - public double EndTime => endTimeBacking.IsValid ? endTimeBacking : (endTimeBacking.Value = HasCommands ? commands.Max(c => c.EndTime) : double.MaxValue); + public double EndTime => endTimeBacking.IsValid ? endTimeBacking : endTimeBacking.Value = HasCommands ? commands.Max(c => c.EndTime) : double.MaxValue; public T StartValue => HasCommands ? commands.OrderBy(c => c.StartTime).First().StartValue : default(T); public T EndValue => HasCommands ? commands.OrderByDescending(c => c.EndTime).First().EndValue : default(T); From e20b0849002120c9981312853a68ef8ae9c39821 Mon Sep 17 00:00:00 2001 From: miterosan Date: Tue, 11 Sep 2018 22:11:25 +0200 Subject: [PATCH 27/61] Report the test results to appveyor --- build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cake b/build.cake index 4f6883cab0..7e1f1bdda7 100644 --- a/build.cake +++ b/build.cake @@ -32,7 +32,7 @@ Task("Test") DotNetCoreTest(testProject.FullPath, new DotNetCoreTestSettings { Framework = framework, Configuration = configuration, - Logger = $"trx;LogFileName={testProject.GetFilename()}.trx", + Logger = AppVeyor.IsRunningOnAppVeyor ? "Appveyor" : $"trx;LogFileName={testProject.GetFilename()}.trx", ResultsDirectory = "./TestResults/" }); }); From 03ff695a674787c99ee80a84c3421d2c8ed6c4c0 Mon Sep 17 00:00:00 2001 From: miterosan Date: Sun, 16 Sep 2018 16:25:19 +0200 Subject: [PATCH 28/61] Use Dotnet core VSTest This allows only running one testrun. --- build.cake | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/build.cake b/build.cake index 7e1f1bdda7..6808bb3dfc 100644 --- a/build.cake +++ b/build.cake @@ -12,7 +12,6 @@ var configuration = Argument("configuration", "Release"); var osuDesktop = new FilePath("./osu.Desktop/osu.Desktop.csproj"); var osuSolution = new FilePath("./osu.sln"); -var testProjects = GetFiles("**/*.Tests.csproj"); /////////////////////////////////////////////////////////////////////////////// // TASKS @@ -27,13 +26,13 @@ Task("Compile") }); Task("Test") -.ContinueOnError() -.DoesForEach(testProjects, testProject => { - DotNetCoreTest(testProject.FullPath, new DotNetCoreTestSettings { - Framework = framework, - Configuration = configuration, - Logger = AppVeyor.IsRunningOnAppVeyor ? "Appveyor" : $"trx;LogFileName={testProject.GetFilename()}.trx", - ResultsDirectory = "./TestResults/" +.Does(() => { + var testAssemblies = GetFiles("**/*.Tests/bin/**/*.Tests.dll"); + + DotNetCoreVSTest(testAssemblies, new DotNetCoreVSTestSettings { + Logger = AppVeyor.IsRunningOnAppVeyor ? "Appveyor" : $"trx", + Parallel = true, + ToolTimeout = TimeSpan.FromMinutes(10), }); }); From 0491fd581a4516bf55a1d474de40e893351553cb Mon Sep 17 00:00:00 2001 From: miterosan Date: Sun, 16 Sep 2018 16:25:40 +0200 Subject: [PATCH 29/61] Reduce the verbosity of the Restore. --- build.cake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.cake b/build.cake index 6808bb3dfc..9fd1b33f9b 100644 --- a/build.cake +++ b/build.cake @@ -43,7 +43,9 @@ Task("InspectCode") .Does(() => { var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); - DotNetCoreRestore(osuSolution.FullPath); + DotNetCoreRestore(osuSolution.FullPath, new DotNetCoreRestoreSettings { + Verbosity = DotNetCoreVerbosity.Quiet + }); InspectCode(osuSolution, new InspectCodeSettings { CachesHome = "inspectcode", From ead2e388823dc8afb8272a972e21e2b1b478030c Mon Sep 17 00:00:00 2001 From: miterosan Date: Sun, 16 Sep 2018 16:40:40 +0200 Subject: [PATCH 30/61] Build the projects before testing --- build.cake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.cake b/build.cake index 9fd1b33f9b..b8d84b7be6 100644 --- a/build.cake +++ b/build.cake @@ -10,7 +10,6 @@ var target = Argument("target", "Build"); var framework = Argument("framework", "netcoreapp2.1"); var configuration = Argument("configuration", "Release"); -var osuDesktop = new FilePath("./osu.Desktop/osu.Desktop.csproj"); var osuSolution = new FilePath("./osu.sln"); /////////////////////////////////////////////////////////////////////////////// @@ -19,13 +18,14 @@ var osuSolution = new FilePath("./osu.sln"); Task("Compile") .Does(() => { - DotNetCoreBuild(osuDesktop.FullPath, new DotNetCoreBuildSettings { + DotNetCoreBuild(osuSolution.FullPath, new DotNetCoreBuildSettings { Framework = framework, Configuration = configuration }); }); Task("Test") +.IsDependentOn("Compile") .Does(() => { var testAssemblies = GetFiles("**/*.Tests/bin/**/*.Tests.dll"); From 3870980f3e3f25676670ef6c9d608bac9298f289 Mon Sep 17 00:00:00 2001 From: miterosan Date: Sun, 16 Sep 2018 16:57:53 +0200 Subject: [PATCH 31/61] Seperate the compile from restoring. --- build.cake | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/build.cake b/build.cake index b8d84b7be6..fff39079b6 100644 --- a/build.cake +++ b/build.cake @@ -16,11 +16,17 @@ var osuSolution = new FilePath("./osu.sln"); // TASKS /////////////////////////////////////////////////////////////////////////////// +Task("Restore") +.Does(() => { + DotNetCoreRestore(osuSolution.FullPath); +}); + Task("Compile") +.IsDependentOn("Restore") .Does(() => { DotNetCoreBuild(osuSolution.FullPath, new DotNetCoreBuildSettings { - Framework = framework, - Configuration = configuration + Configuration = configuration, + NoRestore = true, }); }); @@ -42,10 +48,6 @@ Task("InspectCode") .IsDependentOn("Compile") .Does(() => { var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); - - DotNetCoreRestore(osuSolution.FullPath, new DotNetCoreRestoreSettings { - Verbosity = DotNetCoreVerbosity.Quiet - }); InspectCode(osuSolution, new InspectCodeSettings { CachesHome = "inspectcode", From 0724b47334e2e51558b23fbcb3f65cbee13e5243 Mon Sep 17 00:00:00 2001 From: miterosan Date: Thu, 4 Oct 2018 18:57:14 +0200 Subject: [PATCH 32/61] Minify the buildscript and update to cake.0.30.0 Also remove the dependency on Cake.CoreCLR cake.tool does not use the packages.config. --- .gitignore | 3 +-- build.ps1 | 17 +++++++++-------- tools/cake.csproj | 9 --------- tools/cakebuild.csproj | 11 +++++++++++ tools/packages.config | 4 ---- 5 files changed, 21 insertions(+), 23 deletions(-) delete mode 100644 tools/cake.csproj create mode 100644 tools/cakebuild.csproj delete mode 100644 tools/packages.config diff --git a/.gitignore b/.gitignore index c75c19f9f5..8f011deabe 100644 --- a/.gitignore +++ b/.gitignore @@ -12,8 +12,7 @@ ### Cake ### tools/* -!tools/packages.config -!tools/cake.csproj +!tools/cakebuild.csproj # Build results bin/[Dd]ebug/ diff --git a/build.ps1 b/build.ps1 index e923331793..64303e67d5 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,7 +1,5 @@ ########################################################################## -# This is the Cake bootstrapper script for PowerShell. -# This file was downloaded from https://github.com/cake-build/resources -# Feel free to change this file to fit your needs. +# This is a customized Cake bootstrapper script for PowerShell. ########################################################################## <# @@ -10,7 +8,7 @@ This is a Powershell script to bootstrap a Cake build. .DESCRIPTION -This Powershell script will download NuGet if missing, restore NuGet tools (including Cake) +This Powershell script restores NuGet tools (including Cake) and execute your Cake build script with the parameters you provide. .PARAMETER Script @@ -49,17 +47,21 @@ Param( 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. $TOOLS_DIR = Join-Path $PSScriptRoot "tools" -$CAKE_CSPROJ = Join-Path $TOOLS_DIR "cake.csproj" +$CAKE_CSPROJ = Join-Path $TOOLS_DIR "cakebootstrap.csproj" -Invoke-Expression "dotnet restore `"$CAKE_CSPROJ`" --packages `"$TOOLS_DIR`"" +# 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/cake.coreclr/ -Filter Cake.dll -Recurse).FullName +$CAKE_EXECUTABLE = (Get-ChildItem -Path ./tools/cake.tool/ -Filter Cake.dll -Recurse).FullName # Build Cake arguments $cakeArguments = @("$Script"); @@ -69,7 +71,6 @@ if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" } if ($ShowDescription) { $cakeArguments += "-showdescription" } if ($DryRun) { $cakeArguments += "-dryrun" } if ($Experimental) { $cakeArguments += "-experimental" } -if ($Mono) { $cakeArguments += "-mono" } $cakeArguments += $ScriptArgs # Start Cake diff --git a/tools/cake.csproj b/tools/cake.csproj deleted file mode 100644 index 06692627d2..0000000000 --- a/tools/cake.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - Exe - netcoreapp2.0 - - - - - \ No newline at end of file diff --git a/tools/cakebuild.csproj b/tools/cakebuild.csproj new file mode 100644 index 0000000000..eaa25ccb24 --- /dev/null +++ b/tools/cakebuild.csproj @@ -0,0 +1,11 @@ + + + Exe + true + netcoreapp2.0 + + + + + + \ No newline at end of file diff --git a/tools/packages.config b/tools/packages.config deleted file mode 100644 index e37e9304d5..0000000000 --- a/tools/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - From 5abe3a0233a7cb1c84ddd03f8a3f73db2b1bd207 Mon Sep 17 00:00:00 2001 From: miterosan Date: Thu, 4 Oct 2018 19:02:59 +0200 Subject: [PATCH 33/61] Also rename the cake project in the bootstrap script --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 64303e67d5..624a6e5de4 100644 --- a/build.ps1 +++ b/build.ps1 @@ -54,7 +54,7 @@ if(!$PSScriptRoot){ # Resolve the paths for resources used for debugging. $TOOLS_DIR = Join-Path $PSScriptRoot "tools" -$CAKE_CSPROJ = Join-Path $TOOLS_DIR "cakebootstrap.csproj" +$CAKE_CSPROJ = Join-Path $TOOLS_DIR "cakebuild.csproj" # Install the required tools locally. Write-Host "Restoring cake tools..." From 74e89fd9452069fb293d6fab34d0c5aeded179a3 Mon Sep 17 00:00:00 2001 From: miterosan Date: Fri, 5 Oct 2018 14:54:11 +0200 Subject: [PATCH 34/61] Add config file --- cake.config | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 cake.config diff --git a/cake.config b/cake.config new file mode 100644 index 0000000000..187d825591 --- /dev/null +++ b/cake.config @@ -0,0 +1,5 @@ + +[Nuget] +Source=https://api.nuget.org/v3/index.json +UseInProcessClient=true +LoadDependencies=true From 6977b2825f46e1a02bc62c073fc23208825813cf Mon Sep 17 00:00:00 2001 From: miterosan Date: Fri, 5 Oct 2018 14:57:09 +0200 Subject: [PATCH 35/61] Use the coreclr instead of caketool, hoping that the version fixes running it on linux --- build.ps1 | 2 +- tools/cakebuild.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 624a6e5de4..9968673c90 100644 --- a/build.ps1 +++ b/build.ps1 @@ -61,7 +61,7 @@ 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/cake.tool/ -Filter Cake.dll -Recurse).FullName +$CAKE_EXECUTABLE = (Get-ChildItem -Path ./tools/cake.coreclr/ -Filter Cake.dll -Recurse).FullName # Build Cake arguments $cakeArguments = @("$Script"); diff --git a/tools/cakebuild.csproj b/tools/cakebuild.csproj index eaa25ccb24..8ccce35e26 100644 --- a/tools/cakebuild.csproj +++ b/tools/cakebuild.csproj @@ -6,6 +6,6 @@ - + \ No newline at end of file From b351aae93fe5d27810e1561228de9d8cc786a6e5 Mon Sep 17 00:00:00 2001 From: Paul Teng Date: Thu, 18 Oct 2018 07:02:18 -0400 Subject: [PATCH 36/61] Reduce height of song progress handle --- osu.Game/Screens/Play/SongProgress.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 2e2c77c1c8..e921cd602b 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -21,7 +21,7 @@ namespace osu.Game.Screens.Play { private const int bottom_bar_height = 5; - private static readonly Vector2 handle_size = new Vector2(14, 25); + private static readonly Vector2 handle_size = new Vector2(14, 18); private const float transition_duration = 200; From ce9b400c4c70c0fc30f16ef4418af63a915adcca Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 25 Oct 2018 18:48:11 +0900 Subject: [PATCH 37/61] Add selection mask test cases --- .../TestCaseHitCircleSelectionMask.cs | 29 ++++++++++++ .../TestCaseSliderSelectionMask.cs | 42 +++++++++++++++++ .../Visual/HitObjectSelectionMaskTestCase.cs | 47 +++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 osu.Game.Rulesets.Osu.Tests/TestCaseHitCircleSelectionMask.cs create mode 100644 osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs create mode 100644 osu.Game/Tests/Visual/HitObjectSelectionMaskTestCase.cs diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircleSelectionMask.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircleSelectionMask.cs new file mode 100644 index 0000000000..e3d61623bf --- /dev/null +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircleSelectionMask.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks; +using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Tests.Visual; +using OpenTK; + +namespace osu.Game.Rulesets.Osu.Tests +{ + public class TestCaseHitCircleSelectionMask : HitObjectSelectionMaskTestCase + { + private readonly DrawableHitCircle drawableObject; + + public TestCaseHitCircleSelectionMask() + { + var hitCircle = new HitCircle { Position = new Vector2(256, 192) }; + hitCircle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 }); + + Add(drawableObject = new DrawableHitCircle(hitCircle)); + } + + protected override SelectionMask CreateMask() => new HitCircleSelectionMask(drawableObject); + } +} diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs new file mode 100644 index 0000000000..5e68d5cdc9 --- /dev/null +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs @@ -0,0 +1,42 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Objects.Types; +using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks; +using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Tests.Visual; +using OpenTK; + +namespace osu.Game.Rulesets.Osu.Tests +{ + public class TestCaseSliderSelectionMask : HitObjectSelectionMaskTestCase + { + private readonly DrawableSlider drawableObject; + + public TestCaseSliderSelectionMask() + { + var slider = new Slider + { + Position = new Vector2(256, 192), + ControlPoints = new[] + { + Vector2.Zero, + new Vector2(150, 150), + new Vector2(300, 0) + }, + CurveType = CurveType.Bezier, + Distance = 350 + }; + + slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 }); + + Add(drawableObject = new DrawableSlider(slider)); + } + + protected override SelectionMask CreateMask() => new SliderSelectionMask(drawableObject); + } +} diff --git a/osu.Game/Tests/Visual/HitObjectSelectionMaskTestCase.cs b/osu.Game/Tests/Visual/HitObjectSelectionMaskTestCase.cs new file mode 100644 index 0000000000..3ba6841280 --- /dev/null +++ b/osu.Game/Tests/Visual/HitObjectSelectionMaskTestCase.cs @@ -0,0 +1,47 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Input.Events; +using osu.Framework.Timing; +using osu.Game.Rulesets.Edit; + +namespace osu.Game.Tests.Visual +{ + public abstract class HitObjectSelectionMaskTestCase : OsuTestCase + { + private SelectionMask mask; + + protected override Container Content => content ?? base.Content; + private readonly Container content; + + protected HitObjectSelectionMaskTestCase() + { + base.Content.Add(content = new Container + { + Clock = new FramedClock(new StopwatchClock()), + RelativeSizeAxes = Axes.Both + }); + } + + [BackgroundDependencyLoader] + private void load() + { + base.Content.Add(mask = CreateMask()); + mask.SelectionRequested += (_, __) => mask.Select(); + + AddStep("Select", () => mask.Select()); + AddStep("Deselect", () => mask.Deselect()); + } + + protected override bool OnClick(ClickEvent e) + { + mask.Deselect(); + return true; + } + + protected abstract SelectionMask CreateMask(); + } +} From df6fc4013a6e34c21b416e015726b1a533132365 Mon Sep 17 00:00:00 2001 From: Kyle Chang Date: Sun, 28 Oct 2018 01:40:19 -0400 Subject: [PATCH 38/61] Add interface to adjust Beatmaps --- .../Rulesets/Mods/IApplicableToBeatmap.cs | 19 +++++++++++++++++++ osu.Game/Rulesets/UI/RulesetContainer.cs | 19 +++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 osu.Game/Rulesets/Mods/IApplicableToBeatmap.cs diff --git a/osu.Game/Rulesets/Mods/IApplicableToBeatmap.cs b/osu.Game/Rulesets/Mods/IApplicableToBeatmap.cs new file mode 100644 index 0000000000..e1398ecf2b --- /dev/null +++ b/osu.Game/Rulesets/Mods/IApplicableToBeatmap.cs @@ -0,0 +1,19 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps; + +namespace osu.Game.Rulesets.Mods +{ + /// + /// Interface for a that applies changes to a . + /// + public interface IApplicableToBeatmap : IApplicableMod + { + /// + /// Applies this to a . + /// + /// The to apply to. + void ApplyToBeatmap(IBeatmap beatmap); + } +} diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index a23a5a78f7..4b55bb558d 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -238,6 +238,8 @@ namespace osu.Game.Rulesets.UI KeyBindingInputManager = CreateInputManager(); KeyBindingInputManager.RelativeSizeAxes = Axes.Both; + + applyBeatmapMods(Mods); } [BackgroundDependencyLoader] @@ -255,16 +257,29 @@ namespace osu.Game.Rulesets.UI KeyBindingInputManager.Add(Cursor); // Apply mods - applyMods(Mods, config); + applyRulesetMods(Mods, config); loadObjects(); } + /// + /// Applies the active mods to the Beatmap. + /// + /// + private void applyBeatmapMods(IEnumerable mods) + { + if (mods == null) + return; + + foreach (var mod in mods.OfType()) + mod.ApplyToBeatmap(Beatmap); + } + /// /// Applies the active mods to this RulesetContainer. /// /// - private void applyMods(IEnumerable mods, OsuConfigManager config) + private void applyRulesetMods(IEnumerable mods, OsuConfigManager config) { if (mods == null) return; From 9b246f065c07769e8623edf9bf7e9885b0b5130c Mon Sep 17 00:00:00 2001 From: Kyle Chang Date: Sun, 28 Oct 2018 02:20:46 -0400 Subject: [PATCH 39/61] Have dual stage mod apply changes to beatmap directly --- .../Mods/ManiaModDualStages.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs index aecfb50fbe..12b62d2b65 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs @@ -4,14 +4,11 @@ using System.Collections.Generic; using osu.Game.Beatmaps; using osu.Game.Rulesets.Mania.Beatmaps; -using osu.Game.Rulesets.Mania.Objects; -using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mods; -using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Mania.Mods { - public class ManiaModDualStages : Mod, IPlayfieldTypeMod, IApplicableToBeatmapConverter, IApplicableToRulesetContainer + public class ManiaModDualStages : Mod, IPlayfieldTypeMod, IApplicableToBeatmapConverter, IApplicableToBeatmap { public override string Name => "Dual Stages"; public override string ShortenedName => "DS"; @@ -34,22 +31,21 @@ namespace osu.Game.Rulesets.Mania.Mods mbc.TargetColumns *= 2; } - public void ApplyToRulesetContainer(RulesetContainer rulesetContainer) + public void ApplyToBeatmap(IBeatmap beatmap) { - var mrc = (ManiaRulesetContainer)rulesetContainer; - - // Although this can work, for now let's not allow keymods for mania-specific beatmaps if (isForCurrentRuleset) return; + var maniaBeatmap = (ManiaBeatmap) beatmap; + var newDefinitions = new List(); - foreach (var existing in mrc.Beatmap.Stages) + foreach (var existing in maniaBeatmap.Stages) { newDefinitions.Add(new StageDefinition { Columns = existing.Columns / 2 }); newDefinitions.Add(new StageDefinition { Columns = existing.Columns / 2 }); } - mrc.Beatmap.Stages = newDefinitions; + maniaBeatmap.Stages = newDefinitions; } public PlayfieldType PlayfieldType => PlayfieldType.Dual; From 3a61594da4924803d860536a7829c1e1d5854025 Mon Sep 17 00:00:00 2001 From: miterosan Date: Sun, 28 Oct 2018 13:04:54 +0100 Subject: [PATCH 40/61] Reference the build script in the README. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index dc36145337..d0919e1d82 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Build and run - Using Visual Studio 2017, Rider or Visual Studio Code (configurations are included) - From command line using `dotnet run --project osu.Desktop`. When building for non-development purposes, add `-c Release` to gain higher performance. +- And from command line using `powershell ./build.ps1`. This will also run tests and code analysis. This command is used on CI. The code analysis is windows only. Note: If you run from command line under linux, you will need to prefix the output folder to your `LD_LIBRARY_PATH`. See `.vscode/launch.json` for an example From b0f5ace0e88b07ee34bbb2ed2020fa0e7ce64b33 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 29 Oct 2018 14:07:06 +0900 Subject: [PATCH 41/61] Implement slider control point visualisation --- .../TestCaseSliderSelectionMask.cs | 13 +++ .../Components/ControlPointPiece.cs | 90 +++++++++++++++++++ .../Components/ControlPointVisualiser.cs | 34 +++++++ .../Masks/SliderMasks/SliderSelectionMask.cs | 1 + osu.Game.Rulesets.Osu/Objects/Slider.cs | 13 ++- 5 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs create mode 100644 osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointVisualiser.cs diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs index 5e68d5cdc9..a73cb69536 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs @@ -1,11 +1,14 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using System.Collections.Generic; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks; +using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Tests.Visual; @@ -15,6 +18,16 @@ namespace osu.Game.Rulesets.Osu.Tests { public class TestCaseSliderSelectionMask : HitObjectSelectionMaskTestCase { + public override IReadOnlyList RequiredTypes => new Type[] + { + typeof(SliderSelectionMask), + typeof(SliderCircleSelectionMask), + typeof(SliderBodyPiece), + typeof(SliderCircle), + typeof(ControlPointVisualiser), + typeof(ControlPointPiece) + }; + private readonly DrawableSlider drawableObject; public TestCaseSliderSelectionMask() diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs new file mode 100644 index 0000000000..5a3c5d5aaf --- /dev/null +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs @@ -0,0 +1,90 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Lines; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Input.Events; +using osu.Game.Graphics; +using osu.Game.Rulesets.Osu.Objects; +using OpenTK; + +namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components +{ + public class ControlPointPiece : CompositeDrawable + { + private readonly Slider slider; + private readonly int index; + + private readonly Path path; + private readonly CircularContainer marker; + + [Resolved] + private OsuColour colours { get; set; } + + public ControlPointPiece(Slider slider, int index) + { + this.slider = slider; + this.index = index; + + Origin = Anchor.Centre; + Size = new Vector2(10); + + InternalChildren = new Drawable[] + { + path = new SmoothPath + { + BypassAutoSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + PathWidth = 1 + }, + marker = new CircularContainer + { + RelativeSizeAxes = Axes.Both, + Masking = true, + Child = new Box { RelativeSizeAxes = Axes.Both } + } + }; + } + + protected override void Update() + { + base.Update(); + + Position = slider.StackedPosition + slider.ControlPoints[index]; + + marker.Colour = segmentSeparator ? colours.Red : colours.Yellow; + + path.ClearVertices(); + + if (index != slider.ControlPoints.Length - 1) + { + path.AddVertex(Vector2.Zero); + path.AddVertex(slider.ControlPoints[index + 1] - slider.ControlPoints[index]); + } + + path.OriginPosition = path.PositionInBoundingBox(Vector2.Zero); + } + + protected override bool OnDragStart(DragStartEvent e) => true; + + protected override bool OnDrag(DragEvent e) + { + var newControlPoints = slider.ControlPoints.ToArray(); + newControlPoints[index] += e.Delta; + + slider.ControlPoints = newControlPoints; + + return true; + } + + protected override bool OnDragEnd(DragEndEvent e) => true; + + private bool segmentSeparator => index != 0 && index != slider.ControlPoints.Length - 1 + && slider.ControlPoints[index - 1] != slider.ControlPoints[index] + && slider.ControlPoints[index + 1] != slider.ControlPoints[index]; + } +} diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointVisualiser.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointVisualiser.cs new file mode 100644 index 0000000000..d8031c4f5b --- /dev/null +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointVisualiser.cs @@ -0,0 +1,34 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Osu.Objects; + +namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components +{ + public class ControlPointVisualiser : CompositeDrawable + { + private readonly Slider slider; + + private readonly Container pieces; + + public ControlPointVisualiser(Slider slider) + { + this.slider = slider; + + InternalChild = pieces = new Container { RelativeSizeAxes = Axes.Both }; + + slider.ControlPointsChanged += _ => updateControlPoints(); + updateControlPoints(); + } + + private void updateControlPoints() + { + while (slider.ControlPoints.Length > pieces.Count) + pieces.Add(new ControlPointPiece(slider, pieces.Count)); + while (slider.ControlPoints.Length < pieces.Count) + pieces.Remove(pieces[pieces.Count - 1]); + } + } +} diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/SliderSelectionMask.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/SliderSelectionMask.cs index a411064f68..8478374a5f 100644 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/SliderSelectionMask.cs +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/SliderSelectionMask.cs @@ -24,6 +24,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks new SliderBodyPiece(sliderObject), headMask = new SliderCircleSelectionMask(slider.HeadCircle, sliderObject, SliderPosition.Start), new SliderCircleSelectionMask(slider.TailCircle, sliderObject, SliderPosition.End), + new ControlPointVisualiser(sliderObject), }; } diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs index a6f5bdb24e..10ffe82579 100644 --- a/osu.Game.Rulesets.Osu/Objects/Slider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs @@ -22,6 +22,8 @@ namespace osu.Game.Rulesets.Osu.Objects /// private const float base_scoring_distance = 100; + public event Action ControlPointsChanged; + public double EndTime => StartTime + this.SpanCount() * Curve.Distance / Velocity; public double Duration => EndTime - StartTime; @@ -54,8 +56,15 @@ namespace osu.Game.Rulesets.Osu.Objects public Vector2[] ControlPoints { - get { return Curve.ControlPoints; } - set { Curve.ControlPoints = value; } + get => Curve.ControlPoints; + set + { + if (Curve.ControlPoints == value) + return; + Curve.ControlPoints = value; + + ControlPointsChanged?.Invoke(value); + } } public CurveType CurveType From acd703c27b3f8d1b147e9e7144524bb1e604beb8 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 29 Oct 2018 15:36:43 +0900 Subject: [PATCH 42/61] Make sliders respond to control point changes --- .../TestCaseSliderSelectionMask.cs | 2 +- .../Components/ControlPointPiece.cs | 23 ++++++++++++-- .../SliderMasks/Components/SliderBodyPiece.cs | 1 + .../Components/SliderCirclePiece.cs | 2 ++ .../Objects/Drawables/DrawableSlider.cs | 2 ++ .../Objects/Drawables/DrawableSliderHead.cs | 7 ++++- .../Objects/Drawables/DrawableSliderTail.cs | 11 ++++++- .../Drawables/Pieces/SnakingSliderBody.cs | 31 +++++++++++++------ osu.Game.Rulesets.Osu/Objects/Slider.cs | 3 ++ osu.Game/Rulesets/Objects/SliderCurve.cs | 27 ++++++++++++++-- 10 files changed, 92 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs index a73cb69536..1ba3e26e65 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs @@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Osu.Tests { public class TestCaseSliderSelectionMask : HitObjectSelectionMaskTestCase { - public override IReadOnlyList RequiredTypes => new Type[] + public override IReadOnlyList RequiredTypes => new[] { typeof(SliderSelectionMask), typeof(SliderCircleSelectionMask), diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs index 5a3c5d5aaf..401fc24902 100644 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs @@ -73,10 +73,27 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components protected override bool OnDrag(DragEvent e) { - var newControlPoints = slider.ControlPoints.ToArray(); - newControlPoints[index] += e.Delta; + if (index == 0) + { + // Special handling for the head - only the position of the slider changes + slider.Position += e.Delta; - slider.ControlPoints = newControlPoints; + // Since control points are relative to the position of the slider, they all need to be offset backwards by the delta + var newControlPoints = slider.ControlPoints.ToArray(); + for (int i = 1; i < newControlPoints.Length; i++) + newControlPoints[i] -= e.Delta; + + slider.ControlPoints = newControlPoints; + slider.Curve.Calculate(true); + } + else + { + var newControlPoints = slider.ControlPoints.ToArray(); + newControlPoints[index] += e.Delta; + + slider.ControlPoints = newControlPoints; + slider.Curve.Calculate(true); + } return true; } diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderBodyPiece.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderBodyPiece.cs index 3123a4fcea..46d99e1740 100644 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderBodyPiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderBodyPiece.cs @@ -46,6 +46,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components // Need to cause one update body.UpdateProgress(0); + body.Refresh(); } } } diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderCirclePiece.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderCirclePiece.cs index c5ecde5c4c..a8565fafb6 100644 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderCirclePiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderCirclePiece.cs @@ -16,6 +16,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components { this.slider = slider; this.position = position; + + slider.ControlPointsChanged += _ => UpdatePosition(); } protected override void UpdatePosition() diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs index 16bd522c1d..7599001a82 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs @@ -85,6 +85,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables } HitObject.PositionChanged += _ => Position = HitObject.StackedPosition; + + slider.ControlPointsChanged += _ => Body.Refresh(); } public override Color4 AccentColour diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs index 6d6cba4936..6a836679a2 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs @@ -16,7 +16,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { this.slider = slider; - Position = HitObject.Position - slider.Position; + h.PositionChanged += _ => updatePosition(); + slider.ControlPointsChanged += _ => updatePosition(); + + updatePosition(); } protected override void Update() @@ -33,5 +36,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public Action OnShake; protected override void Shake(double maximumLength) => OnShake?.Invoke(maximumLength); + + private void updatePosition() => Position = HitObject.Position - slider.Position; } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs index 45c925b87a..cc88a6718b 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs @@ -8,6 +8,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { public class DrawableSliderTail : DrawableOsuHitObject, IRequireTracking { + private readonly Slider slider; + /// /// The judgement text is provided by the . /// @@ -18,6 +20,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public DrawableSliderTail(Slider slider, SliderTailCircle hitCircle) : base(hitCircle) { + this.slider = slider; + Origin = Anchor.Centre; RelativeSizeAxes = Axes.Both; @@ -25,7 +29,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables AlwaysPresent = true; - Position = HitObject.Position - slider.Position; + hitCircle.PositionChanged += _ => updatePosition(); + slider.ControlPointsChanged += _ => updatePosition(); + + updatePosition(); } protected override void CheckForResult(bool userTriggered, double timeOffset) @@ -33,5 +40,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables if (!userTriggered && timeOffset >= 0) ApplyResult(r => r.Type = Tracking ? HitResult.Great : HitResult.Miss); } + + private void updatePosition() => Position = HitObject.Position - slider.Position; } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SnakingSliderBody.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SnakingSliderBody.cs index 09d6f9459a..3d02f9a92d 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SnakingSliderBody.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SnakingSliderBody.cs @@ -45,15 +45,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces [BackgroundDependencyLoader] private void load() { - // Generate the entire curve - slider.Curve.GetPathToProgress(CurrentCurve, 0, 1); - SetVertices(CurrentCurve); - - // The body is sized to the full path size to avoid excessive autosize computations - Size = Path.Size; - - snakedPosition = Path.PositionInBoundingBox(Vector2.Zero); - snakedPathOffset = Path.PositionInBoundingBox(Path.Vertices[0]); + Refresh(); } public void UpdateProgress(double completionProgress) @@ -80,6 +72,27 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces setRange(start, end); } + public void Refresh() + { + // Generate the entire curve + slider.Curve.GetPathToProgress(CurrentCurve, 0, 1); + SetVertices(CurrentCurve); + + // The body is sized to the full path size to avoid excessive autosize computations + Size = Path.Size; + + snakedPosition = Path.PositionInBoundingBox(Vector2.Zero); + snakedPathOffset = Path.PositionInBoundingBox(Path.Vertices[0]); + + var lastSnakedStart = SnakedStart ?? 0; + var lastSnakedEnd = SnakedEnd ?? 0; + + SnakedStart = null; + SnakedEnd = null; + + setRange(lastSnakedStart, lastSnakedEnd); + } + private void setRange(double p0, double p1) { if (p0 > p1) diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs index 10ffe82579..de7ba8451b 100644 --- a/osu.Game.Rulesets.Osu/Objects/Slider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs @@ -64,6 +64,9 @@ namespace osu.Game.Rulesets.Osu.Objects Curve.ControlPoints = value; ControlPointsChanged?.Invoke(value); + + if (TailCircle != null) + TailCircle.Position = EndPosition; } } diff --git a/osu.Game/Rulesets/Objects/SliderCurve.cs b/osu.Game/Rulesets/Objects/SliderCurve.cs index dfccdf68f2..6a8192a4f2 100644 --- a/osu.Game/Rulesets/Objects/SliderCurve.cs +++ b/osu.Game/Rulesets/Objects/SliderCurve.cs @@ -124,10 +124,33 @@ namespace osu.Game.Rulesets.Objects } } - public void Calculate() + private void calculateCumulativeLength() + { + double l = 0; + + cumulativeLength.Clear(); + cumulativeLength.Add(l); + + for (int i = 0; i < calculatedPath.Count - 1; ++i) + { + Vector2 diff = calculatedPath[i + 1] - calculatedPath[i]; + double d = diff.Length; + + l += d; + cumulativeLength.Add(l); + } + + Distance = l; + } + + public void Calculate(bool updateDistance = false) { calculatePath(); - calculateCumulativeLengthAndTrimPath(); + + if (!updateDistance) + calculateCumulativeLengthAndTrimPath(); + else + calculateCumulativeLength(); } private int indexOfDistance(double d) From c1fffde10db3cb0ccf508899dc9545f7b0d58816 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 29 Oct 2018 15:52:28 +0900 Subject: [PATCH 43/61] Fix broken conditional --- .../Components/ControlPointPiece.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs index 401fc24902..7547b4523b 100644 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs @@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components Position = slider.StackedPosition + slider.ControlPoints[index]; - marker.Colour = segmentSeparator ? colours.Red : colours.Yellow; + marker.Colour = isSegmentSeparator ? colours.Red : colours.Yellow; path.ClearVertices(); @@ -100,8 +100,19 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components protected override bool OnDragEnd(DragEndEvent e) => true; - private bool segmentSeparator => index != 0 && index != slider.ControlPoints.Length - 1 - && slider.ControlPoints[index - 1] != slider.ControlPoints[index] - && slider.ControlPoints[index + 1] != slider.ControlPoints[index]; + private bool isSegmentSeparator + { + get + { + bool separator = false; + + if (index < slider.ControlPoints.Length - 1) + separator |= slider.ControlPoints[index + 1] == slider.ControlPoints[index]; + if (index > 0) + separator |= slider.ControlPoints[index - 1] == slider.ControlPoints[index]; + + return separator; + } + } } } From 2ae7b4224464bc544598f3d9e1724f6a0e4731d0 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 29 Oct 2018 16:15:04 +0900 Subject: [PATCH 44/61] Fix control points disappearing if moved offscreen --- .../Masks/SliderMasks/Components/ControlPointPiece.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs index 7547b4523b..b1d157d9b7 100644 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs @@ -31,19 +31,20 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components this.index = index; Origin = Anchor.Centre; - Size = new Vector2(10); + AutoSizeAxes = Axes.Both; InternalChildren = new Drawable[] { path = new SmoothPath { - BypassAutoSizeAxes = Axes.Both, Anchor = Anchor.Centre, PathWidth = 1 }, marker = new CircularContainer { - RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(15), Masking = true, Child = new Box { RelativeSizeAxes = Axes.Both } } @@ -69,6 +70,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components path.OriginPosition = path.PositionInBoundingBox(Vector2.Zero); } + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => marker.ReceivePositionalInputAt(screenSpacePos); + protected override bool OnDragStart(DragStartEvent e) => true; protected override bool OnDrag(DragEvent e) From ff47b2be7a6eb17cd29b7be24156394597a14a9a Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 29 Oct 2018 18:42:35 +0100 Subject: [PATCH 45/61] Create a simple bootstrapper in the bash script language --- build.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000000..caf1702f41 --- /dev/null +++ b/build.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +########################################################################## +# This is a customized Cake bootstrapper script for Shell. +########################################################################## + +echo "Preparing to run build script..." + +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=$TOOLS_DIR/"cakebuild.csproj" + +# Parse arguments. +CAKE_ARGUMENTS=() +for i in "$@"; do + case $1 in + -s|--script) SCRIPT="$2"; shift ;; + --) shift; CAKE_ARGUMENTS+=("$@"); break ;; + *) CAKE_ARGUMENTS+=("$1") ;; + esac + shift +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..." + +dotnet "$CAKE_BINARY" $SCRIPT "${CAKE_ARGUMENTS[@]}" From bf83c1eb6adaf256172776843cf77bebf0b39f41 Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 29 Oct 2018 18:45:08 +0100 Subject: [PATCH 46/61] Mention the bash script in the readme. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d0919e1d82..00f55242d2 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Build and run - Using Visual Studio 2017, Rider or Visual Studio Code (configurations are included) - From command line using `dotnet run --project osu.Desktop`. When building for non-development purposes, add `-c Release` to gain higher performance. -- And from command line using `powershell ./build.ps1`. This will also run tests and code analysis. This command is used on CI. The code analysis is windows only. +- And from command line using `powershell ./build.ps1` or if you use bash as your shell: `./build.sh`. This will also run tests and code analysis. This command is used on CI. The code analysis is windows only. Note: If you run from command line under linux, you will need to prefix the output folder to your `LD_LIBRARY_PATH`. See `.vscode/launch.json` for an example From 4d97b96705214a6d8da94363c8cb96236651108d Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 29 Oct 2018 18:49:31 +0100 Subject: [PATCH 47/61] Remove the framework settings. It is not used. --- build.cake | 1 - 1 file changed, 1 deletion(-) diff --git a/build.cake b/build.cake index fff39079b6..136ad67ab9 100644 --- a/build.cake +++ b/build.cake @@ -7,7 +7,6 @@ /////////////////////////////////////////////////////////////////////////////// var target = Argument("target", "Build"); -var framework = Argument("framework", "netcoreapp2.1"); var configuration = Argument("configuration", "Release"); var osuSolution = new FilePath("./osu.sln"); From 6d00aff9fd7958227a16e607b32121130b9d3e70 Mon Sep 17 00:00:00 2001 From: Kyle Chang Date: Tue, 30 Oct 2018 00:13:33 -0400 Subject: [PATCH 48/61] Add type parameter to IApplicableToBeatmap --- osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs | 7 ++++--- osu.Game/Rulesets/Mods/IApplicableToBeatmap.cs | 13 ++++++++----- osu.Game/Rulesets/UI/RulesetContainer.cs | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs index 12b62d2b65..4790a77cc0 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs @@ -4,11 +4,12 @@ using System.Collections.Generic; using osu.Game.Beatmaps; using osu.Game.Rulesets.Mania.Beatmaps; +using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Mania.Mods { - public class ManiaModDualStages : Mod, IPlayfieldTypeMod, IApplicableToBeatmapConverter, IApplicableToBeatmap + public class ManiaModDualStages : Mod, IPlayfieldTypeMod, IApplicableToBeatmapConverter, IApplicableToBeatmap { public override string Name => "Dual Stages"; public override string ShortenedName => "DS"; @@ -31,12 +32,12 @@ namespace osu.Game.Rulesets.Mania.Mods mbc.TargetColumns *= 2; } - public void ApplyToBeatmap(IBeatmap beatmap) + public void ApplyToBeatmap(Beatmap beatmap) { if (isForCurrentRuleset) return; - var maniaBeatmap = (ManiaBeatmap) beatmap; + var maniaBeatmap = (ManiaBeatmap)beatmap; var newDefinitions = new List(); foreach (var existing in maniaBeatmap.Stages) diff --git a/osu.Game/Rulesets/Mods/IApplicableToBeatmap.cs b/osu.Game/Rulesets/Mods/IApplicableToBeatmap.cs index e1398ecf2b..1eb74ca76a 100644 --- a/osu.Game/Rulesets/Mods/IApplicableToBeatmap.cs +++ b/osu.Game/Rulesets/Mods/IApplicableToBeatmap.cs @@ -2,18 +2,21 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Game.Beatmaps; +using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mods { /// - /// Interface for a that applies changes to a . + /// Interface for a that applies changes to a + /// after conversion and post-processing has completed. /// - public interface IApplicableToBeatmap : IApplicableMod + public interface IApplicableToBeatmap : IApplicableMod + where TObject : HitObject { /// - /// Applies this to a . + /// Applies this to a . /// - /// The to apply to. - void ApplyToBeatmap(IBeatmap beatmap); + /// The to apply to. + void ApplyToBeatmap(Beatmap beatmap); } } diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 4b55bb558d..d1303e21a9 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -271,7 +271,7 @@ namespace osu.Game.Rulesets.UI if (mods == null) return; - foreach (var mod in mods.OfType()) + foreach (var mod in mods.OfType>()) mod.ApplyToBeatmap(Beatmap); } From b0ccd614805c9d89dc1da5f3e5fb5b43ab164dd1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 29 Oct 2018 12:41:22 -0700 Subject: [PATCH 49/61] Fix weird code formatting --- build.cake | 70 +++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/build.cake b/build.cake index 136ad67ab9..bc7dfafb8c 100644 --- a/build.cake +++ b/build.cake @@ -16,57 +16,57 @@ var osuSolution = new FilePath("./osu.sln"); /////////////////////////////////////////////////////////////////////////////// Task("Restore") -.Does(() => { - DotNetCoreRestore(osuSolution.FullPath); -}); + .Does(() => { + DotNetCoreRestore(osuSolution.FullPath); + }); Task("Compile") -.IsDependentOn("Restore") -.Does(() => { - DotNetCoreBuild(osuSolution.FullPath, new DotNetCoreBuildSettings { - Configuration = configuration, - NoRestore = true, + .IsDependentOn("Restore") + .Does(() => { + DotNetCoreBuild(osuSolution.FullPath, new DotNetCoreBuildSettings { + Configuration = configuration, + NoRestore = true, + }); }); -}); Task("Test") -.IsDependentOn("Compile") -.Does(() => { - var testAssemblies = GetFiles("**/*.Tests/bin/**/*.Tests.dll"); + .IsDependentOn("Compile") + .Does(() => { + var testAssemblies = GetFiles("**/*.Tests/bin/**/*.Tests.dll"); - DotNetCoreVSTest(testAssemblies, new DotNetCoreVSTestSettings { - Logger = AppVeyor.IsRunningOnAppVeyor ? "Appveyor" : $"trx", - Parallel = true, - ToolTimeout = TimeSpan.FromMinutes(10), + DotNetCoreVSTest(testAssemblies, new DotNetCoreVSTestSettings { + Logger = AppVeyor.IsRunningOnAppVeyor ? "Appveyor" : $"trx", + Parallel = true, + ToolTimeout = TimeSpan.FromMinutes(10), + }); }); -}); // windows only because both inspectcore and nvika depend on net45 Task("InspectCode") -.WithCriteria(IsRunningOnWindows()) -.IsDependentOn("Compile") -.Does(() => { - var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); + .WithCriteria(IsRunningOnWindows()) + .IsDependentOn("Compile") + .Does(() => { + var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); - InspectCode(osuSolution, new InspectCodeSettings { - CachesHome = "inspectcode", - OutputFile = "inspectcodereport.xml", + InspectCode(osuSolution, new InspectCodeSettings { + CachesHome = "inspectcode", + OutputFile = "inspectcodereport.xml", + }); + + StartProcess(nVikaToolPath, @"parsereport ""inspectcodereport.xml"" --treatwarningsaserrors"); }); - StartProcess(nVikaToolPath, @"parsereport ""inspectcodereport.xml"" --treatwarningsaserrors"); -}); - Task("CodeFileSanity") -.Does(() => { - ValidateCodeSanity(new ValidateCodeSanitySettings { - RootDirectory = ".", - IsAppveyorBuild = AppVeyor.IsRunningOnAppVeyor + .Does(() => { + ValidateCodeSanity(new ValidateCodeSanitySettings { + RootDirectory = ".", + IsAppveyorBuild = AppVeyor.IsRunningOnAppVeyor + }); }); -}); Task("Build") -.IsDependentOn("CodeFileSanity") -.IsDependentOn("InspectCode") -.IsDependentOn("Test"); + .IsDependentOn("CodeFileSanity") + .IsDependentOn("InspectCode") + .IsDependentOn("Test"); RunTarget(target); \ No newline at end of file From d173335b6d2760936d015d814bd7172e79cc2e07 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 30 Oct 2018 00:02:32 -0700 Subject: [PATCH 50/61] Reword readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 00f55242d2..baaba22726 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Build and run - Using Visual Studio 2017, Rider or Visual Studio Code (configurations are included) - From command line using `dotnet run --project osu.Desktop`. When building for non-development purposes, add `-c Release` to gain higher performance. -- And from command line using `powershell ./build.ps1` or if you use bash as your shell: `./build.sh`. This will also run tests and code analysis. This command is used on CI. The code analysis is windows only. +- To run with code analysis, instead use `powershell ./build.ps1` or `build.sh`. This is currently only supported under windows due to [resharper cli shortcomings](https://youtrack.jetbrains.com/issue/RSRP-410004). Alternative, you can install resharper or use rider to get inline support in your IDE of choice. Note: If you run from command line under linux, you will need to prefix the output folder to your `LD_LIBRARY_PATH`. See `.vscode/launch.json` for an example From 0b534885b8a021b72c184983f38d89ac15ad1f08 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 30 Oct 2018 00:10:34 -0700 Subject: [PATCH 51/61] Update framework --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index e2b466c69f..2f8c743bee 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -18,7 +18,7 @@ - + From 71b6789136b786d36163c8f5bb576f8f8f932d28 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 30 Oct 2018 16:47:39 +0900 Subject: [PATCH 52/61] Fix post-merge conflict --- .../Edit/Masks/SliderMasks/Components/SliderBodyPiece.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderBodyPiece.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderBodyPiece.cs index 0595b046d1..3123a4fcea 100644 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderBodyPiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderBodyPiece.cs @@ -13,12 +13,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components public class SliderBodyPiece : CompositeDrawable { private readonly Slider slider; - private readonly SliderBody body; + private readonly SnakingSliderBody body; public SliderBodyPiece(Slider slider) { this.slider = slider; - InternalChild = body = new SliderBody(slider) + InternalChild = body = new SnakingSliderBody(slider) { AccentColour = Color4.Transparent, PathWidth = slider.Scale * 64 From 4bc9161cd1412bfcce6179d210fa6e7a4b43d9a1 Mon Sep 17 00:00:00 2001 From: Paul Teng Date: Tue, 30 Oct 2018 08:32:12 -0400 Subject: [PATCH 53/61] Leave bigger gap if replaying --- osu.Game/Screens/Play/HUDOverlay.cs | 2 ++ osu.Game/Screens/Play/SongProgress.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index db0d7b6ccc..0f9f4fc20a 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -134,11 +134,13 @@ namespace osu.Game.Screens.Play { PlayerSettingsOverlay.Show(); ModDisplay.FadeIn(200); + KeyCounter.Margin = new MarginPadding(10) { Bottom = 30 }; } else { PlayerSettingsOverlay.Hide(); ModDisplay.Delay(2000).FadeOut(200); + KeyCounter.Margin = new MarginPadding(10); } } diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index e921cd602b..d1fc7b3378 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -135,6 +135,8 @@ namespace osu.Game.Screens.Play { bar.FadeTo(allowSeeking ? 1 : 0, transition_duration, Easing.In); this.MoveTo(new Vector2(0, allowSeeking ? 0 : bottom_bar_height), transition_duration, Easing.In); + + info.Margin = new MarginPadding { Bottom = Height - (allowSeeking ? 0 : handle_size.Y) }; } protected override void PopIn() From 6f1ef3243d2c7bd21e271e01883cbc2bac202ca8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 31 Oct 2018 02:56:25 +0900 Subject: [PATCH 54/61] Proportionally adjust width in line with change --- osu.Game/Screens/Play/SongProgress.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index d1fc7b3378..d4615b3016 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -21,7 +21,7 @@ namespace osu.Game.Screens.Play { private const int bottom_bar_height = 5; - private static readonly Vector2 handle_size = new Vector2(14, 18); + private static readonly Vector2 handle_size = new Vector2(10, 18); private const float transition_duration = 200; From 3207a585c6e4dcd0bd82f74c854b5d05f8afaa42 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 31 Oct 2018 12:01:10 +0900 Subject: [PATCH 55/61] Add missing xmldoc --- osu.Game/Rulesets/Edit/PlacementMask.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Rulesets/Edit/PlacementMask.cs b/osu.Game/Rulesets/Edit/PlacementMask.cs index a588a9e181..be2c42b586 100644 --- a/osu.Game/Rulesets/Edit/PlacementMask.cs +++ b/osu.Game/Rulesets/Edit/PlacementMask.cs @@ -15,6 +15,9 @@ using OpenTK; namespace osu.Game.Rulesets.Edit { + /// + /// A mask which governs the creation of a new to actualisation. + /// public abstract class PlacementMask : CompositeDrawable, IRequireHighFrequencyMousePosition { /// From 5eaf80ab7671c43412cbad7f185c550fb9313ba2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 31 Oct 2018 12:07:06 +0900 Subject: [PATCH 56/61] Add missing newline --- osu.Game/Screens/Edit/Screens/Compose/Layers/MaskSelection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Edit/Screens/Compose/Layers/MaskSelection.cs b/osu.Game/Screens/Edit/Screens/Compose/Layers/MaskSelection.cs index 4946b35abb..17b34bfb49 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Layers/MaskSelection.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Layers/MaskSelection.cs @@ -87,6 +87,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers placementHandler.Delete(h.HitObject.HitObject); return true; } + return base.OnKeyDown(e); } From 214ed43b812666383e4cea2098620404ddef4922 Mon Sep 17 00:00:00 2001 From: Kyle Chang Date: Tue, 30 Oct 2018 23:47:54 -0400 Subject: [PATCH 57/61] Check if SongSelect is current screen before playing selected song --- osu.Game/Screens/Select/SongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 4288483caf..acf699aa24 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -350,7 +350,7 @@ namespace osu.Game.Screens.Select } } - ensurePlayingSelected(preview); + if (IsCurrentScreen) ensurePlayingSelected(preview); UpdateBeatmap(Beatmap.Value); } From 85a732591141310e576abbe95c7c073cc32bd2d3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 31 Oct 2018 17:23:27 +0900 Subject: [PATCH 58/61] Fix placement masks handling scroll events --- osu.Game/Rulesets/Edit/PlacementMask.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Rulesets/Edit/PlacementMask.cs b/osu.Game/Rulesets/Edit/PlacementMask.cs index be2c42b586..97c6a74c92 100644 --- a/osu.Game/Rulesets/Edit/PlacementMask.cs +++ b/osu.Game/Rulesets/Edit/PlacementMask.cs @@ -84,6 +84,8 @@ namespace osu.Game.Rulesets.Edit switch (e) { + case ScrollEvent _: + return false; case MouseEvent _: return true; default: From d2fbf051377bc1af9bf2e0a61bc0f8715364cc54 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 31 Oct 2018 18:01:53 +0900 Subject: [PATCH 59/61] Reduce size of control point --- .../Edit/Masks/SliderMasks/Components/ControlPointPiece.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs index b1d157d9b7..2c6f9120c2 100644 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs @@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Size = new Vector2(15), + Size = new Vector2(10), Masking = true, Child = new Box { RelativeSizeAxes = Axes.Both } } From ffec532079a74c71478b1e2cda3ac770c76a5ef6 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 31 Oct 2018 18:02:08 +0900 Subject: [PATCH 60/61] Fix segment control points not changing in unison --- .../Components/ControlPointPiece.cs | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs index 2c6f9120c2..aedde870ca 100644 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs @@ -76,46 +76,38 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components protected override bool OnDrag(DragEvent e) { + var newControlPoints = slider.ControlPoints.ToArray(); + if (index == 0) { // Special handling for the head - only the position of the slider changes slider.Position += e.Delta; // Since control points are relative to the position of the slider, they all need to be offset backwards by the delta - var newControlPoints = slider.ControlPoints.ToArray(); for (int i = 1; i < newControlPoints.Length; i++) newControlPoints[i] -= e.Delta; - - slider.ControlPoints = newControlPoints; - slider.Curve.Calculate(true); } else - { - var newControlPoints = slider.ControlPoints.ToArray(); newControlPoints[index] += e.Delta; - slider.ControlPoints = newControlPoints; - slider.Curve.Calculate(true); - } + if (isSegmentSeparatorWithNext) + newControlPoints[index + 1] = newControlPoints[index]; + + if (isSegmentSeparatorWithPrevious) + newControlPoints[index - 1] = newControlPoints[index]; + + slider.ControlPoints = newControlPoints; + slider.Curve.Calculate(true); return true; } protected override bool OnDragEnd(DragEndEvent e) => true; - private bool isSegmentSeparator - { - get - { - bool separator = false; + private bool isSegmentSeparator => isSegmentSeparatorWithNext || isSegmentSeparatorWithPrevious; - if (index < slider.ControlPoints.Length - 1) - separator |= slider.ControlPoints[index + 1] == slider.ControlPoints[index]; - if (index > 0) - separator |= slider.ControlPoints[index - 1] == slider.ControlPoints[index]; + private bool isSegmentSeparatorWithNext => index < slider.ControlPoints.Length - 1 && slider.ControlPoints[index + 1] == slider.ControlPoints[index]; - return separator; - } - } + private bool isSegmentSeparatorWithPrevious => index > 0 && slider.ControlPoints[index - 1] == slider.ControlPoints[index]; } } From bb2f8deb18bff435c70a96d36dee0d1e1c0e1d0a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 1 Nov 2018 03:52:24 +0900 Subject: [PATCH 61/61] ControlPoint -> PathControlPoint Also Curve -> Path. --- .../TestCaseAutoJuiceStream.cs | 2 +- .../Beatmaps/CatchBeatmapConverter.cs | 2 +- .../Objects/JuiceStream.cs | 26 +++++++++---------- osu.Game.Rulesets.Osu.Tests/TestCaseSlider.cs | 8 +++--- .../TestCaseSliderSelectionMask.cs | 6 ++--- .../Beatmaps/OsuBeatmapConverter.cs | 2 +- .../Preprocessing/OsuDifficultyHitObject.cs | 2 +- ...PointPiece.cs => PathControlPointPiece.cs} | 6 ++--- ...liser.cs => PathControlPointVisualiser.cs} | 16 ++++++------ .../Components/SliderCirclePiece.cs | 4 +-- .../Masks/SliderMasks/SliderSelectionMask.cs | 2 +- osu.Game.Rulesets.Osu/Mods/OsuModHardRock.cs | 2 +- .../Objects/Drawables/DrawableSlider.cs | 2 +- .../Drawables/Pieces/SnakingSliderBody.cs | 4 +-- osu.Game.Rulesets.Osu/Objects/Slider.cs | 26 +++++++++---------- .../Legacy/Catch/ConvertHitObjectParser.cs | 4 +-- .../Objects/Legacy/ConvertHitObjectParser.cs | 20 +++++++------- .../Rulesets/Objects/Legacy/ConvertSlider.cs | 4 +-- .../Legacy/Mania/ConvertHitObjectParser.cs | 4 +-- .../Legacy/Osu/ConvertHitObjectParser.cs | 4 +-- .../Legacy/Taiko/ConvertHitObjectParser.cs | 4 +-- .../Objects/{SliderCurve.cs => SliderPath.cs} | 26 +++++++++---------- osu.Game/Rulesets/Objects/Types/IHasCurve.cs | 6 ++--- .../Types/{CurveType.cs => PathType.cs} | 2 +- 24 files changed, 92 insertions(+), 92 deletions(-) rename osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/{ControlPointPiece.cs => PathControlPointPiece.cs} (95%) rename osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/{ControlPointVisualiser.cs => PathControlPointVisualiser.cs} (54%) rename osu.Game/Rulesets/Objects/{SliderCurve.cs => SliderPath.cs} (92%) rename osu.Game/Rulesets/Objects/Types/{CurveType.cs => PathType.cs} (91%) diff --git a/osu.Game.Rulesets.Catch.Tests/TestCaseAutoJuiceStream.cs b/osu.Game.Rulesets.Catch.Tests/TestCaseAutoJuiceStream.cs index 5e68acde94..cac1356c81 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestCaseAutoJuiceStream.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestCaseAutoJuiceStream.cs @@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Catch.Tests Vector2.Zero, new Vector2(width * CatchPlayfield.BASE_WIDTH, 0) }, - CurveType = CurveType.Linear, + PathType = PathType.Linear, Distance = width * CatchPlayfield.BASE_WIDTH, StartTime = i * 2000, NewCombo = i % 8 == 0 diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs index 15d4edc411..a178748bd5 100644 --- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs +++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs @@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps StartTime = obj.StartTime, Samples = obj.Samples, ControlPoints = curveData.ControlPoints, - CurveType = curveData.CurveType, + PathType = curveData.PathType, Distance = curveData.Distance, RepeatSamples = curveData.RepeatSamples, RepeatCount = curveData.RepeatCount, diff --git a/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs b/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs index 82e32d24d2..da581d9619 100644 --- a/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs +++ b/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs @@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Catch.Objects if (TickDistance == 0) return; - var length = Curve.Distance; + var length = Path.Distance; var tickDistance = Math.Min(TickDistance, length); var spanDuration = length / Velocity; @@ -95,7 +95,7 @@ namespace osu.Game.Rulesets.Catch.Objects AddNested(new TinyDroplet { StartTime = t, - X = X + Curve.PositionAt(progress).X / CatchPlayfield.BASE_WIDTH, + X = X + Path.PositionAt(progress).X / CatchPlayfield.BASE_WIDTH, Samples = new List(Samples.Select(s => new SampleInfo { Bank = s.Bank, @@ -110,7 +110,7 @@ namespace osu.Game.Rulesets.Catch.Objects AddNested(new Droplet { StartTime = time, - X = X + Curve.PositionAt(distanceProgress).X / CatchPlayfield.BASE_WIDTH, + X = X + Path.PositionAt(distanceProgress).X / CatchPlayfield.BASE_WIDTH, Samples = new List(Samples.Select(s => new SampleInfo { Bank = s.Bank, @@ -127,12 +127,12 @@ namespace osu.Game.Rulesets.Catch.Objects { Samples = Samples, StartTime = spanStartTime + spanDuration, - X = X + Curve.PositionAt(reversed ? 0 : 1).X / CatchPlayfield.BASE_WIDTH + X = X + Path.PositionAt(reversed ? 0 : 1).X / CatchPlayfield.BASE_WIDTH }); } } - public double EndTime => StartTime + this.SpanCount() * Curve.Distance / Velocity; + public double EndTime => StartTime + this.SpanCount() * Path.Distance / Velocity; public float EndX => X + this.CurvePositionAt(1).X / CatchPlayfield.BASE_WIDTH; @@ -140,24 +140,24 @@ namespace osu.Game.Rulesets.Catch.Objects public double Distance { - get { return Curve.Distance; } - set { Curve.Distance = value; } + get { return Path.Distance; } + set { Path.Distance = value; } } - public SliderCurve Curve { get; } = new SliderCurve(); + public SliderPath Path { get; } = new SliderPath(); public Vector2[] ControlPoints { - get { return Curve.ControlPoints; } - set { Curve.ControlPoints = value; } + get { return Path.ControlPoints; } + set { Path.ControlPoints = value; } } public List> RepeatSamples { get; set; } = new List>(); - public CurveType CurveType + public PathType PathType { - get { return Curve.CurveType; } - set { Curve.CurveType = value; } + get { return Path.PathType; } + set { Path.PathType = value; } } public double? LegacyLastTickOffset { get; set; } diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseSlider.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseSlider.cs index 300ac16155..4c0385deda 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestCaseSlider.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseSlider.cs @@ -181,7 +181,7 @@ namespace osu.Game.Rulesets.Osu.Tests { var slider = new Slider { - CurveType = CurveType.Linear, + PathType = PathType.Linear, StartTime = Time.Current + 1000, Position = new Vector2(-200, 0), ControlPoints = new[] @@ -207,7 +207,7 @@ namespace osu.Game.Rulesets.Osu.Tests { var slider = new Slider { - CurveType = CurveType.Bezier, + PathType = PathType.Bezier, StartTime = Time.Current + 1000, Position = new Vector2(-200, 0), ControlPoints = new[] @@ -232,7 +232,7 @@ namespace osu.Game.Rulesets.Osu.Tests { var slider = new Slider { - CurveType = CurveType.Linear, + PathType = PathType.Linear, StartTime = Time.Current + 1000, Position = new Vector2(0, 0), ControlPoints = new[] @@ -264,7 +264,7 @@ namespace osu.Game.Rulesets.Osu.Tests { StartTime = Time.Current + 1000, Position = new Vector2(-100, 0), - CurveType = CurveType.Catmull, + PathType = PathType.Catmull, ControlPoints = new[] { Vector2.Zero, diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs index 1ba3e26e65..87e0e1a7ec 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs @@ -24,8 +24,8 @@ namespace osu.Game.Rulesets.Osu.Tests typeof(SliderCircleSelectionMask), typeof(SliderBodyPiece), typeof(SliderCircle), - typeof(ControlPointVisualiser), - typeof(ControlPointPiece) + typeof(PathControlPointVisualiser), + typeof(PathControlPointPiece) }; private readonly DrawableSlider drawableObject; @@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Osu.Tests new Vector2(150, 150), new Vector2(300, 0) }, - CurveType = CurveType.Bezier, + PathType = PathType.Bezier, Distance = 350 }; diff --git a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs index b2914d4b82..9f432fc31a 100644 --- a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs +++ b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs @@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps StartTime = original.StartTime, Samples = original.Samples, ControlPoints = curveData.ControlPoints, - CurveType = curveData.CurveType, + PathType = curveData.PathType, Distance = curveData.Distance, RepeatSamples = curveData.RepeatSamples, RepeatCount = curveData.RepeatCount, diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs index d6684f55af..39e3c009da 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -108,7 +108,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing progress = progress % 1; // ReSharper disable once PossibleInvalidOperationException (bugged in current r# version) - var diff = slider.StackedPosition + slider.Curve.PositionAt(progress) - slider.LazyEndPosition.Value; + var diff = slider.StackedPosition + slider.Path.PositionAt(progress) - slider.LazyEndPosition.Value; float dist = diff.Length; if (dist > approxFollowCircleRadius) diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/PathControlPointPiece.cs similarity index 95% rename from osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs rename to osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/PathControlPointPiece.cs index aedde870ca..70156578b4 100644 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointPiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/PathControlPointPiece.cs @@ -14,7 +14,7 @@ using OpenTK; namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components { - public class ControlPointPiece : CompositeDrawable + public class PathControlPointPiece : CompositeDrawable { private readonly Slider slider; private readonly int index; @@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components [Resolved] private OsuColour colours { get; set; } - public ControlPointPiece(Slider slider, int index) + public PathControlPointPiece(Slider slider, int index) { this.slider = slider; this.index = index; @@ -97,7 +97,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components newControlPoints[index - 1] = newControlPoints[index]; slider.ControlPoints = newControlPoints; - slider.Curve.Calculate(true); + slider.Path.Calculate(true); return true; } diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointVisualiser.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/PathControlPointVisualiser.cs similarity index 54% rename from osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointVisualiser.cs rename to osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/PathControlPointVisualiser.cs index d8031c4f5b..1d25f8cd39 100644 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/ControlPointVisualiser.cs +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/PathControlPointVisualiser.cs @@ -7,26 +7,26 @@ using osu.Game.Rulesets.Osu.Objects; namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components { - public class ControlPointVisualiser : CompositeDrawable + public class PathControlPointVisualiser : CompositeDrawable { private readonly Slider slider; - private readonly Container pieces; + private readonly Container pieces; - public ControlPointVisualiser(Slider slider) + public PathControlPointVisualiser(Slider slider) { this.slider = slider; - InternalChild = pieces = new Container { RelativeSizeAxes = Axes.Both }; + InternalChild = pieces = new Container { RelativeSizeAxes = Axes.Both }; - slider.ControlPointsChanged += _ => updateControlPoints(); - updateControlPoints(); + slider.ControlPointsChanged += _ => updatePathControlPoints(); + updatePathControlPoints(); } - private void updateControlPoints() + private void updatePathControlPoints() { while (slider.ControlPoints.Length > pieces.Count) - pieces.Add(new ControlPointPiece(slider, pieces.Count)); + pieces.Add(new PathControlPointPiece(slider, pieces.Count)); while (slider.ControlPoints.Length < pieces.Count) pieces.Remove(pieces[pieces.Count - 1]); } diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderCirclePiece.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderCirclePiece.cs index a8565fafb6..7864429d93 100644 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderCirclePiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/Components/SliderCirclePiece.cs @@ -25,10 +25,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components switch (position) { case SliderPosition.Start: - Position = slider.StackedPosition + slider.Curve.PositionAt(0); + Position = slider.StackedPosition + slider.Path.PositionAt(0); break; case SliderPosition.End: - Position = slider.StackedPosition + slider.Curve.PositionAt(1); + Position = slider.StackedPosition + slider.Path.PositionAt(1); break; } } diff --git a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/SliderSelectionMask.cs b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/SliderSelectionMask.cs index 8478374a5f..b79b0ba1fb 100644 --- a/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/SliderSelectionMask.cs +++ b/osu.Game.Rulesets.Osu/Edit/Masks/SliderMasks/SliderSelectionMask.cs @@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks new SliderBodyPiece(sliderObject), headMask = new SliderCircleSelectionMask(slider.HeadCircle, sliderObject, SliderPosition.Start), new SliderCircleSelectionMask(slider.TailCircle, sliderObject, SliderPosition.End), - new ControlPointVisualiser(sliderObject), + new PathControlPointVisualiser(sliderObject), }; } diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHardRock.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHardRock.cs index 1b3725a15e..e01d71e1f8 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHardRock.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHardRock.cs @@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Osu.Mods newControlPoints[i] = new Vector2(slider.ControlPoints[i].X, -slider.ControlPoints[i].Y); slider.ControlPoints = newControlPoints; - slider.Curve?.Calculate(); // Recalculate the slider curve + slider.Path?.Calculate(); // Recalculate the slider curve } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs index 7599001a82..a137343cfe 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs @@ -121,7 +121,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables double completionProgress = MathHelper.Clamp((Time.Current - slider.StartTime) / slider.Duration, 0, 1); foreach (var c in components.OfType()) c.UpdateProgress(completionProgress); - foreach (var c in components.OfType()) c.UpdateSnakingPosition(slider.Curve.PositionAt(Body.SnakedStart ?? 0), slider.Curve.PositionAt(Body.SnakedEnd ?? 0)); + foreach (var c in components.OfType()) c.UpdateSnakingPosition(slider.Path.PositionAt(Body.SnakedStart ?? 0), slider.Path.PositionAt(Body.SnakedEnd ?? 0)); foreach (var t in components.OfType()) t.Tracking = Ball.Tracking; Size = Body.Size; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SnakingSliderBody.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SnakingSliderBody.cs index 3d02f9a92d..0e6f3ad16c 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SnakingSliderBody.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SnakingSliderBody.cs @@ -75,7 +75,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces public void Refresh() { // Generate the entire curve - slider.Curve.GetPathToProgress(CurrentCurve, 0, 1); + slider.Path.GetPathToProgress(CurrentCurve, 0, 1); SetVertices(CurrentCurve); // The body is sized to the full path size to avoid excessive autosize computations @@ -103,7 +103,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces SnakedStart = p0; SnakedEnd = p1; - slider.Curve.GetPathToProgress(CurrentCurve, p0, p1); + slider.Path.GetPathToProgress(CurrentCurve, p0, p1); SetVertices(CurrentCurve); diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs index de7ba8451b..b7240991d4 100644 --- a/osu.Game.Rulesets.Osu/Objects/Slider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs @@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.Objects public event Action ControlPointsChanged; - public double EndTime => StartTime + this.SpanCount() * Curve.Distance / Velocity; + public double EndTime => StartTime + this.SpanCount() * Path.Distance / Velocity; public double Duration => EndTime - StartTime; public Vector2 StackedPositionAt(double t) => StackedPosition + this.CurvePositionAt(t); @@ -52,16 +52,16 @@ namespace osu.Game.Rulesets.Osu.Objects } } - public SliderCurve Curve { get; } = new SliderCurve(); + public SliderPath Path { get; } = new SliderPath(); public Vector2[] ControlPoints { - get => Curve.ControlPoints; + get => Path.ControlPoints; set { - if (Curve.ControlPoints == value) + if (Path.ControlPoints == value) return; - Curve.ControlPoints = value; + Path.ControlPoints = value; ControlPointsChanged?.Invoke(value); @@ -70,16 +70,16 @@ namespace osu.Game.Rulesets.Osu.Objects } } - public CurveType CurveType + public PathType PathType { - get { return Curve.CurveType; } - set { Curve.CurveType = value; } + get { return Path.PathType; } + set { Path.PathType = value; } } public double Distance { - get { return Curve.Distance; } - set { Curve.Distance = value; } + get { return Path.Distance; } + set { Path.Distance = value; } } public override Vector2 Position @@ -189,7 +189,7 @@ namespace osu.Game.Rulesets.Osu.Objects private void createTicks() { - var length = Curve.Distance; + var length = Path.Distance; var tickDistance = MathHelper.Clamp(TickDistance, 0, length); if (tickDistance == 0) return; @@ -228,7 +228,7 @@ namespace osu.Game.Rulesets.Osu.Objects SpanIndex = span, SpanStartTime = spanStartTime, StartTime = spanStartTime + timeProgress * SpanDuration, - Position = Position + Curve.PositionAt(distanceProgress), + Position = Position + Path.PositionAt(distanceProgress), StackHeight = StackHeight, Scale = Scale, Samples = sampleList @@ -246,7 +246,7 @@ namespace osu.Game.Rulesets.Osu.Objects RepeatIndex = repeatIndex, SpanDuration = SpanDuration, StartTime = StartTime + repeat * SpanDuration, - Position = Position + Curve.PositionAt(repeat % 2), + Position = Position + Path.PositionAt(repeat % 2), StackHeight = StackHeight, Scale = Scale, Samples = new List(RepeatSamples[repeatIndex]) diff --git a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHitObjectParser.cs index 9c9fc2e742..85efdca07b 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHitObjectParser.cs @@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch }; } - protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, CurveType curveType, int repeatCount, List> repeatSamples) + protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List> repeatSamples) { newCombo |= forceNewCombo; comboOffset += extraComboOffset; @@ -52,7 +52,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch ComboOffset = comboOffset, ControlPoints = controlPoints, Distance = length, - CurveType = curveType, + PathType = pathType, RepeatSamples = repeatSamples, RepeatCount = repeatCount }; diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs index 965e76d27a..73f70d414f 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs @@ -70,7 +70,7 @@ namespace osu.Game.Rulesets.Objects.Legacy } else if (type.HasFlag(ConvertHitObjectType.Slider)) { - CurveType curveType = CurveType.Catmull; + PathType pathType = PathType.Catmull; double length = 0; string[] pointSplit = split[5].Split('|'); @@ -90,16 +90,16 @@ namespace osu.Game.Rulesets.Objects.Legacy switch (t) { case @"C": - curveType = CurveType.Catmull; + pathType = PathType.Catmull; break; case @"B": - curveType = CurveType.Bezier; + pathType = PathType.Bezier; break; case @"L": - curveType = CurveType.Linear; + pathType = PathType.Linear; break; case @"P": - curveType = CurveType.PerfectCurve; + pathType = PathType.PerfectCurve; break; } @@ -113,8 +113,8 @@ namespace osu.Game.Rulesets.Objects.Legacy // osu-stable special-cased colinear perfect curves to a CurveType.Linear bool isLinear(Vector2[] p) => Precision.AlmostEquals(0, (p[1].Y - p[0].Y) * (p[2].X - p[0].X) - (p[1].X - p[0].X) * (p[2].Y - p[0].Y)); - if (points.Length == 3 && curveType == CurveType.PerfectCurve && isLinear(points)) - curveType = CurveType.Linear; + if (points.Length == 3 && pathType == PathType.PerfectCurve && isLinear(points)) + pathType = PathType.Linear; int repeatCount = Convert.ToInt32(split[6], CultureInfo.InvariantCulture); @@ -178,7 +178,7 @@ namespace osu.Game.Rulesets.Objects.Legacy for (int i = 0; i < nodes; i++) nodeSamples.Add(convertSoundType(nodeSoundTypes[i], nodeBankInfos[i])); - result = CreateSlider(pos, combo, comboOffset, points, length, curveType, repeatCount, nodeSamples); + result = CreateSlider(pos, combo, comboOffset, points, length, pathType, repeatCount, nodeSamples); } else if (type.HasFlag(ConvertHitObjectType.Spinner)) { @@ -268,11 +268,11 @@ namespace osu.Game.Rulesets.Objects.Legacy /// When starting a new combo, the offset of the new combo relative to the current one. /// The slider control points. /// The slider length. - /// The slider curve type. + /// The slider curve type. /// The slider repeat count. /// The samples to be played when the repeat nodes are hit. This includes the head and tail of the slider. /// The hit object. - protected abstract HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, CurveType curveType, int repeatCount, List> repeatSamples); + protected abstract HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List> repeatSamples); /// /// Creates a legacy Spinner-type hit object. diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs index 93c49ea3ce..6030bff427 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs @@ -20,9 +20,9 @@ namespace osu.Game.Rulesets.Objects.Legacy /// /// s don't need a curve since they're converted to ruleset-specific hitobjects. /// - public SliderCurve Curve { get; } = null; + public SliderPath Path { get; } = null; public Vector2[] ControlPoints { get; set; } - public CurveType CurveType { get; set; } + public PathType PathType { get; set; } public double Distance { get; set; } diff --git a/osu.Game/Rulesets/Objects/Legacy/Mania/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/Mania/ConvertHitObjectParser.cs index 68e05f6223..6f10880aa2 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Mania/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Mania/ConvertHitObjectParser.cs @@ -26,14 +26,14 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania }; } - protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, CurveType curveType, int repeatCount, List> repeatSamples) + protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List> repeatSamples) { return new ConvertSlider { X = position.X, ControlPoints = controlPoints, Distance = length, - CurveType = curveType, + PathType = pathType, RepeatSamples = repeatSamples, RepeatCount = repeatCount }; diff --git a/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHitObjectParser.cs index f3c815fc32..31c200eddc 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHitObjectParser.cs @@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu }; } - protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, CurveType curveType, int repeatCount, List> repeatSamples) + protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List> repeatSamples) { newCombo |= forceNewCombo; comboOffset += extraComboOffset; @@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu ComboOffset = comboOffset, ControlPoints = controlPoints, Distance = Math.Max(0, length), - CurveType = curveType, + PathType = pathType, RepeatSamples = repeatSamples, RepeatCount = repeatCount }; diff --git a/osu.Game/Rulesets/Objects/Legacy/Taiko/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/Taiko/ConvertHitObjectParser.cs index 985a032640..0a244bb6c6 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Taiko/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Taiko/ConvertHitObjectParser.cs @@ -23,13 +23,13 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko return new ConvertHit(); } - protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, CurveType curveType, int repeatCount, List> repeatSamples) + protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List> repeatSamples) { return new ConvertSlider { ControlPoints = controlPoints, Distance = length, - CurveType = curveType, + PathType = pathType, RepeatSamples = repeatSamples, RepeatCount = repeatCount }; diff --git a/osu.Game/Rulesets/Objects/SliderCurve.cs b/osu.Game/Rulesets/Objects/SliderPath.cs similarity index 92% rename from osu.Game/Rulesets/Objects/SliderCurve.cs rename to osu.Game/Rulesets/Objects/SliderPath.cs index 6a8192a4f2..46f8cae8a0 100644 --- a/osu.Game/Rulesets/Objects/SliderCurve.cs +++ b/osu.Game/Rulesets/Objects/SliderPath.cs @@ -10,13 +10,13 @@ using OpenTK; namespace osu.Game.Rulesets.Objects { - public class SliderCurve + public class SliderPath { public double Distance; public Vector2[] ControlPoints; - public CurveType CurveType = CurveType.PerfectCurve; + public PathType PathType = PathType.PerfectCurve; public Vector2 Offset; @@ -25,15 +25,15 @@ namespace osu.Game.Rulesets.Objects private List calculateSubpath(ReadOnlySpan subControlPoints) { - switch (CurveType) + switch (PathType) { - case CurveType.Linear: + case PathType.Linear: var result = new List(subControlPoints.Length); foreach (var c in subControlPoints) result.Add(c); return result; - case CurveType.PerfectCurve: + case PathType.PerfectCurve: //we can only use CircularArc iff we have exactly three control points and no dissection. if (ControlPoints.Length != 3 || subControlPoints.Length != 3) break; @@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Objects break; return subpath; - case CurveType.Catmull: + case PathType.Catmull: return new CatmullApproximator(subControlPoints).CreateCatmull(); } @@ -93,7 +93,7 @@ namespace osu.Game.Rulesets.Objects Vector2 diff = calculatedPath[i + 1] - calculatedPath[i]; double d = diff.Length; - // Shorten slider curves that are too long compared to what's + // Shorten slider paths that are too long compared to what's // in the .osu file. if (Distance - l < d) { @@ -109,7 +109,7 @@ namespace osu.Game.Rulesets.Objects cumulativeLength.Add(l); } - // Lengthen slider curves that are too short compared to what's + // Lengthen slider paths that are too short compared to what's // in the .osu file. if (l < Distance && calculatedPath.Count > 1) { @@ -191,10 +191,10 @@ namespace osu.Game.Rulesets.Objects } /// - /// Computes the slider curve until a given progress that ranges from 0 (beginning of the slider) + /// Computes the slider path until a given progress that ranges from 0 (beginning of the slider) /// to 1 (end of the slider) and stores the generated path in the given list. /// - /// The list to be filled with the computed curve. + /// The list to be filled with the computed path. /// Start progress. Ranges from 0 (beginning of the slider) to 1 (end of the slider). /// End progress. Ranges from 0 (beginning of the slider) to 1 (end of the slider). public void GetPathToProgress(List path, double p0, double p1) @@ -219,10 +219,10 @@ namespace osu.Game.Rulesets.Objects } /// - /// Computes the position on the slider at a given progress that ranges from 0 (beginning of the curve) - /// to 1 (end of the curve). + /// Computes the position on the slider at a given progress that ranges from 0 (beginning of the path) + /// to 1 (end of the path). /// - /// Ranges from 0 (beginning of the curve) to 1 (end of the curve). + /// Ranges from 0 (beginning of the path) to 1 (end of the path). /// public Vector2 PositionAt(double progress) { diff --git a/osu.Game/Rulesets/Objects/Types/IHasCurve.cs b/osu.Game/Rulesets/Objects/Types/IHasCurve.cs index 69b2f722e7..2a0d495e94 100644 --- a/osu.Game/Rulesets/Objects/Types/IHasCurve.cs +++ b/osu.Game/Rulesets/Objects/Types/IHasCurve.cs @@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Objects.Types /// /// The curve. /// - SliderCurve Curve { get; } + SliderPath Path { get; } /// /// The control points that shape the curve. @@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Objects.Types /// /// The type of curve. /// - CurveType CurveType { get; } + PathType PathType { get; } } public static class HasCurveExtensions @@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.Objects.Types /// [0, 1] where 0 is the start time of the and 1 is the end time of the . /// The position on the curve. public static Vector2 CurvePositionAt(this IHasCurve obj, double progress) - => obj.Curve.PositionAt(obj.ProgressAt(progress)); + => obj.Path.PositionAt(obj.ProgressAt(progress)); /// /// Computes the progress along the curve relative to how much of the has been completed. diff --git a/osu.Game/Rulesets/Objects/Types/CurveType.cs b/osu.Game/Rulesets/Objects/Types/PathType.cs similarity index 91% rename from osu.Game/Rulesets/Objects/Types/CurveType.cs rename to osu.Game/Rulesets/Objects/Types/PathType.cs index 1cee6202b6..5156302fe1 100644 --- a/osu.Game/Rulesets/Objects/Types/CurveType.cs +++ b/osu.Game/Rulesets/Objects/Types/PathType.cs @@ -3,7 +3,7 @@ namespace osu.Game.Rulesets.Objects.Types { - public enum CurveType + public enum PathType { Catmull, Bezier,