diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 221e4746cb..0000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,8 +0,0 @@ -Add any details pertaining to developers above the break. - -- [ ] Depends on #PR -- Closes #ISSUE - ---- - -Add a sentence or two describing this change in plain english. This will be displayed on the [changelog](https://osu.ppy.sh/home/changelog). A single screenshot or short gif is also welcomed. \ No newline at end of file diff --git a/.gitignore b/.gitignore index f95a04e517..0e2850a01c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,10 @@ *.userprefs ### Cake ### -tools/* -!tools/cakebuild.csproj +tools/** +build/tools/** + +fastlane/report.xml # Build results bin/[Dd]ebug/ diff --git a/.vscode/launch.json b/.vscode/launch.json index 10c6f02314..c3306c2db7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -68,6 +68,20 @@ } }, "console": "internalConsole" + }, + { + "name": "Cake: Debug Script", + "type": "coreclr", + "request": "launch", + "program": "${workspaceRoot}/build/tools/Cake.CoreCLR/0.30.0/Cake.dll", + "args": [ + "${workspaceRoot}/build/build.cake", + "--debug", + "--verbosity=diagnostic" + ], + "cwd": "${workspaceRoot}/build", + "stopAtEntry": true, + "externalConsole": false } ] } diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000..cdd3a6b349 --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +source "https://rubygems.org" + +gem "fastlane" + +plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') +eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000000..17c0db12e7 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,173 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.0) + addressable (2.6.0) + public_suffix (>= 2.0.2, < 4.0) + atomos (0.1.3) + babosa (1.0.2) + claide (1.0.2) + colored (1.2) + colored2 (3.1.2) + commander-fastlane (4.4.6) + highline (~> 1.7.2) + declarative (0.0.10) + declarative-option (0.1.0) + digest-crc (0.4.1) + domain_name (0.5.20180417) + unf (>= 0.0.5, < 1.0.0) + dotenv (2.7.1) + emoji_regex (1.0.1) + excon (0.62.0) + faraday (0.15.4) + multipart-post (>= 1.2, < 3) + faraday-cookie_jar (0.0.6) + faraday (>= 0.7.4) + http-cookie (~> 1.0.0) + faraday_middleware (0.13.1) + faraday (>= 0.7.4, < 1.0) + fastimage (2.1.5) + fastlane (2.117.0) + CFPropertyList (>= 2.3, < 4.0.0) + addressable (>= 2.3, < 3.0.0) + babosa (>= 1.0.2, < 2.0.0) + bundler (>= 1.12.0, < 3.0.0) + colored + commander-fastlane (>= 4.4.6, < 5.0.0) + dotenv (>= 2.1.1, < 3.0.0) + emoji_regex (>= 0.1, < 2.0) + excon (>= 0.45.0, < 1.0.0) + faraday (~> 0.9) + faraday-cookie_jar (~> 0.0.6) + faraday_middleware (~> 0.9) + fastimage (>= 2.1.0, < 3.0.0) + gh_inspector (>= 1.1.2, < 2.0.0) + google-api-client (>= 0.21.2, < 0.24.0) + google-cloud-storage (>= 1.15.0, < 2.0.0) + highline (>= 1.7.2, < 2.0.0) + json (< 3.0.0) + mini_magick (~> 4.5.1) + multi_json + multi_xml (~> 0.5) + multipart-post (~> 2.0.0) + plist (>= 3.1.0, < 4.0.0) + public_suffix (~> 2.0.0) + rubyzip (>= 1.2.2, < 2.0.0) + security (= 0.1.3) + simctl (~> 1.6.3) + slack-notifier (>= 2.0.0, < 3.0.0) + terminal-notifier (>= 1.6.2, < 2.0.0) + terminal-table (>= 1.4.5, < 2.0.0) + tty-screen (>= 0.6.3, < 1.0.0) + tty-spinner (>= 0.8.0, < 1.0.0) + word_wrap (~> 1.0.0) + xcodeproj (>= 1.6.0, < 2.0.0) + xcpretty (~> 0.3.0) + xcpretty-travis-formatter (>= 0.0.3) + fastlane-plugin-clean_testflight_testers (0.2.0) + fastlane-plugin-souyuz (0.8.1) + souyuz (>= 0.8.1) + fastlane-plugin-xamarin (0.6.3) + gh_inspector (1.1.3) + google-api-client (0.23.9) + addressable (~> 2.5, >= 2.5.1) + googleauth (>= 0.5, < 0.7.0) + httpclient (>= 2.8.1, < 3.0) + mime-types (~> 3.0) + representable (~> 3.0) + retriable (>= 2.0, < 4.0) + signet (~> 0.9) + google-cloud-core (1.3.0) + google-cloud-env (~> 1.0) + google-cloud-env (1.0.5) + faraday (~> 0.11) + google-cloud-storage (1.16.0) + digest-crc (~> 0.4) + google-api-client (~> 0.23) + google-cloud-core (~> 1.2) + googleauth (>= 0.6.2, < 0.10.0) + googleauth (0.6.7) + faraday (~> 0.12) + jwt (>= 1.4, < 3.0) + memoist (~> 0.16) + multi_json (~> 1.11) + os (>= 0.9, < 2.0) + signet (~> 0.7) + highline (1.7.10) + http-cookie (1.0.3) + domain_name (~> 0.5) + httpclient (2.8.3) + json (2.2.0) + jwt (2.1.0) + memoist (0.16.0) + mime-types (3.2.2) + mime-types-data (~> 3.2015) + mime-types-data (3.2018.0812) + mini_magick (4.5.1) + mini_portile2 (2.4.0) + multi_json (1.13.1) + multi_xml (0.6.0) + multipart-post (2.0.0) + nanaimo (0.2.6) + naturally (2.2.0) + nokogiri (1.10.1) + mini_portile2 (~> 2.4.0) + os (1.0.0) + plist (3.5.0) + public_suffix (2.0.5) + representable (3.0.4) + declarative (< 0.1.0) + declarative-option (< 0.2.0) + uber (< 0.2.0) + retriable (3.1.2) + rouge (2.0.7) + rubyzip (1.2.2) + security (0.1.3) + signet (0.11.0) + addressable (~> 2.3) + faraday (~> 0.9) + jwt (>= 1.5, < 3.0) + multi_json (~> 1.10) + simctl (1.6.5) + CFPropertyList + naturally + slack-notifier (2.3.2) + souyuz (0.8.1) + fastlane (>= 2.29.0) + highline (~> 1.7) + nokogiri (~> 1.7) + terminal-notifier (1.8.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) + tty-cursor (0.6.1) + tty-screen (0.6.5) + tty-spinner (0.9.0) + tty-cursor (~> 0.6.0) + uber (0.1.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.5) + unicode-display_width (1.4.1) + word_wrap (1.0.0) + xcodeproj (1.8.1) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.2.6) + xcpretty (0.3.0) + rouge (~> 2.0.7) + xcpretty-travis-formatter (1.0.0) + xcpretty (~> 0.2, >= 0.0.7) + +PLATFORMS + ruby + +DEPENDENCIES + fastlane + fastlane-plugin-clean_testflight_testers + fastlane-plugin-souyuz + fastlane-plugin-xamarin + +BUNDLED WITH + 2.0.1 diff --git a/build.ps1 b/build.ps1 index 9968673c90..c6a0bf6d4a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -41,27 +41,28 @@ Param( [switch]$ShowDescription, [Alias("WhatIf", "Noop")] [switch]$DryRun, - [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] + [Parameter(Position = 0, Mandatory = $false, ValueFromRemainingArguments = $true)] [string[]]$ScriptArgs ) Write-Host "Preparing to run build script..." # Determine the script root for resolving other paths. -if(!$PSScriptRoot){ +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 "cakebuild.csproj" +$BUILD_DIR = Join-Path $PSScriptRoot "build" +$TOOLS_DIR = Join-Path $BUILD_DIR "tools" +$CAKE_CSPROJ = Join-Path $BUILD_DIR "cakebuild.csproj" # Install the required tools locally. Write-Host "Restoring cake tools..." Invoke-Expression "dotnet restore `"$CAKE_CSPROJ`" --packages `"$TOOLS_DIR`"" | Out-Null # Find the Cake executable -$CAKE_EXECUTABLE = (Get-ChildItem -Path ./tools/cake.coreclr/ -Filter Cake.dll -Recurse).FullName +$CAKE_EXECUTABLE = (Get-ChildItem -Path "$TOOLS_DIR/cake.coreclr/" -Filter Cake.dll -Recurse).FullName # Build Cake arguments $cakeArguments = @("$Script"); @@ -75,5 +76,7 @@ $cakeArguments += $ScriptArgs # Start Cake Write-Host "Running build script..." +Push-Location -Path $BUILD_DIR Invoke-Expression "dotnet `"$CAKE_EXECUTABLE`" $cakeArguments" +Pop-Location exit $LASTEXITCODE diff --git a/build.sh b/build.sh index caf1702f41..8f1ef5b455 100755 --- a/build.sh +++ b/build.sh @@ -6,12 +6,13 @@ echo "Preparing to run build script..." +cd build SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) TOOLS_DIR=$SCRIPT_DIR/tools CAKE_BINARY_PATH=$TOOLS_DIR/"cake.coreclr" SCRIPT="build.cake" -CAKE_CSPROJ=$TOOLS_DIR/"cakebuild.csproj" +CAKE_CSPROJ=$SCRIPT_DIR/"cakebuild.csproj" # Parse arguments. CAKE_ARGUMENTS=() diff --git a/build.cake b/build/build.cake similarity index 75% rename from build.cake rename to build/build.cake index bc7dfafb8c..81deeb3bc7 100644 --- a/build.cake +++ b/build/build.cake @@ -1,6 +1,7 @@ #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" +var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); /////////////////////////////////////////////////////////////////////////////// // ARGUMENTS @@ -9,30 +10,24 @@ var target = Argument("target", "Build"); var configuration = Argument("configuration", "Release"); -var osuSolution = new FilePath("./osu.sln"); +var rootDirectory = new DirectoryPath(".."); +var solution = rootDirectory.CombineWithFilePath("osu.sln"); /////////////////////////////////////////////////////////////////////////////// // TASKS /////////////////////////////////////////////////////////////////////////////// -Task("Restore") - .Does(() => { - DotNetCoreRestore(osuSolution.FullPath); - }); - Task("Compile") - .IsDependentOn("Restore") .Does(() => { - DotNetCoreBuild(osuSolution.FullPath, new DotNetCoreBuildSettings { + DotNetCoreBuild(solution.FullPath, new DotNetCoreBuildSettings { Configuration = configuration, - NoRestore = true, }); }); Task("Test") .IsDependentOn("Compile") .Does(() => { - var testAssemblies = GetFiles("**/*.Tests/bin/**/*.Tests.dll"); + var testAssemblies = GetFiles(rootDirectory + "/**/*.Tests/bin/**/*.Tests.dll"); DotNetCoreVSTest(testAssemblies, new DotNetCoreVSTestSettings { Logger = AppVeyor.IsRunningOnAppVeyor ? "Appveyor" : $"trx", @@ -46,9 +41,7 @@ Task("InspectCode") .WithCriteria(IsRunningOnWindows()) .IsDependentOn("Compile") .Does(() => { - var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); - - InspectCode(osuSolution, new InspectCodeSettings { + InspectCode(solution, new InspectCodeSettings { CachesHome = "inspectcode", OutputFile = "inspectcodereport.xml", }); @@ -59,7 +52,7 @@ Task("InspectCode") Task("CodeFileSanity") .Does(() => { ValidateCodeSanity(new ValidateCodeSanitySettings { - RootDirectory = ".", + RootDirectory = rootDirectory.FullPath, IsAppveyorBuild = AppVeyor.IsRunningOnAppVeyor }); }); diff --git a/tools/cakebuild.csproj b/build/cakebuild.csproj similarity index 100% rename from tools/cakebuild.csproj rename to build/cakebuild.csproj diff --git a/fastlane/Appfile b/fastlane/Appfile new file mode 100644 index 0000000000..083de66985 --- /dev/null +++ b/fastlane/Appfile @@ -0,0 +1,2 @@ +app_identifier("sh.ppy.osulazer") # The bundle identifier of your app +apple_id("apple-dev@ppy.sh") # Your Apple email address diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 0000000000..3f64bcdf19 --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,65 @@ +update_fastlane + +default_platform(:ios) + +platform :ios do + lane :testflight_prune_dry do + clean_testflight_testers(days_of_inactivity:45, dry_run: true) + end + + # Specify a custom number for what's "inactive" + lane :testflight_prune do + clean_testflight_testers(days_of_inactivity: 45) # 120 days, so about 4 months + end + + lane :update_version do |options| + options[:plist_path] = '../osu.iOS/Info.plist' + app_version(options) + end + + desc 'Deploy to testflight' + lane :beta do |options| + update_version(options) + + provision( + type: 'appstore' + ) + + build( + build_configuration: 'Release', + build_platform: 'iPhone' + ) + + client = HTTPClient.new + changelog = client.get_content 'https://gist.githubusercontent.com/peppy/ab89c29dcc0dce95f39eb218e8fad197/raw' + changelog.gsub!('$BUILD_ID', options[:build]) + + pilot( + wait_processing_interval: 900, + changelog: changelog, + ipa: './osu.iOS/bin/iPhone/Release/osu.iOS.ipa' + ) + end + + desc 'Compile the project' + lane :build do + nuget_restore( + project_path: 'osu.iOS.sln' + ) + + souyuz( + platform: "ios", + build_target: "osu_iOS", + plist_path: "../osu.iOS/Info.plist" + ) + end + + desc 'Install provisioning profiles using match' + lane :provision do |options| + if Helper.is_ci? + options[:readonly] = true + end + + match(options) + end +end diff --git a/fastlane/Matchfile b/fastlane/Matchfile new file mode 100644 index 0000000000..40c974b09e --- /dev/null +++ b/fastlane/Matchfile @@ -0,0 +1 @@ +git_url('https://github.com/peppy/apple-certificates') diff --git a/fastlane/Pluginfile b/fastlane/Pluginfile new file mode 100644 index 0000000000..9f4f47f213 --- /dev/null +++ b/fastlane/Pluginfile @@ -0,0 +1,7 @@ +# Autogenerated by fastlane +# +# Ensure this file is checked in to source control! + +gem 'fastlane-plugin-clean_testflight_testers' +gem 'fastlane-plugin-souyuz' +gem 'fastlane-plugin-xamarin' diff --git a/fastlane/README.md b/fastlane/README.md new file mode 100644 index 0000000000..53bbc62cae --- /dev/null +++ b/fastlane/README.md @@ -0,0 +1,54 @@ +fastlane documentation +================ +# Installation + +Make sure you have the latest version of the Xcode command line tools installed: + +``` +xcode-select --install +``` + +Install _fastlane_ using +``` +[sudo] gem install fastlane -NV +``` +or alternatively using `brew cask install fastlane` + +# Available Actions +## iOS +### ios testflight_prune_dry +``` +fastlane ios testflight_prune_dry +``` + +### ios testflight_prune +``` +fastlane ios testflight_prune +``` + +### ios update_version +``` +fastlane ios update_version +``` + +### ios beta +``` +fastlane ios beta +``` +Deploy to testflight +### ios build +``` +fastlane ios build +``` +Compile the project +### ios provision +``` +fastlane ios provision +``` +Install provisioning profiles using match + +---- + +This README.md is auto-generated and will be re-generated every time [fastlane](https://fastlane.tools) is run. +More information about fastlane can be found on [fastlane.tools](https://fastlane.tools). +The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools). diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index ef8ec0c105..7e5b003f03 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -83,8 +83,7 @@ namespace osu.Desktop public override void SetHost(GameHost host) { base.SetHost(host); - var desktopWindow = host.Window as DesktopGameWindow; - if (desktopWindow != null) + if (host.Window is DesktopGameWindow desktopWindow) { desktopWindow.CursorState |= CursorState.Hidden; diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 5b67d528ae..b8a0e337b6 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -60,7 +60,7 @@ namespace osu.Desktop.Overlays { new OsuSpriteText { - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold), Text = game.Name }, new OsuSpriteText @@ -74,9 +74,8 @@ namespace osu.Desktop.Overlays { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - TextSize = 12, + Font = OsuFont.Numeric.With(size: 12), Colour = colours.Yellow, - Font = @"Venera", Text = @"Development Build" }, new Sprite diff --git a/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs b/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs index d40a108c5e..7f85d4ccce 100644 --- a/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs +++ b/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs @@ -34,13 +34,16 @@ namespace osu.Game.Rulesets.Catch.Tests case JuiceStream stream: foreach (var nested in stream.NestedHitObjects) yield return new ConvertValue((CatchHitObject)nested); + break; case BananaShower shower: foreach (var nested in shower.NestedHitObjects) yield return new ConvertValue((CatchHitObject)nested); + break; default: yield return new ConvertValue((CatchHitObject)hitObject); + break; } } diff --git a/osu.Game.Rulesets.Catch.Tests/CatchDifficultyCalculatorTest.cs b/osu.Game.Rulesets.Catch.Tests/CatchDifficultyCalculatorTest.cs new file mode 100644 index 0000000000..01c57a6b9a --- /dev/null +++ b/osu.Game.Rulesets.Catch.Tests/CatchDifficultyCalculatorTest.cs @@ -0,0 +1,24 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Catch.Difficulty; +using osu.Game.Rulesets.Difficulty; +using osu.Game.Tests.Beatmaps; + +namespace osu.Game.Rulesets.Catch.Tests +{ + public class CatchDifficultyCalculatorTest : DifficultyCalculatorTest + { + protected override string ResourceAssembly => "osu.Game.Rulesets.Catch"; + + [TestCase(4.2038001515546597d, "diffcalc-test")] + public void Test(double expected, string name) + => base.Test(expected, name); + + protected override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new CatchDifficultyCalculator(new CatchRuleset(), beatmap); + + protected override Ruleset CreateRuleset() => new CatchRuleset(); + } +} diff --git a/osu.Game.Rulesets.Catch.Tests/TestCaseCatchPlayer.cs b/osu.Game.Rulesets.Catch.Tests/TestCaseCatchPlayer.cs index 030c52afea..8f9dd73b80 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestCaseCatchPlayer.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestCaseCatchPlayer.cs @@ -8,7 +8,8 @@ namespace osu.Game.Rulesets.Catch.Tests [TestFixture] public class TestCaseCatchPlayer : Game.Tests.Visual.TestCasePlayer { - public TestCaseCatchPlayer() : base(new CatchRuleset()) + public TestCaseCatchPlayer() + : base(new CatchRuleset()) { } } diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs index 2932afa9fe..5f1e0b97da 100644 --- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs @@ -56,6 +56,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps rng.Next(); // osu!stable retrieved a random banana rotation rng.Next(); // osu!stable retrieved a random banana colour } + break; case JuiceStream juiceStream: foreach (var nested in juiceStream.NestedHitObjects) @@ -67,6 +68,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps rng.Next(); // osu!stable retrieved a random droplet rotation hitObject.X = MathHelper.Clamp(hitObject.X, 0, 1); } + break; } } diff --git a/osu.Game.Rulesets.Catch/CatchInputManager.cs b/osu.Game.Rulesets.Catch/CatchInputManager.cs index 285b90b0ce..021d7a7efe 100644 --- a/osu.Game.Rulesets.Catch/CatchInputManager.cs +++ b/osu.Game.Rulesets.Catch/CatchInputManager.cs @@ -19,8 +19,10 @@ namespace osu.Game.Rulesets.Catch { [Description("Move left")] MoveLeft, + [Description("Move right")] MoveRight, + [Description("Engage dash")] Dash, } diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs index c6518cbf8a..75f5b18607 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using osu.Game.Rulesets.Difficulty; -using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Catch.Difficulty { @@ -10,10 +9,5 @@ namespace osu.Game.Rulesets.Catch.Difficulty { public double ApproachRate; public int MaxCombo; - - public CatchDifficultyAttributes(Mod[] mods, double starRating) - : base(mods, starRating) - { - } } } diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index a0b813478d..8cfda5d532 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -1,148 +1,92 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.Collections.Generic; using System.Linq; using osu.Game.Beatmaps; -using osu.Game.Rulesets.Difficulty; -using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Catch.Difficulty.Preprocessing; +using osu.Game.Rulesets.Catch.Difficulty.Skills; using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.UI; +using osu.Game.Rulesets.Difficulty; +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Difficulty.Skills; +using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Catch.Difficulty { public class CatchDifficultyCalculator : DifficultyCalculator { - /// - /// In milliseconds. For difficulty calculation we will only look at the highest strain value in each time interval of size STRAIN_STEP. - /// This is to eliminate higher influence of stream over aim by simply having more HitObjects with high strain. - /// The higher this value, the less strains there will be, indirectly giving long beatmaps an advantage. - /// - private const double strain_step = 750; - - /// - /// The weighting of each strain value decays to this number * it's previous value - /// - private const double decay_weight = 0.94; - private const double star_scaling_factor = 0.145; + protected override int SectionLength => 750; + + private readonly float halfCatchWidth; + public CatchDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap) : base(ruleset, beatmap) { + var catcher = new CatcherArea.Catcher(beatmap.BeatmapInfo.BaseDifficulty); + halfCatchWidth = catcher.CatchWidth * 0.5f; + + // We're only using 80% of the catcher's width to simulate imperfect gameplay. + halfCatchWidth *= 0.8f; } - protected override DifficultyAttributes Calculate(IBeatmap beatmap, Mod[] mods, double timeRate) + protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) { - if (!beatmap.HitObjects.Any()) - return new CatchDifficultyAttributes(mods, 0); + if (beatmap.HitObjects.Count == 0) + return new CatchDifficultyAttributes { Mods = mods }; - var catcher = new CatcherArea.Catcher(beatmap.BeatmapInfo.BaseDifficulty); - float halfCatchWidth = catcher.CatchWidth * 0.5f; + // this is the same as osu!, so there's potential to share the implementation... maybe + double preempt = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / clockRate; - var difficultyHitObjects = new List(); - - foreach (var hitObject in beatmap.HitObjects) + return new CatchDifficultyAttributes { + StarRating = Math.Sqrt(skills[0].DifficultyValue()) * star_scaling_factor, + Mods = mods, + ApproachRate = preempt > 1200.0 ? -(preempt - 1800.0) / 120.0 : -(preempt - 1200.0) / 150.0 + 5.0, + MaxCombo = beatmap.HitObjects.Count(h => h is Fruit) + beatmap.HitObjects.OfType().SelectMany(j => j.NestedHitObjects).Count(h => !(h is TinyDroplet)) + }; + } + + protected override IEnumerable CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate) + { + CatchHitObject lastObject = null; + + foreach (var hitObject in beatmap.HitObjects.OfType()) + { + if (lastObject == null) + { + lastObject = hitObject; + continue; + } + switch (hitObject) { // We want to only consider fruits that contribute to the combo. Droplets are addressed as accuracy and spinners are not relevant for "skill" calculations. case Fruit fruit: - difficultyHitObjects.Add(new CatchDifficultyHitObject(fruit, halfCatchWidth)); + yield return new CatchDifficultyHitObject(fruit, lastObject, clockRate, halfCatchWidth); + + lastObject = hitObject; break; case JuiceStream _: - difficultyHitObjects.AddRange(hitObject.NestedHitObjects.OfType().Where(o => !(o is TinyDroplet)).Select(o => new CatchDifficultyHitObject(o, halfCatchWidth))); + foreach (var nested in hitObject.NestedHitObjects.OfType().Where(o => !(o is TinyDroplet))) + { + yield return new CatchDifficultyHitObject(nested, lastObject, clockRate, halfCatchWidth); + + lastObject = nested; + } + break; } } - - difficultyHitObjects.Sort((a, b) => a.BaseHitObject.StartTime.CompareTo(b.BaseHitObject.StartTime)); - - if (!calculateStrainValues(difficultyHitObjects, timeRate)) - return new CatchDifficultyAttributes(mods, 0); - - // this is the same as osu!, so there's potential to share the implementation... maybe - double preempt = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / timeRate; - double starRating = Math.Sqrt(calculateDifficulty(difficultyHitObjects, timeRate)) * star_scaling_factor; - - return new CatchDifficultyAttributes(mods, starRating) - { - ApproachRate = preempt > 1200.0 ? -(preempt - 1800.0) / 120.0 : -(preempt - 1200.0) / 150.0 + 5.0, - MaxCombo = difficultyHitObjects.Count - }; } - private bool calculateStrainValues(List objects, double timeRate) + protected override Skill[] CreateSkills(IBeatmap beatmap) => new Skill[] { - CatchDifficultyHitObject lastObject = null; - - if (!objects.Any()) return false; - - // Traverse hitObjects in pairs to calculate the strain value of NextHitObject from the strain value of CurrentHitObject and environment. - foreach (var currentObject in objects) - { - if (lastObject != null) - currentObject.CalculateStrains(lastObject, timeRate); - - lastObject = currentObject; - } - - return true; - } - - private double calculateDifficulty(List objects, double timeRate) - { - // The strain step needs to be adjusted for the algorithm to be considered equal with speed changing mods - double actualStrainStep = strain_step * timeRate; - - // Find the highest strain value within each strain step - var highestStrains = new List(); - double intervalEndTime = actualStrainStep; - double maximumStrain = 0; // We need to keep track of the maximum strain in the current interval - - CatchDifficultyHitObject previousHitObject = null; - foreach (CatchDifficultyHitObject hitObject in objects) - { - // While we are beyond the current interval push the currently available maximum to our strain list - while (hitObject.BaseHitObject.StartTime > intervalEndTime) - { - highestStrains.Add(maximumStrain); - - // The maximum strain of the next interval is not zero by default! We need to take the last hitObject we encountered, take its strain and apply the decay - // until the beginning of the next interval. - if (previousHitObject == null) - { - maximumStrain = 0; - } - else - { - double decay = Math.Pow(CatchDifficultyHitObject.DECAY_BASE, (intervalEndTime - previousHitObject.BaseHitObject.StartTime) / 1000); - maximumStrain = previousHitObject.Strain * decay; - } - - // Go to the next time interval - intervalEndTime += actualStrainStep; - } - - // Obtain maximum strain - maximumStrain = Math.Max(hitObject.Strain, maximumStrain); - - previousHitObject = hitObject; - } - - // Build the weighted sum over the highest strains for each interval - double difficulty = 0; - double weight = 1; - highestStrains.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain. - - foreach (double strain in highestStrains) - { - difficulty += weight * strain; - weight *= decay_weight; - } - - return difficulty; - } + new Movement(), + }; } } diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs deleted file mode 100644 index fb16e117b1..0000000000 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using osu.Game.Rulesets.Catch.Objects; -using osu.Game.Rulesets.Catch.UI; -using osuTK; - -namespace osu.Game.Rulesets.Catch.Difficulty -{ - public class CatchDifficultyHitObject - { - internal static readonly double DECAY_BASE = 0.20; - private const float normalized_hitobject_radius = 41.0f; - private const float absolute_player_positioning_error = 16f; - private readonly float playerPositioningError; - - internal CatchHitObject BaseHitObject; - - /// - /// Measures jump difficulty. CtB doesn't have something like button pressing speed or accuracy - /// - internal double Strain = 1; - - /// - /// This is required to keep track of lazy player movement (always moving only as far as necessary) - /// Without this quick repeat sliders / weirdly shaped streams might become ridiculously overrated - /// - internal float PlayerPositionOffset; - internal float LastMovement; - - internal float NormalizedPosition; - internal float ActualNormalizedPosition => NormalizedPosition + PlayerPositionOffset; - - internal CatchDifficultyHitObject(CatchHitObject baseHitObject, float catcherWidthHalf) - { - BaseHitObject = baseHitObject; - - // We will scale everything by this factor, so we can assume a uniform CircleSize among beatmaps. - float scalingFactor = normalized_hitobject_radius / catcherWidthHalf; - - playerPositioningError = absolute_player_positioning_error; // * scalingFactor; - NormalizedPosition = baseHitObject.X * CatchPlayfield.BASE_WIDTH * scalingFactor; - } - - private const double direction_change_bonus = 12.5; - internal void CalculateStrains(CatchDifficultyHitObject previousHitObject, double timeRate) - { - // Rather simple, but more specialized things are inherently inaccurate due to the big difference playstyles and opinions make. - // See Taiko feedback thread. - double timeElapsed = (BaseHitObject.StartTime - previousHitObject.BaseHitObject.StartTime) / timeRate; - double decay = Math.Pow(DECAY_BASE, timeElapsed / 1000); - - // Update new position with lazy movement. - PlayerPositionOffset = - MathHelper.Clamp( - previousHitObject.ActualNormalizedPosition, - NormalizedPosition - (normalized_hitobject_radius - playerPositioningError), - NormalizedPosition + (normalized_hitobject_radius - playerPositioningError)) // Obtain new lazy position, but be stricter by allowing for an error of a certain degree of the player. - - NormalizedPosition; // Subtract HitObject position to obtain offset - - LastMovement = DistanceTo(previousHitObject); - double addition = spacingWeight(LastMovement); - - if (NormalizedPosition < previousHitObject.NormalizedPosition) - { - LastMovement = -LastMovement; - } - - CatchHitObject previousHitCircle = previousHitObject.BaseHitObject; - - double additionBonus = 0; - double sqrtTime = Math.Sqrt(Math.Max(timeElapsed, 25)); - - // Direction changes give an extra point! - if (Math.Abs(LastMovement) > 0.1) - { - if (Math.Abs(previousHitObject.LastMovement) > 0.1 && Math.Sign(LastMovement) != Math.Sign(previousHitObject.LastMovement)) - { - double bonus = direction_change_bonus / sqrtTime; - - // Weight bonus by how - double bonusFactor = Math.Min(playerPositioningError, Math.Abs(LastMovement)) / playerPositioningError; - - // We want time to play a role twice here! - addition += bonus * bonusFactor; - - // Bonus for tougher direction switches and "almost" hyperdashes at this point - if (previousHitCircle != null && previousHitCircle.DistanceToHyperDash <= 10.0f / CatchPlayfield.BASE_WIDTH) - { - additionBonus += 0.3 * bonusFactor; - } - } - - // Base bonus for every movement, giving some weight to streams. - addition += 7.5 * Math.Min(Math.Abs(LastMovement), normalized_hitobject_radius * 2) / (normalized_hitobject_radius * 6) / sqrtTime; - } - - // Bonus for "almost" hyperdashes at corner points - if (previousHitCircle != null && previousHitCircle.DistanceToHyperDash <= 10.0f / CatchPlayfield.BASE_WIDTH) - { - if (!previousHitCircle.HyperDash) - { - additionBonus += 1.0; - } - else - { - // After a hyperdash we ARE in the correct position. Always! - PlayerPositionOffset = 0; - } - - addition *= 1.0 + additionBonus * ((10 - previousHitCircle.DistanceToHyperDash * CatchPlayfield.BASE_WIDTH) / 10); - } - - addition *= 850.0 / Math.Max(timeElapsed, 25); - - Strain = previousHitObject.Strain * decay + addition; - } - - private static double spacingWeight(float distance) - { - return Math.Pow(distance, 1.3) / 500; - } - - internal float DistanceTo(CatchDifficultyHitObject other) - { - return Math.Abs(ActualNormalizedPosition - other.ActualNormalizedPosition); - } - } -} diff --git a/osu.Game.Rulesets.Catch/Difficulty/Preprocessing/CatchDifficultyHitObject.cs b/osu.Game.Rulesets.Catch/Difficulty/Preprocessing/CatchDifficultyHitObject.cs new file mode 100644 index 0000000000..24e526ed19 --- /dev/null +++ b/osu.Game.Rulesets.Catch/Difficulty/Preprocessing/CatchDifficultyHitObject.cs @@ -0,0 +1,41 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Game.Rulesets.Catch.Objects; +using osu.Game.Rulesets.Catch.UI; +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Objects; + +namespace osu.Game.Rulesets.Catch.Difficulty.Preprocessing +{ + public class CatchDifficultyHitObject : DifficultyHitObject + { + private const float normalized_hitobject_radius = 41.0f; + + public new CatchHitObject BaseObject => (CatchHitObject)base.BaseObject; + + public new CatchHitObject LastObject => (CatchHitObject)base.LastObject; + + public readonly float NormalizedPosition; + public readonly float LastNormalizedPosition; + + /// + /// Milliseconds elapsed since the start time of the previous , with a minimum of 25ms. + /// + public readonly double StrainTime; + + public CatchDifficultyHitObject(HitObject hitObject, HitObject lastObject, double clockRate, float halfCatcherWidth) + : base(hitObject, lastObject, clockRate) + { + // We will scale everything by this factor, so we can assume a uniform CircleSize among beatmaps. + var scalingFactor = normalized_hitobject_radius / halfCatcherWidth; + + NormalizedPosition = BaseObject.X * CatchPlayfield.BASE_WIDTH * scalingFactor; + LastNormalizedPosition = LastObject.X * CatchPlayfield.BASE_WIDTH * scalingFactor; + + // Every strain interval is hard capped at the equivalent of 600 BPM streaming speed as a safety measure + StrainTime = Math.Max(25, DeltaTime); + } + } +} diff --git a/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs b/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs new file mode 100644 index 0000000000..d146153294 --- /dev/null +++ b/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs @@ -0,0 +1,85 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Game.Rulesets.Catch.Difficulty.Preprocessing; +using osu.Game.Rulesets.Catch.UI; +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Difficulty.Skills; +using osuTK; + +namespace osu.Game.Rulesets.Catch.Difficulty.Skills +{ + public class Movement : Skill + { + private const float absolute_player_positioning_error = 16f; + private const float normalized_hitobject_radius = 41.0f; + private const double direction_change_bonus = 12.5; + + protected override double SkillMultiplier => 850; + protected override double StrainDecayBase => 0.2; + + protected override double DecayWeight => 0.94; + + private float? lastPlayerPosition; + private float lastDistanceMoved; + + protected override double StrainValueOf(DifficultyHitObject current) + { + var catchCurrent = (CatchDifficultyHitObject)current; + + if (lastPlayerPosition == null) + lastPlayerPosition = catchCurrent.LastNormalizedPosition; + + float playerPosition = MathHelper.Clamp( + lastPlayerPosition.Value, + catchCurrent.NormalizedPosition - (normalized_hitobject_radius - absolute_player_positioning_error), + catchCurrent.NormalizedPosition + (normalized_hitobject_radius - absolute_player_positioning_error) + ); + + float distanceMoved = playerPosition - lastPlayerPosition.Value; + + double distanceAddition = Math.Pow(Math.Abs(distanceMoved), 1.3) / 500; + double sqrtStrain = Math.Sqrt(catchCurrent.StrainTime); + + double bonus = 0; + + // Direction changes give an extra point! + if (Math.Abs(distanceMoved) > 0.1) + { + if (Math.Abs(lastDistanceMoved) > 0.1 && Math.Sign(distanceMoved) != Math.Sign(lastDistanceMoved)) + { + double bonusFactor = Math.Min(absolute_player_positioning_error, Math.Abs(distanceMoved)) / absolute_player_positioning_error; + + distanceAddition += direction_change_bonus / sqrtStrain * bonusFactor; + + // Bonus for tougher direction switches and "almost" hyperdashes at this point + if (catchCurrent.LastObject.DistanceToHyperDash <= 10 / CatchPlayfield.BASE_WIDTH) + bonus = 0.3 * bonusFactor; + } + + // Base bonus for every movement, giving some weight to streams. + distanceAddition += 7.5 * Math.Min(Math.Abs(distanceMoved), normalized_hitobject_radius * 2) / (normalized_hitobject_radius * 6) / sqrtStrain; + } + + // Bonus for "almost" hyperdashes at corner points + if (catchCurrent.LastObject.DistanceToHyperDash <= 10.0f / CatchPlayfield.BASE_WIDTH) + { + if (!catchCurrent.LastObject.HyperDash) + bonus += 1.0; + else + { + // After a hyperdash we ARE in the correct position. Always! + playerPosition = catchCurrent.NormalizedPosition; + } + + distanceAddition *= 1.0 + bonus * ((10 - catchCurrent.LastObject.DistanceToHyperDash * CatchPlayfield.BASE_WIDTH) / 10); + } + + lastPlayerPosition = playerPosition; + lastDistanceMoved = distanceMoved; + + return distanceAddition / catchCurrent.StrainTime; + } + } +} diff --git a/osu.Game.Rulesets.Catch/MathUtils/FastRandom.cs b/osu.Game.Rulesets.Catch/MathUtils/FastRandom.cs index 2bd2c9766f..b3605b013b 100644 --- a/osu.Game.Rulesets.Catch/MathUtils/FastRandom.cs +++ b/osu.Game.Rulesets.Catch/MathUtils/FastRandom.cs @@ -33,11 +33,11 @@ namespace osu.Game.Rulesets.Catch.MathUtils /// The random value. public uint NextUInt() { - uint t = _x ^ _x << 11; + uint t = _x ^ (_x << 11); _x = _y; _y = _z; _z = _w; - return _w = _w ^ _w >> 19 ^ t ^ t >> 8; + return _w = _w ^ (_w >> 19) ^ t ^ (t >> 8); } /// diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModFlashlight.cs b/osu.Game.Rulesets.Catch/Mods/CatchModFlashlight.cs index 4f5d7abfd4..82cda7df47 100644 --- a/osu.Game.Rulesets.Catch/Mods/CatchModFlashlight.cs +++ b/osu.Game.Rulesets.Catch/Mods/CatchModFlashlight.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.UI; @@ -55,9 +56,9 @@ namespace osu.Game.Rulesets.Catch.Mods return default_flashlight_size; } - protected override void OnComboChange(int newCombo) + protected override void OnComboChange(ValueChangedEvent e) { - this.TransformTo(nameof(FlashlightSize), new Vector2(0, getSizeFor(newCombo)), FLASHLIGHT_FADE_DURATION); + this.TransformTo(nameof(FlashlightSize), new Vector2(0, getSizeFor(e.NewValue)), FLASHLIGHT_FADE_DURATION); } protected override string FragmentShader => "CircularFlashlight"; diff --git a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableDroplet.cs b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableDroplet.cs index c80dacde93..8fed8eb4cd 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableDroplet.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableDroplet.cs @@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable public override Color4 AccentColour { - get { return base.AccentColour; } + get => base.AccentColour; set { base.AccentColour = value; diff --git a/osu.Game.Rulesets.Catch/Objects/Drawable/Pieces/Pulp.cs b/osu.Game.Rulesets.Catch/Objects/Drawable/Pieces/Pulp.cs index d5adbee8aa..2e18c5f2ad 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawable/Pieces/Pulp.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawable/Pieces/Pulp.cs @@ -23,9 +23,10 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable.Pieces } private Color4 accentColour; + public Color4 AccentColour { - get { return accentColour; } + get => accentColour; set { accentColour = value; diff --git a/osu.Game.Rulesets.Catch/Resources/Testing/Beatmaps/diffcalc-test.osu b/osu.Game.Rulesets.Catch/Resources/Testing/Beatmaps/diffcalc-test.osu new file mode 100644 index 0000000000..ebad654404 --- /dev/null +++ b/osu.Game.Rulesets.Catch/Resources/Testing/Beatmaps/diffcalc-test.osu @@ -0,0 +1,138 @@ +osu file format v14 + +[General] +StackLeniency: 0.3 +Mode: 2 + +[Difficulty] +CircleSize:4 +OverallDifficulty:7 +ApproachRate:8.3 +SliderMultiplier:1.6 +SliderTickRate:1 + +[TimingPoints] +500,500,4,2,1,50,1,0 +34500,-50,4,2,1,50,0,0 + +[HitObjects] +// fruits spaced 1/1 beat apart +32,128,0,5,0,0:0:0:0: +96,128,500,1,0,0:0:0:0: +160,128,1000,1,0,0:0:0:0: +224,128,1500,1,0,0:0:0:0: +288,128,2000,1,0,0:0:0:0: +352,128,2500,1,0,0:0:0:0: +416,128,3000,1,0,0:0:0:0: +480,128,3500,1,0,0:0:0:0: + +// fruits spaced 1/2 beat apart +32,160,4500,1,0,0:0:0:0: +64,160,4750,1,0,0:0:0:0: +96,160,5000,1,0,0:0:0:0: +128,160,5250,1,0,0:0:0:0: +160,160,5500,1,0,0:0:0:0: +192,160,5750,1,0,0:0:0:0: +224,160,6000,1,0,0:0:0:0: +256,160,6250,1,0,0:0:0:0: +288,160,6500,1,0,0:0:0:0: + +// fruits spaced 1/4 beat apart +96,128,7500,1,0,0:0:0:0: +128,128,7625,1,0,0:0:0:0: +160,128,7750,1,0,0:0:0:0: +192,128,7875,1,0,0:0:0:0: +224,128,8000,1,0,0:0:0:0: +256,128,8125,1,0,0:0:0:0: +288,128,8250,1,0,0:0:0:0: +320,128,8375,1,0,0:0:0:0: +352,128,8500,1,0,0:0:0:0: + +// fruit hyperdashes, spaced 1/2 beat apart +32,160,9500,1,0,0:0:0:0: +480,160,9750,1,0,0:0:0:0: +32,160,10000,1,0,0:0:0:0: +480,160,10250,1,0,0:0:0:0: +32,160,10500,1,0,0:0:0:0: +480,160,10750,1,0,0:0:0:0: +32,160,11000,1,0,0:0:0:0: + +// fruit hyperdashes, spaced 1/4 beat apart +32,192,12000,1,0,0:0:0:0: +480,192,12125,1,0,0:0:0:0: +32,192,12250,1,0,0:0:0:0: +480,192,12375,1,0,0:0:0:0: +32,192,12500,1,0,0:0:0:0: +480,192,12625,1,0,0:0:0:0: +32,192,12750,1,0,0:0:0:0: +480,192,12875,1,0,0:0:0:0: +32,192,13000,1,0,0:0:0:0: + +// stream + hyperdash + stream, spaced 1/4 beat apart +32,192,14000,1,0,0:0:0:0: +64,192,14125,1,0,0:0:0:0: +96,192,14250,1,0,0:0:0:0: +128,192,14375,1,0,0:0:0:0: +480,192,14500,1,0,0:0:0:0: +448,192,14625,1,0,0:0:0:0: +416,192,14750,1,0,0:0:0:0: +384,192,14875,1,0,0:0:0:0: +32,192,15000,1,0,0:0:0:0: + +// basic sliders +32,192,16000,2,0,L|192:192,1,160 +224,192,17000,2,0,L|384:192,1,160 +416,192,17875,2,0,L|480:192,1,40 + +// slider hyperdashes, spaced 1/4 beat apart +32,192,19000,2,0,L|128:192,1,80 +480,192,19375,2,0,L|384:192,1,80 +352,192,19750,2,0,L|256:192,1,80 +0,192,20125,2,0,L|128:192,1,120 + +// stream + slider hyperdashes, spaced 1/4 beat apart +32,192,21500,1,0,0:0:0:0: +64,192,21625,1,0,0:0:0:0: +96,192,21750,1,0,0:0:0:0: +512,192,21875,2,0,L|320:192,1,160 +320,192,22500,1,0,0:0:0:0: +288,192,22625,1,0,0:0:0:0: +256,192,22750,1,0,0:0:0:0: +0,192,22875,2,0,L|64:192,1,40 + +// streams, spaced 1/4 beat apart +64,192,24000,1,0,0:0:0:0: +160,192,24125,1,0,0:0:0:0: +64,192,24250,1,0,0:0:0:0: +160,192,24375,1,0,0:0:0:0: +64,192,24500,1,0,0:0:0:0: +160,192,24625,1,0,0:0:0:0: +64,192,24750,1,0,0:0:0:0: +160,192,24875,1,0,0:0:0:0: +64,192,25000,1,0,0:0:0:0: +160,192,25125,1,0,0:0:0:0: +64,192,25250,1,0,0:0:0:0: +160,192,25375,1,0,0:0:0:0: +64,192,25500,1,0,0:0:0:0: + +// stream + spinner combo, spaced 1/4 beat apart +256,192,26500,12,0,27000,0:0:0:0: +128,192,27250,5,0,0:0:0:0: +128,192,27375,1,0,0:0:0:0: +160,192,27500,1,0,0:0:0:0: +192,192,27625,1,0,0:0:0:0: +256,192,27750,12,0,28500,0:0:0:0: +192,192,28625,5,0,0:0:0:0: +224,192,28750,1,0,0:0:0:0: +256,192,28875,1,0,0:0:0:0: +256,192,29000,1,0,0:0:0:0: +256,192,29125,12,0,29500,0:0:0:0: + +// long slow slider +0,192,30500,6,0,B|480:192|480:192|0:192,2,960 + +// long fast slider +0,192,37500,6,0,B|480:192|480:192|0:192,2,960 + +// long hyperdash slider +0,192,41500,2,0,P|544:192|544:192,5,480 diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index d79f106310..d0f50c6af2 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Catch.UI { public class CatcherArea : Container { - public const float CATCHER_SIZE = 100; + public const float CATCHER_SIZE = 106.75f; protected internal readonly Catcher MovableCatcher; @@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Catch.UI public Container ExplodingFruitTarget { - set { MovableCatcher.ExplodingFruitTarget = value; } + set => MovableCatcher.ExplodingFruitTarget = value; } public CatcherArea(BeatmapDifficulty difficulty = null) @@ -158,7 +158,7 @@ namespace osu.Game.Rulesets.Catch.UI protected bool Dashing { - get { return dashing; } + get => dashing; set { if (value == dashing) return; @@ -176,7 +176,7 @@ namespace osu.Game.Rulesets.Catch.UI /// protected bool Trail { - get { return trail; } + get => trail; set { if (value == trail) return; diff --git a/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs b/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs index 7a2b4e7b39..6b95975059 100644 --- a/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs +++ b/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs @@ -40,29 +40,29 @@ namespace osu.Game.Rulesets.Mania.Tests protected override Ruleset CreateRuleset() => new ManiaRuleset(); } - public class ManiaConvertMapping : ConvertMapping, IEquatable - { - public uint RandomW; - public uint RandomX; - public uint RandomY; - public uint RandomZ; + public class ManiaConvertMapping : ConvertMapping, IEquatable + { + public uint RandomW; + public uint RandomX; + public uint RandomY; + public uint RandomZ; - public ManiaConvertMapping() - { - } + public ManiaConvertMapping() + { + } - public ManiaConvertMapping(IBeatmapConverter converter) - { - var maniaConverter = (ManiaBeatmapConverter)converter; - RandomW = maniaConverter.Random.W; - RandomX = maniaConverter.Random.X; - RandomY = maniaConverter.Random.Y; - RandomZ = maniaConverter.Random.Z; - } + public ManiaConvertMapping(IBeatmapConverter converter) + { + var maniaConverter = (ManiaBeatmapConverter)converter; + RandomW = maniaConverter.Random.W; + RandomX = maniaConverter.Random.X; + RandomY = maniaConverter.Random.Y; + RandomZ = maniaConverter.Random.Z; + } - public bool Equals(ManiaConvertMapping other) => other != null && RandomW == other.RandomW && RandomX == other.RandomX && RandomY == other.RandomY && RandomZ == other.RandomZ; - public override bool Equals(ConvertMapping other) => base.Equals(other) && Equals(other as ManiaConvertMapping); - } + public bool Equals(ManiaConvertMapping other) => other != null && RandomW == other.RandomW && RandomX == other.RandomX && RandomY == other.RandomY && RandomZ == other.RandomZ; + public override bool Equals(ConvertMapping other) => base.Equals(other) && Equals(other as ManiaConvertMapping); + } public struct ConvertValue : IEquatable { diff --git a/osu.Game.Rulesets.Mania.Tests/ManiaDifficultyCalculatorTest.cs b/osu.Game.Rulesets.Mania.Tests/ManiaDifficultyCalculatorTest.cs new file mode 100644 index 0000000000..2c36e81190 --- /dev/null +++ b/osu.Game.Rulesets.Mania.Tests/ManiaDifficultyCalculatorTest.cs @@ -0,0 +1,24 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Difficulty; +using osu.Game.Rulesets.Mania.Difficulty; +using osu.Game.Tests.Beatmaps; + +namespace osu.Game.Rulesets.Mania.Tests +{ + public class ManiaDifficultyCalculatorTest : DifficultyCalculatorTest + { + protected override string ResourceAssembly => "osu.Game.Rulesets.Mania"; + + [TestCase(2.3683365342338796d, "diffcalc-test")] + public void Test(double expected, string name) + => base.Test(expected, name); + + protected override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new ManiaDifficultyCalculator(new ManiaRuleset(), beatmap); + + protected override Ruleset CreateRuleset() => new ManiaRuleset(); + } +} diff --git a/osu.Game.Rulesets.Mania.Tests/TestCaseEditor.cs b/osu.Game.Rulesets.Mania.Tests/TestCaseEditor.cs index 32f455bb73..78e7768788 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestCaseEditor.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestCaseEditor.cs @@ -3,7 +3,7 @@ using NUnit.Framework; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Rulesets.Mania.Configuration; using osu.Game.Rulesets.Mania.UI; using osu.Game.Tests.Visual; diff --git a/osu.Game.Rulesets.Mania.Tests/TestCaseNotes.cs b/osu.Game.Rulesets.Mania.Tests/TestCaseNotes.cs index 2f4b51e372..0bc2c3ea28 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestCaseNotes.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestCaseNotes.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -14,6 +14,7 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Graphics; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables; @@ -141,7 +142,7 @@ namespace osu.Game.Rulesets.Mania.Tests { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - TextSize = 14, + Font = OsuFont.GetFont(size: 14), Text = description } } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 380ce533bb..71df68c087 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -27,6 +27,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps protected override IEnumerable ValidConversionTypes { get; } = new[] { typeof(IHasXPosition) }; public int TargetColumns; + public bool Dual; public readonly bool IsForCurrentRuleset; // Internal for testing purposes @@ -45,7 +46,14 @@ namespace osu.Game.Rulesets.Mania.Beatmaps var roundedOverallDifficulty = Math.Round(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty); if (IsForCurrentRuleset) + { TargetColumns = (int)Math.Max(1, roundedCircleSize); + if (TargetColumns >= 10) + { + TargetColumns = TargetColumns / 2; + Dual = true; + } + } else { float percentSliderOrSpinner = (float)beatmap.HitObjects.Count(h => h is IHasEndTime) / beatmap.HitObjects.Count; @@ -70,14 +78,22 @@ namespace osu.Game.Rulesets.Mania.Beatmaps return base.ConvertBeatmap(original); } - protected override Beatmap CreateBeatmap() => beatmap = new ManiaBeatmap(new StageDefinition { Columns = TargetColumns }); + protected override Beatmap CreateBeatmap() + { + beatmap = new ManiaBeatmap(new StageDefinition { Columns = TargetColumns }); + + if (Dual) + beatmap.Stages.Add(new StageDefinition { Columns = TargetColumns }); + + return beatmap; + } protected override IEnumerable ConvertHitObject(HitObject original, IBeatmap beatmap) { - var maniaOriginal = original as ManiaHitObject; - if (maniaOriginal != null) + if (original is ManiaHitObject maniaOriginal) { yield return maniaOriginal; + yield break; } @@ -92,6 +108,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps private readonly List prevNoteTimes = new List(max_notes_for_density); private double density = int.MaxValue; + private void computeDensity(double newNoteTime) { if (prevNoteTimes.Count == max_notes_for_density) @@ -104,6 +121,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps private double lastTime; private Vector2 lastPosition; private PatternType lastStair = PatternType.Stair; + private void recordNote(double time, Vector2 position) { lastTime = time; diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 3eff2d62f3..ed52bdd23f 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -65,6 +65,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy if (originalPattern.HitObjects.Count() == 1) { yield return originalPattern; + yield break; } @@ -135,6 +136,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { if (convertType.HasFlag(PatternType.LowProbability)) return generateNRandomNotes(HitObject.StartTime, 0.78, 0.3, 0); + return generateNRandomNotes(HitObject.StartTime, 0.85, 0.36, 0.03); } @@ -142,6 +144,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { if (convertType.HasFlag(PatternType.LowProbability)) return generateNRandomNotes(HitObject.StartTime, 0.43, 0.08, 0); + return generateNRandomNotes(HitObject.StartTime, 0.56, 0.18, 0); } @@ -149,11 +152,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { if (convertType.HasFlag(PatternType.LowProbability)) return generateNRandomNotes(HitObject.StartTime, 0.3, 0, 0); + return generateNRandomNotes(HitObject.StartTime, 0.37, 0.08, 0); } if (convertType.HasFlag(PatternType.LowProbability)) return generateNRandomNotes(HitObject.StartTime, 0.17, 0, 0); + return generateNRandomNotes(HitObject.StartTime, 0.27, 0, 0); } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs index 7004ea4969..34f5f5c415 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs @@ -116,10 +116,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy } if (convertType.HasFlag(PatternType.Cycle) && PreviousPattern.HitObjects.Count() == 1 - // If we convert to 7K + 1, let's not overload the special key - && (TotalColumns != 8 || lastColumn != 0) - // Make sure the last column was not the centre column - && (TotalColumns % 2 == 0 || lastColumn != TotalColumns / 2)) + // If we convert to 7K + 1, let's not overload the special key + && (TotalColumns != 8 || lastColumn != 0) + // Make sure the last column was not the centre column + && (TotalColumns % 2 == 0 || lastColumn != TotalColumns / 2)) { // Generate a new pattern by cycling backwards (similar to Reverse but for only one hit object) int column = RandomStart + TotalColumns - lastColumn - 1; @@ -172,6 +172,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy return pattern = generateRandomPatternWithMirrored(0.12, 0.38, 0.12); if (ConversionDifficulty > 4) return pattern = generateRandomPatternWithMirrored(0.12, 0.17, 0); + return pattern = generateRandomPatternWithMirrored(0.12, 0, 0); } @@ -179,6 +180,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { if (convertType.HasFlag(PatternType.LowProbability)) return pattern = generateRandomPattern(0.78, 0.42, 0, 0); + return pattern = generateRandomPattern(1, 0.62, 0, 0); } @@ -186,6 +188,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { if (convertType.HasFlag(PatternType.LowProbability)) return pattern = generateRandomPattern(0.35, 0.08, 0, 0); + return pattern = generateRandomPattern(0.52, 0.15, 0, 0); } @@ -193,6 +196,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { if (convertType.HasFlag(PatternType.LowProbability)) return pattern = generateRandomPattern(0.18, 0, 0, 0); + return pattern = generateRandomPattern(0.45, 0, 0, 0); } @@ -250,6 +254,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy } else last = GetRandomColumn(); + return last; } } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs index cf5dc4fe66..b702291c5d 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs @@ -87,6 +87,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy return 4; if (val >= 1 - p3) return 3; + return val >= 1 - p2 ? 2 : 1; } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs index a6fa234960..a3cd455886 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternType.cs @@ -12,51 +12,63 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy internal enum PatternType { None = 0, + /// /// Keep the same as last row. /// ForceStack = 1 << 0, + /// /// Keep different from last row. /// ForceNotStack = 1 << 1, + /// /// Keep as single note at its original position. /// KeepSingle = 1 << 2, + /// /// Use a lower random value. /// LowProbability = 1 << 3, + /// /// Reserved. /// Alternate = 1 << 4, + /// /// Ignore the repeat count. /// ForceSigSlider = 1 << 5, + /// /// Convert slider to circle. /// ForceNotSlider = 1 << 6, + /// /// Notes gathered together. /// Gathered = 1 << 7, Mirror = 1 << 8, + /// /// Change 0 -> 6. /// Reverse = 1 << 9, + /// /// 1 -> 5 -> 1 -> 5 like reverse. /// Cycle = 1 << 10, + /// /// Next note will be at column + 1. /// Stair = 1 << 11, + /// /// Next note will be at column - 1. /// diff --git a/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyAttributes.cs b/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyAttributes.cs index 2f614ea14b..3ff665d2c8 100644 --- a/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyAttributes.cs +++ b/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyAttributes.cs @@ -2,17 +2,11 @@ // See the LICENCE file in the repository root for full licence text. using osu.Game.Rulesets.Difficulty; -using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Mania.Difficulty { public class ManiaDifficultyAttributes : DifficultyAttributes { public double GreatHitWindow; - - public ManiaDifficultyAttributes(Mod[] mods, double starRating) - : base(mods, starRating) - { - } } } diff --git a/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyCalculator.cs b/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyCalculator.cs index b8588dbce2..59fed1031f 100644 --- a/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyCalculator.cs @@ -1,34 +1,24 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Collections.Generic; using System.Linq; using osu.Game.Beatmaps; using osu.Game.Rulesets.Difficulty; +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Difficulty.Skills; using osu.Game.Rulesets.Mania.Beatmaps; +using osu.Game.Rulesets.Mania.Difficulty.Preprocessing; +using osu.Game.Rulesets.Mania.Difficulty.Skills; using osu.Game.Rulesets.Mania.Mods; -using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Mania.Difficulty { - internal class ManiaDifficultyCalculator : DifficultyCalculator + public class ManiaDifficultyCalculator : DifficultyCalculator { private const double star_scaling_factor = 0.018; - /// - /// In milliseconds. For difficulty calculation we will only look at the highest strain value in each time interval of size strain_step. - /// This is to eliminate higher influence of stream over aim by simply having more HitObjects with high strain. - /// The higher this value, the less strains there will be, indirectly giving long beatmaps an advantage. - /// - private const double strain_step = 400; - - /// - /// The weighting of each strain value decays to this number * it's previous value - /// - private const double decay_weight = 0.9; - private readonly bool isForCurrentRuleset; public ManiaDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap) @@ -37,108 +27,70 @@ namespace osu.Game.Rulesets.Mania.Difficulty isForCurrentRuleset = beatmap.BeatmapInfo.Ruleset.Equals(ruleset.RulesetInfo); } - protected override DifficultyAttributes Calculate(IBeatmap beatmap, Mod[] mods, double timeRate) + protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) { - if (!beatmap.HitObjects.Any()) - return new ManiaDifficultyAttributes(mods, 0); + if (beatmap.HitObjects.Count == 0) + return new ManiaDifficultyAttributes { Mods = mods }; - var difficultyHitObjects = new List(); - - int columnCount = ((ManiaBeatmap)beatmap).TotalColumns; - - // Sort DifficultyHitObjects by StartTime of the HitObjects - just to make sure. - // Note: Stable sort is done so that the ordering of hitobjects with equal start times doesn't change - difficultyHitObjects.AddRange(beatmap.HitObjects.Select(h => new ManiaHitObjectDifficulty((ManiaHitObject)h, columnCount)).OrderBy(h => h.BaseHitObject.StartTime)); - - if (!calculateStrainValues(difficultyHitObjects, timeRate)) - return new ManiaDifficultyAttributes(mods, 0); - - double starRating = calculateDifficulty(difficultyHitObjects, timeRate) * star_scaling_factor; - - return new ManiaDifficultyAttributes(mods, starRating) + return new ManiaDifficultyAttributes { - // Todo: This int cast is temporary to achieve 1:1 results with osu!stable, and should be remoevd in the future - GreatHitWindow = (int)(beatmap.HitObjects.First().HitWindows.Great / 2) / timeRate + StarRating = difficultyValue(skills) * star_scaling_factor, + Mods = mods, + // Todo: This int cast is temporary to achieve 1:1 results with osu!stable, and should be removed in the future + GreatHitWindow = (int)(beatmap.HitObjects.First().HitWindows.Great / 2) / clockRate, }; } - private bool calculateStrainValues(List objects, double timeRate) + private double difficultyValue(Skill[] skills) { - // Traverse hitObjects in pairs to calculate the strain value of NextHitObject from the strain value of CurrentHitObject and environment. - using (var hitObjectsEnumerator = objects.GetEnumerator()) + // Preprocess the strains to find the maximum overall + individual (aggregate) strain from each section + var overall = skills.OfType().Single(); + var aggregatePeaks = new List(Enumerable.Repeat(0.0, overall.StrainPeaks.Count)); + + foreach (var individual in skills.OfType()) { - if (!hitObjectsEnumerator.MoveNext()) - return false; - - ManiaHitObjectDifficulty current = hitObjectsEnumerator.Current; - - // First hitObject starts at strain 1. 1 is the default for strain values, so we don't need to set it here. See DifficultyHitObject. - while (hitObjectsEnumerator.MoveNext()) + for (int i = 0; i < individual.StrainPeaks.Count; i++) { - var next = hitObjectsEnumerator.Current; - next?.CalculateStrains(current, timeRate); - current = next; + double aggregate = individual.StrainPeaks[i] + overall.StrainPeaks[i]; + + if (aggregate > aggregatePeaks[i]) + aggregatePeaks[i] = aggregate; } - - return true; - } - } - - private double calculateDifficulty(List objects, double timeRate) - { - double actualStrainStep = strain_step * timeRate; - - // Find the highest strain value within each strain step - List highestStrains = new List(); - double intervalEndTime = actualStrainStep; - double maximumStrain = 0; // We need to keep track of the maximum strain in the current interval - - ManiaHitObjectDifficulty previousHitObject = null; - foreach (var hitObject in objects) - { - // While we are beyond the current interval push the currently available maximum to our strain list - while (hitObject.BaseHitObject.StartTime > intervalEndTime) - { - highestStrains.Add(maximumStrain); - - // The maximum strain of the next interval is not zero by default! We need to take the last hitObject we encountered, take its strain and apply the decay - // until the beginning of the next interval. - if (previousHitObject == null) - { - maximumStrain = 0; - } - else - { - double individualDecay = Math.Pow(ManiaHitObjectDifficulty.INDIVIDUAL_DECAY_BASE, (intervalEndTime - previousHitObject.BaseHitObject.StartTime) / 1000); - double overallDecay = Math.Pow(ManiaHitObjectDifficulty.OVERALL_DECAY_BASE, (intervalEndTime - previousHitObject.BaseHitObject.StartTime) / 1000); - maximumStrain = previousHitObject.IndividualStrain * individualDecay + previousHitObject.OverallStrain * overallDecay; - } - - // Go to the next time interval - intervalEndTime += actualStrainStep; - } - - // Obtain maximum strain - double strain = hitObject.IndividualStrain + hitObject.OverallStrain; - maximumStrain = Math.Max(strain, maximumStrain); - - previousHitObject = hitObject; } - // Build the weighted sum over the highest strains for each interval + aggregatePeaks.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain. + double difficulty = 0; double weight = 1; - highestStrains.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain. - foreach (double strain in highestStrains) + // Difficulty is the weighted sum of the highest strains from every section. + foreach (double strain in aggregatePeaks) { - difficulty += weight * strain; - weight *= decay_weight; + difficulty += strain * weight; + weight *= 0.9; } return difficulty; } + protected override IEnumerable CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate) + { + for (int i = 1; i < beatmap.HitObjects.Count; i++) + yield return new ManiaDifficultyHitObject(beatmap.HitObjects[i], beatmap.HitObjects[i - 1], clockRate); + } + + protected override Skill[] CreateSkills(IBeatmap beatmap) + { + int columnCount = ((ManiaBeatmap)beatmap).TotalColumns; + + var skills = new List { new Overall(columnCount) }; + + for (int i = 0; i < columnCount; i++) + skills.Add(new Individual(i, columnCount)); + + return skills.ToArray(); + } + protected override Mod[] DifficultyAdjustmentMods { get diff --git a/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs b/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs index 2f4870f647..b99bddee96 100644 --- a/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs @@ -114,8 +114,8 @@ namespace osu.Game.Rulesets.Mania.Difficulty // Lots of arbitrary values from testing. // Considering to use derivation from perfect accuracy in a probabilistic manner - assume normal distribution double accuracyValue = Math.Max(0.0, 0.2 - (Attributes.GreatHitWindow - 34) * 0.006667) - * strainValue - * Math.Pow(Math.Max(0.0, scaledScore - 960000) / 40000, 1.1); + * strainValue + * Math.Pow(Math.Max(0.0, scaledScore - 960000) / 40000, 1.1); // Bonus for many hitcircles - it's harder to keep good accuracy up for longer // accuracyValue *= Math.Min(1.15, Math.Pow(totalHits / 1500.0, 0.3)); diff --git a/osu.Game.Rulesets.Mania/Difficulty/Preprocessing/ManiaDifficultyHitObject.cs b/osu.Game.Rulesets.Mania/Difficulty/Preprocessing/ManiaDifficultyHitObject.cs new file mode 100644 index 0000000000..29ba934e9f --- /dev/null +++ b/osu.Game.Rulesets.Mania/Difficulty/Preprocessing/ManiaDifficultyHitObject.cs @@ -0,0 +1,19 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Objects; + +namespace osu.Game.Rulesets.Mania.Difficulty.Preprocessing +{ + public class ManiaDifficultyHitObject : DifficultyHitObject + { + public new ManiaHitObject BaseObject => (ManiaHitObject)base.BaseObject; + + public ManiaDifficultyHitObject(HitObject hitObject, HitObject lastObject, double clockRate) + : base(hitObject, lastObject, clockRate) + { + } + } +} diff --git a/osu.Game.Rulesets.Mania/Difficulty/Skills/Individual.cs b/osu.Game.Rulesets.Mania/Difficulty/Skills/Individual.cs new file mode 100644 index 0000000000..059cd39641 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Difficulty/Skills/Individual.cs @@ -0,0 +1,47 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Difficulty.Skills; +using osu.Game.Rulesets.Mania.Difficulty.Preprocessing; +using osu.Game.Rulesets.Mania.Objects; + +namespace osu.Game.Rulesets.Mania.Difficulty.Skills +{ + public class Individual : Skill + { + protected override double SkillMultiplier => 1; + protected override double StrainDecayBase => 0.125; + + private readonly double[] holdEndTimes; + + private readonly int column; + + public Individual(int column, int columnCount) + { + this.column = column; + + holdEndTimes = new double[columnCount]; + } + + protected override double StrainValueOf(DifficultyHitObject current) + { + var maniaCurrent = (ManiaDifficultyHitObject)current; + var endTime = (maniaCurrent.BaseObject as HoldNote)?.EndTime ?? maniaCurrent.BaseObject.StartTime; + + try + { + if (maniaCurrent.BaseObject.Column != column) + return 0; + + // We give a slight bonus if something is held meanwhile + return holdEndTimes.Any(t => t > endTime) ? 2.5 : 2; + } + finally + { + holdEndTimes[maniaCurrent.BaseObject.Column] = endTime; + } + } + } +} diff --git a/osu.Game.Rulesets.Mania/Difficulty/Skills/Overall.cs b/osu.Game.Rulesets.Mania/Difficulty/Skills/Overall.cs new file mode 100644 index 0000000000..ed25173d38 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Difficulty/Skills/Overall.cs @@ -0,0 +1,56 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Difficulty.Skills; +using osu.Game.Rulesets.Mania.Difficulty.Preprocessing; +using osu.Game.Rulesets.Mania.Objects; + +namespace osu.Game.Rulesets.Mania.Difficulty.Skills +{ + public class Overall : Skill + { + protected override double SkillMultiplier => 1; + protected override double StrainDecayBase => 0.3; + + private readonly double[] holdEndTimes; + + private readonly int columnCount; + + public Overall(int columnCount) + { + this.columnCount = columnCount; + + holdEndTimes = new double[columnCount]; + } + + protected override double StrainValueOf(DifficultyHitObject current) + { + var maniaCurrent = (ManiaDifficultyHitObject)current; + var endTime = (maniaCurrent.BaseObject as HoldNote)?.EndTime ?? maniaCurrent.BaseObject.StartTime; + + double holdFactor = 1.0; // Factor in case something else is held + double holdAddition = 0; // Addition to the current note in case it's a hold and has to be released awkwardly + + for (int i = 0; i < columnCount; i++) + { + // If there is at least one other overlapping end or note, then we get an addition, buuuuuut... + if (current.BaseObject.StartTime < holdEndTimes[i] && endTime > holdEndTimes[i]) + holdAddition = 1.0; + + // ... this addition only is valid if there is _no_ other note with the same ending. + // Releasing multiple notes at the same time is just as easy as releasing one + if (endTime == holdEndTimes[i]) + holdAddition = 0; + + // We give a slight bonus if something is held meanwhile + if (holdEndTimes[i] > endTime) + holdFactor = 1.25; + } + + holdEndTimes[maniaCurrent.BaseObject.Column] = endTime; + + return (1 + holdAddition) * holdFactor; + } + } +} diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs index 9bf14b0672..d64c5dbc6a 100644 --- a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Game.Graphics; diff --git a/osu.Game.Rulesets.Mania/ManiaInputManager.cs b/osu.Game.Rulesets.Mania/ManiaInputManager.cs index 864084b407..292990fd7e 100644 --- a/osu.Game.Rulesets.Mania/ManiaInputManager.cs +++ b/osu.Game.Rulesets.Mania/ManiaInputManager.cs @@ -19,6 +19,7 @@ namespace osu.Game.Rulesets.Mania { [Description("Special 1")] Special1 = 1, + [Description("Special 2")] Special2, @@ -26,38 +27,55 @@ namespace osu.Game.Rulesets.Mania // above at a later time, without breaking replays/configs. [Description("Key 1")] Key1 = 10, + [Description("Key 2")] Key2, + [Description("Key 3")] Key3, + [Description("Key 4")] Key4, + [Description("Key 5")] Key5, + [Description("Key 6")] Key6, + [Description("Key 7")] Key7, + [Description("Key 8")] Key8, + [Description("Key 9")] Key9, + [Description("Key 10")] Key10, + [Description("Key 11")] Key11, + [Description("Key 12")] Key12, + [Description("Key 13")] Key13, + [Description("Key 14")] Key14, + [Description("Key 15")] Key15, + [Description("Key 16")] Key16, + [Description("Key 17")] Key17, + [Description("Key 18")] Key18, } diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs index 57728dd134..525bacee65 100644 --- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs @@ -330,12 +330,12 @@ namespace osu.Game.Rulesets.Mania for (int i = LeftKeys.Length - columns / 2; i < LeftKeys.Length; i++) bindings.Add(new KeyBinding(LeftKeys[i], currentNormalAction++)); - for (int i = 0; i < columns / 2; i++) - bindings.Add(new KeyBinding(RightKeys[i], currentNormalAction++)); - if (columns % 2 == 1) bindings.Add(new KeyBinding(SpecialKey, SpecialAction)); + for (int i = 0; i < columns / 2; i++) + bindings.Add(new KeyBinding(RightKeys[i], currentNormalAction++)); + nextNormalAction = currentNormalAction; return bindings; } @@ -349,6 +349,7 @@ namespace osu.Game.Rulesets.Mania /// Number of columns in this stage lies at (item - Single). /// Single = 0, + /// /// Columns are grouped into two stages. /// Overall number of columns lies at (item - Dual), further computation is required for diff --git a/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs b/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs index a88512e12f..a9cd7f2476 100644 --- a/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs +++ b/osu.Game.Rulesets.Mania/MathUtils/FastRandom.cs @@ -37,11 +37,11 @@ namespace osu.Game.Rulesets.Mania.MathUtils /// The random value. public uint NextUInt() { - uint t = X ^ X << 11; + uint t = X ^ (X << 11); X = Y; Y = Z; Z = W; - return W = W ^ W >> 19 ^ t ^ t >> 8; + return W = W ^ (W >> 19) ^ t ^ (t >> 8); } /// diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs index 7b2ee9a632..c78bf72979 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs @@ -1,15 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -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 { public override string Name => "Dual Stages"; public override string Acronym => "DS"; @@ -29,24 +27,7 @@ namespace osu.Game.Rulesets.Mania.Mods if (isForCurrentRuleset) return; - mbc.TargetColumns *= 2; - } - - public void ApplyToBeatmap(Beatmap beatmap) - { - if (isForCurrentRuleset) - return; - - var maniaBeatmap = (ManiaBeatmap)beatmap; - - var newDefinitions = new List(); - foreach (var existing in maniaBeatmap.Stages) - { - newDefinitions.Add(new StageDefinition { Columns = existing.Columns / 2 }); - newDefinitions.Add(new StageDefinition { Columns = existing.Columns / 2 }); - } - - maniaBeatmap.Stages = newDefinitions; + mbc.Dual = true; } public PlayfieldType PlayfieldType => PlayfieldType.Dual; diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModFlashlight.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModFlashlight.cs index baa757008f..6893e1e73b 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModFlashlight.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModFlashlight.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using osu.Framework.Bindables; using osu.Framework.Caching; using osu.Framework.Graphics; using osu.Game.Rulesets.Mania.Objects; @@ -51,7 +52,7 @@ namespace osu.Game.Rulesets.Mania.Mods } } - protected override void OnComboChange(int newCombo) + protected override void OnComboChange(ValueChangedEvent e) { } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index 8b2da60a9e..4bfd940aa0 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Linq; +using osu.Framework.Bindables; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; @@ -75,16 +76,16 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables AddNested(Tail); } - protected override void OnDirectionChanged(ScrollingDirection direction) + protected override void OnDirectionChanged(ValueChangedEvent e) { - base.OnDirectionChanged(direction); + base.OnDirectionChanged(e); - bodyPiece.Anchor = bodyPiece.Origin = direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft; + bodyPiece.Anchor = bodyPiece.Origin = e.NewValue == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft; } public override Color4 AccentColour { - get { return base.AccentColour; } + get => base.AccentColour; set { base.AccentColour = value; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs index eb7d153a90..43aac7907f 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public override Color4 AccentColour { - get { return base.AccentColour; } + get => base.AccentColour; set { base.AccentColour = value; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index bc34648dd8..a78524011f 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -3,7 +3,7 @@ using JetBrains.Annotations; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI.Scrolling; @@ -41,9 +41,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables protected override bool ShouldBeAlive => AlwaysAlive || base.ShouldBeAlive; - protected virtual void OnDirectionChanged(ScrollingDirection direction) + protected virtual void OnDirectionChanged(ValueChangedEvent e) { - Anchor = Origin = direction == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; + Anchor = Origin = e.NewValue == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 7ed8e89f95..7ef90cdb9c 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osuTK.Graphics; using osu.Framework.Graphics; @@ -31,16 +32,16 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables InternalChild = headPiece = new NotePiece(); } - protected override void OnDirectionChanged(ScrollingDirection direction) + protected override void OnDirectionChanged(ValueChangedEvent e) { - base.OnDirectionChanged(direction); + base.OnDirectionChanged(e); - headPiece.Anchor = headPiece.Origin = direction == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; + headPiece.Anchor = headPiece.Origin = e.NewValue == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; } public override Color4 AccentColour { - get { return base.AccentColour; } + get => base.AccentColour; set { base.AccentColour = value; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs index 3decd46888..2baf1ad520 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs @@ -77,11 +77,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces public Color4 AccentColour { - get { return accentColour; } + get => accentColour; set { if (accentColour == value) return; + accentColour = value; updateAccentColour(); @@ -90,7 +91,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces public bool Hitting { - get { return hitting; } + get => hitting; set { hitting = value; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/GlowPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/GlowPiece.cs index 4a54ac0aac..b146a33fd3 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/GlowPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/GlowPiece.cs @@ -35,13 +35,15 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces } private Color4 accentColour; + public Color4 AccentColour { - get { return accentColour; } + get => accentColour; set { if (accentColour == value) return; + accentColour = value; updateGlow(); diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/LaneGlowPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/LaneGlowPiece.cs index 8927e0b068..9e0307c5c2 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/LaneGlowPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/LaneGlowPiece.cs @@ -78,8 +78,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces public Color4 AccentColour { - get { return Colour; } - set { Colour = value; } + get => Colour; + set => Colour = value; } } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs index 65a376a3a8..bb33693783 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osuTK.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -49,20 +49,22 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces private void load(IScrollingInfo scrollingInfo) { direction.BindTo(scrollingInfo.Direction); - direction.BindValueChanged(direction => + direction.BindValueChanged(dir => { - colouredBox.Anchor = colouredBox.Origin = direction == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; + colouredBox.Anchor = colouredBox.Origin = dir.NewValue == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; }, true); } private Color4 accentColour; + public Color4 AccentColour { - get { return accentColour; } + get => accentColour; set { if (accentColour == value) return; + accentColour = value; colouredBox.Colour = AccentColour.Lighten(0.9f); diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 8bb22fb586..5e9f46d9c7 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -17,9 +17,10 @@ namespace osu.Game.Rulesets.Mania.Objects public double EndTime => StartTime + Duration; private double duration; + public double Duration { - get { return duration; } + get => duration; set { duration = value; @@ -29,7 +30,7 @@ namespace osu.Game.Rulesets.Mania.Objects public override double StartTime { - get { return base.StartTime; } + get => base.StartTime; set { base.StartTime = value; @@ -40,7 +41,7 @@ namespace osu.Game.Rulesets.Mania.Objects public override int Column { - get { return base.Column; } + get => base.Column; set { base.Column = value; diff --git a/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs index 5765817b63..70720a926b 100644 --- a/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Rulesets.Mania.Objects.Types; using osu.Game.Rulesets.Objects; @@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Mania.Objects public virtual int Column { - get => ColumnBindable; + get => ColumnBindable.Value; set => ColumnBindable.Value = value; } diff --git a/osu.Game.Rulesets.Mania/Objects/ManiaHitObjectDifficulty.cs b/osu.Game.Rulesets.Mania/Objects/ManiaHitObjectDifficulty.cs deleted file mode 100644 index b6ea8c8665..0000000000 --- a/osu.Game.Rulesets.Mania/Objects/ManiaHitObjectDifficulty.cs +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Game.Rulesets.Objects.Types; -using System; - -namespace osu.Game.Rulesets.Mania.Objects -{ - internal class ManiaHitObjectDifficulty - { - /// - /// Factor by how much individual / overall strain decays per second. - /// - /// - /// These values are results of tweaking a lot and taking into account general feedback. - /// - internal const double INDIVIDUAL_DECAY_BASE = 0.125; - internal const double OVERALL_DECAY_BASE = 0.30; - - internal ManiaHitObject BaseHitObject; - - private readonly int beatmapColumnCount; - - private readonly double endTime; - private readonly double[] heldUntil; - - /// - /// Measures jacks or more generally: repeated presses of the same button - /// - private readonly double[] individualStrains; - - internal double IndividualStrain - { - get - { - return individualStrains[BaseHitObject.Column]; - } - - set - { - individualStrains[BaseHitObject.Column] = value; - } - } - - /// - /// Measures note density in a way - /// - internal double OverallStrain = 1; - - public ManiaHitObjectDifficulty(ManiaHitObject baseHitObject, int columnCount) - { - BaseHitObject = baseHitObject; - - endTime = (baseHitObject as IHasEndTime)?.EndTime ?? baseHitObject.StartTime; - - beatmapColumnCount = columnCount; - heldUntil = new double[beatmapColumnCount]; - individualStrains = new double[beatmapColumnCount]; - - for (int i = 0; i < beatmapColumnCount; ++i) - { - individualStrains[i] = 0; - heldUntil[i] = 0; - } - } - - internal void CalculateStrains(ManiaHitObjectDifficulty previousHitObject, double timeRate) - { - // TODO: Factor in holds - double timeElapsed = (BaseHitObject.StartTime - previousHitObject.BaseHitObject.StartTime) / timeRate; - double individualDecay = Math.Pow(INDIVIDUAL_DECAY_BASE, timeElapsed / 1000); - double overallDecay = Math.Pow(OVERALL_DECAY_BASE, timeElapsed / 1000); - - double holdFactor = 1.0; // Factor to all additional strains in case something else is held - double holdAddition = 0; // Addition to the current note in case it's a hold and has to be released awkwardly - - // Fill up the heldUntil array - for (int i = 0; i < beatmapColumnCount; ++i) - { - heldUntil[i] = previousHitObject.heldUntil[i]; - - // If there is at least one other overlapping end or note, then we get an addition, buuuuuut... - if (BaseHitObject.StartTime < heldUntil[i] && endTime > heldUntil[i]) - { - holdAddition = 1.0; - } - - // ... this addition only is valid if there is _no_ other note with the same ending. Releasing multiple notes at the same time is just as easy as releasing 1 - if (endTime == heldUntil[i]) - { - holdAddition = 0; - } - - // We give a slight bonus to everything if something is held meanwhile - if (heldUntil[i] > endTime) - { - holdFactor = 1.25; - } - - // Decay individual strains - individualStrains[i] = previousHitObject.individualStrains[i] * individualDecay; - } - - heldUntil[BaseHitObject.Column] = endTime; - - // Increase individual strain in own column - IndividualStrain += 2.0 * holdFactor; - - OverallStrain = previousHitObject.OverallStrain * overallDecay + (1.0 + holdAddition) * holdFactor; - } - } -} diff --git a/osu.Game.Rulesets.Mania/Objects/ManiaHitWindows.cs b/osu.Game.Rulesets.Mania/Objects/ManiaHitWindows.cs index 9ebe638c30..5f2ceab48b 100644 --- a/osu.Game.Rulesets.Mania/Objects/ManiaHitWindows.cs +++ b/osu.Game.Rulesets.Mania/Objects/ManiaHitWindows.cs @@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Mania.Objects private static readonly IReadOnlyDictionary base_ranges = new Dictionary { { HitResult.Perfect, (44.8, 38.8, 27.8) }, - { HitResult.Great, (128, 98, 68 ) }, + { HitResult.Great, (128, 98, 68) }, { HitResult.Good, (194, 164, 134) }, { HitResult.Ok, (254, 224, 194) }, { HitResult.Meh, (302, 272, 242) }, diff --git a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/diffcalc-test.osu b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/diffcalc-test.osu new file mode 100644 index 0000000000..4c877c6193 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/diffcalc-test.osu @@ -0,0 +1,180 @@ +osu file format v14 + +[General] +Mode: 3 + +[Difficulty] +CircleSize:4 +OverallDifficulty:7 +ApproachRate:8.3 +SliderMultiplier:1.6 +SliderTickRate:1 + +[TimingPoints] +500,500,4,2,1,50,1,0 +37500,-50,4,2,1,50,0,0 +41500,-25,4,2,1,50,0,0 + +[HitObjects] +// jacks spaced 1/1 beat apart +64,192,0,1,0,0:0:0:0: +64,192,500,1,0,0:0:0:0: +64,192,1000,1,0,0:0:0:0: +64,192,1500,1,0,0:0:0:0: +64,192,2000,1,0,0:0:0:0: +64,192,2500,1,0,0:0:0:0: + +// jacks spaced 1/2 beat apart +64,192,3500,1,0,0:0:0:0: +64,192,3750,1,0,0:0:0:0: +64,192,4000,1,0,0:0:0:0: +64,192,4250,1,0,0:0:0:0: +64,192,4500,1,0,0:0:0:0: +64,192,4750,1,0,0:0:0:0: +64,192,5000,1,0,0:0:0:0: +64,192,6000,1,0,0:0:0:0: + +// doubles jacks spaced 1/2 beat apart +192,192,6000,1,0,0:0:0:0: +64,192,6250,1,0,0:0:0:0: +192,192,6250,1,0,0:0:0:0: +64,192,6500,1,0,0:0:0:0: +192,192,6500,1,0,0:0:0:0: +64,192,6750,1,0,0:0:0:0: +192,192,6750,1,0,0:0:0:0: +64,192,7000,1,0,0:0:0:0: +192,192,7000,1,0,0:0:0:0: +64,192,7250,1,0,0:0:0:0: +192,192,7250,1,0,0:0:0:0: +64,192,7500,1,0,0:0:0:0: +192,192,7500,1,0,0:0:0:0: + +// trill spaced 1/2 beat apart +64,192,8500,1,0,0:0:0:0: +192,192,8750,1,0,0:0:0:0: +64,192,9000,1,0,0:0:0:0: +192,192,9250,1,0,0:0:0:0: +64,192,9500,1,0,0:0:0:0: +192,192,9750,1,0,0:0:0:0: +64,192,10000,1,0,0:0:0:0: +192,192,10250,1,0,0:0:0:0: +64,192,10500,1,0,0:0:0:0: + +// stair spaced 1/4 apart +64,192,11500,1,0,0:0:0:0: +192,192,11625,1,0,0:0:0:0: +320,192,11750,1,0,0:0:0:0: +448,192,11875,1,0,0:0:0:0: +320,192,12000,1,0,0:0:0:0: +192,192,12125,1,0,0:0:0:0: +64,192,12250,1,0,0:0:0:0: +192,192,12375,1,0,0:0:0:0: +320,192,12500,1,0,0:0:0:0: +448,192,12625,1,0,0:0:0:0: + +// jumpstreams? +64,192,13500,1,0,0:0:0:0: +192,192,13625,1,0,0:0:0:0: +320,192,13750,1,0,0:0:0:0: +448,192,13875,1,0,0:0:0:0: +320,192,14000,1,0,0:0:0:0: +192,192,14000,1,0,0:0:0:0: +64,192,14125,1,0,0:0:0:0: +192,192,14250,1,0,0:0:0:0: +320,192,14250,1,0,0:0:0:0: +448,192,14250,1,0,0:0:0:0: +64,192,14375,1,0,0:0:0:0: +64,192,14500,1,0,0:0:0:0: +320,192,14625,1,0,0:0:0:0: +448,192,14625,1,0,0:0:0:0: +192,192,14625,1,0,0:0:0:0: +192,192,14750,1,0,0:0:0:0: +64,192,14875,1,0,0:0:0:0: +192,192,15000,1,0,0:0:0:0: +320,192,15125,1,0,0:0:0:0: +448,192,15125,1,0,0:0:0:0: + +// double... jumps? +64,192,16000,1,0,0:0:0:0: +64,192,16250,1,0,0:0:0:0: +192,192,16250,1,0,0:0:0:0: +192,192,16500,1,0,0:0:0:0: +320,192,16500,1,0,0:0:0:0: +320,192,16750,1,0,0:0:0:0: +448,192,16750,1,0,0:0:0:0: +448,192,17000,1,0,0:0:0:0: + +// notes alongside hold +64,192,18000,128,0,18500:0:0:0:0: +192,192,18000,1,0,0:0:0:0: +192,192,18250,1,0,0:0:0:0: +192,192,18500,1,0,0:0:0:0: + +// notes overlapping hold +64,192,19500,1,0,0:0:0:0: +192,192,19625,128,0,20875:0:0:0:0: +64,192,19750,1,0,0:0:0:0: +64,192,20000,1,0,0:0:0:0: +64,192,20250,1,0,0:0:0:0: +64,192,20500,1,0,0:0:0:0: +64,192,20750,1,0,0:0:0:0: +64,192,21000,1,0,0:0:0:0: + +// simultaneous holds +64,192,22000,128,0,23000:0:0:0:0: +192,192,22000,128,0,23000:0:0:0:0: +320,192,22000,128,0,23000:0:0:0:0: +448,192,22000,128,0,23000:0:0:0:0: + +// hold stairs +64,192,24500,128,0,25500:0:0:0:0: +192,192,24625,128,0,25375:0:0:0:0: +320,192,24750,128,0,25250:0:0:0:0: +448,192,24875,128,0,25125:0:0:0:0: +448,192,25375,128,0,26375:0:0:0:0: +320,192,25500,128,0,26250:0:0:0:0: +192,192,25625,128,0,26125:0:0:0:0: +64,192,25750,128,0,26000:0:0:0:0: + +// quads +64,192,26500,1,0,0:0:0:0: +64,192,27500,1,0,0:0:0:0: +192,192,27500,1,0,0:0:0:0: +320,192,27500,1,0,0:0:0:0: +448,192,27500,1,0,0:0:0:0: +64,192,27750,1,0,0:0:0:0: +192,192,27750,1,0,0:0:0:0: +320,192,27750,1,0,0:0:0:0: +448,192,27750,1,0,0:0:0:0: +64,192,28000,1,0,0:0:0:0: +192,192,28000,1,0,0:0:0:0: +320,192,28000,1,0,0:0:0:0: +448,192,28000,1,0,0:0:0:0: +64,192,28250,1,0,0:0:0:0: +192,192,28250,1,0,0:0:0:0: +320,192,28250,1,0,0:0:0:0: +448,192,28250,1,0,0:0:0:0: +64,192,28500,1,0,0:0:0:0: +192,192,28500,1,0,0:0:0:0: +320,192,28500,1,0,0:0:0:0: +448,192,28500,1,0,0:0:0:0: + +// double-trills +64,192,29500,1,0,0:0:0:0: +192,192,29500,1,0,0:0:0:0: +320,192,29625,1,0,0:0:0:0: +448,192,29625,1,0,0:0:0:0: +64,192,29750,1,0,0:0:0:0: +192,192,29750,1,0,0:0:0:0: +320,192,29875,1,0,0:0:0:0: +448,192,29875,1,0,0:0:0:0: +64,192,30000,1,0,0:0:0:0: +192,192,30000,1,0,0:0:0:0: +320,192,30125,1,0,0:0:0:0: +448,192,30125,1,0,0:0:0:0: +64,192,30250,1,0,0:0:0:0: +192,192,30250,1,0,0:0:0:0: +320,192,30375,1,0,0:0:0:0: +448,192,30375,1,0,0:0:0:0: +64,192,30500,1,0,0:0:0:0: +192,192,30500,1,0,0:0:0:0: diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 3e7884af6c..c59bed4ea7 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -8,7 +8,7 @@ using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Rulesets.Objects.Drawables; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Input.Bindings; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mania.UI.Components; @@ -82,28 +82,30 @@ namespace osu.Game.Rulesets.Mania.UI TopLevelContainer.Add(explosionContainer.CreateProxy()); - Direction.BindValueChanged(d => + Direction.BindValueChanged(dir => { hitTargetContainer.Padding = new MarginPadding { - Top = d == ScrollingDirection.Up ? ManiaStage.HIT_TARGET_POSITION : 0, - Bottom = d == ScrollingDirection.Down ? ManiaStage.HIT_TARGET_POSITION : 0, + Top = dir.NewValue == ScrollingDirection.Up ? ManiaStage.HIT_TARGET_POSITION : 0, + Bottom = dir.NewValue == ScrollingDirection.Down ? ManiaStage.HIT_TARGET_POSITION : 0, }; - keyArea.Anchor = keyArea.Origin= d == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft; + keyArea.Anchor = keyArea.Origin = dir.NewValue == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft; }, true); } public override Axes RelativeSizeAxes => Axes.Y; private bool isSpecial; + public bool IsSpecial { - get { return isSpecial; } + get => isSpecial; set { if (isSpecial == value) return; + isSpecial = value; Width = isSpecial ? special_column_width : column_width; @@ -111,13 +113,15 @@ namespace osu.Game.Rulesets.Mania.UI } private Color4 accentColour; + public Color4 AccentColour { - get { return accentColour; } + get => accentColour; set { if (accentColour == value) return; + accentColour = value; background.AccentColour = value; @@ -156,7 +160,7 @@ namespace osu.Game.Rulesets.Mania.UI internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result) { - if (!result.IsHit || !judgedObject.DisplayResult || !DisplayJudgements) + if (!result.IsHit || !judgedObject.DisplayResult || !DisplayJudgements.Value) return; explosionContainer.Add(new HitExplosion(judgedObject) @@ -167,7 +171,7 @@ namespace osu.Game.Rulesets.Mania.UI public bool OnPressed(ManiaAction action) { - if (action != Action) + if (action != Action.Value) return false; var nextObject = diff --git a/osu.Game.Rulesets.Mania/UI/Components/ColumnBackground.cs b/osu.Game.Rulesets.Mania/UI/Components/ColumnBackground.cs index b7f291b5a2..b4e29ae9f9 100644 --- a/osu.Game.Rulesets.Mania/UI/Components/ColumnBackground.cs +++ b/osu.Game.Rulesets.Mania/UI/Components/ColumnBackground.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -48,9 +48,9 @@ namespace osu.Game.Rulesets.Mania.UI.Components }; direction.BindTo(scrollingInfo.Direction); - direction.BindValueChanged(direction => + direction.BindValueChanged(dir => { - backgroundOverlay.Anchor = backgroundOverlay.Origin = direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft; + backgroundOverlay.Anchor = backgroundOverlay.Origin = dir.NewValue == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft; updateColours(); }, true); } @@ -70,6 +70,7 @@ namespace osu.Game.Rulesets.Mania.UI.Components { if (accentColour == value) return; + accentColour = value; updateColours(); diff --git a/osu.Game.Rulesets.Mania/UI/Components/ColumnHitObjectArea.cs b/osu.Game.Rulesets.Mania/UI/Components/ColumnHitObjectArea.cs index 7f5687e600..89e8cd9b5a 100644 --- a/osu.Game.Rulesets.Mania/UI/Components/ColumnHitObjectArea.cs +++ b/osu.Game.Rulesets.Mania/UI/Components/ColumnHitObjectArea.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -49,9 +49,9 @@ namespace osu.Game.Rulesets.Mania.UI.Components private void load(IScrollingInfo scrollingInfo) { direction.BindTo(scrollingInfo.Direction); - direction.BindValueChanged(direction => + direction.BindValueChanged(dir => { - Anchor anchor = direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft; + Anchor anchor = dir.NewValue == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft; hitTargetBar.Anchor = hitTargetBar.Origin = anchor; hitTargetLine.Anchor = hitTargetLine.Origin = anchor; @@ -73,6 +73,7 @@ namespace osu.Game.Rulesets.Mania.UI.Components { if (accentColour == value) return; + accentColour = value; updateColours(); diff --git a/osu.Game.Rulesets.Mania/UI/Components/ColumnKeyArea.cs b/osu.Game.Rulesets.Mania/UI/Components/ColumnKeyArea.cs index a180ffbd3b..03b55cbead 100644 --- a/osu.Game.Rulesets.Mania/UI/Components/ColumnKeyArea.cs +++ b/osu.Game.Rulesets.Mania/UI/Components/ColumnKeyArea.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -64,11 +64,11 @@ namespace osu.Game.Rulesets.Mania.UI.Components }; direction.BindTo(scrollingInfo.Direction); - direction.BindValueChanged(direction => + direction.BindValueChanged(dir => { gradient.Colour = ColourInfo.GradientVertical( - direction == ScrollingDirection.Up ? Color4.Black : Color4.Black.Opacity(0), - direction == ScrollingDirection.Up ? Color4.Black.Opacity(0) : Color4.Black); + dir.NewValue == ScrollingDirection.Up ? Color4.Black : Color4.Black.Opacity(0), + dir.NewValue == ScrollingDirection.Up ? Color4.Black.Opacity(0) : Color4.Black); }, true); } @@ -87,6 +87,7 @@ namespace osu.Game.Rulesets.Mania.UI.Components { if (accentColour == value) return; + accentColour = value; updateColours(); diff --git a/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs b/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs index 1469924bb2..5874bac7f6 100644 --- a/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs +++ b/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Mania.UI private void load() { if (JudgementText != null) - JudgementText.TextSize = 25; + JudgementText.Font = JudgementText.Font.With(size: 25); } protected override void LoadComplete() diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index 892ad584dc..9b8d63dc92 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Input; @@ -15,7 +15,6 @@ using osu.Game.Input.Handlers; using osu.Game.Replays; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Configuration; -using osu.Game.Rulesets.Mania.Mods; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Replays; @@ -76,7 +75,7 @@ namespace osu.Game.Rulesets.Mania.UI BarLines.ForEach(Playfield.Add); Config.BindWith(ManiaSetting.ScrollDirection, configDirection); - configDirection.BindValueChanged(v => Direction.Value = (ScrollingDirection)v, true); + configDirection.BindValueChanged(direction => Direction.Value = (ScrollingDirection)direction.NewValue, true); Config.BindWith(ManiaSetting.ScrollTime, TimeRange); } @@ -96,7 +95,7 @@ namespace osu.Game.Rulesets.Mania.UI public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this); - public override int Variant => (int)(Mods.OfType().FirstOrDefault()?.PlayfieldType ?? PlayfieldType.Single) + Beatmap.TotalColumns; + public override int Variant => (int)(Beatmap.Stages.Count == 1 ? PlayfieldType.Single : PlayfieldType.Dual) + Beatmap.TotalColumns; public override PassThroughInputManager CreateInputManager() => new ManiaInputManager(Ruleset.RulesetInfo, Variant); diff --git a/osu.Game.Rulesets.Mania/UI/ManiaStage.cs b/osu.Game.Rulesets.Mania/UI/ManiaStage.cs index bce333ff34..a28de7ea58 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaStage.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaStage.cs @@ -136,12 +136,12 @@ namespace osu.Game.Rulesets.Mania.UI AddColumn(column); } - Direction.BindValueChanged(d => + Direction.BindValueChanged(dir => { barLineContainer.Padding = new MarginPadding { - Top = d == ScrollingDirection.Up ? HIT_TARGET_POSITION : 0, - Bottom = d == ScrollingDirection.Down ? HIT_TARGET_POSITION : 0, + Top = dir.NewValue == ScrollingDirection.Up ? HIT_TARGET_POSITION : 0, + Bottom = dir.NewValue == ScrollingDirection.Down ? HIT_TARGET_POSITION : 0, }; }, true); } @@ -185,7 +185,7 @@ namespace osu.Game.Rulesets.Mania.UI internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result) { - if (!judgedObject.DisplayResult || !DisplayJudgements) + if (!judgedObject.DisplayResult || !DisplayJudgements.Value) return; judgements.Clear(); diff --git a/osu.Game.Rulesets.Osu.Tests/OsuBeatmapConversionTest.cs b/osu.Game.Rulesets.Osu.Tests/OsuBeatmapConversionTest.cs index 0ebcad3637..f7d1ff4db1 100644 --- a/osu.Game.Rulesets.Osu.Tests/OsuBeatmapConversionTest.cs +++ b/osu.Game.Rulesets.Osu.Tests/OsuBeatmapConversionTest.cs @@ -33,9 +33,11 @@ namespace osu.Game.Rulesets.Osu.Tests case Slider slider: foreach (var nested in slider.NestedHitObjects) yield return createConvertValue(nested); + break; default: yield return createConvertValue(hitObject); + break; } diff --git a/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs b/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs new file mode 100644 index 0000000000..e55dc1f902 --- /dev/null +++ b/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs @@ -0,0 +1,25 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Difficulty; +using osu.Game.Rulesets.Osu.Difficulty; +using osu.Game.Tests.Beatmaps; + +namespace osu.Game.Rulesets.Osu.Tests +{ + [TestFixture] + public class OsuDifficultyCalculatorTest : DifficultyCalculatorTest + { + protected override string ResourceAssembly => "osu.Game.Rulesets.Osu"; + + [TestCase(6.931145117263422, "diffcalc-test")] + public void Test(double expected, string name) + => base.Test(expected, name); + + protected override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new OsuDifficultyCalculator(new OsuRuleset(), beatmap); + + protected override Ruleset CreateRuleset() => new OsuRuleset(); + } +} diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseGameplayCursor.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseGameplayCursor.cs index 6ebfe4fad1..3d553c334f 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestCaseGameplayCursor.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseGameplayCursor.cs @@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Osu.Tests { private GameplayCursor cursor; - public override IReadOnlyList RequiredTypes => new [] { typeof(CursorTrail) }; + public override IReadOnlyList RequiredTypes => new[] { typeof(CursorTrail) }; public CursorContainer Cursor => cursor; diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircle.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircle.cs index 5484f15581..e1e854e8dc 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircle.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircle.cs @@ -89,7 +89,8 @@ namespace osu.Game.Rulesets.Osu.Tests { private readonly bool auto; - public TestDrawableHitCircle(HitCircle h, bool auto) : base(h) + public TestDrawableHitCircle(HitCircle h, bool auto) + : base(h) { this.auto = auto; } diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseSlider.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseSlider.cs index d6b88c1c5f..35e8f3e17e 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestCaseSlider.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseSlider.cs @@ -16,6 +16,7 @@ using osuTK.Graphics; using osu.Game.Rulesets.Mods; using System.Linq; using NUnit.Framework; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects; @@ -300,6 +301,7 @@ namespace osu.Game.Rulesets.Osu.Tests } private float judgementOffsetDirection = 1; + private void onNewResult(DrawableHitObject judgedObject, JudgementResult result) { var osuObject = judgedObject as DrawableOsuHitObject; @@ -313,7 +315,7 @@ namespace osu.Game.Rulesets.Osu.Tests Origin = Anchor.Centre, Text = result.IsHit ? "Hit!" : "Miss!", Colour = result.IsHit ? Color4.Green : Color4.Red, - TextSize = 30, + Font = OsuFont.GetFont(size: 30), Position = osuObject.HitObject.StackedEndPosition + judgementOffsetDirection * new Vector2(0, 45) }); diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs new file mode 100644 index 0000000000..57effe01f1 --- /dev/null +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs @@ -0,0 +1,372 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; +using osu.Framework.Screens; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Replays; +using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Objects.Types; +using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; +using osu.Game.Rulesets.Osu.Replays; +using osu.Game.Rulesets.Replays; +using osu.Game.Rulesets.Scoring; +using osu.Game.Scoring; +using osu.Game.Screens.Play; +using osu.Game.Tests.Beatmaps; +using osu.Game.Tests.Visual; +using osuTK; + +namespace osu.Game.Rulesets.Osu.Tests +{ + public class TestCaseSliderInput : RateAdjustedBeatmapTestCase + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(SliderBall), + typeof(DrawableSlider), + typeof(DrawableSliderTick), + typeof(DrawableRepeatPoint), + typeof(DrawableOsuHitObject), + typeof(DrawableSliderHead), + typeof(DrawableSliderTail), + }; + + private const double time_before_slider = 250; + private const double time_slider_start = 1500; + private const double time_during_slide_1 = 2500; + private const double time_during_slide_2 = 3000; + private const double time_during_slide_3 = 3500; + private const double time_during_slide_4 = 3800; + + private List judgementResults; + private bool allJudgedFired; + + /// + /// Scenario: + /// - Press a key before a slider starts + /// - Press the other key on the slider head timed correctly while holding the original key + /// - Release the latter pressed key + /// Expected Result: + /// A passing test case will have the cursor lose tracking on replay frame 3. + /// + [Test] + public void TestInvalidKeyTransfer() + { + performTest(new List + { + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_before_slider }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton, OsuAction.RightButton }, Time = time_slider_start }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_during_slide_1 }, + }); + + AddAssert("Tracking lost", assertMidSliderJudgementFail); + } + + /// + /// Scenario: + /// - Press a key on the slider head timed correctly + /// - Press the other key in the middle of the slider while holding the original key + /// - Release the original key used to hit the slider + /// Expected Result: + /// A passing test case will have the cursor continue tracking on replay frame 3. + /// + [Test] + public void TestLeftBeforeSliderThenRightThenLettingGoOfLeft() + { + performTest(new List + { + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_slider_start }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton, OsuAction.RightButton }, Time = time_during_slide_1 }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.RightButton }, Time = time_during_slide_2 }, + }); + + AddAssert("Tracking retained", assertGreatJudge); + } + + /// + /// Scenario: + /// - Press a key on the slider head timed correctly + /// - Press the other key in the middle of the slider while holding the original key + /// - Release the new key that was pressed second + /// Expected Result: + /// A passing test case will have the cursor continue tracking on replay frame 3. + /// + [Test] + public void TestTrackingRetentionLeftRightLeft() + { + performTest(new List + { + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_before_slider }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton, OsuAction.RightButton }, Time = time_slider_start }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.RightButton }, Time = time_during_slide_1 }, + }); + + AddAssert("Tracking retained", assertGreatJudge); + } + + /// + /// Scenario: + /// - Press a key before a slider starts + /// - Press the other key on the slider head timed correctly while holding the original key + /// - Release the key that was held down before the slider started. + /// Expected Result: + /// A passing test case will have the cursor continue tracking on replay frame 3 + /// + [Test] + public void TestTrackingLeftBeforeSliderToRight() + { + performTest(new List + { + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_before_slider }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton, OsuAction.RightButton }, Time = time_slider_start }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.RightButton }, Time = time_during_slide_1 }, + }); + + AddAssert("Tracking retained", assertGreatJudge); + } + + /// + /// Scenario: + /// - Press a key before a slider starts + /// - Hold the key down throughout the slider without pressing any other buttons. + /// Expected Result: + /// A passing test case will have the cursor track the slider, but miss the slider head. + /// + [Test] + public void TestTrackingPreclicked() + { + performTest(new List + { + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_before_slider }, + }); + + AddAssert("Tracking retained, sliderhead miss", assertHeadMissTailTracked); + } + + /// + /// Scenario: + /// - Press a key before a slider starts + /// - Hold the key down after the slider starts + /// - Move the cursor away from the slider body + /// - Move the cursor back onto the body + /// Expected Result: + /// A passing test case will have the cursor track the slider, miss the head, miss the ticks where its outside of the body, and resume tracking when the cursor returns. + /// + [Test] + public void TestTrackingReturnMidSlider() + { + performTest(new List + { + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_slider_start }, + new OsuReplayFrame { Position = new Vector2(150, 150), Actions = { OsuAction.LeftButton }, Time = time_during_slide_1 }, + new OsuReplayFrame { Position = new Vector2(200, 200), Actions = { OsuAction.LeftButton }, Time = time_during_slide_2 }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_during_slide_3 }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_during_slide_4 }, + }); + + AddAssert("Tracking re-acquired", assertMidSliderJudgements); + } + + /// + /// Scenario: + /// - Press a key before a slider starts + /// - Press the other key on the slider head timed correctly while holding the original key + /// - Release the key used to hit the slider head + /// - While holding the first key, move the cursor away from the slider body + /// - Still holding the first key, move the cursor back to the slider body + /// Expected Result: + /// A passing test case will have the slider not track despite having the cursor return to the slider body. + /// + [Test] + public void TestTrackingReturnMidSliderKeyDownBefore() + { + performTest(new List + { + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_before_slider }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton, OsuAction.RightButton }, Time = time_slider_start }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_during_slide_1 }, + new OsuReplayFrame { Position = new Vector2(200, 200), Actions = { OsuAction.LeftButton }, Time = time_during_slide_2 }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_during_slide_3 }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_during_slide_4 }, + }); + + AddAssert("Tracking lost", assertMidSliderJudgementFail); + } + + /// + /// Scenario: + /// - Wait for the slider to reach a mid-point + /// - Press a key away from the slider body + /// - While holding down the key, move into the slider body + /// Expected Result: + /// A passing test case will have the slider track the cursor after the cursor enters the slider body. + /// + [Test] + public void TestTrackingMidSlider() + { + performTest(new List + { + new OsuReplayFrame { Position = new Vector2(150, 150), Actions = { OsuAction.LeftButton }, Time = time_during_slide_1 }, + new OsuReplayFrame { Position = new Vector2(200, 200), Actions = { OsuAction.LeftButton }, Time = time_during_slide_2 }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_during_slide_3 }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_during_slide_4 }, + }); + + AddAssert("Tracking acquired", assertMidSliderJudgements); + } + + /// + /// Scenario: + /// - Press a key before the slider starts + /// - Press another key on the slider head while holding the original key + /// - Move out of the slider body while releasing the two pressed keys + /// - Move back into the slider body while pressing any key. + /// Expected Result: + /// A passing test case will have the slider track the cursor after the cursor enters the slider body. + /// + [Test] + public void TestMidSliderTrackingAcquired() + { + performTest(new List + { + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_before_slider }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton, OsuAction.RightButton }, Time = time_slider_start }, + new OsuReplayFrame { Position = new Vector2(100, 100), Time = time_during_slide_1 }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_during_slide_2 }, + }); + + AddAssert("Tracking acquired", assertMidSliderJudgements); + } + + [Test] + public void TestMidSliderTrackingAcquiredWithMouseDownOutsideSlider() + { + performTest(new List + { + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_before_slider }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton, OsuAction.RightButton }, Time = time_slider_start }, + new OsuReplayFrame { Position = new Vector2(100, 100), Actions = { OsuAction.RightButton }, Time = time_during_slide_1 }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.RightButton }, Time = time_during_slide_2 }, + }); + + AddAssert("Tracking acquired", assertMidSliderJudgements); + } + + /// + /// Scenario: + /// - Press a key on the slider head + /// - While holding the key, move outside of the slider body with the cursor + /// - Release the key while outside of the slider body + /// - Press the key again while outside of the slider body + /// - Move back into the slider body while holding the pressed key + /// Expected Result: + /// A passing test case will have the slider track the cursor after the cursor enters the slider body. + /// + [Test] + public void TestTrackingReleasedValidKey() + { + performTest(new List + { + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_slider_start }, + new OsuReplayFrame { Position = new Vector2(100, 100), Actions = { OsuAction.LeftButton }, Time = time_during_slide_1 }, + new OsuReplayFrame { Position = new Vector2(100, 100), Time = time_during_slide_2 }, + new OsuReplayFrame { Position = new Vector2(100, 100), Actions = { OsuAction.LeftButton }, Time = time_during_slide_3 }, + new OsuReplayFrame { Position = new Vector2(0, 0), Actions = { OsuAction.LeftButton }, Time = time_during_slide_4 }, + }); + + AddAssert("Tracking acquired", assertMidSliderJudgements); + } + + private bool assertGreatJudge() => judgementResults.Last().Type == HitResult.Great; + + private bool assertHeadMissTailTracked() => judgementResults[judgementResults.Count - 2].Type == HitResult.Great && judgementResults.First().Type == HitResult.Miss; + + private bool assertMidSliderJudgements() => judgementResults[judgementResults.Count - 2].Type == HitResult.Great; + + private bool assertMidSliderJudgementFail() => judgementResults[judgementResults.Count - 2].Type == HitResult.Miss; + + private ScoreAccessibleReplayPlayer currentPlayer; + + private void performTest(List frames) + { + // Empty frame to be added as a workaround for first frame behavior. + // If an input exists on the first frame, the input would apply to the entire intro lead-in + // Likely requires some discussion regarding how first frame inputs should be handled. + frames.Insert(0, new OsuReplayFrame()); + + AddStep("load player", () => + { + Beatmap.Value = new TestWorkingBeatmap(new Beatmap + { + HitObjects = + { + new Slider + { + StartTime = time_slider_start, + Position = new Vector2(0, 0), + Path = new SliderPath(PathType.PerfectCurve, new[] + { + Vector2.Zero, + new Vector2(25, 0), + }, 25), + } + }, + ControlPointInfo = + { + DifficultyPoints = { new DifficultyControlPoint { SpeedMultiplier = 0.1f } } + }, + BeatmapInfo = + { + BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 3 }, + Ruleset = new OsuRuleset().RulesetInfo + }, + }, Clock); + + var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } }) + { + AllowPause = false, + AllowLeadIn = false, + AllowResults = false + }; + + p.OnLoadComplete += _ => + { + p.ScoreProcessor.NewJudgement += result => + { + if (currentPlayer == p) judgementResults.Add(result); + }; + p.ScoreProcessor.AllJudged += () => + { + if (currentPlayer == p) allJudgedFired = true; + }; + }; + + LoadScreen(currentPlayer = p); + allJudgedFired = false; + judgementResults = new List(); + }); + + AddUntilStep(() => Beatmap.Value.Track.CurrentTime == 0, "Beatmap at 0"); + AddUntilStep(() => currentPlayer.IsCurrentScreen(), "Wait until player is loaded"); + AddUntilStep(() => allJudgedFired, "Wait for all judged"); + } + + private class ScoreAccessibleReplayPlayer : ReplayPlayer + { + public new ScoreProcessor ScoreProcessor => base.ScoreProcessor; + + public ScoreAccessibleReplayPlayer(Score score) + : base(score) + { + } + } + } +} diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseSpinner.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseSpinner.cs index df903efe3d..e8b534bba9 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestCaseSpinner.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseSpinner.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Tests public class TestCaseSpinner : OsuTestCase { public override IReadOnlyList RequiredTypes => new[] -{ + { typeof(SpinnerDisc), typeof(DrawableSpinner), typeof(DrawableOsuHitObject) @@ -67,7 +67,8 @@ namespace osu.Game.Rulesets.Osu.Tests { private bool auto; - public TestDrawableSpinner(Spinner s, bool auto) : base(s) + public TestDrawableSpinner(Spinner s, bool auto) + : base(s) { this.auto = auto; } diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyAttributes.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyAttributes.cs index fd54dc0260..6e991a1d08 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyAttributes.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyAttributes.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using osu.Game.Rulesets.Difficulty; -using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Osu.Difficulty { @@ -13,10 +12,5 @@ namespace osu.Game.Rulesets.Osu.Difficulty public double ApproachRate; public double OverallDifficulty; public int MaxCombo; - - public OsuDifficultyAttributes(Mod[] mods, double starRating) - : base(mods, starRating) - { - } } } diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs index 3d0a1dc266..e2a1542574 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs @@ -1,10 +1,13 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using System.Linq; using osu.Game.Beatmaps; using osu.Game.Rulesets.Difficulty; +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Difficulty.Skills; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Osu.Difficulty.Preprocessing; using osu.Game.Rulesets.Osu.Difficulty.Skills; @@ -15,7 +18,6 @@ namespace osu.Game.Rulesets.Osu.Difficulty { public class OsuDifficultyCalculator : DifficultyCalculator { - private const int section_length = 400; private const double difficulty_multiplier = 0.0675; public OsuDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap) @@ -23,58 +25,27 @@ namespace osu.Game.Rulesets.Osu.Difficulty { } - protected override DifficultyAttributes Calculate(IBeatmap beatmap, Mod[] mods, double timeRate) + protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) { - if (!beatmap.HitObjects.Any()) - return new OsuDifficultyAttributes(mods, 0); - - OsuDifficultyBeatmap difficultyBeatmap = new OsuDifficultyBeatmap(beatmap.HitObjects.Cast().ToList(), timeRate); - Skill[] skills = - { - new Aim(), - new Speed() - }; - - double sectionLength = section_length * timeRate; - - // The first object doesn't generate a strain, so we begin with an incremented section end - double currentSectionEnd = Math.Ceiling(beatmap.HitObjects.First().StartTime / sectionLength) * sectionLength; - - foreach (OsuDifficultyHitObject h in difficultyBeatmap) - { - while (h.BaseObject.StartTime > currentSectionEnd) - { - foreach (Skill s in skills) - { - s.SaveCurrentPeak(); - s.StartNewSectionFrom(currentSectionEnd); - } - - currentSectionEnd += sectionLength; - } - - foreach (Skill s in skills) - s.Process(h); - } - - // The peak strain will not be saved for the last section in the above loop - foreach (Skill s in skills) - s.SaveCurrentPeak(); + if (beatmap.HitObjects.Count == 0) + return new OsuDifficultyAttributes { Mods = mods }; double aimRating = Math.Sqrt(skills[0].DifficultyValue()) * difficulty_multiplier; double speedRating = Math.Sqrt(skills[1].DifficultyValue()) * difficulty_multiplier; double starRating = aimRating + speedRating + Math.Abs(aimRating - speedRating) / 2; // Todo: These int casts are temporary to achieve 1:1 results with osu!stable, and should be removed in the future - double hitWindowGreat = (int)(beatmap.HitObjects.First().HitWindows.Great / 2) / timeRate; - double preempt = (int)BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / timeRate; + double hitWindowGreat = (int)(beatmap.HitObjects.First().HitWindows.Great / 2) / clockRate; + double preempt = (int)BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / clockRate; int maxCombo = beatmap.HitObjects.Count; // Add the ticks + tail of the slider. 1 is subtracted because the head circle would be counted twice (once for the slider itself in the line above) maxCombo += beatmap.HitObjects.OfType().Sum(s => s.NestedHitObjects.Count - 1); - return new OsuDifficultyAttributes(mods, starRating) + return new OsuDifficultyAttributes { + StarRating = starRating, + Mods = mods, AimStrain = aimRating, SpeedStrain = speedRating, ApproachRate = preempt > 1200 ? (1800 - preempt) / 120 : (1200 - preempt) / 150 + 5, @@ -83,6 +54,26 @@ namespace osu.Game.Rulesets.Osu.Difficulty }; } + protected override IEnumerable CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate) + { + // The first jump is formed by the first two hitobjects of the map. + // If the map has less than two OsuHitObjects, the enumerator will not return anything. + for (int i = 1; i < beatmap.HitObjects.Count; i++) + { + var lastLast = i > 1 ? beatmap.HitObjects[i - 2] : null; + var last = beatmap.HitObjects[i - 1]; + var current = beatmap.HitObjects[i]; + + yield return new OsuDifficultyHitObject(current, lastLast, last, clockRate); + } + } + + protected override Skill[] CreateSkills(IBeatmap beatmap) => new Skill[] + { + new Aim(), + new Speed() + }; + protected override Mod[] DifficultyAdjustmentMods => new Mod[] { new OsuModDoubleTime(), diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs index 13a21c5c55..0dce5208dd 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs @@ -97,7 +97,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty // Longer maps are worth more double lengthBonus = 0.95f + 0.4f * Math.Min(1.0f, totalHits / 2000.0f) + - (totalHits > 2000 ? Math.Log10(totalHits / 2000.0f) * 0.5f : 0.0f); + (totalHits > 2000 ? Math.Log10(totalHits / 2000.0f) * 0.5f : 0.0f); aimValue *= lengthBonus; @@ -113,7 +113,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty approachRateFactor += 0.3f * (Attributes.ApproachRate - 10.33f); else if (Attributes.ApproachRate < 8.0f) { - approachRateFactor += 0.01f * (8.0f - Attributes.ApproachRate); + approachRateFactor += 0.01f * (8.0f - Attributes.ApproachRate); } aimValue *= approachRateFactor; @@ -126,8 +126,10 @@ namespace osu.Game.Rulesets.Osu.Difficulty { // Apply object-based bonus for flashlight. aimValue *= 1.0f + 0.35f * Math.Min(1.0f, totalHits / 200.0f) + - (totalHits > 200 ? 0.3f * Math.Min(1.0f, (totalHits - 200) / 300.0f) + - (totalHits > 500 ? (totalHits - 500) / 1200.0f : 0.0f) : 0.0f); + (totalHits > 200 + ? 0.3f * Math.Min(1.0f, (totalHits - 200) / 300.0f) + + (totalHits > 500 ? (totalHits - 500) / 1200.0f : 0.0f) + : 0.0f); } // Scale the aim value with accuracy _slightly_ @@ -144,7 +146,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty // Longer maps are worth more speedValue *= 0.95f + 0.4f * Math.Min(1.0f, totalHits / 2000.0f) + - (totalHits > 2000 ? Math.Log10(totalHits / 2000.0f) * 0.5f : 0.0f); + (totalHits > 2000 ? Math.Log10(totalHits / 2000.0f) * 0.5f : 0.0f); // Penalize misses exponentially. This mainly fixes tag4 maps and the likes until a per-hitobject solution is available speedValue *= Math.Pow(0.97f, countMiss); diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyBeatmap.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyBeatmap.cs deleted file mode 100644 index 068564d50c..0000000000 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyBeatmap.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using osu.Game.Rulesets.Osu.Objects; - -namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing -{ - /// - /// An enumerable container wrapping input as - /// which contains extra data required for difficulty calculation. - /// - public class OsuDifficultyBeatmap : IEnumerable - { - private readonly IEnumerator difficultyObjects; - - /// - /// Creates an enumerator, which preprocesses a list of s recieved as input, wrapping them as - /// which contains extra data required for difficulty calculation. - /// - public OsuDifficultyBeatmap(List objects, double timeRate) - { - // Sort OsuHitObjects by StartTime - they are not correctly ordered in some cases. - // This should probably happen before the objects reach the difficulty calculator. - difficultyObjects = createDifficultyObjectEnumerator(objects.OrderBy(h => h.StartTime).ToList(), timeRate); - } - - /// - /// Returns an enumerator that enumerates all s in the . - /// - public IEnumerator GetEnumerator() => difficultyObjects; - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - - private IEnumerator createDifficultyObjectEnumerator(List objects, double timeRate) - { - // The first jump is formed by the first two hitobjects of the map. - // If the map has less than two OsuHitObjects, the enumerator will not return anything. - for (int i = 1; i < objects.Count; i++) - { - var lastLast = i > 1 ? objects[i - 2] : null; - var last = objects[i - 1]; - var current = objects[i]; - - yield return new OsuDifficultyHitObject(lastLast, last, current, timeRate); - } - } - } -} diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs index 1ec12adb3b..37276a3432 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -1,24 +1,20 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.Linq; +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Objects; using osuTK; namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing { - /// - /// A wrapper around extending it with additional data required for difficulty calculation. - /// - public class OsuDifficultyHitObject + public class OsuDifficultyHitObject : DifficultyHitObject { private const int normalized_radius = 52; - /// - /// The this refers to. - /// - public OsuHitObject BaseObject { get; } + protected new OsuHitObject BaseObject => (OsuHitObject)base.BaseObject; /// /// Normalized distance from the end position of the previous to the start position of this . @@ -30,40 +26,30 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing /// public double TravelDistance { get; private set; } - /// - /// Milliseconds elapsed since the StartTime of the previous . - /// - public double DeltaTime { get; private set; } - - /// - /// Milliseconds elapsed since the start time of the previous , with a minimum of 50ms. - /// - public double StrainTime { get; private set; } - /// /// Angle the player has to take to hit this . /// Calculated as the angle between the circles (current-2, current-1, current). /// public double? Angle { get; private set; } + /// + /// Milliseconds elapsed since the start time of the previous , with a minimum of 50ms. + /// + public readonly double StrainTime; + private readonly OsuHitObject lastLastObject; private readonly OsuHitObject lastObject; - private readonly double timeRate; - /// - /// Initializes the object calculating extra data required for difficulty calculation. - /// - public OsuDifficultyHitObject(OsuHitObject lastLastObject, OsuHitObject lastObject, OsuHitObject currentObject, double timeRate) + public OsuDifficultyHitObject(HitObject hitObject, HitObject lastLastObject, HitObject lastObject, double clockRate) + : base(hitObject, lastObject, clockRate) { - this.lastLastObject = lastLastObject; - this.lastObject = lastObject; - this.timeRate = timeRate; - - BaseObject = currentObject; + this.lastLastObject = (OsuHitObject)lastLastObject; + this.lastObject = (OsuHitObject)lastObject; setDistances(); - setTimingValues(); - // Calculate angle here + + // Every strain interval is hard capped at the equivalent of 375 BPM streaming speed as a safety measure + StrainTime = Math.Max(50, DeltaTime); } private void setDistances() @@ -102,18 +88,11 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing } } - private void setTimingValues() - { - DeltaTime = (BaseObject.StartTime - lastObject.StartTime) / timeRate; - - // Every strain interval is hard capped at the equivalent of 375 BPM streaming speed as a safety measure - StrainTime = Math.Max(50, DeltaTime); - } - private void computeSliderCursorPosition(Slider slider) { if (slider.LazyEndPosition != null) return; + slider.LazyEndPosition = slider.StackedPosition; float approxFollowCircleRadius = (float)(slider.Radius * 3); @@ -149,8 +128,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing { Vector2 pos = hitObject.StackedPosition; - var slider = hitObject as Slider; - if (slider != null) + if (hitObject is Slider slider) { computeSliderCursorPosition(slider); pos = slider.LazyEndPosition ?? pos; diff --git a/osu.Game.Rulesets.Osu/Difficulty/Skills/Aim.cs b/osu.Game.Rulesets.Osu/Difficulty/Skills/Aim.cs index b5e57985e9..e74f4933b2 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Skills/Aim.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Skills/Aim.cs @@ -2,7 +2,10 @@ // See the LICENCE file in the repository root for full licence text. using System; +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Difficulty.Skills; using osu.Game.Rulesets.Osu.Difficulty.Preprocessing; +using osu.Game.Rulesets.Osu.Objects; namespace osu.Game.Rulesets.Osu.Difficulty.Skills { @@ -17,33 +20,40 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills protected override double SkillMultiplier => 26.25; protected override double StrainDecayBase => 0.15; - protected override double StrainValueOf(OsuDifficultyHitObject current) + protected override double StrainValueOf(DifficultyHitObject current) { + if (current.BaseObject is Spinner) + return 0; + + var osuCurrent = (OsuDifficultyHitObject)current; + double result = 0; - const double scale = 90; - - double applyDiminishingExp(double val) => Math.Pow(val, 0.99); - if (Previous.Count > 0) { - if (current.Angle != null && current.Angle.Value > angle_bonus_begin) + var osuPrevious = (OsuDifficultyHitObject)Previous[0]; + + if (osuCurrent.Angle != null && osuCurrent.Angle.Value > angle_bonus_begin) { + const double scale = 90; + var angleBonus = Math.Sqrt( - Math.Max(Previous[0].JumpDistance - scale, 0) - * Math.Pow(Math.Sin(current.Angle.Value - angle_bonus_begin), 2) - * Math.Max(current.JumpDistance - scale, 0)); - result = 1.5 * applyDiminishingExp(Math.Max(0, angleBonus)) / Math.Max(timing_threshold, Previous[0].StrainTime); + Math.Max(osuPrevious.JumpDistance - scale, 0) + * Math.Pow(Math.Sin(osuCurrent.Angle.Value - angle_bonus_begin), 2) + * Math.Max(osuCurrent.JumpDistance - scale, 0)); + result = 1.5 * applyDiminishingExp(Math.Max(0, angleBonus)) / Math.Max(timing_threshold, osuPrevious.StrainTime); } } - double jumpDistanceExp = applyDiminishingExp(current.JumpDistance); - double travelDistanceExp = applyDiminishingExp(current.TravelDistance); + double jumpDistanceExp = applyDiminishingExp(osuCurrent.JumpDistance); + double travelDistanceExp = applyDiminishingExp(osuCurrent.TravelDistance); return Math.Max( - result + (jumpDistanceExp + travelDistanceExp + Math.Sqrt(travelDistanceExp * jumpDistanceExp)) / Math.Max(current.StrainTime, timing_threshold), - (Math.Sqrt(travelDistanceExp * jumpDistanceExp) + jumpDistanceExp + travelDistanceExp) / current.StrainTime + result + (jumpDistanceExp + travelDistanceExp + Math.Sqrt(travelDistanceExp * jumpDistanceExp)) / Math.Max(osuCurrent.StrainTime, timing_threshold), + (Math.Sqrt(travelDistanceExp * jumpDistanceExp) + jumpDistanceExp + travelDistanceExp) / osuCurrent.StrainTime ); } + + private double applyDiminishingExp(double val) => Math.Pow(val, 0.99); } } diff --git a/osu.Game.Rulesets.Osu/Difficulty/Skills/Speed.cs b/osu.Game.Rulesets.Osu/Difficulty/Skills/Speed.cs index e78691ce53..46a81a9480 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Skills/Speed.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Skills/Speed.cs @@ -2,7 +2,10 @@ // See the LICENCE file in the repository root for full licence text. using System; +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Difficulty.Skills; using osu.Game.Rulesets.Osu.Difficulty.Preprocessing; +using osu.Game.Rulesets.Osu.Objects; namespace osu.Game.Rulesets.Osu.Difficulty.Skills { @@ -11,6 +14,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills /// public class Speed : Skill { + private const double single_spacing_threshold = 125; + private const double angle_bonus_begin = 5 * Math.PI / 6; private const double pi_over_4 = Math.PI / 4; private const double pi_over_2 = Math.PI / 2; @@ -22,9 +27,14 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills private const double max_speed_bonus = 45; // ~330BPM private const double speed_balancing_factor = 40; - protected override double StrainValueOf(OsuDifficultyHitObject current) + protected override double StrainValueOf(DifficultyHitObject current) { - double distance = Math.Min(SINGLE_SPACING_THRESHOLD, current.TravelDistance + current.JumpDistance); + if (current.BaseObject is Spinner) + return 0; + + var osuCurrent = (OsuDifficultyHitObject)current; + + double distance = Math.Min(single_spacing_threshold, osuCurrent.TravelDistance + osuCurrent.JumpDistance); double deltaTime = Math.Max(max_speed_bonus, current.DeltaTime); double speedBonus = 1.0; @@ -32,20 +42,20 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills speedBonus = 1 + Math.Pow((min_speed_bonus - deltaTime) / speed_balancing_factor, 2); double angleBonus = 1.0; - if (current.Angle != null && current.Angle.Value < angle_bonus_begin) + if (osuCurrent.Angle != null && osuCurrent.Angle.Value < angle_bonus_begin) { - angleBonus = 1 + Math.Pow(Math.Sin(1.5 * (angle_bonus_begin - current.Angle.Value)), 2) / 3.57; - if (current.Angle.Value < pi_over_2) + angleBonus = 1 + Math.Pow(Math.Sin(1.5 * (angle_bonus_begin - osuCurrent.Angle.Value)), 2) / 3.57; + if (osuCurrent.Angle.Value < pi_over_2) { angleBonus = 1.28; - if (distance < 90 && current.Angle.Value < pi_over_4) + if (distance < 90 && osuCurrent.Angle.Value < pi_over_4) angleBonus += (1 - angleBonus) * Math.Min((90 - distance) / 10, 1); else if (distance < 90) - angleBonus += (1 - angleBonus) * Math.Min((90 - distance) / 10, 1) * Math.Sin((pi_over_2 - current.Angle.Value) / pi_over_4); + angleBonus += (1 - angleBonus) * Math.Min((90 - distance) / 10, 1) * Math.Sin((pi_over_2 - osuCurrent.Angle.Value) / pi_over_4); } } - return (1 + (speedBonus - 1) * 0.75) * angleBonus * (0.95 + speedBonus * Math.Pow(distance / SINGLE_SPACING_THRESHOLD, 3.5)) / current.StrainTime; + return (1 + (speedBonus - 1) * 0.75) * angleBonus * (0.95 + speedBonus * Math.Pow(distance / single_spacing_threshold, 3.5)) / osuCurrent.StrainTime; } } } diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/Components/HitCirclePiece.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/Components/HitCirclePiece.cs index 5958b32f33..7f6a60c400 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/Components/HitCirclePiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/Components/HitCirclePiece.cs @@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components PositionBindable.BindValueChanged(_ => UpdatePosition(), true); StackHeightBindable.BindValueChanged(_ => UpdatePosition()); - ScaleBindable.BindValueChanged(v => Scale = new Vector2(v), true); + ScaleBindable.BindValueChanged(scale => Scale = new Vector2(scale.NewValue), true); } protected virtual void UpdatePosition() => Position = hitCircle.StackedPosition; diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitObjectPiece.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitObjectPiece.cs index 44e61f30b0..315a5a2b9d 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitObjectPiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitObjectPiece.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Osu.Objects; using osuTK; diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/SliderPiece.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/SliderPiece.cs index dfc8bf4664..8fd1d6d6f9 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/SliderPiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/SliderPiece.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Objects; diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/SliderBodyPiece.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/SliderBodyPiece.cs index cb9b5211d4..179fa1bc72 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/SliderBodyPiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/SliderBodyPiece.cs @@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components body.BorderColour = colours.Yellow; PositionBindable.BindValueChanged(_ => updatePosition(), true); - ScaleBindable.BindValueChanged(v => body.PathWidth = v * 64, true); + ScaleBindable.BindValueChanged(scale => body.PathWidth = scale.NewValue * 64, true); } private void updatePosition() => Position = slider.StackedPosition; diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/SliderCirclePiece.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/SliderCirclePiece.cs index d2fec859b8..9d164ebe0b 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/SliderCirclePiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/SliderCirclePiece.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components; using osu.Game.Rulesets.Osu.Objects; diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Spinners/Components/SpinnerPiece.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Spinners/Components/SpinnerPiece.cs index 7f91bc49eb..ae94848c81 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Spinners/Components/SpinnerPiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Spinners/Components/SpinnerPiece.cs @@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components PositionBindable.BindValueChanged(_ => updatePosition(), true); StackHeightBindable.BindValueChanged(_ => updatePosition()); - ScaleBindable.BindValueChanged(v => ring.Scale = new Vector2(v), true); + ScaleBindable.BindValueChanged(scale => ring.Scale = new Vector2(scale.NewValue), true); } private void updatePosition() => Position = spinner.Position; diff --git a/osu.Game.Rulesets.Osu/Judgements/ComboResult.cs b/osu.Game.Rulesets.Osu/Judgements/ComboResult.cs index d7c76fccbe..ad292b0439 100644 --- a/osu.Game.Rulesets.Osu/Judgements/ComboResult.cs +++ b/osu.Game.Rulesets.Osu/Judgements/ComboResult.cs @@ -9,8 +9,10 @@ namespace osu.Game.Rulesets.Osu.Judgements { [Description(@"")] None, + [Description(@"Good")] Good, + [Description(@"Amazing")] Perfect } diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs b/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs index 19b627b560..a203e23687 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs @@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Osu.Mods public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor) { - scoreProcessor.Health.ValueChanged += val => { blinds.AnimateClosedness((float)val); }; + scoreProcessor.Health.ValueChanged += health => { blinds.AnimateClosedness((float)health.NewValue); }; } /// diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs b/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs index ba82465a78..2c40d18f1b 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Input; using osu.Framework.Input.Events; @@ -41,9 +42,9 @@ namespace osu.Game.Rulesets.Osu.Mods return default_flashlight_size; } - protected override void OnComboChange(int newCombo) + protected override void OnComboChange(ValueChangedEvent e) { - this.TransformTo(nameof(FlashlightSize), new Vector2(0, getSizeFor(newCombo)), FLASHLIGHT_FADE_DURATION); + this.TransformTo(nameof(FlashlightSize), new Vector2(0, getSizeFor(e.NewValue)), FLASHLIGHT_FADE_DURATION); } protected override string FragmentShader => "CircularFlashlight"; diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs b/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs new file mode 100644 index 0000000000..65e9eb7a1d --- /dev/null +++ b/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs @@ -0,0 +1,74 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using osu.Framework.Graphics; +using osu.Game.Graphics; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Rulesets.Osu.Objects.Drawables; + +namespace osu.Game.Rulesets.Osu.Mods +{ + internal class OsuModGrow : Mod, IApplicableToDrawableHitObjects + { + public override string Name => "Grow"; + + public override string Acronym => "GR"; + + public override FontAwesome Icon => FontAwesome.fa_arrows_v; + + public override ModType Type => ModType.Fun; + + public override string Description => "Hit them at the right size!"; + + public override double ScoreMultiplier => 1; + + public void ApplyToDrawableHitObjects(IEnumerable drawables) + { + foreach (var drawable in drawables) + { + switch (drawable) + { + case DrawableSpinner _: + continue; + default: + drawable.ApplyCustomUpdateState += ApplyCustomState; + break; + } + } + } + + protected virtual void ApplyCustomState(DrawableHitObject drawable, ArmedState state) + { + var h = (OsuHitObject)drawable.HitObject; + + // apply grow effect + switch (drawable) + { + case DrawableSliderHead _: + case DrawableSliderTail _: + // special cases we should *not* be scaling. + break; + case DrawableSlider _: + case DrawableHitCircle _: + { + using (drawable.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true)) + drawable.ScaleTo(0.5f).Then().ScaleTo(1, h.TimePreempt, Easing.OutSine); + break; + } + } + + // remove approach circles + switch (drawable) + { + case DrawableHitCircle circle: + // we don't want to see the approach circle + using (circle.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true)) + circle.ApproachCircle.Hide(); + break; + } + } + } +} diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs b/osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs index 959bf1dc77..9a769ec39c 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs @@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Osu.Mods { foreach (var drawable in drawables) { - var hitObject = (OsuHitObject) drawable.HitObject; + var hitObject = (OsuHitObject)drawable.HitObject; float appearDistance = (float)(hitObject.TimePreempt - hitObject.TimeFadeIn) / 2; @@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Osu.Mods .MoveTo(originalPosition, moveDuration, Easing.InOutSine); } - theta += (float) hitObject.TimeFadeIn / 1000; + theta += (float)hitObject.TimeFadeIn / 1000; } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs index 0e88e1094e..9106f4c7bd 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs @@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections /// /// Connects hit objects visually, for example with follow points. /// - public abstract class ConnectionRenderer : Container + public abstract class ConnectionRenderer : LifetimeManagementContainer where T : HitObject { /// diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs index 4c0f646ad5..8f9d487d49 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs @@ -12,39 +12,44 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections public class FollowPointRenderer : ConnectionRenderer { private int pointDistance = 32; + /// /// Determines how much space there is between points. /// public int PointDistance { - get { return pointDistance; } + get => pointDistance; set { if (pointDistance == value) return; + pointDistance = value; update(); } } private int preEmpt = 800; + /// /// Follow points to the next hitobject start appearing for this many milliseconds before an hitobject's end time. /// public int PreEmpt { - get { return preEmpt; } + get => preEmpt; set { if (preEmpt == value) return; + preEmpt = value; update(); } } private IEnumerable hitObjects; + public override IEnumerable HitObjects { - get { return hitObjects; } + get => hitObjects; set { hitObjects = value; @@ -56,7 +61,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections private void update() { - Clear(); + ClearInternal(); if (hitObjects == null) return; @@ -86,7 +91,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections FollowPoint fp; - Add(fp = new FollowPoint + AddInternal(fp = new FollowPoint { Position = pointStartPosition, Rotation = rotation, @@ -107,6 +112,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections fp.Expire(true); } } + prevHitObject = currHitObject; } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index df0769982d..decd0ce073 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -3,8 +3,9 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using osuTK; @@ -27,40 +28,60 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private readonly IBindable stackHeightBindable = new Bindable(); private readonly IBindable scaleBindable = new Bindable(); + public OsuAction? HitAction => circle.HitAction; + + private readonly Container explodeContainer; + + private readonly Container scaleContainer; + public DrawableHitCircle(HitCircle h) : base(h) { Origin = Anchor.Centre; Position = HitObject.StackedPosition; - Scale = new Vector2(h.Scale); InternalChildren = new Drawable[] { - glow = new GlowPiece(), - circle = new CirclePiece + scaleContainer = new Container { - Hit = () => + RelativeSizeAxes = Axes.Both, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Child = explodeContainer = new Container { - if (AllJudged) - return false; + RelativeSizeAxes = Axes.Both, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Children = new Drawable[] + { + glow = new GlowPiece(), + circle = new CirclePiece + { + Hit = () => + { + if (AllJudged) + return false; - UpdateResult(true); - return true; - }, + UpdateResult(true); + return true; + }, + }, + number = new NumberPiece + { + Text = (HitObject.IndexInCurrentCombo + 1).ToString(), + }, + ring = new RingPiece(), + flash = new FlashPiece(), + explode = new ExplodePiece(), + ApproachCircle = new ApproachCircle + { + Alpha = 0, + Scale = new Vector2(4), + } + } + } }, - number = new NumberPiece - { - Text = (HitObject.IndexInCurrentCombo + 1).ToString(), - }, - ring = new RingPiece(), - flash = new FlashPiece(), - explode = new ExplodePiece(), - ApproachCircle = new ApproachCircle - { - Alpha = 0, - Scale = new Vector2(4), - } }; //may not be so correct @@ -72,7 +93,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { positionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition); stackHeightBindable.BindValueChanged(_ => Position = HitObject.StackedPosition); - scaleBindable.BindValueChanged(v => Scale = new Vector2(v)); + scaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue), true); positionBindable.BindTo(HitObject.PositionBindable); stackHeightBindable.BindTo(HitObject.StackHeightBindable); @@ -81,7 +102,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public override Color4 AccentColour { - get { return base.AccentColour; } + get => base.AccentColour; set { base.AccentColour = value; @@ -118,6 +139,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables ApproachCircle.FadeIn(Math.Min(HitObject.TimeFadeIn * 2, HitObject.TimePreempt)); ApproachCircle.ScaleTo(1.1f, HitObject.TimePreempt); + ApproachCircle.Expire(true); } protected override void UpdateCurrentState(ArmedState state) @@ -131,6 +153,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables Expire(true); + circle.HitAction = null; + // override lifetime end as FadeIn may have been changed externally, causing out expiration to be too early. LifetimeEnd = HitObject.StartTime + HitObject.HitWindows.HalfWindowFor(HitResult.Miss); break; @@ -156,8 +180,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables circle.FadeOut(); number.FadeOut(); - this.FadeOut(800) - .ScaleTo(Scale * 1.5f, 400, Easing.OutQuad); + this.FadeOut(800); + explodeContainer.ScaleTo(1.5f, 400, Easing.OutQuad); } Expire(); diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs index ca9a27976e..6595e53a6a 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs @@ -8,7 +8,7 @@ using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; using osu.Game.Configuration; using osu.Game.Rulesets.Objects; @@ -53,6 +53,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables repeatPoints = new Container { RelativeSizeAxes = Axes.Both }, Ball = new SliderBall(s, this) { + GetInitialHitAction = () => HeadCircle.HitAction, BypassAutoSizeAxes = Axes.Both, Scale = new Vector2(s.Scale), AlwaysPresent = true, @@ -99,10 +100,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables config.BindWith(OsuSetting.SnakingOutSliders, Body.SnakingOut); positionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition); - scaleBindable.BindValueChanged(v => + scaleBindable.BindValueChanged(scale => { - Body.PathWidth = HitObject.Scale * 64; - Ball.Scale = new Vector2(HitObject.Scale); + Body.PathWidth = scale.NewValue * 64; + Ball.Scale = new Vector2(scale.NewValue); }); positionBindable.BindTo(HitObject.PositionBindable); @@ -114,7 +115,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public override Color4 AccentColour { - get { return base.AccentColour; } + get => base.AccentColour; set { base.AccentColour = value; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs index e24efc6ffb..66b6f0f9ac 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs @@ -3,7 +3,7 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; using osuTK; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs index 53f6aa5b76..23c5494cf5 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Scoring; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs index 1105e8525b..b5ce36f889 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -20,7 +20,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public override bool DisplayResult => false; - public DrawableSliderTick(SliderTick sliderTick) : base(sliderTick) + public DrawableSliderTick(SliderTick sliderTick) + : base(sliderTick) { Size = new Vector2(16) * sliderTick.Scale; Origin = Anchor.Centre; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs index c411b562e4..789af4f49b 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs @@ -11,7 +11,7 @@ using osuTK.Graphics; using osu.Game.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Screens.Ranking; using osu.Game.Rulesets.Scoring; @@ -42,7 +42,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private Color4 normalColour; private Color4 completeColour; - public DrawableSpinner(Spinner s) : base(s) + public DrawableSpinner(Spinner s) + : base(s) { Origin = Anchor.Centre; Position = s.Position; @@ -130,7 +131,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables circle.Colour = colours.BlueDark; glow.Colour = colours.BlueDark; - positionBindable.BindValueChanged(v => Position = v); + positionBindable.BindValueChanged(pos => Position = pos.NewValue); positionBindable.BindTo(HitObject.PositionBindable); } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ApproachCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ApproachCircle.cs index 8ed99ca660..8ee065aaea 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ApproachCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ApproachCircle.cs @@ -12,6 +12,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { public class ApproachCircle : Container { + public override bool RemoveWhenNotAlive => false; + public ApproachCircle() { Anchor = Anchor.Centre; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs index b7e2748ca9..786cac7198 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs @@ -17,6 +17,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces public Func Hit; + public OsuAction? HitAction; + public CirclePiece() { Size = new Vector2((float)OsuHitObject.OBJECT_RADIUS * 2); @@ -35,7 +37,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { case OsuAction.LeftButton: case OsuAction.RightButton: - return IsHovered && (Hit?.Invoke() ?? false); + if (IsHovered && (Hit?.Invoke() ?? false)) + { + HitAction = action; + return true; + } + + break; } return false; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/NumberPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/NumberPiece.cs index bc354bc2b6..93ac8748dd 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/NumberPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/NumberPiece.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Sprites; using osuTK.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; using osu.Game.Skinning; namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces @@ -17,8 +18,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces public string Text { - get { return number.Text; } - set { number.Text = value; } + get => number.Text; + set => number.Text = value; } public NumberPiece() @@ -42,9 +43,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces }, s => s.GetTexture("Play/osu/hitcircle") == null), number = new SkinnableSpriteText("Play/osu/number-text", _ => new OsuSpriteText { - Font = @"Venera", + Font = OsuFont.Numeric.With(size: 40), UseFullGlyphHeight = false, - TextSize = 40, }, restrictSize: false) { Text = @"1" diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBall.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBall.cs index db9fee242a..1b2e2c1f47 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBall.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBall.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -19,12 +20,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces private Color4 accentColour = Color4.Black; + public Func GetInitialHitAction; + /// /// The colour that is used for the slider ball. /// public Color4 AccentColour { - get { return accentColour; } + get => accentColour; set { accentColour = value; @@ -133,11 +136,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces public bool Tracking { - get { return tracking; } + get => tracking; private set { if (value == tracking) return; + tracking = value; FollowCircle.ScaleTo(tracking ? 2f : 1, 300, Easing.OutQuint); @@ -145,20 +149,72 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces } } - private bool canCurrentlyTrack => Time.Current >= slider.StartTime && Time.Current < slider.EndTime; + /// + /// If the cursor moves out of the ball's radius we still need to be able to receive positional updates to stop tracking. + /// + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; + + /// + /// The point in time after which we can accept any key for tracking. Before this time, we may need to restrict tracking to the key used to hit the head circle. + /// + /// This is a requirement to stop the case where a player holds down one key (from before the slider) and taps the second key while maintaining full scoring (tracking) of sliders. + /// Visually, this special case can be seen below (time increasing from left to right): + /// + /// Z Z+X Z + /// o========o + /// + /// Without this logic, tracking would continue through the entire slider even though no key hold action is directly attributing to it. + /// + /// In all other cases, no special handling is required (either key being pressed is allowable as valid tracking). + /// + /// The reason for storing this as a time value (rather than a bool) is to correctly handle rewind scenarios. + /// + private double? timeToAcceptAnyKeyAfter; protected override void Update() { base.Update(); - if (Time.Current < slider.EndTime) + // from the point at which the head circle is hit, this will be non-null. + // it may be null if the head circle was missed. + var headCircleHitAction = GetInitialHitAction(); + + if (headCircleHitAction == null) + timeToAcceptAnyKeyAfter = null; + + var actions = drawableSlider?.OsuActionInputManager?.PressedActions; + + // if the head circle was hit with a specific key, tracking should only occur while that key is pressed. + if (headCircleHitAction != null && timeToAcceptAnyKeyAfter == null) { - // Make sure to use the base version of ReceivePositionalInputAt so that we correctly check the position. - Tracking = canCurrentlyTrack - && lastScreenSpaceMousePosition.HasValue - && ReceivePositionalInputAt(lastScreenSpaceMousePosition.Value) - && (drawableSlider?.OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false); + var otherKey = headCircleHitAction == OsuAction.RightButton ? OsuAction.LeftButton : OsuAction.RightButton; + + // we can return to accepting all keys if the initial head circle key is the *only* key pressed, or all keys have been released. + if (actions?.Contains(otherKey) != true) + timeToAcceptAnyKeyAfter = Time.Current; } + + Tracking = + // in valid time range + Time.Current >= slider.StartTime && Time.Current < slider.EndTime && + // in valid position range + lastScreenSpaceMousePosition.HasValue && base.ReceivePositionalInputAt(lastScreenSpaceMousePosition.Value) && + // valid action + (actions?.Any(isValidTrackingAction) ?? false); + } + + /// + /// Check whether a given user input is a valid tracking action. + /// + private bool isValidTrackingAction(OsuAction action) + { + bool headCircleHit = GetInitialHitAction().HasValue; + + // if the head circle was hit, we may not yet be allowed to accept any key, so we must use the initial hit action. + if (headCircleHit && (!timeToAcceptAnyKeyAfter.HasValue || Time.Current <= timeToAcceptAnyKeyAfter.Value)) + return action == GetInitialHitAction(); + + return action == OsuAction.LeftButton || action == OsuAction.RightButton; } public void UpdateProgress(double completionProgress) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs index 6d2dc220da..b088f1914b 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs @@ -40,6 +40,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { if (path.AccentColour == value) return; + path.AccentColour = value; container.ForceRedraw(); @@ -56,6 +57,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { if (path.BorderColour == value) return; + path.BorderColour = value; container.ForceRedraw(); @@ -105,6 +107,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { if (borderColour == value) return; + borderColour = value; InvalidateTexture(); @@ -120,6 +123,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { if (accentColour == value) return; + accentColour = value; InvalidateTexture(); diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SnakingSliderBody.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SnakingSliderBody.cs index 256cd088de..73b184bffe 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SnakingSliderBody.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SnakingSliderBody.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Rulesets.Objects.Types; using osuTK; @@ -54,18 +54,18 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces var spanProgress = slider.ProgressAt(completionProgress); double start = 0; - double end = SnakingIn ? MathHelper.Clamp((Time.Current - (slider.StartTime - slider.TimePreempt)) / slider.TimeFadeIn, 0, 1) : 1; + double end = SnakingIn.Value ? MathHelper.Clamp((Time.Current - (slider.StartTime - slider.TimePreempt)) / slider.TimeFadeIn, 0, 1) : 1; if (span >= slider.SpanCount() - 1) { if (Math.Min(span, slider.SpanCount() - 1) % 2 == 1) { start = 0; - end = SnakingOut ? spanProgress : 1; + end = SnakingOut.Value ? spanProgress : 1; } else { - start = SnakingOut ? spanProgress : 0; + start = SnakingOut.Value ? spanProgress : 0; } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerBackground.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerBackground.cs index 0d970f4c2c..c982f53c2b 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerBackground.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerBackground.cs @@ -15,10 +15,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces public Color4 AccentColour { - get - { - return Disc.Colour; - } + get => Disc.Colour; set { Disc.Colour = value; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs index 4206852b6c..448a2eada7 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs @@ -17,8 +17,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces public Color4 AccentColour { - get { return background.AccentColour; } - set { background.AccentColour = value; } + get => background.AccentColour; + set => background.AccentColour = value; } private readonly SpinnerBackground background; @@ -43,12 +43,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; private bool tracking; + public bool Tracking { - get { return tracking; } + get => tracking; set { if (value == tracking) return; + tracking = value; background.FadeTo(tracking ? tracking_alpha : idle_alpha, 100); @@ -56,12 +58,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces } private bool complete; + public bool Complete { - get { return complete; } + get => complete; set { if (value == complete) return; + complete = value; updateCompleteTick(); diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerSpmCounter.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerSpmCounter.cs index e4d09b9306..b1d90c49f6 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerSpmCounter.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerSpmCounter.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces @@ -23,16 +24,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = @"0", - Font = @"Venera", - TextSize = 24 + Font = OsuFont.Numeric.With(size: 24) }, new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = @"SPINS PER MINUTE", - Font = @"Venera", - TextSize = 12, + Font = OsuFont.Numeric.With(size: 12), Y = 30 } }; @@ -42,10 +41,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces public double SpinsPerMinute { - get { return spm; } + get => spm; private set { if (value == spm) return; + spm = value; spmText.Text = Math.Truncate(value).ToString(@"#0"); } diff --git a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs index a2e518ace4..364c182dd4 100644 --- a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Beatmaps; using osu.Game.Rulesets.Objects; using osuTK; @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Objects public virtual Vector2 Position { - get => PositionBindable; + get => PositionBindable.Value; set => PositionBindable.Value = value; } @@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Osu.Objects public int StackHeight { - get => StackHeightBindable; + get => StackHeightBindable.Value; set => StackHeightBindable.Value = value; } @@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Osu.Objects public float Scale { - get => ScaleBindable; + get => ScaleBindable.Value; set => ScaleBindable.Value = value; } diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs index d47fed354a..345f599b9d 100644 --- a/osu.Game.Rulesets.Osu/Objects/Slider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs @@ -7,8 +7,8 @@ using osu.Game.Rulesets.Objects.Types; using System.Collections.Generic; using osu.Game.Rulesets.Objects; using System.Linq; +using osu.Framework.Bindables; using osu.Framework.Caching; -using osu.Framework.Configuration; using osu.Game.Audio; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; @@ -262,6 +262,7 @@ namespace osu.Game.Rulesets.Osu.Objects { if (nodeIndex < NodeSamples.Count) return NodeSamples[nodeIndex]; + return Samples; } diff --git a/osu.Game.Rulesets.Osu/Objects/SliderTailCircle.cs b/osu.Game.Rulesets.Osu/Objects/SliderTailCircle.cs index 29b00b8d5d..43a2ae0fbb 100644 --- a/osu.Game.Rulesets.Osu/Objects/SliderTailCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/SliderTailCircle.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Judgements; diff --git a/osu.Game.Rulesets.Osu/OsuInputManager.cs b/osu.Game.Rulesets.Osu/OsuInputManager.cs index 2dd34d7d40..b9e083d35b 100644 --- a/osu.Game.Rulesets.Osu/OsuInputManager.cs +++ b/osu.Game.Rulesets.Osu/OsuInputManager.cs @@ -38,6 +38,7 @@ namespace osu.Game.Rulesets.Osu protected override bool Handle(UIEvent e) { if (!AllowUserPresses) return false; + return base.Handle(e); } } diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs index 12d0a28a8f..5ae7344996 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -121,9 +121,11 @@ namespace osu.Game.Rulesets.Osu new OsuModAutopilot(), }; case ModType.Fun: - return new Mod[] { + return new Mod[] + { new OsuModTransform(), new OsuModWiggle(), + new OsuModGrow() }; default: return new Mod[] { }; diff --git a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs index b024ff4b05..b0fb85d7ed 100644 --- a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs +++ b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs @@ -209,7 +209,7 @@ namespace osu.Game.Rulesets.Osu.Replays // Only "snap" to hitcircles if they are far enough apart. As the time between hitcircles gets shorter the snapping threshold goes up. if (timeDifference > 0 && // Sanity checks ((lastPosition - targetPos).Length > h.Radius * (1.5 + 100.0 / timeDifference) || // Either the distance is big enough - timeDifference >= 266)) // ... or the beats are slow enough to tap anyway. + timeDifference >= 266)) // ... or the beats are slow enough to tap anyway. { // Perform eased movement for (double time = lastFrame.Time + FrameDelay; time < h.StartTime; time += FrameDelay) diff --git a/osu.Game.Rulesets.Osu/Replays/OsuAutoGeneratorBase.cs b/osu.Game.Rulesets.Osu/Replays/OsuAutoGeneratorBase.cs index 8bcdb5ee41..9a60f0cafc 100644 --- a/osu.Game.Rulesets.Osu/Replays/OsuAutoGeneratorBase.cs +++ b/osu.Game.Rulesets.Osu/Replays/OsuAutoGeneratorBase.cs @@ -20,6 +20,7 @@ namespace osu.Game.Rulesets.Osu.Replays /// Constants (for spinners). /// protected static readonly Vector2 SPINNER_CENTRE = OsuPlayfield.BASE_SIZE / 2; + protected const float SPIN_RADIUS = 50; /// @@ -46,6 +47,7 @@ namespace osu.Game.Rulesets.Osu.Replays #endregion #region Utilities + protected double ApplyModsToTime(double v) => v; protected double ApplyModsToRate(double v) => v; diff --git a/osu.Game.Rulesets.Osu/Replays/OsuReplayInputHandler.cs b/osu.Game.Rulesets.Osu/Replays/OsuFramedReplayInputHandler.cs similarity index 89% rename from osu.Game.Rulesets.Osu/Replays/OsuReplayInputHandler.cs rename to osu.Game.Rulesets.Osu/Replays/OsuFramedReplayInputHandler.cs index 0e9a906d85..d1ac77857d 100644 --- a/osu.Game.Rulesets.Osu/Replays/OsuReplayInputHandler.cs +++ b/osu.Game.Rulesets.Osu/Replays/OsuFramedReplayInputHandler.cs @@ -11,9 +11,9 @@ using osuTK; namespace osu.Game.Rulesets.Osu.Replays { - public class OsuReplayInputHandler : FramedReplayInputHandler + public class OsuFramedReplayInputHandler : FramedReplayInputHandler { - public OsuReplayInputHandler(Replay replay) + public OsuFramedReplayInputHandler(Replay replay) : base(replay) { } diff --git a/osu.Game.Rulesets.Osu/Resources/Testing/Beatmaps/diffcalc-test.osu b/osu.Game.Rulesets.Osu/Resources/Testing/Beatmaps/diffcalc-test.osu new file mode 100644 index 0000000000..bf345811a2 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Resources/Testing/Beatmaps/diffcalc-test.osu @@ -0,0 +1,179 @@ +osu file format v14 + +[General] +StackLeniency: 0.3 +Mode: 0 + +[Difficulty] +CircleSize:4 +OverallDifficulty:7 +ApproachRate:8.3 +SliderMultiplier:1.6 +SliderTickRate:1 + +[TimingPoints] +500,500,4,2,1,50,1,0 +62500,-500,4,2,1,50,0,0 +71000,-100,4,2,1,50,0,0 + +[HitObjects] +// Circles spaced 1 beat apart, with increasing jump distance +126,112,500,5,0,0:0:0:0: +130,155,1000,1,0,0:0:0:0: +131,269,1500,1,0,0:0:0:0: +341,269,2000,1,0,0:0:0:0: +113,95,2500,1,0,0:0:0:0: + +// Circles spaced 1/2 beat apart, with increasing jump distance +108,104,3500,5,0,0:0:0:0: +110,145,3750,1,0,0:0:0:0: +115,262,4000,1,0,0:0:0:0: +285,265,4250,1,0,0:0:0:0: +458,48,4500,1,0,0:0:0:0: +35,199,4750,1,0,0:0:0:0: +251,340,5000,1,0,0:0:0:0: +20,352,5250,1,0,0:0:0:0: +426,62,5500,1,0,0:0:0:0: + +// Circles spaced 1/4 beat apart, with increasing jump distances +211,138,6500,5,0,0:0:0:0: +99,256,6625,1,0,0:0:0:0: +68,129,6750,1,0,0:0:0:0: +371,340,6875,1,0,0:0:0:0: +241,219,7000,1,0,0:0:0:0: +252,148,7125,1,0,0:0:0:0: +434,97,7250,1,0,0:0:0:0: +40,38,7375,1,0,0:0:0:0: +114,334,7500,1,0,0:0:0:0: +301,19,7625,1,0,0:0:0:0: +441,241,7750,1,0,0:0:0:0: +121,91,7875,1,0,0:0:0:0: +270,384,8000,1,0,0:0:0:0: +488,92,8125,1,0,0:0:0:0: +332,82,8250,1,0,0:0:0:0: +108,240,8375,1,0,0:0:0:0: +281,268,8500,1,0,0:0:0:0: + +// Constant spaced circles spaced 1/2 beat apart, small jump distances, changing angles +252,191,9500,5,0,0:0:0:0: +356,191,9750,1,0,0:0:0:0: +311,268,10000,1,0,0:0:0:0: +190,270,10250,1,0,0:0:0:0: +107,199,10500,1,0,0:0:0:0: +172,105,10750,1,0,0:0:0:0: +297,102,11000,1,0,0:0:0:0: +373,178,11250,1,0,0:0:0:0: +252,195,11500,1,0,0:0:0:0: + +// Constant spaced circles spaced 1/2 beat apart, large jump distances, changing angles +140,187,12500,5,0,0:0:0:0: +451,331,12750,1,0,0:0:0:0: +46,338,13000,1,0,0:0:0:0: +204,50,13250,1,0,0:0:0:0: +464,162,13500,1,0,0:0:0:0: +252,346,13750,1,0,0:0:0:0: +13,175,14000,1,0,0:0:0:0: +488,181,14250,1,0,0:0:0:0: +251,187,14500,1,0,0:0:0:0: + +// Constant spaced circles spaced 1/4 beat apart, small jump distances, changing angles +188,192,15500,5,0,0:0:0:0: +298,194,15625,1,0,0:0:0:0: +317,84,15750,1,0,0:0:0:0: +185,85,15875,1,0,0:0:0:0: +77,200,16000,1,0,0:0:0:0: +184,303,16125,1,0,0:0:0:0: +295,225,16250,1,0,0:0:0:0: +300,84,16375,1,0,0:0:0:0: +144,82,16500,1,0,0:0:0:0: +141,215,16625,1,0,0:0:0:0: +314,184,16750,1,0,0:0:0:0: +188,192,16875,1,0,0:0:0:0: +188,192,17000,1,0,0:0:0:0: + +// Constant spaced circles spaced 1/4 beat apart, large jump distances, changing angles +97,192,18000,5,0,0:0:0:0: +336,38,18125,1,0,0:0:0:0: +440,322,18250,1,0,0:0:0:0: +39,331,18375,1,0,0:0:0:0: +98,39,18500,1,0,0:0:0:0: +460,179,18625,1,0,0:0:0:0: +245,338,18750,1,0,0:0:0:0: +12,184,18875,1,0,0:0:0:0: +250,41,19000,1,0,0:0:0:0: +265,193,19125,1,0,0:0:0:0: +486,22,19250,1,0,0:0:0:0: +411,205,19375,1,0,0:0:0:0: +107,198,19500,1,0,0:0:0:0: + +// Short sliders spaced 1 beat apart +28,108,20500,2,0,L|196:107,1,160 +25,177,21500,2,0,L|193:176,1,160 +26,308,22500,2,0,L|194:307,1,160 +320,89,23500,2,0,L|488:88,1,160 + +// Short sliders spaced 1/2 beat apart +28,108,25000,6,0,L|196:107,1,160 +27,173,25750,2,0,L|195:172,1,160 +25,292,26500,2,0,L|193:291,1,160 +340,213,27250,2,0,L|508:212,1,160 +21,44,28000,2,0,L|189:43,1,160 + +// Short sliders spaced 1/4 beat apart +28,108,29500,6,0,L|196:107,1,160 +30,169,30125,2,0,L|198:168,1,160 +35,282,30750,2,0,L|203:281,1,160 +327,286,31375,2,0,L|495:285,1,160 +51,61,32000,2,0,L|219:60,1,160 + +// Large, medium-paced slider shapes +// PerfectCurve +66,86,33500,6,0,P|246:348|427:44,1,800 +66,86,36500,2,0,P|246:348|427:44,1,800 +66,86,39500,2,0,P|246:348|427:44,1,800 +// Linear +66,72,42500,2,0,B|419:65|419:65|66:316|66:316|426:318,1,1120 +66,72,46500,2,0,B|419:65|419:65|66:316|66:316|426:318,1,1120 +66,72,50500,2,0,B|419:65|419:65|66:316|66:316|426:318,1,1120 +// Bezier +76,287,54500,2,0,B|440:325|138:128|470:302|500:30|130:85|66:82,1,640 +76,287,57000,2,0,B|440:325|138:128|470:302|500:30|130:85|66:82,1,640 +76,287,59500,2,0,B|440:325|138:128|470:302|500:30|130:85|66:82,1,640 + +// Large slow slider with many ticks +81,170,62500,6,0,P|263:78|168:268,1,480 + +// Fast slider with many repeats +102,152,71000,6,0,L|175:153,18,64 + +// Slider-circle combos, spaced 1/2 beat apart +106,204,75500,6,0,P|275:33|171:304,1,800 +255,179,78250,1,0,0:0:0:0: +106,204,78500,2,0,P|275:33|171:304,1,800 +255,179,81250,1,0,0:0:0:0: +106,204,81500,2,0,P|275:33|171:304,1,800 + +// Circle-spinner combos, spaced 1/2 beat apart +82,69,85000,5,0,0:0:0:0: +256,192,85250,8,0,86000,0:0:0:0: +384,189,86250,5,0,0:0:0:0: +256,192,86500,12,0,87000,0:0:0:0: + +// Spinner-spinner combos, spaced 1/2 beat apart +256,192,88000,12,0,89000,0:0:0:0: +256,192,89250,12,0,90250,0:0:0:0: +256,192,90500,12,0,91500,0:0:0:0: +256,192,91750,12,0,92750,0:0:0:0: +256,192,93000,12,0,94000,0:0:0:0: + +// Slider-spinner combos, spaced 1/2 beat apart +49,89,95000,6,0,L|214:87,1,160 +256,192,95625,12,0,96500,0:0:0:0: +12,299,96625,6,0,L|177:297,1,160 +256,192,97250,12,0,98125,0:0:0:0: +295,107,98250,6,0,L|460:105,1,160 +256,192,98875,12,0,99750,0:0:0:0: +279,325,99875,6,0,L|444:323,1,160 +256,192,100500,12,0,101375,0:0:0:0: +197,197,101500,6,0,L|362:195,1,160 +256,192,102125,12,0,103000,0:0:0:0: diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs index 03030121d3..0f8a0ce1ae 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs @@ -255,10 +255,13 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor { [VertexMember(2, VertexAttribPointerType.Float)] public Vector2 Position; + [VertexMember(4, VertexAttribPointerType.Float)] public Color4 Colour; + [VertexMember(2, VertexAttribPointerType.Float)] public Vector2 TexturePosition; + [VertexMember(1, VertexAttribPointerType.Float)] public float Time; diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs index 3167e93923..ef126cdf7d 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -183,13 +183,13 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor }; this.beatmap.BindTo(beatmap); - this.beatmap.ValueChanged += v => calculateScale(); + this.beatmap.ValueChanged += _ => calculateScale(); cursorScale = config.GetBindable(OsuSetting.GameplayCursorSize); - cursorScale.ValueChanged += v => calculateScale(); + cursorScale.ValueChanged += _ => calculateScale(); autoCursorScale = config.GetBindable(OsuSetting.AutoCursorSize); - autoCursorScale.ValueChanged += v => calculateScale(); + autoCursorScale.ValueChanged += _ => calculateScale(); calculateScale(); } @@ -198,7 +198,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor { float scale = (float)cursorScale.Value; - if (autoCursorScale && beatmap.Value != null) + if (autoCursorScale.Value && beatmap.Value != null) { // if we have a beatmap available, let's get its circle size to figure out an automatic cursor scale modifier. scale *= (float)(1 - 0.7 * (1 + beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY); @@ -213,6 +213,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor public void Expand() { if (!cursorExpand) return; + expandTarget.ScaleTo(released_scale).ScaleTo(pressed_scale, 100, Easing.OutQuad); } diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index c4097ccb46..2db2b45540 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Osu.UI { public class OsuPlayfield : Playfield { - private readonly Container approachCircles; + private readonly ApproachCircleProxyContainer approachCircles; private readonly JudgementContainer judgementLayer; private readonly ConnectionRenderer connectionLayer; @@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Osu.UI Depth = 1, }, HitObjectContainer, - approachCircles = new Container + approachCircles = new ApproachCircleProxyContainer { RelativeSizeAxes = Axes.Both, Depth = -1, @@ -58,13 +58,26 @@ namespace osu.Game.Rulesets.Osu.UI { h.OnNewResult += onNewResult; - var c = h as IDrawableHitObjectWithProxiedApproach; - if (c != null) - approachCircles.Add(c.ProxiedLayer.CreateProxy()); + if (h is IDrawableHitObjectWithProxiedApproach c) + { + var original = c.ProxiedLayer; + + // Hitobjects only have lifetimes set on LoadComplete. For nested hitobjects (e.g. SliderHeads), this only happens when the parenting slider becomes visible. + // This delegation is required to make sure that the approach circles for those not-yet-loaded objects aren't added prematurely. + original.OnLoadComplete += addApproachCircleProxy; + } base.Add(h); } + private void addApproachCircleProxy(Drawable d) + { + var proxy = d.CreateProxy(); + proxy.LifetimeStart = d.LifetimeStart; + proxy.LifetimeEnd = d.LifetimeEnd; + approachCircles.Add(proxy); + } + public override void PostProcess() { connectionLayer.HitObjects = HitObjectContainer.Objects.Select(d => d.HitObject).OfType(); @@ -72,7 +85,7 @@ namespace osu.Game.Rulesets.Osu.UI private void onNewResult(DrawableHitObject judgedObject, JudgementResult result) { - if (!judgedObject.DisplayResult || !DisplayJudgements) + if (!judgedObject.DisplayResult || !DisplayJudgements.Value) return; DrawableOsuJudgement explosion = new DrawableOsuJudgement(result, judgedObject) @@ -86,5 +99,10 @@ namespace osu.Game.Rulesets.Osu.UI } public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => HitObjectContainer.ReceivePositionalInputAt(screenSpacePos); + + private class ApproachCircleProxyContainer : LifetimeManagementContainer + { + public void Add(Drawable approachCircleProxy) => AddInternal(approachCircleProxy); + } } } diff --git a/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs b/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs index 86e5f8467d..935f9c5c0d 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs @@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Osu.UI return null; } - protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new OsuReplayInputHandler(replay); + protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new OsuFramedReplayInputHandler(replay); public override double GameplayStartTime { diff --git a/osu.Game.Rulesets.Taiko.Tests/TaikoDifficultyCalculatorTest.cs b/osu.Game.Rulesets.Taiko.Tests/TaikoDifficultyCalculatorTest.cs new file mode 100644 index 0000000000..e7b6d8615b --- /dev/null +++ b/osu.Game.Rulesets.Taiko.Tests/TaikoDifficultyCalculatorTest.cs @@ -0,0 +1,25 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Difficulty; +using osu.Game.Rulesets.Taiko.Difficulty; +using osu.Game.Tests.Beatmaps; + +namespace osu.Game.Rulesets.Taiko.Tests +{ + public class TaikoDifficultyCalculatorTest : DifficultyCalculatorTest + { + protected override string ResourceAssembly => "osu.Game.Rulesets.Taiko"; + + [TestCase(2.9811338051242915d, "diffcalc-test")] + [TestCase(2.9811338051242915d, "diffcalc-test-strong")] + public void Test(double expected, string name) + => base.Test(expected, name); + + protected override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new TaikoDifficultyCalculator(new TaikoRuleset(), beatmap); + + protected override Ruleset CreateRuleset() => new TaikoRuleset(); + } +} diff --git a/osu.Game.Rulesets.Taiko.Tests/TestCaseTaikoPlayfield.cs b/osu.Game.Rulesets.Taiko.Tests/TestCaseTaikoPlayfield.cs index 2c02649102..00e1b649d9 100644 --- a/osu.Game.Rulesets.Taiko.Tests/TestCaseTaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko.Tests/TestCaseTaikoPlayfield.cs @@ -78,7 +78,7 @@ namespace osu.Game.Rulesets.Taiko.Tests Ruleset = new TaikoRuleset().RulesetInfo }, ControlPointInfo = controlPointInfo - }); + }, Clock); Add(playfieldContainer = new Container { diff --git a/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/TaikoDifficultyHitObject.cs b/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/TaikoDifficultyHitObject.cs new file mode 100644 index 0000000000..24345275c1 --- /dev/null +++ b/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/TaikoDifficultyHitObject.cs @@ -0,0 +1,20 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Taiko.Objects; + +namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing +{ + public class TaikoDifficultyHitObject : DifficultyHitObject + { + public readonly bool HasTypeChange; + + public TaikoDifficultyHitObject(HitObject hitObject, HitObject lastObject, double clockRate) + : base(hitObject, lastObject, clockRate) + { + HasTypeChange = lastObject is RimHit != hitObject is RimHit; + } + } +} diff --git a/osu.Game.Rulesets.Taiko/Difficulty/Skills/Strain.cs b/osu.Game.Rulesets.Taiko/Difficulty/Skills/Strain.cs new file mode 100644 index 0000000000..c6fe273b50 --- /dev/null +++ b/osu.Game.Rulesets.Taiko/Difficulty/Skills/Strain.cs @@ -0,0 +1,95 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Difficulty.Skills; +using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing; +using osu.Game.Rulesets.Taiko.Objects; + +namespace osu.Game.Rulesets.Taiko.Difficulty.Skills +{ + public class Strain : Skill + { + private const double rhythm_change_base_threshold = 0.2; + private const double rhythm_change_base = 2.0; + + protected override double SkillMultiplier => 1; + protected override double StrainDecayBase => 0.3; + + private ColourSwitch lastColourSwitch = ColourSwitch.None; + + private int sameColourCount = 1; + + protected override double StrainValueOf(DifficultyHitObject current) + { + double addition = 1; + + // We get an extra addition if we are not a slider or spinner + if (current.LastObject is Hit && current.BaseObject is Hit && current.DeltaTime < 1000) + { + if (hasColourChange(current)) + addition += 0.75; + + if (hasRhythmChange(current)) + addition += 1; + } + else + { + lastColourSwitch = ColourSwitch.None; + sameColourCount = 1; + } + + double additionFactor = 1; + + // Scale the addition factor linearly from 0.4 to 1 for DeltaTime from 0 to 50 + if (current.DeltaTime < 50) + additionFactor = 0.4 + 0.6 * current.DeltaTime / 50; + + return additionFactor * addition; + } + + private bool hasRhythmChange(DifficultyHitObject current) + { + // We don't want a division by zero if some random mapper decides to put two HitObjects at the same time. + if (current.DeltaTime == 0 || Previous.Count == 0 || Previous[0].DeltaTime == 0) + return false; + + double timeElapsedRatio = Math.Max(Previous[0].DeltaTime / current.DeltaTime, current.DeltaTime / Previous[0].DeltaTime); + + if (timeElapsedRatio >= 8) + return false; + + double difference = Math.Log(timeElapsedRatio, rhythm_change_base) % 1.0; + + return difference > rhythm_change_base_threshold && difference < 1 - rhythm_change_base_threshold; + } + + private bool hasColourChange(DifficultyHitObject current) + { + var taikoCurrent = (TaikoDifficultyHitObject)current; + + if (!taikoCurrent.HasTypeChange) + { + sameColourCount++; + return false; + } + + var oldColourSwitch = lastColourSwitch; + var newColourSwitch = sameColourCount % 2 == 0 ? ColourSwitch.Even : ColourSwitch.Odd; + + lastColourSwitch = newColourSwitch; + sameColourCount = 1; + + // We only want a bonus if the parity of the color switch changes + return oldColourSwitch != ColourSwitch.None && oldColourSwitch != newColourSwitch; + } + + private enum ColourSwitch + { + None, + Even, + Odd + } + } +} diff --git a/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyAttributes.cs b/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyAttributes.cs index 3770f9601a..75d3807bba 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyAttributes.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyAttributes.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using osu.Game.Rulesets.Difficulty; -using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Taiko.Difficulty { @@ -10,10 +9,5 @@ namespace osu.Game.Rulesets.Taiko.Difficulty { public double GreatHitWindow; public int MaxCombo; - - public TaikoDifficultyAttributes(Mod[] mods, double starRating) - : base(mods, starRating) - { - } } } diff --git a/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs b/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs index 2322446666..685ad9949b 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs @@ -1,137 +1,51 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Collections.Generic; using System.Linq; using osu.Game.Beatmaps; using osu.Game.Rulesets.Difficulty; +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Difficulty.Skills; using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing; +using osu.Game.Rulesets.Taiko.Difficulty.Skills; using osu.Game.Rulesets.Taiko.Mods; using osu.Game.Rulesets.Taiko.Objects; namespace osu.Game.Rulesets.Taiko.Difficulty { - internal class TaikoDifficultyCalculator : DifficultyCalculator + public class TaikoDifficultyCalculator : DifficultyCalculator { private const double star_scaling_factor = 0.04125; - /// - /// In milliseconds. For difficulty calculation we will only look at the highest strain value in each time interval of size STRAIN_STEP. - /// This is to eliminate higher influence of stream over aim by simply having more HitObjects with high strain. - /// The higher this value, the less strains there will be, indirectly giving long beatmaps an advantage. - /// - private const double strain_step = 400; - - /// - /// The weighting of each strain value decays to this number * it's previous value - /// - private const double decay_weight = 0.9; - public TaikoDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap) : base(ruleset, beatmap) { } - protected override DifficultyAttributes Calculate(IBeatmap beatmap, Mod[] mods, double timeRate) + protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) { - if (!beatmap.HitObjects.Any()) - return new TaikoDifficultyAttributes(mods, 0); + if (beatmap.HitObjects.Count == 0) + return new TaikoDifficultyAttributes { Mods = mods }; - var difficultyHitObjects = new List(); - - foreach (var hitObject in beatmap.HitObjects) - difficultyHitObjects.Add(new TaikoHitObjectDifficulty((TaikoHitObject)hitObject)); - - // Sort DifficultyHitObjects by StartTime of the HitObjects - just to make sure. - difficultyHitObjects.Sort((a, b) => a.BaseHitObject.StartTime.CompareTo(b.BaseHitObject.StartTime)); - - if (!calculateStrainValues(difficultyHitObjects, timeRate)) - return new TaikoDifficultyAttributes(mods, 0); - - double starRating = calculateDifficulty(difficultyHitObjects, timeRate) * star_scaling_factor; - - return new TaikoDifficultyAttributes(mods, starRating) + return new TaikoDifficultyAttributes { - // Todo: This int cast is temporary to achieve 1:1 results with osu!stable, and should be remoevd in the future - GreatHitWindow = (int)(beatmap.HitObjects.First().HitWindows.Great / 2) / timeRate, - MaxCombo = beatmap.HitObjects.Count(h => h is Hit) + StarRating = skills.Single().DifficultyValue() * star_scaling_factor, + Mods = mods, + // Todo: This int cast is temporary to achieve 1:1 results with osu!stable, and should be removed in the future + GreatHitWindow = (int)(beatmap.HitObjects.First().HitWindows.Great / 2) / clockRate, + MaxCombo = beatmap.HitObjects.Count(h => h is Hit), }; } - private bool calculateStrainValues(List objects, double timeRate) + protected override IEnumerable CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate) { - // Traverse hitObjects in pairs to calculate the strain value of NextHitObject from the strain value of CurrentHitObject and environment. - using (var hitObjectsEnumerator = objects.GetEnumerator()) - { - if (!hitObjectsEnumerator.MoveNext()) return false; - - TaikoHitObjectDifficulty current = hitObjectsEnumerator.Current; - - // First hitObject starts at strain 1. 1 is the default for strain values, so we don't need to set it here. See DifficultyHitObject. - while (hitObjectsEnumerator.MoveNext()) - { - var next = hitObjectsEnumerator.Current; - next?.CalculateStrains(current, timeRate); - current = next; - } - - return true; - } + for (int i = 1; i < beatmap.HitObjects.Count; i++) + yield return new TaikoDifficultyHitObject(beatmap.HitObjects[i], beatmap.HitObjects[i - 1], clockRate); } - private double calculateDifficulty(List objects, double timeRate) - { - double actualStrainStep = strain_step * timeRate; - - // Find the highest strain value within each strain step - List highestStrains = new List(); - double intervalEndTime = actualStrainStep; - double maximumStrain = 0; // We need to keep track of the maximum strain in the current interval - - TaikoHitObjectDifficulty previousHitObject = null; - foreach (var hitObject in objects) - { - // While we are beyond the current interval push the currently available maximum to our strain list - while (hitObject.BaseHitObject.StartTime > intervalEndTime) - { - highestStrains.Add(maximumStrain); - - // The maximum strain of the next interval is not zero by default! We need to take the last hitObject we encountered, take its strain and apply the decay - // until the beginning of the next interval. - if (previousHitObject == null) - { - maximumStrain = 0; - } - else - { - double decay = Math.Pow(TaikoHitObjectDifficulty.DECAY_BASE, (intervalEndTime - previousHitObject.BaseHitObject.StartTime) / 1000); - maximumStrain = previousHitObject.Strain * decay; - } - - // Go to the next time interval - intervalEndTime += actualStrainStep; - } - - // Obtain maximum strain - maximumStrain = Math.Max(hitObject.Strain, maximumStrain); - - previousHitObject = hitObject; - } - - // Build the weighted sum over the highest strains for each interval - double difficulty = 0; - double weight = 1; - highestStrains.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain. - - foreach (double strain in highestStrains) - { - difficulty += weight * strain; - weight *= decay_weight; - } - - return difficulty; - } + protected override Skill[] CreateSkills(IBeatmap beatmap) => new Skill[] { new Strain() }; protected override Mod[] DifficultyAdjustmentMods => new Mod[] { diff --git a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs index c7e6771b80..b99ec57166 100644 --- a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs +++ b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Bindables; using osu.Framework.Caching; using osu.Framework.Graphics; using osu.Game.Rulesets.Mods; @@ -48,9 +49,9 @@ namespace osu.Game.Rulesets.Taiko.Mods return default_flashlight_size; } - protected override void OnComboChange(int newCombo) + protected override void OnComboChange(ValueChangedEvent e) { - this.TransformTo(nameof(FlashlightSize), new Vector2(0, getSizeFor(newCombo)), FLASHLIGHT_FADE_DURATION); + this.TransformTo(nameof(FlashlightSize), new Vector2(0, getSizeFor(e.NewValue)), FLASHLIGHT_FADE_DURATION); } protected override string FragmentShader => "CircularFlashlight"; diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs index d6a598fbec..9211eccc40 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs @@ -229,6 +229,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables // Ensure alternating centre and rim hits if (lastWasCentre == isCentre) return false; + lastWasCentre = isCentre; UpdateResult(true); diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs index 38bf877040..5f755c7cc3 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs @@ -49,6 +49,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables protected void ProxyContent() { if (isProxied) return; + isProxied = true; nonProxiedContent.Remove(Content); @@ -62,6 +63,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables protected void UnproxyContent() { if (!isProxied) return; + isProxied = false; proxiedContent.Remove(Content); diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CirclePiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CirclePiece.cs index 5369499dbc..53dbe5d08e 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CirclePiece.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CirclePiece.cs @@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces /// public override Color4 AccentColour { - get { return base.AccentColour; } + get => base.AccentColour; set { base.AccentColour = value; @@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces /// public override bool KiaiMode { - get { return base.KiaiMode; } + get => base.KiaiMode; set { base.KiaiMode = value; diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs index dd6a1a5021..773e3ae907 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs @@ -11,26 +11,25 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces public class TaikoPiece : BeatSyncedContainer, IHasAccentColour { private Color4 accentColour; + /// /// The colour of the inner circle and outer glows. /// public virtual Color4 AccentColour { - get { return accentColour; } - set { accentColour = value; } + get => accentColour; + set => accentColour = value; } private bool kiaiMode; + /// /// Whether Kiai mode effects are enabled for this circle piece. /// public virtual bool KiaiMode { - get { return kiaiMode; } - set - { - kiaiMode = value; - } + get => kiaiMode; + set => kiaiMode = value; } public TaikoPiece() diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TickPiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TickPiece.cs index d625047d29..83cf7a64ec 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TickPiece.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TickPiece.cs @@ -23,9 +23,10 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces private const float tick_size = 0.35f; private bool filled; + public bool Filled { - get { return filled; } + get => filled; set { filled = value; diff --git a/osu.Game.Rulesets.Taiko/Objects/Swell.cs b/osu.Game.Rulesets.Taiko/Objects/Swell.cs index 9d511daae4..befa728570 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Swell.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Swell.cs @@ -19,7 +19,10 @@ namespace osu.Game.Rulesets.Taiko.Objects /// public int RequiredHits = 10; - public override bool IsStrong { set => throw new NotSupportedException($"{nameof(Swell)} cannot be a strong hitobject."); } + public override bool IsStrong + { + set => throw new NotSupportedException($"{nameof(Swell)} cannot be a strong hitobject."); + } protected override void CreateNestedHitObjects() { diff --git a/osu.Game.Rulesets.Taiko/Objects/TaikoHitObjectDifficulty.cs b/osu.Game.Rulesets.Taiko/Objects/TaikoHitObjectDifficulty.cs deleted file mode 100644 index 46dd7aa87f..0000000000 --- a/osu.Game.Rulesets.Taiko/Objects/TaikoHitObjectDifficulty.cs +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; - -namespace osu.Game.Rulesets.Taiko.Objects -{ - internal class TaikoHitObjectDifficulty - { - /// - /// Factor by how much individual / overall strain decays per second. - /// - /// - /// These values are results of tweaking a lot and taking into account general feedback. - /// - internal const double DECAY_BASE = 0.30; - - private const double type_change_bonus = 0.75; - private const double rhythm_change_bonus = 1.0; - private const double rhythm_change_base_threshold = 0.2; - private const double rhythm_change_base = 2.0; - - internal TaikoHitObject BaseHitObject; - - /// - /// Measures note density in a way - /// - internal double Strain = 1; - - private double timeElapsed; - private int sameTypeSince = 1; - - private bool isRim => BaseHitObject is RimHit; - - public TaikoHitObjectDifficulty(TaikoHitObject baseHitObject) - { - BaseHitObject = baseHitObject; - } - - internal void CalculateStrains(TaikoHitObjectDifficulty previousHitObject, double timeRate) - { - // Rather simple, but more specialized things are inherently inaccurate due to the big difference playstyles and opinions make. - // See Taiko feedback thread. - timeElapsed = (BaseHitObject.StartTime - previousHitObject.BaseHitObject.StartTime) / timeRate; - double decay = Math.Pow(DECAY_BASE, timeElapsed / 1000); - - double addition = 1; - - // Only if we are no slider or spinner we get an extra addition - if (previousHitObject.BaseHitObject is Hit && BaseHitObject is Hit - && BaseHitObject.StartTime - previousHitObject.BaseHitObject.StartTime < 1000) // And we only want to check out hitobjects which aren't so far in the past - { - addition += typeChangeAddition(previousHitObject); - addition += rhythmChangeAddition(previousHitObject); - } - - double additionFactor = 1.0; - // Scale AdditionFactor linearly from 0.4 to 1 for TimeElapsed from 0 to 50 - if (timeElapsed < 50.0) - additionFactor = 0.4 + 0.6 * timeElapsed / 50.0; - - Strain = previousHitObject.Strain * decay + addition * additionFactor; - } - - private TypeSwitch lastTypeSwitchEven = TypeSwitch.None; - private double typeChangeAddition(TaikoHitObjectDifficulty previousHitObject) - { - // If we don't have the same hit type, trigger a type change! - if (previousHitObject.isRim != isRim) - { - lastTypeSwitchEven = previousHitObject.sameTypeSince % 2 == 0 ? TypeSwitch.Even : TypeSwitch.Odd; - - // We only want a bonus if the parity of the type switch changes! - switch (previousHitObject.lastTypeSwitchEven) - { - case TypeSwitch.Even: - if (lastTypeSwitchEven == TypeSwitch.Odd) - return type_change_bonus; - break; - case TypeSwitch.Odd: - if (lastTypeSwitchEven == TypeSwitch.Even) - return type_change_bonus; - break; - } - } - // No type change? Increment counter and keep track of last type switch - else - { - lastTypeSwitchEven = previousHitObject.lastTypeSwitchEven; - sameTypeSince = previousHitObject.sameTypeSince + 1; - } - - return 0; - } - - private double rhythmChangeAddition(TaikoHitObjectDifficulty previousHitObject) - { - // We don't want a division by zero if some random mapper decides to put 2 HitObjects at the same time. - if (timeElapsed == 0 || previousHitObject.timeElapsed == 0) - return 0; - - double timeElapsedRatio = Math.Max(previousHitObject.timeElapsed / timeElapsed, timeElapsed / previousHitObject.timeElapsed); - - if (timeElapsedRatio >= 8) - return 0; - - double difference = Math.Log(timeElapsedRatio, rhythm_change_base) % 1.0; - - if (isWithinChangeThreshold(difference)) - return rhythm_change_bonus; - - return 0; - } - - private bool isWithinChangeThreshold(double value) - { - return value > rhythm_change_base_threshold && value < 1 - rhythm_change_base_threshold; - } - - private enum TypeSwitch - { - None, - Even, - Odd - } - } -} diff --git a/osu.Game.Rulesets.Taiko/Resources/Testing/Beatmaps/diffcalc-test-strong.osu b/osu.Game.Rulesets.Taiko/Resources/Testing/Beatmaps/diffcalc-test-strong.osu new file mode 100644 index 0000000000..33510eceb7 --- /dev/null +++ b/osu.Game.Rulesets.Taiko/Resources/Testing/Beatmaps/diffcalc-test-strong.osu @@ -0,0 +1,257 @@ +osu file format v14 + +[General] +Mode: 1 + +[Difficulty] +CircleSize:4 +OverallDifficulty:7 +ApproachRate:8.3 +SliderMultiplier:1.6 +SliderTickRate:1 + +[TimingPoints] +500,500,4,2,1,50,1,0 +62500,-500,4,2,1,50,0,0 +71000,-100,4,2,1,50,0,0 + +[HitObjects] +// Same as diffcalc-test with finishers on every note +142,122,0,5,4,0:0:0:0: +142,122,125,1,4,0:0:0:0: +142,122,250,1,4,0:0:0:0: +142,122,375,1,4,0:0:0:0: +142,122,500,1,4,0:0:0:0: +142,122,625,1,4,0:0:0:0: +142,122,750,1,4,0:0:0:0: +142,122,875,1,4,0:0:0:0: +142,122,1000,1,4,0:0:0:0: +142,122,1125,1,4,0:0:0:0: +142,122,1250,1,4,0:0:0:0: +142,122,1375,1,4,0:0:0:0: +142,122,1500,1,4,0:0:0:0: +119,106,2500,1,6,0:0:0:0: +119,106,2625,1,6,0:0:0:0: +119,106,2750,1,6,0:0:0:0: +119,106,2875,1,6,0:0:0:0: +119,106,3000,1,6,0:0:0:0: +119,106,3125,1,6,0:0:0:0: +119,106,3250,1,6,0:0:0:0: +119,106,3375,1,6,0:0:0:0: +119,106,3500,1,6,0:0:0:0: +119,106,3625,1,6,0:0:0:0: +119,106,3750,1,6,0:0:0:0: +119,106,3875,1,6,0:0:0:0: +119,106,4000,1,6,0:0:0:0: +136,90,5000,1,4,0:0:0:0: +136,90,5125,1,6,0:0:0:0: +136,90,5250,1,4,0:0:0:0: +136,90,5375,1,6,0:0:0:0: +136,90,5500,1,4,0:0:0:0: +136,90,5625,1,6,0:0:0:0: +136,90,5750,1,4,0:0:0:0: +136,90,5875,1,6,0:0:0:0: +136,90,6000,1,4,0:0:0:0: +136,90,6125,1,6,0:0:0:0: +136,90,6250,1,4,0:0:0:0: +136,90,6375,1,6,0:0:0:0: +136,90,6500,1,4,0:0:0:0: +86,113,7500,1,4,0:0:0:0: +86,113,7625,1,4,0:0:0:0: +86,113,7750,1,6,0:0:0:0: +86,113,7875,1,6,0:0:0:0: +86,113,8000,1,4,0:0:0:0: +86,113,8125,1,4,0:0:0:0: +86,113,8250,1,6,0:0:0:0: +86,113,8375,1,6,0:0:0:0: +86,113,8500,1,4,0:0:0:0: +86,113,8625,1,4,0:0:0:0: +86,113,8750,1,6,0:0:0:0: +86,113,8875,1,6,0:0:0:0: +86,113,9000,1,4,0:0:0:0: +146,90,10000,1,4,0:0:0:0: +146,90,10125,1,4,0:0:0:0: +146,90,10250,1,4,0:0:0:0: +146,90,10375,1,6,0:0:0:0: +146,90,10500,1,6,0:0:0:0: +146,90,10625,1,6,0:0:0:0: +146,90,10750,1,4,0:0:0:0: +146,90,10875,1,4,0:0:0:0: +146,90,11000,1,4,0:0:0:0: +146,90,11125,1,6,0:0:0:0: +146,90,11250,1,6,0:0:0:0: +146,90,11375,1,6,0:0:0:0: +146,90,11500,1,4,0:0:0:0: +146,90,11625,1,4,0:0:0:0: +146,90,11750,1,4,0:0:0:0: +146,90,11875,1,6,0:0:0:0: +146,90,12000,1,6,0:0:0:0: +146,90,12125,1,6,0:0:0:0: +146,90,12250,1,4,0:0:0:0: +146,90,12375,1,4,0:0:0:0: +146,90,12500,1,4,0:0:0:0: +69,99,13500,1,4,0:0:0:0: +69,99,13625,1,4,0:0:0:0: +69,99,13750,1,4,0:0:0:0: +69,99,13875,1,6,0:0:0:0: +69,99,14000,1,4,0:0:0:0: +69,99,14125,1,4,0:0:0:0: +69,99,14250,1,4,0:0:0:0: +69,99,14375,1,6,0:0:0:0: +69,99,14500,1,4,0:0:0:0: +69,99,14625,1,4,0:0:0:0: +69,99,14750,1,4,0:0:0:0: +69,99,14875,1,6,0:0:0:0: +69,99,15000,1,4,0:0:0:0: +69,99,15125,1,4,0:0:0:0: +69,99,15250,1,4,0:0:0:0: +69,99,15375,1,6,0:0:0:0: +69,99,15500,1,4,0:0:0:0: +83,89,16500,1,4,0:0:0:0: +83,89,16625,1,6,0:0:0:0: +83,89,16750,1,6,0:0:0:0: +83,89,16875,1,4,0:0:0:0: +83,89,17000,1,4,0:0:0:0: +83,89,17125,1,4,0:0:0:0: +83,89,17250,1,6,0:0:0:0: +83,89,17375,1,6,0:0:0:0: +83,89,17500,1,6,0:0:0:0: +83,89,17625,1,6,0:0:0:0: +83,89,17750,1,4,0:0:0:0: +83,89,17875,1,4,0:0:0:0: +83,89,18000,1,4,0:0:0:0: +83,89,18125,1,4,0:0:0:0: +83,89,18250,1,4,0:0:0:0: +83,89,18375,1,6,0:0:0:0: +83,89,18500,1,6,0:0:0:0: +83,89,18625,1,6,0:0:0:0: +83,89,18750,1,6,0:0:0:0: +83,89,18875,1,4,0:0:0:0: +83,89,19000,1,4,0:0:0:0: +83,89,19125,1,4,0:0:0:0: +83,89,19250,1,4,0:0:0:0: +83,89,19375,1,6,0:0:0:0: +83,89,19500,1,6,0:0:0:0: +83,89,19625,1,4,0:0:0:0: +84,122,20500,1,4,0:0:0:0: +84,122,20625,2,4,L|217:123,1,120 +84,122,21125,1,4,0:0:0:0: +84,122,21250,2,4,L|217:123,1,120 +84,122,21750,1,4,0:0:0:0: +84,122,21875,2,4,L|217:123,1,120 +84,122,22375,1,4,0:0:0:0: +84,122,22500,2,4,L|217:123,1,120 +84,122,23000,1,4,0:0:0:0: +84,122,23125,2,4,L|217:123,1,120 +99,106,24500,1,4,0:0:0:0: +99,106,24625,1,4,0:0:0:0: +99,106,24750,2,4,L|194:107,1,80 +99,106,25125,1,4,0:0:0:0: +99,106,25250,1,4,0:0:0:0: +99,106,25375,2,4,L|194:107,1,80 +99,106,25750,1,4,0:0:0:0: +99,106,25875,1,4,0:0:0:0: +99,106,26000,2,4,L|194:107,1,80 +99,106,26375,1,4,0:0:0:0: +99,106,26500,1,4,0:0:0:0: +99,106,26625,2,4,L|194:107,1,80 +99,106,27000,1,4,0:0:0:0: +99,106,27125,1,4,0:0:0:0: +99,106,27250,2,4,L|194:107,1,80 +121,103,28500,1,4,0:0:0:0: +121,103,28625,1,4,0:0:0:0: +121,103,28750,1,4,0:0:0:0: +121,103,28875,2,4,L|190:103,1,40 +121,103,29125,1,4,0:0:0:0: +121,103,29250,1,4,0:0:0:0: +121,103,29375,1,4,0:0:0:0: +121,103,29500,2,4,L|190:103,1,40 +121,103,29750,1,4,0:0:0:0: +121,103,29875,1,4,0:0:0:0: +121,103,30000,1,4,0:0:0:0: +121,103,30125,2,4,L|190:103,1,40 +121,103,30375,1,4,0:0:0:0: +121,103,30500,1,4,0:0:0:0: +121,103,30625,1,4,0:0:0:0: +121,103,30750,2,4,L|190:103,1,40 +121,103,31000,1,4,0:0:0:0: +121,103,31125,1,4,0:0:0:0: +121,103,31250,1,4,0:0:0:0: +121,103,31375,2,4,L|190:103,1,40 +121,103,32500,1,4,0:0:0:0: +121,103,32625,1,6,0:0:0:0: +121,103,32750,1,4,0:0:0:0: +121,103,32875,2,4,L|190:103,1,40 +121,103,33125,1,4,0:0:0:0: +121,103,33250,1,6,0:0:0:0: +121,103,33375,1,4,0:0:0:0: +121,103,33500,2,4,L|190:103,1,40 +121,103,33750,1,4,0:0:0:0: +121,103,33875,1,6,0:0:0:0: +121,103,34000,1,4,0:0:0:0: +121,103,34125,2,4,L|190:103,1,40 +121,103,34375,1,4,0:0:0:0: +121,103,34500,1,6,0:0:0:0: +121,103,34625,1,4,0:0:0:0: +121,103,34750,2,4,L|190:103,1,40 +121,103,35000,1,4,0:0:0:0: +121,103,35125,1,6,0:0:0:0: +121,103,35250,1,4,0:0:0:0: +121,103,35375,2,4,L|190:103,1,40 +121,103,36500,1,4,0:0:0:0: +121,103,36625,1,4,0:0:0:0: +121,103,36750,1,6,0:0:0:0: +121,103,36875,2,4,L|190:103,1,40 +121,103,37125,1,4,0:0:0:0: +121,103,37250,1,4,0:0:0:0: +121,103,37375,1,6,0:0:0:0: +121,103,37500,2,4,L|190:103,1,40 +121,103,37750,1,4,0:0:0:0: +121,103,37875,1,4,0:0:0:0: +121,103,38000,1,6,0:0:0:0: +121,103,38125,2,4,L|190:103,1,40 +121,103,38375,1,4,0:0:0:0: +121,103,38500,1,4,0:0:0:0: +121,103,38625,1,6,0:0:0:0: +121,103,38750,2,4,L|190:103,1,40 +121,103,39000,1,4,0:0:0:0: +121,103,39125,1,4,0:0:0:0: +121,103,39250,1,6,0:0:0:0: +121,103,39375,2,4,L|190:103,1,40 +107,106,40500,1,4,0:0:0:0: +107,106,40625,1,4,0:0:0:0: +107,106,40750,1,6,0:0:0:0: +107,106,40875,1,6,0:0:0:0: +46,112,41000,2,4,L|214:112,1,160 +107,106,41625,1,4,0:0:0:0: +107,106,41750,1,4,0:0:0:0: +107,106,41875,1,6,0:0:0:0: +107,106,42000,1,6,0:0:0:0: +46,112,42125,2,4,L|214:112,1,160 +107,106,42750,1,4,0:0:0:0: +107,106,42875,1,4,0:0:0:0: +107,106,43000,1,6,0:0:0:0: +107,106,43125,1,6,0:0:0:0: +46,112,43250,2,4,L|214:112,1,160 +107,106,43875,1,4,0:0:0:0: +107,106,44000,1,4,0:0:0:0: +107,106,44125,1,6,0:0:0:0: +107,106,44250,1,6,0:0:0:0: +46,112,44375,2,4,L|214:112,1,160 +107,106,45000,1,4,0:0:0:0: +107,106,45125,1,4,0:0:0:0: +107,106,45250,1,6,0:0:0:0: +107,106,45375,1,6,0:0:0:0: +46,112,45500,2,4,L|214:112,1,160 +256,192,47000,12,4,47500,0:0:0:0: +256,192,47625,12,4,48000,0:0:0:0: +256,192,48125,12,4,48500,0:0:0:0: +256,192,48625,12,4,49000,0:0:0:0: +256,192,50000,12,4,50500,0:0:0:0: +183,143,50625,5,4,0:0:0:0: +256,192,50750,12,4,51250,0:0:0:0: +114,106,51375,5,4,0:0:0:0: +256,192,51625,12,4,52125,0:0:0:0: +154,143,52250,5,4,0:0:0:0: +256,192,52375,12,4,52875,0:0:0:0: +116,111,53000,5,4,0:0:0:0: diff --git a/osu.Game.Rulesets.Taiko/Resources/Testing/Beatmaps/diffcalc-test.osu b/osu.Game.Rulesets.Taiko/Resources/Testing/Beatmaps/diffcalc-test.osu new file mode 100644 index 0000000000..15326162ea --- /dev/null +++ b/osu.Game.Rulesets.Taiko/Resources/Testing/Beatmaps/diffcalc-test.osu @@ -0,0 +1,285 @@ +osu file format v14 + +[General] +Mode: 1 + +[Difficulty] +CircleSize:4 +OverallDifficulty:7 +ApproachRate:8.3 +SliderMultiplier:1.6 +SliderTickRate:1 + +[TimingPoints] +500,500,4,2,1,50,1,0 +62500,-500,4,2,1,50,0,0 +71000,-100,4,2,1,50,0,0 + +[HitObjects] +// dd, spaced 1/4 beat apart +142,122,0,5,0,0:0:0:0: +142,122,125,1,0,0:0:0:0: +142,122,250,1,0,0:0:0:0: +142,122,375,1,0,0:0:0:0: +142,122,500,1,0,0:0:0:0: +142,122,625,1,0,0:0:0:0: +142,122,750,1,0,0:0:0:0: +142,122,875,1,0,0:0:0:0: +142,122,1000,1,0,0:0:0:0: +142,122,1125,1,0,0:0:0:0: +142,122,1250,1,0,0:0:0:0: +142,122,1375,1,0,0:0:0:0: +142,122,1500,1,0,0:0:0:0: + +// kk, spaced 1/4 beat apart +119,106,2500,1,2,0:0:0:0: +119,106,2625,1,2,0:0:0:0: +119,106,2750,1,2,0:0:0:0: +119,106,2875,1,2,0:0:0:0: +119,106,3000,1,2,0:0:0:0: +119,106,3125,1,2,0:0:0:0: +119,106,3250,1,2,0:0:0:0: +119,106,3375,1,2,0:0:0:0: +119,106,3500,1,2,0:0:0:0: +119,106,3625,1,2,0:0:0:0: +119,106,3750,1,2,0:0:0:0: +119,106,3875,1,2,0:0:0:0: +119,106,4000,1,2,0:0:0:0: + +// dk, spaced 1/4 beat apart +136,90,5000,1,0,0:0:0:0: +136,90,5125,1,2,0:0:0:0: +136,90,5250,1,0,0:0:0:0: +136,90,5375,1,2,0:0:0:0: +136,90,5500,1,0,0:0:0:0: +136,90,5625,1,2,0:0:0:0: +136,90,5750,1,0,0:0:0:0: +136,90,5875,1,2,0:0:0:0: +136,90,6000,1,0,0:0:0:0: +136,90,6125,1,2,0:0:0:0: +136,90,6250,1,0,0:0:0:0: +136,90,6375,1,2,0:0:0:0: +136,90,6500,1,0,0:0:0:0: + +// ddkk, spaced 1/4 beat apart +86,113,7500,1,0,0:0:0:0: +86,113,7625,1,0,0:0:0:0: +86,113,7750,1,2,0:0:0:0: +86,113,7875,1,2,0:0:0:0: +86,113,8000,1,0,0:0:0:0: +86,113,8125,1,0,0:0:0:0: +86,113,8250,1,2,0:0:0:0: +86,113,8375,1,2,0:0:0:0: +86,113,8500,1,0,0:0:0:0: +86,113,8625,1,0,0:0:0:0: +86,113,8750,1,2,0:0:0:0: +86,113,8875,1,2,0:0:0:0: +86,113,9000,1,0,0:0:0:0: + +// dddkkk, spaced 1/4 beat apart +146,90,10000,1,0,0:0:0:0: +146,90,10125,1,0,0:0:0:0: +146,90,10250,1,0,0:0:0:0: +146,90,10375,1,2,0:0:0:0: +146,90,10500,1,2,0:0:0:0: +146,90,10625,1,2,0:0:0:0: +146,90,10750,1,0,0:0:0:0: +146,90,10875,1,0,0:0:0:0: +146,90,11000,1,0,0:0:0:0: +146,90,11125,1,2,0:0:0:0: +146,90,11250,1,2,0:0:0:0: +146,90,11375,1,2,0:0:0:0: +146,90,11500,1,0,0:0:0:0: +146,90,11625,1,0,0:0:0:0: +146,90,11750,1,0,0:0:0:0: +146,90,11875,1,2,0:0:0:0: +146,90,12000,1,2,0:0:0:0: +146,90,12125,1,2,0:0:0:0: +146,90,12250,1,0,0:0:0:0: +146,90,12375,1,0,0:0:0:0: +146,90,12500,1,0,0:0:0:0: + +// dddk, spaced 1/4 beat apart +69,99,13500,1,0,0:0:0:0: +69,99,13625,1,0,0:0:0:0: +69,99,13750,1,0,0:0:0:0: +69,99,13875,1,2,0:0:0:0: +69,99,14000,1,0,0:0:0:0: +69,99,14125,1,0,0:0:0:0: +69,99,14250,1,0,0:0:0:0: +69,99,14375,1,2,0:0:0:0: +69,99,14500,1,0,0:0:0:0: +69,99,14625,1,0,0:0:0:0: +69,99,14750,1,0,0:0:0:0: +69,99,14875,1,2,0:0:0:0: +69,99,15000,1,0,0:0:0:0: +69,99,15125,1,0,0:0:0:0: +69,99,15250,1,0,0:0:0:0: +69,99,15375,1,2,0:0:0:0: +69,99,15500,1,0,0:0:0:0: + +// arbitrary pattern, spaced 1/4 beat apart +83,89,16500,1,0,0:0:0:0: +83,89,16625,1,2,0:0:0:0: +83,89,16750,1,2,0:0:0:0: +83,89,16875,1,0,0:0:0:0: +83,89,17000,1,0,0:0:0:0: +83,89,17125,1,0,0:0:0:0: +83,89,17250,1,2,0:0:0:0: +83,89,17375,1,2,0:0:0:0: +83,89,17500,1,2,0:0:0:0: +83,89,17625,1,2,0:0:0:0: +83,89,17750,1,0,0:0:0:0: +83,89,17875,1,0,0:0:0:0: +83,89,18000,1,0,0:0:0:0: +83,89,18125,1,0,0:0:0:0: +83,89,18250,1,0,0:0:0:0: +83,89,18375,1,2,0:0:0:0: +83,89,18500,1,2,0:0:0:0: +83,89,18625,1,2,0:0:0:0: +83,89,18750,1,2,0:0:0:0: +83,89,18875,1,0,0:0:0:0: +83,89,19000,1,0,0:0:0:0: +83,89,19125,1,0,0:0:0:0: +83,89,19250,1,0,0:0:0:0: +83,89,19375,1,2,0:0:0:0: +83,89,19500,1,2,0:0:0:0: +83,89,19625,1,0,0:0:0:0: + +// d-slider pattern, spaced 1/4 beat apart +84,122,20500,1,0,0:0:0:0: +84,122,20625,2,0,L|217:123,1,120 +84,122,21125,1,0,0:0:0:0: +84,122,21250,2,0,L|217:123,1,120 +84,122,21750,1,0,0:0:0:0: +84,122,21875,2,0,L|217:123,1,120 +84,122,22375,1,0,0:0:0:0: +84,122,22500,2,0,L|217:123,1,120 +84,122,23000,1,0,0:0:0:0: +84,122,23125,2,0,L|217:123,1,120 + +// dd-slider pattern, spaced 1/4 beat apart +99,106,24500,1,0,0:0:0:0: +99,106,24625,1,0,0:0:0:0: +99,106,24750,2,0,L|194:107,1,80 +99,106,25125,1,0,0:0:0:0: +99,106,25250,1,0,0:0:0:0: +99,106,25375,2,0,L|194:107,1,80 +99,106,25750,1,0,0:0:0:0: +99,106,25875,1,0,0:0:0:0: +99,106,26000,2,0,L|194:107,1,80 +99,106,26375,1,0,0:0:0:0: +99,106,26500,1,0,0:0:0:0: +99,106,26625,2,0,L|194:107,1,80 +99,106,27000,1,0,0:0:0:0: +99,106,27125,1,0,0:0:0:0: +99,106,27250,2,0,L|194:107,1,80 + +// ddd-slider pattern, spaced 1/4 beat apart +121,103,28500,1,0,0:0:0:0: +121,103,28625,1,0,0:0:0:0: +121,103,28750,1,0,0:0:0:0: +121,103,28875,2,0,L|190:103,1,40 +121,103,29125,1,0,0:0:0:0: +121,103,29250,1,0,0:0:0:0: +121,103,29375,1,0,0:0:0:0: +121,103,29500,2,0,L|190:103,1,40 +121,103,29750,1,0,0:0:0:0: +121,103,29875,1,0,0:0:0:0: +121,103,30000,1,0,0:0:0:0: +121,103,30125,2,0,L|190:103,1,40 +121,103,30375,1,0,0:0:0:0: +121,103,30500,1,0,0:0:0:0: +121,103,30625,1,0,0:0:0:0: +121,103,30750,2,0,L|190:103,1,40 +121,103,31000,1,0,0:0:0:0: +121,103,31125,1,0,0:0:0:0: +121,103,31250,1,0,0:0:0:0: +121,103,31375,2,0,L|190:103,1,40 + +// dkd-slider pattern, spaced 1/4 beat apart +121,103,32500,1,0,0:0:0:0: +121,103,32625,1,2,0:0:0:0: +121,103,32750,1,0,0:0:0:0: +121,103,32875,2,0,L|190:103,1,40 +121,103,33125,1,0,0:0:0:0: +121,103,33250,1,2,0:0:0:0: +121,103,33375,1,0,0:0:0:0: +121,103,33500,2,0,L|190:103,1,40 +121,103,33750,1,0,0:0:0:0: +121,103,33875,1,2,0:0:0:0: +121,103,34000,1,0,0:0:0:0: +121,103,34125,2,0,L|190:103,1,40 +121,103,34375,1,0,0:0:0:0: +121,103,34500,1,2,0:0:0:0: +121,103,34625,1,0,0:0:0:0: +121,103,34750,2,0,L|190:103,1,40 +121,103,35000,1,0,0:0:0:0: +121,103,35125,1,2,0:0:0:0: +121,103,35250,1,0,0:0:0:0: +121,103,35375,2,0,L|190:103,1,40 + +//ddk-slider pattern, spaced 1/4 beat apart +121,103,36500,1,0,0:0:0:0: +121,103,36625,1,0,0:0:0:0: +121,103,36750,1,2,0:0:0:0: +121,103,36875,2,0,L|190:103,1,40 +121,103,37125,1,0,0:0:0:0: +121,103,37250,1,0,0:0:0:0: +121,103,37375,1,2,0:0:0:0: +121,103,37500,2,0,L|190:103,1,40 +121,103,37750,1,0,0:0:0:0: +121,103,37875,1,0,0:0:0:0: +121,103,38000,1,2,0:0:0:0: +121,103,38125,2,0,L|190:103,1,40 +121,103,38375,1,0,0:0:0:0: +121,103,38500,1,0,0:0:0:0: +121,103,38625,1,2,0:0:0:0: +121,103,38750,2,0,L|190:103,1,40 +121,103,39000,1,0,0:0:0:0: +121,103,39125,1,0,0:0:0:0: +121,103,39250,1,2,0:0:0:0: +121,103,39375,2,0,L|190:103,1,40 + +//ddkk-slider pattern, spaced 1/4 beat apart +107,106,40500,1,0,0:0:0:0: +107,106,40625,1,0,0:0:0:0: +107,106,40750,1,2,0:0:0:0: +107,106,40875,1,2,0:0:0:0: +46,112,41000,2,0,L|214:112,1,160 +107,106,41625,1,0,0:0:0:0: +107,106,41750,1,0,0:0:0:0: +107,106,41875,1,2,0:0:0:0: +107,106,42000,1,2,0:0:0:0: +46,112,42125,2,0,L|214:112,1,160 +107,106,42750,1,0,0:0:0:0: +107,106,42875,1,0,0:0:0:0: +107,106,43000,1,2,0:0:0:0: +107,106,43125,1,2,0:0:0:0: +46,112,43250,2,0,L|214:112,1,160 +107,106,43875,1,0,0:0:0:0: +107,106,44000,1,0,0:0:0:0: +107,106,44125,1,2,0:0:0:0: +107,106,44250,1,2,0:0:0:0: +46,112,44375,2,0,L|214:112,1,160 +107,106,45000,1,0,0:0:0:0: +107,106,45125,1,0,0:0:0:0: +107,106,45250,1,2,0:0:0:0: +107,106,45375,1,2,0:0:0:0: +46,112,45500,2,0,L|214:112,1,160 + +// spinner-spinner pattern, spaced 1/4 beat apart +256,192,47000,12,0,47500,0:0:0:0: +256,192,47625,12,0,48000,0:0:0:0: +256,192,48125,12,0,48500,0:0:0:0: +256,192,48625,12,0,49000,0:0:0:0: + +// spinner-d pattern, spaced 1/4 beat apart +256,192,50000,12,0,50500,0:0:0:0: +183,143,50625,5,0,0:0:0:0: +256,192,50750,12,0,51250,0:0:0:0: +114,106,51375,5,0,0:0:0:0: +256,192,51625,12,0,52125,0:0:0:0: +154,143,52250,5,0,0:0:0:0: +256,192,52375,12,0,52875,0:0:0:0: +116,111,53000,5,0,0:0:0:0: diff --git a/osu.Game.Rulesets.Taiko/TaikoInputManager.cs b/osu.Game.Rulesets.Taiko/TaikoInputManager.cs index 2aae0b23b7..058bec5111 100644 --- a/osu.Game.Rulesets.Taiko/TaikoInputManager.cs +++ b/osu.Game.Rulesets.Taiko/TaikoInputManager.cs @@ -19,10 +19,13 @@ namespace osu.Game.Rulesets.Taiko { [Description("Left (rim)")] LeftRim, + [Description("Left (centre)")] LeftCentre, + [Description("Right (centre)")] RightCentre, + [Description("Right (rim)")] RightRim } diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index 8dc9a2ca37..cb527adb98 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -225,7 +225,7 @@ namespace osu.Game.Rulesets.Taiko.UI internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result) { - if (!DisplayJudgements) + if (!DisplayJudgements.Value) return; if (!judgedObject.DisplayResult) diff --git a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj index 002d6a7e8d..656ebcc7c2 100644 --- a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj +++ b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj @@ -10,4 +10,4 @@ - \ No newline at end of file + diff --git a/osu.Game.Tests/NonVisual/DifficultyAdjustmentModCombinationsTest.cs b/osu.Game.Tests/NonVisual/DifficultyAdjustmentModCombinationsTest.cs index 795c2244a2..760a033aff 100644 --- a/osu.Game.Tests/NonVisual/DifficultyAdjustmentModCombinationsTest.cs +++ b/osu.Game.Tests/NonVisual/DifficultyAdjustmentModCombinationsTest.cs @@ -2,9 +2,12 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using NUnit.Framework; using osu.Game.Beatmaps; using osu.Game.Rulesets.Difficulty; +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Difficulty.Skills; using osu.Game.Rulesets.Mods; namespace osu.Game.Tests.NonVisual @@ -15,7 +18,7 @@ namespace osu.Game.Tests.NonVisual [Test] public void TestNoMods() { - var combinations = new TestDifficultyCalculator().CreateDifficultyAdjustmentModCombinations(); + var combinations = new TestLegacyDifficultyCalculator().CreateDifficultyAdjustmentModCombinations(); Assert.AreEqual(1, combinations.Length); Assert.IsTrue(combinations[0] is ModNoMod); @@ -24,7 +27,7 @@ namespace osu.Game.Tests.NonVisual [Test] public void TestSingleMod() { - var combinations = new TestDifficultyCalculator(new ModA()).CreateDifficultyAdjustmentModCombinations(); + var combinations = new TestLegacyDifficultyCalculator(new ModA()).CreateDifficultyAdjustmentModCombinations(); Assert.AreEqual(2, combinations.Length); Assert.IsTrue(combinations[0] is ModNoMod); @@ -34,7 +37,7 @@ namespace osu.Game.Tests.NonVisual [Test] public void TestDoubleMod() { - var combinations = new TestDifficultyCalculator(new ModA(), new ModB()).CreateDifficultyAdjustmentModCombinations(); + var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModB()).CreateDifficultyAdjustmentModCombinations(); Assert.AreEqual(4, combinations.Length); Assert.IsTrue(combinations[0] is ModNoMod); @@ -49,7 +52,7 @@ namespace osu.Game.Tests.NonVisual [Test] public void TestIncompatibleMods() { - var combinations = new TestDifficultyCalculator(new ModA(), new ModIncompatibleWithA()).CreateDifficultyAdjustmentModCombinations(); + var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModIncompatibleWithA()).CreateDifficultyAdjustmentModCombinations(); Assert.AreEqual(3, combinations.Length); Assert.IsTrue(combinations[0] is ModNoMod); @@ -60,7 +63,7 @@ namespace osu.Game.Tests.NonVisual [Test] public void TestDoubleIncompatibleMods() { - var combinations = new TestDifficultyCalculator(new ModA(), new ModB(), new ModIncompatibleWithA(), new ModIncompatibleWithAAndB()).CreateDifficultyAdjustmentModCombinations(); + var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModB(), new ModIncompatibleWithA(), new ModIncompatibleWithAAndB()).CreateDifficultyAdjustmentModCombinations(); Assert.AreEqual(8, combinations.Length); Assert.IsTrue(combinations[0] is ModNoMod); @@ -83,7 +86,7 @@ namespace osu.Game.Tests.NonVisual [Test] public void TestIncompatibleThroughBaseType() { - var combinations = new TestDifficultyCalculator(new ModAofA(), new ModIncompatibleWithAofA()).CreateDifficultyAdjustmentModCombinations(); + var combinations = new TestLegacyDifficultyCalculator(new ModAofA(), new ModIncompatibleWithAofA()).CreateDifficultyAdjustmentModCombinations(); Assert.AreEqual(3, combinations.Length); Assert.IsTrue(combinations[0] is ModNoMod); @@ -136,9 +139,9 @@ namespace osu.Game.Tests.NonVisual public override Type[] IncompatibleMods => new[] { typeof(ModA), typeof(ModB) }; } - private class TestDifficultyCalculator : DifficultyCalculator + private class TestLegacyDifficultyCalculator : DifficultyCalculator { - public TestDifficultyCalculator(params Mod[] mods) + public TestLegacyDifficultyCalculator(params Mod[] mods) : base(null, null) { DifficultyAdjustmentMods = mods; @@ -146,7 +149,20 @@ namespace osu.Game.Tests.NonVisual protected override Mod[] DifficultyAdjustmentMods { get; } - protected override DifficultyAttributes Calculate(IBeatmap beatmap, Mod[] mods, double timeRate) => throw new NotImplementedException(); + protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) + { + throw new NotImplementedException(); + } + + protected override IEnumerable CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate) + { + throw new NotImplementedException(); + } + + protected override Skill[] CreateSkills(IBeatmap beatmap) + { + throw new NotImplementedException(); + } } } } diff --git a/osu.Game.Tests/NonVisual/LimitedCapacityStackTest.cs b/osu.Game.Tests/NonVisual/LimitedCapacityStackTest.cs new file mode 100644 index 0000000000..1c78b63499 --- /dev/null +++ b/osu.Game.Tests/NonVisual/LimitedCapacityStackTest.cs @@ -0,0 +1,115 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using NUnit.Framework; +using osu.Game.Rulesets.Difficulty.Utils; + +namespace osu.Game.Tests.NonVisual +{ + [TestFixture] + public class LimitedCapacityStackTest + { + private const int capacity = 3; + + private LimitedCapacityStack stack; + + [SetUp] + public void Setup() + { + stack = new LimitedCapacityStack(capacity); + } + + [Test] + public void TestEmptyStack() + { + Assert.AreEqual(0, stack.Count); + + Assert.Throws(() => + { + int unused = stack[0]; + }); + + int count = 0; + foreach (var unused in stack) + count++; + + Assert.AreEqual(0, count); + } + + [TestCase(1)] + [TestCase(2)] + [TestCase(3)] + public void TestInRangeElements(int count) + { + // e.g. 0 -> 1 -> 2 + for (int i = 0; i < count; i++) + stack.Push(i); + + Assert.AreEqual(count, stack.Count); + + // e.g. 2 -> 1 -> 0 (reverse order) + for (int i = 0; i < stack.Count; i++) + Assert.AreEqual(count - 1 - i, stack[i]); + + // e.g. indices 3, 4, 5, 6 (out of range) + for (int i = stack.Count; i < stack.Count + capacity; i++) + { + Assert.Throws(() => + { + int unused = stack[i]; + }); + } + } + + [TestCase(4)] + [TestCase(5)] + [TestCase(6)] + public void TestOverflowElements(int count) + { + // e.g. 0 -> 1 -> 2 -> 3 + for (int i = 0; i < count; i++) + stack.Push(i); + + Assert.AreEqual(capacity, stack.Count); + + // e.g. 3 -> 2 -> 1 (reverse order) + for (int i = 0; i < stack.Count; i++) + Assert.AreEqual(count - 1 - i, stack[i]); + + // e.g. indices 3, 4, 5, 6 (out of range) + for (int i = stack.Count; i < stack.Count + capacity; i++) + { + Assert.Throws(() => + { + int unused = stack[i]; + }); + } + } + + [TestCase(1)] + [TestCase(2)] + [TestCase(3)] + [TestCase(4)] + [TestCase(5)] + [TestCase(6)] + public void TestEnumerator(int count) + { + // e.g. 0 -> 1 -> 2 -> 3 + for (int i = 0; i < count; i++) + stack.Push(i); + + int enumeratorCount = 0; + int expectedValue = count - 1; + + foreach (var item in stack) + { + Assert.AreEqual(expectedValue, item); + enumeratorCount++; + expectedValue--; + } + + Assert.AreEqual(stack.Count, enumeratorCount); + } + } +} diff --git a/osu.Game.Tests/Visual/TestCaseAutoplay.cs b/osu.Game.Tests/Visual/TestCaseAutoplay.cs index 3f3d62377e..61339a6af8 100644 --- a/osu.Game.Tests/Visual/TestCaseAutoplay.cs +++ b/osu.Game.Tests/Visual/TestCaseAutoplay.cs @@ -27,7 +27,7 @@ namespace osu.Game.Tests.Visual protected override void AddCheckSteps(Func player) { base.AddCheckSteps(player); - AddUntilStep(() => ((ScoreAccessiblePlayer)player()).ScoreProcessor.TotalScore > 0, "score above zero"); + AddUntilStep(() => ((ScoreAccessiblePlayer)player()).ScoreProcessor.TotalScore.Value > 0, "score above zero"); AddUntilStep(() => ((ScoreAccessiblePlayer)player()).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0), "key counter counted keys"); } diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs new file mode 100644 index 0000000000..d850c58f09 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -0,0 +1,414 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; +using osu.Framework.Input.States; +using osu.Framework.Platform; +using osu.Framework.Screens; +using osu.Game.Beatmaps; +using osu.Game.Configuration; +using osu.Game.Database; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Osu.Mods; +using osu.Game.Scoring; +using osu.Game.Screens; +using osu.Game.Screens.Backgrounds; +using osu.Game.Screens.Play; +using osu.Game.Screens.Play.PlayerSettings; +using osu.Game.Screens.Select; +using osu.Game.Tests.Resources; +using osu.Game.Users; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Tests.Visual +{ + [TestFixture] + public class TestCaseBackgroundScreenBeatmap : ManualInputManagerTestCase + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(ScreenWithBeatmapBackground), + typeof(PlayerLoader), + typeof(Player), + typeof(UserDimContainer), + typeof(OsuScreen) + }; + + private DummySongSelect songSelect; + private DimAccessiblePlayerLoader playerLoader; + private DimAccessiblePlayer player; + private DatabaseContextFactory factory; + private BeatmapManager manager; + private RulesetStore rulesets; + + private ScreenStackCacheContainer screenStackContainer; + + [BackgroundDependencyLoader] + private void load(GameHost host) + { + factory = new DatabaseContextFactory(LocalStorage); + factory.ResetDatabase(); + + using (var usage = factory.Get()) + usage.Migrate(); + + factory.ResetDatabase(); + + using (var usage = factory.Get()) + usage.Migrate(); + + Dependencies.Cache(rulesets = new RulesetStore(factory)); + Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, null, host, Beatmap.Default)); + Dependencies.Cache(new OsuConfigManager(LocalStorage)); + + Beatmap.SetDefault(); + } + + [SetUp] + public virtual void SetUp() + { + Schedule(() => + { + manager.Delete(manager.GetAllUsableBeatmapSets()); + var temp = TestResources.GetTestBeatmapForImport(); + manager.Import(temp); + Child = screenStackContainer = new ScreenStackCacheContainer { RelativeSizeAxes = Axes.Both }; + screenStackContainer.ScreenStack.Push(songSelect = new DummySongSelect()); + }); + } + + /// + /// Check if properly triggers background dim previews when a user hovers over the visual settings panel. + /// + [Test] + public void PlayerLoaderSettingsHoverTest() + { + setupUserSettings(); + AddStep("Start player loader", () => songSelect.Push(playerLoader = new DimAccessiblePlayerLoader(player = new DimAccessiblePlayer()))); + AddUntilStep(() => playerLoader?.IsLoaded ?? false, "Wait for Player Loader to load"); + AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent()); + AddStep("Trigger background preview", () => + { + InputManager.MoveMouseTo(playerLoader.ScreenPos); + InputManager.MoveMouseTo(playerLoader.VisualSettingsPos); + }); + waitForDim(); + AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed()); + AddStep("Stop background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos)); + waitForDim(); + AddAssert("Screen is undimmed", () => songSelect.IsBackgroundUndimmed()); + } + + /// + /// In the case of a user triggering the dim preview the instant player gets loaded, then moving the cursor off of the visual settings: + /// The OnHover of PlayerLoader will trigger, which could potentially trigger an undim unless checked for in PlayerLoader. + /// We need to check that in this scenario, the dim is still properly applied after entering player. + /// + [Test] + public void PlayerLoaderTransitionTest() + { + performFullSetup(); + AddStep("Trigger hover event", () => playerLoader.TriggerOnHover()); + AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent()); + waitForDim(); + AddAssert("Screen is dimmed and unblurred", () => songSelect.IsBackgroundDimmed() && songSelect.IsBackgroundUnblurred()); + } + + /// + /// Make sure the background is fully invisible (Alpha == 0) when the background should be disabled by the storyboard. + /// + [Test] + public void StoryboardBackgroundVisibilityTest() + { + performFullSetup(); + createFakeStoryboard(); + AddStep("Storyboard Enabled", () => + { + player.ReplacesBackground.Value = true; + player.StoryboardEnabled.Value = true; + }); + waitForDim(); + AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.IsStoryboardVisible()); + AddStep("Storyboard Disabled", () => + { + player.ReplacesBackground.Value = false; + player.StoryboardEnabled.Value = false; + }); + waitForDim(); + AddAssert("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && player.IsStoryboardInvisible()); + } + + /// + /// When exiting player, the screen that it suspends/exits to needs to have a fully visible (Alpha == 1) background. + /// + [Test] + public void StoryboardTransitionTest() + { + performFullSetup(); + createFakeStoryboard(); + AddStep("Exit to song select", () => player.Exit()); + waitForDim(); + AddAssert("Background is visible", () => songSelect.IsBackgroundVisible()); + } + + /// + /// Check if the is properly accepting user dim changes at all. + /// + [Test] + public void DisableUserDimTest() + { + performFullSetup(); + waitForDim(); + AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed()); + AddStep("EnableUserDim disabled", () => songSelect.DimEnabled.Value = false); + waitForDim(); + AddAssert("Screen is undimmed", () => songSelect.IsBackgroundUndimmed()); + AddStep("EnableUserDim enabled", () => songSelect.DimEnabled.Value = true); + waitForDim(); + AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed()); + } + + /// + /// Check if the fade container retains dim when pausing + /// + [Test] + public void PauseTest() + { + performFullSetup(true); + AddStep("Pause", () => player.CurrentPauseContainer.Pause()); + waitForDim(); + AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed()); + AddStep("Unpause", () => player.CurrentPauseContainer.Resume()); + waitForDim(); + AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed()); + } + + /// + /// Check if the fade container removes user dim when suspending for + /// + [Test] + public void TransitionTest() + { + performFullSetup(); + AddStep("Transition to Results", () => player.Push(new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } }))); + waitForDim(); + AddAssert("Screen is undimmed and is original background", () => songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent()); + } + + /// + /// Check if background gets undimmed when leaving for + /// + [Test] + public void TransitionOutTest() + { + performFullSetup(); + AddStep("Exit to song select", () => player.Exit()); + waitForDim(); + AddAssert("Screen is undimmed", () => songSelect.IsBackgroundUndimmed()); + } + + private void waitForDim() => AddWaitStep(5, "Wait for dim"); + + private void createFakeStoryboard() => AddStep("Create storyboard", () => + { + player.StoryboardEnabled.Value = false; + player.ReplacesBackground.Value = false; + player.CurrentStoryboardContainer.Add(new SpriteText + { + Size = new Vector2(250, 50), + Alpha = 1, + Colour = Color4.Tomato, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Text = "THIS IS A STORYBOARD", + }); + }); + + private void performFullSetup(bool allowPause = false) + { + setupUserSettings(); + + AddStep("Start player loader", () => + { + songSelect.Push(playerLoader = new DimAccessiblePlayerLoader(player = new DimAccessiblePlayer + { + AllowPause = allowPause, + Ready = true, + })); + }); + AddUntilStep(() => playerLoader.IsLoaded, "Wait for Player Loader to load"); + AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos)); + AddUntilStep(() => player.IsLoaded, "Wait for player to load"); + } + + private void setupUserSettings() + { + AddUntilStep(() => songSelect.Carousel.SelectedBeatmap != null, "Song select has selection"); + AddStep("Set default user settings", () => + { + Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { new OsuModNoFail() }); + songSelect.DimLevel.Value = 0.7f; + songSelect.BlurLevel.Value = 0.0f; + }); + } + + private class DummySongSelect : PlaySongSelect + { + protected override BackgroundScreen CreateBackground() + { + FadeAccessibleBackground background = new FadeAccessibleBackground(Beatmap.Value); + DimEnabled.BindTo(background.EnableUserDim); + return background; + } + + public readonly Bindable DimEnabled = new Bindable(); + public readonly Bindable DimLevel = new Bindable(); + public readonly Bindable BlurLevel = new Bindable(); + + public new BeatmapCarousel Carousel => base.Carousel; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + config.BindWith(OsuSetting.DimLevel, DimLevel); + config.BindWith(OsuSetting.BlurLevel, BlurLevel); + } + + public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1 - (float)DimLevel.Value); + + public bool IsBackgroundUnblurred() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(0); + + public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).CurrentColour == Color4.White; + + public bool IsBackgroundInvisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 0; + + public bool IsBackgroundVisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 1; + + /// + /// Make sure every time a screen gets pushed, the background doesn't get replaced + /// + /// Whether or not the original background (The one created in DummySongSelect) is still the current background + public bool IsBackgroundCurrent() => ((FadeAccessibleBackground)Background).IsCurrentScreen(); + } + + private class FadeAccessibleResults : SoloResults + { + public FadeAccessibleResults(ScoreInfo score) + : base(score) + { + } + + protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); + } + + private class DimAccessiblePlayer : Player + { + protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); + + protected override UserDimContainer CreateStoryboardContainer() + { + return new TestUserDimContainer(true) + { + RelativeSizeAxes = Axes.Both, + Alpha = 1, + EnableUserDim = { Value = true } + }; + } + + public PauseContainer CurrentPauseContainer => PauseContainer; + + public UserDimContainer CurrentStoryboardContainer => StoryboardContainer; + + // Whether or not the player should be allowed to load. + public bool Ready; + + public Bindable StoryboardEnabled; + public readonly Bindable ReplacesBackground = new Bindable(); + public readonly Bindable IsPaused = new Bindable(); + + public bool IsStoryboardVisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha == 1; + + public bool IsStoryboardInvisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha <= 1; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + while (!Ready) + Thread.Sleep(1); + StoryboardEnabled = config.GetBindable(OsuSetting.ShowStoryboard); + ReplacesBackground.BindTo(Background.StoryboardReplacesBackground); + RulesetContainer.IsPaused.BindTo(IsPaused); + } + } + + private class ScreenStackCacheContainer : Container + { + [Cached] + private BackgroundScreenStack backgroundScreenStack; + + public readonly ScreenStack ScreenStack; + + public ScreenStackCacheContainer() + { + Add(backgroundScreenStack = new BackgroundScreenStack { RelativeSizeAxes = Axes.Both }); + Add(ScreenStack = new ScreenStack { RelativeSizeAxes = Axes.Both }); + } + } + + private class DimAccessiblePlayerLoader : PlayerLoader + { + public VisualSettings VisualSettingsPos => VisualSettings; + public BackgroundScreen ScreenPos => Background; + + public DimAccessiblePlayerLoader(Player player) + : base(() => player) + { + } + + public void TriggerOnHover() => OnHover(new HoverEvent(new InputState())); + + protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); + } + + private class FadeAccessibleBackground : BackgroundScreenBeatmap + { + protected override UserDimContainer CreateFadeContainer() => fadeContainer = new TestUserDimContainer { RelativeSizeAxes = Axes.Both }; + + public Color4 CurrentColour => fadeContainer.CurrentColour; + public float CurrentAlpha => fadeContainer.CurrentAlpha; + + public Vector2 CurrentBlur => Background.BlurSigma; + + private TestUserDimContainer fadeContainer; + + public FadeAccessibleBackground(WorkingBeatmap beatmap) + : base(beatmap) + { + } + } + + private class TestUserDimContainer : UserDimContainer + { + public Color4 CurrentColour => DimContainer.Colour; + public float CurrentAlpha => DimContainer.Alpha; + + public TestUserDimContainer(bool isStoryboard = false) + : base(isStoryboard) + { + } + } + } +} diff --git a/osu.Game.Tests/Visual/TestCaseBeatSyncedContainer.cs b/osu.Game.Tests/Visual/TestCaseBeatSyncedContainer.cs index 85ef5963a5..2fd8d467f6 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatSyncedContainer.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatSyncedContainer.cs @@ -15,6 +15,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Overlays; using osuTK.Graphics; using osu.Framework.Lists; +using osu.Game.Graphics; namespace osu.Game.Tests.Visual { @@ -140,6 +141,7 @@ namespace osu.Game.Tests.Visual } private SortedList timingPoints => Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints; + private TimingControlPoint getNextTimingPoint(TimingControlPoint current) { if (timingPoints[timingPoints.Count - 1] == current) @@ -189,15 +191,15 @@ namespace osu.Game.Tests.Visual public double Value { - set { valueText.Text = $"{value:G}"; } + set => valueText.Text = $"{value:G}"; } public InfoString(string header) { AutoSizeAxes = Axes.Both; Direction = FillDirection.Horizontal; - Add(new OsuSpriteText { Text = header + @": ", TextSize = text_size }); - Add(valueText = new OsuSpriteText { TextSize = text_size }); + Add(new OsuSpriteText { Text = header + @": ", Font = OsuFont.GetFont(size: text_size) }); + Add(valueText = new OsuSpriteText { Font = OsuFont.GetFont(size: text_size) }); Margin = new MarginPadding(margin); } } diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs b/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs index e61bca9846..618d8376c0 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs @@ -147,9 +147,10 @@ namespace osu.Game.Tests.Visual private bool selectedBeatmapVisible() { - var currentlySelected = carousel.Items.Find(s => s.Item is CarouselBeatmap && s.Item.State == CarouselItemState.Selected); + var currentlySelected = carousel.Items.Find(s => s.Item is CarouselBeatmap && s.Item.State.Value == CarouselItemState.Selected); if (currentlySelected == null) return true; + return currentlySelected.Item.Visible; } @@ -166,8 +167,7 @@ namespace osu.Game.Tests.Visual carousel.Filter(new FilterCriteria { SearchText = "Dingo" }, false); carousel.Filter(new FilterCriteria(), false); eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID); - } - ); + }); } /// @@ -522,6 +522,7 @@ namespace osu.Game.Tests.Visual } }); } + return toReturn; } diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapDetails.cs b/osu.Game.Tests/Visual/TestCaseBeatmapDetails.cs index bc4f89ac26..84af6453f5 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapDetails.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapDetails.cs @@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual Padding = new MarginPadding(150), }); - AddStep("beatmap all metrics", () => details.Beatmap = new BeatmapInfo + AddStep("all metrics", () => details.Beatmap = new BeatmapInfo { Version = "All Metrics", Metadata = new BeatmapMetadata @@ -45,7 +45,30 @@ namespace osu.Game.Tests.Visual }, }); - AddStep("beatmap ratings", () => details.Beatmap = new BeatmapInfo + AddStep("all except source", () => details.Beatmap = new BeatmapInfo + { + Version = "All Metrics", + Metadata = new BeatmapMetadata + { + Tags = "this beatmap has all the metrics", + }, + BaseDifficulty = new BeatmapDifficulty + { + CircleSize = 7, + DrainRate = 1, + OverallDifficulty = 5.7f, + ApproachRate = 3.5f, + }, + StarDifficulty = 5.3f, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 11), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }); + + AddStep("ratings", () => details.Beatmap = new BeatmapInfo { Version = "Only Ratings", Metadata = new BeatmapMetadata @@ -67,7 +90,7 @@ namespace osu.Game.Tests.Visual }, }); - AddStep("beatmap fails retries", () => details.Beatmap = new BeatmapInfo + AddStep("fails retries", () => details.Beatmap = new BeatmapInfo { Version = "Only Retries and Fails", Metadata = new BeatmapMetadata @@ -90,7 +113,7 @@ namespace osu.Game.Tests.Visual }, }); - AddStep("beatmap no metrics", () => details.Beatmap = new BeatmapInfo + AddStep("no metrics", () => details.Beatmap = new BeatmapInfo { Version = "No Metrics", Metadata = new BeatmapMetadata diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs b/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs index d3056f0b13..31bb8b64a3 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs @@ -50,7 +50,7 @@ namespace osu.Game.Tests.Visual AddStep("show", () => { infoWedge.State = Visibility.Visible; - infoWedge.Beatmap = Beatmap; + infoWedge.Beatmap = Beatmap.Value; }); // select part is redundant, but wait for load isn't diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs b/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs index 321a38d087..6ad11ae6c4 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapScoresContainer.cs @@ -160,7 +160,8 @@ namespace osu.Game.Tests.Visual Accuracy = 0.6543, }, }; - foreach(var s in scores) + + foreach (var s in scores) { s.Statistics.Add(HitResult.Great, RNG.Next(2000)); s.Statistics.Add(HitResult.Good, RNG.Next(2000)); diff --git a/osu.Game.Tests/Visual/TestCaseChannelTabControl.cs b/osu.Game.Tests/Visual/TestCaseChannelTabControl.cs index 6e60eb3306..749303b1bb 100644 --- a/osu.Game.Tests/Visual/TestCaseChannelTabControl.cs +++ b/osu.Game.Tests/Visual/TestCaseChannelTabControl.cs @@ -69,7 +69,7 @@ namespace osu.Game.Tests.Visual }); channelTabControl.OnRequestLeave += channel => channelTabControl.RemoveChannel(channel); - channelTabControl.Current.ValueChanged += channel => currentText.Text = "Currently selected channel: " + channel.ToString(); + channelTabControl.Current.ValueChanged += channel => currentText.Text = "Currently selected channel: " + channel.NewValue.ToString(); AddStep("Add random private channel", addRandomPrivateChannel); AddAssert("There is only one channels", () => channelTabControl.Items.Count() == 2); diff --git a/osu.Game.Tests/Visual/TestCaseChatLink.cs b/osu.Game.Tests/Visual/TestCaseChatLink.cs index f119e6dc24..b2ec2c9b47 100644 --- a/osu.Game.Tests/Visual/TestCaseChatLink.cs +++ b/osu.Game.Tests/Visual/TestCaseChatLink.cs @@ -13,10 +13,10 @@ using System; using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using osu.Framework.Bindables; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Overlays; -using osu.Framework.Configuration; namespace osu.Game.Tests.Visual { @@ -56,7 +56,7 @@ namespace osu.Game.Tests.Visual var chatManager = new ChannelManager(); BindableList availableChannels = (BindableList)chatManager.AvailableChannels; - availableChannels.Add(new Channel { Name = "#english"}); + availableChannels.Add(new Channel { Name = "#english" }); availableChannels.Add(new Channel { Name = "#japanese" }); Dependencies.Cache(chatManager); @@ -96,7 +96,7 @@ namespace osu.Game.Tests.Visual return true; } - bool isItalic() => newLine.ContentFlow.Where(d => d is OsuSpriteText).Cast().All(sprite => sprite.Font == "Exo2.0-MediumItalic"); + bool isItalic() => newLine.ContentFlow.Where(d => d is OsuSpriteText).Cast().All(sprite => sprite.Font.Italics); bool isShowingLinks() { diff --git a/osu.Game.Tests/Visual/TestCaseContextMenu.cs b/osu.Game.Tests/Visual/TestCaseContextMenu.cs index f969ec69e2..5cbe97e21d 100644 --- a/osu.Game.Tests/Visual/TestCaseContextMenu.cs +++ b/osu.Game.Tests/Visual/TestCaseContextMenu.cs @@ -61,10 +61,10 @@ namespace osu.Game.Tests.Visual // Move box along a square trajectory container.Loop(c => c - .MoveTo(new Vector2(0, 100), duration).Then() - .MoveTo(new Vector2(100, 100), duration).Then() - .MoveTo(new Vector2(100, 0), duration).Then() - .MoveTo(Vector2.Zero, duration) + .MoveTo(new Vector2(0, 100), duration).Then() + .MoveTo(new Vector2(100, 100), duration).Then() + .MoveTo(new Vector2(100, 0), duration).Then() + .MoveTo(Vector2.Zero, duration) ); } diff --git a/osu.Game.Tests/Visual/TestCaseDrawableDate.cs b/osu.Game.Tests/Visual/TestCaseDrawableDate.cs index 839f2a82de..8d2182dd78 100644 --- a/osu.Game.Tests/Visual/TestCaseDrawableDate.cs +++ b/osu.Game.Tests/Visual/TestCaseDrawableDate.cs @@ -60,7 +60,7 @@ namespace osu.Game.Tests.Visual } }; - drawableDate.Current.ValueChanged += v => flash.FadeOutFromOne(500); + drawableDate.Current.ValueChanged += _ => flash.FadeOutFromOne(500); } } } diff --git a/osu.Game.Tests/Visual/TestCaseEditorCompose.cs b/osu.Game.Tests/Visual/TestCaseEditorCompose.cs index 66e13545d9..a52454d684 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorCompose.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorCompose.cs @@ -19,7 +19,7 @@ namespace osu.Game.Tests.Visual [BackgroundDependencyLoader] private void load() { - Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo); + Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo, Clock); Child = new ComposeScreen(); } } diff --git a/osu.Game.Tests/Visual/TestCaseEditorComposeTimeline.cs b/osu.Game.Tests/Visual/TestCaseEditorComposeTimeline.cs index a2f40f1903..9ae9b55546 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorComposeTimeline.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorComposeTimeline.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osuTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs b/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs index 6cb9a1abfd..0ec87e6f52 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs @@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual { TimingPoints = { - new TimingControlPoint { Time = 0, BeatLength = 200}, + new TimingControlPoint { Time = 0, BeatLength = 200 }, new TimingControlPoint { Time = 100, BeatLength = 400 }, new TimingControlPoint { Time = 175, BeatLength = 800 }, new TimingControlPoint { Time = 350, BeatLength = 200 }, @@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual } }; - Beatmap.Value = new TestWorkingBeatmap(testBeatmap); + Beatmap.Value = new TestWorkingBeatmap(testBeatmap, Clock); Child = new TimingPointVisualiser(testBeatmap, 5000) { Clock = Clock }; } diff --git a/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs b/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs index b952582ef2..305924958b 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs @@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual [BackgroundDependencyLoader] private void load() { - Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo); + Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo, null); Add(new SummaryTimeline { diff --git a/osu.Game.Tests/Visual/TestCaseGameplayMenuOverlay.cs b/osu.Game.Tests/Visual/TestCaseGameplayMenuOverlay.cs index c5abe03dbd..a21573236a 100644 --- a/osu.Game.Tests/Visual/TestCaseGameplayMenuOverlay.cs +++ b/osu.Game.Tests/Visual/TestCaseGameplayMenuOverlay.cs @@ -76,7 +76,7 @@ namespace osu.Game.Tests.Visual AddStep("Hover first button", () => InputManager.MoveMouseTo(failOverlay.Buttons.First())); AddStep("Hide overlay", () => failOverlay.Hide()); - AddAssert("Overlay state is reset", () => !failOverlay.Buttons.Any(b => b.Selected)); + AddAssert("Overlay state is reset", () => !failOverlay.Buttons.Any(b => b.Selected.Value)); } private void press(Key key) @@ -106,7 +106,7 @@ namespace osu.Game.Tests.Visual AddStep("Show overlay", () => pauseOverlay.Show()); AddStep("Up arrow", () => press(Key.Up)); - AddAssert("Last button selected", () => pauseOverlay.Buttons.Last().Selected); + AddAssert("Last button selected", () => pauseOverlay.Buttons.Last().Selected.Value); AddStep("Hide overlay", () => pauseOverlay.Hide()); } @@ -119,7 +119,7 @@ namespace osu.Game.Tests.Visual AddStep("Show overlay", () => pauseOverlay.Show()); AddStep("Down arrow", () => press(Key.Down)); - AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected); + AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected.Value); AddStep("Hide overlay", () => pauseOverlay.Hide()); } @@ -132,11 +132,11 @@ namespace osu.Game.Tests.Visual AddStep("Show overlay", () => failOverlay.Show()); AddStep("Up arrow", () => press(Key.Up)); - AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected); + AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value); AddStep("Up arrow", () => press(Key.Up)); - AddAssert("First button selected", () => failOverlay.Buttons.First().Selected); + AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value); AddStep("Up arrow", () => press(Key.Up)); - AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected); + AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value); AddStep("Hide overlay", () => failOverlay.Hide()); } @@ -149,11 +149,11 @@ namespace osu.Game.Tests.Visual AddStep("Show overlay", () => failOverlay.Show()); AddStep("Down arrow", () => press(Key.Down)); - AddAssert("First button selected", () => failOverlay.Buttons.First().Selected); + AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value); AddStep("Down arrow", () => press(Key.Down)); - AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected); + AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value); AddStep("Down arrow", () => press(Key.Down)); - AddAssert("First button selected", () => failOverlay.Buttons.First().Selected); + AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value); AddStep("Hide overlay", () => failOverlay.Hide()); } @@ -169,8 +169,8 @@ namespace osu.Game.Tests.Visual AddStep("Down arrow", () => press(Key.Down)); AddStep("Hover second button", () => InputManager.MoveMouseTo(secondButton)); - AddAssert("First button not selected", () => !pauseOverlay.Buttons.First().Selected); - AddAssert("Second button selected", () => secondButton.Selected); + AddAssert("First button not selected", () => !pauseOverlay.Buttons.First().Selected.Value); + AddAssert("Second button selected", () => secondButton.Selected.Value); AddStep("Hide overlay", () => pauseOverlay.Hide()); } @@ -190,8 +190,8 @@ namespace osu.Game.Tests.Visual AddStep("Hover second button", () => InputManager.MoveMouseTo(secondButton)); AddStep("Up arrow", () => press(Key.Up)); - AddAssert("Second button not selected", () => !secondButton.Selected); - AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected); + AddAssert("Second button not selected", () => !secondButton.Selected.Value); + AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected.Value); AddStep("Hide overlay", () => pauseOverlay.Hide()); } @@ -208,7 +208,7 @@ namespace osu.Game.Tests.Visual AddStep("Hover second button", () => InputManager.MoveMouseTo(secondButton)); AddStep("Unhover second button", () => InputManager.MoveMouseTo(Vector2.Zero)); AddStep("Down arrow", () => press(Key.Down)); - AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected); // Initial state condition + AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected.Value); // Initial state condition AddStep("Hide overlay", () => pauseOverlay.Hide()); } @@ -265,6 +265,7 @@ namespace osu.Game.Tests.Visual pauseOverlay.OnRetry = lastAction; lastAction = null; } + return triggered; }); AddAssert("Overlay is closed", () => pauseOverlay.State == Visibility.Hidden); diff --git a/osu.Game.Tests/Visual/TestCaseHoldToConfirmOverlay.cs b/osu.Game.Tests/Visual/TestCaseHoldToConfirmOverlay.cs index 046bd76f7e..f66bf34875 100644 --- a/osu.Game.Tests/Visual/TestCaseHoldToConfirmOverlay.cs +++ b/osu.Game.Tests/Visual/TestCaseHoldToConfirmOverlay.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using osu.Framework.Graphics; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Screens.Menu; @@ -22,7 +23,7 @@ namespace osu.Game.Tests.Visual Anchor = Anchor.Centre, Origin = Anchor.Centre, Text = "Fired!", - TextSize = 50, + Font = OsuFont.GetFont(size: 50), Alpha = 0, }; diff --git a/osu.Game.Tests/Visual/TestCaseIdleTracker.cs b/osu.Game.Tests/Visual/TestCaseIdleTracker.cs index ea669af28c..8e8c4e38ae 100644 --- a/osu.Game.Tests/Visual/TestCaseIdleTracker.cs +++ b/osu.Game.Tests/Visual/TestCaseIdleTracker.cs @@ -128,7 +128,7 @@ namespace osu.Game.Tests.Visual }, }; - idleTracker.IsIdle.BindValueChanged(idle => box.Colour = idle ? Color4.White : Color4.Black, true); + idleTracker.IsIdle.BindValueChanged(idle => box.Colour = idle.NewValue ? Color4.White : Color4.Black, true); } } } diff --git a/osu.Game.Tests/Visual/TestCaseLeaderboard.cs b/osu.Game.Tests/Visual/TestCaseLeaderboard.cs index 822809b96e..eb1a2c0249 100644 --- a/osu.Game.Tests/Visual/TestCaseLeaderboard.cs +++ b/osu.Game.Tests/Visual/TestCaseLeaderboard.cs @@ -20,7 +20,8 @@ namespace osu.Game.Tests.Visual [Description("PlaySongSelect leaderboard")] public class TestCaseLeaderboard : OsuTestCase { - public override IReadOnlyList RequiredTypes => new[] { + public override IReadOnlyList RequiredTypes => new[] + { typeof(Placeholder), typeof(MessagePlaceholder), typeof(RetrievalFailurePlaceholder), diff --git a/osu.Game.Tests/Visual/TestCaseLoungeRoomsContainer.cs b/osu.Game.Tests/Visual/TestCaseLoungeRoomsContainer.cs index c87b91003b..13bc5e24d9 100644 --- a/osu.Game.Tests/Visual/TestCaseLoungeRoomsContainer.cs +++ b/osu.Game.Tests/Visual/TestCaseLoungeRoomsContainer.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Graphics; using osu.Game.Online.Multiplayer; diff --git a/osu.Game.Tests/Visual/TestCaseMatchHostInfo.cs b/osu.Game.Tests/Visual/TestCaseMatchHostInfo.cs index fabeb0aaa4..45092c5b93 100644 --- a/osu.Game.Tests/Visual/TestCaseMatchHostInfo.cs +++ b/osu.Game.Tests/Visual/TestCaseMatchHostInfo.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Screens.Multi.Match.Components; using osu.Game.Users; diff --git a/osu.Game.Tests/Visual/TestCaseMatchSettingsOverlay.cs b/osu.Game.Tests/Visual/TestCaseMatchSettingsOverlay.cs index 317707a77e..a320fc88fa 100644 --- a/osu.Game.Tests/Visual/TestCaseMatchSettingsOverlay.cs +++ b/osu.Game.Tests/Visual/TestCaseMatchSettingsOverlay.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; @@ -52,16 +52,16 @@ namespace osu.Game.Tests.Visual Room.Playlist.Clear(); }); - AddAssert("button disabled", () => !settings.ApplyButton.Enabled); + AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value); AddStep("set name", () => Room.Name.Value = "Room name"); - AddAssert("button disabled", () => !settings.ApplyButton.Enabled); + AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value); AddStep("set beatmap", () => Room.Playlist.Add(new PlaylistItem { Beatmap = new DummyWorkingBeatmap().BeatmapInfo })); - AddAssert("button enabled", () => settings.ApplyButton.Enabled); + AddAssert("button enabled", () => settings.ApplyButton.Enabled.Value); AddStep("clear name", () => Room.Name.Value = ""); - AddAssert("button disabled", () => !settings.ApplyButton.Enabled); + AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value); } [Test] diff --git a/osu.Game.Tests/Visual/TestCaseMods.cs b/osu.Game.Tests/Visual/TestCaseMods.cs index e0c0b419af..99bc10d8cc 100644 --- a/osu.Game.Tests/Visual/TestCaseMods.cs +++ b/osu.Game.Tests/Visual/TestCaseMods.cs @@ -13,7 +13,7 @@ using osu.Game.Rulesets.Osu.Mods; using System.Linq; using System.Collections.Generic; using NUnit.Framework; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Mods.Sections; diff --git a/osu.Game.Tests/Visual/TestCaseMultiScreen.cs b/osu.Game.Tests/Visual/TestCaseMultiScreen.cs index fc4037f58b..804e3c5b1f 100644 --- a/osu.Game.Tests/Visual/TestCaseMultiScreen.cs +++ b/osu.Game.Tests/Visual/TestCaseMultiScreen.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using NUnit.Framework; -using osu.Framework.Screens; using osu.Game.Screens.Multi; using osu.Game.Screens.Multi.Lounge; using osu.Game.Screens.Multi.Lounge.Components; @@ -26,8 +25,6 @@ namespace osu.Game.Tests.Visual Multiplayer multi = new Multiplayer(); AddStep(@"show", () => LoadScreen(multi)); - AddWaitStep(5); - AddStep(@"exit", multi.Exit); } } } diff --git a/osu.Game.Tests/Visual/TestCaseNotificationOverlay.cs b/osu.Game.Tests/Visual/TestCaseNotificationOverlay.cs index 109c2ed916..d6a3361cf2 100644 --- a/osu.Game.Tests/Visual/TestCaseNotificationOverlay.cs +++ b/osu.Game.Tests/Visual/TestCaseNotificationOverlay.cs @@ -47,7 +47,7 @@ namespace osu.Game.Tests.Visual void setState(Visibility state) => AddStep(state.ToString(), () => manager.State = state); void checkProgressingCount(int expected) => AddAssert($"progressing count is {expected}", () => progressingNotifications.Count == expected); - manager.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count}"; }; + manager.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count.NewValue}"; }; setState(Visibility.Visible); AddStep(@"simple #1", sendHelloNotification); diff --git a/osu.Game.Tests/Visual/TestCaseOsuGame.cs b/osu.Game.Tests/Visual/TestCaseOsuGame.cs index c527bce683..9e649b92e4 100644 --- a/osu.Game.Tests/Visual/TestCaseOsuGame.cs +++ b/osu.Game.Tests/Visual/TestCaseOsuGame.cs @@ -4,10 +4,10 @@ using System; using System.Collections.Generic; using NUnit.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; -using osu.Framework.Screens; -using osu.Game.Screens; +using osu.Framework.Platform; using osu.Game.Screens.Menu; using osuTK.Graphics; @@ -21,8 +21,12 @@ namespace osu.Game.Tests.Visual typeof(OsuLogo), }; - public TestCaseOsuGame() + [BackgroundDependencyLoader] + private void load(GameHost host) { + OsuGame game = new OsuGame(); + game.SetHost(host); + Children = new Drawable[] { new Box @@ -30,10 +34,7 @@ namespace osu.Game.Tests.Visual RelativeSizeAxes = Axes.Both, Colour = Color4.Black, }, - new ScreenStack(new Loader()) - { - RelativeSizeAxes = Axes.Both, - } + game }; } } diff --git a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs index 78e90987b1..5fa818472c 100644 --- a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs @@ -8,7 +8,7 @@ using System.Linq; using System.Text; using NUnit.Framework; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions; using osu.Framework.MathUtils; using osu.Framework.Platform; @@ -187,8 +187,8 @@ namespace osu.Game.Tests.Visual AddAssert("mods changed before ruleset", () => modChangeIndex < rulesetChangeIndex); AddAssert("empty mods", () => !selectedMods.Value.Any()); - void onModChange(IEnumerable mods) => modChangeIndex = actionIndex++; - void onRulesetChange(RulesetInfo ruleset) => rulesetChangeIndex = actionIndex--; + void onModChange(ValueChangedEvent> e) => modChangeIndex = actionIndex++; + void onRulesetChange(ValueChangedEvent e) => rulesetChangeIndex = actionIndex--; } [Test] diff --git a/osu.Game.Tests/Visual/TestCasePlaybackControl.cs b/osu.Game.Tests/Visual/TestCasePlaybackControl.cs index 15b96d394a..abcff24c67 100644 --- a/osu.Game.Tests/Visual/TestCasePlaybackControl.cs +++ b/osu.Game.Tests/Visual/TestCasePlaybackControl.cs @@ -26,10 +26,10 @@ namespace osu.Game.Tests.Visual { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Size = new Vector2(200,100) + Size = new Vector2(200, 100) }; - Beatmap.Value = new TestWorkingBeatmap(new Beatmap()); + Beatmap.Value = new TestWorkingBeatmap(new Beatmap(), Clock); Child = playback; } diff --git a/osu.Game.Tests/Visual/TestCasePlayerLoader.cs b/osu.Game.Tests/Visual/TestCasePlayerLoader.cs index 16cb94c65e..244f553e97 100644 --- a/osu.Game.Tests/Visual/TestCasePlayerLoader.cs +++ b/osu.Game.Tests/Visual/TestCasePlayerLoader.cs @@ -6,6 +6,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Screens; using osu.Game.Beatmaps; +using osu.Game.Screens; using osu.Game.Screens.Play; namespace osu.Game.Tests.Visual @@ -13,15 +14,22 @@ namespace osu.Game.Tests.Visual public class TestCasePlayerLoader : ManualInputManagerTestCase { private PlayerLoader loader; - private ScreenStack stack; + private readonly ScreenStack stack; + + [Cached] + private BackgroundScreenStack backgroundStack; + + public TestCasePlayerLoader() + { + InputManager.Add(backgroundStack = new BackgroundScreenStack { RelativeSizeAxes = Axes.Both }); + InputManager.Add(stack = new ScreenStack { RelativeSizeAxes = Axes.Both }); + } [BackgroundDependencyLoader] private void load(OsuGameBase game) { Beatmap.Value = new DummyWorkingBeatmap(game); - InputManager.Add(stack = new ScreenStack { RelativeSizeAxes = Axes.Both }); - AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => new Player { AllowPause = false, diff --git a/osu.Game.Tests/Visual/TestCasePollingComponent.cs b/osu.Game.Tests/Visual/TestCasePollingComponent.cs index 68c44c7758..63f4f88948 100644 --- a/osu.Game.Tests/Visual/TestCasePollingComponent.cs +++ b/osu.Game.Tests/Visual/TestCasePollingComponent.cs @@ -56,6 +56,7 @@ namespace osu.Game.Tests.Visual }); [Test] + [Ignore("polling is threaded, and it's very hard to hook into it correctly")] public void TestInstantPolling() { createPoller(true); @@ -106,8 +107,11 @@ namespace osu.Game.Tests.Visual private void checkCount(int checkValue) { - Logger.Log($"value is {count}"); - AddAssert($"count is {checkValue}", () => count == checkValue); + AddAssert($"count is {checkValue}", () => + { + Logger.Log($"value is {count}"); + return count == checkValue; + }); } private void createPoller(bool instant) => AddStep("create poller", () => diff --git a/osu.Game.Tests/Visual/TestCaseScoreCounter.cs b/osu.Game.Tests/Visual/TestCaseScoreCounter.cs index e4e80e4017..3519ea67a6 100644 --- a/osu.Game.Tests/Visual/TestCaseScoreCounter.cs +++ b/osu.Game.Tests/Visual/TestCaseScoreCounter.cs @@ -74,7 +74,7 @@ namespace osu.Game.Tests.Visual AddStep(@"Hit! :D", delegate { - score.Current.Value += 300 + (ulong)(300.0 * (comboCounter.Current > 0 ? comboCounter.Current - 1 : 0) / 25.0); + score.Current.Value += 300 + (ulong)(300.0 * (comboCounter.Current.Value > 0 ? comboCounter.Current.Value - 1 : 0) / 25.0); comboCounter.Increment(); numerator++; denominator++; diff --git a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs index 7202861833..204f4a493d 100644 --- a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs +++ b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs @@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual }, }; - breadcrumbs.Current.ValueChanged += s => titleText.Text = $"Changed to {s.ToString()}"; + breadcrumbs.Current.ValueChanged += screen => titleText.Text = $"Changed to {screen.NewValue.ToString()}"; breadcrumbs.Current.TriggerChange(); waitForCurrent(); @@ -84,7 +84,7 @@ namespace osu.Game.Tests.Visual public TestScreen PushNext() { TestScreen screen = CreateNextScreen(); - this.Push(screen); + this.Push(screen); return screen; } diff --git a/osu.Game.Tests/Visual/TestCaseSkinReloadable.cs b/osu.Game.Tests/Visual/TestCaseSkinReloadable.cs new file mode 100644 index 0000000000..94f01e9d32 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseSkinReloadable.cs @@ -0,0 +1,153 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using NUnit.Framework; +using osu.Framework.Audio.Sample; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Game.Graphics; +using osu.Game.Skinning; +using osuTK.Graphics; + +namespace osu.Game.Tests.Visual +{ + public class TestCaseSkinReloadable : OsuTestCase + { + [Test] + public void TestInitialLoad() + { + var secondarySource = new SecondarySource(); + SkinConsumer consumer = null; + + AddStep("setup layout", () => + { + Child = new SkinSourceContainer + { + RelativeSizeAxes = Axes.Both, + Child = new LocalSkinOverrideContainer(secondarySource) + { + RelativeSizeAxes = Axes.Both, + Child = consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true) + } + }; + }); + + AddAssert("consumer using override source", () => consumer.Drawable is SecondarySourceBox); + AddAssert("skinchanged only called once", () => consumer.SkinChangedCount == 1); + } + + [Test] + public void TestOverride() + { + var secondarySource = new SecondarySource(); + + SkinConsumer consumer = null; + Container target = null; + + AddStep("setup layout", () => + { + Child = new SkinSourceContainer + { + RelativeSizeAxes = Axes.Both, + Child = target = new LocalSkinOverrideContainer(secondarySource) + { + RelativeSizeAxes = Axes.Both, + } + }; + }); + + AddStep("add permissive", () => target.Add(consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true))); + AddAssert("consumer using override source", () => consumer.Drawable is SecondarySourceBox); + AddAssert("skinchanged only called once", () => consumer.SkinChangedCount == 1); + } + + private class NamedBox : Container + { + public NamedBox(string name) + { + Children = new Drawable[] + { + new Box + { + Colour = Color4.Black, + RelativeSizeAxes = Axes.Both, + }, + new SpriteText + { + Font = OsuFont.Default.With(size: 40), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Text = name + } + }; + } + } + + private class SkinConsumer : SkinnableDrawable + { + public new Drawable Drawable => base.Drawable; + public int SkinChangedCount { get; private set; } + + public SkinConsumer(string name, Func defaultImplementation, Func allowFallback = null, bool restrictSize = true) + : base(name, defaultImplementation, allowFallback, restrictSize) + { + } + + protected override void SkinChanged(ISkinSource skin, bool allowFallback) + { + base.SkinChanged(skin, allowFallback); + SkinChangedCount++; + } + } + + private class BaseSourceBox : NamedBox + { + public BaseSourceBox() + : base("Base Source") + { + } + } + + private class SecondarySourceBox : NamedBox + { + public SecondarySourceBox() + : base("Secondary Source") + { + } + } + + private class SecondarySource : ISkinSource + { + public event Action SourceChanged; + + public void TriggerSourceChanged() => SourceChanged?.Invoke(); + + public Drawable GetDrawableComponent(string componentName) => new SecondarySourceBox(); + + public Texture GetTexture(string componentName) => throw new NotImplementedException(); + + public SampleChannel GetSample(string sampleName) => throw new NotImplementedException(); + + public TValue GetValue(Func query) where TConfiguration : SkinConfiguration => throw new NotImplementedException(); + } + + private class SkinSourceContainer : Container, ISkinSource + { + public event Action SourceChanged; + + public void TriggerSourceChanged() => SourceChanged?.Invoke(); + + public Drawable GetDrawableComponent(string componentName) => new BaseSourceBox(); + + public Texture GetTexture(string componentName) => throw new NotImplementedException(); + + public SampleChannel GetSample(string sampleName) => throw new NotImplementedException(); + + public TValue GetValue(Func query) where TConfiguration : SkinConfiguration => throw new NotImplementedException(); + } + } +} diff --git a/osu.Game.Tests/Visual/TestCaseSongProgress.cs b/osu.Game.Tests/Visual/TestCaseSongProgress.cs index 9ce33f21d6..9845df7461 100644 --- a/osu.Game.Tests/Visual/TestCaseSongProgress.cs +++ b/osu.Game.Tests/Visual/TestCaseSongProgress.cs @@ -15,7 +15,7 @@ namespace osu.Game.Tests.Visual public class TestCaseSongProgress : OsuTestCase { private readonly SongProgress progress; - private readonly SongProgressGraph graph; + private readonly TestSongProgressGraph graph; private readonly StopwatchClock clock; @@ -31,7 +31,7 @@ namespace osu.Game.Tests.Visual Origin = Anchor.BottomLeft, }); - Add(graph = new SongProgressGraph + Add(graph = new TestSongProgressGraph { RelativeSizeAxes = Axes.X, Height = 200, @@ -39,13 +39,24 @@ namespace osu.Game.Tests.Visual Origin = Anchor.TopLeft, }); + AddWaitStep(5); + AddAssert("ensure not created", () => graph.CreationCount == 0); + + AddStep("display values", displayNewValues); + AddWaitStep(5); + AddUntilStep(() => graph.CreationCount == 1, "wait for creation count"); + AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking); AddWaitStep(5); + AddUntilStep(() => graph.CreationCount == 1, "wait for creation count"); + AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking); - AddWaitStep(2); + AddWaitStep(5); + AddUntilStep(() => graph.CreationCount == 1, "wait for creation count"); AddRepeatStep("New Values", displayNewValues, 5); - displayNewValues(); + AddWaitStep(5); + AddAssert("ensure debounced", () => graph.CreationCount == 2); } private void displayNewValues() @@ -60,5 +71,16 @@ namespace osu.Game.Tests.Visual progress.AudioClock = clock; progress.OnSeek = pos => clock.Seek(pos); } + + private class TestSongProgressGraph : SongProgressGraph + { + public int CreationCount { get; private set; } + + protected override void RecreateGraph() + { + base.RecreateGraph(); + CreationCount++; + } + } } } diff --git a/osu.Game.Tests/Visual/TestCaseStoryboard.cs b/osu.Game.Tests/Visual/TestCaseStoryboard.cs index a4ad213116..c4b41e40f4 100644 --- a/osu.Game.Tests/Visual/TestCaseStoryboard.cs +++ b/osu.Game.Tests/Visual/TestCaseStoryboard.cs @@ -3,6 +3,7 @@ using NUnit.Framework; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -49,7 +50,10 @@ namespace osu.Game.Tests.Visual }); AddStep("Restart", restart); - AddToggleStep("Passing", passing => { if (storyboard != null) storyboard.Passing = passing; }); + AddToggleStep("Passing", passing => + { + if (storyboard != null) storyboard.Passing = passing; + }); } [BackgroundDependencyLoader] @@ -58,15 +62,15 @@ namespace osu.Game.Tests.Visual Beatmap.ValueChanged += beatmapChanged; } - private void beatmapChanged(WorkingBeatmap working) - => loadStoryboard(working); + private void beatmapChanged(ValueChangedEvent e) + => loadStoryboard(e.NewValue); private void restart() { var track = Beatmap.Value.Track; track.Reset(); - loadStoryboard(Beatmap); + loadStoryboard(Beatmap.Value); track.Start(); } @@ -78,7 +82,7 @@ namespace osu.Game.Tests.Visual var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true }; storyboardContainer.Clock = decoupledClock; - storyboard = working.Storyboard.CreateDrawable(Beatmap); + storyboard = working.Storyboard.CreateDrawable(Beatmap.Value); storyboard.Passing = false; storyboardContainer.Add(storyboard); diff --git a/osu.Game.Tests/Visual/TestCaseTabControl.cs b/osu.Game.Tests/Visual/TestCaseTabControl.cs index 82f56cb0f8..ebf8f3bb30 100644 --- a/osu.Game.Tests/Visual/TestCaseTabControl.cs +++ b/osu.Game.Tests/Visual/TestCaseTabControl.cs @@ -33,9 +33,9 @@ namespace osu.Game.Tests.Visual filter.PinItem(GroupMode.All); filter.PinItem(GroupMode.RecentlyPlayed); - filter.Current.ValueChanged += newFilter => + filter.Current.ValueChanged += grouping => { - text.Text = "Currently Selected: " + newFilter.ToString(); + text.Text = "Currently Selected: " + grouping.NewValue.ToString(); }; } } diff --git a/osu.Game.Tests/Visual/TestCaseUpdateableBeatmapBackgroundSprite.cs b/osu.Game.Tests/Visual/TestCaseUpdateableBeatmapBackgroundSprite.cs index 14f178a293..3ee617e092 100644 --- a/osu.Game.Tests/Visual/TestCaseUpdateableBeatmapBackgroundSprite.cs +++ b/osu.Game.Tests/Visual/TestCaseUpdateableBeatmapBackgroundSprite.cs @@ -3,7 +3,7 @@ using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; diff --git a/osu.Game.Tests/Visual/TestCaseWaveContainer.cs b/osu.Game.Tests/Visual/TestCaseWaveContainer.cs index 56dcfc3cbb..07a282a1a7 100644 --- a/osu.Game.Tests/Visual/TestCaseWaveContainer.cs +++ b/osu.Game.Tests/Visual/TestCaseWaveContainer.cs @@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual { Anchor = Anchor.Centre, Origin = Anchor.Centre, - TextSize = 20, + Font = OsuFont.GetFont(size: 20), Text = @"Wave Container", }, }, diff --git a/osu.Game.Tournament/Screens/Drawings/Components/ScrollingTeamContainer.cs b/osu.Game.Tournament/Screens/Drawings/Components/ScrollingTeamContainer.cs index 5c171a68c0..eb92ba55d0 100644 --- a/osu.Game.Tournament/Screens/Drawings/Components/ScrollingTeamContainer.cs +++ b/osu.Game.Tournament/Screens/Drawings/Components/ScrollingTeamContainer.cs @@ -86,7 +86,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components private ScrollState scrollState { - get { return _scrollState; } + get => _scrollState; set { @@ -326,7 +326,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components public bool Selected { - get { return selected; } + get => selected; set { diff --git a/osu.Game.Tournament/Screens/Drawings/Components/VisualiserContainer.cs b/osu.Game.Tournament/Screens/Drawings/Components/VisualiserContainer.cs index 76aaa2c210..1cd942b987 100644 --- a/osu.Game.Tournament/Screens/Drawings/Components/VisualiserContainer.cs +++ b/osu.Game.Tournament/Screens/Drawings/Components/VisualiserContainer.cs @@ -19,7 +19,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components /// public int Lines { - get { return allLines.Count; } + get => allLines.Count; set { while (value > allLines.Count) diff --git a/osu.Game/Audio/PreviewTrack.cs b/osu.Game/Audio/PreviewTrack.cs index 5abf6bdb08..3b21bdefc4 100644 --- a/osu.Game/Audio/PreviewTrack.cs +++ b/osu.Game/Audio/PreviewTrack.cs @@ -28,6 +28,7 @@ namespace osu.Game.Audio private void load() { track = GetTrack(); + track.Completed += () => Schedule(Stop); } /// @@ -50,15 +51,6 @@ namespace osu.Game.Audio /// public bool IsRunning => track?.IsRunning ?? false; - protected override void Update() - { - base.Update(); - - // Todo: Track currently doesn't signal its completion, so we have to handle it manually - if (hasStarted && track.HasCompleted) - Stop(); - } - private ScheduledDelegate startDelegate; /// @@ -71,6 +63,7 @@ namespace osu.Game.Audio if (hasStarted) return; + hasStarted = true; track.Restart(); @@ -89,6 +82,7 @@ namespace osu.Game.Audio if (!hasStarted) return; + hasStarted = false; track.Stop(); diff --git a/osu.Game/Audio/PreviewTrackManager.cs b/osu.Game/Audio/PreviewTrackManager.cs index 6de7d0e4f7..99c0d70ac9 100644 --- a/osu.Game/Audio/PreviewTrackManager.cs +++ b/osu.Game/Audio/PreviewTrackManager.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Track; +using osu.Framework.Bindables; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.IO.Stores; diff --git a/osu.Game/Audio/SampleInfo.cs b/osu.Game/Audio/SampleInfo.cs index 736caf69e8..5bc6dce60b 100644 --- a/osu.Game/Audio/SampleInfo.cs +++ b/osu.Game/Audio/SampleInfo.cs @@ -50,12 +50,14 @@ namespace osu.Game.Audio { if (!string.IsNullOrEmpty(Suffix)) yield return $"{Namespace}/{Bank}-{Name}{Suffix}"; + yield return $"{Namespace}/{Bank}-{Name}"; } // check non-namespace as a fallback even when we have a namespace if (!string.IsNullOrEmpty(Suffix)) yield return $"{Bank}-{Name}{Suffix}"; + yield return $"{Bank}-{Name}"; } } diff --git a/osu.Game/Beatmaps/BeatmapConverter.cs b/osu.Game/Beatmaps/BeatmapConverter.cs index d6041ad38d..b6fa6674f6 100644 --- a/osu.Game/Beatmaps/BeatmapConverter.cs +++ b/osu.Game/Beatmaps/BeatmapConverter.cs @@ -16,6 +16,7 @@ namespace osu.Game.Beatmaps where T : HitObject { private event Action> ObjectConverted; + event Action> IBeatmapConverter.ObjectConverted { add => ObjectConverted += value; diff --git a/osu.Game/Beatmaps/BeatmapDifficulty.cs b/osu.Game/Beatmaps/BeatmapDifficulty.cs index 21b943e111..8727431e0e 100644 --- a/osu.Game/Beatmaps/BeatmapDifficulty.cs +++ b/osu.Game/Beatmaps/BeatmapDifficulty.cs @@ -48,6 +48,7 @@ namespace osu.Game.Beatmaps return mid + (max - mid) * (difficulty - 5) / 5; if (difficulty < 5) return mid - (mid - min) * (5 - difficulty) / 5; + return mid; } diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 21739f16c2..2b559d5912 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -206,7 +206,17 @@ namespace osu.Game.Beatmaps PostNotification?.Invoke(downloadNotification); // don't run in the main api queue as this is a long-running task. - Task.Factory.StartNew(() => request.Perform(api), TaskCreationOptions.LongRunning); + Task.Factory.StartNew(() => + { + try + { + request.Perform(api); + } + catch (Exception e) + { + // no need to handle here as exceptions will filter down to request.Failure above. + } + }, TaskCreationOptions.LongRunning); BeatmapDownloadBegan?.Invoke(request); return true; } diff --git a/osu.Game/Beatmaps/BeatmapMetadata.cs b/osu.Game/Beatmaps/BeatmapMetadata.cs index bac8ad5ed7..001f319307 100644 --- a/osu.Game/Beatmaps/BeatmapMetadata.cs +++ b/osu.Game/Beatmaps/BeatmapMetadata.cs @@ -34,8 +34,8 @@ namespace osu.Game.Beatmaps [Column("Author")] public string AuthorString { - get { return Author?.Username; } - set { Author = new User { Username = value }; } + get => Author?.Username; + set => Author = new User { Username = value }; } /// @@ -48,6 +48,7 @@ namespace osu.Game.Beatmaps [JsonProperty(@"tags")] public string Tags { get; set; } + public int PreviewTime { get; set; } public string AudioFile { get; set; } public string BackgroundFile { get; set; } @@ -72,15 +73,15 @@ namespace osu.Game.Beatmaps return false; return Title == other.Title - && TitleUnicode == other.TitleUnicode - && Artist == other.Artist - && ArtistUnicode == other.ArtistUnicode - && AuthorString == other.AuthorString - && Source == other.Source - && Tags == other.Tags - && PreviewTime == other.PreviewTime - && AudioFile == other.AudioFile - && BackgroundFile == other.BackgroundFile; + && TitleUnicode == other.TitleUnicode + && Artist == other.Artist + && ArtistUnicode == other.ArtistUnicode + && AuthorString == other.AuthorString + && Source == other.Source + && Tags == other.Tags + && PreviewTime == other.PreviewTime + && AudioFile == other.AudioFile + && BackgroundFile == other.BackgroundFile; } } } diff --git a/osu.Game/Beatmaps/BeatmapStore.cs b/osu.Game/Beatmaps/BeatmapStore.cs index ad7648e7fd..f4b7b1d74f 100644 --- a/osu.Game/Beatmaps/BeatmapStore.cs +++ b/osu.Game/Beatmaps/BeatmapStore.cs @@ -12,7 +12,7 @@ namespace osu.Game.Beatmaps /// /// Handles the storage and retrieval of Beatmaps/BeatmapSets to the database backing /// - public class BeatmapStore : MutableDatabaseBackedStore + public class BeatmapStore : MutableDatabaseBackedStoreWithFileIncludes { public event Action BeatmapHidden; public event Action BeatmapRestored; @@ -34,6 +34,7 @@ namespace osu.Game.Beatmaps Refresh(ref beatmap, Beatmaps); if (beatmap.Hidden) return false; + beatmap.Hidden = true; } @@ -53,6 +54,7 @@ namespace osu.Game.Beatmaps Refresh(ref beatmap, Beatmaps); if (!beatmap.Hidden) return false; + beatmap.Hidden = false; } @@ -62,18 +64,17 @@ namespace osu.Game.Beatmaps protected override IQueryable AddIncludesForDeletion(IQueryable query) => base.AddIncludesForDeletion(query) - .Include(s => s.Beatmaps).ThenInclude(b => b.Metadata) - .Include(s => s.Beatmaps).ThenInclude(b => b.BaseDifficulty) .Include(s => s.Metadata) - .Include(s => s.Beatmaps).ThenInclude(b => b.Scores); + .Include(s => s.Beatmaps).ThenInclude(b => b.Scores) + .Include(s => s.Beatmaps).ThenInclude(b => b.BaseDifficulty) + .Include(s => s.Beatmaps).ThenInclude(b => b.Metadata); protected override IQueryable AddIncludesForConsumption(IQueryable query) => base.AddIncludesForConsumption(query) .Include(s => s.Metadata) .Include(s => s.Beatmaps).ThenInclude(s => s.Ruleset) .Include(s => s.Beatmaps).ThenInclude(b => b.BaseDifficulty) - .Include(s => s.Beatmaps).ThenInclude(b => b.Metadata) - .Include(s => s.Files).ThenInclude(f => f.FileInfo); + .Include(s => s.Beatmaps).ThenInclude(b => b.Metadata); protected override void Purge(List items, OsuDbContext context) { diff --git a/osu.Game/Beatmaps/BindableBeatmap.cs b/osu.Game/Beatmaps/BindableBeatmap.cs index ca03aac685..657dc06297 100644 --- a/osu.Game/Beatmaps/BindableBeatmap.cs +++ b/osu.Game/Beatmaps/BindableBeatmap.cs @@ -6,12 +6,12 @@ using System.Diagnostics; using JetBrains.Annotations; using osu.Framework.Audio; using osu.Framework.Audio.Track; -using osu.Framework.Configuration; +using osu.Framework.Bindables; namespace osu.Game.Beatmaps { /// - /// A for the beatmap. + /// A for the beatmap. /// This should be used sparingly in-favour of . /// public abstract class BindableBeatmap : NonNullableBindable @@ -34,7 +34,7 @@ namespace osu.Game.Beatmaps this.audioManager = audioManager; - ValueChanged += registerAudioTrack; + ValueChanged += b => registerAudioTrack(b.NewValue); // If the track has changed prior to this being called, let's register it if (Value != Default) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapBackgroundSprite.cs b/osu.Game/Beatmaps/Drawables/BeatmapBackgroundSprite.cs index c8c735b439..0c59eec1ef 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapBackgroundSprite.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapBackgroundSprite.cs @@ -13,8 +13,8 @@ namespace osu.Game.Beatmaps.Drawables public BeatmapBackgroundSprite(WorkingBeatmap working) { - if (working == null) - throw new ArgumentNullException(nameof(working)); + if (working == null) + throw new ArgumentNullException(nameof(working)); this.working = working; } diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs index 5e20ca8bc8..351e5df17a 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs @@ -4,6 +4,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osuTK.Graphics; @@ -22,6 +23,7 @@ namespace osu.Game.Beatmaps.Drawables { if (status == value) return; + status = value; Alpha = value == BeatmapSetOnlineStatus.None ? 0 : 1; @@ -31,8 +33,8 @@ namespace osu.Game.Beatmaps.Drawables public float TextSize { - get => statusText.TextSize; - set => statusText.TextSize = value; + get => statusText.Font.Size; + set => statusText.Font = statusText.Font.With(size: value); } public MarginPadding TextPadding @@ -58,7 +60,7 @@ namespace osu.Game.Beatmaps.Drawables { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold) }, }; diff --git a/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs b/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs index b025b5985c..ec52517197 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs @@ -53,6 +53,7 @@ namespace osu.Game.Beatmaps.Drawables if (rating < 3.75) return DifficultyRating.Hard; if (rating < 5.25) return DifficultyRating.Insane; if (rating < 6.75) return DifficultyRating.Expert; + return DifficultyRating.ExpertPlus; } diff --git a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs index d1d30a7c29..6fa7d47683 100644 --- a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs +++ b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -20,12 +20,13 @@ namespace osu.Game.Beatmaps.Drawables public UpdateableBeatmapBackgroundSprite() { - Beatmap.BindValueChanged(b => Model = b); + Beatmap.BindValueChanged(b => Model = b.NewValue); } protected override Drawable CreateDrawable(BeatmapInfo model) { - return new DelayedLoadUnloadWrapper(() => { + return new DelayedLoadUnloadWrapper(() => + { Drawable drawable; var localBeatmap = beatmaps.GetWorkingBeatmap(model); diff --git a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs index 45df2b3406..367b63d6d1 100644 --- a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs +++ b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs @@ -13,12 +13,14 @@ namespace osu.Game.Beatmaps.Drawables private Drawable displayedCover; private BeatmapSetInfo beatmapSet; + public BeatmapSetInfo BeatmapSet { - get { return beatmapSet; } + get => beatmapSet; set { if (value == beatmapSet) return; + beatmapSet = value; if (IsLoaded) @@ -27,12 +29,14 @@ namespace osu.Game.Beatmaps.Drawables } private BeatmapSetCoverType coverType = BeatmapSetCoverType.Cover; + public BeatmapSetCoverType CoverType { - get { return coverType; } + get => coverType; set { if (value == coverType) return; + coverType = value; if (IsLoaded) diff --git a/osu.Game/Beatmaps/Formats/LegacyDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyDecoder.cs index 34e5afd1cd..040f582e3b 100644 --- a/osu.Game/Beatmaps/Formats/LegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyDecoder.cs @@ -72,6 +72,7 @@ namespace osu.Game.Beatmaps.Formats var index = line.AsSpan().IndexOf("//".AsSpan()); if (index > 0) return line.Substring(0, index); + return line; } @@ -115,6 +116,7 @@ namespace osu.Game.Beatmaps.Formats else { if (!(output is IHasCustomColours tHasCustomColours)) return; + tHasCustomColours.CustomColours[pair.Key] = colour; } } diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 18ff97e079..2e36d87024 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -2,16 +2,16 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Audio.Track; -using osu.Framework.Configuration; using osu.Framework.Graphics.Textures; using osu.Game.Rulesets.Mods; using System; using System.Collections.Generic; -using System.Linq; using osu.Game.Storyboards; using osu.Framework.IO.File; using System.IO; +using System.Linq; using System.Threading; +using osu.Framework.Bindables; using osu.Game.IO.Serialization; using osu.Game.Rulesets; using osu.Game.Rulesets.Objects; @@ -36,7 +36,7 @@ namespace osu.Game.Beatmaps BeatmapSetInfo = beatmapInfo.BeatmapSet; Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo?.Metadata ?? new BeatmapMetadata(); - Mods.ValueChanged += mods => applyRateAdjustments(); + Mods.ValueChanged += _ => applyRateAdjustments(); beatmap = new RecyclableLazy(() => { diff --git a/osu.Game/Configuration/DatabasedConfigManager.cs b/osu.Game/Configuration/DatabasedConfigManager.cs index e218f31f83..f547a7d3e1 100644 --- a/osu.Game/Configuration/DatabasedConfigManager.cs +++ b/osu.Game/Configuration/DatabasedConfigManager.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using osu.Framework.Bindables; using osu.Framework.Configuration; using osu.Game.Rulesets; @@ -60,9 +61,9 @@ namespace osu.Game.Configuration databasedSettings.Add(setting); } - bindable.ValueChanged += v => + bindable.ValueChanged += b => { - setting.Value = v; + setting.Value = b.NewValue; settings.Update(setting); }; } diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 613efe1801..1260a524b4 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -33,14 +33,14 @@ namespace osu.Game.Configuration Set(OsuSetting.Username, string.Empty); Set(OsuSetting.Token, string.Empty); - Set(OsuSetting.SavePassword, false).ValueChanged += val => + Set(OsuSetting.SavePassword, false).ValueChanged += enabled => { - if (val) Set(OsuSetting.SaveUsername, true); + if (enabled.NewValue) Set(OsuSetting.SaveUsername, true); }; - Set(OsuSetting.SaveUsername, true).ValueChanged += val => + Set(OsuSetting.SaveUsername, true).ValueChanged += enabled => { - if (!val) Set(OsuSetting.SavePassword, false); + if (!enabled.NewValue) Set(OsuSetting.SavePassword, false); }; Set(OsuSetting.ExternalLinkWarning, true); diff --git a/osu.Game/Configuration/RandomSelectAlgorithm.cs b/osu.Game/Configuration/RandomSelectAlgorithm.cs index 35240db0ee..8d0c87374f 100644 --- a/osu.Game/Configuration/RandomSelectAlgorithm.cs +++ b/osu.Game/Configuration/RandomSelectAlgorithm.cs @@ -5,10 +5,11 @@ using System.ComponentModel; namespace osu.Game.Configuration { - public enum RandomSelectAlgorithm + public enum RandomSelectAlgorithm { [Description("Never repeat")] RandomPermutation, + [Description("Random")] Random } diff --git a/osu.Game/Configuration/RankingType.cs b/osu.Game/Configuration/RankingType.cs index 6514be750d..7701e1dd1d 100644 --- a/osu.Game/Configuration/RankingType.cs +++ b/osu.Game/Configuration/RankingType.cs @@ -8,8 +8,10 @@ namespace osu.Game.Configuration public enum RankingType { Local, + [Description("Global")] Top, + [Description("Selected Mods")] SelectedMod, Friends, diff --git a/osu.Game/Configuration/ScalingMode.cs b/osu.Game/Configuration/ScalingMode.cs index 1dadfcecc9..0bcc908f71 100644 --- a/osu.Game/Configuration/ScalingMode.cs +++ b/osu.Game/Configuration/ScalingMode.cs @@ -9,6 +9,7 @@ namespace osu.Game.Configuration { Off, Everything, + [Description("Excluding overlays")] ExcludeOverlays, Gameplay, diff --git a/osu.Game/Configuration/ScreenshotFormat.cs b/osu.Game/Configuration/ScreenshotFormat.cs index 8015945747..6d4c96bfa9 100644 --- a/osu.Game/Configuration/ScreenshotFormat.cs +++ b/osu.Game/Configuration/ScreenshotFormat.cs @@ -9,6 +9,7 @@ namespace osu.Game.Configuration { [Description("JPG (web-friendly)")] Jpg = 1, + [Description("PNG (lossless)")] Png = 2 } diff --git a/osu.Game/Configuration/ScrollVisualisationMethod.cs b/osu.Game/Configuration/ScrollVisualisationMethod.cs index d2c09f9128..5f48fe8bfd 100644 --- a/osu.Game/Configuration/ScrollVisualisationMethod.cs +++ b/osu.Game/Configuration/ScrollVisualisationMethod.cs @@ -9,8 +9,10 @@ namespace osu.Game.Configuration { [Description("Sequential")] Sequential, + [Description("Overlapping")] Overlapping, + [Description("Constant")] Constant } diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 6bf9e2ff37..5b4a191682 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Threading.Tasks; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; +using osu.Framework; using osu.Framework.Extensions; using osu.Framework.IO.File; using osu.Framework.Logging; @@ -53,6 +54,8 @@ namespace osu.Game.Database public virtual string[] HandledExtensions => new[] { ".zip" }; + public virtual bool SupportsImportFromStable => RuntimeInfo.IsDesktop; + protected readonly FileStore Files; protected readonly IDatabaseContextFactory ContextFactory; @@ -105,7 +108,7 @@ namespace osu.Game.Database a.Invoke(); } - protected ArchiveModelManager(Storage storage, IDatabaseContextFactory contextFactory, MutableDatabaseBackedStore modelStore, IIpcHost importHost = null) + protected ArchiveModelManager(Storage storage, IDatabaseContextFactory contextFactory, MutableDatabaseBackedStoreWithFileIncludes modelStore, IIpcHost importHost = null) { ContextFactory = contextFactory; @@ -539,6 +542,7 @@ namespace osu.Game.Database return new LegacyDirectoryArchiveReader(path); if (File.Exists(path)) return new LegacyFileArchiveReader(path); + throw new InvalidFormatException($"{path} is not a valid archive"); } } diff --git a/osu.Game/Database/DatabaseWriteUsage.cs b/osu.Game/Database/DatabaseWriteUsage.cs index 4659c212f3..1fd2f23d50 100644 --- a/osu.Game/Database/DatabaseWriteUsage.cs +++ b/osu.Game/Database/DatabaseWriteUsage.cs @@ -31,6 +31,7 @@ namespace osu.Game.Database protected void Dispose(bool disposing) { if (isDisposed) return; + isDisposed = true; try diff --git a/osu.Game/Database/MutableDatabaseBackedStore.cs b/osu.Game/Database/MutableDatabaseBackedStore.cs index 5e820d1478..8ed38fedb8 100644 --- a/osu.Game/Database/MutableDatabaseBackedStore.cs +++ b/osu.Game/Database/MutableDatabaseBackedStore.cs @@ -71,6 +71,7 @@ namespace osu.Game.Database Refresh(ref item); if (item.DeletePending) return false; + item.DeletePending = true; } @@ -89,6 +90,7 @@ namespace osu.Game.Database Refresh(ref item, ConsumableItems); if (!item.DeletePending) return false; + item.DeletePending = false; } diff --git a/osu.Game/Database/MutableDatabaseBackedStoreWithFileIncludes.cs b/osu.Game/Database/MutableDatabaseBackedStoreWithFileIncludes.cs new file mode 100644 index 0000000000..5d6ff6b09b --- /dev/null +++ b/osu.Game/Database/MutableDatabaseBackedStoreWithFileIncludes.cs @@ -0,0 +1,27 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using Microsoft.EntityFrameworkCore; +using osu.Framework.Platform; + +namespace osu.Game.Database +{ + public abstract class MutableDatabaseBackedStoreWithFileIncludes : MutableDatabaseBackedStore + where T : class, IHasPrimaryKey, ISoftDelete, IHasFiles + where U : INamedFileInfo + { + protected MutableDatabaseBackedStoreWithFileIncludes(IDatabaseContextFactory contextFactory, Storage storage = null) + : base(contextFactory, storage) + { + } + + protected override IQueryable AddIncludesForConsumption(IQueryable query) => + base.AddIncludesForConsumption(query) + .Include(s => s.Files).ThenInclude(f => f.FileInfo); + + protected override IQueryable AddIncludesForDeletion(IQueryable query) => + base.AddIncludesForDeletion(query) + .Include(s => s.Files); // don't include FileInfo. these are handled by the FileStore itself. + } +} diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index f4abcd6496..ebd9db786f 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -86,7 +86,7 @@ namespace osu.Game.Graphics.Backgrounds public float TriangleScale { - get { return triangleScale; } + get => triangleScale; set { float change = value / triangleScale; @@ -110,10 +110,10 @@ namespace osu.Game.Graphics.Backgrounds if (CreateNewTriangles) addTriangles(false); - float adjustedAlpha = HideAlphaDiscrepancies ? + float adjustedAlpha = HideAlphaDiscrepancies // Cubically scale alpha to make it drop off more sharply. - (float)Math.Pow(DrawColourInfo.Colour.AverageColour.Linear.A, 3) : - 1; + ? (float)Math.Pow(DrawColourInfo.Colour.AverageColour.Linear.A, 3) + : 1; float elapsedSeconds = (float)Time.Elapsed / 1000; // Since position is relative, the velocity needs to scale inversely with DrawHeight. @@ -181,6 +181,7 @@ namespace osu.Game.Graphics.Backgrounds protected override DrawNode CreateDrawNode() => new TrianglesDrawNode(); private readonly TrianglesDrawNodeSharedData sharedData = new TrianglesDrawNodeSharedData(); + protected override void ApplyDrawNode(DrawNode node) { base.ApplyDrawNode(node); diff --git a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs index b929217ae4..621eeea2b7 100644 --- a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs +++ b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs @@ -3,7 +3,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio.Track; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; diff --git a/osu.Game/Graphics/Containers/ConstrainedIconContainer.cs b/osu.Game/Graphics/Containers/ConstrainedIconContainer.cs index e2e1385f3e..c1811f37d5 100644 --- a/osu.Game/Graphics/Containers/ConstrainedIconContainer.cs +++ b/osu.Game/Graphics/Containers/ConstrainedIconContainer.cs @@ -15,15 +15,9 @@ namespace osu.Game.Graphics.Containers { public Drawable Icon { - get - { - return InternalChild; - } + get => InternalChild; - set - { - InternalChild = value; - } + set => InternalChild = value; } /// @@ -33,8 +27,8 @@ namespace osu.Game.Graphics.Containers /// public new EdgeEffectParameters EdgeEffect { - get { return base.EdgeEffect; } - set { base.EdgeEffect = value; } + get => base.EdgeEffect; + set => base.EdgeEffect = value; } protected override void Update() diff --git a/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs b/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs index d23568e6be..a5b5b7af42 100644 --- a/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs +++ b/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index 3c4d94e970..8e47bf2e99 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -4,9 +4,9 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; +using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; using osuTK; -using osu.Framework.Configuration; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Game.Audio; @@ -24,7 +24,11 @@ namespace osu.Game.Graphics.Containers protected override bool BlockNonPositionalInput => true; - private PreviewTrackManager previewTrackManager; + [Resolved(CanBeNull = true)] + private OsuGame osuGame { get; set; } + + [Resolved] + private PreviewTrackManager previewTrackManager { get; set; } protected readonly Bindable OverlayActivationMode = new Bindable(OverlayActivation.All); @@ -36,10 +40,8 @@ namespace osu.Game.Graphics.Containers } [BackgroundDependencyLoader(true)] - private void load(OsuGame osuGame, AudioManager audio, PreviewTrackManager previewTrackManager) + private void load(AudioManager audio) { - this.previewTrackManager = previewTrackManager; - if (osuGame != null) OverlayActivationMode.BindTo(osuGame.OverlayActivationMode); @@ -90,15 +92,18 @@ namespace osu.Game.Graphics.Containers switch (visibility) { case Visibility.Visible: - if (OverlayActivationMode != OverlayActivation.Disabled) + if (OverlayActivationMode.Value != OverlayActivation.Disabled) { if (PlaySamplesOnStateChange) samplePopIn?.Play(); + if (BlockScreenWideMouse) osuGame?.AddBlockingOverlay(this); } else State = Visibility.Hidden; + break; case Visibility.Hidden: if (PlaySamplesOnStateChange) samplePopOut?.Play(); + if (BlockScreenWideMouse) osuGame?.RemoveBlockingOverlay(this); break; } } @@ -108,5 +113,11 @@ namespace osu.Game.Graphics.Containers base.PopOut(); previewTrackManager.StopAnyPlaying(this); } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + osuGame?.RemoveBlockingOverlay(this); + } } } diff --git a/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs b/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs index e8b8537807..56e5f411b8 100644 --- a/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs +++ b/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs @@ -12,7 +12,8 @@ namespace osu.Game.Graphics.Containers { public class OsuTextFlowContainer : TextFlowContainer { - public OsuTextFlowContainer(Action defaultCreationParameters = null) : base(defaultCreationParameters) + public OsuTextFlowContainer(Action defaultCreationParameters = null) + : base(defaultCreationParameters) { } diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index f7d30dc109..f65a0a469a 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -6,8 +6,8 @@ using osu.Framework.Graphics; using osu.Framework.Input; using osuTK; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Game.Configuration; -using osu.Framework.Configuration; using osu.Framework.MathUtils; namespace osu.Game.Graphics.Containers @@ -45,7 +45,7 @@ namespace osu.Game.Graphics.Containers parallaxEnabled = config.GetBindable(OsuSetting.MenuParallax); parallaxEnabled.ValueChanged += delegate { - if (!parallaxEnabled) + if (!parallaxEnabled.Value) { content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, Easing.OutQuint); content.Scale = new Vector2(1 + System.Math.Abs(ParallaxAmount)); @@ -65,7 +65,7 @@ namespace osu.Game.Graphics.Containers { base.Update(); - if (parallaxEnabled) + if (parallaxEnabled.Value) { Vector2 offset = (input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.Position) - DrawSize / 2) * ParallaxAmount; diff --git a/osu.Game/Graphics/Containers/ScalingContainer.cs b/osu.Game/Graphics/Containers/ScalingContainer.cs index a20c17cc8e..51f068d920 100644 --- a/osu.Game/Graphics/Containers/ScalingContainer.cs +++ b/osu.Game/Graphics/Containers/ScalingContainer.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Configuration; @@ -74,10 +74,10 @@ namespace osu.Game.Graphics.Containers } } - private void scaleChanged(float value) + private void scaleChanged(ValueChangedEvent args) { - this.ScaleTo(new Vector2(value), 500, Easing.Out); - this.ResizeTo(new Vector2(1 / value), 500, Easing.Out); + this.ScaleTo(new Vector2(args.NewValue), 500, Easing.Out); + this.ResizeTo(new Vector2(1 / args.NewValue), 500, Easing.Out); } } @@ -108,7 +108,7 @@ namespace osu.Game.Graphics.Containers sizableContainer.FinishTransforms(); } - private bool requiresBackgroundVisible => (scalingMode == ScalingMode.Everything || scalingMode == ScalingMode.ExcludeOverlays) && (sizeX.Value != 1 || sizeY.Value != 1); + private bool requiresBackgroundVisible => (scalingMode.Value == ScalingMode.Everything || scalingMode.Value == ScalingMode.ExcludeOverlays) && (sizeX.Value != 1 || sizeY.Value != 1); private void updateSize() { @@ -137,8 +137,8 @@ namespace osu.Game.Graphics.Containers bool scaling = targetMode == null || scalingMode.Value == targetMode; - var targetSize = scaling ? new Vector2(sizeX, sizeY) : Vector2.One; - var targetPosition = scaling ? new Vector2(posX, posY) * (Vector2.One - targetSize) : Vector2.Zero; + var targetSize = scaling ? new Vector2(sizeX.Value, sizeY.Value) : Vector2.One; + var targetPosition = scaling ? new Vector2(posX.Value, posY.Value) * (Vector2.One - targetSize) : Vector2.Zero; bool requiresMasking = scaling && targetSize != Vector2.One; if (requiresMasking) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index 00014385c7..6bbab4766d 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -3,7 +3,7 @@ using System; using System.Linq; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -24,7 +24,7 @@ namespace osu.Game.Graphics.Containers public Drawable ExpandableHeader { - get { return expandableHeader; } + get => expandableHeader; set { if (value == expandableHeader) return; @@ -40,7 +40,7 @@ namespace osu.Game.Graphics.Containers public Drawable FixedHeader { - get { return fixedHeader; } + get => fixedHeader; set { if (value == fixedHeader) return; @@ -56,7 +56,7 @@ namespace osu.Game.Graphics.Containers public Drawable Footer { - get { return footer; } + get => footer; set { if (value == footer) return; @@ -75,7 +75,7 @@ namespace osu.Game.Graphics.Containers public Drawable HeaderBackground { - get { return headerBackground; } + get => headerBackground; set { if (value == headerBackground) return; @@ -110,6 +110,7 @@ namespace osu.Game.Graphics.Containers private float headerHeight, footerHeight; private readonly MarginPadding originalSectionsMargin; + private void updateSectionsMargin() { if (!Children.Any()) return; @@ -142,6 +143,7 @@ namespace osu.Game.Graphics.Containers public void ScrollToTop() => scrollContainer.ScrollTo(0); private float lastKnownScroll; + protected override void UpdateAfterChildren() { base.UpdateAfterChildren(); diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs new file mode 100644 index 0000000000..4c8928e122 --- /dev/null +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -0,0 +1,88 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Configuration; +using osuTK.Graphics; + +namespace osu.Game.Graphics.Containers +{ + /// + /// A container that applies user-configured dim levels to its contents. + /// This container specifies behavior that applies to both Storyboards and Backgrounds. + /// + public class UserDimContainer : Container + { + private const float background_fade_duration = 800; + + private Bindable dimLevel { get; set; } + + private Bindable showStoryboard { get; set; } + + /// + /// Whether or not user-configured dim levels should be applied to the container. + /// + public readonly Bindable EnableUserDim = new Bindable(); + + /// + /// Whether or not the storyboard loaded should completely hide the background behind it. + /// + public readonly Bindable StoryboardReplacesBackground = new Bindable(); + + protected Container DimContainer { get; } + + protected override Container Content => DimContainer; + + private readonly bool isStoryboard; + + /// + /// Creates a new . + /// + /// Whether or not this instance of UserDimContainer contains a storyboard. + /// + /// While both backgrounds and storyboards allow user dim levels to be applied, storyboards can be toggled via + /// and can cause backgrounds to become hidden via . + /// + /// + public UserDimContainer(bool isStoryboard = false) + { + this.isStoryboard = isStoryboard; + AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both }); + } + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + dimLevel = config.GetBindable(OsuSetting.DimLevel); + showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); + EnableUserDim.ValueChanged += _ => updateBackgroundDim(); + dimLevel.ValueChanged += _ => updateBackgroundDim(); + showStoryboard.ValueChanged += _ => updateBackgroundDim(); + StoryboardReplacesBackground.ValueChanged += _ => updateBackgroundDim(); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + updateBackgroundDim(); + } + + private void updateBackgroundDim() + { + if (isStoryboard) + { + DimContainer.FadeTo(!showStoryboard.Value || dimLevel.Value == 1 ? 0 : 1, background_fade_duration, Easing.OutQuint); + } + else + { + // The background needs to be hidden in the case of it being replaced by the storyboard + DimContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint); + } + + DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); + } + } +} diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index 76c2345cd5..059beeca4d 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -3,7 +3,6 @@ using osuTK; using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -11,6 +10,7 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Configuration; using System; using JetBrains.Annotations; +using osu.Framework.Bindables; using osu.Framework.Graphics.Textures; using osu.Framework.Input.Events; using osuTK.Input; @@ -80,11 +80,12 @@ namespace osu.Game.Graphics.Cursor activeCursor.AdditiveLayer.FadeInFromZero(800, Easing.OutQuint); } - if (e.Button == MouseButton.Left && cursorRotate) + if (e.Button == MouseButton.Left && cursorRotate.Value) { dragRotationState = DragRotationState.DragStarted; positionMouseDown = e.MousePosition; } + return base.OnMouseDown(e); } @@ -102,6 +103,7 @@ namespace osu.Game.Graphics.Cursor activeCursor.RotateTo(0, 600 * (1 + Math.Abs(activeCursor.Rotation / 720)), Easing.OutElasticHalf); dragRotationState = DragRotationState.NotDragging; } + return base.OnMouseUp(e); } @@ -156,7 +158,7 @@ namespace osu.Game.Graphics.Cursor }; cursorScale = config.GetBindable(OsuSetting.MenuCursorSize); - cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)newScale * base_scale); + cursorScale.ValueChanged += scale => cursorContainer.Scale = new Vector2((float)scale.NewValue * base_scale); cursorScale.TriggerChange(); } } diff --git a/osu.Game/Graphics/Cursor/MenuCursorContainer.cs b/osu.Game/Graphics/Cursor/MenuCursorContainer.cs index 5f9b428dfc..92e5ba6195 100644 --- a/osu.Game/Graphics/Cursor/MenuCursorContainer.cs +++ b/osu.Game/Graphics/Cursor/MenuCursorContainer.cs @@ -43,6 +43,7 @@ namespace osu.Game.Graphics.Cursor } private IProvideCursor currentTarget; + protected override void Update() { base.Update(); diff --git a/osu.Game/Graphics/Cursor/OsuTooltipContainer.cs b/osu.Game/Graphics/Cursor/OsuTooltipContainer.cs index 8f451054ac..4e0ce4a3e1 100644 --- a/osu.Game/Graphics/Cursor/OsuTooltipContainer.cs +++ b/osu.Game/Graphics/Cursor/OsuTooltipContainer.cs @@ -17,7 +17,8 @@ namespace osu.Game.Graphics.Cursor { protected override ITooltip CreateTooltip() => new OsuTooltip(); - public OsuTooltipContainer(CursorContainer cursor) : base(cursor) + public OsuTooltipContainer(CursorContainer cursor) + : base(cursor) { } @@ -46,8 +47,6 @@ namespace osu.Game.Graphics.Cursor } } - private const float text_size = 16; - public OsuTooltip() { AutoSizeEasing = Easing.OutQuint; @@ -69,9 +68,8 @@ namespace osu.Game.Graphics.Cursor }, text = new OsuSpriteText { - TextSize = text_size, Padding = new MarginPadding(5), - Font = @"Exo2.0-Regular", + Font = OsuFont.GetFont(weight: FontWeight.Regular) } }; } diff --git a/osu.Game/Graphics/DrawableDate.cs b/osu.Game/Graphics/DrawableDate.cs index be1c9e0cfc..3ae1033f5d 100644 --- a/osu.Game/Graphics/DrawableDate.cs +++ b/osu.Game/Graphics/DrawableDate.cs @@ -21,6 +21,7 @@ namespace osu.Game.Graphics { if (date == value) return; + date = value.ToLocalTime(); if (LoadState >= LoadState.Ready) @@ -30,8 +31,7 @@ namespace osu.Game.Graphics public DrawableDate(DateTimeOffset date) { - Font = "Exo2.0-RegularItalic"; - + Font = OsuFont.GetFont(weight: FontWeight.Regular, italics: true); Date = date; } diff --git a/osu.Game/Graphics/OsuFont.cs b/osu.Game/Graphics/OsuFont.cs new file mode 100644 index 0000000000..dc660fd159 --- /dev/null +++ b/osu.Game/Graphics/OsuFont.cs @@ -0,0 +1,117 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics.Sprites; + +namespace osu.Game.Graphics +{ + public struct OsuFont + { + /// + /// The default font size. + /// + public const float DEFAULT_FONT_SIZE = 16; + + /// + /// The default font. + /// + public static FontUsage Default => GetFont(); + + public static FontUsage Numeric => GetFont(Typeface.Venera, weight: FontWeight.Regular); + + /// + /// Retrieves a . + /// + /// The font typeface. + /// The size of the text in local space. For a value of 16, a single line will have a height of 16px. + /// The font weight. + /// Whether the font is italic. + /// Whether all characters should be spaced the same distance apart. + /// The . + public static FontUsage GetFont(Typeface typeface = Typeface.Exo, float size = DEFAULT_FONT_SIZE, FontWeight weight = FontWeight.Medium, bool italics = false, bool fixedWidth = false) + => new FontUsage(GetFamilyString(typeface), size, GetWeightString(typeface, weight), italics, fixedWidth); + + /// + /// Retrieves the string representation of a . + /// + /// The . + /// The string representation. + public static string GetFamilyString(Typeface typeface) + { + switch (typeface) + { + case Typeface.Exo: + return "Exo2.0"; + case Typeface.FontAwesome: + return "FontAwesome"; + case Typeface.Venera: + return "Venera"; + } + + return null; + } + + /// + /// Retrieves the string representation of a . + /// + /// The . + /// The . + /// The string representation of in the specified . + public static string GetWeightString(Typeface typeface, FontWeight weight) + => GetWeightString(GetFamilyString(typeface), weight); + + /// + /// Retrieves the string representation of a . + /// + /// The . + /// The . + /// The string representation of in the specified . + public static string GetWeightString(string family, FontWeight weight) + { + string weightString = weight.ToString(); + + // Only exo has an explicit "regular" weight, other fonts do not + if (family != GetFamilyString(Typeface.Exo) && weight == FontWeight.Regular) + weightString = string.Empty; + + return weightString; + } + } + + public static class OsuFontExtensions + { + /// + /// Creates a new by applying adjustments to this . + /// + /// The font typeface. If null, the value is copied from this . + /// The text size. If null, the value is copied from this . + /// The font weight. If null, the value is copied from this . + /// Whether the font is italic. If null, the value is copied from this . + /// Whether all characters should be spaced apart the same distance. If null, the value is copied from this . + /// The resulting . + public static FontUsage With(this FontUsage usage, Typeface? typeface = null, float? size = null, FontWeight? weight = null, bool? italics = null, bool? fixedWidth = null) + { + string familyString = typeface != null ? OsuFont.GetFamilyString(typeface.Value) : usage.Family; + string weightString = weight != null ? OsuFont.GetWeightString(familyString, weight.Value) : usage.Weight; + + return usage.With(familyString, size, weightString, italics, fixedWidth); + } + } + + public enum Typeface + { + Exo, + FontAwesome, + Venera, + } + + public enum FontWeight + { + Light, + Regular, + Medium, + SemiBold, + Bold, + Black + } +} diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index ef4209f6f3..a2ac71de93 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; using osu.Framework.Input; using osu.Framework.Input.Bindings; @@ -127,7 +127,7 @@ namespace osu.Game.Graphics { base.Update(); - if (cursorVisibility == false && Interlocked.CompareExchange(ref screenShotTasks, 0, 0) == 0) + if (cursorVisibility.Value == false && Interlocked.CompareExchange(ref screenShotTasks, 0, 0) == 0) cursorVisibility.Value = true; } diff --git a/osu.Game/Graphics/SpriteIcon.cs b/osu.Game/Graphics/SpriteIcon.cs index dcb29d50ea..f7d7d21435 100644 --- a/osu.Game/Graphics/SpriteIcon.cs +++ b/osu.Game/Graphics/SpriteIcon.cs @@ -65,6 +65,7 @@ namespace osu.Game.Graphics } private FontAwesome loadedIcon; + private void updateTexture() { var loadableIcon = icon; @@ -104,9 +105,10 @@ namespace osu.Game.Graphics } private bool shadow; + public bool Shadow { - get { return shadow; } + get => shadow; set { shadow = value; @@ -119,11 +121,7 @@ namespace osu.Game.Graphics public FontAwesome Icon { - get - { - return icon; - } - + get => icon; set { if (icon == value) return; diff --git a/osu.Game/Graphics/Sprites/OsuSpriteText.cs b/osu.Game/Graphics/Sprites/OsuSpriteText.cs index a0c025f4fa..ed771bb03f 100644 --- a/osu.Game/Graphics/Sprites/OsuSpriteText.cs +++ b/osu.Game/Graphics/Sprites/OsuSpriteText.cs @@ -9,12 +9,10 @@ namespace osu.Game.Graphics.Sprites { public class OsuSpriteText : SpriteText { - public const float FONT_SIZE = 16; - public OsuSpriteText() { Shadow = true; - TextSize = FONT_SIZE; + Font = OsuFont.Default; } } diff --git a/osu.Game/Graphics/UserInterface/Bar.cs b/osu.Game/Graphics/UserInterface/Bar.cs index 92b71a1cc3..2a858ccbcf 100644 --- a/osu.Game/Graphics/UserInterface/Bar.cs +++ b/osu.Game/Graphics/UserInterface/Bar.cs @@ -26,10 +26,7 @@ namespace osu.Game.Graphics.UserInterface /// public float Length { - get - { - return length; - } + get => length; set { length = MathHelper.Clamp(value, 0, 1); @@ -39,35 +36,21 @@ namespace osu.Game.Graphics.UserInterface public Color4 BackgroundColour { - get - { - return background.Colour; - } - set - { - background.Colour = value; - } + get => background.Colour; + set => background.Colour = value; } public Color4 AccentColour { - get - { - return bar.Colour; - } - set - { - bar.Colour = value; - } + get => bar.Colour; + set => bar.Colour = value; } private BarDirection direction = BarDirection.LeftToRight; + public BarDirection Direction { - get - { - return direction; - } + get => direction; set { direction = value; diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index 97335e3c42..58058c9d4c 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -17,12 +17,10 @@ namespace osu.Game.Graphics.UserInterface public float? MaxValue { get; set; } private BarDirection direction = BarDirection.BottomToTop; + public new BarDirection Direction { - get - { - return direction; - } + get => direction; set { direction = value; @@ -69,6 +67,7 @@ namespace osu.Game.Graphics.UserInterface }); } } + //I'm using ToList() here because Where() returns an Enumerable which can change it's elements afterwards RemoveRange(Children.Where((bar, index) => index >= value.Count()).ToList()); } diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index b9196adda3..40bc98a654 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -27,12 +27,12 @@ namespace osu.Game.Graphics.UserInterface { Height = 32; TabContainer.Spacing = new Vector2(padding, 0f); - Current.ValueChanged += tab => + Current.ValueChanged += index => { foreach (var t in TabContainer.Children.OfType()) { var tIndex = TabContainer.IndexOf(t); - var tabIndex = TabContainer.IndexOf(TabMap[tab]); + var tabIndex = TabContainer.IndexOf(TabMap[index.NewValue]); t.State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible; t.Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, Easing.OutQuint); @@ -57,10 +57,11 @@ namespace osu.Game.Graphics.UserInterface public Visibility State { - get { return state; } + get => state; set { if (value == state) return; + state = value; const float transition_duration = 500; @@ -80,9 +81,10 @@ namespace osu.Game.Graphics.UserInterface } } - public BreadcrumbTabItem(T value) : base(value) + public BreadcrumbTabItem(T value) + : base(value) { - Text.TextSize = 18; + Text.Font = Text.Font.With(size: 18); Text.Margin = new MarginPadding { Vertical = 8 }; Padding = new MarginPadding { Right = padding + item_chevron_size }; Add(Chevron = new SpriteIcon diff --git a/osu.Game/Graphics/UserInterface/DialogButton.cs b/osu.Game/Graphics/UserInterface/DialogButton.cs index 644f66a92d..dbbe5b4258 100644 --- a/osu.Game/Graphics/UserInterface/DialogButton.cs +++ b/osu.Game/Graphics/UserInterface/DialogButton.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Bindables; using osuTK; using osuTK.Graphics; using osu.Framework.Graphics; @@ -12,7 +13,6 @@ using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Sprites; using osu.Framework.Extensions.Color4Extensions; using osu.Game.Graphics.Containers; -using osu.Framework.Configuration; using osu.Framework.Input.Events; namespace osu.Game.Graphics.UserInterface @@ -141,8 +141,7 @@ namespace osu.Game.Graphics.UserInterface Text = Text, Anchor = Anchor.Centre, Origin = Anchor.Centre, - TextSize = 28, - Font = "Exo2.0-Bold", + Font = OsuFont.GetFont(size: 28, weight: FontWeight.Bold), Shadow = true, ShadowColour = new Color4(0, 0, 0, 0.1f), Colour = Color4.White, @@ -155,12 +154,10 @@ namespace osu.Game.Graphics.UserInterface } private Color4 buttonColour; + public Color4 ButtonColour { - get - { - return buttonColour; - } + get => buttonColour; set { buttonColour = value; @@ -170,12 +167,10 @@ namespace osu.Game.Graphics.UserInterface } private Color4 backgroundColour = OsuColour.Gray(34); + public Color4 BackgroundColour { - get - { - return backgroundColour; - } + get => backgroundColour; set { backgroundColour = value; @@ -184,12 +179,10 @@ namespace osu.Game.Graphics.UserInterface } private string text; + public string Text { - get - { - return text; - } + get => text; set { text = value; @@ -197,18 +190,10 @@ namespace osu.Game.Graphics.UserInterface } } - private float textSize = 28; public float TextSize { - get - { - return textSize; - } - set - { - textSize = value; - spriteText.TextSize = value; - } + get => spriteText.Font.Size; + set => spriteText.Font = spriteText.Font.With(size: value); } public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => backgroundContainer.ReceivePositionalInputAt(screenSpacePos); @@ -242,9 +227,9 @@ namespace osu.Game.Graphics.UserInterface Selected.Value = false; } - private void selectionChanged(bool isSelected) + private void selectionChanged(ValueChangedEvent args) { - if (isSelected) + if (args.NewValue) { spriteText.TransformSpacingTo(hoverSpacing, hover_duration, Easing.OutElastic); colourContainer.ResizeTo(new Vector2(hover_width, 1f), hover_duration, Easing.OutElastic); diff --git a/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs b/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs index 309021b7d6..2ed37799f6 100644 --- a/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs +++ b/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs @@ -51,7 +51,7 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnClick(ClickEvent e) { - if(Link != null) + if (Link != null) host.OpenUrlExternally(Link); return true; } diff --git a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs index 4f84108d8a..cbbaa6d303 100644 --- a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs @@ -17,7 +17,8 @@ namespace osu.Game.Graphics.UserInterface { private SampleChannel sampleClick; - public HoverClickSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal) : base(sampleSet) + public HoverClickSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal) + : base(sampleSet) { } diff --git a/osu.Game/Graphics/UserInterface/HoverSounds.cs b/osu.Game/Graphics/UserInterface/HoverSounds.cs index b2cd4aab19..b246092a7f 100644 --- a/osu.Game/Graphics/UserInterface/HoverSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverSounds.cs @@ -45,8 +45,10 @@ namespace osu.Game.Graphics.UserInterface { [Description("")] Loud, + [Description("-soft")] Normal, + [Description("-softer")] Soft } diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index b9062b8d39..025aa30986 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -19,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface /// public Color4 IconColour { - get { return iconColour ?? Color4.White; } + get => iconColour ?? Color4.White; set { iconColour = value; @@ -34,8 +34,8 @@ namespace osu.Game.Graphics.UserInterface /// public Color4 IconHoverColour { - get { return iconHoverColour ?? IconColour; } - set { iconHoverColour = value; } + get => iconHoverColour ?? IconColour; + set => iconHoverColour = value; } /// @@ -43,8 +43,8 @@ namespace osu.Game.Graphics.UserInterface /// public FontAwesome Icon { - get { return icon.Icon; } - set { icon.Icon = value; } + get => icon.Icon; + set => icon.Icon = value; } /// @@ -52,8 +52,8 @@ namespace osu.Game.Graphics.UserInterface /// public Vector2 IconScale { - get { return icon.Scale; } - set { icon.Scale = value; } + get => icon.Scale; + set => icon.Scale = value; } /// diff --git a/osu.Game/Graphics/UserInterface/LineGraph.cs b/osu.Game/Graphics/UserInterface/LineGraph.cs index 88d64c1bfb..7a20dd3d16 100644 --- a/osu.Game/Graphics/UserInterface/LineGraph.cs +++ b/osu.Game/Graphics/UserInterface/LineGraph.cs @@ -44,7 +44,7 @@ namespace osu.Game.Graphics.UserInterface /// public IEnumerable Values { - get { return values; } + get => values; set { values = value.ToArray(); @@ -112,6 +112,7 @@ namespace osu.Game.Graphics.UserInterface protected float GetYPosition(float value) { if (ActualMaxValue == ActualMinValue) return 0; + return (ActualMaxValue - value) / (ActualMaxValue - ActualMinValue); } } diff --git a/osu.Game/Graphics/UserInterface/Nub.cs b/osu.Game/Graphics/UserInterface/Nub.cs index 0405a09a78..1f5195eaf1 100644 --- a/osu.Game/Graphics/UserInterface/Nub.cs +++ b/osu.Game/Graphics/UserInterface/Nub.cs @@ -5,7 +5,7 @@ using System; using osuTK; using osuTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -41,9 +41,9 @@ namespace osu.Game.Graphics.UserInterface }, }; - Current.ValueChanged += newValue => + Current.ValueChanged += filled => { - if (newValue) + if (filled.NewValue) fill.FadeIn(200, Easing.OutQuint); else fill.FadeTo(0.01f, 200, Easing.OutQuint); //todo: remove once we figure why containers aren't drawing at all times @@ -72,9 +72,10 @@ namespace osu.Game.Graphics.UserInterface } private bool glowing; + public bool Glowing { - get { return glowing; } + get => glowing; set { glowing = value; @@ -94,10 +95,7 @@ namespace osu.Game.Graphics.UserInterface public bool Expanded { - set - { - this.ResizeTo(new Vector2(value ? EXPANDED_SIZE : COLLAPSED_SIZE, 12), 500, Easing.OutQuint); - } + set => this.ResizeTo(new Vector2(value ? EXPANDED_SIZE : COLLAPSED_SIZE, 12), 500, Easing.OutQuint); } private readonly Bindable current = new Bindable(); @@ -116,9 +114,10 @@ namespace osu.Game.Graphics.UserInterface } private Color4 accentColour; + public Color4 AccentColour { - get { return accentColour; } + get => accentColour; set { accentColour = value; @@ -128,9 +127,10 @@ namespace osu.Game.Graphics.UserInterface } private Color4 glowingAccentColour; + public Color4 GlowingAccentColour { - get { return glowingAccentColour; } + get => glowingAccentColour; set { glowingAccentColour = value; @@ -140,9 +140,10 @@ namespace osu.Game.Graphics.UserInterface } private Color4 glowColour; + public Color4 GlowColour { - get { return glowColour; } + get => glowColour; set { glowColour = value; diff --git a/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs b/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs index 9d9f95662b..d64068f74c 100644 --- a/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs +++ b/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs @@ -73,7 +73,7 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(OsuColour colours) { - Enabled.BindValueChanged(enabled => this.FadeColour(enabled ? Color4.White : colours.Gray9, 200, Easing.OutQuint), true); + Enabled.BindValueChanged(enabled => this.FadeColour(enabled.NewValue ? Color4.White : colours.Gray9, 200, Easing.OutQuint), true); } protected override bool OnHover(HoverEvent e) diff --git a/osu.Game/Graphics/UserInterface/OsuButton.cs b/osu.Game/Graphics/UserInterface/OsuButton.cs index 6ba461ad70..7a27f825f6 100644 --- a/osu.Game/Graphics/UserInterface/OsuButton.cs +++ b/osu.Game/Graphics/UserInterface/OsuButton.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; @@ -46,13 +47,13 @@ namespace osu.Game.Graphics.UserInterface new HoverClickSounds(HoverSampleSet.Loud), }); - Enabled.ValueChanged += enabled_ValueChanged; + Enabled.ValueChanged += enabledChanged; Enabled.TriggerChange(); } - private void enabled_ValueChanged(bool enabled) + private void enabledChanged(ValueChangedEvent e) { - this.FadeColour(enabled ? Color4.White : Color4.Gray, 200, Easing.OutQuint); + this.FadeColour(e.NewValue ? Color4.White : Color4.Gray, 200, Easing.OutQuint); } protected override bool OnHover(HoverEvent e) @@ -84,7 +85,7 @@ namespace osu.Game.Graphics.UserInterface Depth = -1, Origin = Anchor.Centre, Anchor = Anchor.Centre, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold) }; } } diff --git a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs index b71bdcc593..de3d93d845 100644 --- a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs @@ -4,7 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; @@ -33,7 +33,7 @@ namespace osu.Game.Graphics.UserInterface public string LabelText { - get { return labelSpriteText?.Text; } + get => labelSpriteText?.Text; set { if (labelSpriteText != null) @@ -43,7 +43,7 @@ namespace osu.Game.Graphics.UserInterface public MarginPadding LabelPadding { - get { return labelSpriteText?.Padding ?? new MarginPadding(); } + get => labelSpriteText?.Padding ?? new MarginPadding(); set { if (labelSpriteText != null) @@ -86,9 +86,9 @@ namespace osu.Game.Graphics.UserInterface { base.LoadComplete(); - Current.ValueChanged += newValue => + Current.ValueChanged += enabled => { - if (newValue) + if (enabled.NewValue) sampleChecked?.Play(); else sampleUnchecked?.Play(); diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index 0877776d0e..db38067a50 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -17,9 +17,10 @@ namespace osu.Game.Graphics.UserInterface public class OsuDropdown : Dropdown, IHasAccentColour { private Color4 accentColour; + public Color4 AccentColour { - get { return accentColour; } + get => accentColour; set { accentColour = value; @@ -37,11 +38,9 @@ namespace osu.Game.Graphics.UserInterface private void updateAccentColour() { - var header = Header as IHasAccentColour; - if (header != null) header.AccentColour = accentColour; + if (Header is IHasAccentColour header) header.AccentColour = accentColour; - var menu = Menu as IHasAccentColour; - if (menu != null) menu.AccentColour = accentColour; + if (Menu is IHasAccentColour menu) menu.AccentColour = accentColour; } protected override DropdownHeader CreateHeader() => new OsuDropdownHeader(); @@ -49,6 +48,7 @@ namespace osu.Game.Graphics.UserInterface protected override DropdownMenu CreateMenu() => new OsuDropdownMenu(); #region OsuDropdownMenu + protected class OsuDropdownMenu : DropdownMenu, IHasAccentColour { public override bool HandleNonPositionalInput => State == MenuState.Open; @@ -83,9 +83,10 @@ namespace osu.Game.Graphics.UserInterface } private Color4 accentColour; + public Color4 AccentColour { - get { return accentColour; } + get => accentColour; set { accentColour = value; @@ -97,15 +98,17 @@ namespace osu.Game.Graphics.UserInterface protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableOsuDropdownMenuItem(item) { AccentColour = accentColour }; #region DrawableOsuDropdownMenuItem + public class DrawableOsuDropdownMenuItem : DrawableDropdownMenuItem, IHasAccentColour { // IsHovered is used public override bool HandlePositionalInput => true; private Color4? accentColour; + public Color4 AccentColour { - get { return accentColour ?? nonAccentSelectedColour; } + get => accentColour ?? nonAccentSelectedColour; set { accentColour = value; @@ -149,8 +152,7 @@ namespace osu.Game.Graphics.UserInterface { base.UpdateForegroundColour(); - var content = Foreground.Children.FirstOrDefault() as Content; - if (content != null) content.Chevron.Alpha = IsHovered ? 1 : 0; + if (Foreground.Children.FirstOrDefault() is Content content) content.Chevron.Alpha = IsHovered ? 1 : 0; } protected override Drawable CreateContent() => new Content(); @@ -159,8 +161,8 @@ namespace osu.Game.Graphics.UserInterface { public string Text { - get { return Label.Text; } - set { Label.Text = value; } + get => Label.Text; + set => Label.Text = value; } public readonly OsuSpriteText Label; @@ -194,25 +196,29 @@ namespace osu.Game.Graphics.UserInterface } } } + #endregion } + #endregion public class OsuDropdownHeader : DropdownHeader, IHasAccentColour { protected readonly SpriteText Text; + protected override string Label { - get { return Text.Text; } - set { Text.Text = value; } + get => Text.Text; + set => Text.Text = value; } protected readonly SpriteIcon Icon; private Color4 accentColour; + public virtual Color4 AccentColour { - get { return accentColour; } + get => accentColour; set { accentColour = value; diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index 0a1dfe8c41..9b5755ea8b 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -125,7 +125,7 @@ namespace osu.Game.Graphics.UserInterface { public string Text { - get { return NormalText.Text; } + get => NormalText.Text; set { NormalText.Text = value; @@ -149,7 +149,7 @@ namespace osu.Game.Graphics.UserInterface { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - TextSize = text_size, + Font = OsuFont.GetFont(size: text_size), Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, }, BoldText = new OsuSpriteText @@ -158,8 +158,7 @@ namespace osu.Game.Graphics.UserInterface Alpha = 0, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - TextSize = text_size, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold), Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, } }; diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs index c66a20a115..c558fd7c7b 100644 --- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs @@ -35,9 +35,10 @@ namespace osu.Game.Graphics.UserInterface public virtual string TooltipText { get; private set; } private Color4 accentColour; + public Color4 AccentColour { - get { return accentColour; } + get => accentColour; set { accentColour = value; @@ -79,10 +80,7 @@ namespace osu.Game.Graphics.UserInterface new HoverClickSounds() }; - Current.DisabledChanged += disabled => - { - Alpha = disabled ? 0.3f : 1; - }; + Current.DisabledChanged += disabled => { Alpha = disabled ? 0.3f : 1; }; } [BackgroundDependencyLoader] @@ -95,7 +93,7 @@ namespace osu.Game.Graphics.UserInterface protected override void LoadComplete() { base.LoadComplete(); - CurrentNumber.BindValueChanged(updateTooltipText, true); + CurrentNumber.BindValueChanged(current => updateTooltipText(current.NewValue), true); } protected override bool OnHover(HoverEvent e) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 7089b7a79a..e2a4955011 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -6,7 +6,7 @@ using System.Linq; using osuTK; using osuTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -58,14 +58,14 @@ namespace osu.Game.Graphics.UserInterface } private Color4 accentColour; + public Color4 AccentColour { - get { return accentColour; } + get => accentColour; set { accentColour = value; - var dropdown = Dropdown as IHasAccentColour; - if (dropdown != null) + if (Dropdown is IHasAccentColour dropdown) dropdown.AccentColour = value; foreach (var i in TabContainer.Children.OfType()) i.AccentColour = value; @@ -101,13 +101,14 @@ namespace osu.Game.Graphics.UserInterface protected readonly Box Bar; private Color4 accentColour; + public Color4 AccentColour { - get { return accentColour; } + get => accentColour; set { accentColour = value; - if (!Active) + if (!Active.Value) Text.Colour = value; } } @@ -128,14 +129,14 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnHover(HoverEvent e) { - if (!Active) + if (!Active.Value) fadeActive(); return true; } protected override void OnHoverLost(HoverLostEvent e) { - if (!Active) + if (!Active.Value) fadeInactive(); } @@ -146,7 +147,8 @@ namespace osu.Game.Graphics.UserInterface AccentColour = colours.Blue; } - public OsuTabItem(T value) : base(value) + public OsuTabItem(T value) + : base(value) { AutoSizeAxes = Axes.X; RelativeSizeAxes = Axes.Y; @@ -159,7 +161,7 @@ namespace osu.Game.Graphics.UserInterface Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, Text = (value as IHasDescription)?.Description ?? (value as Enum)?.GetDescription() ?? value.ToString(), - TextSize = 14, + Font = OsuFont.GetFont(size: 14) }, Bar = new Box { @@ -173,7 +175,7 @@ namespace osu.Game.Graphics.UserInterface new HoverClickSounds() }; - Active.BindValueChanged(val => Text.Font = val ? @"Exo2.0-Bold" : @"Exo2.0", true); + Active.BindValueChanged(active => Text.Font = Text.Font.With(Typeface.Exo, weight: active.NewValue ? FontWeight.Bold : FontWeight.Medium), true); } protected override void OnActivated() => fadeActive(); @@ -224,11 +226,7 @@ namespace osu.Game.Graphics.UserInterface { public override Color4 AccentColour { - get - { - return base.AccentColour; - } - + get => base.AccentColour; set { base.AccentColour = value; diff --git a/osu.Game/Graphics/UserInterface/OsuTabControlCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuTabControlCheckbox.cs index 0626534307..918473ac53 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControlCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControlCheckbox.cs @@ -24,14 +24,15 @@ namespace osu.Game.Graphics.UserInterface private readonly SpriteIcon icon; private Color4? accentColour; + public Color4 AccentColour { - get { return accentColour.GetValueOrDefault(); } + get => accentColour.GetValueOrDefault(); set { accentColour = value; - if (Current) + if (Current.Value) { text.Colour = AccentColour; icon.Colour = AccentColour; @@ -41,8 +42,8 @@ namespace osu.Game.Graphics.UserInterface public string Text { - get { return text.Text; } - set { text.Text = value; } + get => text.Text; + set => text.Text = value; } private const float transition_length = 500; @@ -67,7 +68,7 @@ namespace osu.Game.Graphics.UserInterface protected override void OnHoverLost(HoverLostEvent e) { - if (!Current) + if (!Current.Value) fadeOut(); base.OnHoverLost(e); @@ -94,11 +95,7 @@ namespace osu.Game.Graphics.UserInterface Direction = FillDirection.Horizontal, Children = new Drawable[] { - text = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-Bold", - }, + text = new OsuSpriteText { Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold) }, icon = new SpriteIcon { Size = new Vector2(14), @@ -118,9 +115,9 @@ namespace osu.Game.Graphics.UserInterface } }; - Current.ValueChanged += v => + Current.ValueChanged += selected => { - if (v) + if (selected.NewValue) { fadeIn(); icon.Icon = FontAwesome.fa_check_circle_o; diff --git a/osu.Game/Graphics/UserInterface/OsuTextBox.cs b/osu.Game/Graphics/UserInterface/OsuTextBox.cs index a481edb06b..21cdfbf5af 100644 --- a/osu.Game/Graphics/UserInterface/OsuTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTextBox.cs @@ -24,7 +24,7 @@ namespace osu.Game.Graphics.UserInterface protected override SpriteText CreatePlaceholder() => new OsuSpriteText { - Font = @"Exo2.0-MediumItalic", + Font = OsuFont.GetFont(italics: true), Colour = new Color4(180, 180, 180, 255), Margin = new MarginPadding { Left = 2 }, }; @@ -57,7 +57,7 @@ namespace osu.Game.Graphics.UserInterface base.OnFocusLost(e); } - protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), TextSize = CalculatedTextSize }; + protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), Font = OsuFont.GetFont(size: CalculatedTextSize) }; public virtual bool OnPressed(GlobalAction action) { diff --git a/osu.Game/Graphics/UserInterface/PageTabControl.cs b/osu.Game/Graphics/UserInterface/PageTabControl.cs index 904951da0e..156a556b5e 100644 --- a/osu.Game/Graphics/UserInterface/PageTabControl.cs +++ b/osu.Game/Graphics/UserInterface/PageTabControl.cs @@ -32,7 +32,8 @@ namespace osu.Game.Graphics.UserInterface protected readonly SpriteText Text; - public PageTabItem(T value) : base(value) + public PageTabItem(T value) + : base(value) { AutoSizeAxes = Axes.X; RelativeSizeAxes = Axes.Y; @@ -45,7 +46,7 @@ namespace osu.Game.Graphics.UserInterface Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, Text = (value as Enum)?.GetDescription() ?? value.ToString(), - TextSize = 14, + Font = OsuFont.GetFont(size: 14) }, box = new Box { @@ -59,7 +60,7 @@ namespace osu.Game.Graphics.UserInterface new HoverClickSounds() }; - Active.BindValueChanged(val => Text.Font = val ? @"Exo2.0-Bold" : @"Exo2.0", true); + Active.BindValueChanged(active => Text.Font = Text.Font.With(Typeface.Exo, weight: active.NewValue ? FontWeight.Bold : FontWeight.Medium), true); } [BackgroundDependencyLoader] @@ -70,14 +71,14 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnHover(HoverEvent e) { - if (!Active) + if (!Active.Value) slideActive(); return true; } protected override void OnHoverLost(HoverLostEvent e) { - if (!Active) + if (!Active.Value) slideInactive(); } diff --git a/osu.Game/Graphics/UserInterface/PercentageCounter.cs b/osu.Game/Graphics/UserInterface/PercentageCounter.cs index 9205525af3..8254bdda7c 100644 --- a/osu.Game/Graphics/UserInterface/PercentageCounter.cs +++ b/osu.Game/Graphics/UserInterface/PercentageCounter.cs @@ -22,7 +22,7 @@ namespace osu.Game.Graphics.UserInterface public PercentageCounter() { - DisplayedCountSpriteText.FixedWidth = true; + DisplayedCountSpriteText.Font = DisplayedCountSpriteText.Font.With(fixedWidth: true); Current.Value = DisplayedCount = 1.0f; } @@ -41,7 +41,7 @@ namespace osu.Game.Graphics.UserInterface public override void Increment(double amount) { - Current.Value = Current + amount; + Current.Value = Current.Value + amount; } } } diff --git a/osu.Game/Graphics/UserInterface/ProgressBar.cs b/osu.Game/Graphics/UserInterface/ProgressBar.cs index 04f85e62b7..d271cd121c 100644 --- a/osu.Game/Graphics/UserInterface/ProgressBar.cs +++ b/osu.Game/Graphics/UserInterface/ProgressBar.cs @@ -18,7 +18,7 @@ namespace osu.Game.Graphics.UserInterface public Color4 FillColour { - set { fill.FadeColour(value, 150, Easing.OutQuint); } + set => fill.FadeColour(value, 150, Easing.OutQuint); } public Color4 BackgroundColour @@ -32,12 +32,12 @@ namespace osu.Game.Graphics.UserInterface public double EndTime { - set { CurrentNumber.MaxValue = value; } + set => CurrentNumber.MaxValue = value; } public double CurrentTime { - set { CurrentNumber.Value = value; } + set => CurrentNumber.Value = value; } public ProgressBar() diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 6e261a8fa7..47e12f5f15 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -1,13 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics.Sprites; using System; using System.Collections.Generic; +using osu.Framework.Bindables; using osuTK.Graphics; namespace osu.Game.Graphics.UserInterface @@ -45,15 +45,13 @@ namespace osu.Game.Graphics.UserInterface /// public virtual T DisplayedCount { - get - { - return displayedCount; - } + get => displayedCount; set { if (EqualityComparer.Default.Equals(displayedCount, value)) return; + displayedCount = value; DisplayedCountSpriteText.Text = FormatCount(value); } @@ -61,22 +59,17 @@ namespace osu.Game.Graphics.UserInterface public abstract void Increment(T amount); - private float textSize; public float TextSize { - get { return textSize; } - set - { - textSize = value; - DisplayedCountSpriteText.TextSize = value; - } + get => DisplayedCountSpriteText.Font.Size; + set => DisplayedCountSpriteText.Font = DisplayedCountSpriteText.Font.With(size: value); } public Color4 AccentColour { - get { return DisplayedCountSpriteText.Colour; } - set { DisplayedCountSpriteText.Colour = value; } + get => DisplayedCountSpriteText.Colour; + set => DisplayedCountSpriteText.Colour = value; } /// @@ -86,20 +79,17 @@ namespace osu.Game.Graphics.UserInterface { Children = new Drawable[] { - DisplayedCountSpriteText = new OsuSpriteText - { - Font = @"Venera" - }, + DisplayedCountSpriteText = new OsuSpriteText { Font = OsuFont.Numeric } }; TextSize = 40; AutoSizeAxes = Axes.Both; - DisplayedCount = Current; + DisplayedCount = Current.Value; - Current.ValueChanged += newValue => + Current.ValueChanged += val => { - if (IsLoaded) TransformCount(displayedCount, newValue); + if (IsLoaded) TransformCount(displayedCount, val.NewValue); }; } @@ -107,7 +97,7 @@ namespace osu.Game.Graphics.UserInterface { base.LoadComplete(); - DisplayedCountSpriteText.Text = FormatCount(Current); + DisplayedCountSpriteText.Text = FormatCount(Current.Value); } /// @@ -126,7 +116,7 @@ namespace osu.Game.Graphics.UserInterface public virtual void StopRolling() { FinishTransforms(false, nameof(DisplayedCount)); - DisplayedCount = Current; + DisplayedCount = Current.Value; } /// diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs index 944993d99c..63062cdc9d 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -28,7 +28,7 @@ namespace osu.Game.Graphics.UserInterface /// How many leading zeroes the counter will have. public ScoreCounter(uint leading = 0) { - DisplayedCountSpriteText.FixedWidth = true; + DisplayedCountSpriteText.Font = DisplayedCountSpriteText.Font.With(fixedWidth: true); LeadingZeroes = leading; } @@ -52,7 +52,7 @@ namespace osu.Game.Graphics.UserInterface public override void Increment(double amount) { - Current.Value = Current + amount; + Current.Value = Current.Value + amount; } } } diff --git a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs index 6e01c69df5..f564a4b5a8 100644 --- a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs @@ -19,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface onPushed(null, stack.CurrentScreen); - Current.ValueChanged += newScreen => newScreen.MakeCurrent(); + Current.ValueChanged += current => current.NewValue.MakeCurrent(); } private void onPushed(IScreen lastScreen, IScreen newScreen) diff --git a/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs b/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs index b0657e707e..4717401c75 100644 --- a/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs @@ -33,7 +33,7 @@ namespace osu.Game.Graphics.UserInterface public override void Increment(int amount) { - Current.Value = Current + amount; + Current.Value = Current.Value + amount; } } } diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index ad8ff8ec74..7dc05d174f 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -41,10 +41,7 @@ namespace osu.Game.Graphics.UserInterface /// public float CountStars { - get - { - return countStars; - } + get => countStars; set { @@ -137,6 +134,7 @@ namespace osu.Game.Graphics.UserInterface private class Star : Container { public readonly SpriteIcon Icon; + public Star() { Size = new Vector2(star_size); diff --git a/osu.Game/Graphics/UserInterface/TriangleButton.cs b/osu.Game/Graphics/UserInterface/TriangleButton.cs index 31fe29fc3a..685d230a4b 100644 --- a/osu.Game/Graphics/UserInterface/TriangleButton.cs +++ b/osu.Game/Graphics/UserInterface/TriangleButton.cs @@ -27,14 +27,11 @@ namespace osu.Game.Graphics.UserInterface }); } - public IEnumerable FilterTerms => new[] { Text }; + public virtual IEnumerable FilterTerms => new[] { Text }; public bool MatchingFilter { - set - { - this.FadeTo(value ? 1 : 0); - } + set => this.FadeTo(value ? 1 : 0); } } } diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index eddacf8e2d..1d8298904b 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -48,11 +48,7 @@ namespace osu.Game.Graphics.UserInterface public override Anchor Origin { - get - { - return base.Origin; - } - + get => base.Origin; set { base.Origin = value; @@ -155,18 +151,12 @@ namespace osu.Game.Graphics.UserInterface public FontAwesome Icon { - set - { - bouncingIcon.Icon = value; - } + set => bouncingIcon.Icon = value; } public string Text { - set - { - text.Text = value; - } + set => text.Text = value; } public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => IconLayer.ReceivePositionalInputAt(screenSpacePos) || TextLayer.ReceivePositionalInputAt(screenSpacePos); @@ -217,7 +207,10 @@ namespace osu.Game.Graphics.UserInterface private readonly SpriteIcon icon; - public FontAwesome Icon { set { icon.Icon = value; } } + public FontAwesome Icon + { + set => icon.Icon = value; + } public BouncingIcon() { diff --git a/osu.Game/IO/FileStore.cs b/osu.Game/IO/FileStore.cs index 21639e4f43..458f8964f9 100644 --- a/osu.Game/IO/FileStore.cs +++ b/osu.Game/IO/FileStore.cs @@ -21,7 +21,8 @@ namespace osu.Game.IO public new Storage Storage => base.Storage; - public FileStore(IDatabaseContextFactory contextFactory, Storage storage) : base(contextFactory, storage.GetStorageForDirectory(@"files")) + public FileStore(IDatabaseContextFactory contextFactory, Storage storage) + : base(contextFactory, storage.GetStorageForDirectory(@"files")) { Store = new StorageBackedResourceStore(Storage); } diff --git a/osu.Game/IO/Legacy/SerializationReader.cs b/osu.Game/IO/Legacy/SerializationReader.cs index aba9c289fa..95ee5aea6b 100644 --- a/osu.Game/IO/Legacy/SerializationReader.cs +++ b/osu.Game/IO/Legacy/SerializationReader.cs @@ -39,6 +39,7 @@ namespace osu.Game.IO.Legacy public override string ReadString() { if (ReadByte() == 0) return null; + return base.ReadString(); } @@ -48,6 +49,7 @@ namespace osu.Game.IO.Legacy int len = ReadInt32(); if (len > 0) return ReadBytes(len); if (len < 0) return null; + return Array.Empty(); } @@ -57,6 +59,7 @@ namespace osu.Game.IO.Legacy int len = ReadInt32(); if (len > 0) return ReadChars(len); if (len < 0) return null; + return Array.Empty(); } @@ -65,6 +68,7 @@ namespace osu.Game.IO.Legacy { long ticks = ReadInt64(); if (ticks < 0) throw new IOException("Bad ticks count read!"); + return new DateTime(ticks, DateTimeKind.Utc); } @@ -73,6 +77,7 @@ namespace osu.Game.IO.Legacy { int count = ReadInt32(); if (count < 0) return null; + IList d = new List(count); SerializationReader sr = new SerializationReader(BaseStream); @@ -88,6 +93,7 @@ namespace osu.Game.IO.Legacy { if (skipErrors) continue; + throw; } @@ -102,6 +108,7 @@ namespace osu.Game.IO.Legacy { int count = ReadInt32(); if (count < 0) return null; + IList d = new List(count); for (int i = 0; i < count; i++) d.Add((T)ReadObject()); return d; @@ -112,6 +119,7 @@ namespace osu.Game.IO.Legacy { int count = ReadInt32(); if (count < 0) return null; + IDictionary d = new Dictionary(); for (int i = 0; i < count; i++) d[(T)ReadObject()] = (U)ReadObject(); return d; @@ -174,7 +182,7 @@ namespace osu.Game.IO.Legacy versionBinder = new VersionConfigToNamespaceAssemblyObjectBinder(); formatter = new BinaryFormatter { -// AssemblyFormat = FormatterAssemblyStyle.Simple, + // AssemblyFormat = FormatterAssemblyStyle.Simple, Binder = versionBinder }; } @@ -224,6 +232,7 @@ namespace osu.Game.IO.Legacy genType = BindToType(assemblyName, typ); } } + if (genType != null && tmpTypes.Count > 0) { return genType.MakeGenericType(tmpTypes.ToArray()); diff --git a/osu.Game/IO/Legacy/SerializationWriter.cs b/osu.Game/IO/Legacy/SerializationWriter.cs index be6e9a0afe..695767c822 100644 --- a/osu.Game/IO/Legacy/SerializationWriter.cs +++ b/osu.Game/IO/Legacy/SerializationWriter.cs @@ -8,6 +8,7 @@ using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Formatters.Binary; using System.Text; + // ReSharper disable ConditionIsAlwaysTrueOrFalse (we're allowing nulls to be passed to the writer where the underlying class doesn't). // ReSharper disable HeuristicUnreachableCode @@ -219,7 +220,7 @@ namespace osu.Game.IO.Legacy Write((byte)ObjType.otherType); BinaryFormatter b = new BinaryFormatter { -// AssemblyFormat = FormatterAssemblyStyle.Simple, + // AssemblyFormat = FormatterAssemblyStyle.Simple, TypeFormat = FormatterTypeStyle.TypesWhenNeeded }; b.Serialize(BaseStream, obj); diff --git a/osu.Game/Input/Bindings/DatabasedKeyBinding.cs b/osu.Game/Input/Bindings/DatabasedKeyBinding.cs index 5e15b07b46..8c0072c3da 100644 --- a/osu.Game/Input/Bindings/DatabasedKeyBinding.cs +++ b/osu.Game/Input/Bindings/DatabasedKeyBinding.cs @@ -19,15 +19,15 @@ namespace osu.Game.Input.Bindings [Column("Keys")] public string KeysString { - get { return KeyCombination.ToString(); } - private set { KeyCombination = value; } + get => KeyCombination.ToString(); + private set => KeyCombination = value; } [Column("Action")] public int IntAction { - get { return (int)Action; } - set { Action = value; } + get => (int)Action; + set => Action = value; } } } diff --git a/osu.Game/Input/Bindings/GlobalActionContainer.cs b/osu.Game/Input/Bindings/GlobalActionContainer.cs index 844b6ea658..97f4a9771f 100644 --- a/osu.Game/Input/Bindings/GlobalActionContainer.cs +++ b/osu.Game/Input/Bindings/GlobalActionContainer.cs @@ -62,31 +62,41 @@ namespace osu.Game.Input.Bindings { [Description("Toggle chat overlay")] ToggleChat, + [Description("Toggle social overlay")] ToggleSocial, + [Description("Reset input settings")] ResetInputSettings, + [Description("Toggle toolbar")] ToggleToolbar, + [Description("Toggle settings")] ToggleSettings, + [Description("Toggle osu!direct")] ToggleDirect, + [Description("Increase volume")] IncreaseVolume, + [Description("Decrease volume")] DecreaseVolume, + [Description("Toggle mute")] ToggleMute, // In-Game Keybindings [Description("Skip cutscene")] SkipCutscene, + [Description("Quick retry (hold)")] QuickRetry, [Description("Take screenshot")] TakeScreenshot, + [Description("Toggle gameplay mouse buttons")] ToggleGameplayMouseButtons, diff --git a/osu.Game/Input/IdleTracker.cs b/osu.Game/Input/IdleTracker.cs index ab010a9532..91e2456ef7 100644 --- a/osu.Game/Input/IdleTracker.cs +++ b/osu.Game/Input/IdleTracker.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Input; using osu.Framework.Input.Bindings; diff --git a/osu.Game/Migrations/20190225062029_AddUserIDColumn.Designer.cs b/osu.Game/Migrations/20190225062029_AddUserIDColumn.Designer.cs new file mode 100644 index 0000000000..8e1e3a59f3 --- /dev/null +++ b/osu.Game/Migrations/20190225062029_AddUserIDColumn.Designer.cs @@ -0,0 +1,487 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using osu.Game.Database; + +namespace osu.Game.Migrations +{ + [DbContext(typeof(OsuDbContext))] + [Migration("20190225062029_AddUserIDColumn")] + partial class AddUserIDColumn + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.1-servicing-10028"); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("ApproachRate"); + + b.Property("CircleSize"); + + b.Property("DrainRate"); + + b.Property("OverallDifficulty"); + + b.Property("SliderMultiplier"); + + b.Property("SliderTickRate"); + + b.HasKey("ID"); + + b.ToTable("BeatmapDifficulty"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("AudioLeadIn"); + + b.Property("BaseDifficultyID"); + + b.Property("BeatDivisor"); + + b.Property("BeatmapSetInfoID"); + + b.Property("Countdown"); + + b.Property("DistanceSpacing"); + + b.Property("GridSize"); + + b.Property("Hash"); + + b.Property("Hidden"); + + b.Property("LetterboxInBreaks"); + + b.Property("MD5Hash"); + + b.Property("MetadataID"); + + b.Property("OnlineBeatmapID"); + + b.Property("Path"); + + b.Property("RulesetID"); + + b.Property("SpecialStyle"); + + b.Property("StackLeniency"); + + b.Property("StarDifficulty"); + + b.Property("Status"); + + b.Property("StoredBookmarks"); + + b.Property("TimelineZoom"); + + b.Property("Version"); + + b.Property("WidescreenStoryboard"); + + b.HasKey("ID"); + + b.HasIndex("BaseDifficultyID"); + + b.HasIndex("BeatmapSetInfoID"); + + b.HasIndex("Hash"); + + b.HasIndex("MD5Hash"); + + b.HasIndex("MetadataID"); + + b.HasIndex("OnlineBeatmapID") + .IsUnique(); + + b.HasIndex("RulesetID"); + + b.ToTable("BeatmapInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Artist"); + + b.Property("ArtistUnicode"); + + b.Property("AudioFile"); + + b.Property("AuthorString") + .HasColumnName("Author"); + + b.Property("BackgroundFile"); + + b.Property("PreviewTime"); + + b.Property("Source"); + + b.Property("Tags"); + + b.Property("Title"); + + b.Property("TitleUnicode"); + + b.HasKey("ID"); + + b.ToTable("BeatmapMetadata"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("BeatmapSetInfoID"); + + b.Property("FileInfoID"); + + b.Property("Filename") + .IsRequired(); + + b.HasKey("ID"); + + b.HasIndex("BeatmapSetInfoID"); + + b.HasIndex("FileInfoID"); + + b.ToTable("BeatmapSetFileInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("DeletePending"); + + b.Property("Hash"); + + b.Property("MetadataID"); + + b.Property("OnlineBeatmapSetID"); + + b.Property("Protected"); + + b.Property("Status"); + + b.HasKey("ID"); + + b.HasIndex("DeletePending"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("MetadataID"); + + b.HasIndex("OnlineBeatmapSetID") + .IsUnique(); + + b.ToTable("BeatmapSetInfo"); + }); + + modelBuilder.Entity("osu.Game.Configuration.DatabasedSetting", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("IntKey") + .HasColumnName("Key"); + + b.Property("RulesetID"); + + b.Property("StringValue") + .HasColumnName("Value"); + + b.Property("Variant"); + + b.HasKey("ID"); + + b.HasIndex("RulesetID", "Variant"); + + b.ToTable("Settings"); + }); + + modelBuilder.Entity("osu.Game.IO.FileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Hash"); + + b.Property("ReferenceCount"); + + b.HasKey("ID"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("ReferenceCount"); + + b.ToTable("FileInfo"); + }); + + modelBuilder.Entity("osu.Game.Input.Bindings.DatabasedKeyBinding", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("IntAction") + .HasColumnName("Action"); + + b.Property("KeysString") + .HasColumnName("Keys"); + + b.Property("RulesetID"); + + b.Property("Variant"); + + b.HasKey("ID"); + + b.HasIndex("IntAction"); + + b.HasIndex("RulesetID", "Variant"); + + b.ToTable("KeyBinding"); + }); + + modelBuilder.Entity("osu.Game.Rulesets.RulesetInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Available"); + + b.Property("InstantiationInfo"); + + b.Property("Name"); + + b.Property("ShortName"); + + b.HasKey("ID"); + + b.HasIndex("Available"); + + b.HasIndex("ShortName") + .IsUnique(); + + b.ToTable("RulesetInfo"); + }); + + modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("FileInfoID"); + + b.Property("Filename") + .IsRequired(); + + b.Property("ScoreInfoID"); + + b.HasKey("ID"); + + b.HasIndex("FileInfoID"); + + b.HasIndex("ScoreInfoID"); + + b.ToTable("ScoreFileInfo"); + }); + + modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Accuracy") + .HasColumnType("DECIMAL(1,4)"); + + b.Property("BeatmapInfoID"); + + b.Property("Combo"); + + b.Property("Date"); + + b.Property("DeletePending"); + + b.Property("Hash"); + + b.Property("MaxCombo"); + + b.Property("ModsJson") + .HasColumnName("Mods"); + + b.Property("OnlineScoreID"); + + b.Property("PP"); + + b.Property("Rank"); + + b.Property("RulesetID"); + + b.Property("StatisticsJson") + .HasColumnName("Statistics"); + + b.Property("TotalScore"); + + b.Property("UserID") + .HasColumnName("UserID"); + + b.Property("UserString") + .HasColumnName("User"); + + b.HasKey("ID"); + + b.HasIndex("BeatmapInfoID"); + + b.HasIndex("OnlineScoreID") + .IsUnique(); + + b.HasIndex("RulesetID"); + + b.ToTable("ScoreInfo"); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("FileInfoID"); + + b.Property("Filename") + .IsRequired(); + + b.Property("SkinInfoID"); + + b.HasKey("ID"); + + b.HasIndex("FileInfoID"); + + b.HasIndex("SkinInfoID"); + + b.ToTable("SkinFileInfo"); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Creator"); + + b.Property("DeletePending"); + + b.Property("Hash"); + + b.Property("Name"); + + b.HasKey("ID"); + + b.HasIndex("DeletePending"); + + b.HasIndex("Hash") + .IsUnique(); + + b.ToTable("SkinInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "BaseDifficulty") + .WithMany() + .HasForeignKey("BaseDifficultyID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet") + .WithMany("Beatmaps") + .HasForeignKey("BeatmapSetInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") + .WithMany("Beatmaps") + .HasForeignKey("MetadataID"); + + b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset") + .WithMany() + .HasForeignKey("RulesetID") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo") + .WithMany("Files") + .HasForeignKey("BeatmapSetInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.IO.FileInfo", "FileInfo") + .WithMany() + .HasForeignKey("FileInfoID") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") + .WithMany("BeatmapSets") + .HasForeignKey("MetadataID"); + }); + + modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b => + { + b.HasOne("osu.Game.IO.FileInfo", "FileInfo") + .WithMany() + .HasForeignKey("FileInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Scoring.ScoreInfo") + .WithMany("Files") + .HasForeignKey("ScoreInfoID"); + }); + + modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapInfo", "Beatmap") + .WithMany("Scores") + .HasForeignKey("BeatmapInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset") + .WithMany() + .HasForeignKey("RulesetID") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b => + { + b.HasOne("osu.Game.IO.FileInfo", "FileInfo") + .WithMany() + .HasForeignKey("FileInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Skinning.SkinInfo") + .WithMany("Files") + .HasForeignKey("SkinInfoID") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/osu.Game/Migrations/20190225062029_AddUserIDColumn.cs b/osu.Game/Migrations/20190225062029_AddUserIDColumn.cs new file mode 100644 index 0000000000..0720e0eac7 --- /dev/null +++ b/osu.Game/Migrations/20190225062029_AddUserIDColumn.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace osu.Game.Migrations +{ + public partial class AddUserIDColumn : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "UserID", + table: "ScoreInfo", + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "UserID", + table: "ScoreInfo"); + } + } +} diff --git a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs index 2dafedc3ac..8430e00e4f 100644 --- a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs +++ b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs @@ -14,7 +14,7 @@ namespace osu.Game.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.0-rtm-35687"); + .HasAnnotation("ProductVersion", "2.2.1-servicing-10028"); modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => { @@ -336,7 +336,10 @@ namespace osu.Game.Migrations b.Property("StatisticsJson") .HasColumnName("Statistics"); - b.Property("TotalScore"); + b.Property("TotalScore"); + + b.Property("UserID") + .HasColumnName("UserID"); b.Property("UserString") .HasColumnName("User"); diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 48b9b8a6d5..4d039e0b8a 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -8,7 +8,7 @@ using System.Net; using System.Net.Http; using System.Threading; using Newtonsoft.Json.Linq; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Logging; using osu.Game.Configuration; @@ -64,7 +64,7 @@ namespace osu.Game.Online.API thread.Start(); } - private void onTokenChanged(OAuthToken token) => config.Set(OsuSetting.Token, config.Get(OsuSetting.SavePassword) ? authentication.TokenString : string.Empty); + private void onTokenChanged(ValueChangedEvent e) => config.Set(OsuSetting.Token, config.Get(OsuSetting.SavePassword) ? authentication.TokenString : string.Empty); private readonly List components = new List(); @@ -176,6 +176,7 @@ namespace osu.Game.Online.API lock (queue) { if (queue.Count == 0) break; + req = queue.Dequeue(); } @@ -260,7 +261,7 @@ namespace osu.Game.Online.API public APIState State { - get { return state; } + get => state; private set { APIState oldState = state; diff --git a/osu.Game/Online/API/APIRequest.cs b/osu.Game/Online/API/APIRequest.cs index 59cd685295..2781a5709b 100644 --- a/osu.Game/Online/API/APIRequest.cs +++ b/osu.Game/Online/API/APIRequest.cs @@ -121,7 +121,10 @@ namespace osu.Game.Online.API } public delegate void APIFailureHandler(Exception e); + public delegate void APISuccessHandler(); + public delegate void APIProgressHandler(long current, long total); + public delegate void APISuccessHandler(T content); } diff --git a/osu.Game/Online/API/DummyAPIAccess.cs b/osu.Game/Online/API/DummyAPIAccess.cs index 600192cb85..096ab5d8c8 100644 --- a/osu.Game/Online/API/DummyAPIAccess.cs +++ b/osu.Game/Online/API/DummyAPIAccess.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Users; namespace osu.Game.Online.API diff --git a/osu.Game/Online/API/IAPIProvider.cs b/osu.Game/Online/API/IAPIProvider.cs index ca60506da9..e4533ecb3d 100644 --- a/osu.Game/Online/API/IAPIProvider.cs +++ b/osu.Game/Online/API/IAPIProvider.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Users; namespace osu.Game.Online.API diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs index ffe63e68ea..baf494ebf9 100644 --- a/osu.Game/Online/API/OAuth.cs +++ b/osu.Game/Online/API/OAuth.cs @@ -3,7 +3,7 @@ using System.Diagnostics; using System.Net.Http; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.IO.Network; namespace osu.Game.Online.API diff --git a/osu.Game/Online/API/OAuthToken.cs b/osu.Game/Online/API/OAuthToken.cs index 4c9c7b808f..f103d0917d 100644 --- a/osu.Game/Online/API/OAuthToken.cs +++ b/osu.Game/Online/API/OAuthToken.cs @@ -19,15 +19,8 @@ namespace osu.Game.Online.API [JsonProperty(@"expires_in")] public long ExpiresIn { - get - { - return AccessTokenExpiry - DateTimeOffset.UtcNow.ToUnixTimeSeconds(); - } - - set - { - AccessTokenExpiry = DateTimeOffset.Now.AddSeconds(value).ToUnixTimeSeconds(); - } + get => AccessTokenExpiry - DateTimeOffset.UtcNow.ToUnixTimeSeconds(); + set => AccessTokenExpiry = DateTimeOffset.Now.AddSeconds(value).ToUnixTimeSeconds(); } public bool IsValid => !string.IsNullOrEmpty(AccessToken) && ExpiresIn > 30; @@ -57,6 +50,7 @@ namespace osu.Game.Online.API catch { } + return null; } } diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index c60c1e44ee..9ec39c5cb1 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using Newtonsoft.Json; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Lists; using osu.Game.Users; diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index ded7920cc1..8c6422afe3 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Logging; using osu.Game.Online.API; using osu.Game.Online.API.Requests; @@ -55,7 +55,7 @@ namespace osu.Game.Online.Chat { CurrentChannel.ValueChanged += currentChannelChanged; - HighPollRate.BindValueChanged(high => TimeBetweenPolls = high ? 1000 : 6000, true); + HighPollRate.BindValueChanged(enabled => TimeBetweenPolls = enabled.NewValue ? 1000 : 6000, true); } /// @@ -84,7 +84,7 @@ namespace osu.Game.Online.Chat ?? new Channel(user); } - private void currentChannelChanged(Channel channel) => JoinChannel(channel); + private void currentChannelChanged(ValueChangedEvent e) => JoinChannel(e.NewValue); /// /// Ensure we run post actions in sequence, once at a time. @@ -131,7 +131,7 @@ namespace osu.Game.Online.Chat target.AddLocalEcho(message); // if this is a PM and the first message, we need to do a special request to create the PM channel - if (target.Type == ChannelType.PM && !target.Joined) + if (target.Type == ChannelType.PM && !target.Joined.Value) { var createNewPrivateMessageRequest = new CreateNewPrivateMessageRequest(target.Users.First(), message); @@ -331,7 +331,7 @@ namespace osu.Game.Online.Chat switch (channel.Type) { case ChannelType.Public: - var req = new JoinChannelRequest(channel, api.LocalUser); + var req = new JoinChannelRequest(channel, api.LocalUser.Value); req.Success += () => JoinChannel(channel, true); req.Failure += ex => LeaveChannel(channel); api.Queue(req); @@ -363,7 +363,7 @@ namespace osu.Game.Online.Chat if (channel.Joined.Value) { - api.Queue(new LeaveChannelRequest(channel, api.LocalUser)); + api.Queue(new LeaveChannelRequest(channel, api.LocalUser.Value)); channel.Joined.Value = false; } } diff --git a/osu.Game/Online/Chat/ErrorMessage.cs b/osu.Game/Online/Chat/ErrorMessage.cs index 46e222f11d..a8ff0e9a98 100644 --- a/osu.Game/Online/Chat/ErrorMessage.cs +++ b/osu.Game/Online/Chat/ErrorMessage.cs @@ -5,7 +5,8 @@ namespace osu.Game.Online.Chat { public class ErrorMessage : InfoMessage { - public ErrorMessage(string message) : base(message) + public ErrorMessage(string message) + : base(message) { Sender.Colour = @"ff0000"; } diff --git a/osu.Game/Online/Chat/ExternalLinkOpener.cs b/osu.Game/Online/Chat/ExternalLinkOpener.cs index a2c5a3cf8c..495f1ac0b0 100644 --- a/osu.Game/Online/Chat/ExternalLinkOpener.cs +++ b/osu.Game/Online/Chat/ExternalLinkOpener.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Platform; using osu.Game.Configuration; @@ -27,7 +27,7 @@ namespace osu.Game.Online.Chat public void OpenUrlExternally(string url) { - if (externalLinkWarning) + if (externalLinkWarning.Value) dialogOverlay.Push(new ExternalLinkDialog(url, () => host.OpenUrlExternally(url))); else host.OpenUrlExternally(url); diff --git a/osu.Game/Online/Chat/InfoMessage.cs b/osu.Game/Online/Chat/InfoMessage.cs index 4ef0d5ec65..8dce188804 100644 --- a/osu.Game/Online/Chat/InfoMessage.cs +++ b/osu.Game/Online/Chat/InfoMessage.cs @@ -10,7 +10,8 @@ namespace osu.Game.Online.Chat { private static int infoID = -1; - public InfoMessage(string message) : base(infoID--) + public InfoMessage(string message) + : base(infoID--) { Timestamp = DateTimeOffset.Now; Content = message; diff --git a/osu.Game/Online/Chat/LocalEchoMessage.cs b/osu.Game/Online/Chat/LocalEchoMessage.cs index 639509851d..8a39515575 100644 --- a/osu.Game/Online/Chat/LocalEchoMessage.cs +++ b/osu.Game/Online/Chat/LocalEchoMessage.cs @@ -5,7 +5,8 @@ namespace osu.Game.Online.Chat { public class LocalEchoMessage : LocalMessage { - public LocalEchoMessage() : base(null) + public LocalEchoMessage() + : base(null) { } } diff --git a/osu.Game/Online/Chat/MessageFormatter.cs b/osu.Game/Online/Chat/MessageFormatter.cs index 726f6ad2f0..d35dc07368 100644 --- a/osu.Game/Online/Chat/MessageFormatter.cs +++ b/osu.Game/Online/Chat/MessageFormatter.cs @@ -25,19 +25,19 @@ namespace osu.Game.Online.Chat // This is in the format (, [optional]): // http[s]://.[:port][/path][?query][#fragment] private static readonly Regex advanced_link_regex = new Regex( - // protocol - @"(?[a-z]*?:\/\/" + - // domain + tld - @"(?(?:[a-z0-9]\.|[a-z0-9][a-z0-9-]*[a-z0-9]\.)*[a-z0-9-]*[a-z0-9]" + - // port (optional) - @"(?::\d+)?)" + - // path (optional) - @"(?(?:(?:\/+(?:[a-z0-9$_\.\+!\*\',;:\(\)@&~=-]|%[0-9a-f]{2})*)*" + - // query (optional) - @"(?:\?(?:[a-z0-9$_\+!\*\',;:\(\)@&=\/~-]|%[0-9a-f]{2})*)?)?" + - // fragment (optional) - @"(?:#(?:[a-z0-9$_\+!\*\',;:\(\)@&=\/~-]|%[0-9a-f]{2})*)?)?)", - RegexOptions.IgnoreCase); + // protocol + @"(?[a-z]*?:\/\/" + + // domain + tld + @"(?(?:[a-z0-9]\.|[a-z0-9][a-z0-9-]*[a-z0-9]\.)*[a-z0-9-]*[a-z0-9]" + + // port (optional) + @"(?::\d+)?)" + + // path (optional) + @"(?(?:(?:\/+(?:[a-z0-9$_\.\+!\*\',;:\(\)@&~=-]|%[0-9a-f]{2})*)*" + + // query (optional) + @"(?:\?(?:[a-z0-9$_\+!\*\',;:\(\)@&=\/~-]|%[0-9a-f]{2})*)?)?" + + // fragment (optional) + @"(?:#(?:[a-z0-9$_\+!\*\',;:\(\)@&=\/~-]|%[0-9a-f]{2})*)?)?)", + RegexOptions.IgnoreCase); // 00:00:000 (1,2,3) - test private static readonly Regex time_regex = new Regex(@"\d\d:\d\d:\d\d\d? [^-]*"); @@ -56,14 +56,14 @@ namespace osu.Game.Online.Chat var index = m.Index - captureOffset; var displayText = string.Format(display, - m.Groups[0], - m.Groups.Count > 1 ? m.Groups[1].Value : "", - m.Groups.Count > 2 ? m.Groups[2].Value : "").Trim(); + m.Groups[0], + m.Groups.Count > 1 ? m.Groups[1].Value : "", + m.Groups.Count > 2 ? m.Groups[2].Value : "").Trim(); var linkText = string.Format(link, - m.Groups[0], - m.Groups.Count > 1 ? m.Groups[1].Value : "", - m.Groups.Count > 2 ? m.Groups[2].Value : "").Trim(); + m.Groups[0], + m.Groups.Count > 1 ? m.Groups[1].Value : "", + m.Groups.Count > 2 ? m.Groups[2].Value : "").Trim(); if (displayText.Length == 0 || linkText.Length == 0) continue; diff --git a/osu.Game/Online/Chat/StandAloneChatDisplay.cs b/osu.Game/Online/Chat/StandAloneChatDisplay.cs index a3bcc91e1e..438bf231c4 100644 --- a/osu.Game/Online/Chat/StandAloneChatDisplay.cs +++ b/osu.Game/Online/Chat/StandAloneChatDisplay.cs @@ -3,7 +3,7 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -90,9 +90,9 @@ namespace osu.Game.Online.Chat return; if (text[0] == '/') - ChannelManager?.PostCommand(text.Substring(1), Channel); + ChannelManager?.PostCommand(text.Substring(1), Channel.Value); else - ChannelManager?.PostMessage(text, target: Channel); + ChannelManager?.PostMessage(text, target: Channel.Value); textbox.Text = string.Empty; } @@ -111,13 +111,13 @@ namespace osu.Game.Online.Chat protected virtual ChatLine CreateMessage(Message message) => new StandAloneMessage(message); - private void channelChanged(Channel channel) + private void channelChanged(ValueChangedEvent e) { drawableChannel?.Expire(); - if (channel == null) return; + if (e.NewValue == null) return; - AddInternal(drawableChannel = new StandAloneDrawableChannel(channel) + AddInternal(drawableChannel = new StandAloneDrawableChannel(e.NewValue) { CreateChatLineAction = CreateMessage, Padding = new MarginPadding { Bottom = postingTextbox ? textbox_height : 0 } @@ -126,7 +126,7 @@ namespace osu.Game.Online.Chat protected class StandAloneDrawableChannel : DrawableChannel { - public Func CreateChatLineAction; + public Func CreateChatLineAction; protected override ChatLine CreateChatLine(Message m) => CreateChatLineAction(m); @@ -144,7 +144,8 @@ namespace osu.Game.Online.Chat protected override float HorizontalPadding => 10; protected override float MessagePadding => 120; - public StandAloneMessage(Message message) : base(message) + public StandAloneMessage(Message message) + : base(message) { } } diff --git a/osu.Game/Online/Leaderboards/Leaderboard.cs b/osu.Game/Online/Leaderboards/Leaderboard.cs index f3e7bb5c34..38df0efd6f 100644 --- a/osu.Game/Online/Leaderboards/Leaderboard.cs +++ b/osu.Game/Online/Leaderboards/Leaderboard.cs @@ -39,7 +39,7 @@ namespace osu.Game.Online.Leaderboards public IEnumerable Scores { - get { return scores; } + get => scores; set { scores = value; @@ -98,7 +98,7 @@ namespace osu.Game.Online.Leaderboards public TScope Scope { - get { return scope; } + get => scope; set { if (value.Equals(scope)) @@ -117,7 +117,7 @@ namespace osu.Game.Online.Leaderboards /// protected PlaceholderState PlaceholderState { - get { return placeholderState; } + get => placeholderState; set { if (value != PlaceholderState.Successful) diff --git a/osu.Game/Online/Leaderboards/LeaderboardScore.cs b/osu.Game/Online/Leaderboards/LeaderboardScore.cs index 7373924612..34981bf849 100644 --- a/osu.Game/Online/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Online/Leaderboards/LeaderboardScore.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Containers; @@ -75,9 +76,7 @@ namespace osu.Game.Online.Leaderboards { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = @"Exo2.0-MediumItalic", - TextSize = 22, - // ReSharper disable once ImpureMethodCallOnReadonlyValueField + Font = OsuFont.GetFont(size: 22, italics: true), Text = RankPosition.ToString(), }, }, @@ -137,8 +136,7 @@ namespace osu.Game.Online.Leaderboards nameLabel = new OsuSpriteText { Text = user.Username, - Font = @"Exo2.0-BoldItalic", - TextSize = 23, + Font = OsuFont.GetFont(size: 23, weight: FontWeight.Bold, italics: true) }, new FillFlowContainer { @@ -187,7 +185,7 @@ namespace osu.Game.Online.Leaderboards Spacing = new Vector2(5f, 0f), Children = new Drawable[] { - scoreLabel = new GlowingSpriteText(score.TotalScore.ToString(@"N0"), @"Venera", 23, Color4.White, OsuColour.FromHex(@"83ccfa")), + scoreLabel = new GlowingSpriteText(score.TotalScore.ToString(@"N0"), OsuFont.Numeric.With(size: 23), Color4.White, OsuColour.FromHex(@"83ccfa")), RankContainer = new Container { Size = new Vector2(40f, 20f), @@ -275,7 +273,7 @@ namespace osu.Game.Online.Leaderboards private class GlowingSpriteText : Container { - public GlowingSpriteText(string text, string font, int textSize, Color4 textColour, Color4 glowColour) + public GlowingSpriteText(string text, FontUsage font, Color4 textColour, Color4 glowColour) { AutoSizeAxes = Axes.Both; @@ -296,9 +294,7 @@ namespace osu.Game.Online.Leaderboards { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = font, - FixedWidth = true, - TextSize = textSize, + Font = font.With(fixedWidth: true), Text = text, Colour = glowColour, Shadow = false, @@ -309,9 +305,7 @@ namespace osu.Game.Online.Leaderboards { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = font, - FixedWidth = true, - TextSize = textSize, + Font = font.With(fixedWidth: true), Text = text, Colour = textColour, Shadow = false, @@ -369,7 +363,7 @@ namespace osu.Game.Online.Leaderboards }, }, }, - new GlowingSpriteText(statistic.Value, @"Exo2.0-Bold", 17, Color4.White, OsuColour.FromHex(@"83ccfa")) + new GlowingSpriteText(statistic.Value, OsuFont.GetFont(size: 17, weight: FontWeight.Bold), Color4.White, OsuColour.FromHex(@"83ccfa")) { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, diff --git a/osu.Game/Online/Leaderboards/MessagePlaceholder.cs b/osu.Game/Online/Leaderboards/MessagePlaceholder.cs index 441db0d922..d4256e4a9d 100644 --- a/osu.Game/Online/Leaderboards/MessagePlaceholder.cs +++ b/osu.Game/Online/Leaderboards/MessagePlaceholder.cs @@ -14,7 +14,7 @@ namespace osu.Game.Online.Leaderboards { AddIcon(FontAwesome.fa_exclamation_circle, cp => { - cp.TextSize = TEXT_SIZE; + cp.Font = cp.Font.With(size: TEXT_SIZE); cp.Padding = new MarginPadding { Right = 10 }; }); diff --git a/osu.Game/Online/Leaderboards/Placeholder.cs b/osu.Game/Online/Leaderboards/Placeholder.cs index 72f9502753..d38110a9d0 100644 --- a/osu.Game/Online/Leaderboards/Placeholder.cs +++ b/osu.Game/Online/Leaderboards/Placeholder.cs @@ -12,7 +12,7 @@ namespace osu.Game.Online.Leaderboards protected const float TEXT_SIZE = 22; protected Placeholder() - : base(cp => cp.TextSize = TEXT_SIZE) + : base(cp => cp.Font = cp.Font.With(size: TEXT_SIZE)) { Anchor = Anchor.Centre; Origin = Anchor.Centre; diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index 2dcc7369f9..77236ce3c8 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Online.Multiplayer.GameTypes; using osu.Game.Online.Multiplayer.RoomStatuses; using osu.Game.Users; @@ -86,7 +86,7 @@ namespace osu.Game.Online.Multiplayer [JsonProperty("participant_count")] private int? participantCount { - get => ParticipantCount; + get => ParticipantCount.Value; set => ParticipantCount.Value = value ?? 0; } @@ -106,7 +106,7 @@ namespace osu.Game.Online.Multiplayer [JsonProperty("max_attempts", DefaultValueHandling = DefaultValueHandling.Ignore)] private int? maxAttempts { - get => MaxAttempts; + get => MaxAttempts.Value; set => MaxAttempts.Value = value; } @@ -118,19 +118,19 @@ namespace osu.Game.Online.Multiplayer public void CopyFrom(Room other) { - RoomID.Value = other.RoomID; - Name.Value = other.Name; + RoomID.Value = other.RoomID.Value; + Name.Value = other.Name.Value; if (other.Host.Value != null && Host.Value?.Id != other.Host.Value.Id) - Host.Value = other.Host; + Host.Value = other.Host.Value; - Status.Value = other.Status; - Availability.Value = other.Availability; - Type.Value = other.Type; - MaxParticipants.Value = other.MaxParticipants; + Status.Value = other.Status.Value; + Availability.Value = other.Availability.Value; + Type.Value = other.Type.Value; + MaxParticipants.Value = other.MaxParticipants.Value; ParticipantCount.Value = other.ParticipantCount.Value; Participants.Value = other.Participants.Value.ToArray(); - EndDate.Value = other.EndDate; + EndDate.Value = other.EndDate.Value; if (DateTimeOffset.Now >= EndDate.Value) Status.Value = new RoomStatusEnded(); diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 7b4ff3d295..bf9b4ced3b 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using osu.Framework.Configuration; using osu.Framework.Screens; using osu.Game.Configuration; @@ -19,6 +20,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using osu.Framework.Audio; +using osu.Framework.Bindables; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Input; using osu.Framework.Input.Bindings; @@ -108,6 +110,8 @@ namespace osu.Game private readonly List overlays = new List(); + private readonly List visibleBlockingOverlays = new List(); + // todo: move this to SongSelect once Screen has the ability to unsuspend. [Cached] [Cached(Type = typeof(IBindable>))] @@ -126,6 +130,22 @@ namespace osu.Game public void ToggleDirect() => direct.ToggleVisibility(); + private void updateBlockingOverlayFade() => + screenContainer.FadeColour(visibleBlockingOverlays.Any() ? OsuColour.Gray(0.5f) : Color4.White, 500, Easing.OutQuint); + + public void AddBlockingOverlay(OverlayContainer overlay) + { + if (!visibleBlockingOverlays.Contains(overlay)) + visibleBlockingOverlays.Add(overlay); + updateBlockingOverlayFade(); + } + + public void RemoveBlockingOverlay(OverlayContainer overlay) + { + visibleBlockingOverlays.Remove(overlay); + updateBlockingOverlayFade(); + } + /// /// Close all game-wide overlays. /// @@ -174,15 +194,17 @@ namespace osu.Game // bind config int to database RulesetInfo configRuleset = LocalConfig.GetBindable(OsuSetting.Ruleset); ruleset.Value = RulesetStore.GetRuleset(configRuleset.Value) ?? RulesetStore.AvailableRulesets.First(); - ruleset.ValueChanged += r => configRuleset.Value = r.ID ?? 0; + ruleset.ValueChanged += r => configRuleset.Value = r.NewValue.ID ?? 0; // bind config int to database SkinInfo configSkin = LocalConfig.GetBindable(OsuSetting.Skin); - SkinManager.CurrentSkinInfo.ValueChanged += s => configSkin.Value = s.ID; - configSkin.ValueChanged += id => SkinManager.CurrentSkinInfo.Value = SkinManager.Query(s => s.ID == id) ?? SkinInfo.Default; + SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID; + configSkin.ValueChanged += skinId => SkinManager.CurrentSkinInfo.Value = SkinManager.Query(s => s.ID == skinId.NewValue) ?? SkinInfo.Default; configSkin.TriggerChange(); LocalConfig.BindWith(OsuSetting.VolumeInactive, inactiveVolumeAdjust); + + IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true); } private ExternalLinkOpener externalLinkOpener; @@ -479,6 +501,7 @@ namespace osu.Game overlay.StateChanged += state => { if (state == Visibility.Hidden) return; + singleDisplaySideOverlays.Where(o => o != overlay).ForEach(o => o.Hide()); }; } @@ -492,6 +515,7 @@ namespace osu.Game overlay.StateChanged += state => { if (state == Visibility.Hidden) return; + informationalOverlays.Where(o => o != overlay).ForEach(o => o.Hide()); }; } @@ -513,9 +537,9 @@ namespace osu.Game }; } - OverlayActivationMode.ValueChanged += v => + OverlayActivationMode.ValueChanged += mode => { - if (v != OverlayActivation.All) CloseAllOverlays(); + if (mode.NewValue != OverlayActivation.All) CloseAllOverlays(); }; void updateScreenOffset() @@ -592,21 +616,10 @@ namespace osu.Game } private Task asyncLoadStream; - private int visibleOverlayCount; private void loadComponentSingleFile(T d, Action add) where T : Drawable { - var focused = d as FocusedOverlayContainer; - if (focused != null) - { - focused.StateChanged += s => - { - visibleOverlayCount += s == Visibility.Visible ? 1 : -1; - screenContainer.FadeColour(visibleOverlayCount > 0 ? OsuColour.Gray(0.5f) : Color4.White, 500, Easing.OutQuint); - }; - } - // schedule is here to ensure that all component loads are done after LoadComplete is run (and thus all dependencies are cached). // with some better organisation of LoadComplete to do construction and dependency caching in one step, followed by calls to loadComponentSingleFile, // we could avoid the need for scheduling altogether. @@ -623,7 +636,25 @@ namespace osu.Game try { Logger.Log($"Loading {d}...", level: LogLevel.Debug); - await LoadComponentAsync(d, add); + + // Since this is running in a separate thread, it is possible for OsuGame to be disposed after LoadComponentAsync has been called + // throwing an exception. To avoid this, the call is scheduled on the update thread, which does not run if IsDisposed = true + Task task = null; + var del = new ScheduledDelegate(() => task = LoadComponentAsync(d, add)); + Scheduler.Add(del); + + // The delegate won't complete if OsuGame has been disposed in the meantime + while (!IsDisposed && !del.Completed) + await Task.Delay(10); + + // Either we're disposed or the load process has started successfully + if (IsDisposed) + return; + + Debug.Assert(task != null); + + await task; + Logger.Log($"Loaded {d}!", level: LogLevel.Debug); } catch (OperationCanceledException) @@ -674,16 +705,12 @@ namespace osu.Game private readonly BindableDouble inactiveVolumeAdjust = new BindableDouble(); - protected override void OnDeactivated() + private void updateActiveState(bool isActive) { - base.OnDeactivated(); - Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust); - } - - protected override void OnActivated() - { - base.OnActivated(); - Audio.RemoveAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust); + if (isActive) + Audio.RemoveAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust); + else + Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust); } public bool OnReleased(GlobalAction action) => false; diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 828c23d788..84025abb8c 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -8,7 +8,7 @@ using System.Linq; using System.Reflection; using osu.Framework.Allocation; using osu.Framework.Audio; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.IO.Stores; @@ -75,9 +75,9 @@ namespace osu.Game private Bindable fpsDisplayVisible; - protected AssemblyName AssemblyName => Assembly.GetEntryAssembly()?.GetName() ?? new AssemblyName { Version = new Version() }; + public virtual Version AssemblyVersion => Assembly.GetEntryAssembly()?.GetName().Version ?? new Version(); - public bool IsDeployedBuild => AssemblyName.Version.Major > 0; + public bool IsDeployedBuild => AssemblyVersion.Major > 0; public string Version { @@ -86,8 +86,8 @@ namespace osu.Game if (!IsDeployedBuild) return @"local " + (DebugUtils.IsDebug ? @"debug" : @"release"); - var assembly = AssemblyName; - return $@"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}"; + var version = AssemblyVersion; + return $@"{version.Major}.{version.Minor}.{version.Build}"; } } @@ -209,7 +209,7 @@ namespace osu.Game // TODO: This is temporary until we reimplement the local FPS display. // It's just to allow end-users to access the framework FPS display without knowing the shortcut key. fpsDisplayVisible = LocalConfig.GetBindable(OsuSetting.ShowFpsDisplay); - fpsDisplayVisible.ValueChanged += val => { FrameStatisticsMode = val ? FrameStatisticsMode.Minimal : FrameStatisticsMode.None; }; + fpsDisplayVisible.ValueChanged += visible => { FrameStatisticsMode = visible.NewValue ? FrameStatisticsMode.Minimal : FrameStatisticsMode.None; }; fpsDisplayVisible.TriggerChange(); } diff --git a/osu.Game/Overlays/AccountCreation/ErrorTextFlowContainer.cs b/osu.Game/Overlays/AccountCreation/ErrorTextFlowContainer.cs index bb436dbb2c..87ff4dd398 100644 --- a/osu.Game/Overlays/AccountCreation/ErrorTextFlowContainer.cs +++ b/osu.Game/Overlays/AccountCreation/ErrorTextFlowContainer.cs @@ -13,7 +13,7 @@ namespace osu.Game.Overlays.AccountCreation private readonly List errorDrawables = new List(); public ErrorTextFlowContainer() - : base(cp => { cp.TextSize = 12; }) + : base(cp => cp.Font = cp.Font.With(size: 12)) { } diff --git a/osu.Game/Overlays/AccountCreation/ScreenEntry.cs b/osu.Game/Overlays/AccountCreation/ScreenEntry.cs index 407d2cfbf1..2fc00edbc1 100644 --- a/osu.Game/Overlays/AccountCreation/ScreenEntry.cs +++ b/osu.Game/Overlays/AccountCreation/ScreenEntry.cs @@ -61,10 +61,10 @@ namespace osu.Game.Overlays.AccountCreation { new OsuSpriteText { - TextSize = 20, Margin = new MarginPadding { Vertical = 10 }, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, + Font = OsuFont.GetFont(size: 20), Text = "Let's create an account!", }, usernameTextBox = new OsuTextBox @@ -129,13 +129,13 @@ namespace osu.Game.Overlays.AccountCreation usernameDescription.AddText("This will be your public presence. No profanity, no impersonation. Avoid exposing your own personal details, too!"); emailAddressDescription.AddText("Will be used for notifications, account verification and in the case you forget your password. No spam, ever."); - emailAddressDescription.AddText(" Make sure to get it right!", cp => cp.Font = "Exo2.0-Bold"); + emailAddressDescription.AddText(" Make sure to get it right!", cp => cp.Font = cp.Font.With(Typeface.Exo, weight: FontWeight.Bold)); passwordDescription.AddText("At least "); characterCheckText = passwordDescription.AddText("8 characters long"); passwordDescription.AddText(". Choose something long but also something you will remember, like a line from your favourite song."); - passwordTextBox.Current.ValueChanged += text => { characterCheckText.ForEach(s => s.Colour = text.Length == 0 ? Color4.White : Interpolation.ValueAt(text.Length, Color4.OrangeRed, Color4.YellowGreen, 0, 8, Easing.In)); }; + passwordTextBox.Current.ValueChanged += password => { characterCheckText.ForEach(s => s.Colour = password.NewValue.Length == 0 ? Color4.White : Interpolation.ValueAt(password.NewValue.Length, Color4.OrangeRed, Color4.YellowGreen, 0, 8, Easing.In)); }; } protected override void Update() diff --git a/osu.Game/Overlays/AccountCreation/ScreenWarning.cs b/osu.Game/Overlays/AccountCreation/ScreenWarning.cs index 3cc84e3562..4e2cc1ea00 100644 --- a/osu.Game/Overlays/AccountCreation/ScreenWarning.cs +++ b/osu.Game/Overlays/AccountCreation/ScreenWarning.cs @@ -83,14 +83,13 @@ namespace osu.Game.Overlays.AccountCreation }, new OsuSpriteText { - TextSize = 28, - Font = "Exo2.0-Light", Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Colour = Color4.Red, + Font = OsuFont.GetFont(size: 28, weight: FontWeight.Light), Text = "Warning! 注意!", }, - multiAccountExplanationText = new OsuTextFlowContainer(cp => { cp.TextSize = 12; }) + multiAccountExplanationText = new OsuTextFlowContainer(cp => cp.Font = cp.Font.With(size: 12)) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y @@ -106,7 +105,7 @@ namespace osu.Game.Overlays.AccountCreation Text = "I understand. This account isn't for me.", Action = () => this.Push(new ScreenEntry()) }, - furtherAssistance = new LinkFlowContainer(cp => { cp.TextSize = 12; }) + furtherAssistance = new LinkFlowContainer(cp => cp.Font = cp.Font.With(size: 12)) { Margin = new MarginPadding { Top = 20 }, Anchor = Anchor.TopCentre, diff --git a/osu.Game/Overlays/AccountCreation/ScreenWelcome.cs b/osu.Game/Overlays/AccountCreation/ScreenWelcome.cs index d4b8323394..f6ddb135ec 100644 --- a/osu.Game/Overlays/AccountCreation/ScreenWelcome.cs +++ b/osu.Game/Overlays/AccountCreation/ScreenWelcome.cs @@ -5,6 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Screens; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Settings; using osu.Game.Screens.Menu; @@ -40,17 +41,16 @@ namespace osu.Game.Overlays.AccountCreation }, new OsuSpriteText { - TextSize = 24, - Font = "Exo2.0-Light", Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, + Font = OsuFont.GetFont(size: 24, weight: FontWeight.Light), Text = "New Player Registration", }, new OsuSpriteText { - TextSize = 12, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, + Font = OsuFont.GetFont(size: 12), Text = "let's get you started", }, new SettingsButton diff --git a/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs index c9907014ca..18de87e7b4 100644 --- a/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs +++ b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs @@ -11,6 +11,8 @@ using osuTK; using osuTK.Graphics; using osu.Game.Graphics.Containers; using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; namespace osu.Game.Overlays.BeatmapSet { @@ -25,10 +27,11 @@ namespace osu.Game.Overlays.BeatmapSet public BeatmapSetInfo BeatmapSet { - get { return beatmapSet; } + get => beatmapSet; set { if (value == beatmapSet) return; + beatmapSet = value; updateDisplay(); @@ -47,8 +50,8 @@ namespace osu.Game.Overlays.BeatmapSet fields.Children = new Drawable[] { - new Field("mapped by", BeatmapSet.Metadata.Author.Username, @"Exo2.0-RegularItalic"), - new Field("submitted on", online.Submitted.ToString(@"MMMM d, yyyy"), @"Exo2.0-Bold") + new Field("mapped by", BeatmapSet.Metadata.Author.Username, OsuFont.GetFont(weight: FontWeight.Regular, italics: true)), + new Field("submitted on", online.Submitted.ToString(@"MMMM d, yyyy"), OsuFont.GetFont(weight: FontWeight.Bold)) { Margin = new MarginPadding { Top = 5 }, }, @@ -56,11 +59,11 @@ namespace osu.Game.Overlays.BeatmapSet if (online.Ranked.HasValue) { - fields.Add(new Field("ranked on", online.Ranked.Value.ToString(@"MMMM d, yyyy"), @"Exo2.0-Bold")); + fields.Add(new Field("ranked on", online.Ranked.Value.ToString(@"MMMM d, yyyy"), OsuFont.GetFont(weight: FontWeight.Bold))); } else if (online.LastUpdated.HasValue) { - fields.Add(new Field("last updated on", online.LastUpdated.Value.ToString(@"MMMM d, yyyy"), @"Exo2.0-Bold")); + fields.Add(new Field("last updated on", online.LastUpdated.Value.ToString(@"MMMM d, yyyy"), OsuFont.GetFont(weight: FontWeight.Bold))); } } @@ -105,7 +108,7 @@ namespace osu.Game.Overlays.BeatmapSet private class Field : FillFlowContainer { - public Field(string first, string second, string secondFont) + public Field(string first, string second, FontUsage secondFont) { AutoSizeAxes = Axes.Both; Direction = FillDirection.Horizontal; @@ -115,13 +118,12 @@ namespace osu.Game.Overlays.BeatmapSet new OsuSpriteText { Text = $"{first} ", - TextSize = 13, + Font = OsuFont.GetFont(size: 13) }, new OsuSpriteText { Text = second, - TextSize = 13, - Font = secondFont, + Font = secondFont.With(size: 13) }, }; } diff --git a/osu.Game/Overlays/BeatmapSet/BasicStats.cs b/osu.Game/Overlays/BeatmapSet/BasicStats.cs index af5998bfa1..9ed9875be9 100644 --- a/osu.Game/Overlays/BeatmapSet/BasicStats.cs +++ b/osu.Game/Overlays/BeatmapSet/BasicStats.cs @@ -21,10 +21,11 @@ namespace osu.Game.Overlays.BeatmapSet public BeatmapSetInfo BeatmapSet { - get { return beatmapSet; } + get => beatmapSet; set { if (value == beatmapSet) return; + beatmapSet = value; updateDisplay(); @@ -35,10 +36,11 @@ namespace osu.Game.Overlays.BeatmapSet public BeatmapInfo Beatmap { - get { return beatmap; } + get => beatmap; set { if (value == beatmap) return; + beatmap = value; updateDisplay(); @@ -95,8 +97,8 @@ namespace osu.Game.Overlays.BeatmapSet public string Value { - get { return value.Text; } - set { this.value.Text = value; } + get => value.Text; + set => this.value.Text = value; } public Statistic(FontAwesome icon, string name) @@ -136,9 +138,8 @@ namespace osu.Game.Overlays.BeatmapSet { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - TextSize = 13, - Font = @"Exo2.0-Bold", Margin = new MarginPadding { Left = 10 }, + Font = OsuFont.GetFont(size: 13, weight: FontWeight.Bold), }, }, }, diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs index c2edaf01ed..55dee904b4 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs @@ -5,7 +5,7 @@ using System; using System.Linq; using osu.Framework; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -33,12 +33,14 @@ namespace osu.Game.Overlays.BeatmapSet public readonly Bindable Beatmap = new Bindable(); private BeatmapSetInfo beatmapSet; + public BeatmapSetInfo BeatmapSet { - get { return beatmapSet; } + get => beatmapSet; set { if (value == beatmapSet) return; + beatmapSet = value; updateDisplay(); @@ -107,15 +109,13 @@ namespace osu.Game.Overlays.BeatmapSet { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - TextSize = 20, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold) }, starRating = new OsuSpriteText { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - TextSize = 13, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 13, weight: FontWeight.Bold), Text = "Star Difficulty", Alpha = 0, Margin = new MarginPadding { Bottom = 1 }, @@ -140,7 +140,7 @@ namespace osu.Game.Overlays.BeatmapSet Beatmap.ValueChanged += b => { - showBeatmap(b); + showBeatmap(b.NewValue); updateDifficultyButtons(); }; } @@ -196,12 +196,14 @@ namespace osu.Game.Overlays.BeatmapSet public event Action StateChanged; private DifficultySelectorState state; + public DifficultySelectorState State { - get { return state; } + get => state; set { if (value == state) return; + state = value; StateChanged?.Invoke(State); @@ -279,9 +281,10 @@ namespace osu.Game.Overlays.BeatmapSet private readonly OsuSpriteText text; private int value; + public int Value { - get { return value; } + get => value; set { this.value = value; @@ -309,8 +312,7 @@ namespace osu.Game.Overlays.BeatmapSet { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Font = @"Exo2.0-SemiBoldItalic", - TextSize = 14, + Font = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold, italics: true) }, }; } diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs index 4d46d41c0f..edd886f0f2 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -22,7 +22,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons { private readonly bool noVideo; - public string TooltipText => button.Enabled ? "Download this beatmap" : "Login to download"; + public string TooltipText => button.Enabled.Value ? "Download this beatmap" : "Login to download"; private readonly IBindable localUser = new Bindable(); @@ -83,7 +83,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons }, } }, - new DownloadProgressBar(BeatmapSet) + new DownloadProgressBar(BeatmapSet.Value) { Depth = -2, Anchor = Anchor.BottomLeft, @@ -101,7 +101,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons return; } - beatmaps.Download(BeatmapSet, noVideo); + beatmaps.Download(BeatmapSet.Value, noVideo); }; localUser.BindTo(api.LocalUser); @@ -110,7 +110,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons State.BindValueChanged(state => { - switch (state) + switch (state.NewValue) { case DownloadState.Downloading: textSprites.Children = new Drawable[] @@ -118,8 +118,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons new OsuSpriteText { Text = "Downloading...", - TextSize = 13, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 13, weight: FontWeight.Bold) }, }; break; @@ -129,8 +128,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons new OsuSpriteText { Text = "Importing...", - TextSize = 13, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 13, weight: FontWeight.Bold) }, }; break; @@ -143,14 +141,12 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons new OsuSpriteText { Text = "Download", - TextSize = 13, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 13, weight: FontWeight.Bold) }, new OsuSpriteText { Text = BeatmapSet.Value.OnlineInfo.HasVideo && noVideo ? "without Video" : string.Empty, - TextSize = 11, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 11, weight: FontWeight.Bold) }, }; this.FadeIn(200); @@ -159,8 +155,8 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons }, true); } - private void userChanged(User user) => button.Enabled.Value = !(user is GuestUser); + private void userChanged(ValueChangedEvent e) => button.Enabled.Value = !(e.NewValue is GuestUser); - private void enabledChanged(bool enabled) => this.FadeColour(enabled ? Color4.White : Color4.Gray, 200, Easing.OutQuint); + private void enabledChanged(ValueChangedEvent e) => this.FadeColour(e.NewValue ? Color4.White : Color4.Gray, 200, Easing.OutQuint); } } diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs index b672e7bf07..7824a78a14 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -53,9 +53,9 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons }, }); - Favourited.ValueChanged += value => + Favourited.ValueChanged += favourited => { - if (value) + if (favourited.NewValue) { pink.FadeIn(200); icon.Icon = FontAwesome.fa_heart; diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs index 12b4a7e2d7..8c884e0950 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -30,8 +30,8 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons public BeatmapSetInfo BeatmapSet { - get { return playButton.BeatmapSet; } - set { playButton.BeatmapSet = value; } + get => playButton.BeatmapSet; + set => playButton.BeatmapSet = value; } public PreviewButton() @@ -67,7 +67,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons }; Action = () => playButton.Click(); - Playing.ValueChanged += newValue => progress.FadeTo(newValue ? 1 : 0, 100); + Playing.ValueChanged += playing => progress.FadeTo(playing.NewValue ? 1 : 0, 100); } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/BeatmapSet/Details.cs b/osu.Game/Overlays/BeatmapSet/Details.cs index 538d327d98..fad5c973b7 100644 --- a/osu.Game/Overlays/BeatmapSet/Details.cs +++ b/osu.Game/Overlays/BeatmapSet/Details.cs @@ -25,10 +25,11 @@ namespace osu.Game.Overlays.BeatmapSet public BeatmapSetInfo BeatmapSet { - get { return beatmapSet; } + get => beatmapSet; set { if (value == beatmapSet) return; + beatmapSet = value; basic.BeatmapSet = preview.BeatmapSet = BeatmapSet; @@ -39,7 +40,7 @@ namespace osu.Game.Overlays.BeatmapSet public BeatmapInfo Beatmap { - get { return beatmap; } + get => beatmap; set { if (value == beatmap) return; diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 8721a1ce5a..95cf9e9d04 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -115,8 +115,7 @@ namespace osu.Game.Overlays.BeatmapSet { title = new OsuSpriteText { - Font = @"Exo2.0-BoldItalic", - TextSize = 37, + Font = OsuFont.GetFont(size: 37, weight: FontWeight.Bold, italics: true) }, externalLink = new ExternalLinkButton { @@ -126,11 +125,7 @@ namespace osu.Game.Overlays.BeatmapSet }, } }, - artist = new OsuSpriteText - { - Font = @"Exo2.0-SemiBoldItalic", - TextSize = 25, - }, + artist = new OsuSpriteText { Font = OsuFont.GetFont(size: 25, weight: FontWeight.SemiBold, italics: true) }, new Container { RelativeSizeAxes = Axes.X, @@ -181,8 +176,8 @@ namespace osu.Game.Overlays.BeatmapSet }, }; - Picker.Beatmap.ValueChanged += b => Details.Beatmap = b; - Picker.Beatmap.ValueChanged += b => externalLink.Link = $@"https://osu.ppy.sh/beatmapsets/{BeatmapSet.Value?.OnlineBeatmapSetID}#{b?.Ruleset.ShortName}/{b?.OnlineBeatmapID}"; + Picker.Beatmap.ValueChanged += b => Details.Beatmap = b.NewValue; + Picker.Beatmap.ValueChanged += b => externalLink.Link = $@"https://osu.ppy.sh/beatmapsets/{BeatmapSet.Value?.OnlineBeatmapSetID}#{b.NewValue?.Ruleset.ShortName}/{b.NewValue?.OnlineBeatmapID}"; } [BackgroundDependencyLoader] @@ -192,16 +187,16 @@ namespace osu.Game.Overlays.BeatmapSet State.BindValueChanged(_ => updateDownloadButtons()); - BeatmapSet.BindValueChanged(beatmapSet => + BeatmapSet.BindValueChanged(setInfo => { - Picker.BeatmapSet = author.BeatmapSet = Details.BeatmapSet = beatmapSet; + Picker.BeatmapSet = author.BeatmapSet = Details.BeatmapSet = setInfo.NewValue; - title.Text = beatmapSet?.Metadata.Title ?? string.Empty; - artist.Text = beatmapSet?.Metadata.Artist ?? string.Empty; - onlineStatusPill.Status = beatmapSet?.OnlineInfo.Status ?? BeatmapSetOnlineStatus.None; - cover.BeatmapSet = beatmapSet; + title.Text = setInfo.NewValue?.Metadata.Title ?? string.Empty; + artist.Text = setInfo.NewValue?.Metadata.Artist ?? string.Empty; + onlineStatusPill.Status = setInfo.NewValue?.OnlineInfo.Status ?? BeatmapSetOnlineStatus.None; + cover.BeatmapSet = setInfo.NewValue; - if (beatmapSet != null) + if (setInfo.NewValue != null) { downloadButtonsContainer.FadeIn(transition_duration); favouriteButton.FadeIn(transition_duration); @@ -219,11 +214,12 @@ namespace osu.Game.Overlays.BeatmapSet private void updateDownloadButtons() { if (BeatmapSet.Value == null) return; + switch (State.Value) { case DownloadState.LocallyAvailable: // temporary for UX until new design is implemented. - downloadButtonsContainer.Child = new osu.Game.Overlays.Direct.DownloadButton(BeatmapSet) + downloadButtonsContainer.Child = new osu.Game.Overlays.Direct.DownloadButton(BeatmapSet.Value) { Width = 50, RelativeSizeAxes = Axes.Y @@ -232,12 +228,12 @@ namespace osu.Game.Overlays.BeatmapSet case DownloadState.Downloading: case DownloadState.Downloaded: // temporary to avoid showing two buttons for maps with novideo. will be fixed in new beatmap overlay design. - downloadButtonsContainer.Child = new DownloadButton(BeatmapSet); + downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); break; default: - downloadButtonsContainer.Child = new DownloadButton(BeatmapSet); + downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); if (BeatmapSet.Value.OnlineInfo.HasVideo) - downloadButtonsContainer.Add(new DownloadButton(BeatmapSet, true)); + downloadButtonsContainer.Add(new DownloadButton(BeatmapSet.Value, true)); break; } } diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index 3a32abe9cc..4d974a0b63 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -21,37 +22,20 @@ namespace osu.Game.Overlays.BeatmapSet private const float metadata_width = 225; private const float spacing = 20; - private readonly MetadataSection source, tags; private readonly Box successRateBackground; private readonly SuccessRate successRate; - private BeatmapSetInfo beatmapSet; - public BeatmapSetInfo BeatmapSet - { - get { return beatmapSet; } - set - { - if (value == beatmapSet) return; - beatmapSet = value; - - updateDisplay(); - } - } - - private void updateDisplay() - { - source.Text = BeatmapSet?.Metadata.Source ?? string.Empty; - tags.Text = BeatmapSet?.Metadata.Tags ?? string.Empty; - } + public readonly Bindable BeatmapSet = new Bindable(); public BeatmapInfo Beatmap { - get { return successRate.Beatmap; } - set { successRate.Beatmap = value; } + get => successRate.Beatmap; + set => successRate.Beatmap = value; } public Info() { + MetadataSection source, tags; RelativeSizeAxes = Axes.X; Height = 220; Masking = true; @@ -129,14 +113,18 @@ namespace osu.Game.Overlays.BeatmapSet }, }, }; + + BeatmapSet.ValueChanged += b => + { + source.Text = b.NewValue?.Metadata.Source ?? string.Empty; + tags.Text = b.NewValue?.Metadata.Tags ?? string.Empty; + }; } [BackgroundDependencyLoader] private void load(OsuColour colours) { successRateBackground.Colour = colours.GrayE; - - updateDisplay(); } private class MetadataSection : FillFlowContainer @@ -156,14 +144,14 @@ namespace osu.Game.Overlays.BeatmapSet this.FadeIn(transition_duration); textFlow.Clear(); - textFlow.AddText(value, s => s.TextSize = 14); + textFlow.AddText(value, s => s.Font = s.Font.With(size: 14)); } } public Color4 TextColour { - get { return textFlow.Colour; } - set { textFlow.Colour = value; } + get => textFlow.Colour; + set => textFlow.Colour = value; } public MetadataSection(string title) @@ -177,8 +165,7 @@ namespace osu.Game.Overlays.BeatmapSet header = new OsuSpriteText { Text = title, - Font = @"Exo2.0-Bold", - TextSize = 14, + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), Shadow = false, Margin = new MarginPadding { Top = 20 }, }, diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUsername.cs b/osu.Game/Overlays/BeatmapSet/Scores/ClickableUsername.cs index 0eb8b325d3..31af251877 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUsername.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ClickableUsername.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Input.Events; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Users; @@ -16,12 +17,14 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private UserProfileOverlay profile; private User user; + public User User { - get { return user; } + get => user; set { if (user == value) return; + user = value; text.Text = user.Username; @@ -30,21 +33,14 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public float TextSize { - set - { - if (text.TextSize == value) return; - text.TextSize = value; - } - get { return text.TextSize; } + get => text.Font.Size; + set => text.Font = text.Font.With(size: value); } public ClickableUsername() { AutoSizeAxes = Axes.Both; - Child = text = new OsuSpriteText - { - Font = @"Exo2.0-BoldItalic", - }; + Child = text = new OsuSpriteText { Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true) }; } [BackgroundDependencyLoader(true)] diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs index 1f50385adc..c6c8315aeb 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs @@ -46,7 +46,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Text = $"#{index + 1}", - Font = @"Exo2.0-RegularItalic", + Font = OsuFont.GetFont(weight: FontWeight.Regular, italics: true), Margin = new MarginPadding { Left = side_margin } }, new DrawableFlag(score.User.Country) @@ -87,17 +87,16 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Anchor = Anchor.CentreLeft, Origin = Anchor.CentreRight, Text = $@"{score.TotalScore:N0}", - Font = @"Venera", + Font = OsuFont.Numeric.With(fixedWidth: true), RelativePositionAxes = Axes.X, X = 0.75f, - FixedWidth = true, }, new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreRight, Text = $@"{score.Accuracy:P2}", - Font = @"Exo2.0-RegularItalic", + Font = OsuFont.GetFont(weight: FontWeight.Regular, italics: true), RelativePositionAxes = Axes.X, X = 0.85f }, @@ -106,7 +105,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, Text = $"{score.Statistics[HitResult.Great]}/{score.Statistics[HitResult.Good]}/{score.Statistics[HitResult.Meh]}", - Font = @"Exo2.0-RegularItalic", + Font = OsuFont.GetFont(weight: FontWeight.Regular, italics: true), Margin = new MarginPadding { Right = side_margin } }, }; diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index c9551cf6f8..78e560cdbe 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -44,12 +44,14 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly ScoreModsContainer modsContainer; private APIScoreInfo score; + public APIScoreInfo Score { - get { return score; } + get => score; set { if (score == value) return; + score = value; avatar.User = username.User = score.User; @@ -117,8 +119,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Anchor = Anchor.TopRight, Origin = Anchor.BottomRight, Text = "#1", - TextSize = 40, - Font = @"Exo2.0-BoldItalic", + Font = OsuFont.GetFont(size: 40, weight: FontWeight.Bold, italics: true), Y = height / 4, Margin = new MarginPadding { Right = margin } }, @@ -208,9 +209,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { if (valueText.Text == value) return; + valueText.Text = value; } - get { return valueText.Text; } + get => valueText.Text; } public InfoColumn(string header) @@ -222,15 +224,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { headerText = new OsuSpriteText { - TextSize = 14, Text = header, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold) }, - valueText = new OsuSpriteText - { - TextSize = 25, - Font = @"Exo2.0-RegularItalic", - } + valueText = new OsuSpriteText { Font = OsuFont.GetFont(size: 25, weight: FontWeight.Regular, italics: true) } }; } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index ab34d2ba1d..6c65d491af 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -34,7 +34,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public IEnumerable Scores { - get { return scores; } + get => scores; set { getScoresRequest?.Cancel(); diff --git a/osu.Game/Overlays/BeatmapSet/SuccessRate.cs b/osu.Game/Overlays/BeatmapSet/SuccessRate.cs index 28902561f4..c89bddca63 100644 --- a/osu.Game/Overlays/BeatmapSet/SuccessRate.cs +++ b/osu.Game/Overlays/BeatmapSet/SuccessRate.cs @@ -21,12 +21,14 @@ namespace osu.Game.Overlays.BeatmapSet private readonly FailRetryGraph graph; private BeatmapInfo beatmap; + public BeatmapInfo Beatmap { - get { return beatmap; } + get => beatmap; set { if (value == beatmap) return; + beatmap = value; updateDisplay(); @@ -62,7 +64,7 @@ namespace osu.Game.Overlays.BeatmapSet Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = "Success Rate", - TextSize = 13, + Font = OsuFont.GetFont(size: 13) }, successRate = new Bar { @@ -79,7 +81,7 @@ namespace osu.Game.Overlays.BeatmapSet { Anchor = Anchor.TopRight, Origin = Anchor.TopCentre, - TextSize = 13, + Font = OsuFont.GetFont(size: 13), }, }, graphLabel = new OsuSpriteText @@ -87,7 +89,7 @@ namespace osu.Game.Overlays.BeatmapSet Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = "Points of Failure", - TextSize = 13, + Font = OsuFont.GetFont(size: 13), Margin = new MarginPadding { Vertical = 20 }, }, }, diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index 1237b17214..55c21b7fc9 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -3,6 +3,7 @@ using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -29,32 +30,20 @@ namespace osu.Game.Overlays public const float RIGHT_WIDTH = 275; private readonly Header header; - private readonly Info info; private APIAccess api; private RulesetStore rulesets; private readonly ScrollContainer scroll; - private BeatmapSetInfo beatmapSet; - - public BeatmapSetInfo BeatmapSet - { - get => beatmapSet; - set - { - if (value == beatmapSet) - return; - - header.BeatmapSet.Value = info.BeatmapSet = beatmapSet = value; - } - } + private readonly Bindable beatmapSet = new Bindable(); // receive input outside our bounds so we can trigger a close event on ourselves. public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; public BeatmapSetOverlay() { + Info info; ScoresContainer scores; Waves.FirstWaveColour = OsuColour.Gray(0.4f); Waves.SecondWaveColour = OsuColour.Gray(0.3f); @@ -101,10 +90,13 @@ namespace osu.Game.Overlays }, }; + header.BeatmapSet.BindTo(beatmapSet); + info.BeatmapSet.BindTo(beatmapSet); + header.Picker.Beatmap.ValueChanged += b => { - info.Beatmap = b; - scores.Beatmap = b; + info.Beatmap = b.NewValue; + scores.Beatmap = b.NewValue; }; } @@ -124,7 +116,7 @@ namespace osu.Game.Overlays protected override void PopOut() { base.PopOut(); - FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out).OnComplete(_ => BeatmapSet = null); + FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out).OnComplete(_ => beatmapSet.Value = null); } protected override bool OnClick(ClickEvent e) @@ -135,11 +127,11 @@ namespace osu.Game.Overlays public void FetchAndShowBeatmap(int beatmapId) { - BeatmapSet = null; + beatmapSet.Value = null; var req = new GetBeatmapSetRequest(beatmapId, BeatmapSetLookupType.BeatmapId); req.Success += res => { - BeatmapSet = res.ToBeatmapSet(rulesets); + beatmapSet.Value = res.ToBeatmapSet(rulesets); header.Picker.Beatmap.Value = header.BeatmapSet.Value.Beatmaps.First(b => b.OnlineBeatmapID == beatmapId); }; api.Queue(req); @@ -148,16 +140,16 @@ namespace osu.Game.Overlays public void FetchAndShowBeatmapSet(int beatmapSetId) { - BeatmapSet = null; + beatmapSet.Value = null; var req = new GetBeatmapSetRequest(beatmapSetId); - req.Success += res => BeatmapSet = res.ToBeatmapSet(rulesets); + req.Success += res => beatmapSet.Value = res.ToBeatmapSet(rulesets); api.Queue(req); Show(); } public void ShowBeatmapSet(BeatmapSetInfo set) { - BeatmapSet = set; + beatmapSet.Value = set; Show(); scroll.ScrollTo(0); } diff --git a/osu.Game/Overlays/Chat/ChatLine.cs b/osu.Game/Overlays/Chat/ChatLine.cs index 3e2ef07ef2..a679f33e3a 100644 --- a/osu.Game/Overlays/Chat/ChatLine.cs +++ b/osu.Game/Overlays/Chat/ChatLine.cs @@ -87,9 +87,8 @@ namespace osu.Game.Overlays.Chat Drawable effectedUsername = username = new OsuSpriteText { - Font = @"Exo2.0-BoldItalic", Colour = hasBackground ? customUsernameColour : username_colours[message.Sender.Id % username_colours.Length], - TextSize = TextSize, + Font = OsuFont.GetFont(size: TextSize, weight: FontWeight.Bold, italics: true) }; if (hasBackground) @@ -138,9 +137,7 @@ namespace osu.Game.Overlays.Chat { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Font = @"Exo2.0-SemiBold", - FixedWidth = true, - TextSize = TextSize * 0.75f, + Font = OsuFont.GetFont(size: TextSize * 0.75f, weight: FontWeight.Bold, fixedWidth: true) }, new MessageSender(message.Sender) { @@ -162,13 +159,13 @@ namespace osu.Game.Overlays.Chat { if (Message.IsAction) { - t.Font = @"Exo2.0-MediumItalic"; + t.Font = OsuFont.GetFont(italics: true); if (senderHasBackground) t.Colour = OsuColour.FromHex(message.Sender.Colour); } - t.TextSize = TextSize; + t.Font = t.Font.With(size: TextSize); }) { AutoSizeAxes = Axes.Y, diff --git a/osu.Game/Overlays/Chat/Selection/ChannelListItem.cs b/osu.Game/Overlays/Chat/Selection/ChannelListItem.cs index 23dedf251f..a36abc4f99 100644 --- a/osu.Game/Overlays/Chat/Selection/ChannelListItem.cs +++ b/osu.Game/Overlays/Chat/Selection/ChannelListItem.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using osuTK; using osuTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; @@ -36,12 +36,10 @@ namespace osu.Game.Overlays.Chat.Selection private Color4 hoverColour; public IEnumerable FilterTerms => new[] { channel.Name }; + public bool MatchingFilter { - set - { - this.FadeTo(value ? 1f : 0f, 100); - } + set => this.FadeTo(value ? 1f : 0f, 100); } public Action OnRequestJoin; @@ -54,7 +52,7 @@ namespace osu.Game.Overlays.Chat.Selection RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - Action = () => { (channel.Joined ? OnRequestLeave : OnRequestJoin)?.Invoke(channel); }; + Action = () => { (channel.Joined.Value ? OnRequestLeave : OnRequestJoin)?.Invoke(channel); }; Children = new Drawable[] { @@ -89,8 +87,7 @@ namespace osu.Game.Overlays.Chat.Selection name = new OsuSpriteText { Text = channel.ToString(), - TextSize = text_size, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold), Shadow = false, }, }, @@ -106,8 +103,7 @@ namespace osu.Game.Overlays.Chat.Selection topic = new OsuSpriteText { Text = channel.Topic, - TextSize = text_size, - Font = @"Exo2.0-SemiBold", + Font = OsuFont.GetFont(size: text_size, weight: FontWeight.SemiBold), Shadow = false, }, }, @@ -130,8 +126,7 @@ namespace osu.Game.Overlays.Chat.Selection new OsuSpriteText { Text = @"0", - TextSize = text_size, - Font = @"Exo2.0-SemiBold", + Font = OsuFont.GetFont(size: text_size, weight: FontWeight.SemiBold), Shadow = false, }, }, @@ -148,7 +143,7 @@ namespace osu.Game.Overlays.Chat.Selection joinedColour = colours.Blue; hoverColour = colours.Yellow; - joinedBind.ValueChanged += updateColour; + joinedBind.ValueChanged += joined => updateColour(joined.NewValue); joinedBind.BindTo(channel.Joined); joinedBind.TriggerChange(); diff --git a/osu.Game/Overlays/Chat/Selection/ChannelSection.cs b/osu.Game/Overlays/Chat/Selection/ChannelSection.cs index 2af416f7c0..3f979b6309 100644 --- a/osu.Game/Overlays/Chat/Selection/ChannelSection.cs +++ b/osu.Game/Overlays/Chat/Selection/ChannelSection.cs @@ -7,6 +7,7 @@ using System.Linq; using osuTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Online.Chat; @@ -20,23 +21,21 @@ namespace osu.Game.Overlays.Chat.Selection public IEnumerable FilterableChildren => ChannelFlow.Children; public IEnumerable FilterTerms => Array.Empty(); + public bool MatchingFilter { - set - { - this.FadeTo(value ? 1f : 0f, 100); - } + set => this.FadeTo(value ? 1f : 0f, 100); } public string Header { - get { return header.Text; } - set { header.Text = value.ToUpperInvariant(); } + get => header.Text; + set => header.Text = value.ToUpperInvariant(); } public IEnumerable Channels { - set { ChannelFlow.ChildrenEnumerable = value.Select(c => new ChannelListItem(c)); } + set => ChannelFlow.ChildrenEnumerable = value.Select(c => new ChannelListItem(c)); } public ChannelSection() @@ -48,8 +47,7 @@ namespace osu.Game.Overlays.Chat.Selection { header = new OsuSpriteText { - TextSize = 15, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold), }, ChannelFlow = new FillFlowContainer { diff --git a/osu.Game/Overlays/Chat/Selection/ChannelSelectionOverlay.cs b/osu.Game/Overlays/Chat/Selection/ChannelSelectionOverlay.cs index 00de5fd5fd..feb47b9e8e 100644 --- a/osu.Game/Overlays/Chat/Selection/ChannelSelectionOverlay.cs +++ b/osu.Game/Overlays/Chat/Selection/ChannelSelectionOverlay.cs @@ -110,7 +110,7 @@ namespace osu.Game.Overlays.Chat.Selection new OsuSpriteText { Text = @"Chat Channels", - TextSize = 20, + Font = OsuFont.GetFont(size: 20), Shadow = false, }, search = new HeaderSearchTextBox @@ -125,7 +125,7 @@ namespace osu.Game.Overlays.Chat.Selection }, }; - search.Current.ValueChanged += newValue => sectionsFlow.SearchTerm = newValue; + search.Current.ValueChanged += term => sectionsFlow.SearchTerm = term.NewValue; } public void UpdateAvailableChannels(IEnumerable channels) diff --git a/osu.Game/Overlays/Chat/Tabs/ChannelSelectorTabItem.cs b/osu.Game/Overlays/Chat/Tabs/ChannelSelectorTabItem.cs index d7d299a2cf..52260506fe 100644 --- a/osu.Game/Overlays/Chat/Tabs/ChannelSelectorTabItem.cs +++ b/osu.Game/Overlays/Chat/Tabs/ChannelSelectorTabItem.cs @@ -13,15 +13,16 @@ namespace osu.Game.Overlays.Chat.Tabs public override bool IsSwitchable => false; - public ChannelSelectorTabItem(Channel value) : base(value) + public ChannelSelectorTabItem(Channel value) + : base(value) { Depth = float.MaxValue; Width = 45; Icon.Alpha = 0; - Text.TextSize = 45; - TextBold.TextSize = 45; + Text.Font = Text.Font.With(size: 45); + TextBold.Font = Text.Font.With(size: 45); } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/Chat/Tabs/ChannelTabControl.cs b/osu.Game/Overlays/Chat/Tabs/ChannelTabControl.cs index ccf4af651b..7a43ca4b8c 100644 --- a/osu.Game/Overlays/Chat/Tabs/ChannelTabControl.cs +++ b/osu.Game/Overlays/Chat/Tabs/ChannelTabControl.cs @@ -7,9 +7,9 @@ using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Online.Chat; using osuTK; -using osu.Framework.Configuration; using System; using System.Linq; +using osu.Framework.Bindables; namespace osu.Game.Overlays.Chat.Tabs { @@ -110,7 +110,7 @@ namespace osu.Game.Overlays.Chat.Tabs if (tab == SelectedTab && totalTabs > 1) // Select the tab after tab-to-be-removed's index, or the tab before if current == last SelectTab(TabContainer[currentIndex == totalTabs ? currentIndex - 1 : currentIndex + 1]); - else if (totalTabs == 1 && !selectorTab.Active) + else if (totalTabs == 1 && !selectorTab.Active.Value) // Open channel selection overlay if all channel tabs will be closed after removing this tab SelectTab(selectorTab); diff --git a/osu.Game/Overlays/Chat/Tabs/ChannelTabItem.cs b/osu.Game/Overlays/Chat/Tabs/ChannelTabItem.cs index 7acd56c864..95c5fbf8fa 100644 --- a/osu.Game/Overlays/Chat/Tabs/ChannelTabItem.cs +++ b/osu.Game/Overlays/Chat/Tabs/ChannelTabItem.cs @@ -90,7 +90,7 @@ namespace osu.Game.Overlays.Chat.Tabs Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, Text = value.ToString(), - TextSize = 18, + Font = OsuFont.GetFont(size: 18) }, TextBold = new OsuSpriteText { @@ -99,8 +99,7 @@ namespace osu.Game.Overlays.Chat.Tabs Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, Text = value.ToString(), - Font = @"Exo2.0-Bold", - TextSize = 18, + Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold) }, CloseButton = new TabCloseButton { @@ -127,7 +126,7 @@ namespace osu.Game.Overlays.Chat.Tabs if (IsRemovable && ShowCloseOnHover) CloseButton.FadeIn(200, Easing.OutQuint); - if (!Active) + if (!Active.Value) box.FadeColour(backgroundHover, TRANSITION_LENGTH, Easing.OutQuint); return true; } @@ -158,7 +157,7 @@ namespace osu.Game.Overlays.Chat.Tabs private void updateState() { - if (Active) + if (Active.Value) FadeActive(); else FadeInactive(); diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 821c942a57..5428279325 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -6,7 +6,7 @@ using System.Linq; using osuTK; using osuTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -162,8 +162,8 @@ namespace osu.Game.Overlays }, }; - channelTabControl.Current.ValueChanged += chat => channelManager.CurrentChannel.Value = chat; - channelTabControl.ChannelSelectorActive.ValueChanged += value => channelSelectionOverlay.State = value ? Visibility.Visible : Visibility.Hidden; + channelTabControl.Current.ValueChanged += current => channelManager.CurrentChannel.Value = current.NewValue; + channelTabControl.ChannelSelectorActive.ValueChanged += active => channelSelectionOverlay.State = active.NewValue ? Visibility.Visible : Visibility.Hidden; channelSelectionOverlay.StateChanged += state => { if (state == Visibility.Hidden && channelManager.CurrentChannel.Value == null) @@ -189,9 +189,9 @@ namespace osu.Game.Overlays channelSelectionOverlay.OnRequestLeave = channel => channelManager.LeaveChannel(channel); } - private void currentChannelChanged(Channel channel) + private void currentChannelChanged(ValueChangedEvent e) { - if (channel == null) + if (e.NewValue == null) { textbox.Current.Disabled = true; currentChannelContainer.Clear(false); @@ -199,18 +199,18 @@ namespace osu.Game.Overlays return; } - textbox.Current.Disabled = channel.ReadOnly; + textbox.Current.Disabled = e.NewValue.ReadOnly; - if (channelTabControl.Current.Value != channel) - Scheduler.Add(() => channelTabControl.Current.Value = channel); + if (channelTabControl.Current.Value != e.NewValue) + Scheduler.Add(() => channelTabControl.Current.Value = e.NewValue); - var loaded = loadedChannels.Find(d => d.Channel == channel); + var loaded = loadedChannels.Find(d => d.Channel == e.NewValue); if (loaded == null) { currentChannelContainer.FadeOut(500, Easing.OutQuint); loading.Show(); - loaded = new DrawableChannel(channel); + loaded = new DrawableChannel(e.NewValue); loadedChannels.Add(loaded); LoadComponentAsync(loaded, l => { @@ -328,11 +328,11 @@ namespace osu.Game.Overlays private void load(OsuConfigManager config, OsuColour colours, ChannelManager channelManager) { ChatHeight = config.GetBindable(OsuSetting.ChatDisplayHeight); - ChatHeight.ValueChanged += h => + ChatHeight.ValueChanged += height => { - chatContainer.Height = (float)h; - channelSelectionContainer.Height = 1f - (float)h; - tabBackground.FadeTo(h == 1 ? 1 : 0.8f, 200); + chatContainer.Height = (float)height.NewValue; + channelSelectionContainer.Height = 1f - (float)height.NewValue; + tabBackground.FadeTo(height.NewValue == 1 ? 1 : 0.8f, 200); }; ChatHeight.TriggerChange(); diff --git a/osu.Game/Overlays/Dialog/PopupDialog.cs b/osu.Game/Overlays/Dialog/PopupDialog.cs index bf98d6ec49..72e3cc4f6a 100644 --- a/osu.Game/Overlays/Dialog/PopupDialog.cs +++ b/osu.Game/Overlays/Dialog/PopupDialog.cs @@ -53,6 +53,7 @@ namespace osu.Game.Overlays.Dialog { if (text == value) return; + text = value; header.Text = value; @@ -171,7 +172,7 @@ namespace osu.Game.Overlays.Dialog }, }, }, - header = new OsuTextFlowContainer(t => t.TextSize = 25) + header = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 25)) { Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, @@ -180,7 +181,7 @@ namespace osu.Game.Overlays.Dialog Padding = new MarginPadding(15), TextAnchor = Anchor.TopCentre, }, - body = new OsuTextFlowContainer(t => t.TextSize = 18) + body = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 18)) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 4ee6ff9698..1413f0f885 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -29,7 +29,8 @@ namespace osu.Game.Overlays.Direct protected override PlayButton PlayButton => playButton; protected override Box PreviewBar => progressBar; - public DirectGridPanel(BeatmapSetInfo beatmap) : base(beatmap) + public DirectGridPanel(BeatmapSetInfo beatmap) + : base(beatmap) { Width = 380; Height = 140 + vertical_padding; //full height of all the elements plus vertical padding (autosize uses the image) @@ -75,13 +76,12 @@ namespace osu.Game.Overlays.Direct new OsuSpriteText { Text = new LocalisedString((SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title)), - TextSize = 18, - Font = @"Exo2.0-BoldItalic", + Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold, italics: true) }, new OsuSpriteText { Text = new LocalisedString((SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist)), - Font = @"Exo2.0-BoldItalic", + Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true) }, }, }, @@ -127,15 +127,14 @@ namespace osu.Game.Overlays.Direct new OsuSpriteText { Text = "mapped by ", - TextSize = 14, + Font = OsuFont.GetFont(size: 14), Shadow = false, Colour = colours.Gray5, }, new OsuSpriteText { Text = SetInfo.Metadata.Author.Username, - TextSize = 14, - Font = @"Exo2.0-SemiBoldItalic", + Font = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold, italics: true), Shadow = false, Colour = colours.BlueDark, }, @@ -150,7 +149,7 @@ namespace osu.Game.Overlays.Direct new OsuSpriteText { Text = SetInfo.Metadata.Source, - TextSize = 14, + Font = OsuFont.GetFont(size: 14), Shadow = false, Colour = colours.Gray5, Alpha = string.IsNullOrEmpty(SetInfo.Metadata.Source) ? 0f : 1f, @@ -239,6 +238,6 @@ namespace osu.Game.Overlays.Direct updateStatusContainer(); } - private void updateStatusContainer() => statusContainer.FadeTo(IsHovered || PreviewPlaying ? 0 : 1, 120, Easing.InOutQuint); + private void updateStatusContainer() => statusContainer.FadeTo(IsHovered || PreviewPlaying.Value ? 0 : 1, 120, Easing.InOutQuint); } } diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index cb74ae54a6..7bf372dff7 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -95,13 +95,12 @@ namespace osu.Game.Overlays.Direct new OsuSpriteText { Text = new LocalisedString((SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title)), - TextSize = 18, - Font = @"Exo2.0-BoldItalic", + Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold, italics: true) }, new OsuSpriteText { Text = new LocalisedString((SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist)), - Font = @"Exo2.0-BoldItalic", + Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true) }, } }, @@ -161,13 +160,12 @@ namespace osu.Game.Overlays.Direct new OsuSpriteText { Text = "mapped by ", - TextSize = 14, + Font = OsuFont.GetFont(size: 14) }, new OsuSpriteText { Text = SetInfo.Metadata.Author.Username, - TextSize = 14, - Font = @"Exo2.0-SemiBoldItalic", + Font = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold, italics: true) }, }, }, @@ -176,7 +174,7 @@ namespace osu.Game.Overlays.Direct Text = SetInfo.Metadata.Source, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - TextSize = 14, + Font = OsuFont.GetFont(size: 14), Alpha = string.IsNullOrEmpty(SetInfo.Metadata.Source) ? 0f : 1f, }, }, diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index f8f6fd9b53..3867886f6d 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -88,7 +88,7 @@ namespace osu.Game.Overlays.Direct { base.Update(); - if (PreviewPlaying && Preview != null && Preview.TrackLoaded) + if (PreviewPlaying.Value && Preview != null && Preview.TrackLoaded) { PreviewBar.Width = (float)(Preview.CurrentTime / Preview.Length); } @@ -108,7 +108,7 @@ namespace osu.Game.Overlays.Direct { content.TweenEdgeEffectTo(edgeEffectNormal, hover_transition_time, Easing.OutQuint); content.MoveToY(0, hover_transition_time, Easing.OutQuint); - if (FadePlayButton && !PreviewPlaying) + if (FadePlayButton && !PreviewPlaying.Value) PlayButton.FadeOut(120, Easing.InOutQuint); base.OnHoverLost(e); @@ -127,8 +127,11 @@ namespace osu.Game.Overlays.Direct base.LoadComplete(); this.FadeInFromZero(200, Easing.Out); - PreviewPlaying.ValueChanged += newValue => PlayButton.FadeTo(newValue || IsHovered || !FadePlayButton ? 1 : 0, 120, Easing.InOutQuint); - PreviewPlaying.ValueChanged += newValue => PreviewBar.FadeTo(newValue ? 1 : 0, 120, Easing.InOutQuint); + PreviewPlaying.ValueChanged += playing => + { + PlayButton.FadeTo(playing.NewValue || IsHovered || !FadePlayButton ? 1 : 0, 120, Easing.InOutQuint); + PreviewBar.FadeTo(playing.NewValue ? 1 : 0, 120, Easing.InOutQuint); + }; } protected List GetDifficultyIcons() @@ -155,7 +158,7 @@ namespace osu.Game.Overlays.Direct public int Value { - get { return value; } + get => value; set { this.value = value; @@ -173,10 +176,7 @@ namespace osu.Game.Overlays.Direct Children = new Drawable[] { - text = new OsuSpriteText - { - Font = @"Exo2.0-SemiBoldItalic", - }, + text = new OsuSpriteText { Font = OsuFont.GetFont(weight: FontWeight.SemiBold, italics: true) }, new SpriteIcon { Icon = icon, diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index 201a79f58a..f15413d522 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -67,7 +67,7 @@ namespace osu.Game.Overlays.Direct { base.LoadComplete(); - State.BindValueChanged(updateState, true); + State.BindValueChanged(state => updateState(state.NewValue), true); FinishTransforms(true); } @@ -85,10 +85,10 @@ namespace osu.Game.Overlays.Direct shakeContainer.Shake(); break; case DownloadState.LocallyAvailable: - game.PresentBeatmap(BeatmapSet); + game.PresentBeatmap(BeatmapSet.Value); break; default: - beatmaps.Download(BeatmapSet, noVideo); + beatmaps.Download(BeatmapSet.Value, noVideo); break; } }; diff --git a/osu.Game/Overlays/Direct/DownloadProgressBar.cs b/osu.Game/Overlays/Direct/DownloadProgressBar.cs index 4ac1aba7f5..9c2b1e5b63 100644 --- a/osu.Game/Overlays/Direct/DownloadProgressBar.cs +++ b/osu.Game/Overlays/Direct/DownloadProgressBar.cs @@ -37,7 +37,7 @@ namespace osu.Game.Overlays.Direct State.BindValueChanged(state => { - switch (state) + switch (state.NewValue) { case DownloadState.NotDownloaded: progressBar.Current.Value = 0; diff --git a/osu.Game/Overlays/Direct/DownloadTrackingComposite.cs b/osu.Game/Overlays/Direct/DownloadTrackingComposite.cs index d9eb827834..7be9eadefb 100644 --- a/osu.Game/Overlays/Direct/DownloadTrackingComposite.cs +++ b/osu.Game/Overlays/Direct/DownloadTrackingComposite.cs @@ -2,9 +2,9 @@ // See the LICENCE file in the repository root for full licence text. using System; -using Microsoft.EntityFrameworkCore.Internal; +using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Online.API.Requests; @@ -37,14 +37,14 @@ namespace osu.Game.Overlays.Direct { this.beatmaps = beatmaps; - BeatmapSet.BindValueChanged(set => + BeatmapSet.BindValueChanged(setInfo => { - if (set == null) + if (setInfo.NewValue == null) attachDownload(null); - else if (beatmaps.QueryBeatmapSets(s => s.OnlineBeatmapSetID == set.OnlineBeatmapSetID).Any()) + else if (beatmaps.GetAllUsableBeatmapSetsEnumerable().Any(s => s.OnlineBeatmapSetID == setInfo.NewValue.OnlineBeatmapSetID)) State.Value = DownloadState.LocallyAvailable; else - attachDownload(beatmaps.GetExistingDownload(set)); + attachDownload(beatmaps.GetExistingDownload(setInfo.NewValue)); }, true); beatmaps.BeatmapDownloadBegan += download => @@ -63,8 +63,11 @@ namespace osu.Game.Overlays.Direct { base.Dispose(isDisposing); - beatmaps.BeatmapDownloadBegan -= attachDownload; - beatmaps.ItemAdded -= setAdded; + if (beatmaps != null) + { + beatmaps.BeatmapDownloadBegan -= attachDownload; + beatmaps.ItemAdded -= setAdded; + } State.UnbindAll(); diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index f1ae435c73..d7e0760fc6 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; @@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Direct { DisplayStyleControl.Dropdown.AccentColour = colours.BlueDark; - Ruleset.Value = ruleset ?? rulesets.GetRuleset(0); + Ruleset.Value = ruleset.Value ?? rulesets.GetRuleset(0); foreach (var r in rulesets.AvailableRulesets) modeButtons.Add(new RulesetToggleButton(Ruleset, r)); } @@ -68,9 +68,9 @@ namespace osu.Game.Overlays.Direct private readonly ConstrainedIconContainer iconContainer; - private void Bindable_ValueChanged(RulesetInfo obj) + private void Bindable_ValueChanged(ValueChangedEvent e) { - iconContainer.FadeTo(Ruleset.ID == obj?.ID ? 1f : 0.5f, 100); + iconContainer.FadeTo(Ruleset.ID == e.NewValue?.ID ? 1f : 0.5f, 100); } public override bool HandleNonPositionalInput => !bindable.Disabled && base.HandleNonPositionalInput; @@ -93,7 +93,7 @@ namespace osu.Game.Overlays.Direct Ruleset = ruleset; bindable.ValueChanged += Bindable_ValueChanged; - Bindable_ValueChanged(bindable.Value); + Bindable_ValueChanged(new ValueChangedEvent(bindable.Value, bindable.Value)); Action = () => bindable.Value = Ruleset; } diff --git a/osu.Game/Overlays/Direct/Header.cs b/osu.Game/Overlays/Direct/Header.cs index 267590f19a..e85cb3b4ac 100644 --- a/osu.Game/Overlays/Direct/Header.cs +++ b/osu.Game/Overlays/Direct/Header.cs @@ -15,7 +15,7 @@ namespace osu.Game.Overlays.Direct protected override Color4 BackgroundColour => OsuColour.FromHex(@"252f3a"); protected override DirectTab DefaultTab => DirectTab.Search; - protected override Drawable CreateHeaderText() => new OsuSpriteText { Text = @"osu!direct", TextSize = 25 }; + protected override Drawable CreateHeaderText() => new OsuSpriteText { Text = @"osu!direct", Font = OsuFont.GetFont(size: 25) }; protected override FontAwesome Icon => FontAwesome.fa_osu_chevron_down_o; public Header() @@ -28,10 +28,13 @@ namespace osu.Game.Overlays.Direct public enum DirectTab { Search, + [Description("Newest Maps")] NewestMaps = DirectSortCriteria.Ranked, + [Description("Top Rated")] TopRated = DirectSortCriteria.Rating, + [Description("Most Played")] MostPlayed = DirectSortCriteria.Plays, } diff --git a/osu.Game/Overlays/Direct/PlayButton.cs b/osu.Game/Overlays/Direct/PlayButton.cs index 5e3ad3344e..3c5508ba00 100644 --- a/osu.Game/Overlays/Direct/PlayButton.cs +++ b/osu.Game/Overlays/Direct/PlayButton.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; @@ -24,10 +24,11 @@ namespace osu.Game.Overlays.Direct public BeatmapSetInfo BeatmapSet { - get { return beatmapSet; } + get => beatmapSet; set { if (value == beatmapSet) return; + beatmapSet = value; Preview?.Stop(); @@ -112,12 +113,12 @@ namespace osu.Game.Overlays.Direct base.OnHoverLost(e); } - private void playingStateChanged(bool playing) + private void playingStateChanged(ValueChangedEvent e) { - icon.Icon = playing ? FontAwesome.fa_stop : FontAwesome.fa_play; - icon.FadeColour(playing || IsHovered ? hoverColour : Color4.White, 120, Easing.InOutQuint); + icon.Icon = e.NewValue ? FontAwesome.fa_stop : FontAwesome.fa_play; + icon.FadeColour(e.NewValue || IsHovered ? hoverColour : Color4.White, 120, Easing.InOutQuint); - if (playing) + if (e.NewValue) { if (BeatmapSet == null) { @@ -144,7 +145,7 @@ namespace osu.Game.Overlays.Direct preview.Stopped += () => Playing.Value = false; // user may have changed their mind. - if (Playing) + if (Playing.Value) preview.Start(); }); } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 7dd59bf0bc..0dc74b6a88 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -4,8 +4,9 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Humanizer; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Threading; @@ -45,7 +46,7 @@ namespace osu.Game.Overlays public IEnumerable BeatmapSets { - get { return beatmapSets; } + get => beatmapSets; set { if (beatmapSets?.Equals(value) ?? false) return; @@ -72,10 +73,11 @@ namespace osu.Game.Overlays public ResultCounts ResultAmounts { - get { return resultAmounts; } + get => resultAmounts; set { if (value == ResultAmounts) return; + resultAmounts = value; updateResultCounts(); @@ -105,12 +107,11 @@ namespace osu.Game.Overlays new OsuSpriteText { Text = "Found ", - TextSize = 15, + Font = OsuFont.GetFont(size: 15) }, resultCountsText = new OsuSpriteText { - TextSize = 15, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold) }, } }, @@ -118,7 +119,7 @@ namespace osu.Game.Overlays Filter.Search.Current.ValueChanged += text => { - if (text != string.Empty) + if (text.NewValue != string.Empty) { Header.Tabs.Current.Value = DirectTab.Search; @@ -133,13 +134,13 @@ namespace osu.Game.Overlays Filter.Tabs.Current.Value = DirectSortCriteria.Ranked; } }; - ((FilterControl)Filter).Ruleset.ValueChanged += ruleset => Scheduler.AddOnce(updateSearch); - Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; - Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => Scheduler.AddOnce(updateSearch); + ((FilterControl)Filter).Ruleset.ValueChanged += _ => Scheduler.AddOnce(updateSearch); + Filter.DisplayStyleControl.DisplayStyle.ValueChanged += style => recreatePanels(style.NewValue); + Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += _ => Scheduler.AddOnce(updateSearch); Header.Tabs.Current.ValueChanged += tab => { - if (tab != DirectTab.Search) + if (tab.NewValue != DirectTab.Search) { currentQuery.Value = string.Empty; Filter.Tabs.Current.Value = (DirectSortCriteria)Header.Tabs.Current.Value; @@ -147,11 +148,11 @@ namespace osu.Game.Overlays } }; - currentQuery.ValueChanged += v => + currentQuery.ValueChanged += text => { queryChangedDebounce?.Cancel(); - if (string.IsNullOrEmpty(v)) + if (string.IsNullOrEmpty(text.NewValue)) Scheduler.AddOnce(updateSearch); else { @@ -164,9 +165,9 @@ namespace osu.Game.Overlays currentQuery.BindTo(Filter.Search.Current); - Filter.Tabs.Current.ValueChanged += sortCriteria => + Filter.Tabs.Current.ValueChanged += tab => { - if (Header.Tabs.Current.Value != DirectTab.Search && sortCriteria != (DirectSortCriteria)Header.Tabs.Current.Value) + if (Header.Tabs.Current.Value != DirectTab.Search && tab.NewValue != (DirectSortCriteria)Header.Tabs.Current.Value) Header.Tabs.Current.Value = DirectTab.Search; Scheduler.AddOnce(updateSearch); @@ -190,14 +191,9 @@ namespace osu.Game.Overlays resultCountsContainer.FadeTo(ResultAmounts == null ? 0f : 1f, 200, Easing.OutQuint); if (ResultAmounts == null) return; - resultCountsText.Text = pluralize("Artist", ResultAmounts.Artists) + ", " + - pluralize("Song", ResultAmounts.Songs) + ", " + - pluralize("Tag", ResultAmounts.Tags); - } - - private string pluralize(string prefix, int value) - { - return $@"{value} {prefix}" + (value == 1 ? string.Empty : @"s"); + resultCountsText.Text = "Artist".ToQuantity(ResultAmounts.Artists) + ", " + + "Song".ToQuantity(ResultAmounts.Songs) + ", " + + "Tag".ToQuantity(ResultAmounts.Tags); } private void recreatePanels(PanelDisplayStyle displayStyle) @@ -274,9 +270,6 @@ namespace osu.Game.Overlays if (api == null) return; - if (Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || currentQuery == string.Empty)) - return; - previewTrackManager.StopAnyPlaying(this); getSetsRequest = new SearchBeatmapSetsRequest(currentQuery.Value ?? string.Empty, diff --git a/osu.Game/Overlays/HoldToConfirmOverlay.cs b/osu.Game/Overlays/HoldToConfirmOverlay.cs index 2854fdab50..154aff605a 100644 --- a/osu.Game/Overlays/HoldToConfirmOverlay.cs +++ b/osu.Game/Overlays/HoldToConfirmOverlay.cs @@ -33,7 +33,7 @@ namespace osu.Game.Overlays } }; - Progress.ValueChanged += v => overlay.Alpha = (float)v; + Progress.ValueChanged += p => overlay.Alpha = (float)p.NewValue; } } } diff --git a/osu.Game/Overlays/KeyBinding/GlobalKeyBindingsSection.cs b/osu.Game/Overlays/KeyBinding/GlobalKeyBindingsSection.cs index b67081846c..82e24f550b 100644 --- a/osu.Game/Overlays/KeyBinding/GlobalKeyBindingsSection.cs +++ b/osu.Game/Overlays/KeyBinding/GlobalKeyBindingsSection.cs @@ -33,7 +33,8 @@ namespace osu.Game.Overlays.KeyBinding { protected override string Header => "In Game"; - public InGameKeyBindingsSubsection(GlobalActionContainer manager) : base(null) + public InGameKeyBindingsSubsection(GlobalActionContainer manager) + : base(null) { Defaults = manager.InGameKeyBindings; } diff --git a/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs b/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs index 3dad94c8fa..ef16c81dfc 100644 --- a/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs +++ b/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs @@ -35,7 +35,7 @@ namespace osu.Game.Overlays.KeyBinding public bool MatchingFilter { - get { return matchingFilter; } + get => matchingFilter; set { matchingFilter = value; @@ -309,10 +309,11 @@ namespace osu.Game.Overlays.KeyBinding public bool IsBinding { - get { return isBinding; } + get => isBinding; set { if (value == isBinding) return; + isBinding = value; updateHoverState(); @@ -349,8 +350,7 @@ namespace osu.Game.Overlays.KeyBinding }, Text = new OsuSpriteText { - Font = "Venera", - TextSize = 10, + Font = OsuFont.Numeric.With(size: 10), Margin = new MarginPadding(5), Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Overlays/KeyBindingOverlay.cs b/osu.Game/Overlays/KeyBindingOverlay.cs index d0382a4264..300563dc59 100644 --- a/osu.Game/Overlays/KeyBindingOverlay.cs +++ b/osu.Game/Overlays/KeyBindingOverlay.cs @@ -73,8 +73,7 @@ namespace osu.Game.Overlays Anchor = Anchor.Centre, Origin = Anchor.Centre, Y = 15, - TextSize = 12, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), Text = @"back", }, } diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index 76efd74006..a5703eba92 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -219,13 +219,11 @@ namespace osu.Game.Overlays { if (drawableMedal.State != DisplayState.Full) drawableMedal.State = DisplayState.Icon; - }) - .Delay(step_duration).Schedule(() => + }).Delay(step_duration).Schedule(() => { if (drawableMedal.State != DisplayState.Full) drawableMedal.State = DisplayState.MedalUnlocked; - }) - .Delay(step_duration).Schedule(() => + }).Delay(step_duration).Schedule(() => { if (drawableMedal.State != DisplayState.Full) drawableMedal.State = DisplayState.Full; diff --git a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs index a7579b4d4b..eeb42ec991 100644 --- a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs +++ b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs @@ -29,6 +29,7 @@ namespace osu.Game.Overlays.MedalSplash private readonly OsuSpriteText unlocked, name; private readonly TextFlowContainer description; private DisplayState state; + public DrawableMedal(Medal medal) { this.medal = medal; @@ -63,8 +64,7 @@ namespace osu.Game.Overlays.MedalSplash Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = "Medal Unlocked".ToUpperInvariant(), - TextSize = 24, - Font = @"Exo2.0-Light", + Font = OsuFont.GetFont(size: 24, weight: FontWeight.Light), Alpha = 0f, Scale = new Vector2(1f / scale_when_unlocked), }, @@ -84,8 +84,7 @@ namespace osu.Game.Overlays.MedalSplash Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = medal.Name, - TextSize = 20, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold), Alpha = 0f, Scale = new Vector2(1f / scale_when_full), }, @@ -107,7 +106,7 @@ namespace osu.Game.Overlays.MedalSplash { s.Anchor = Anchor.TopCentre; s.Origin = Anchor.TopCentre; - s.TextSize = 16; + s.Font = s.Font.With(size: 16); }); medalContainer.OnLoadComplete = d => @@ -134,7 +133,7 @@ namespace osu.Game.Overlays.MedalSplash public DisplayState State { - get { return state; } + get => state; set { if (state == value) return; diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index e1fb8674de..23b75caedc 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -14,6 +14,7 @@ using System; using System.Linq; using osu.Framework.Graphics.Cursor; using osu.Framework.Input.Events; +using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Mods @@ -106,10 +107,11 @@ namespace osu.Game.Overlays.Mods public Color4 SelectedColour { - get { return selectedColour; } + get => selectedColour; set { if (value == selectedColour) return; + selectedColour = value; if (Selected) foregroundIcon.Colour = value; } @@ -120,7 +122,7 @@ namespace osu.Game.Overlays.Mods public Mod Mod { - get { return mod; } + get => mod; set { mod = value; @@ -275,7 +277,7 @@ namespace osu.Game.Overlays.Mods Y = 75, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, - TextSize = 18, + Font = OsuFont.GetFont(size: 18) }, new HoverClickSounds() }; diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index 0530f812e3..a118357f21 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -11,6 +11,7 @@ using System; using System.Linq; using System.Collections.Generic; using osu.Framework.Input.Events; +using osu.Game.Graphics; namespace osu.Game.Overlays.Mods { @@ -80,6 +81,7 @@ namespace osu.Game.Overlays.Mods { Mod selected = button.SelectedMod; if (selected == null) continue; + foreach (var type in modTypes) if (type.IsInstanceOfType(selected)) { @@ -123,7 +125,7 @@ namespace osu.Game.Overlays.Mods Origin = Anchor.TopLeft, Anchor = Anchor.TopLeft, Position = new Vector2(0f, 0f), - Font = @"Exo2.0-Bold" + Font = OsuFont.GetFont(weight: FontWeight.Bold) }, ButtonsContainer = new FillFlowContainer { diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 386dd01ebd..24faf36ef8 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -4,7 +4,6 @@ using osuTK; using osuTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -17,6 +16,7 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Audio; using osu.Framework.Audio.Sample; +using osu.Framework.Bindables; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics.Containers; using osu.Game.Rulesets; @@ -74,28 +74,28 @@ namespace osu.Game.Overlays.Mods SelectedMods.UnbindAll(); } - private void rulesetChanged(RulesetInfo newRuleset) + private void rulesetChanged(ValueChangedEvent e) { - if (newRuleset == null) return; + if (e.NewValue == null) return; - var instance = newRuleset.CreateInstance(); + var instance = e.NewValue.CreateInstance(); foreach (ModSection section in ModSectionsContainer.Children) section.Mods = instance.GetModsFor(section.ModType); // attempt to re-select any already selected mods. // this may be the first time we are receiving the ruleset, in which case they will still match. - selectedModsChanged(SelectedMods.Value); + selectedModsChanged(new ValueChangedEvent>(SelectedMods.Value, SelectedMods.Value)); // write the mods back to the SelectedMods bindable in the case a change was not applicable. // this generally isn't required as the previous line will perform deselection; just here for safety. refreshSelectedMods(); } - private void selectedModsChanged(IEnumerable obj) + private void selectedModsChanged(ValueChangedEvent> e) { foreach (ModSection section in ModSectionsContainer.Children) - section.SelectTypes(obj.Select(m => m.GetType()).ToList()); + section.SelectTypes(e.NewValue.Select(m => m.GetType()).ToList()); updateMods(); } @@ -168,6 +168,7 @@ namespace osu.Game.Overlays.Mods public void DeselectTypes(Type[] modTypes, bool immediate = false) { if (modTypes.Length == 0) return; + foreach (ModSection section in ModSectionsContainer.Children) section.DeselectTypes(modTypes, immediate); } @@ -264,9 +265,8 @@ namespace osu.Game.Overlays.Mods { new OsuSpriteText { - Font = @"Exo2.0-Bold", Text = @"Gameplay Mods", - TextSize = 22, + Font = OsuFont.GetFont(size: 22, weight: FontWeight.Bold), Shadow = true, Margin = new MarginPadding { @@ -275,7 +275,7 @@ namespace osu.Game.Overlays.Mods }, new OsuTextFlowContainer(text => { - text.TextSize = 18; + text.Font = text.Font.With(size: 18); text.Shadow = true; }) { @@ -365,7 +365,7 @@ namespace osu.Game.Overlays.Mods new OsuSpriteText { Text = @"Score Multiplier:", - TextSize = 30, + Font = OsuFont.GetFont(size: 30), Margin = new MarginPadding { Top = 5, @@ -374,8 +374,7 @@ namespace osu.Game.Overlays.Mods }, MultiplierLabel = new OsuSpriteText { - Font = @"Exo2.0-Bold", - TextSize = 30, + Font = OsuFont.GetFont(size: 30, weight: FontWeight.Bold), Margin = new MarginPadding { Top = 5 @@ -383,9 +382,8 @@ namespace osu.Game.Overlays.Mods }, UnrankedLabel = new OsuSpriteText { - Font = @"Exo2.0-Bold", Text = @"(Unranked)", - TextSize = 30, + Font = OsuFont.GetFont(size: 30, weight: FontWeight.Bold), Margin = new MarginPadding { Top = 5, diff --git a/osu.Game/Overlays/Music/FilterControl.cs b/osu.Game/Overlays/Music/FilterControl.cs index c2c10d999f..6bceade271 100644 --- a/osu.Game/Overlays/Music/FilterControl.cs +++ b/osu.Game/Overlays/Music/FilterControl.cs @@ -8,6 +8,7 @@ using osu.Game.Graphics.UserInterface; using osuTK; using osuTK.Graphics; using System; +using osu.Framework.Bindables; namespace osu.Game.Overlays.Music { @@ -44,7 +45,7 @@ namespace osu.Game.Overlays.Music Search.Current.ValueChanged += current_ValueChanged; } - private void current_ValueChanged(string newValue) => FilterChanged?.Invoke(newValue); + private void current_ValueChanged(ValueChangedEvent e) => FilterChanged?.Invoke(e.NewValue); public Action ExitRequested; diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 7c7b78afc7..886a202c2a 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -50,12 +50,14 @@ namespace osu.Game.Overlays.Music } private bool selected; + public bool Selected { - get { return selected; } + get => selected; set { if (value == selected) return; + selected = value; FinishTransforms(true); @@ -100,7 +102,7 @@ namespace osu.Game.Overlays.Music titleBind = localisation.GetLocalisedString(new LocalisedString((metadata.TitleUnicode, metadata.Title))); artistBind = localisation.GetLocalisedString(new LocalisedString((metadata.ArtistUnicode, metadata.Artist))); - artistBind.BindValueChanged(newText => recreateText(), true); + artistBind.BindValueChanged(_ => recreateText(), true); } private void recreateText() @@ -108,16 +110,11 @@ namespace osu.Game.Overlays.Music text.Clear(); //space after the title to put a space between the title and artist - titleSprites = text.AddText(titleBind.Value + @" ", sprite => - { - sprite.TextSize = 16; - sprite.Font = @"Exo2.0-Regular"; - }).OfType(); + titleSprites = text.AddText(titleBind.Value + @" ", sprite => sprite.Font = OsuFont.GetFont(weight: FontWeight.Regular)).OfType(); text.AddText(artistBind.Value, sprite => { - sprite.TextSize = 14; - sprite.Font = @"Exo2.0-Bold"; + sprite.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold); sprite.Colour = artistColour; sprite.Padding = new MarginPadding { Top = 1 }; }); @@ -147,7 +144,7 @@ namespace osu.Game.Overlays.Music public bool MatchingFilter { - get { return matching; } + get => matching; set { if (matching == value) return; diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index b388bb1632..7df09f1abe 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; @@ -34,8 +34,8 @@ namespace osu.Game.Overlays.Music public new MarginPadding Padding { - get { return base.Padding; } - set { base.Padding = value; } + get => base.Padding; + set => base.Padding = value; } public BeatmapSetInfo FirstVisibleSet => items.FirstVisibleSet; @@ -109,8 +109,8 @@ namespace osu.Game.Overlays.Music public string SearchTerm { - get { return search.SearchTerm; } - set { search.SearchTerm = value; } + get => search.SearchTerm; + set => search.SearchTerm = value; } public BeatmapSetInfo FirstVisibleSet => items.FirstOrDefault(i => i.MatchingFilter)?.BeatmapSetInfo; @@ -130,6 +130,7 @@ namespace osu.Game.Overlays.Music nativeDragPosition = e.ScreenSpaceMousePosition; if (draggedItem == null) return base.OnDrag(e); + return true; } diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 5b1b7f4da9..8cbea63fe3 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -4,7 +4,7 @@ using System; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 5218edd7d5..6ac597451d 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -107,20 +107,18 @@ namespace osu.Game.Overlays Origin = Anchor.BottomCentre, Anchor = Anchor.TopCentre, Position = new Vector2(0, 40), - TextSize = 25, + Font = OsuFont.GetFont(size: 25, italics: true), Colour = Color4.White, Text = @"Nothing to play", - Font = @"Exo2.0-MediumItalic" }, artist = new OsuSpriteText { Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, Position = new Vector2(0, 45), - TextSize = 15, + Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold, italics: true), Colour = Color4.White, Text = @"Nothing to play", - Font = @"Exo2.0-BoldItalic" }, new Container { @@ -260,9 +258,6 @@ namespace osu.Game.Overlays progressBar.CurrentTime = track.CurrentTime; playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; - - if (track.HasCompleted && !track.Looping && !beatmap.Disabled && beatmapSets.Any()) - next(); } else { @@ -317,13 +312,13 @@ namespace osu.Game.Overlays private WorkingBeatmap current; private TransformDirection? queuedDirection; - private void beatmapChanged(WorkingBeatmap beatmap) + private void beatmapChanged(ValueChangedEvent beatmap) { TransformDirection direction = TransformDirection.None; if (current != null) { - bool audioEquals = beatmap?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false; + bool audioEquals = beatmap.NewValue?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false; if (audioEquals) direction = TransformDirection.None; @@ -336,13 +331,18 @@ namespace osu.Game.Overlays { //figure out the best direction based on order in playlist. var last = beatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo?.ID).Count(); - var next = beatmap == null ? -1 : beatmapSets.TakeWhile(b => b.ID != beatmap.BeatmapSetInfo?.ID).Count(); + var next = beatmap.NewValue == null ? -1 : beatmapSets.TakeWhile(b => b.ID != beatmap.NewValue.BeatmapSetInfo?.ID).Count(); direction = last > next ? TransformDirection.Prev : TransformDirection.Next; } + + current.Track.Completed -= currentTrackCompleted; } - current = beatmap; + current = beatmap.NewValue; + + if (current != null) + current.Track.Completed += currentTrackCompleted; progressBar.CurrentTime = 0; @@ -351,6 +351,12 @@ namespace osu.Game.Overlays queuedDirection = null; } + private void currentTrackCompleted() => Schedule(() => + { + if (!current.Track.Looping && !beatmap.Disabled && beatmapSets.Any()) + next(); + }); + private ScheduledDelegate pendingBeatmapSwitch; private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction) diff --git a/osu.Game/Overlays/NotificationOverlay.cs b/osu.Game/Overlays/NotificationOverlay.cs index 1a23e0d8ef..8f75d3ebf0 100644 --- a/osu.Game/Overlays/NotificationOverlay.cs +++ b/osu.Game/Overlays/NotificationOverlay.cs @@ -11,7 +11,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics.Containers; using System; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Threading; namespace osu.Game.Overlays @@ -78,9 +78,10 @@ namespace osu.Game.Overlays } private ScheduledDelegate notificationsEnabler; + private void updateProcessingMode() { - bool enabled = OverlayActivationMode == OverlayActivation.All || State == Visibility.Visible; + bool enabled = OverlayActivationMode.Value == OverlayActivation.All || State == Visibility.Visible; notificationsEnabler?.Cancel(); @@ -118,8 +119,7 @@ namespace osu.Game.Overlays notification.Closed += notificationClosed; - var hasCompletionTarget = notification as IHasCompletionTarget; - if (hasCompletionTarget != null) + if (notification is IHasCompletionTarget hasCompletionTarget) hasCompletionTarget.CompletionTarget = Post; var ourType = notification.GetType(); diff --git a/osu.Game/Overlays/Notifications/Notification.cs b/osu.Game/Overlays/Notifications/Notification.cs index b77b6f837d..ea6e250556 100644 --- a/osu.Game/Overlays/Notifications/Notification.cs +++ b/osu.Game/Overlays/Notifications/Notification.cs @@ -151,6 +151,7 @@ namespace osu.Game.Overlays.Notifications public virtual void Close() { if (WasClosed) return; + WasClosed = true; Closed?.Invoke(); @@ -205,7 +206,7 @@ namespace osu.Game.Overlays.Notifications public bool Pulsate { - get { return pulsate; } + get => pulsate; set { if (pulsate == value) return; diff --git a/osu.Game/Overlays/Notifications/NotificationSection.cs b/osu.Game/Overlays/Notifications/NotificationSection.cs index afbacfac52..4608d78324 100644 --- a/osu.Game/Overlays/Notifications/NotificationSection.cs +++ b/osu.Game/Overlays/Notifications/NotificationSection.cs @@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Notifications public string ClearText { - get { return clearText; } + get => clearText; set { clearText = value; @@ -51,7 +51,7 @@ namespace osu.Game.Overlays.Notifications public string Title { - get { return title; } + get => title; set { title = value; @@ -102,13 +102,13 @@ namespace osu.Game.Overlays.Notifications titleText = new OsuSpriteText { Text = title.ToUpperInvariant(), - Font = @"Exo2.0-Black", + Font = OsuFont.GetFont(weight: FontWeight.Black) }, countText = new OsuSpriteText { Text = "3", Colour = colours.Yellow, - Font = @"Exo2.0-Black", + Font = OsuFont.GetFont(weight: FontWeight.Black) }, } }, @@ -153,8 +153,8 @@ namespace osu.Game.Overlays.Notifications public string Text { - get { return text.Text; } - set { text.Text = value.ToUpperInvariant(); } + get => text.Text; + set => text.Text = value.ToUpperInvariant(); } } diff --git a/osu.Game/Overlays/Notifications/ProgressNotification.cs b/osu.Game/Overlays/Notifications/ProgressNotification.cs index cf7b716665..75e70b18ea 100644 --- a/osu.Game/Overlays/Notifications/ProgressNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressNotification.cs @@ -17,18 +17,15 @@ namespace osu.Game.Overlays.Notifications { public string Text { - set - { - Schedule(() => textDrawable.Text = value); - } + set => Schedule(() => textDrawable.Text = value); } public string CompletionText { get; set; } = "Task has completed!"; public float Progress { - get { return progressBar.Progress; } - set { Schedule(() => progressBar.Progress = value); } + get => progressBar.Progress; + set => Schedule(() => progressBar.Progress = value); } protected override void LoadComplete() @@ -41,9 +38,8 @@ namespace osu.Game.Overlays.Notifications public virtual ProgressNotificationState State { - get { return state; } - set - { + get => state; + set => Schedule(() => { bool stateChanged = state != value; @@ -82,7 +78,6 @@ namespace osu.Game.Overlays.Notifications } } }); - } } private ProgressNotificationState state; @@ -115,10 +110,7 @@ namespace osu.Game.Overlays.Notifications RelativeSizeAxes = Axes.Both, }); - Content.Add(textDrawable = new OsuTextFlowContainer(t => - { - t.TextSize = 16; - }) + Content.Add(textDrawable = new OsuTextFlowContainer { Colour = OsuColour.Gray(128), AutoSizeAxes = Axes.Y, @@ -181,9 +173,10 @@ namespace osu.Game.Overlays.Notifications private Color4 colourInactive; private float progress; + public float Progress { - get { return progress; } + get => progress; set { if (progress == value) return; @@ -197,7 +190,7 @@ namespace osu.Game.Overlays.Notifications public bool Active { - get { return active; } + get => active; set { active = value; diff --git a/osu.Game/Overlays/Notifications/SimpleNotification.cs b/osu.Game/Overlays/Notifications/SimpleNotification.cs index 283a412b2a..aee056b63d 100644 --- a/osu.Game/Overlays/Notifications/SimpleNotification.cs +++ b/osu.Game/Overlays/Notifications/SimpleNotification.cs @@ -15,9 +15,10 @@ namespace osu.Game.Overlays.Notifications public class SimpleNotification : Notification { private string text = string.Empty; + public string Text { - get { return text; } + get => text; set { text = value; @@ -26,9 +27,10 @@ namespace osu.Game.Overlays.Notifications } private FontAwesome icon = FontAwesome.fa_info_circle; + public FontAwesome Icon { - get { return icon; } + get => icon; set { icon = value; @@ -59,7 +61,7 @@ namespace osu.Game.Overlays.Notifications } }); - Content.Add(textDrawable = new OsuTextFlowContainer(t => t.TextSize = 14) + Content.Add(textDrawable = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14)) { Colour = OsuColour.Gray(128), AutoSizeAxes = Axes.Y, @@ -76,11 +78,7 @@ namespace osu.Game.Overlays.Notifications public override bool Read { - get - { - return base.Read; - } - + get => base.Read; set { if (value == base.Read) return; diff --git a/osu.Game/Overlays/OnScreenDisplay.cs b/osu.Game/Overlays/OnScreenDisplay.cs index 42031ee07e..5e45fbf081 100644 --- a/osu.Game/Overlays/OnScreenDisplay.cs +++ b/osu.Game/Overlays/OnScreenDisplay.cs @@ -69,16 +69,14 @@ namespace osu.Game.Overlays textLine1 = new OsuSpriteText { Padding = new MarginPadding(10), - Font = @"Exo2.0-Black", + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Black), Spacing = new Vector2(1, 0), - TextSize = 14, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, textLine2 = new OsuSpriteText { - TextSize = 24, - Font = @"Exo2.0-Light", + Font = OsuFont.GetFont(size: 24, weight: FontWeight.Light), Padding = new MarginPadding { Left = 10, Right = 10 }, Anchor = Anchor.Centre, Origin = Anchor.BottomCentre, @@ -105,8 +103,7 @@ namespace osu.Game.Overlays Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Margin = new MarginPadding { Bottom = 15 }, - Font = @"Exo2.0-Bold", - TextSize = 12, + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), Alpha = 0.3f, }, } diff --git a/osu.Game/Overlays/Profile/Components/GradeBadge.cs b/osu.Game/Overlays/Profile/Components/GradeBadge.cs index 4280f89cdf..ca56780663 100644 --- a/osu.Game/Overlays/Profile/Components/GradeBadge.cs +++ b/osu.Game/Overlays/Profile/Components/GradeBadge.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Profile.Components @@ -36,8 +37,7 @@ namespace osu.Game.Overlays.Profile.Components { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, - TextSize = 14, - Font = @"Exo2.0-Bold" + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold) }); } diff --git a/osu.Game/Overlays/Profile/Header/BadgeContainer.cs b/osu.Game/Overlays/Profile/Header/BadgeContainer.cs index 56cceae79c..ff4d7a10dc 100644 --- a/osu.Game/Overlays/Profile/Header/BadgeContainer.cs +++ b/osu.Game/Overlays/Profile/Header/BadgeContainer.cs @@ -53,11 +53,10 @@ namespace osu.Game.Overlays.Profile.Header { badgeCountText = new OsuSpriteText { - Alpha = 0, - TextSize = 12, Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, - Font = "Exo2.0-Regular" + Alpha = 0, + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular) }, new Container { diff --git a/osu.Game/Overlays/Profile/Header/RankGraph.cs b/osu.Game/Overlays/Profile/Header/RankGraph.cs index 09880f044c..3df0677576 100644 --- a/osu.Game/Overlays/Profile/Header/RankGraph.cs +++ b/osu.Game/Overlays/Profile/Header/RankGraph.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -44,30 +44,26 @@ namespace osu.Game.Overlays.Profile.Header Anchor = Anchor.Centre, Origin = Anchor.Centre, Text = "No recent plays", - TextSize = 14, - Font = @"Exo2.0-RegularItalic", + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Regular, italics: true) }, rankText = new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Font = @"Exo2.0-RegularItalic", - TextSize = primary_textsize + Font = OsuFont.GetFont(size: primary_textsize, weight: FontWeight.Regular, italics: true), }, relativeText = new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Font = @"Exo2.0-RegularItalic", + Font = OsuFont.GetFont(size: secondary_textsize, weight: FontWeight.Regular, italics: true), Y = 25, - TextSize = secondary_textsize }, performanceText = new OsuSpriteText { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, - Font = @"Exo2.0-RegularItalic", - TextSize = secondary_textsize + Font = OsuFont.GetFont(size: secondary_textsize, weight: FontWeight.Regular, italics: true) }, graph = new RankChartLineGraph { @@ -91,11 +87,11 @@ namespace osu.Game.Overlays.Profile.Header graph.Colour = colours.Yellow; } - private void userChanged(User user) + private void userChanged(ValueChangedEvent e) { placeholder.FadeIn(fade_duration, Easing.Out); - if (user?.Statistics?.Ranks.Global == null) + if (e.NewValue?.Statistics?.Ranks.Global == null) { rankText.Text = string.Empty; performanceText.Text = string.Empty; @@ -105,7 +101,7 @@ namespace osu.Game.Overlays.Profile.Header return; } - int[] userRanks = user.RankHistory?.Data ?? new[] { user.Statistics.Ranks.Global.Value }; + int[] userRanks = e.NewValue.RankHistory?.Data ?? new[] { e.NewValue.Statistics.Ranks.Global.Value }; ranks = userRanks.Select((x, index) => new KeyValuePair(index, x)).Where(x => x.Value != 0).ToArray(); if (ranks.Length > 1) @@ -144,6 +140,7 @@ namespace osu.Game.Overlays.Profile.Header graph.UpdateBallPosition(e.MousePosition.X); graph.ShowBall(); } + return base.OnHover(e); } diff --git a/osu.Game/Overlays/Profile/Header/SupporterIcon.cs b/osu.Game/Overlays/Profile/Header/SupporterIcon.cs index 92c8a34728..722c9c9af2 100644 --- a/osu.Game/Overlays/Profile/Header/SupporterIcon.cs +++ b/osu.Game/Overlays/Profile/Header/SupporterIcon.cs @@ -23,35 +23,35 @@ namespace osu.Game.Overlays.Profile.Header Masking = true; Children = new Drawable[] { - new Box { RelativeSizeAxes = Axes.Both }, - new CircularContainer + new Box { RelativeSizeAxes = Axes.Both }, + new CircularContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Scale = new Vector2(0.8f), + Masking = true, + Children = new Drawable[] { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Scale = new Vector2(0.8f), - Masking = true, - Children = new Drawable[] + background = new Box { RelativeSizeAxes = Axes.Both }, + new Triangles { - background = new Box { RelativeSizeAxes = Axes.Both }, - new Triangles - { - TriangleScale = 0.2f, - ColourLight = OsuColour.FromHex(@"ff7db7"), - ColourDark = OsuColour.FromHex(@"de5b95"), - RelativeSizeAxes = Axes.Both, - Velocity = 0.3f, - }, - } - }, - new SpriteIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Icon = FontAwesome.fa_heart, - Scale = new Vector2(0.45f), + TriangleScale = 0.2f, + ColourLight = OsuColour.FromHex(@"ff7db7"), + ColourDark = OsuColour.FromHex(@"de5b95"), + RelativeSizeAxes = Axes.Both, + Velocity = 0.3f, + }, } + }, + new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Icon = FontAwesome.fa_heart, + Scale = new Vector2(0.45f), + } }; } diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 524b709a83..2641a0551d 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -19,6 +19,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Profile.Components; using osu.Game.Overlays.Profile.Header; using osu.Game.Users; +using Humanizer; namespace osu.Game.Overlays.Profile { @@ -118,8 +119,7 @@ namespace osu.Game.Overlays.Profile usernameText = new OsuSpriteText { Text = user.Username, - Font = @"Exo2.0-RegularItalic", - TextSize = 30, + Font = OsuFont.GetFont(size: 30, weight: FontWeight.Regular, italics: true) }, new ExternalLinkButton($@"https://osu.ppy.sh/users/{user.Id}") { @@ -166,7 +166,7 @@ namespace osu.Game.Overlays.Profile Y = cover_height, Colour = OsuColour.Gray(34), }, - infoTextLeft = new LinkFlowContainer(t => t.TextSize = 14) + infoTextLeft = new LinkFlowContainer(t => t.Font = t.Font.With(size: 14)) { X = UserProfileOverlay.CONTENT_X_MARGIN, Y = cover_height + 20, @@ -175,11 +175,7 @@ namespace osu.Game.Overlays.Profile ParagraphSpacing = 0.8f, LineSpacing = 0.2f }, - infoTextRight = new LinkFlowContainer(t => - { - t.TextSize = 14; - t.Font = @"Exo2.0-RegularItalic"; - }) + infoTextRight = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Regular, italics: true)) { X = UserProfileOverlay.CONTENT_X_MARGIN + info_width + 20, Y = cover_height + 20, @@ -222,7 +218,7 @@ namespace osu.Game.Overlays.Profile Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Y = 11, - TextSize = 20 + Font = OsuFont.GetFont(size: 20) } } }, @@ -323,7 +319,7 @@ namespace osu.Game.Overlays.Profile public User User { - get { return user; } + get => user; set { user = value; @@ -354,19 +350,18 @@ namespace osu.Game.Overlays.Profile colourBar.Show(); } - void boldItalic(SpriteText t) => t.Font = @"Exo2.0-BoldItalic"; + void boldItalic(SpriteText t) => t.Font = t.Font.With(Typeface.Exo, weight: FontWeight.Bold, italics: true); void lightText(SpriteText t) => t.Alpha = 0.8f; OsuSpriteText createScoreText(string text) => new OsuSpriteText { - TextSize = 14, + Font = OsuFont.GetFont(size: 14), Text = text }; OsuSpriteText createScoreNumberText(string text) => new OsuSpriteText { - TextSize = 14, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Text = text @@ -407,7 +402,7 @@ namespace osu.Game.Overlays.Profile infoTextLeft.NewLine(); infoTextLeft.AddText("Contributed ", lightText); - infoTextLeft.AddLink($@"{user.PostCount} forum posts", url: $"https://osu.ppy.sh/users/{user.Id}/posts", creationParameters: boldItalic); + infoTextLeft.AddLink("forum post".ToQuantity(user.PostCount), url: $"https://osu.ppy.sh/users/{user.Id}/posts", creationParameters: boldItalic); string websiteWithoutProtcol = user.Website; if (!string.IsNullOrEmpty(websiteWithoutProtcol)) diff --git a/osu.Game/Overlays/Profile/ProfileSection.cs b/osu.Game/Overlays/Profile/ProfileSection.cs index f5f628f07b..6da736432f 100644 --- a/osu.Game/Overlays/Profile/ProfileSection.cs +++ b/osu.Game/Overlays/Profile/ProfileSection.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Bindables; using osuTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -9,7 +10,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Users; using osuTK.Graphics; -using osu.Framework.Configuration; namespace osu.Game.Overlays.Profile { @@ -35,8 +35,7 @@ namespace osu.Game.Overlays.Profile new OsuSpriteText { Text = Title, - TextSize = 20, - Font = @"Exo2.0-RegularItalic", + Font = OsuFont.GetFont(size: 20, weight: FontWeight.Regular, italics: true), Margin = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, @@ -67,8 +66,6 @@ namespace osu.Game.Overlays.Profile Add(new OsuSpriteText { Text = @"coming soon!", - TextSize = 16, - Font = @"Exo2.0-Medium", Colour = Color4.Gray, Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs b/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs index 3b673ec004..bb55816880 100644 --- a/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Localisation; using osu.Game.Beatmaps; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; @@ -46,17 +47,16 @@ namespace osu.Game.Overlays.Profile.Sections { new OsuSpriteText { - Text = new LocalisedString(($"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ", - $"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] ")), - TextSize = 15, - Font = "Exo2.0-SemiBoldItalic", + Text = new LocalisedString(( + $"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ", + $"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] ")), + Font = OsuFont.GetFont(size: 15, weight: FontWeight.SemiBold, italics: true) }, new OsuSpriteText { Text = new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)), - TextSize = 12, Padding = new MarginPadding { Top = 3 }, - Font = "Exo2.0-RegularItalic", + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular, italics: true) }, }, }; diff --git a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs index 8bceafb8f3..0fc1398f5d 100644 --- a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Linq; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Online.API.Requests; using osu.Game.Overlays.Direct; diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs index 942723479a..b0609e685e 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osuTK; @@ -47,7 +48,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical new OsuSpriteText { Text = @"mapped by ", - TextSize = 12, + Font = OsuFont.GetFont(size: 12) }, mapperContainer = new OsuHoverContainer { @@ -57,8 +58,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical new OsuSpriteText { Text = beatmap.Metadata.AuthorString, - TextSize = 12, - Font = @"Exo2.0-MediumItalic" + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Medium, italics: true) } } }, @@ -78,16 +78,14 @@ namespace osu.Game.Overlays.Profile.Sections.Historical Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, Text = playCount.ToString(), - TextSize = 18, - Font = @"Exo2.0-SemiBoldItalic" + Font = OsuFont.GetFont(size: 18, weight: FontWeight.SemiBold, italics: true) }, new OsuSpriteText { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, Text = @"times played ", - TextSize = 12, - Font = @"Exo2.0-RegularItalic" + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular, italics: true) }, } }); diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs index 5ec252b109..f2eb32c53b 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Linq; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Online.API.Requests; @@ -15,7 +15,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical private GetUserMostPlayedBeatmapsRequest request; public PaginatedMostPlayedBeatmapContainer(Bindable user) - :base(user, "Most Played Beatmaps", "No records. :(") + : base(user, "Most Played Beatmaps", "No records. :(") { ItemsPerPage = 5; diff --git a/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs b/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs index 33b74a6d93..3c69082e9d 100644 --- a/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs +++ b/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs @@ -1,9 +1,9 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Bindables; using osuTK; using osuTK.Graphics; -using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -63,10 +63,10 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu } }; - this.user.ValueChanged += newUser => + this.user.ValueChanged += u => { - total.Count = newUser?.Kudosu.Total ?? 0; - avaliable.Count = newUser?.Kudosu.Available ?? 0; + total.Count = u.NewValue?.Kudosu.Total ?? 0; + avaliable.Count = u.NewValue?.Kudosu.Available ?? 0; }; } @@ -78,7 +78,7 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu public new int Count { - set { valueText.Text = value.ToString(); } + set => valueText.Text = value.ToString(); } public CountSection(string header, string description) @@ -107,21 +107,19 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Text = header + ":", - TextSize = 20, - Font = @"Exo2.0-RegularItalic", + Font = OsuFont.GetFont(size: 20, weight: FontWeight.Regular, italics: true) }, valueText = new OsuSpriteText { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Text = "0", - TextSize = 40, + Font = OsuFont.GetFont(size: 40, weight: FontWeight.Regular, italics: true), UseFullGlyphHeight = false, - Font = @"Exo2.0-RegularItalic" } } }, - new OsuTextFlowContainer(t => { t.TextSize = 19; }) + new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 19)) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 6439475a7b..497d6c3fc4 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -3,9 +3,10 @@ using osuTK; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; @@ -43,9 +44,8 @@ namespace osu.Game.Overlays.Profile.Sections { new OsuSpriteText { - TextSize = 15, Text = header, - Font = "Exo2.0-RegularItalic", + Font = OsuFont.GetFont(size: 15, weight: FontWeight.Regular, italics: true), Margin = new MarginPadding { Top = 10, Bottom = 10 }, }, ItemsContainer = new FillFlowContainer @@ -63,9 +63,9 @@ namespace osu.Game.Overlays.Profile.Sections Origin = Anchor.TopCentre, Child = new OsuSpriteText { - TextSize = 14, + Font = OsuFont.GetFont(size: 14), Text = "show more", - Padding = new MarginPadding {Vertical = 10, Horizontal = 15 }, + Padding = new MarginPadding { Vertical = 10, Horizontal = 15 }, } }, ShowMoreLoading = new LoadingAnimation @@ -76,7 +76,7 @@ namespace osu.Game.Overlays.Profile.Sections }, MissingText = new OsuSpriteText { - TextSize = 14, + Font = OsuFont.GetFont(size: 14), Text = missing, Alpha = 0, }, @@ -93,13 +93,13 @@ namespace osu.Game.Overlays.Profile.Sections User.TriggerChange(); } - private void onUserChanged(User newUser) + private void onUserChanged(ValueChangedEvent e) { VisiblePages = 0; ItemsContainer.Clear(); ShowMoreButton.Hide(); - if (newUser != null) + if (e.NewValue != null) ShowMore(); } diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs index c612169cfb..843f9b7ef2 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs @@ -28,8 +28,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Text = $"{pp:0}pp", Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - TextSize = 18, - Font = "Exo2.0-BoldItalic", + Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold, italics: true) }); if (weight.HasValue) @@ -40,8 +39,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Colour = colour.GrayA, - TextSize = 11, - Font = "Exo2.0-RegularItalic", + Font = OsuFont.GetFont(size: 11, weight: FontWeight.Regular, italics: true) }); } } diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs index 147b8dffca..f4e08b8db1 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs @@ -46,8 +46,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Colour = colour.GrayA, - TextSize = 11, - Font = "Exo2.0-RegularItalic" + Font = OsuFont.GetFont(size: 11, weight: FontWeight.Regular, italics: true) }; RightFlowContainer.Add(text); diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs index 094d6032fd..8bfca08fe7 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs @@ -3,6 +3,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Scoring; @@ -23,8 +24,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Text = Score.TotalScore.ToString("#,###"), Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - TextSize = 18, - Font = "Exo2.0-BoldItalic", + Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold, italics: true) }); } } diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs index a2676350a2..95a18ccfa9 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Online.API.Requests; @@ -9,6 +8,7 @@ using osu.Game.Users; using System; using System.Collections.Generic; using System.Linq; +using osu.Framework.Bindables; namespace osu.Game.Overlays.Profile.Sections.Ranks { diff --git a/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs b/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs index a91aa78b70..7e721ac807 100644 --- a/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs +++ b/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs @@ -42,7 +42,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent RightFlowContainer.Add(new DrawableDate(activity.CreatedAt) { - TextSize = 13, + Font = OsuFont.GetFont(size: 13), Colour = OsuColour.Gray(0xAA), Anchor = Anchor.TopRight, Origin = Anchor.TopRight, diff --git a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs index b7de719305..4b4acb8fbc 100644 --- a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs @@ -1,11 +1,11 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Game.Online.API.Requests; using osu.Game.Users; using System.Linq; +using osu.Framework.Bindables; using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.Profile.Sections.Recent diff --git a/osu.Game/Overlays/SearchableList/DisplayStyleControl.cs b/osu.Game/Overlays/SearchableList/DisplayStyleControl.cs index f5ec6c296a..f55e5f8c59 100644 --- a/osu.Game/Overlays/SearchableList/DisplayStyleControl.cs +++ b/osu.Game/Overlays/SearchableList/DisplayStyleControl.cs @@ -1,8 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Bindables; using osuTK; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; @@ -78,13 +78,13 @@ namespace osu.Game.Overlays.SearchableList }; bindable.ValueChanged += Bindable_ValueChanged; - Bindable_ValueChanged(bindable.Value); + Bindable_ValueChanged(new ValueChangedEvent(bindable.Value, bindable.Value)); Action = () => bindable.Value = this.style; } - private void Bindable_ValueChanged(PanelDisplayStyle style) + private void Bindable_ValueChanged(ValueChangedEvent e) { - icon.FadeTo(style == this.style ? 1.0f : 0.5f, 100); + icon.FadeTo(e.NewValue == style ? 1.0f : 0.5f, 100); } protected override void Dispose(bool isDisposing) diff --git a/osu.Game/Overlays/SearchableList/HeaderTabControl.cs b/osu.Game/Overlays/SearchableList/HeaderTabControl.cs index 6fff17ab26..2087a72c54 100644 --- a/osu.Game/Overlays/SearchableList/HeaderTabControl.cs +++ b/osu.Game/Overlays/SearchableList/HeaderTabControl.cs @@ -19,9 +19,10 @@ namespace osu.Game.Overlays.SearchableList private class HeaderTabItem : OsuTabItem { - public HeaderTabItem(T value) : base(value) + public HeaderTabItem(T value) + : base(value) { - Text.TextSize = 16; + Text.Font = Text.Font.With(size: 16); } } } diff --git a/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs b/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs index 26c2f57f14..8ed196fd01 100644 --- a/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs @@ -4,6 +4,7 @@ using System; using System.Runtime; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -34,8 +35,8 @@ namespace osu.Game.Overlays.Settings.Sections.Debug }; configLatencyMode = config.GetBindable(DebugSetting.ActiveGCMode); - configLatencyMode.BindValueChanged(v => latencyMode.Value = (LatencyMode)v, true); - latencyMode.BindValueChanged(v => configLatencyMode.Value = (GCLatencyMode)v); + configLatencyMode.BindValueChanged(mode => latencyMode.Value = (LatencyMode)mode.NewValue, true); + latencyMode.BindValueChanged(mode => configLatencyMode.Value = (GCLatencyMode)mode.NewValue); } private enum LatencyMode diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 4fad999577..026424e1ff 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -41,7 +41,7 @@ namespace osu.Game.Overlays.Settings.Sections.General public bool Bounding { - get { return bounding; } + get => bounding; set { bounding = value; @@ -78,7 +78,7 @@ namespace osu.Game.Overlays.Settings.Sections.General { Text = "ACCOUNT", Margin = new MarginPadding { Bottom = 5 }, - Font = @"Exo2.0-Black", + Font = OsuFont.GetFont(weight: FontWeight.Black), }, form = new LoginForm { @@ -134,8 +134,7 @@ namespace osu.Game.Overlays.Settings.Sections.General Anchor = Anchor.Centre, Origin = Anchor.Centre, Text = "Signed in", - TextSize = 18, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold), Margin = new MarginPadding { Top = 5, Bottom = 5 }, }, }, @@ -152,9 +151,9 @@ namespace osu.Game.Overlays.Settings.Sections.General panel.Status.BindTo(api.LocalUser.Value.Status); - dropdown.Current.ValueChanged += newValue => + dropdown.Current.ValueChanged += action => { - switch (newValue) + switch (action.NewValue) { case UserAction.Online: api.LocalUser.Value.Status.Value = new UserStatusOnline(); @@ -278,6 +277,7 @@ namespace osu.Game.Overlays.Settings.Sections.General { var h = Header as UserDropdownHeader; if (h == null) return; + h.StatusColour = value; } } @@ -339,7 +339,7 @@ namespace osu.Game.Overlays.Settings.Sections.General public Color4 StatusColour { - set { statusIcon.FadeColour(value, 500, Easing.OutQuint); } + set => statusIcon.FadeColour(value, 500, Easing.OutQuint); } public UserDropdownHeader() diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 4d889856f6..188c9c05ef 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -1,8 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework; using osu.Framework.Allocation; -using osu.Framework.Graphics; using osu.Framework.Platform; using osu.Game.Configuration; @@ -15,19 +15,20 @@ namespace osu.Game.Overlays.Settings.Sections.General [BackgroundDependencyLoader] private void load(Storage storage, OsuConfigManager config) { - Children = new Drawable[] + Add(new SettingsEnumDropdown { - new SettingsEnumDropdown - { - LabelText = "Release stream", - Bindable = config.GetBindable(OsuSetting.ReleaseStream), - }, - new SettingsButton + LabelText = "Release stream", + Bindable = config.GetBindable(OsuSetting.ReleaseStream), + }); + + if (RuntimeInfo.IsDesktop) + { + Add(new SettingsButton { Text = "Open osu! folder", Action = storage.OpenInNativeExplorer, - } - }; + }); + } } } } diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs index 9c5ef32251..58d2eb1f1e 100644 --- a/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs @@ -5,11 +5,13 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Configuration; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Platform; using osu.Game.Configuration; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; @@ -25,10 +27,11 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics private Bindable scalingMode; private Bindable sizeFullscreen; + private readonly BindableList windowModes = new BindableList(); private OsuGameBase game; private SettingsDropdown resolutionDropdown; - private SettingsEnumDropdown windowModeDropdown; + private SettingsDropdown windowModeDropdown; private Bindable scalingPositionX; private Bindable scalingPositionY; @@ -38,7 +41,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics private const int transition_duration = 400; [BackgroundDependencyLoader] - private void load(FrameworkConfigManager config, OsuConfigManager osuConfig, OsuGameBase game) + private void load(FrameworkConfigManager config, OsuConfigManager osuConfig, OsuGameBase game, GameHost host) { this.game = game; @@ -49,14 +52,18 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics scalingPositionX = osuConfig.GetBindable(OsuSetting.ScalingPositionX); scalingPositionY = osuConfig.GetBindable(OsuSetting.ScalingPositionY); + if (host.Window != null) + windowModes.BindTo(host.Window.SupportedWindowModes); + Container resolutionSettingsContainer; Children = new Drawable[] { - windowModeDropdown = new SettingsEnumDropdown + windowModeDropdown = new SettingsDropdown { LabelText = "Screen mode", Bindable = config.GetBindable(FrameworkSetting.WindowMode), + ItemSource = windowModes, }, resolutionSettingsContainer = new Container { @@ -83,7 +90,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics AutoSizeDuration = transition_duration, AutoSizeEasing = Easing.OutQuint, Masking = true, - Children = new [] + Children = new[] { new SettingsSlider { @@ -127,9 +134,9 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics Bindable = sizeFullscreen }; - windowModeDropdown.Bindable.BindValueChanged(windowMode => + windowModeDropdown.Bindable.BindValueChanged(mode => { - if (windowMode == WindowMode.Fullscreen) + if (mode.NewValue == WindowMode.Fullscreen) { resolutionDropdown.Show(); sizeFullscreen.TriggerChange(); @@ -142,13 +149,26 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics scalingMode.BindValueChanged(mode => { scalingSettings.ClearTransforms(); - scalingSettings.AutoSizeAxes = mode != ScalingMode.Off ? Axes.Y : Axes.None; + scalingSettings.AutoSizeAxes = mode.NewValue != ScalingMode.Off ? Axes.Y : Axes.None; - if (mode == ScalingMode.Off) + if (mode.NewValue == ScalingMode.Off) scalingSettings.ResizeHeightTo(0, transition_duration, Easing.OutQuint); - scalingSettings.ForEach(s => s.TransferValueOnCommit = mode == ScalingMode.Everything); + scalingSettings.ForEach(s => s.TransferValueOnCommit = mode.NewValue == ScalingMode.Everything); }, true); + + windowModes.ItemsAdded += _ => windowModesChanged(); + windowModes.ItemsRemoved += _ => windowModesChanged(); + + windowModesChanged(); + } + + private void windowModesChanged() + { + if (windowModes.Count > 1) + windowModeDropdown.Show(); + else + windowModeDropdown.Hide(); } /// @@ -158,7 +178,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics /// A bindable which will propagate updates with a delay. private void bindPreviewEvent(Bindable bindable) { - bindable.ValueChanged += v => + bindable.ValueChanged += _ => { switch (scalingMode.Value) { @@ -170,6 +190,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics } private Drawable preview; + private void showPreview() { if (preview?.IsAlive != true) @@ -224,6 +245,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics { if (item == new Size(9999, 9999)) return "Default"; + return $"{item.Width}x{item.Height}"; } } diff --git a/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs index efe3d782ae..3f1e77d482 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs @@ -16,6 +16,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input new SettingsButton { Text = "Key configuration", + TooltipText = "Change global shortcut keys and gameplay bindings", Action = keyConfig.ToggleVisibility }, }; diff --git a/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs index 05b685a12b..4f2f3dfd1a 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Input; @@ -61,13 +62,13 @@ namespace osu.Game.Overlays.Settings.Sections.Input const string raw_mouse_handler = @"OsuTKRawMouseHandler"; const string standard_mouse_handler = @"OsuTKMouseHandler"; - ignoredInputHandler.Value = enabled ? standard_mouse_handler : raw_mouse_handler; + ignoredInputHandler.Value = enabled.NewValue ? standard_mouse_handler : raw_mouse_handler; }; ignoredInputHandler = config.GetBindable(FrameworkSetting.IgnoredInputHandlers); ignoredInputHandler.ValueChanged += handler => { - bool raw = !handler.Contains("Raw"); + bool raw = !handler.NewValue.Contains("Raw"); rawInputToggle.Value = raw; sensitivity.Bindable.Disabled = !raw; }; diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs index d512652938..398a091486 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs @@ -25,9 +25,9 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance [BackgroundDependencyLoader] private void load(BeatmapManager beatmaps, SkinManager skins, DialogOverlay dialogOverlay) { - Children = new Drawable[] + if (beatmaps.SupportsImportFromStable) { - importBeatmapsButton = new SettingsButton + Add(importBeatmapsButton = new SettingsButton { Text = "Import beatmaps from stable", Action = () => @@ -35,20 +35,25 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance importBeatmapsButton.Enabled.Value = false; beatmaps.ImportFromStableAsync().ContinueWith(t => Schedule(() => importBeatmapsButton.Enabled.Value = true)); } - }, - deleteBeatmapsButton = new DangerousSettingsButton + }); + } + + Add(deleteBeatmapsButton = new DangerousSettingsButton + { + Text = "Delete ALL beatmaps", + Action = () => { - Text = "Delete ALL beatmaps", - Action = () => + dialogOverlay?.Push(new DeleteAllBeatmapsDialog(() => { - dialogOverlay?.Push(new DeleteAllBeatmapsDialog(() => - { - deleteBeatmapsButton.Enabled.Value = false; - Task.Run(() => beatmaps.Delete(beatmaps.GetAllUsableBeatmapSets())).ContinueWith(t => Schedule(() => deleteBeatmapsButton.Enabled.Value = true)); - })); - } - }, - importSkinsButton = new SettingsButton + deleteBeatmapsButton.Enabled.Value = false; + Task.Run(() => beatmaps.Delete(beatmaps.GetAllUsableBeatmapSets())).ContinueWith(t => Schedule(() => deleteBeatmapsButton.Enabled.Value = true)); + })); + } + }); + + if (skins.SupportsImportFromStable) + { + Add(importSkinsButton = new SettingsButton { Text = "Import skins from stable", Action = () => @@ -56,7 +61,11 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance importSkinsButton.Enabled.Value = false; skins.ImportFromStableAsync().ContinueWith(t => Schedule(() => importSkinsButton.Enabled.Value = true)); } - }, + }); + } + + AddRange(new Drawable[] + { deleteSkinsButton = new DangerousSettingsButton { Text = "Delete ALL skins", @@ -91,7 +100,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance Task.Run(() => beatmaps.Undelete(beatmaps.QueryBeatmapSets(b => b.DeletePending).ToList())).ContinueWith(t => Schedule(() => undeleteButton.Enabled.Value = true)); } }, - }; + }); } } } diff --git a/osu.Game/Overlays/Settings/Sections/SkinSection.cs b/osu.Game/Overlays/Settings/Sections/SkinSection.cs index 7361d671de..d1f47b6016 100644 --- a/osu.Game/Overlays/Settings/Sections/SkinSection.cs +++ b/osu.Game/Overlays/Settings/Sections/SkinSection.cs @@ -3,7 +3,7 @@ using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Configuration; using osu.Game.Graphics; @@ -76,8 +76,8 @@ namespace osu.Game.Overlays.Settings.Sections if (skinDropdown.Items.All(s => s.ID != configBindable.Value)) configBindable.Value = 0; - configBindable.BindValueChanged(v => dropdownBindable.Value = skinDropdown.Items.Single(s => s.ID == v), true); - dropdownBindable.BindValueChanged(v => configBindable.Value = v.ID); + configBindable.BindValueChanged(id => dropdownBindable.Value = skinDropdown.Items.Single(s => s.ID == id.NewValue), true); + dropdownBindable.BindValueChanged(skin => configBindable.Value = skin.NewValue.ID); } private void itemRemoved(SkinInfo s) => Schedule(() => skinDropdown.Items = skinDropdown.Items.Where(i => i.ID != s.ID).ToArray()); diff --git a/osu.Game/Overlays/Settings/SettingsButton.cs b/osu.Game/Overlays/Settings/SettingsButton.cs index 73cf855e18..ef98c28285 100644 --- a/osu.Game/Overlays/Settings/SettingsButton.cs +++ b/osu.Game/Overlays/Settings/SettingsButton.cs @@ -1,17 +1,33 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; +using System.Linq; using osu.Framework.Graphics; +using osu.Framework.Graphics.Cursor; using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Settings { - public class SettingsButton : TriangleButton + public class SettingsButton : TriangleButton, IHasTooltip { public SettingsButton() { RelativeSizeAxes = Axes.X; Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS }; } + + public string TooltipText { get; set; } + + public override IEnumerable FilterTerms + { + get + { + if (TooltipText != null) + return base.FilterTerms.Append(TooltipText); + + return base.FilterTerms; + } + } } } diff --git a/osu.Game/Overlays/Settings/SettingsCheckbox.cs b/osu.Game/Overlays/Settings/SettingsCheckbox.cs index 71c197b784..46c23c3bbf 100644 --- a/osu.Game/Overlays/Settings/SettingsCheckbox.cs +++ b/osu.Game/Overlays/Settings/SettingsCheckbox.cs @@ -14,8 +14,8 @@ namespace osu.Game.Overlays.Settings public override string LabelText { - get { return checkbox.LabelText; } - set { checkbox.LabelText = value; } + get => checkbox.LabelText; + set => checkbox.LabelText = value; } } } diff --git a/osu.Game/Overlays/Settings/SettingsDropdown.cs b/osu.Game/Overlays/Settings/SettingsDropdown.cs index 1829bbdcbc..de3f741cd7 100644 --- a/osu.Game/Overlays/Settings/SettingsDropdown.cs +++ b/osu.Game/Overlays/Settings/SettingsDropdown.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Graphics.UserInterface; @@ -26,11 +27,25 @@ namespace osu.Game.Overlays.Settings } } + private IBindableList itemSource; + + public IBindableList ItemSource + { + get => itemSource; + set + { + itemSource = value; + + if (Control != null) + Control.ItemSource = value; + } + } + public override IEnumerable FilterTerms => base.FilterTerms.Concat(Control.Items.Select(i => i.ToString())); protected sealed override Drawable CreateControl() => CreateDropdown(); - protected virtual OsuDropdown CreateDropdown() => new DropdownControl { Items = Items }; + protected virtual OsuDropdown CreateDropdown() => new DropdownControl { Items = Items, ItemSource = ItemSource }; protected class DropdownControl : OsuDropdown { diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 7c50e2f254..e8c2c1ffe8 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -56,14 +56,13 @@ namespace osu.Game.Overlays.Settings Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = game.Name, - TextSize = 18, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold), }, new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - TextSize = 14, + Font = OsuFont.GetFont(size: 14), Text = game.Version, Colour = DebugUtils.IsDebug ? colours.Red : Color4.White, }, diff --git a/osu.Game/Overlays/Settings/SettingsHeader.cs b/osu.Game/Overlays/Settings/SettingsHeader.cs index fceeec5166..fbf29f7ff5 100644 --- a/osu.Game/Overlays/Settings/SettingsHeader.cs +++ b/osu.Game/Overlays/Settings/SettingsHeader.cs @@ -38,7 +38,7 @@ namespace osu.Game.Overlays.Settings new OsuSpriteText { Text = heading, - TextSize = 40, + Font = OsuFont.GetFont(size: 40), Margin = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, @@ -49,7 +49,7 @@ namespace osu.Game.Overlays.Settings { Colour = colours.Pink, Text = subheading, - TextSize = 18, + Font = OsuFont.GetFont(size: 18), Margin = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, diff --git a/osu.Game/Overlays/Settings/SettingsItem.cs b/osu.Game/Overlays/Settings/SettingsItem.cs index dab8ce1eaa..56c750b552 100644 --- a/osu.Game/Overlays/Settings/SettingsItem.cs +++ b/osu.Game/Overlays/Settings/SettingsItem.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osuTK.Graphics; -using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Settings public virtual string LabelText { - get { return text?.Text ?? string.Empty; } + get => text?.Text ?? string.Empty; set { if (text == null) @@ -58,7 +58,7 @@ namespace osu.Game.Overlays.Settings public virtual Bindable Bindable { - get { return bindable; } + get => bindable; set { @@ -78,11 +78,7 @@ namespace osu.Game.Overlays.Settings public bool MatchingFilter { - set - { - // probably needs a better transition. - this.FadeTo(value ? 1 : 0); - } + set => this.FadeTo(value ? 1 : 0); } protected SettingsItem() @@ -117,12 +113,12 @@ namespace osu.Game.Overlays.Settings public Bindable Bindable { - get { return bindable; } + get => bindable; set { bindable = value; - bindable.ValueChanged += newValue => UpdateState(); - bindable.DisabledChanged += disabled => UpdateState(); + bindable.ValueChanged += _ => UpdateState(); + bindable.DisabledChanged += _ => UpdateState(); } } diff --git a/osu.Game/Overlays/Settings/SettingsSection.cs b/osu.Game/Overlays/Settings/SettingsSection.cs index 4af9961ea8..38a8b58a68 100644 --- a/osu.Game/Overlays/Settings/SettingsSection.cs +++ b/osu.Game/Overlays/Settings/SettingsSection.cs @@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Settings public bool MatchingFilter { - set { this.FadeTo(value ? 1 : 0); } + set => this.FadeTo(value ? 1 : 0); } protected SettingsSection() @@ -77,7 +77,7 @@ namespace osu.Game.Overlays.Settings { new OsuSpriteText { - TextSize = header_size, + Font = OsuFont.GetFont(size: header_size), Text = Header, Colour = colours.Yellow, Margin = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS } diff --git a/osu.Game/Overlays/Settings/SettingsSubsection.cs b/osu.Game/Overlays/Settings/SettingsSubsection.cs index 4d0b0de7f9..2215e95fec 100644 --- a/osu.Game/Overlays/Settings/SettingsSubsection.cs +++ b/osu.Game/Overlays/Settings/SettingsSubsection.cs @@ -8,6 +8,7 @@ using osu.Game.Graphics.Sprites; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; +using osu.Game.Graphics; namespace osu.Game.Overlays.Settings { @@ -21,12 +22,10 @@ namespace osu.Game.Overlays.Settings public IEnumerable FilterableChildren => Children.OfType(); public IEnumerable FilterTerms => new[] { Header }; + public bool MatchingFilter { - set - { - this.FadeTo(value ? 1 : 0); - } + set => this.FadeTo(value ? 1 : 0); } protected SettingsSubsection() @@ -53,7 +52,7 @@ namespace osu.Game.Overlays.Settings { Text = Header.ToUpperInvariant(), Margin = new MarginPadding { Bottom = 10, Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS }, - Font = @"Exo2.0-Black", + Font = OsuFont.GetFont(weight: FontWeight.Black), }, FlowContent }); diff --git a/osu.Game/Overlays/Settings/Sidebar.cs b/osu.Game/Overlays/Settings/Sidebar.cs index 960ceaa78f..969686e36d 100644 --- a/osu.Game/Overlays/Settings/Sidebar.cs +++ b/osu.Game/Overlays/Settings/Sidebar.cs @@ -88,7 +88,7 @@ namespace osu.Game.Overlays.Settings public ExpandedState State { - get { return state; } + get => state; set { expandEvent?.Cancel(); diff --git a/osu.Game/Overlays/Settings/SidebarButton.cs b/osu.Game/Overlays/Settings/SidebarButton.cs index c53596cabe..c7736d6047 100644 --- a/osu.Game/Overlays/Settings/SidebarButton.cs +++ b/osu.Game/Overlays/Settings/SidebarButton.cs @@ -26,12 +26,10 @@ namespace osu.Game.Overlays.Settings public new Action Action; private SettingsSection section; + public SettingsSection Section { - get - { - return section; - } + get => section; set { section = value; @@ -41,9 +39,10 @@ namespace osu.Game.Overlays.Settings } private bool selected; + public bool Selected { - get { return selected; } + get => selected; set { selected = value; diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index 802e97d92a..174d3a3de1 100644 --- a/osu.Game/Overlays/SettingsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -107,12 +107,12 @@ namespace osu.Game.Overlays SectionsContainer.SelectedSection.ValueChanged += section => { selectedSidebarButton.Selected = false; - selectedSidebarButton = Sidebar.Children.Single(b => b.Section == section); + selectedSidebarButton = Sidebar.Children.Single(b => b.Section == section.NewValue); selectedSidebarButton.Selected = true; }; } - searchTextBox.Current.ValueChanged += newValue => SectionsContainer.SearchContainer.SearchTerm = newValue; + searchTextBox.Current.ValueChanged += term => SectionsContainer.SearchContainer.SearchTerm = term.NewValue; CreateSections()?.ForEach(AddSection); } diff --git a/osu.Game/Overlays/Social/Header.cs b/osu.Game/Overlays/Social/Header.cs index de738247ec..cf8053ac6e 100644 --- a/osu.Game/Overlays/Social/Header.cs +++ b/osu.Game/Overlays/Social/Header.cs @@ -32,13 +32,12 @@ namespace osu.Game.Overlays.Social new OsuSpriteText { Text = "social ", - TextSize = 25, + Font = OsuFont.GetFont(size: 25), }, browser = new OsuSpriteText { Text = "browser", - TextSize = 25, - Font = @"Exo2.0-Light", + Font = OsuFont.GetFont(size: 25, weight: FontWeight.Light), }, }, }; @@ -55,6 +54,7 @@ namespace osu.Game.Overlays.Social { [Description("All Players")] AllPlayers, + [Description("Friends")] Friends, //[Description("Team Members")] diff --git a/osu.Game/Overlays/Social/SocialGridPanel.cs b/osu.Game/Overlays/Social/SocialGridPanel.cs index ccb8870bc9..6f707d640b 100644 --- a/osu.Game/Overlays/Social/SocialGridPanel.cs +++ b/osu.Game/Overlays/Social/SocialGridPanel.cs @@ -7,7 +7,8 @@ namespace osu.Game.Overlays.Social { public class SocialGridPanel : SocialPanel { - public SocialGridPanel(User user) : base(user) + public SocialGridPanel(User user) + : base(user) { Width = 300; } diff --git a/osu.Game/Overlays/Social/SocialListPanel.cs b/osu.Game/Overlays/Social/SocialListPanel.cs index 52c2caaa49..1ba91e9204 100644 --- a/osu.Game/Overlays/Social/SocialListPanel.cs +++ b/osu.Game/Overlays/Social/SocialListPanel.cs @@ -8,7 +8,8 @@ namespace osu.Game.Overlays.Social { public class SocialListPanel : SocialPanel { - public SocialListPanel(User user) : base(user) + public SocialListPanel(User user) + : base(user) { RelativeSizeAxes = Axes.X; } diff --git a/osu.Game/Overlays/Social/SocialPanel.cs b/osu.Game/Overlays/Social/SocialPanel.cs index bf1be29aa1..738f940484 100644 --- a/osu.Game/Overlays/Social/SocialPanel.cs +++ b/osu.Game/Overlays/Social/SocialPanel.cs @@ -15,7 +15,8 @@ namespace osu.Game.Overlays.Social { private const double hover_transition_time = 400; - public SocialPanel(User user) : base(user) + public SocialPanel(User user) + : base(user) { } diff --git a/osu.Game/Overlays/SocialOverlay.cs b/osu.Game/Overlays/SocialOverlay.cs index 2f14446564..3464058abb 100644 --- a/osu.Game/Overlays/SocialOverlay.cs +++ b/osu.Game/Overlays/SocialOverlay.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osuTK; using osuTK.Graphics; using osu.Framework.Graphics; @@ -15,7 +16,6 @@ using osu.Game.Online.API.Requests; using osu.Game.Overlays.SearchableList; using osu.Game.Overlays.Social; using osu.Game.Users; -using osu.Framework.Configuration; using osu.Framework.Threading; namespace osu.Game.Overlays @@ -34,9 +34,10 @@ namespace osu.Game.Overlays protected override SearchableListFilterControl CreateFilterControl() => new FilterControl(); private IEnumerable users; + public IEnumerable Users { - get { return users; } + get => users; set { if (users?.Equals(value) ?? false) @@ -57,7 +58,7 @@ namespace osu.Game.Overlays Filter.Search.Current.ValueChanged += text => { - if (!string.IsNullOrEmpty(text)) + if (!string.IsNullOrEmpty(text.NewValue)) { // force searching in players until searching for friends is supported Header.Tabs.Current.Value = SocialTab.AllPlayers; @@ -67,18 +68,18 @@ namespace osu.Game.Overlays } }; - Header.Tabs.Current.ValueChanged += tab => Scheduler.AddOnce(updateSearch); + Header.Tabs.Current.ValueChanged += _ => Scheduler.AddOnce(updateSearch); - Filter.Tabs.Current.ValueChanged += sortCriteria => Scheduler.AddOnce(updateSearch); + Filter.Tabs.Current.ValueChanged += _ => Scheduler.AddOnce(updateSearch); - Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; - Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += sortOrder => Scheduler.AddOnce(updateSearch); + Filter.DisplayStyleControl.DisplayStyle.ValueChanged += style => recreatePanels(style.NewValue); + Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += _ => Scheduler.AddOnce(updateSearch); currentQuery.ValueChanged += query => { queryChangedDebounce?.Cancel(); - if (string.IsNullOrEmpty(query)) + if (string.IsNullOrEmpty(query.NewValue)) Scheduler.AddOnce(updateSearch); else queryChangedDebounce = Scheduler.AddDelayed(updateSearch, 500); @@ -123,6 +124,7 @@ namespace osu.Game.Overlays panel = new SocialListPanel(u); break; } + panel.Status.BindTo(u.Status); return panel; }) @@ -130,7 +132,7 @@ namespace osu.Game.Overlays LoadComponentAsync(newPanels, f => { - if(panels != null) + if (panels != null) ScrollFlow.Remove(panels); ScrollFlow.Add(panels = newPanels); @@ -171,6 +173,7 @@ namespace osu.Game.Overlays api.Queue(getUsersRequest = userRequest); break; } + loading.Show(); } diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 2dc9b15cc5..61b2014af8 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -10,7 +10,7 @@ using osu.Game.Graphics; using osuTK; using osu.Framework.Graphics.Shapes; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Input.Events; namespace osu.Game.Overlays.Toolbar @@ -85,7 +85,7 @@ namespace osu.Game.Overlays.Toolbar { StateChanged += visibility => { - if (overlayActivationMode == OverlayActivation.Disabled) + if (overlayActivationMode.Value == OverlayActivation.Disabled) State = Visibility.Hidden; }; diff --git a/osu.Game/Overlays/Toolbar/ToolbarButton.cs b/osu.Game/Overlays/Toolbar/ToolbarButton.cs index 563411d833..4d8fbb99ac 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarButton.cs @@ -35,34 +35,25 @@ namespace osu.Game.Overlays.Toolbar public FontAwesome Icon { - set { SetIcon(value); } + set => SetIcon(value); } public string Text { - get { return DrawableText.Text; } - set - { - DrawableText.Text = value; - } + get => DrawableText.Text; + set => DrawableText.Text = value; } public string TooltipMain { - get { return tooltip1.Text; } - set - { - tooltip1.Text = value; - } + get => tooltip1.Text; + set => tooltip1.Text = value; } public string TooltipSub { - get { return tooltip2.Text; } - set - { - tooltip2.Text = value; - } + get => tooltip2.Text; + set => tooltip2.Text = value; } protected virtual Anchor TooltipAnchor => Anchor.TopLeft; @@ -75,7 +66,8 @@ namespace osu.Game.Overlays.Toolbar private readonly SpriteText tooltip2; protected FillFlowContainer Flow; - public ToolbarButton() : base(HoverSampleSet.Loud) + public ToolbarButton() + : base(HoverSampleSet.Loud) { Width = WIDTH; RelativeSizeAxes = Axes.Y; @@ -129,15 +121,13 @@ namespace osu.Game.Overlays.Toolbar Anchor = TooltipAnchor, Origin = TooltipAnchor, Shadow = true, - TextSize = 22, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 22, weight: FontWeight.Bold), }, tooltip2 = new OsuSpriteText { Anchor = TooltipAnchor, Origin = TooltipAnchor, Shadow = true, - TextSize = 16 } } } diff --git a/osu.Game/Overlays/Toolbar/ToolbarNotificationButton.cs b/osu.Game/Overlays/Toolbar/ToolbarNotificationButton.cs index 4b83e08292..751045f61c 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarNotificationButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarNotificationButton.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -47,11 +47,11 @@ namespace osu.Game.Overlays.Toolbar NotificationCount.ValueChanged += count => { - if (count == 0) + if (count.NewValue == 0) countDisplay.FadeOut(200, Easing.OutQuint); else { - countDisplay.Count = count; + countDisplay.Count = count.NewValue; countDisplay.FadeIn(200, Easing.OutQuint); } }; @@ -66,7 +66,7 @@ namespace osu.Game.Overlays.Toolbar public int Count { - get { return count; } + get => count; set { if (count == value) @@ -99,11 +99,10 @@ namespace osu.Game.Overlays.Toolbar Anchor = Anchor.Centre, Origin = Anchor.Centre, Y = -1, - TextSize = 14, + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), Padding = new MarginPadding(5), Colour = Color4.White, UseFullGlyphHeight = true, - Font = "Exo2.0-Bold", } }; } diff --git a/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs b/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs index fc6a54477c..ca86ce7aa7 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs @@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Toolbar public OverlayContainer StateContainer { - get { return stateContainer; } + get => stateContainer; set { stateContainer = value; diff --git a/osu.Game/Overlays/Toolbar/ToolbarRulesetButton.cs b/osu.Game/Overlays/Toolbar/ToolbarRulesetButton.cs index 07a53f0bae..f729810fbc 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarRulesetButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarRulesetButton.cs @@ -10,9 +10,10 @@ namespace osu.Game.Overlays.Toolbar public class ToolbarRulesetButton : ToolbarButton { private RulesetInfo ruleset; + public RulesetInfo Ruleset { - get { return ruleset; } + get => ruleset; set { ruleset = value; diff --git a/osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs index 354a7b6b58..d01eab4dab 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs @@ -3,13 +3,13 @@ using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Caching; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osuTK; using osuTK.Input; using osuTK.Graphics; -using osu.Framework.Configuration; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Game.Rulesets; @@ -115,11 +115,11 @@ namespace osu.Game.Overlays.Toolbar Size = new Vector2(modeButtons.DrawSize.X, 1); } - private void rulesetChanged(RulesetInfo ruleset) + private void rulesetChanged(ValueChangedEvent e) { foreach (ToolbarRulesetButton m in modeButtons.Children.Cast()) { - bool isActive = m.Ruleset.ID == ruleset.ID; + bool isActive = m.Ruleset.ID == e.NewValue.ID; m.Active = isActive; if (isActive) activeButton = m; diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs index eeb9527b50..f9cf5d4350 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs @@ -22,7 +22,8 @@ namespace osu.Game.Overlays.Toolbar RelativeSizeAxes = Axes.Y; AutoSizeAxes = Axes.X; - Children = new Drawable[] { + Children = new Drawable[] + { button = new ToolbarUserButton { Action = () => LoginOverlay.ToggleVisibility(), diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs index 28a1d60c40..d47f3a7b16 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs @@ -5,6 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; using osu.Game.Online.API; using osu.Game.Users; using osuTK; @@ -20,7 +21,7 @@ namespace osu.Game.Overlays.Toolbar { AutoSizeAxes = Axes.X; - DrawableText.Font = @"Exo2.0-MediumItalic"; + DrawableText.Font = OsuFont.GetFont(italics: true); Add(new OpaqueBackground { Depth = 1 }); @@ -57,7 +58,7 @@ namespace osu.Game.Overlays.Toolbar break; case APIState.Online: Text = api.LocalUser.Value.Username; - avatar.User = api.LocalUser; + avatar.User = api.LocalUser.Value; break; } } diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index d897c6c299..1ff1c2ce91 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -126,16 +126,16 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Both } }); - sectionsContainer.SelectedSection.ValueChanged += s => + sectionsContainer.SelectedSection.ValueChanged += section => { - if (lastSection != s) + if (lastSection != section.NewValue) { - lastSection = s; + lastSection = section.NewValue; tabs.Current.Value = lastSection; } }; - tabs.Current.ValueChanged += s => + tabs.Current.ValueChanged += section => { if (lastSection == null) { @@ -144,9 +144,10 @@ namespace osu.Game.Overlays tabs.Current.Value = lastSection; return; } - if (lastSection != s) + + if (lastSection != section.NewValue) { - lastSection = s; + lastSection = section.NewValue; sectionsContainer.ScrollTo(lastSection); } }; @@ -212,7 +213,8 @@ namespace osu.Game.Overlays private class ProfileTabItem : PageTabItem { - public ProfileTabItem(ProfileSection value) : base(value) + public ProfileTabItem(ProfileSection value) + : base(value) { Text.Text = value.Title; } diff --git a/osu.Game/Overlays/Volume/MuteButton.cs b/osu.Game/Overlays/Volume/MuteButton.cs index 2c46ed5517..6061ead2da 100644 --- a/osu.Game/Overlays/Volume/MuteButton.cs +++ b/osu.Game/Overlays/Volume/MuteButton.cs @@ -3,7 +3,7 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -69,10 +69,10 @@ namespace osu.Game.Overlays.Volume } }); - Current.ValueChanged += newValue => + Current.ValueChanged += muted => { - icon.Icon = newValue ? FontAwesome.fa_volume_off : FontAwesome.fa_volume_up; - icon.Margin = new MarginPadding { Left = newValue ? width / 2 - 15 : width / 2 - 10 }; //Magic numbers to line up both icons because they're different widths + icon.Icon = muted.NewValue ? FontAwesome.fa_volume_off : FontAwesome.fa_volume_up; + icon.Margin = new MarginPadding { Left = muted.NewValue ? width / 2 - 15 : width / 2 - 10 }; //Magic numbers to line up both icons because they're different widths }; Current.TriggerChange(); } diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs index b7d13156de..da696e0fdd 100644 --- a/osu.Game/Overlays/Volume/VolumeMeter.cs +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -4,7 +4,7 @@ using System; using System.Globalization; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -140,8 +140,7 @@ namespace osu.Game.Overlays.Volume { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = "Venera", - TextSize = 0.16f * circleSize + Font = OsuFont.Numeric.With(size: 0.16f * circleSize) }).WithEffect(new GlowEffect { Colour = Color4.Transparent, @@ -169,16 +168,16 @@ namespace osu.Game.Overlays.Volume { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = "Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold), Text = name } } } }; - Bindable.ValueChanged += newVolume => + Bindable.ValueChanged += volume => { this.TransformTo("DisplayVolume", - newVolume, + volume.NewValue, 400, Easing.OutQuint); }; @@ -218,7 +217,7 @@ namespace osu.Game.Overlays.Volume public double Volume { - get => Bindable; + get => Bindable.Value; private set => Bindable.Value = value; } diff --git a/osu.Game/Overlays/VolumeOverlay.cs b/osu.Game/Overlays/VolumeOverlay.cs index 95a1348941..e2e480ef53 100644 --- a/osu.Game/Overlays/VolumeOverlay.cs +++ b/osu.Game/Overlays/VolumeOverlay.cs @@ -3,7 +3,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -74,9 +74,9 @@ namespace osu.Game.Overlays volumeMeterEffect.Bindable.BindTo(audio.VolumeSample); volumeMeterMusic.Bindable.BindTo(audio.VolumeTrack); - muteButton.Current.ValueChanged += mute => + muteButton.Current.ValueChanged += muted => { - if (mute) + if (muted.NewValue) audio.AddAdjustment(AdjustableProperty.Volume, muteAdjustment); else audio.RemoveAdjustment(AdjustableProperty.Volume, muteAdjustment); @@ -113,7 +113,7 @@ namespace osu.Game.Overlays return true; case GlobalAction.ToggleMute: Show(); - muteButton.Current.Value = !muteButton.Current; + muteButton.Current.Value = !muteButton.Current.Value; return true; } diff --git a/osu.Game/Rulesets/Difficulty/DifficultyAttributes.cs b/osu.Game/Rulesets/Difficulty/DifficultyAttributes.cs index d7654462d5..d808ee528e 100644 --- a/osu.Game/Rulesets/Difficulty/DifficultyAttributes.cs +++ b/osu.Game/Rulesets/Difficulty/DifficultyAttributes.cs @@ -7,8 +7,13 @@ namespace osu.Game.Rulesets.Difficulty { public class DifficultyAttributes { - public readonly Mod[] Mods; - public readonly double StarRating; + public Mod[] Mods; + + public double StarRating; + + public DifficultyAttributes() + { + } public DifficultyAttributes(Mod[] mods, double starRating) { diff --git a/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs b/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs index 818d24508a..db8bdde6bb 100644 --- a/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs +++ b/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; @@ -7,12 +7,20 @@ using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Timing; using osu.Game.Beatmaps; +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Difficulty.Skills; using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Difficulty { public abstract class DifficultyCalculator { + /// + /// The length of each strain section. + /// + protected virtual int SectionLength => 400; + private readonly Ruleset ruleset; private readonly WorkingBeatmap beatmap; @@ -35,7 +43,7 @@ namespace osu.Game.Rulesets.Difficulty var clock = new StopwatchClock(); mods.OfType().ForEach(m => m.ApplyToClock(clock)); - return Calculate(playableBeatmap, mods, clock.Rate); + return calculate(playableBeatmap, mods, clock.Rate); } /// @@ -53,6 +61,44 @@ namespace osu.Game.Rulesets.Difficulty } } + private DifficultyAttributes calculate(IBeatmap beatmap, Mod[] mods, double clockRate) + { + var skills = CreateSkills(beatmap); + + if (!beatmap.HitObjects.Any()) + return CreateDifficultyAttributes(beatmap, mods, skills, clockRate); + + var difficultyHitObjects = CreateDifficultyHitObjects(beatmap, clockRate).OrderBy(h => h.BaseObject.StartTime).ToList(); + + double sectionLength = SectionLength * clockRate; + + // The first object doesn't generate a strain, so we begin with an incremented section end + double currentSectionEnd = Math.Ceiling(beatmap.HitObjects.First().StartTime / sectionLength) * sectionLength; + + foreach (DifficultyHitObject h in difficultyHitObjects) + { + while (h.BaseObject.StartTime > currentSectionEnd) + { + foreach (Skill s in skills) + { + s.SaveCurrentPeak(); + s.StartNewSectionFrom(currentSectionEnd); + } + + currentSectionEnd += sectionLength; + } + + foreach (Skill s in skills) + s.Process(h); + } + + // The peak strain will not be saved for the last section in the above loop + foreach (Skill s in skills) + s.SaveCurrentPeak(); + + return CreateDifficultyAttributes(beatmap, mods, skills, clockRate); + } + /// /// Creates all combinations which adjust the difficulty. /// @@ -67,12 +113,15 @@ namespace osu.Game.Rulesets.Difficulty case 0: // Initial-case: Empty current set yield return new ModNoMod(); + break; case 1: yield return currentSet.Single(); + break; default: yield return new MultiMod(currentSet.ToArray()); + break; } @@ -96,12 +145,27 @@ namespace osu.Game.Rulesets.Difficulty protected virtual Mod[] DifficultyAdjustmentMods => Array.Empty(); /// - /// Calculates the difficulty of a using a specific combination. + /// Creates to describe beatmap's calculated difficulty. /// - /// The to compute the difficulty for. - /// The s that should be applied. - /// The rate of time in . - /// A structure containing the difficulty attributes. - protected abstract DifficultyAttributes Calculate(IBeatmap beatmap, Mod[] mods, double timeRate); + /// The whose difficulty was calculated. + /// The s that difficulty was calculated with. + /// The skills which processed the beatmap. + /// The rate at which the gameplay clock is run at. + protected abstract DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate); + + /// + /// Enumerates s to be processed from s in the . + /// + /// The providing the s to enumerate. + /// The rate at which the gameplay clock is run at. + /// The enumerated s. + protected abstract IEnumerable CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate); + + /// + /// Creates the s to calculate the difficulty of an . + /// + /// The whose difficulty will be calculated.The s. + protected abstract Skill[] CreateSkills(IBeatmap beatmap); } } diff --git a/osu.Game/Rulesets/Difficulty/Preprocessing/DifficultyHitObject.cs b/osu.Game/Rulesets/Difficulty/Preprocessing/DifficultyHitObject.cs new file mode 100644 index 0000000000..ebbffb5143 --- /dev/null +++ b/osu.Game/Rulesets/Difficulty/Preprocessing/DifficultyHitObject.cs @@ -0,0 +1,41 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets.Objects; + +namespace osu.Game.Rulesets.Difficulty.Preprocessing +{ + /// + /// Wraps a and provides additional information to be used for difficulty calculation. + /// + public class DifficultyHitObject + { + /// + /// The this wraps. + /// + public readonly HitObject BaseObject; + + /// + /// The last which occurs before . + /// + public readonly HitObject LastObject; + + /// + /// Amount of time elapsed between and . + /// + public readonly double DeltaTime; + + /// + /// Creates a new . + /// + /// The which this wraps. + /// The last which occurs before in the beatmap. + /// The rate at which the gameplay clock is run at. + public DifficultyHitObject(HitObject hitObject, HitObject lastObject, double clockRate) + { + BaseObject = hitObject; + LastObject = lastObject; + DeltaTime = (hitObject.StartTime - lastObject.StartTime) / clockRate; + } + } +} diff --git a/osu.Game.Rulesets.Osu/Difficulty/Skills/Skill.cs b/osu.Game/Rulesets/Difficulty/Skills/Skill.cs similarity index 68% rename from osu.Game.Rulesets.Osu/Difficulty/Skills/Skill.cs rename to osu.Game/Rulesets/Difficulty/Skills/Skill.cs index 2f23552eb9..e8020ed185 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Skills/Skill.cs +++ b/osu.Game/Rulesets/Difficulty/Skills/Skill.cs @@ -3,20 +3,21 @@ using System; using System.Collections.Generic; -using osu.Game.Rulesets.Osu.Difficulty.Preprocessing; -using osu.Game.Rulesets.Osu.Difficulty.Utils; -using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Rulesets.Difficulty.Preprocessing; +using osu.Game.Rulesets.Difficulty.Utils; -namespace osu.Game.Rulesets.Osu.Difficulty.Skills +namespace osu.Game.Rulesets.Difficulty.Skills { /// - /// Used to processes strain values of s, keep track of strain levels caused by the processed objects + /// Used to processes strain values of s, keep track of strain levels caused by the processed objects /// and to calculate a final difficulty value representing the difficulty of hitting all the processed objects. /// public abstract class Skill { - protected const double SINGLE_SPACING_THRESHOLD = 125; - protected const double STREAM_SPACING_THRESHOLD = 110; + /// + /// The peak strain for each section of the beatmap. + /// + public IList StrainPeaks => strainPeaks; /// /// Strain values are multiplied by this number for the given skill. Used to balance the value of different skills between each other. @@ -30,22 +31,27 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills protected abstract double StrainDecayBase { get; } /// - /// s that were processed previously. They can affect the strain values of the following objects. + /// The weight by which each strain value decays. /// - protected readonly History Previous = new History(2); // Contained objects not used yet + protected virtual double DecayWeight => 0.9; + + /// + /// s that were processed previously. They can affect the strain values of the following objects. + /// + protected readonly LimitedCapacityStack Previous = new LimitedCapacityStack(2); // Contained objects not used yet private double currentStrain = 1; // We keep track of the strain level at all times throughout the beatmap. private double currentSectionPeak = 1; // We also keep track of the peak strain level in the current section. + private readonly List strainPeaks = new List(); /// - /// Process an and update current strain values accordingly. + /// Process a and update current strain values accordingly. /// - public void Process(OsuDifficultyHitObject current) + public void Process(DifficultyHitObject current) { currentStrain *= strainDecay(current.DeltaTime); - if (!(current.BaseObject is Spinner)) - currentStrain += StrainValueOf(current) * SkillMultiplier; + currentStrain += StrainValueOf(current) * SkillMultiplier; currentSectionPeak = Math.Max(currentStrain, currentSectionPeak); @@ -64,7 +70,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills /// /// Sets the initial strain level for a new section. /// - /// The beginning of the new section in milliseconds + /// The beginning of the new section in milliseconds. public void StartNewSectionFrom(double offset) { // The maximum strain of the new section is not zero by default, strain decays as usual regardless of section boundaries. @@ -74,7 +80,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills } /// - /// Returns the calculated difficulty value representing all processed s. + /// Returns the calculated difficulty value representing all processed s. /// public double DifficultyValue() { @@ -87,16 +93,16 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills foreach (double strain in strainPeaks) { difficulty += strain * weight; - weight *= 0.9; + weight *= DecayWeight; } return difficulty; } /// - /// Calculates the strain value of an . This value is affected by previously processed objects. + /// Calculates the strain value of a . This value is affected by previously processed objects. /// - protected abstract double StrainValueOf(OsuDifficultyHitObject current); + protected abstract double StrainValueOf(DifficultyHitObject current); private double strainDecay(double ms) => Math.Pow(StrainDecayBase, ms / 1000); } diff --git a/osu.Game.Rulesets.Osu/Difficulty/Utils/History.cs b/osu.Game/Rulesets/Difficulty/Utils/LimitedCapacityStack.cs similarity index 68% rename from osu.Game.Rulesets.Osu/Difficulty/Utils/History.cs rename to osu.Game/Rulesets/Difficulty/Utils/LimitedCapacityStack.cs index e39351087e..95b7d9b19d 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Utils/History.cs +++ b/osu.Game/Rulesets/Difficulty/Utils/LimitedCapacityStack.cs @@ -5,14 +5,16 @@ using System; using System.Collections; using System.Collections.Generic; -namespace osu.Game.Rulesets.Osu.Difficulty.Utils +namespace osu.Game.Rulesets.Difficulty.Utils { /// - /// An indexed stack with Push() only, which disposes items at the bottom after the capacity is full. - /// Indexing starts at the top of the stack. + /// An indexed stack with limited depth. Indexing starts at the top of the stack. /// - public class History : IEnumerable + public class LimitedCapacityStack : IEnumerable { + /// + /// The number of elements in the stack. + /// public int Count { get; private set; } private readonly T[] array; @@ -20,10 +22,10 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Utils private int marker; // Marks the position of the most recently added item. /// - /// Initializes a new instance of the History class that is empty and has the specified capacity. + /// Constructs a new . /// - /// The number of items the History can hold. - public History(int capacity) + /// The number of items the stack can hold. + public LimitedCapacityStack(int capacity) { if (capacity < 0) throw new ArgumentOutOfRangeException(); @@ -34,8 +36,9 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Utils } /// - /// The most recently added item is returned at index 0. + /// Retrieves the item at an index in the stack. /// + /// The index of the item to retrieve. The top of the stack is returned at index 0. public T this[int i] { get @@ -52,11 +55,12 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Utils } /// - /// Adds the item as the most recent one in the history. - /// The oldest item is disposed if the history is full. + /// Pushes an item to this . /// - public void Push(T item) // Overwrite the oldest item instead of shifting every item by one with every addition. + /// The item to push. + public void Push(T item) { + // Overwrite the oldest item instead of shifting every item by one with every addition. if (marker == 0) marker = capacity - 1; else diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 635e32d489..025564e249 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input; @@ -111,8 +111,8 @@ namespace osu.Game.Rulesets.Edit toolboxCollection.Items = CompositionTools.Select(t => new RadioButton(t.Name, () => blueprintContainer.CurrentTool = t)) - .Prepend(new RadioButton("Select", () => blueprintContainer.CurrentTool = null)) - .ToList(); + .Prepend(new RadioButton("Select", () => blueprintContainer.CurrentTool = null)) + .ToList(); toolboxCollection.Items[0].Select(); } diff --git a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs index 3ab62160cd..74aa9ace2d 100644 --- a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs +++ b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs @@ -4,7 +4,7 @@ using System; using osu.Framework; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; @@ -75,6 +75,7 @@ namespace osu.Game.Rulesets.Edit { if (state == value) return; + state = value; if (state == PlacementState.Shown) diff --git a/osu.Game/Rulesets/Judgements/DrawableJudgement.cs b/osu.Game/Rulesets/Judgements/DrawableJudgement.cs index ced24b3308..0d6e11c649 100644 --- a/osu.Game/Rulesets/Judgements/DrawableJudgement.cs +++ b/osu.Game/Rulesets/Judgements/DrawableJudgement.cs @@ -58,10 +58,9 @@ namespace osu.Game.Rulesets.Judgements Child = new SkinnableDrawable($"Play/{Result.Type}", _ => JudgementText = new OsuSpriteText { Text = Result.Type.GetDescription().ToUpperInvariant(), - Font = @"Venera", + Font = OsuFont.Numeric.With(size: 12), Colour = judgementColour(Result.Type), Scale = new Vector2(0.85f, 1), - TextSize = 12 }, restrictSize: false) }; } diff --git a/osu.Game/Rulesets/Judgements/Judgement.cs b/osu.Game/Rulesets/Judgements/Judgement.cs index 7b5e70383c..e14eedd3dc 100644 --- a/osu.Game/Rulesets/Judgements/Judgement.cs +++ b/osu.Game/Rulesets/Judgements/Judgement.cs @@ -58,5 +58,7 @@ namespace osu.Game.Rulesets.Judgements /// The to find the numeric health increase for. /// The numeric health increase of . public double HealthIncreaseFor(JudgementResult result) => HealthIncreaseFor(result.Type); + + public override string ToString() => $"AffectsCombo:{AffectsCombo} MaxResult:{MaxResult} MaxScore:{MaxNumericResult}"; } } diff --git a/osu.Game/Rulesets/Judgements/JudgementResult.cs b/osu.Game/Rulesets/Judgements/JudgementResult.cs index b1950f330e..d4ef5750b1 100644 --- a/osu.Game/Rulesets/Judgements/JudgementResult.cs +++ b/osu.Game/Rulesets/Judgements/JudgementResult.cs @@ -55,5 +55,7 @@ namespace osu.Game.Rulesets.Judgements { Judgement = judgement; } + + public override string ToString() => $"{Type} (Score:{Judgement.NumericResultFor(this)} HP:{Judgement.HealthIncreaseFor(this)} {Judgement})"; } } diff --git a/osu.Game/Rulesets/Mods/ModDaycore.cs b/osu.Game/Rulesets/Mods/ModDaycore.cs index 74216653c7..2eea6a237c 100644 --- a/osu.Game/Rulesets/Mods/ModDaycore.cs +++ b/osu.Game/Rulesets/Mods/ModDaycore.cs @@ -16,8 +16,7 @@ namespace osu.Game.Rulesets.Mods public override void ApplyToClock(IAdjustableClock clock) { - var pitchAdjust = clock as IHasPitchAdjust; - if (pitchAdjust != null) + if (clock is IHasPitchAdjust pitchAdjust) pitchAdjust.PitchAdjust = 0.75; else base.ApplyToClock(clock); diff --git a/osu.Game/Rulesets/Mods/ModFlashlight.cs b/osu.Game/Rulesets/Mods/ModFlashlight.cs index 74acf80b7b..dfada5614a 100644 --- a/osu.Game/Rulesets/Mods/ModFlashlight.cs +++ b/osu.Game/Rulesets/Mods/ModFlashlight.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.OpenGL.Vertices; using osu.Framework.Graphics.Primitives; @@ -104,11 +104,12 @@ namespace osu.Game.Rulesets.Mods } } - protected abstract void OnComboChange(int newCombo); + protected abstract void OnComboChange(ValueChangedEvent e); protected abstract string FragmentShader { get; } private Vector2 flashlightPosition; + protected Vector2 FlashlightPosition { get => flashlightPosition; @@ -122,6 +123,7 @@ namespace osu.Game.Rulesets.Mods } private Vector2 flashlightSize; + protected Vector2 FlashlightSize { get => flashlightSize; diff --git a/osu.Game/Rulesets/Mods/ModHidden.cs b/osu.Game/Rulesets/Mods/ModHidden.cs index 465ead450c..e526125947 100644 --- a/osu.Game/Rulesets/Mods/ModHidden.cs +++ b/osu.Game/Rulesets/Mods/ModHidden.cs @@ -1,12 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Rulesets.Objects.Drawables; using System.Collections.Generic; using System.Linq; +using osu.Framework.Bindables; namespace osu.Game.Rulesets.Mods { @@ -27,10 +27,12 @@ namespace osu.Game.Rulesets.Mods public virtual void ApplyToDrawableHitObjects(IEnumerable drawables) { - foreach (var d in drawables.Skip(IncreaseFirstObjectVisibility ? 1 : 0)) + foreach (var d in drawables.Skip(IncreaseFirstObjectVisibility.Value ? 1 : 0)) d.ApplyCustomUpdateState += ApplyHiddenState; } - protected virtual void ApplyHiddenState(DrawableHitObject hitObject, ArmedState state) { } + protected virtual void ApplyHiddenState(DrawableHitObject hitObject, ArmedState state) + { + } } } diff --git a/osu.Game/Rulesets/Mods/ModNightcore.cs b/osu.Game/Rulesets/Mods/ModNightcore.cs index 4dd8972dd6..e6bd532f72 100644 --- a/osu.Game/Rulesets/Mods/ModNightcore.cs +++ b/osu.Game/Rulesets/Mods/ModNightcore.cs @@ -16,8 +16,7 @@ namespace osu.Game.Rulesets.Mods public override void ApplyToClock(IAdjustableClock clock) { - var pitchAdjust = clock as IHasPitchAdjust; - if (pitchAdjust != null) + if (clock is IHasPitchAdjust pitchAdjust) pitchAdjust.PitchAdjust = 1.5; else base.ApplyToClock(clock); diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 06fe22a95e..e1e76f109d 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.TypeExtensions; using osu.Framework.Graphics.Primitives; using osu.Game.Audio; @@ -124,14 +124,14 @@ namespace osu.Game.Rulesets.Objects.Drawables { base.LoadComplete(); - State.ValueChanged += state => + State.ValueChanged += armed => { - UpdateState(state); + UpdateState(armed.NewValue); // apply any custom state overrides - ApplyCustomUpdateState?.Invoke(this, state); + ApplyCustomUpdateState?.Invoke(this, armed.NewValue); - if (State == ArmedState.Hit) + if (armed.NewValue == ArmedState.Hit) PlaySamples(); }; @@ -220,6 +220,16 @@ namespace osu.Game.Rulesets.Objects.Drawables OnNewResult?.Invoke(this, Result); } + /// + /// Will called at least once after the of this has been passed. + /// + internal void OnLifetimeEnd() + { + foreach (var nested in NestedHitObjects) + nested.OnLifetimeEnd(); + UpdateResult(false); + } + /// /// Processes this , checking if a scoring result has occurred. /// diff --git a/osu.Game/Rulesets/Objects/Drawables/IScrollingHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/IScrollingHitObject.cs index c3f0279013..48fcfabc2f 100644 --- a/osu.Game/Rulesets/Objects/Drawables/IScrollingHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/IScrollingHitObject.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; namespace osu.Game.Rulesets.Objects.Drawables diff --git a/osu.Game/Rulesets/Objects/HitWindows.cs b/osu.Game/Rulesets/Objects/HitWindows.cs index 6c97f6b6da..c5b7686da6 100644 --- a/osu.Game/Rulesets/Objects/HitWindows.cs +++ b/osu.Game/Rulesets/Objects/HitWindows.cs @@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Objects private static readonly IReadOnlyDictionary base_ranges = new Dictionary { { HitResult.Perfect, (44.8, 38.8, 27.8) }, - { HitResult.Great, (128, 98, 68 ) }, + { HitResult.Great, (128, 98, 68) }, { HitResult.Good, (194, 164, 134) }, { HitResult.Ok, (254, 224, 194) }, { HitResult.Meh, (302, 272, 242) }, diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectType.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectType.cs index 6917d009f4..c9f7224643 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectType.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectType.cs @@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Objects.Legacy Slider = 1 << 1, NewCombo = 1 << 2, Spinner = 1 << 3, - ComboOffset = 1 << 4 | 1 << 5 | 1 << 6, + ComboOffset = (1 << 4) | (1 << 5) | (1 << 6), Hold = 1 << 7 } } diff --git a/osu.Game/Rulesets/Objects/SliderPath.cs b/osu.Game/Rulesets/Objects/SliderPath.cs index 8cadb38190..1e9767a54f 100644 --- a/osu.Game/Rulesets/Objects/SliderPath.cs +++ b/osu.Game/Rulesets/Objects/SliderPath.cs @@ -125,6 +125,7 @@ namespace osu.Game.Rulesets.Objects { if (isInitialised) return; + isInitialised = true; controlPoints = controlPoints ?? Array.Empty(); @@ -280,6 +281,7 @@ namespace osu.Game.Rulesets.Objects public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; + return obj is SliderPath other && Equals(other); } } diff --git a/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs b/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs index ed4be4b815..c89ac59e10 100644 --- a/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs +++ b/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs @@ -99,6 +99,7 @@ namespace osu.Game.Rulesets.Replays // that would occur as a result of this frame in forward playback if (currentDirection == -1) return CurrentTime = CurrentFrame.Time - 1; + return CurrentTime = CurrentFrame.Time; } } diff --git a/osu.Game/Rulesets/RulesetStore.cs b/osu.Game/Rulesets/RulesetStore.cs index 5283c5c3cf..0ebadd73d2 100644 --- a/osu.Game/Rulesets/RulesetStore.cs +++ b/osu.Game/Rulesets/RulesetStore.cs @@ -22,7 +22,8 @@ namespace osu.Game.Rulesets { AppDomain.CurrentDomain.AssemblyResolve += currentDomain_AssemblyResolve; - foreach (string file in Directory.GetFiles(Environment.CurrentDirectory, $"{ruleset_library_prefix}.*.dll")) + foreach (string file in Directory.GetFiles(Environment.CurrentDirectory, $"{ruleset_library_prefix}.*.dll") + .Where(f => !Path.GetFileName(f).Contains("Tests"))) loadRulesetFromFile(file); } @@ -124,7 +125,7 @@ namespace osu.Game.Rulesets } catch (Exception e) { - Logger.Error(e, "Failed to load ruleset"); + Logger.Error(e, $"Failed to load ruleset {filename}"); } } } diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index 45f2cbd7c8..63e1c93dd5 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions; using osu.Framework.Extensions.TypeExtensions; using osu.Game.Beatmaps; @@ -113,6 +113,7 @@ namespace osu.Game.Rulesets.Scoring return ScoreRank.B; if (acc > 0.7) return ScoreRank.C; + return ScoreRank.D; } @@ -168,11 +169,11 @@ namespace osu.Game.Rulesets.Scoring /// public virtual void PopulateScore(ScoreInfo score) { - score.TotalScore = (int)Math.Round(TotalScore); - score.Combo = Combo; - score.MaxCombo = HighestCombo; - score.Accuracy = Math.Round(Accuracy, 4); - score.Rank = Rank; + score.TotalScore = (long)Math.Round(TotalScore.Value); + score.Combo = Combo.Value; + score.MaxCombo = HighestCombo.Value; + score.Accuracy = Math.Round(Accuracy.Value, 4); + score.Rank = Rank.Value; score.Date = DateTimeOffset.Now; var hitWindows = CreateHitWindows(); @@ -298,8 +299,8 @@ namespace osu.Game.Rulesets.Scoring /// The to apply. protected virtual void ApplyResult(JudgementResult result) { - result.ComboAtJudgement = Combo; - result.HighestComboAtJudgement = HighestCombo; + result.ComboAtJudgement = Combo.Value; + result.HighestComboAtJudgement = HighestCombo.Value; JudgedHits++; @@ -371,10 +372,10 @@ namespace osu.Game.Rulesets.Scoring { default: case ScoringMode.Standardised: - return max_score * (base_portion * baseScore / maxBaseScore + combo_portion * HighestCombo / maxHighestCombo) + bonusScore; + return max_score * (base_portion * baseScore / maxBaseScore + combo_portion * HighestCombo.Value / maxHighestCombo) + bonusScore; case ScoringMode.Classic: // should emulate osu-stable's scoring as closely as we can (https://osu.ppy.sh/help/wiki/Score/ScoreV1) - return bonusScore + baseScore * (1 + Math.Max(0, HighestCombo - 1) / 25); + return bonusScore + baseScore * (1 + Math.Max(0, HighestCombo.Value - 1) / 25); } } @@ -389,7 +390,7 @@ namespace osu.Game.Rulesets.Scoring if (storeResults) { MaxHits = JudgedHits; - maxHighestCombo = HighestCombo; + maxHighestCombo = HighestCombo.Value; maxBaseScore = baseScore; } diff --git a/osu.Game/Rulesets/UI/HitObjectContainer.cs b/osu.Game/Rulesets/UI/HitObjectContainer.cs index 4d5dbf09d1..2f3a384e95 100644 --- a/osu.Game/Rulesets/UI/HitObjectContainer.cs +++ b/osu.Game/Rulesets/UI/HitObjectContainer.cs @@ -9,7 +9,7 @@ using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.UI { - public class HitObjectContainer : CompositeDrawable + public class HitObjectContainer : LifetimeManagementContainer { public IEnumerable Objects => InternalChildren.Cast().OrderBy(h => h.HitObject.StartTime); public IEnumerable AliveObjects => AliveInternalChildren.Cast().OrderBy(h => h.HitObject.StartTime); @@ -31,5 +31,11 @@ namespace osu.Game.Rulesets.UI int i = yObj.HitObject.StartTime.CompareTo(xObj.HitObject.StartTime); return i == 0 ? CompareReverseChildID(x, y) : i; } + + protected override void OnChildLifetimeBoundaryCrossed(LifetimeBoundaryCrossedEvent e) + { + if (e.Kind == LifetimeBoundaryKind.End && e.Direction == LifetimeBoundaryCrossingDirection.Forward && e.Child is DrawableHitObject hitObject) + hitObject.OnLifetimeEnd(); + } } } diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 12b9134f92..9f80dea9f7 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -22,8 +22,8 @@ namespace osu.Game.Rulesets.UI public FontAwesome Icon { - get { return modIcon.Icon; } - set { modIcon.Icon = value; } + get => modIcon.Icon; + set => modIcon.Icon = value; } private readonly ModType type; @@ -100,7 +100,7 @@ namespace osu.Game.Rulesets.UI public bool Highlighted { - get { return highlighted; } + get => highlighted; set { diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index 572f41b7e6..3b8a7353c6 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -7,8 +7,8 @@ using System.Linq; using osu.Framework.Graphics; using osu.Game.Rulesets.Objects.Drawables; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Extensions.IEnumerableExtensions; -using osu.Framework.Configuration; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Rulesets.Mods; diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 0d020238aa..1c29cf4e2b 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -13,7 +13,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics.Cursor; using osu.Framework.Input; using osu.Game.Configuration; @@ -96,10 +96,10 @@ namespace osu.Game.Rulesets.UI IsPaused.ValueChanged += paused => { - if (HasReplayLoaded) + if (HasReplayLoaded.Value) return; - KeyBindingInputManager.UseParentInput = !paused; + KeyBindingInputManager.UseParentInput = !paused.NewValue; }; Cursor = CreateCursor(); diff --git a/osu.Game/Rulesets/UI/RulesetInputManager.cs b/osu.Game/Rulesets/UI/RulesetInputManager.cs index 274a9475db..fc61d41ab4 100644 --- a/osu.Game/Rulesets/UI/RulesetInputManager.cs +++ b/osu.Game/Rulesets/UI/RulesetInputManager.cs @@ -1,9 +1,10 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input; @@ -121,6 +122,8 @@ namespace osu.Game.Rulesets.UI private const int max_catch_up_updates_per_frame = 50; + private const double sixty_frame_time = 1000.0 / 60; + public override bool UpdateSubTree() { requireMoreUpdateLoops = true; @@ -130,59 +133,64 @@ namespace osu.Game.Rulesets.UI while (validState && requireMoreUpdateLoops && loops++ < max_catch_up_updates_per_frame) { - if (!base.UpdateSubTree()) - return false; + updateClock(); - UpdateSubTreeMasking(this, ScreenSpaceDrawQuad.AABBFloat); - - if (isAttached) + if (validState) { - // When handling replay input, we need to consider the possibility of fast-forwarding, which may cause the clock to be updated - // to a point very far into the future, then playing a frame at that time. In such a case, lifetime MUST be updated before - // input is handled. This is why base.Update is not called from the derived Update when handling replay input, and is instead - // called manually at the correct time here. - base.Update(); + base.UpdateSubTree(); + UpdateSubTreeMasking(this, ScreenSpaceDrawQuad.AABBFloat); } } return true; } - protected override void Update() + private void updateClock() { if (parentClock == null) return; clock.Rate = parentClock.Rate; clock.IsRunning = parentClock.IsRunning; - if (!isAttached) - { - clock.CurrentTime = parentClock.CurrentTime; - } - else - { - double? newTime = replayInputHandler.SetFrameFromTime(parentClock.CurrentTime); + var newProposedTime = parentClock.CurrentTime; - if (newTime == null) + try + { + if (Math.Abs(clock.CurrentTime - newProposedTime) > sixty_frame_time * 1.2f) { - // we shouldn't execute for this time value. probably waiting on more replay data. - validState = false; - return; + newProposedTime = clock.Rate > 0 + ? Math.Min(newProposedTime, clock.CurrentTime + sixty_frame_time) + : Math.Max(newProposedTime, clock.CurrentTime - sixty_frame_time); } - clock.CurrentTime = newTime.Value; + if (!isAttached) + { + clock.CurrentTime = newProposedTime; + } + else + { + double? newTime = replayInputHandler.SetFrameFromTime(newProposedTime); + + if (newTime == null) + { + // we shouldn't execute for this time value. probably waiting on more replay data. + validState = false; + + requireMoreUpdateLoops = true; + clock.CurrentTime = newProposedTime; + return; + } + + clock.CurrentTime = newTime.Value; + } + + requireMoreUpdateLoops = clock.CurrentTime != parentClock.CurrentTime; } - - requireMoreUpdateLoops = clock.CurrentTime != parentClock.CurrentTime; - - // The manual clock time has changed in the above code. The framed clock now needs to be updated - // to ensure that the its time is valid for our children before input is processed - Clock.ProcessFrame(); - - if (!isAttached) + finally { - // For non-replay input handling, this provides equivalent input ordering as if Update was not overridden - base.Update(); + // The manual clock time has changed in the above code. The framed clock now needs to be updated + // to ensure that the its time is valid for our children before input is processed + Clock.ProcessFrame(); } } @@ -205,12 +213,15 @@ namespace osu.Game.Rulesets.UI case MouseDownEvent mouseDown when mouseDown.Button == MouseButton.Left || mouseDown.Button == MouseButton.Right: if (mouseDisabled.Value) return false; + break; case MouseUpEvent mouseUp: if (!CurrentState.Mouse.IsPressed(mouseUp.Button)) return false; + break; } + return base.Handle(e); } diff --git a/osu.Game/Rulesets/UI/Scrolling/IScrollingInfo.cs b/osu.Game/Rulesets/UI/Scrolling/IScrollingInfo.cs index 49cdfea4d4..cd85932599 100644 --- a/osu.Game/Rulesets/UI/Scrolling/IScrollingInfo.cs +++ b/osu.Game/Rulesets/UI/Scrolling/IScrollingInfo.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.UI.Scrolling.Algorithms; diff --git a/osu.Game/Rulesets/UI/Scrolling/ScrollingDirection.cs b/osu.Game/Rulesets/UI/Scrolling/ScrollingDirection.cs index 1a307c29b8..81e1a6c916 100644 --- a/osu.Game/Rulesets/UI/Scrolling/ScrollingDirection.cs +++ b/osu.Game/Rulesets/UI/Scrolling/ScrollingDirection.cs @@ -9,14 +9,17 @@ namespace osu.Game.Rulesets.UI.Scrolling /// Hit objects will scroll vertically from the bottom of the hitobject container. /// Up, + /// /// Hit objects will scroll vertically from the top of the hitobject container. /// Down, + /// /// Hit objects will scroll horizontally from the right of the hitobject container. /// Left, + /// /// Hit objects will scroll horizontally from the left of the hitobject container. /// diff --git a/osu.Game/Rulesets/UI/Scrolling/ScrollingHitObjectContainer.cs b/osu.Game/Rulesets/UI/Scrolling/ScrollingHitObjectContainer.cs index e29bfbc452..ed3534fb36 100644 --- a/osu.Game/Rulesets/UI/Scrolling/ScrollingHitObjectContainer.cs +++ b/osu.Game/Rulesets/UI/Scrolling/ScrollingHitObjectContainer.cs @@ -2,8 +2,8 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Caching; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; diff --git a/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs b/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs index c08bb26dbc..bf2203e176 100644 --- a/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs +++ b/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.UI.Scrolling diff --git a/osu.Game/Rulesets/UI/Scrolling/ScrollingRulesetContainer.cs b/osu.Game/Rulesets/UI/Scrolling/ScrollingRulesetContainer.cs index 26298588a9..7a60e0b021 100644 --- a/osu.Game/Rulesets/UI/Scrolling/ScrollingRulesetContainer.cs +++ b/osu.Game/Rulesets/UI/Scrolling/ScrollingRulesetContainer.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Input.Bindings; using osu.Framework.Lists; @@ -157,10 +157,10 @@ namespace osu.Game.Rulesets.UI.Scrolling switch (action) { case GlobalAction.IncreaseScrollSpeed: - this.TransformBindableTo(TimeRange, TimeRange - time_span_step, 200, Easing.OutQuint); + this.TransformBindableTo(TimeRange, TimeRange.Value - time_span_step, 200, Easing.OutQuint); return true; case GlobalAction.DecreaseScrollSpeed: - this.TransformBindableTo(TimeRange, TimeRange + time_span_step, 200, Easing.OutQuint); + this.TransformBindableTo(TimeRange, TimeRange.Value + time_span_step, 200, Easing.OutQuint); return true; } diff --git a/osu.Game/Scoring/Legacy/LegacyScoreParser.cs b/osu.Game/Scoring/Legacy/LegacyScoreParser.cs index f89f8e80bf..ace8892330 100644 --- a/osu.Game/Scoring/Legacy/LegacyScoreParser.cs +++ b/osu.Game/Scoring/Legacy/LegacyScoreParser.cs @@ -111,12 +111,14 @@ namespace osu.Game.Scoring.Legacy byte[] properties = new byte[5]; if (replayInStream.Read(properties, 0, 5) != 5) throw new IOException("input .lzma is too short"); + long outSize = 0; for (int i = 0; i < 8; i++) { int v = replayInStream.ReadByte(); if (v < 0) throw new IOException("Can't Read 1"); + outSize |= (long)(byte)v << (8 * i); } @@ -264,6 +266,7 @@ namespace osu.Game.Scoring.Legacy var convertible = currentRuleset.CreateConvertibleReplayFrame(); if (convertible == null) throw new InvalidOperationException($"Legacy replay cannot be converted for the ruleset: {currentRuleset.Description}"); + convertible.ConvertFrom(legacyFrame, currentBeatmap); var frame = (ReplayFrame)convertible; diff --git a/osu.Game/Scoring/ScoreInfo.cs b/osu.Game/Scoring/ScoreInfo.cs index c88fd77eb2..6ae51796e8 100644 --- a/osu.Game/Scoring/ScoreInfo.cs +++ b/osu.Game/Scoring/ScoreInfo.cs @@ -25,10 +25,10 @@ namespace osu.Game.Scoring public ScoreRank Rank { get; set; } [JsonProperty("total_score")] - public int TotalScore { get; set; } + public long TotalScore { get; set; } [JsonProperty("accuracy")] - [Column(TypeName="DECIMAL(1,4)")] + [Column(TypeName = "DECIMAL(1,4)")] public double Accuracy { get; set; } [JsonProperty(@"pp")] @@ -109,7 +109,27 @@ namespace osu.Game.Scoring public string UserString { get => User?.Username; - set => User = new User { Username = value }; + set + { + if (User == null) + User = new User(); + + User.Username = value; + } + } + + [JsonIgnore] + [Column("UserID")] + public long? UserID + { + get => User?.Id ?? 1; + set + { + if (User == null) + User = new User(); + + User.Id = value ?? 1; + } } [JsonIgnore] diff --git a/osu.Game/Scoring/ScoreRank.cs b/osu.Game/Scoring/ScoreRank.cs index 05a0efe45c..82c33748bb 100644 --- a/osu.Game/Scoring/ScoreRank.cs +++ b/osu.Game/Scoring/ScoreRank.cs @@ -9,20 +9,28 @@ namespace osu.Game.Scoring { [Description(@"F")] F, + [Description(@"F")] D, + [Description(@"C")] C, + [Description(@"B")] B, + [Description(@"A")] A, + [Description(@"S")] S, + [Description(@"SPlus")] SH, + [Description(@"SS")] X, + [Description(@"SSPlus")] XH, } diff --git a/osu.Game/Scoring/ScoreStore.cs b/osu.Game/Scoring/ScoreStore.cs index 745bb6cc29..9627481f4d 100644 --- a/osu.Game/Scoring/ScoreStore.cs +++ b/osu.Game/Scoring/ScoreStore.cs @@ -8,7 +8,7 @@ using osu.Game.Database; namespace osu.Game.Scoring { - public class ScoreStore : MutableDatabaseBackedStore + public class ScoreStore : MutableDatabaseBackedStoreWithFileIncludes { public ScoreStore(IDatabaseContextFactory factory, Storage storage) : base(factory, storage) @@ -17,7 +17,6 @@ namespace osu.Game.Scoring protected override IQueryable AddIncludesForConsumption(IQueryable query) => base.AddIncludesForConsumption(query) - .Include(s => s.Files).ThenInclude(f => f.FileInfo) .Include(s => s.Beatmap) .Include(s => s.Ruleset); } diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 8706cc6668..13d1ff39ef 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -2,10 +2,12 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; using osu.Game.Beatmaps; using osu.Game.Graphics.Backgrounds; +using osu.Game.Graphics.Containers; namespace osu.Game.Screens.Backgrounds { @@ -13,9 +15,20 @@ namespace osu.Game.Screens.Backgrounds { private WorkingBeatmap beatmap; - public WorkingBeatmap Beatmap + /// + /// Whether or not user dim settings should be applied to this Background. + /// + public readonly Bindable EnableUserDim = new Bindable(); + + public readonly Bindable StoryboardReplacesBackground = new Bindable(); + + private readonly UserDimContainer fadeContainer; + + protected virtual UserDimContainer CreateFadeContainer() => new UserDimContainer { RelativeSizeAxes = Axes.Both }; + + public virtual WorkingBeatmap Beatmap { - get { return beatmap; } + get => beatmap; set { if (beatmap == value && beatmap != null) @@ -37,8 +50,9 @@ namespace osu.Game.Screens.Backgrounds } b.Depth = newDepth; - AddInternal(Background = b); + fadeContainer.Add(Background = b); Background.BlurSigma = BlurTarget; + StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground); })); }); } @@ -47,6 +61,8 @@ namespace osu.Game.Screens.Backgrounds public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null) { Beatmap = beatmap; + InternalChild = fadeContainer = CreateFadeContainer(); + fadeContainer.EnableUserDim.BindTo(EnableUserDim); } public override bool Equals(BackgroundScreen other) @@ -57,7 +73,7 @@ namespace osu.Game.Screens.Backgrounds return base.Equals(other) && beatmap == otherBeatmapBackground.Beatmap; } - private class BeatmapBackground : Background + protected class BeatmapBackground : Background { private readonly WorkingBeatmap beatmap; diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index 072da7c66e..87a6b5d591 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.MathUtils; using osu.Framework.Threading; @@ -70,7 +70,8 @@ namespace osu.Game.Screens.Backgrounds { private readonly Skin skin; - public SkinnedBackground(Skin skin, string fallbackTextureName) : base(fallbackTextureName) + public SkinnedBackground(Skin skin, string fallbackTextureName) + : base(fallbackTextureName) { this.skin = skin; } diff --git a/osu.Game/Screens/BlurrableBackgroundScreen.cs b/osu.Game/Screens/BlurrableBackgroundScreen.cs index cbd33136f1..d19e699acb 100644 --- a/osu.Game/Screens/BlurrableBackgroundScreen.cs +++ b/osu.Game/Screens/BlurrableBackgroundScreen.cs @@ -15,6 +15,9 @@ namespace osu.Game.Screens protected Vector2 BlurTarget; public TransformSequence BlurTo(Vector2 sigma, double duration, Easing easing = Easing.None) - => Background?.BlurTo(BlurTarget = sigma, duration, easing); + { + BlurTarget = sigma; + return Background?.BlurTo(BlurTarget, duration, easing); + } } } diff --git a/osu.Game/Screens/Charts/ChartListing.cs b/osu.Game/Screens/Charts/ChartListing.cs index ea60dc4365..18bba6433f 100644 --- a/osu.Game/Screens/Charts/ChartListing.cs +++ b/osu.Game/Screens/Charts/ChartListing.cs @@ -8,8 +8,9 @@ namespace osu.Game.Screens.Charts { public class ChartListing : ScreenWhiteBox { - protected override IEnumerable PossibleChildren => new[] { - typeof(ChartInfo) + protected override IEnumerable PossibleChildren => new[] + { + typeof(ChartInfo) }; } } diff --git a/osu.Game/Screens/Edit/BindableBeatDivisor.cs b/osu.Game/Screens/Edit/BindableBeatDivisor.cs index 59fe45b9ec..ea3b68e3bd 100644 --- a/osu.Game/Screens/Edit/BindableBeatDivisor.cs +++ b/osu.Game/Screens/Edit/BindableBeatDivisor.cs @@ -3,7 +3,7 @@ using System; using System.Linq; -using osu.Framework.Configuration; +using osu.Framework.Bindables; namespace osu.Game.Screens.Edit { @@ -22,7 +22,7 @@ namespace osu.Game.Screens.Edit public override int Value { - get { return base.Value; } + get => base.Value; set { if (!VALID_DIVISORS.Contains(value)) diff --git a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs index 726f6d2025..cb5078a479 100644 --- a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs +++ b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs @@ -3,7 +3,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio.Track; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; diff --git a/osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs b/osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs index 527900acf2..752615245e 100644 --- a/osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs +++ b/osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -110,7 +110,8 @@ namespace osu.Game.Screens.Edit.Components.Menus { public TextContainer() { - NormalText.TextSize = BoldText.TextSize = 14; + NormalText.Font = NormalText.Font.With(size: 14); + BoldText.Font = BoldText.Font.With(size: 14); NormalText.Margin = BoldText.Margin = new MarginPadding { Horizontal = 10, Vertical = MARGIN_VERTICAL }; } } @@ -174,6 +175,7 @@ namespace osu.Game.Screens.Edit.Components.Menus { if (Item is EditorMenuItemSpacer) return true; + return base.OnHover(e); } @@ -181,6 +183,7 @@ namespace osu.Game.Screens.Edit.Components.Menus { if (Item is EditorMenuItemSpacer) return true; + return base.OnClick(e); } } diff --git a/osu.Game/Screens/Edit/Components/PlaybackControl.cs b/osu.Game/Screens/Edit/Components/PlaybackControl.cs index 5d611d3bca..227ad29000 100644 --- a/osu.Game/Screens/Edit/Components/PlaybackControl.cs +++ b/osu.Game/Screens/Edit/Components/PlaybackControl.cs @@ -61,7 +61,7 @@ namespace osu.Game.Screens.Edit.Components } }; - tabs.Current.ValueChanged += newValue => Beatmap.Value.Track.Tempo.Value = newValue; + tabs.Current.ValueChanged += tempo => Beatmap.Value.Track.Tempo.Value = tempo.NewValue; } protected override bool OnKeyDown(KeyDownEvent e) @@ -114,7 +114,8 @@ namespace osu.Game.Screens.Edit.Components private readonly OsuSpriteText text; private readonly OsuSpriteText textBold; - public PlaybackTabItem(double value) : base(value) + public PlaybackTabItem(double value) + : base(value) { RelativeSizeAxes = Axes.Both; @@ -127,15 +128,14 @@ namespace osu.Game.Screens.Edit.Components Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, Text = $"{value:0%}", - TextSize = 14, + Font = OsuFont.GetFont(size: 14) }, textBold = new OsuSpriteText { Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, Text = $"{value:0%}", - TextSize = 14, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), Alpha = 0, }, }; @@ -163,9 +163,9 @@ namespace osu.Game.Screens.Edit.Components private void updateState() { - text.FadeColour(Active || IsHovered ? hoveredColour : normalColour, fade_duration, Easing.OutQuint); - text.FadeTo(Active ? 0 : 1, fade_duration, Easing.OutQuint); - textBold.FadeTo(Active ? 1 : 0, fade_duration, Easing.OutQuint); + text.FadeColour(Active.Value || IsHovered ? hoveredColour : normalColour, fade_duration, Easing.OutQuint); + text.FadeTo(Active.Value ? 0 : 1, fade_duration, Easing.OutQuint); + textBold.FadeTo(Active.Value ? 1 : 0, fade_duration, Easing.OutQuint); } } } diff --git a/osu.Game/Screens/Edit/Components/RadioButtons/DrawableRadioButton.cs b/osu.Game/Screens/Edit/Components/RadioButtons/DrawableRadioButton.cs index 5d46f83ad3..1ad69afe91 100644 --- a/osu.Game/Screens/Edit/Components/RadioButtons/DrawableRadioButton.cs +++ b/osu.Game/Screens/Edit/Components/RadioButtons/DrawableRadioButton.cs @@ -80,10 +80,10 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons { base.LoadComplete(); - button.Selected.ValueChanged += v => + button.Selected.ValueChanged += selected => { updateSelectionState(); - if (v) + if (selected.NewValue) Selected?.Invoke(button); }; @@ -95,16 +95,16 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons if (!IsLoaded) return; - BackgroundColour = button.Selected ? selectedBackgroundColour : defaultBackgroundColour; - bubble.Colour = button.Selected ? selectedBubbleColour : defaultBubbleColour; + BackgroundColour = button.Selected.Value ? selectedBackgroundColour : defaultBackgroundColour; + bubble.Colour = button.Selected.Value ? selectedBubbleColour : defaultBubbleColour; } protected override bool OnClick(ClickEvent e) { - if (button.Selected) + if (button.Selected.Value) return true; - if (!Enabled) + if (!Enabled.Value) return true; button.Selected.Value = true; diff --git a/osu.Game/Screens/Edit/Components/RadioButtons/RadioButton.cs b/osu.Game/Screens/Edit/Components/RadioButtons/RadioButton.cs index d35bb55449..3692c0437b 100644 --- a/osu.Game/Screens/Edit/Components/RadioButtons/RadioButton.cs +++ b/osu.Game/Screens/Edit/Components/RadioButtons/RadioButton.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; -using osu.Framework.Configuration; +using osu.Framework.Bindables; namespace osu.Game.Screens.Edit.Components.RadioButtons { diff --git a/osu.Game/Screens/Edit/Components/RadioButtons/RadioButtonCollection.cs b/osu.Game/Screens/Edit/Components/RadioButtons/RadioButtonCollection.cs index eb433b1c0a..16574c0baf 100644 --- a/osu.Game/Screens/Edit/Components/RadioButtons/RadioButtonCollection.cs +++ b/osu.Game/Screens/Edit/Components/RadioButtons/RadioButtonCollection.cs @@ -12,13 +12,15 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons public class RadioButtonCollection : CompositeDrawable { private IReadOnlyList items; + public IReadOnlyList Items { - get { return items; } + get => items; set { if (ReferenceEquals(items, value)) return; + items = value; buttonContainer.Clear(); @@ -42,11 +44,12 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons } private RadioButton currentlySelected; + private void addButton(RadioButton button) { - button.Selected.ValueChanged += v => + button.Selected.ValueChanged += selected => { - if (v) + if (selected.NewValue) { currentlySelected?.Deselect(); currentlySelected = button; diff --git a/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs b/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs index 3b58a3a1f7..0391074b11 100644 --- a/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs +++ b/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs @@ -6,6 +6,7 @@ using osu.Game.Graphics.Sprites; using System; using osu.Framework.Allocation; using osu.Framework.Timing; +using osu.Game.Graphics; namespace osu.Game.Screens.Edit.Components { @@ -23,8 +24,7 @@ namespace osu.Game.Screens.Edit.Components { Origin = Anchor.BottomLeft, RelativePositionAxes = Axes.Y, - TextSize = 22, - FixedWidth = true, + Font = OsuFont.GetFont(size: 22, fixedWidth: true), Y = 0.5f, } }; diff --git a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/ControlPointPart.cs b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/ControlPointPart.cs index 5bc70746bd..102955657e 100644 --- a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/ControlPointPart.cs +++ b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/ControlPointPart.cs @@ -26,12 +26,12 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts // Consider all non-timing points as the same type cpi.SamplePoints.Select(c => (ControlPoint)c) - .Concat(cpi.EffectPoints) - .Concat(cpi.DifficultyPoints) - .Distinct() - // Non-timing points should not be added where there are timing points - .Where(c => cpi.TimingPointAt(c.Time).Time != c.Time) - .ForEach(addNonTimingPoint); + .Concat(cpi.EffectPoints) + .Concat(cpi.DifficultyPoints) + .Distinct() + // Non-timing points should not be added where there are timing points + .Where(c => cpi.TimingPointAt(c.Time).Time != c.Time) + .ForEach(addNonTimingPoint); } private void addTimingPoint(ControlPoint controlPoint) => Add(new TimingPointVisualisation(controlPoint)); diff --git a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/MarkerPart.cs b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/MarkerPart.cs index 3ac34e227b..07d307f293 100644 --- a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/MarkerPart.cs +++ b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/MarkerPart.cs @@ -32,6 +32,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts protected override bool OnDragStart(DragStartEvent e) => true; protected override bool OnDragEnd(DragEndEvent e) => true; + protected override bool OnDrag(DragEvent e) { seekToPosition(e.ScreenSpaceMousePosition); diff --git a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs index edf7baf687..26d9614631 100644 --- a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs +++ b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs @@ -3,8 +3,8 @@ using System; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osuTK; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; @@ -27,7 +27,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts Beatmap.ValueChanged += b => { updateRelativeChildSize(); - LoadBeatmap(b); + LoadBeatmap(b.NewValue); }; } diff --git a/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs b/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs index f1bd70d4dd..3f7672ae08 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs @@ -4,7 +4,7 @@ using System; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -118,7 +118,7 @@ namespace osu.Game.Screens.Edit.Compose.Components }, new Drawable[] { - new TextFlowContainer(s => s.TextSize = 14) + new TextFlowContainer(s => s.Font = s.Font.With(size: 14)) { Padding = new MarginPadding { Horizontal = 15 }, Text = "beat snap divisor", @@ -157,12 +157,8 @@ namespace osu.Game.Screens.Edit.Compose.Components protected override void LoadComplete() { base.LoadComplete(); - - beatDivisor.ValueChanged += v => updateText(); - updateText(); + beatDivisor.BindValueChanged(val => Text = $"1/{val.NewValue}", true); } - - private void updateText() => Text = $"1/{beatDivisor.Value}"; } private class DivisorButton : IconButton @@ -219,9 +215,9 @@ namespace osu.Game.Screens.Edit.Compose.Components AddInternal(marker = new Marker()); - CurrentNumber.ValueChanged += v => + CurrentNumber.ValueChanged += div => { - marker.MoveToX(getMappedPosition(v), 100, Easing.OutQuint); + marker.MoveToX(getMappedPosition(div.NewValue), 100, Easing.OutQuint); marker.Flash(); }; } @@ -238,11 +234,11 @@ namespace osu.Game.Screens.Edit.Compose.Components { case Key.Right: beatDivisor.Next(); - OnUserChange(Current); + OnUserChange(Current.Value); return true; case Key.Left: beatDivisor.Previous(); - OnUserChange(Current); + OnUserChange(Current.Value); return true; default: return false; @@ -279,7 +275,7 @@ namespace osu.Game.Screens.Edit.Compose.Components var xPosition = (ToLocalSpace(screenSpaceMousePosition).X - RangePadding) / UsableWidth; CurrentNumber.Value = availableDivisors.OrderBy(d => Math.Abs(getMappedPosition(d) - xPosition)).First(); - OnUserChange(Current); + OnUserChange(Current.Value); } private float getMappedPosition(float divisor) => (float)Math.Pow((divisor - 1) / (availableDivisors.Last() - 1), 0.90f); diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs index e7a9d148bb..a1e62cd38b 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs @@ -68,6 +68,7 @@ namespace osu.Game.Screens.Edit.Compose.Components { if (currentTool == value) return; + currentTool = value; refreshTool(); @@ -188,6 +189,7 @@ namespace osu.Game.Screens.Edit.Compose.Components { if (!(x is SelectionBlueprint xBlueprint) || !(y is SelectionBlueprint yBlueprint)) return base.Compare(x, y); + return Compare(xBlueprint, yBlueprint); } diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs index b00d0b0b46..748c9e2ba3 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs @@ -3,7 +3,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio.Track; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Audio; @@ -49,13 +49,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline // We don't want the centre marker to scroll AddInternal(new CentreMarker()); - WaveformVisible.ValueChanged += visible => waveform.FadeTo(visible ? 1 : 0, 200, Easing.OutQuint); + WaveformVisible.ValueChanged += visible => waveform.FadeTo(visible.NewValue ? 1 : 0, 200, Easing.OutQuint); Beatmap.BindTo(beatmap); Beatmap.BindValueChanged(b => { - waveform.Waveform = b.Waveform; - track = b.Track; + waveform.Waveform = b.NewValue.Waveform; + track = b.NewValue.Track; }, true); } diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineButton.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineButton.cs index 1244e834c1..5ded97393b 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineButton.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineButton.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; @@ -19,8 +19,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline public FontAwesome Icon { - get { return button.Icon; } - set { button.Icon = value; } + get => button.Icon; + set => button.Icon = value; } private readonly IconButton button; diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs index 2060fe6694..1e94a20dc7 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs @@ -47,6 +47,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline { if (value < 1) throw new ArgumentException($"{nameof(MinZoom)} must be >= 1.", nameof(value)); + minZoom = value; if (Zoom < value) @@ -66,6 +67,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline { if (value < 1) throw new ArgumentException($"{nameof(MaxZoom)} must be >= 1.", nameof(value)); + maxZoom = value; if (Zoom > value) @@ -108,6 +110,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline } private float zoomTarget = 1; + private void setZoomTarget(float newZoom, float focusPoint) { zoomTarget = MathHelper.Clamp(newZoom, MinZoom, MaxZoom); diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index b147679cca..f2d2381d20 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Screens.Edit.Components.Timelines.Summary; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Events; using osu.Framework.Platform; @@ -21,6 +22,8 @@ using osu.Game.Screens.Edit.Components.Menus; using osu.Game.Screens.Edit.Compose; using osu.Game.Screens.Edit.Design; using osuTK.Input; +using System.Collections.Generic; +using osu.Framework; namespace osu.Game.Screens.Edit { @@ -66,6 +69,15 @@ namespace osu.Game.Screens.Edit SummaryTimeline timeline; PlaybackControl playback; + var fileMenuItems = new List(); + if (RuntimeInfo.IsDesktop) + { + fileMenuItems.Add(new EditorMenuItem("Export", MenuItemType.Standard, exportBeatmap)); + fileMenuItems.Add(new EditorMenuItemSpacer()); + } + + fileMenuItems.Add(new EditorMenuItem("Exit", MenuItemType.Standard, this.Exit)); + InternalChildren = new[] { new Container @@ -93,12 +105,7 @@ namespace osu.Game.Screens.Edit { new MenuItem("File") { - Items = new[] - { - new EditorMenuItem("Export", MenuItemType.Standard, exportBeatmap), - new EditorMenuItemSpacer(), - new EditorMenuItem("Exit", MenuItemType.Standard, this.Exit) - } + Items = fileMenuItems } } } @@ -222,11 +229,11 @@ namespace osu.Game.Screens.Edit private void exportBeatmap() => host.OpenFileExternally(Beatmap.Value.Save()); - private void onModeChanged(EditorScreenMode mode) + private void onModeChanged(ValueChangedEvent e) { currentScreen?.Exit(); - switch (mode) + switch (e.NewValue) { case EditorScreenMode.Compose: currentScreen = new ComposeScreen(); diff --git a/osu.Game/Screens/Edit/EditorClock.cs b/osu.Game/Screens/Edit/EditorClock.cs index 1660a1b703..8f65366650 100644 --- a/osu.Game/Screens/Edit/EditorClock.cs +++ b/osu.Game/Screens/Edit/EditorClock.cs @@ -46,7 +46,7 @@ namespace osu.Game.Screens.Edit public bool SeekSnapped(double position) { var timingPoint = ControlPointInfo.TimingPointAt(position); - double beatSnapLength = timingPoint.BeatLength / beatDivisor; + double beatSnapLength = timingPoint.BeatLength / beatDivisor.Value; // We will be snapping to beats within the timing point position -= timingPoint.Time; @@ -91,7 +91,7 @@ namespace osu.Game.Screens.Edit timingPoint = ControlPointInfo.TimingPoints[--activeIndex]; } - double seekAmount = timingPoint.BeatLength / beatDivisor * amount; + double seekAmount = timingPoint.BeatLength / beatDivisor.Value * amount; double seekTime = CurrentTime + seekAmount * direction; if (!snapped || ControlPointInfo.TimingPoints.Count == 0) diff --git a/osu.Game/Screens/Edit/EditorScreen.cs b/osu.Game/Screens/Edit/EditorScreen.cs index bfe0423c8a..045e5a1226 100644 --- a/osu.Game/Screens/Edit/EditorScreen.cs +++ b/osu.Game/Screens/Edit/EditorScreen.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; diff --git a/osu.Game/Screens/Edit/EditorScreenMode.cs b/osu.Game/Screens/Edit/EditorScreenMode.cs index 12fd67ebfd..12cfcc605b 100644 --- a/osu.Game/Screens/Edit/EditorScreenMode.cs +++ b/osu.Game/Screens/Edit/EditorScreenMode.cs @@ -9,10 +9,13 @@ namespace osu.Game.Screens.Edit { [Description("setup")] SongSetup, + [Description("compose")] Compose, + [Description("design")] Design, + [Description("timing")] Timing, } diff --git a/osu.Game/Screens/Edit/Setup/Components/LabelledComponents/LabelledTextBox.cs b/osu.Game/Screens/Edit/Setup/Components/LabelledComponents/LabelledTextBox.cs index 3340daa6b8..50d524d1f5 100644 --- a/osu.Game/Screens/Edit/Setup/Components/LabelledComponents/LabelledTextBox.cs +++ b/osu.Game/Screens/Edit/Setup/Components/LabelledComponents/LabelledTextBox.cs @@ -38,8 +38,8 @@ namespace osu.Game.Screens.Edit.Setup.Components.LabelledComponents public float LabelTextSize { - get => label.TextSize; - set => label.TextSize = value; + get => label.Font.Size; + set => label.Font = label.Font.With(size: value); } public string PlaceholderText @@ -103,8 +103,7 @@ namespace osu.Game.Screens.Edit.Setup.Components.LabelledComponents Origin = Anchor.TopLeft, Padding = new MarginPadding { Left = default_label_left_padding, Top = default_label_top_padding }, Colour = Color4.White, - TextSize = default_label_text_size, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(size: default_label_text_size, weight: FontWeight.Bold), }, textBox = new OsuTextBox { diff --git a/osu.Game/Screens/IOsuScreen.cs b/osu.Game/Screens/IOsuScreen.cs index 9e28de5593..e665f401d9 100644 --- a/osu.Game/Screens/IOsuScreen.cs +++ b/osu.Game/Screens/IOsuScreen.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Overlays; diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index f73d6ba560..a02c2a37fa 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -118,7 +118,6 @@ namespace osu.Game.Screens.Menu AllowMultiline = false, Anchor = Anchor.Centre, Origin = Anchor.Centre, - TextSize = 16, Position = new Vector2(0, 35), Text = text } @@ -243,7 +242,7 @@ namespace osu.Game.Screens.Menu public ButtonState State { - get { return state; } + get => state; set { diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 4a09bfe142..1f68818669 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -8,11 +8,12 @@ using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Bindings; using osu.Framework.Logging; +using osu.Framework.Platform; using osu.Framework.Threading; using osu.Game.Graphics; using osu.Game.Input; @@ -90,19 +91,6 @@ namespace osu.Game.Screens.Menu }); buttonArea.Flow.CentreTarget = iconFacade; - - buttonsPlay.Add(new Button(@"solo", @"button-solo-select", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P)); - buttonsPlay.Add(new Button(@"multi", @"button-generic-select", FontAwesome.fa_users, new Color4(94, 63, 186, 255), onMulti, 0, Key.M)); - buttonsPlay.Add(new Button(@"chart", @"button-generic-select", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke())); - buttonsPlay.ForEach(b => b.VisibleState = ButtonSystemState.Play); - - buttonsTopLevel.Add(new Button(@"play", @"button-play-select", FontAwesome.fa_osu_logo, new Color4(102, 68, 204, 255), () => State = ButtonSystemState.Play, WEDGE_WIDTH, Key.P)); - buttonsTopLevel.Add(new Button(@"osu!editor", @"button-generic-select", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E)); - buttonsTopLevel.Add(new Button(@"osu!direct", @"button-direct-select", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), () => OnDirect?.Invoke(), 0, Key.D)); - buttonsTopLevel.Add(new Button(@"exit", string.Empty, FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), () => OnExit?.Invoke(), 0, Key.Q)); - - buttonArea.AddRange(buttonsPlay); - buttonArea.AddRange(buttonsTopLevel); } [Resolved(CanBeNull = true)] @@ -115,9 +103,24 @@ namespace osu.Game.Screens.Menu private NotificationOverlay notifications { get; set; } [BackgroundDependencyLoader(true)] - private void load(AudioManager audio, IdleTracker idleTracker) + private void load(AudioManager audio, IdleTracker idleTracker, GameHost host) { - isIdle.ValueChanged += updateIdleState; + buttonsPlay.Add(new Button(@"solo", @"button-solo-select", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P)); + buttonsPlay.Add(new Button(@"multi", @"button-generic-select", FontAwesome.fa_users, new Color4(94, 63, 186, 255), onMulti, 0, Key.M)); + buttonsPlay.Add(new Button(@"chart", @"button-generic-select", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke())); + buttonsPlay.ForEach(b => b.VisibleState = ButtonSystemState.Play); + + buttonsTopLevel.Add(new Button(@"play", @"button-play-select", FontAwesome.fa_osu_logo, new Color4(102, 68, 204, 255), () => State = ButtonSystemState.Play, WEDGE_WIDTH, Key.P)); + buttonsTopLevel.Add(new Button(@"osu!editor", @"button-generic-select", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E)); + buttonsTopLevel.Add(new Button(@"osu!direct", @"button-direct-select", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), () => OnDirect?.Invoke(), 0, Key.D)); + + if (host.CanExit) + buttonsTopLevel.Add(new Button(@"exit", string.Empty, FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), () => OnExit?.Invoke(), 0, Key.Q)); + + buttonArea.AddRange(buttonsPlay); + buttonArea.AddRange(buttonsTopLevel); + + isIdle.ValueChanged += idle => updateIdleState(idle.NewValue); if (idleTracker != null) isIdle.BindTo(idleTracker.IsIdle); @@ -203,7 +206,7 @@ namespace osu.Game.Screens.Menu public ButtonSystemState State { - get { return state; } + get => state; set { diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index c0ff37cc0b..8c1cfdcda1 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -64,31 +64,19 @@ namespace osu.Game.Screens.Menu } }; - textFlow.AddText("This is an ", t => - { - t.TextSize = 30; - t.Font = @"Exo2.0-Light"; - }); - textFlow.AddText("early development build", t => - { - t.TextSize = 30; - t.Font = @"Exo2.0-SemiBold"; - }); + textFlow.AddText("This is an ", t => t.Font = t.Font.With(Typeface.Exo, 30, FontWeight.Light)); + textFlow.AddText("early development build", t => t.Font = t.Font.With(Typeface.Exo, 30, FontWeight.SemiBold)); - textFlow.AddParagraph("Things may not work as expected", t => t.TextSize = 20); + textFlow.AddParagraph("Things may not work as expected", t => t.Font = t.Font.With(size: 20)); textFlow.NewParagraph(); - Action format = t => - { - t.TextSize = 15; - t.Font = @"Exo2.0-SemiBold"; - }; + Action format = t => t.Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold); textFlow.AddParagraph("Detailed bug reports are welcomed via github issues.", format); textFlow.NewParagraph(); textFlow.AddText("Visit ", format); - textFlow.AddLink("discord.gg/ppy", "https://discord.gg/ppy", creationParameters:format); + textFlow.AddLink("discord.gg/ppy", "https://discord.gg/ppy", creationParameters: format); textFlow.AddText(" to help out or follow progress!", format); textFlow.NewParagraph(); @@ -102,7 +90,7 @@ namespace osu.Game.Screens.Menu supporterDrawables.Add(heart = textFlow.AddIcon(FontAwesome.fa_heart, t => { t.Padding = new MarginPadding { Left = 5 }; - t.TextSize = 12; + t.Font = t.Font.With(size: 12); t.Colour = colours.Pink; t.Origin = Anchor.Centre; }).First()); diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 10cfc4a299..2392d650a0 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -5,7 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Audio.Track; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Screens; using osu.Framework.Graphics; using osu.Framework.MathUtils; @@ -52,7 +52,7 @@ namespace osu.Game.Screens.Menu BeatmapSetInfo setInfo = null; - if (!menuMusic) + if (!menuMusic.Value) { var sets = beatmaps.GetAllUsableBeatmapSets(); if (sets.Count > 0) @@ -93,13 +93,13 @@ namespace osu.Game.Screens.Menu { Beatmap.Value = introBeatmap; - if (menuVoice) + if (menuVoice.Value) welcome.Play(); Scheduler.AddDelayed(delegate { // Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Manu. - if (menuMusic) + if (menuMusic.Value) track.Start(); LoadComponentAsync(mainMenu = new MainMenu()); @@ -112,7 +112,6 @@ namespace osu.Game.Screens.Menu }, delay_step_two); } - logo.RelativePositionAxes = Axes.Both; logo.Colour = Color4.White; logo.Ripple = false; @@ -159,7 +158,7 @@ namespace osu.Game.Screens.Menu double fadeOutTime = EXIT_DELAY; //we also handle the exit transition. - if (menuVoice) + if (menuVoice.Value) seeya.Play(); else fadeOutTime = 500; diff --git a/osu.Game/Screens/Menu/IntroSequence.cs b/osu.Game/Screens/Menu/IntroSequence.cs index 03a5b7ff46..093d01f12d 100644 --- a/osu.Game/Screens/Menu/IntroSequence.cs +++ b/osu.Game/Screens/Menu/IntroSequence.cs @@ -57,7 +57,7 @@ namespace osu.Game.Screens.Menu Anchor = Anchor.Centre, Origin = Anchor.Centre, AutoSizeAxes = Axes.Both, - Children = new [] + Children = new[] { lineTopLeft = new Box { @@ -102,9 +102,8 @@ namespace osu.Game.Screens.Menu Origin = Anchor.Centre, Text = "welcome", Padding = new MarginPadding { Bottom = 10 }, - Font = @"Exo2.0-Light", + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 42), Alpha = 0, - TextSize = 42, Spacing = new Vector2(5), }, new CircularContainer diff --git a/osu.Game/Screens/Menu/LogoVisualisation.cs b/osu.Game/Screens/Menu/LogoVisualisation.cs index 2534c57b1e..e930f924be 100644 --- a/osu.Game/Screens/Menu/LogoVisualisation.cs +++ b/osu.Game/Screens/Menu/LogoVisualisation.cs @@ -3,7 +3,6 @@ using osuTK; using osuTK.Graphics; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Batches; using osu.Framework.Graphics.Colour; @@ -15,6 +14,7 @@ using osu.Game.Beatmaps; using osu.Game.Graphics; using System; using osu.Framework.Allocation; +using osu.Framework.Bindables; namespace osu.Game.Screens.Menu { @@ -156,7 +156,9 @@ namespace osu.Game.Screens.Menu { public Shader Shader; public Texture Texture; + public VisualiserSharedData Shared; + //Asuming the logo is a circle, we don't need a second dimension. public float Size; @@ -213,6 +215,7 @@ namespace osu.Game.Screens.Menu } } } + Shader.Unbind(); } } diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index b380724f4b..f717e52db0 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -4,7 +4,9 @@ using osuTK; using osuTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Framework.Platform; using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Graphics; @@ -20,28 +22,31 @@ namespace osu.Game.Screens.Menu { public class MainMenu : OsuScreen { - private readonly ButtonSystem buttons; + private ButtonSystem buttons; public override bool HideOverlaysOnEnter => buttons.State == ButtonSystemState.Initial; - protected override bool AllowBackButton => buttons.State != ButtonSystemState.Initial; + protected override bool AllowBackButton => buttons.State != ButtonSystemState.Initial && host.CanExit; public override bool AllowExternalScreenChange => true; private Screen songSelect; - private readonly MenuSideFlashes sideFlashes; + private MenuSideFlashes sideFlashes; + + [Resolved] + private GameHost host { get; set; } protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault(); - public MainMenu() + [BackgroundDependencyLoader(true)] + private void load(OsuGame game = null) { - InternalChildren = new Drawable[] + if (host.CanExit) + AddInternal(new ExitConfirmOverlay { Action = this.Exit }); + + AddRangeInternal(new Drawable[] { - new ExitConfirmOverlay - { - Action = this.Exit, - }, new ParallaxContainer { ParallaxAmount = 0.01f, @@ -50,16 +55,16 @@ namespace osu.Game.Screens.Menu buttons = new ButtonSystem { OnChart = delegate { this.Push(new ChartListing()); }, - OnDirect = delegate {this.Push(new OnlineListing()); }, - OnEdit = delegate {this.Push(new Editor()); }, + OnDirect = delegate { this.Push(new OnlineListing()); }, + OnEdit = delegate { this.Push(new Editor()); }, OnSolo = onSolo, - OnMulti = delegate {this.Push(new Multiplayer()); }, + OnMulti = delegate { this.Push(new Multiplayer()); }, OnExit = this.Exit, } } }, sideFlashes = new MenuSideFlashes(), - }; + }); buttons.StateChanged += state => { @@ -74,11 +79,7 @@ namespace osu.Game.Screens.Menu break; } }; - } - [BackgroundDependencyLoader(true)] - private void load(OsuGame game = null) - { if (game != null) { buttons.OnSettings = game.ToggleSettings; @@ -96,7 +97,7 @@ namespace osu.Game.Screens.Menu public void LoadToSolo() => Schedule(onSolo); - private void onSolo() =>this.Push(consumeSongSelect()); + private void onSolo() => this.Push(consumeSongSelect()); private Screen consumeSongSelect() { @@ -154,7 +155,7 @@ namespace osu.Game.Screens.Menu .OnComplete(l => buttons.SetOsuLogo(null)); } - private void beatmap_ValueChanged(WorkingBeatmap newValue) + private void beatmap_ValueChanged(ValueChangedEvent e) { if (!this.IsCurrentScreen()) return; @@ -180,7 +181,7 @@ namespace osu.Game.Screens.Menu { base.OnResuming(last); - ((BackgroundScreenDefault)Background).Next(); + (Background as BackgroundScreenDefault)?.Next(); //we may have consumed our preloaded instance, so let's make another. preloadSongSelect(); diff --git a/osu.Game/Screens/Menu/MenuSideFlashes.cs b/osu.Game/Screens/Menu/MenuSideFlashes.cs index 7288cc8db5..ce0a38ba8d 100644 --- a/osu.Game/Screens/Menu/MenuSideFlashes.cs +++ b/osu.Game/Screens/Menu/MenuSideFlashes.cs @@ -4,7 +4,6 @@ using osuTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Audio.Track; -using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -14,6 +13,7 @@ using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using System; +using osu.Framework.Bindables; namespace osu.Game.Screens.Menu { diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index e682d5f711..af697d37bd 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -62,7 +62,7 @@ namespace osu.Game.Screens.Menu public bool Triangles { - set { colourAndTriangles.FadeTo(value ? 1 : 0, transition_length, Easing.OutQuint); } + set => colourAndTriangles.FadeTo(value ? 1 : 0, transition_length, Easing.OutQuint); } public bool BeatMatching = true; @@ -71,8 +71,8 @@ namespace osu.Game.Screens.Menu public bool Ripple { - get { return rippleContainer.Alpha > 0; } - set { rippleContainer.FadeTo(value ? 1 : 0, transition_length, Easing.OutQuint); } + get => rippleContainer.Alpha > 0; + set => rippleContainer.FadeTo(value ? 1 : 0, transition_length, Easing.OutQuint); } private readonly Box flashLayer; diff --git a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs index 7a513a7f5f..e096fb33da 100644 --- a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs +++ b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs @@ -25,10 +25,10 @@ namespace osu.Game.Screens.Multi.Components [BackgroundDependencyLoader] private void load() { - CurrentItem.BindValueChanged(v => updateText(), true); + CurrentItem.BindValueChanged(_ => updateText(), true); } - private float textSize = OsuSpriteText.FONT_SIZE; + private float textSize = OsuFont.DEFAULT_FONT_SIZE; public float TextSize { @@ -37,6 +37,7 @@ namespace osu.Game.Screens.Multi.Components { if (textSize == value) return; + textSize = value; updateText(); @@ -58,7 +59,7 @@ namespace osu.Game.Screens.Multi.Components if (beatmap == null) textFlow.AddText("No beatmap selected", s => { - s.TextSize = TextSize; + s.Font = s.Font.With(size: TextSize); s.Colour = colours.PinkLight; }); else @@ -68,17 +69,17 @@ namespace osu.Game.Screens.Multi.Components new OsuSpriteText { Text = new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)), - TextSize = TextSize, + Font = OsuFont.GetFont(size: TextSize), }, new OsuSpriteText { Text = " - ", - TextSize = TextSize, + Font = OsuFont.GetFont(size: TextSize), }, new OsuSpriteText { Text = new LocalisedString((beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title)), - TextSize = TextSize, + Font = OsuFont.GetFont(size: TextSize), } }, null, LinkAction.OpenBeatmap, beatmap.OnlineBeatmapID.ToString(), "Open beatmap"); } diff --git a/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs b/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs index 4f432a232c..23771451bd 100644 --- a/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs +++ b/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs @@ -40,7 +40,7 @@ namespace osu.Game.Screens.Multi.Components Children = new Drawable[] { new BeatmapTitle(), - beatmapAuthor = new LinkFlowContainer(s => s.TextSize = 14) + beatmapAuthor = new LinkFlowContainer(s => s.Font = s.Font.With(size: 14)) { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, @@ -55,7 +55,7 @@ namespace osu.Game.Screens.Multi.Components { beatmapAuthor.Clear(); - var beatmap = item?.Beatmap; + var beatmap = item.NewValue?.Beatmap; if (beatmap != null) { diff --git a/osu.Game/Screens/Multi/Components/DisableableTabControl.cs b/osu.Game/Screens/Multi/Components/DisableableTabControl.cs index 5bbf4b064f..b6b0332cf3 100644 --- a/osu.Game/Screens/Multi/Components/DisableableTabControl.cs +++ b/osu.Game/Screens/Multi/Components/DisableableTabControl.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Events; @@ -29,8 +29,9 @@ namespace osu.Game.Screens.Multi.Components protected override bool OnClick(ClickEvent e) { - if (!Enabled) + if (!Enabled.Value) return true; + return base.OnClick(e); } } diff --git a/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs b/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs index 0d49f75b46..8ab23a620b 100644 --- a/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs +++ b/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs @@ -46,9 +46,9 @@ namespace osu.Game.Screens.Multi.Components }, }; - CurrentItem.BindValueChanged(updateBeatmap, true); + CurrentItem.BindValueChanged(item => updateBeatmap(item.NewValue), true); - Type.BindValueChanged(v => gameTypeContainer.Child = new DrawableGameType(v) { Size = new Vector2(height) }, true); + Type.BindValueChanged(type => gameTypeContainer.Child = new DrawableGameType(type.NewValue) { Size = new Vector2(height) }, true); } private void updateBeatmap(PlaylistItem item) diff --git a/osu.Game/Screens/Multi/Components/MultiplayerBackgroundSprite.cs b/osu.Game/Screens/Multi/Components/MultiplayerBackgroundSprite.cs index 06d5e585ab..512f79942d 100644 --- a/osu.Game/Screens/Multi/Components/MultiplayerBackgroundSprite.cs +++ b/osu.Game/Screens/Multi/Components/MultiplayerBackgroundSprite.cs @@ -16,7 +16,7 @@ namespace osu.Game.Screens.Multi.Components InternalChild = sprite = CreateBackgroundSprite(); - CurrentItem.BindValueChanged(i => sprite.Beatmap.Value = i?.Beatmap, true); + CurrentItem.BindValueChanged(item => sprite.Beatmap.Value = item.NewValue?.Beatmap, true); } protected virtual UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both }; diff --git a/osu.Game/Screens/Multi/Components/ParticipantCount.cs b/osu.Game/Screens/Multi/Components/ParticipantCount.cs index 27bfc9a3f7..498eeb09b3 100644 --- a/osu.Game/Screens/Multi/Components/ParticipantCount.cs +++ b/osu.Game/Screens/Multi/Components/ParticipantCount.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; namespace osu.Game.Screens.Multi.Components @@ -34,25 +35,22 @@ namespace osu.Game.Screens.Multi.Components { count = new OsuSpriteText { - TextSize = text_size, - Font = @"Exo2.0-Bold" + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: text_size) }, slash = new OsuSpriteText { Text = @"/", - TextSize = text_size, - Font = @"Exo2.0-Light" + Font = OsuFont.GetFont(weight: FontWeight.Light, size: text_size) }, maxText = new OsuSpriteText { - TextSize = text_size, - Font = @"Exo2.0-Light" + Font = OsuFont.GetFont(weight: FontWeight.Light, size: text_size) }, } }; MaxParticipants.BindValueChanged(_ => updateMax(), true); - ParticipantCount.BindValueChanged(v => count.Text = v.ToString("#,0"), true); + ParticipantCount.BindValueChanged(c => count.Text = c.NewValue.ToString("#,0"), true); } private void updateMax() diff --git a/osu.Game/Screens/Multi/Components/RoomStatusInfo.cs b/osu.Game/Screens/Multi/Components/RoomStatusInfo.cs index 24a2d70b60..d799f846c2 100644 --- a/osu.Game/Screens/Multi/Components/RoomStatusInfo.cs +++ b/osu.Game/Screens/Multi/Components/RoomStatusInfo.cs @@ -3,7 +3,7 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -34,10 +34,9 @@ namespace osu.Game.Screens.Multi.Components { statusPart = new StatusPart { - TextSize = 14, - Font = "Exo2.0-Bold" + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14) }, - endDatePart = new EndDatePart { TextSize = 14 } + endDatePart = new EndDatePart { Font = OsuFont.GetFont(size: 14) } } }; @@ -54,7 +53,7 @@ namespace osu.Game.Screens.Multi.Components public EndDatePart() : base(DateTimeOffset.UtcNow) { - EndDate.BindValueChanged(d => Date = d); + EndDate.BindValueChanged(date => Date = date.NewValue); } protected override string Format() diff --git a/osu.Game/Screens/Multi/Components/StatusColouredContainer.cs b/osu.Game/Screens/Multi/Components/StatusColouredContainer.cs index 6d573d0866..97af6674bf 100644 --- a/osu.Game/Screens/Multi/Components/StatusColouredContainer.cs +++ b/osu.Game/Screens/Multi/Components/StatusColouredContainer.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; @@ -25,7 +25,7 @@ namespace osu.Game.Screens.Multi.Components [BackgroundDependencyLoader] private void load(OsuColour colours) { - status.BindValueChanged(s => this.FadeColour(s.GetAppropriateColour(colours), transitionDuration), true); + status.BindValueChanged(s => this.FadeColour(s.NewValue.GetAppropriateColour(colours), transitionDuration), true); } } } diff --git a/osu.Game/Screens/Multi/Header.cs b/osu.Game/Screens/Multi/Header.cs index 687a28b7a6..0e958bf523 100644 --- a/osu.Game/Screens/Multi/Header.cs +++ b/osu.Game/Screens/Multi/Header.cs @@ -64,12 +64,11 @@ namespace osu.Game.Screens.Multi new OsuSpriteText { Text = "multiplayer ", - TextSize = 25, + Font = OsuFont.GetFont(size: 25) }, screenType = new OsuSpriteText { - TextSize = 25, - Font = @"Exo2.0-Light", + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 25) }, }, }, @@ -85,10 +84,10 @@ namespace osu.Game.Screens.Multi }, }; - breadcrumbs.Current.ValueChanged += s => + breadcrumbs.Current.ValueChanged += scren => { - if (s is IMultiplayerSubScreen mpScreen) - screenType.Text = mpScreen.ShortTitle.ToLowerInvariant(); + if (scren.NewValue is IMultiplayerSubScreen multiScreen) + screenType.Text = multiScreen.ShortTitle.ToLowerInvariant(); }; breadcrumbs.Current.TriggerChange(); diff --git a/osu.Game/Screens/Multi/IRoomManager.cs b/osu.Game/Screens/Multi/IRoomManager.cs index 980879d79a..f6c979851e 100644 --- a/osu.Game/Screens/Multi/IRoomManager.cs +++ b/osu.Game/Screens/Multi/IRoomManager.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Online.Multiplayer; namespace osu.Game.Screens.Multi diff --git a/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs index afe2b70524..e41238a7ff 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using osu.Framework; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -43,12 +43,14 @@ namespace osu.Game.Screens.Multi.Lounge.Components public readonly Room Room; private SelectionState state; + public SelectionState State { - get { return state; } + get => state; set { if (value == state) return; + state = value; if (state == SelectionState.Selected) @@ -63,9 +65,10 @@ namespace osu.Game.Screens.Multi.Lounge.Components public IEnumerable FilterTerms => new[] { Room.Name.Value }; private bool matchingFilter; + public bool MatchingFilter { - get { return matchingFilter; } + get => matchingFilter; set { matchingFilter = value; @@ -155,7 +158,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components Spacing = new Vector2(5f), Children = new Drawable[] { - new RoomName { TextSize = 18 }, + new RoomName { Font = OsuFont.GetFont(size: 18) }, new ParticipantInfo(), }, }, diff --git a/osu.Game/Screens/Multi/Lounge/Components/FilterControl.cs b/osu.Game/Screens/Multi/Lounge/Components/FilterControl.cs index 950d475a30..8e14f76e4b 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/FilterControl.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/FilterControl.cs @@ -3,7 +3,7 @@ using System.ComponentModel; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Graphics; using osu.Game.Overlays.SearchableList; using osuTK.Graphics; @@ -45,8 +45,8 @@ namespace osu.Game.Screens.Multi.Lounge.Components filter.Value = new FilterCriteria { SearchString = Search.Current.Value ?? string.Empty, - PrimaryFilter = Tabs.Current, - SecondaryFilter = DisplayStyleControl.Dropdown.Current + PrimaryFilter = Tabs.Current.Value, + SecondaryFilter = DisplayStyleControl.Dropdown.Current.Value }; } } @@ -54,6 +54,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components public enum PrimaryFilter { Open, + [Description("Recently Ended")] RecentlyEnded, Participated, diff --git a/osu.Game/Screens/Multi/Lounge/Components/ParticipantInfo.cs b/osu.Game/Screens/Multi/Lounge/Components/ParticipantInfo.cs index 806bc92882..40e59de25d 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/ParticipantInfo.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/ParticipantInfo.cs @@ -81,28 +81,29 @@ namespace osu.Game.Screens.Multi.Lounge.Components summary = new OsuSpriteText { Text = "0 participants", - TextSize = 14, + Font = OsuFont.GetFont(size: 14) } }, }, }; - Host.BindValueChanged(v => + Host.BindValueChanged(host => { hostText.Clear(); flagContainer.Clear(); - if (v != null) + if (host.NewValue != null) { hostText.AddText("hosted by "); - hostText.AddLink(v.Username, null, LinkAction.OpenUserProfile, v.Id.ToString(), "Open profile", s => s.Font = "Exo2.0-BoldItalic"); - flagContainer.Child = new DrawableFlag(v.Country) { RelativeSizeAxes = Axes.Both }; + hostText.AddLink(host.NewValue.Username, null, LinkAction.OpenUserProfile, host.NewValue.Id.ToString(), "Open profile", + s => s.Font = s.Font.With(Typeface.Exo, weight: FontWeight.Bold, italics: true)); + flagContainer.Child = new DrawableFlag(host.NewValue.Country) { RelativeSizeAxes = Axes.Both }; } }, true); - ParticipantCount.BindValueChanged(v => summary.Text = $"{v:#,0}{" participant".Pluralize(v == 1)}", true); + ParticipantCount.BindValueChanged(count => summary.Text = "participant".ToQuantity(count.NewValue), true); - /*Participants.BindValueChanged(v => + /*Participants.BindValueChanged(e => { var ranks = v.Select(u => u.Statistics.Ranks.Global); levelRangeLower.Text = ranks.Min().ToString(); diff --git a/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs index 3e665ab27e..fd9c8d7b35 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs @@ -3,7 +3,7 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -96,7 +96,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - TextSize = 30, + Font = OsuFont.GetFont(size: 30), Current = Name }, }, @@ -135,8 +135,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components AutoSizeAxes = Axes.Both, Child = new StatusText { - TextSize = 14, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14), } }, beatmapTypeInfo = new BeatmapTypeInfo(), @@ -192,7 +191,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components } else { - status.Value = Status; + status.Value = Status.Value; participantCount.FadeIn(transition_duration); beatmapTypeInfo.FadeIn(transition_duration); @@ -215,7 +214,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components [BackgroundDependencyLoader] private void load() { - status.BindValueChanged(s => Text = s.Message, true); + status.BindValueChanged(s => Text = s.NewValue.Message, true); } } diff --git a/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs b/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs index baeac900ee..99a6de0064 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -109,7 +109,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components private void updateSorting() { foreach (var room in roomFlow) - roomFlow.SetLayoutPosition(room, room.Room.Position); + roomFlow.SetLayoutPosition(room, room.Room.Position.Value); } private void selectRoom(Room room) diff --git a/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs b/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs index 71205dc199..dd1e060125 100644 --- a/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs +++ b/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; diff --git a/osu.Game/Screens/Multi/Match/Components/Header.cs b/osu.Game/Screens/Multi/Match/Components/Header.cs index 9a0fdbd4e7..6a6a1f274c 100644 --- a/osu.Game/Screens/Multi/Match/Components/Header.cs +++ b/osu.Game/Screens/Multi/Match/Components/Header.cs @@ -3,7 +3,7 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -108,7 +108,7 @@ namespace osu.Game.Screens.Multi.Match.Components }, }; - CurrentItem.BindValueChanged(i => modDisplay.Current.Value = i?.RequiredMods, true); + CurrentItem.BindValueChanged(item => modDisplay.Current.Value = item.NewValue?.RequiredMods, true); beatmapButton.Action = () => RequestBeatmapSelection?.Invoke(); } @@ -126,7 +126,7 @@ namespace osu.Game.Screens.Multi.Match.Components [BackgroundDependencyLoader] private void load() { - roomId.BindValueChanged(v => this.FadeTo(v.HasValue ? 0 : 1), true); + roomId.BindValueChanged(id => this.FadeTo(id.NewValue.HasValue ? 0 : 1), true); } } diff --git a/osu.Game/Screens/Multi/Match/Components/HeaderButton.cs b/osu.Game/Screens/Multi/Match/Components/HeaderButton.cs index 8c9f99c446..f3412d0be7 100644 --- a/osu.Game/Screens/Multi/Match/Components/HeaderButton.cs +++ b/osu.Game/Screens/Multi/Match/Components/HeaderButton.cs @@ -41,8 +41,7 @@ namespace osu.Game.Screens.Multi.Match.Components Depth = -1, Origin = Anchor.Centre, Anchor = Anchor.Centre, - Font = @"Exo2.0-Light", - TextSize = 30, + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 30), }; } } diff --git a/osu.Game/Screens/Multi/Match/Components/HostInfo.cs b/osu.Game/Screens/Multi/Match/Components/HostInfo.cs index 942e03b306..02c8929f44 100644 --- a/osu.Game/Screens/Multi/Match/Components/HostInfo.cs +++ b/osu.Game/Screens/Multi/Match/Components/HostInfo.cs @@ -1,9 +1,10 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Online.Chat; using osu.Game.Users; @@ -42,7 +43,7 @@ namespace osu.Game.Screens.Multi.Match.Components } }; - Host.BindValueChanged(updateHost); + Host.BindValueChanged(host => updateHost(host.NewValue)); } private void updateHost(User host) @@ -53,7 +54,8 @@ namespace osu.Game.Screens.Multi.Match.Components { linkContainer.AddText("hosted by"); linkContainer.NewLine(); - linkContainer.AddLink(host.Username, null, LinkAction.OpenUserProfile, host.Id.ToString(), "View Profile", s => s.Font = "Exo2.0-BoldItalic"); + linkContainer.AddLink(host.Username, null, LinkAction.OpenUserProfile, host.Id.ToString(), "View Profile", + s => s.Font = s.Font.With(Typeface.Exo, weight: FontWeight.Bold, italics: true)); } } } diff --git a/osu.Game/Screens/Multi/Match/Components/Info.cs b/osu.Game/Screens/Multi/Match/Components/Info.cs index b27c5b0ab4..a944d965bd 100644 --- a/osu.Game/Screens/Multi/Match/Components/Info.cs +++ b/osu.Game/Screens/Multi/Match/Components/Info.cs @@ -62,7 +62,7 @@ namespace osu.Game.Screens.Multi.Match.Components { new OsuSpriteText { - TextSize = 30, + Font = OsuFont.GetFont(size: 30), Current = Name }, new RoomStatusInfo(), @@ -94,8 +94,8 @@ namespace osu.Game.Screens.Multi.Match.Components CurrentItem.BindValueChanged(item => { - viewBeatmapButton.Beatmap.Value = item?.Beatmap; - readyButton.Beatmap.Value = item?.Beatmap; + viewBeatmapButton.Beatmap.Value = item.NewValue?.Beatmap; + readyButton.Beatmap.Value = item.NewValue?.Beatmap; }, true); hostInfo.Host.BindTo(Host); diff --git a/osu.Game/Screens/Multi/Match/Components/MatchChatDisplay.cs b/osu.Game/Screens/Multi/Match/Components/MatchChatDisplay.cs index 0b61637cd5..bd8e4c7335 100644 --- a/osu.Game/Screens/Multi/Match/Components/MatchChatDisplay.cs +++ b/osu.Game/Screens/Multi/Match/Components/MatchChatDisplay.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Online.Chat; using osu.Game.Online.Multiplayer; @@ -28,13 +28,13 @@ namespace osu.Game.Screens.Multi.Match.Components { base.LoadComplete(); - roomId.BindValueChanged(v => updateChannel(), true); + roomId.BindValueChanged(_ => updateChannel(), true); } private void updateChannel() { if (roomId.Value != null) - Channel.Value = channelManager?.JoinChannel(new Channel { Id = channelId, Type = ChannelType.Multiplayer, Name = $"#mp_{roomId.Value}" }); + Channel.Value = channelManager?.JoinChannel(new Channel { Id = channelId.Value, Type = ChannelType.Multiplayer, Name = $"#mp_{roomId.Value}" }); } } } diff --git a/osu.Game/Screens/Multi/Match/Components/MatchLeaderboard.cs b/osu.Game/Screens/Multi/Match/Components/MatchLeaderboard.cs index 60604eeb5c..fff713f026 100644 --- a/osu.Game/Screens/Multi/Match/Components/MatchLeaderboard.cs +++ b/osu.Game/Screens/Multi/Match/Components/MatchLeaderboard.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; @@ -25,7 +25,7 @@ namespace osu.Game.Screens.Multi.Match.Components { roomId.BindValueChanged(id => { - if (id == null) + if (id.NewValue == null) return; Scores = null; diff --git a/osu.Game/Screens/Multi/Match/Components/MatchPage.cs b/osu.Game/Screens/Multi/Match/Components/MatchPage.cs index 15749864b6..fc98db157b 100644 --- a/osu.Game/Screens/Multi/Match/Components/MatchPage.cs +++ b/osu.Game/Screens/Multi/Match/Components/MatchPage.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; namespace osu.Game.Screens.Multi.Match.Components { diff --git a/osu.Game/Screens/Multi/Match/Components/MatchSettingsOverlay.cs b/osu.Game/Screens/Multi/Match/Components/MatchSettingsOverlay.cs index c3169ebe94..b310e62d7c 100644 --- a/osu.Game/Screens/Multi/Match/Components/MatchSettingsOverlay.cs +++ b/osu.Game/Screens/Multi/Match/Components/MatchSettingsOverlay.cs @@ -4,7 +4,7 @@ using System; using Humanizer; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -148,7 +148,7 @@ namespace osu.Game.Screens.Multi.Match.Components }, typeLabel = new OsuSpriteText { - TextSize = 14, + Font = OsuFont.GetFont(size: 14), Colour = colours.Yellow }, }, @@ -264,12 +264,12 @@ namespace osu.Game.Screens.Multi.Match.Components processingOverlay = new ProcessingOverlay { Alpha = 0 } }; - TypePicker.Current.BindValueChanged(t => typeLabel.Text = t?.Name ?? string.Empty, true); - Name.BindValueChanged(n => NameField.Text = n, true); - Availability.BindValueChanged(a => AvailabilityPicker.Current.Value = a, true); - Type.BindValueChanged(t => TypePicker.Current.Value = t, true); - MaxParticipants.BindValueChanged(m => MaxParticipantsField.Text = m?.ToString(), true); - Duration.BindValueChanged(d => DurationField.Current.Value = d, true); + TypePicker.Current.BindValueChanged(type => typeLabel.Text = type.NewValue?.Name ?? string.Empty, true); + Name.BindValueChanged(name => NameField.Text = name.NewValue, true); + Availability.BindValueChanged(availability => AvailabilityPicker.Current.Value = availability.NewValue, true); + Type.BindValueChanged(type => TypePicker.Current.Value = type.NewValue, true); + MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true); + Duration.BindValueChanged(duration => DurationField.Current.Value = duration.NewValue, true); } protected override void Update() @@ -296,7 +296,7 @@ namespace osu.Game.Screens.Multi.Match.Components Duration.Value = DurationField.Current.Value; - manager?.CreateRoom(currentRoom, onSuccess, onError); + manager?.CreateRoom(currentRoom.Value, onSuccess, onError); processingOverlay.Show(); } @@ -364,8 +364,7 @@ namespace osu.Game.Screens.Multi.Match.Components { new OsuSpriteText { - TextSize = 12, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12), Text = title.ToUpper(), }, content = new Container diff --git a/osu.Game/Screens/Multi/Match/Components/MatchTabControl.cs b/osu.Game/Screens/Multi/Match/Components/MatchTabControl.cs index 7ac1016e72..c700d7b88a 100644 --- a/osu.Game/Screens/Multi/Match/Components/MatchTabControl.cs +++ b/osu.Game/Screens/Multi/Match/Components/MatchTabControl.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Events; @@ -26,9 +26,9 @@ namespace osu.Game.Screens.Multi.Match.Components [BackgroundDependencyLoader] private void load() { - roomId.BindValueChanged(v => + roomId.BindValueChanged(id => { - if (v.HasValue) + if (id.NewValue.HasValue) { Items.ForEach(t => t.Enabled.Value = !(t is SettingsMatchPage)); Current.Value = new RoomMatchPage(); @@ -51,13 +51,14 @@ namespace osu.Game.Screens.Multi.Match.Components : base(value) { enabled.BindTo(value.Enabled); - enabled.BindValueChanged(v => Colour = v ? Color4.White : Color4.Gray); + enabled.BindValueChanged(enabled => Colour = enabled.NewValue ? Color4.White : Color4.Gray, true); } protected override bool OnClick(ClickEvent e) { if (!enabled.Value) return true; + return base.OnClick(e); } } diff --git a/osu.Game/Screens/Multi/Match/Components/Participants.cs b/osu.Game/Screens/Multi/Match/Components/Participants.cs index 1565d75c21..2d6099c65d 100644 --- a/osu.Game/Screens/Multi/Match/Components/Participants.cs +++ b/osu.Game/Screens/Multi/Match/Components/Participants.cs @@ -50,9 +50,9 @@ namespace osu.Game.Screens.Multi.Match.Components }, }; - Participants.BindValueChanged(v => + Participants.BindValueChanged(participants => { - usersFlow.Children = v.Select(u => new UserPanel(u) + usersFlow.Children = participants.NewValue.Select(u => new UserPanel(u) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, diff --git a/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs b/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs index 50cf2addeb..b299e70962 100644 --- a/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs +++ b/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs @@ -4,7 +4,7 @@ using System; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; @@ -39,8 +39,9 @@ namespace osu.Game.Screens.Multi.Match.Components private void load() { beatmaps.ItemAdded += beatmapAdded; + beatmaps.ItemRemoved += beatmapRemoved; - Beatmap.BindValueChanged(updateBeatmap, true); + Beatmap.BindValueChanged(b => updateBeatmap(b.NewValue), true); } private void updateBeatmap(BeatmapInfo beatmap) @@ -62,6 +63,15 @@ namespace osu.Game.Screens.Multi.Match.Components Schedule(() => hasBeatmap = true); } + private void beatmapRemoved(BeatmapSetInfo model) + { + if (Beatmap.Value == null) + return; + + if (model.OnlineBeatmapSetID == Beatmap.Value.BeatmapSet.OnlineBeatmapSetID) + Schedule(() => hasBeatmap = false); + } + protected override void Update() { base.Update(); @@ -77,7 +87,7 @@ namespace osu.Game.Screens.Multi.Match.Components return; } - bool hasEnoughTime = DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(gameBeatmap.Value.Track.Length) < endDate; + bool hasEnoughTime = DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(gameBeatmap.Value.Track.Length) < endDate.Value; Enabled.Value = hasBeatmap && hasEnoughTime; } diff --git a/osu.Game/Screens/Multi/Match/Components/RoomAvailabilityPicker.cs b/osu.Game/Screens/Multi/Match/Components/RoomAvailabilityPicker.cs index 4e6ebf2135..8751e27552 100644 --- a/osu.Game/Screens/Multi/Match/Components/RoomAvailabilityPicker.cs +++ b/osu.Game/Screens/Multi/Match/Components/RoomAvailabilityPicker.cs @@ -39,7 +39,8 @@ namespace osu.Game.Screens.Multi.Match.Components private readonly Box hover, selection; - public RoomAvailabilityPickerItem(RoomAvailability value) : base(value) + public RoomAvailabilityPickerItem(RoomAvailability value) + : base(value) { RelativeSizeAxes = Axes.Y; Width = 102; @@ -68,7 +69,7 @@ namespace osu.Game.Screens.Multi.Match.Components { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold), Text = value.GetDescription(), }, }; diff --git a/osu.Game/Screens/Multi/Match/Components/ViewBeatmapButton.cs b/osu.Game/Screens/Multi/Match/Components/ViewBeatmapButton.cs index e26a6b7e20..8d1ff21124 100644 --- a/osu.Game/Screens/Multi/Match/Components/ViewBeatmapButton.cs +++ b/osu.Game/Screens/Multi/Match/Components/ViewBeatmapButton.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Beatmaps; using osuTK; @@ -28,7 +28,7 @@ namespace osu.Game.Screens.Multi.Match.Components private void load() { if (osuGame != null) - Beatmap.BindValueChanged(updateAction, true); + Beatmap.BindValueChanged(beatmap => updateAction(beatmap.NewValue), true); } private void updateAction(BeatmapInfo beatmap) diff --git a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs index d97b32e54a..229b9bde6a 100644 --- a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Screens; @@ -43,7 +43,7 @@ namespace osu.Game.Screens.Multi.Match protected Bindable CurrentItem { get; private set; } [Resolved] - protected Bindable> CurrentMods { get; private set; } + protected Bindable> SelectedMods { get; private set; } [Resolved] private BeatmapManager beatmapManager { get; set; } @@ -55,7 +55,7 @@ namespace osu.Game.Screens.Multi.Match public MatchSubScreen(Room room) { - Title = room.RoomID.Value == null ? "New room" : room.Name; + Title = room.RoomID.Value == null ? "New room" : room.Name.Value; } [BackgroundDependencyLoader] @@ -146,10 +146,10 @@ namespace osu.Game.Screens.Multi.Match }, }; - header.Tabs.Current.BindValueChanged(t => + header.Tabs.Current.BindValueChanged(tab => { const float fade_duration = 500; - if (t is SettingsMatchPage) + if (tab.NewValue is SettingsMatchPage) { settings.Show(); info.FadeOut(fade_duration, Easing.OutQuint); @@ -188,15 +188,15 @@ namespace osu.Game.Screens.Multi.Match /// /// Handles propagation of the current playlist item's content to game-wide mechanisms. /// - private void currentItemChanged(PlaylistItem item) + private void currentItemChanged(ValueChangedEvent e) { // Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info - var localBeatmap = item?.Beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == item.Beatmap.OnlineBeatmapID); + var localBeatmap = e.NewValue?.Beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == e.NewValue.Beatmap.OnlineBeatmapID); Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap); - CurrentMods.Value = item?.RequiredMods ?? Enumerable.Empty(); - if (item?.Ruleset != null) - Ruleset.Value = item.Ruleset; + SelectedMods.Value = e.NewValue?.RequiredMods ?? Enumerable.Empty(); + if (e.NewValue?.Ruleset != null) + Ruleset.Value = e.NewValue.Ruleset; } /// @@ -222,13 +222,13 @@ namespace osu.Game.Screens.Multi.Match private void onStart() { - Beatmap.Value.Mods.Value = CurrentMods.Value.ToArray(); + Beatmap.Value.Mods.Value = SelectedMods.Value.ToArray(); switch (type.Value) { default: case GameTypeTimeshift _: - multiplayer?.Start(() => new TimeshiftPlayer(CurrentItem) + multiplayer?.Start(() => new TimeshiftPlayer(CurrentItem.Value) { Exited = () => leaderboard.RefreshScores() }); diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index 32eea88fbc..dd01ae4160 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -3,7 +3,7 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -135,7 +135,7 @@ namespace osu.Game.Screens.Multi protected override void LoadComplete() { base.LoadComplete(); - isIdle.BindValueChanged(updatePollingRate, true); + isIdle.BindValueChanged(idle => updatePollingRate(idle.NewValue), true); } protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) diff --git a/osu.Game/Screens/Multi/MultiplayerComposite.cs b/osu.Game/Screens/Multi/MultiplayerComposite.cs index 245a6ac358..da6bba7865 100644 --- a/osu.Game/Screens/Multi/MultiplayerComposite.cs +++ b/osu.Game/Screens/Multi/MultiplayerComposite.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; using osu.Game.Online.Multiplayer; using osu.Game.Users; diff --git a/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs b/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs index 71f6687cc6..6b88403b9e 100644 --- a/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs +++ b/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs @@ -2,15 +2,19 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using System.Threading; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Logging; using osu.Framework.Screens; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.Multiplayer; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Mods; using osu.Game.Scoring; using osu.Game.Screens.Multi.Ranking; using osu.Game.Screens.Play; @@ -30,6 +34,12 @@ namespace osu.Game.Screens.Multi.Play [Resolved] private APIAccess api { get; set; } + [Resolved] + private IBindable ruleset { get; set; } + + [Resolved] + private Bindable> selectedMods { get; set; } + public TimeshiftPlayer(PlaylistItem playlistItem) { this.playlistItem = playlistItem; @@ -44,6 +54,16 @@ namespace osu.Game.Screens.Multi.Play bool failed = false; + // Sanity checks to ensure that TimeshiftPlayer matches the settings for the current PlaylistItem + if (Beatmap.Value.BeatmapInfo.OnlineBeatmapID != playlistItem.Beatmap.OnlineBeatmapID) + throw new InvalidOperationException("Current Beatmap does not match PlaylistItem's Beatmap"); + + if (ruleset.Value.ID != playlistItem.Ruleset.ID) + throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset"); + + if (!playlistItem.RequiredMods.All(m => selectedMods.Value.Contains(m))) + throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods"); + var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID); req.Success += r => token = r.ID; req.Failure += e => diff --git a/osu.Game/Screens/Multi/Ranking/MatchResults.cs b/osu.Game/Screens/Multi/Ranking/MatchResults.cs index db52a79ccb..fe68d7e849 100644 --- a/osu.Game/Screens/Multi/Ranking/MatchResults.cs +++ b/osu.Game/Screens/Multi/Ranking/MatchResults.cs @@ -18,9 +18,9 @@ namespace osu.Game.Screens.Multi.Ranking protected override IEnumerable CreateResultPages() => new IResultPageInfo[] { - new ScoreOverviewPageInfo(Score, Beatmap), - new LocalLeaderboardPageInfo(Score, Beatmap), - new RoomLeaderboardPageInfo(Score, Beatmap), + new ScoreOverviewPageInfo(Score, Beatmap.Value), + new LocalLeaderboardPageInfo(Score, Beatmap.Value), + new RoomLeaderboardPageInfo(Score, Beatmap.Value), }; } } diff --git a/osu.Game/Screens/Multi/Ranking/Pages/RoomLeaderboardPage.cs b/osu.Game/Screens/Multi/Ranking/Pages/RoomLeaderboardPage.cs index 1b4c99d972..d20b021fc6 100644 --- a/osu.Game/Screens/Multi/Ranking/Pages/RoomLeaderboardPage.cs +++ b/osu.Game/Screens/Multi/Ranking/Pages/RoomLeaderboardPage.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Internal; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -80,7 +80,7 @@ namespace osu.Game.Screens.Multi.Ranking.Pages Action gray = s => s.Colour = colours.GrayC; Action white = s => { - s.TextSize *= 1.4f; + s.Font = s.Font.With(size: s.Font.Size * 1.4f); s.Colour = colours.GrayF; }; @@ -91,7 +91,7 @@ namespace osu.Game.Screens.Multi.Ranking.Pages rankText.AddText($"#{index + 1} ", s => { - s.Font = "Exo2.0-Bold"; + s.Font = s.Font.With(Typeface.Exo, weight: FontWeight.Bold); s.Colour = colours.YellowDark; }); diff --git a/osu.Game/Screens/Multi/RoomManager.cs b/osu.Game/Screens/Multi/RoomManager.cs index b1f021618f..c15a8471a1 100644 --- a/osu.Game/Screens/Multi/RoomManager.cs +++ b/osu.Game/Screens/Multi/RoomManager.cs @@ -5,7 +5,7 @@ using System; using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Logging; using osu.Game.Beatmaps; using osu.Game.Online; @@ -56,7 +56,7 @@ namespace osu.Game.Screens.Multi public void CreateRoom(Room room, Action onSuccess = null, Action onError = null) { - room.Host.Value = api.LocalUser; + room.Host.Value = api.LocalUser.Value; var req = new CreateRoomRequest(room); diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index b8d6fda97d..5034385969 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Internal; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Input.Bindings; using osu.Framework.Screens; @@ -174,7 +174,7 @@ namespace osu.Game.Screens logo.FadeOut(300, Easing.OutQuint); logo.Anchor = Anchor.TopLeft; logo.Origin = Anchor.Centre; - logo.RelativePositionAxes = Axes.None; + logo.RelativePositionAxes = Axes.Both; logo.BeatMatching = true; logo.Triangles = true; logo.Ripple = true; diff --git a/osu.Game/Screens/OsuScreenDependencies.cs b/osu.Game/Screens/OsuScreenDependencies.cs index b51ce0d33f..84e5de76de 100644 --- a/osu.Game/Screens/OsuScreenDependencies.cs +++ b/osu.Game/Screens/OsuScreenDependencies.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Beatmaps; using osu.Game.Rulesets; diff --git a/osu.Game/Screens/Play/Break/BlurredIcon.cs b/osu.Game/Screens/Play/Break/BlurredIcon.cs index 04b87d123f..53b968959c 100644 --- a/osu.Game/Screens/Play/Break/BlurredIcon.cs +++ b/osu.Game/Screens/Play/Break/BlurredIcon.cs @@ -15,8 +15,8 @@ namespace osu.Game.Screens.Play.Break public FontAwesome Icon { - set { icon.Icon = value; } - get { return icon.Icon; } + set => icon.Icon = value; + get => icon.Icon; } public override Vector2 Size @@ -27,7 +27,7 @@ namespace osu.Game.Screens.Play.Break base.Size = value + BlurSigma * 2.5f; ForceRedraw(); } - get { return base.Size; } + get => base.Size; } public BlurredIcon() diff --git a/osu.Game/Screens/Play/Break/BreakInfo.cs b/osu.Game/Screens/Play/Break/BreakInfo.cs index 39a5594450..a3d64d05a3 100644 --- a/osu.Game/Screens/Play/Break/BreakInfo.cs +++ b/osu.Game/Screens/Play/Break/BreakInfo.cs @@ -3,6 +3,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Scoring; using osuTK; @@ -29,8 +30,7 @@ namespace osu.Game.Screens.Play.Break Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = "current progress".ToUpperInvariant(), - TextSize = 15, - Font = "Exo2.0-Black", + Font = OsuFont.GetFont(weight: FontWeight.Black, size: 15), }, new FillFlowContainer { diff --git a/osu.Game/Screens/Play/Break/BreakInfoLine.cs b/osu.Game/Screens/Play/Break/BreakInfoLine.cs index d2b8b8c26a..4b07405812 100644 --- a/osu.Game/Screens/Play/Break/BreakInfoLine.cs +++ b/osu.Game/Screens/Play/Break/BreakInfoLine.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; @@ -34,7 +34,7 @@ namespace osu.Game.Screens.Play.Break Anchor = Anchor.Centre, Origin = Anchor.CentreRight, Text = name, - TextSize = 17, + Font = OsuFont.GetFont(size: 17), Margin = new MarginPadding { Right = margin } }, valueText = new OsuSpriteText @@ -42,8 +42,7 @@ namespace osu.Game.Screens.Play.Break Anchor = Anchor.Centre, Origin = Anchor.CentreLeft, Text = prefix + @"-", - TextSize = 17, - Font = "Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17), Margin = new MarginPadding { Left = margin } } }; @@ -51,9 +50,9 @@ namespace osu.Game.Screens.Play.Break Current.ValueChanged += currentValueChanged; } - private void currentValueChanged(T newValue) + private void currentValueChanged(ValueChangedEvent e) { - var newText = prefix + Format(newValue); + var newText = prefix + Format(e.NewValue); if (valueText.Text == newText) return; @@ -73,7 +72,8 @@ namespace osu.Game.Screens.Play.Break public class PercentageBreakInfoLine : BreakInfoLine { - public PercentageBreakInfoLine(string name, string prefix = "") : base(name, prefix) + public PercentageBreakInfoLine(string name, string prefix = "") + : base(name, prefix) { } diff --git a/osu.Game/Screens/Play/Break/GlowIcon.cs b/osu.Game/Screens/Play/Break/GlowIcon.cs index 8843373ded..8d918cd225 100644 --- a/osu.Game/Screens/Play/Break/GlowIcon.cs +++ b/osu.Game/Screens/Play/Break/GlowIcon.cs @@ -16,7 +16,7 @@ namespace osu.Game.Screens.Play.Break public override Vector2 Size { - get { return base.Size; } + get => base.Size; set { blurredIcon.Size = spriteIcon.Size = value; @@ -26,14 +26,14 @@ namespace osu.Game.Screens.Play.Break public Vector2 BlurSigma { - get { return blurredIcon.BlurSigma; } - set { blurredIcon.BlurSigma = value; } + get => blurredIcon.BlurSigma; + set => blurredIcon.BlurSigma = value; } public FontAwesome Icon { - get { return spriteIcon.Icon; } - set { spriteIcon.Icon = blurredIcon.Icon = value; } + get => spriteIcon.Icon; + set => spriteIcon.Icon = blurredIcon.Icon = value; } public GlowIcon() diff --git a/osu.Game/Screens/Play/Break/RemainingTimeCounter.cs b/osu.Game/Screens/Play/Break/RemainingTimeCounter.cs index c85ce1b70b..2f5e43aebf 100644 --- a/osu.Game/Screens/Play/Break/RemainingTimeCounter.cs +++ b/osu.Game/Screens/Play/Break/RemainingTimeCounter.cs @@ -4,6 +4,7 @@ using System; using osu.Framework.Graphics; using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; namespace osu.Game.Screens.Play.Break @@ -19,8 +20,7 @@ namespace osu.Game.Screens.Play.Break { Anchor = Anchor.Centre, Origin = Anchor.Centre, - TextSize = 33, - Font = "Venera", + Font = OsuFont.Numeric.With(size: 33), }; } diff --git a/osu.Game/Screens/Play/GameplayMenuOverlay.cs b/osu.Game/Screens/Play/GameplayMenuOverlay.cs index dc0636c44f..5d210446c3 100644 --- a/osu.Game/Screens/Play/GameplayMenuOverlay.cs +++ b/osu.Game/Screens/Play/GameplayMenuOverlay.cs @@ -18,6 +18,7 @@ using System.Linq; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Game.Input.Bindings; +using Humanizer; namespace osu.Game.Screens.Play { @@ -88,11 +89,10 @@ namespace osu.Game.Screens.Play new OsuSpriteText { Text = Header, - Font = @"Exo2.0-Medium", + Font = OsuFont.GetFont(size: 30), Spacing = new Vector2(5, 0), Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, - TextSize = 30, Colour = colours.Yellow, Shadow = true, ShadowColour = new Color4(0, 0, 0, 0.25f) @@ -176,7 +176,7 @@ namespace osu.Game.Screens.Play } }; - button.Selected.ValueChanged += s => buttonSelectionChanged(button, s); + button.Selected.ValueChanged += selected => buttonSelectionChanged(button, selected.NewValue); InternalButtons.Add(button); } @@ -185,7 +185,7 @@ namespace osu.Game.Screens.Play private int selectionIndex { - get { return _selectionIndex; } + get => _selectionIndex; set { if (_selectionIndex == value) @@ -260,22 +260,21 @@ namespace osu.Game.Screens.Play Text = "You've retried ", Shadow = true, ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 + Font = OsuFont.GetFont(size: 18), }, new OsuSpriteText { - Text = $"{retries:n0}", - Font = @"Exo2.0-Bold", + Text = "time".ToQuantity(retries), + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 18), Shadow = true, ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 }, new OsuSpriteText { - Text = $" time{(retries == 1 ? "" : "s")} in this session", + Text = " in this session", Shadow = true, ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 + Font = OsuFont.GetFont(size: 18), } }; } @@ -292,7 +291,7 @@ namespace osu.Game.Screens.Play protected override bool OnKeyDown(KeyDownEvent e) { - if (e.Repeat || e.Key != Key.Enter || !Selected) + if (e.Repeat || e.Key != Key.Enter || !Selected.Value) return false; Click(); diff --git a/osu.Game/Screens/Play/HUD/ComboCounter.cs b/osu.Game/Screens/Play/HUD/ComboCounter.cs index b45b1bb8a5..5ac3dac5f7 100644 --- a/osu.Game/Screens/Play/HUD/ComboCounter.cs +++ b/osu.Game/Screens/Play/HUD/ComboCounter.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -63,14 +63,14 @@ namespace osu.Game.Screens.Play.HUD TextSize = 80; - Current.ValueChanged += newValue => updateCount(newValue == 0); + Current.ValueChanged += combo => updateCount(combo.NewValue == 0); } protected override void LoadComplete() { base.LoadComplete(); - DisplayedCountSpriteText.Text = FormatCount(Current); + DisplayedCountSpriteText.Text = FormatCount(Current.Value); DisplayedCountSpriteText.Anchor = Anchor; DisplayedCountSpriteText.Origin = Origin; @@ -78,29 +78,33 @@ namespace osu.Game.Screens.Play.HUD } private int displayedCount; + /// /// Value shown at the current moment. /// public virtual int DisplayedCount { - get { return displayedCount; } + get => displayedCount; protected set { if (displayedCount.Equals(value)) return; + updateDisplayedCount(displayedCount, value, IsRolling); } } private float textSize; + public float TextSize { - get { return textSize; } + get => textSize; set { textSize = value; - DisplayedCountSpriteText.TextSize = TextSize; - PopOutCount.TextSize = TextSize; + + DisplayedCountSpriteText.Font = DisplayedCountSpriteText.Font.With(size: TextSize); + PopOutCount.Font = PopOutCount.Font.With(size: TextSize); } } @@ -110,7 +114,7 @@ namespace osu.Game.Screens.Play.HUD /// public void Increment(int amount = 1) { - Current.Value = Current + amount; + Current.Value = Current.Value + amount; } /// @@ -161,7 +165,7 @@ namespace osu.Game.Screens.Play.HUD private void updateCount(bool rolling) { int prev = previousValue; - previousValue = Current; + previousValue = Current.Value; if (!IsLoaded) return; @@ -172,14 +176,14 @@ namespace osu.Game.Screens.Play.HUD IsRolling = false; DisplayedCount = prev; - if (prev + 1 == Current) - OnCountIncrement(prev, Current); + if (prev + 1 == Current.Value) + OnCountIncrement(prev, Current.Value); else - OnCountChange(prev, Current); + OnCountChange(prev, Current.Value); } else { - OnCountRolling(displayedCount, Current); + OnCountRolling(displayedCount, Current.Value); IsRolling = true; } } diff --git a/osu.Game/Screens/Play/HUD/ComboResultCounter.cs b/osu.Game/Screens/Play/HUD/ComboResultCounter.cs index a45a1dbc68..3f6b1e29e6 100644 --- a/osu.Game/Screens/Play/HUD/ComboResultCounter.cs +++ b/osu.Game/Screens/Play/HUD/ComboResultCounter.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play.HUD public override void Increment(long amount) { - Current.Value = Current + amount; + Current.Value = Current.Value + amount; } } } diff --git a/osu.Game/Screens/Play/HUD/HealthDisplay.cs b/osu.Game/Screens/Play/HUD/HealthDisplay.cs index cc3b4e8254..acd8656fb2 100644 --- a/osu.Game/Screens/Play/HUD/HealthDisplay.cs +++ b/osu.Game/Screens/Play/HUD/HealthDisplay.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; namespace osu.Game.Screens.Play.HUD @@ -16,7 +16,7 @@ namespace osu.Game.Screens.Play.HUD protected HealthDisplay() { - Current.ValueChanged += newValue => SetHealth((float)newValue); + Current.ValueChanged += health => SetHealth((float)health.NewValue); } protected abstract void SetHealth(float value); diff --git a/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs b/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs index a0bcc3460b..ca4cce8929 100644 --- a/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs +++ b/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs @@ -42,7 +42,7 @@ namespace osu.Game.Screens.Play.HUD text = new OsuSpriteText { Text = "hold for menu", - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold), Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft }, @@ -163,7 +163,7 @@ namespace osu.Game.Screens.Play.HUD private void bind() { circularProgress.Current.BindTo(Progress); - Progress.ValueChanged += v => icon.Scale = new Vector2(1 + (float)v * 0.2f); + Progress.ValueChanged += progress => icon.Scale = new Vector2(1 + (float)progress.NewValue * 0.2f); } private bool pendingAnimation; diff --git a/osu.Game/Screens/Play/HUD/ModDisplay.cs b/osu.Game/Screens/Play/HUD/ModDisplay.cs index d329902a2d..2c1293833f 100644 --- a/osu.Game/Screens/Play/HUD/ModDisplay.cs +++ b/osu.Game/Screens/Play/HUD/ModDisplay.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; @@ -14,6 +14,7 @@ using osu.Game.Rulesets.UI; using osuTK; using osu.Game.Graphics.Containers; using osu.Framework.Input.Events; +using osu.Game.Graphics; namespace osu.Game.Screens.Play.HUD { @@ -60,15 +61,14 @@ namespace osu.Game.Screens.Play.HUD Anchor = Anchor.BottomCentre, Origin = Anchor.TopCentre, Text = @"/ UNRANKED /", - Font = @"Venera", - TextSize = 12, + Font = OsuFont.Numeric.With(size: 12) } }; Current.ValueChanged += mods => { iconsContainer.Clear(); - foreach (Mod mod in mods) + foreach (Mod mod in mods.NewValue) { iconsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.6f) }); } diff --git a/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs b/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs index 863fee2257..d3dba88281 100644 --- a/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs +++ b/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs @@ -17,6 +17,7 @@ namespace osu.Game.Screens.Play.HUD public bool ReplayLoaded; public readonly PlaybackSettings PlaybackSettings; + public readonly VisualSettings VisualSettings; //public readonly CollectionSettings CollectionSettings; //public readonly DiscussionSettings DiscussionSettings; diff --git a/osu.Game/Screens/Play/HUD/StandardHealthDisplay.cs b/osu.Game/Screens/Play/HUD/StandardHealthDisplay.cs index f961e6b227..8f09c2b2bf 100644 --- a/osu.Game/Screens/Play/HUD/StandardHealthDisplay.cs +++ b/osu.Game/Screens/Play/HUD/StandardHealthDisplay.cs @@ -44,18 +44,20 @@ namespace osu.Game.Screens.Play.HUD public Color4 AccentColour { - get { return fill.Colour; } - set { fill.Colour = value; } + get => fill.Colour; + set => fill.Colour = value; } private Color4 glowColour; + public Color4 GlowColour { - get { return glowColour; } + get => glowColour; set { if (glowColour == value) return; + glowColour = value; fill.EdgeEffect = new EdgeEffectParameters diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 1b1862d587..130d2ecc95 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; @@ -92,7 +92,7 @@ namespace osu.Game.Screens.Play Progress.Objects = rulesetContainer.Objects; Progress.AudioClock = offsetClock; - Progress.AllowSeeking = rulesetContainer.HasReplayLoaded; + Progress.AllowSeeking = rulesetContainer.HasReplayLoaded.Value; Progress.OnSeek = pos => adjustableClock.Seek(pos); ModDisplay.Current.BindTo(working.Mods); @@ -104,10 +104,10 @@ namespace osu.Game.Screens.Play private void load(OsuConfigManager config, NotificationOverlay notificationOverlay) { showHud = config.GetBindable(OsuSetting.ShowInterface); - showHud.ValueChanged += hudVisibility => visibilityContainer.FadeTo(hudVisibility ? 1 : 0, duration); + showHud.ValueChanged += visible => visibilityContainer.FadeTo(visible.NewValue ? 1 : 0, duration); showHud.TriggerChange(); - if (!showHud && !hasShownNotificationOnce) + if (!showHud.Value && !hasShownNotificationOnce) { hasShownNotificationOnce = true; @@ -126,11 +126,11 @@ namespace osu.Game.Screens.Play replayLoaded.TriggerChange(); } - private void replayLoadedValueChanged(bool loaded) + private void replayLoadedValueChanged(ValueChangedEvent e) { - PlayerSettingsOverlay.ReplayLoaded = loaded; + PlayerSettingsOverlay.ReplayLoaded = e.NewValue; - if (loaded) + if (e.NewValue) { PlayerSettingsOverlay.Show(); ModDisplay.FadeIn(200); @@ -241,8 +241,7 @@ namespace osu.Game.Screens.Play ComboCounter?.Current.BindTo(processor.Combo); HealthDisplay?.Current.BindTo(processor.Health); - var shd = HealthDisplay as StandardHealthDisplay; - if (shd != null) + if (HealthDisplay is StandardHealthDisplay shd) processor.NewJudgement += shd.Flash; } } diff --git a/osu.Game/Screens/Play/KeyCounter.cs b/osu.Game/Screens/Play/KeyCounter.cs index 9d8fb2a501..0e1f938137 100644 --- a/osu.Game/Screens/Play/KeyCounter.cs +++ b/osu.Game/Screens/Play/KeyCounter.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osuTK; using osuTK.Graphics; @@ -26,9 +27,10 @@ namespace osu.Game.Screens.Play public bool IsCounting { get; set; } = true; private int countPresses; + public int CountPresses { - get { return countPresses; } + get => countPresses; private set { if (countPresses != value) @@ -40,9 +42,10 @@ namespace osu.Game.Screens.Play } private bool isLit; + public bool IsLit { - get { return isLit; } + get => isLit; protected set { if (isLit != value) @@ -96,8 +99,7 @@ namespace osu.Game.Screens.Play new OsuSpriteText { Text = Name, - Font = @"Venera", - TextSize = 12, + Font = OsuFont.Numeric.With(size: 12), Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativePositionAxes = Axes.Both, diff --git a/osu.Game/Screens/Play/KeyCounterAction.cs b/osu.Game/Screens/Play/KeyCounterAction.cs index 3a17379da9..8deac653ad 100644 --- a/osu.Game/Screens/Play/KeyCounterAction.cs +++ b/osu.Game/Screens/Play/KeyCounterAction.cs @@ -10,7 +10,8 @@ namespace osu.Game.Screens.Play { public T Action { get; } - public KeyCounterAction(T action) : base($"B{(int)(object)action + 1}") + public KeyCounterAction(T action) + : base($"B{(int)(object)action + 1}") { Action = action; } diff --git a/osu.Game/Screens/Play/KeyCounterCollection.cs b/osu.Game/Screens/Play/KeyCounterCollection.cs index f033a20226..0259258636 100644 --- a/osu.Game/Screens/Play/KeyCounterCollection.cs +++ b/osu.Game/Screens/Play/KeyCounterCollection.cs @@ -4,7 +4,7 @@ using System; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; @@ -58,9 +58,10 @@ namespace osu.Game.Screens.Play } private bool isCounting = true; + public bool IsCounting { - get { return isCounting; } + get => isCounting; set { if (value == isCounting) return; @@ -72,9 +73,10 @@ namespace osu.Game.Screens.Play } private int fadeTime; + public int FadeTime { - get { return fadeTime; } + get => fadeTime; set { if (value != fadeTime) @@ -87,9 +89,10 @@ namespace osu.Game.Screens.Play } private Color4 keyDownTextColor = Color4.DarkGray; + public Color4 KeyDownTextColor { - get { return keyDownTextColor; } + get => keyDownTextColor; set { if (value != keyDownTextColor) @@ -102,9 +105,10 @@ namespace osu.Game.Screens.Play } private Color4 keyUpTextColor = Color4.White; + public Color4 KeyUpTextColor { - get { return keyUpTextColor; } + get => keyUpTextColor; set { if (value != keyUpTextColor) @@ -161,6 +165,7 @@ namespace osu.Game.Screens.Play case MouseUpEvent _: return Target.Children.Any(c => c.TriggerEvent(e)); } + return base.Handle(e); } } diff --git a/osu.Game/Screens/Play/KeyCounterKeyboard.cs b/osu.Game/Screens/Play/KeyCounterKeyboard.cs index 9e8d5b9d39..d9b6dca79d 100644 --- a/osu.Game/Screens/Play/KeyCounterKeyboard.cs +++ b/osu.Game/Screens/Play/KeyCounterKeyboard.cs @@ -9,7 +9,9 @@ namespace osu.Game.Screens.Play public class KeyCounterKeyboard : KeyCounter { public Key Key { get; } - public KeyCounterKeyboard(Key key) : base(key.ToString()) + + public KeyCounterKeyboard(Key key) + : base(key.ToString()) { Key = key; } diff --git a/osu.Game/Screens/Play/KeyCounterMouse.cs b/osu.Game/Screens/Play/KeyCounterMouse.cs index 0fe667b403..13dbe40a8b 100644 --- a/osu.Game/Screens/Play/KeyCounterMouse.cs +++ b/osu.Game/Screens/Play/KeyCounterMouse.cs @@ -11,7 +11,8 @@ namespace osu.Game.Screens.Play { public MouseButton Button { get; } - public KeyCounterMouse(MouseButton button) : base(getStringRepresentation(button)) + public KeyCounterMouse(MouseButton button) + : base(getStringRepresentation(button)) { Button = button; } diff --git a/osu.Game/Screens/Play/PauseContainer.cs b/osu.Game/Screens/Play/PauseContainer.cs index 8dae0ab964..8961d91763 100644 --- a/osu.Game/Screens/Play/PauseContainer.cs +++ b/osu.Game/Screens/Play/PauseContainer.cs @@ -4,7 +4,7 @@ using System; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Timing; @@ -32,7 +32,10 @@ namespace osu.Game.Screens.Play protected override Container Content => content; - public int Retries { set { pauseOverlay.Retries = value; } } + public int Retries + { + set => pauseOverlay.Retries = value; + } public bool CanPause => (CheckCanPause?.Invoke() ?? true) && Time.Current >= lastPauseActionTime + pause_cooldown; public bool IsResuming { get; private set; } @@ -78,7 +81,7 @@ namespace osu.Game.Screens.Play { if (!CanPause && !force) return; - if (IsPaused) return; + if (IsPaused.Value) return; // stop the seekable clock (stops the audio eventually) decoupledClock.Stop(); @@ -91,7 +94,7 @@ namespace osu.Game.Screens.Play public void Resume() { - if (!IsPaused) return; + if (!IsPaused.Value) return; IsPaused.Value = false; IsResuming = false; @@ -116,10 +119,10 @@ namespace osu.Game.Screens.Play protected override void Update() { // eagerly pause when we lose window focus (if we are locally playing). - if (!game.IsActive && CanPause) + if (!game.IsActive.Value && CanPause) Pause(); - if (!IsPaused) + if (!IsPaused.Value) framedClock.ProcessFrame(); base.Update(); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 2ab207e47a..bb2211a533 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -8,7 +8,7 @@ using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -19,7 +19,6 @@ using osu.Framework.Threading; using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Configuration; -using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Cursor; using osu.Game.Online.API; @@ -32,7 +31,6 @@ using osu.Game.Scoring; using osu.Game.Screens.Ranking; using osu.Game.Skinning; using osu.Game.Storyboards.Drawables; -using osuTK.Graphics; namespace osu.Game.Screens.Play { @@ -57,6 +55,8 @@ namespace osu.Game.Screens.Play private Bindable mouseWheelDisabled; private Bindable userAudioOffset; + private readonly Bindable storyboardReplacesBackground = new Bindable(); + public int RestartCount; public CursorContainer Cursor => RulesetContainer.Cursor; @@ -72,7 +72,7 @@ namespace osu.Game.Screens.Play [Resolved] private ScoreManager scoreManager { get; set; } - private PauseContainer pauseContainer; + protected PauseContainer PauseContainer { get; private set; } private RulesetInfo ruleset; @@ -80,14 +80,21 @@ namespace osu.Game.Screens.Play private SampleChannel sampleRestart; - protected ScoreProcessor ScoreProcessor; - protected RulesetContainer RulesetContainer; + protected ScoreProcessor ScoreProcessor { get; private set; } + protected RulesetContainer RulesetContainer { get; private set; } - protected HUDOverlay HUDOverlay; + protected HUDOverlay HUDOverlay { get; private set; } private FailOverlay failOverlay; private DrawableStoryboard storyboard; - private Container storyboardContainer; + protected UserDimContainer StoryboardContainer { get; private set; } + + protected virtual UserDimContainer CreateStoryboardContainer() => new UserDimContainer(true) + { + RelativeSizeAxes = Axes.Both, + Alpha = 1, + EnableUserDim = { Value = true } + }; public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true; @@ -159,7 +166,7 @@ namespace osu.Game.Screens.Play // the final usable gameplay clock with user-set offsets applied. var offsetClock = new FramedOffsetClock(platformOffsetClock); - userAudioOffset.ValueChanged += v => offsetClock.Offset = v; + userAudioOffset.ValueChanged += offset => offsetClock.Offset = offset.NewValue; userAudioOffset.TriggerChange(); ScoreProcessor = RulesetContainer.CreateScoreProcessor(); @@ -168,19 +175,15 @@ namespace osu.Game.Screens.Play InternalChildren = new Drawable[] { - pauseContainer = new PauseContainer(offsetClock, adjustableClock) + PauseContainer = new PauseContainer(offsetClock, adjustableClock) { Retries = RestartCount, OnRetry = Restart, OnQuit = performUserRequestedExit, - CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded, - Children = new[] + CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded.Value, + Children = new Container[] { - storyboardContainer = new Container - { - RelativeSizeAxes = Axes.Both, - Alpha = 0, - }, + StoryboardContainer = CreateStoryboardContainer(), new ScalingContainer(ScalingMode.Gameplay) { Child = new LocalSkinOverrideContainer(working.Skin) @@ -236,9 +239,9 @@ namespace osu.Game.Screens.Play HUDOverlay.HoldToQuit.Action = performUserRequestedExit; HUDOverlay.KeyCounter.Visible.BindTo(RulesetContainer.HasReplayLoaded); - RulesetContainer.IsPaused.BindTo(pauseContainer.IsPaused); + RulesetContainer.IsPaused.BindTo(PauseContainer.IsPaused); - if (ShowStoryboard) + if (ShowStoryboard.Value) initializeStoryboard(false); // Bind ScoreProcessor to ourselves @@ -261,6 +264,7 @@ namespace osu.Game.Screens.Play private void performUserRequestedExit() { if (!this.IsCurrentScreen()) return; + this.Exit(); } @@ -296,7 +300,7 @@ namespace osu.Game.Screens.Play if (RulesetContainer.ReplayScore == null) scoreManager.Import(score, true); - this.Push(CreateResults(score)); + this.Push(CreateResults(score)); onCompletionEvent = null; }); @@ -345,6 +349,18 @@ namespace osu.Game.Screens.Play .Delay(250) .FadeIn(250); + ShowStoryboard.ValueChanged += enabled => + { + if (enabled.NewValue) initializeStoryboard(true); + }; + + Background.EnableUserDim.Value = true; + + Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); + StoryboardContainer.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); + + storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable; + Task.Run(() => { sourceClock.Reset(); @@ -356,7 +372,7 @@ namespace osu.Game.Screens.Play this.Delay(750).Schedule(() => { - if (!pauseContainer.IsPaused) + if (!PauseContainer.IsPaused.Value) { adjustableClock.Start(); } @@ -364,8 +380,8 @@ namespace osu.Game.Screens.Play }); }); - pauseContainer.Alpha = 0; - pauseContainer.FadeIn(750, Easing.OutQuint); + PauseContainer.Alpha = 0; + PauseContainer.FadeIn(750, Easing.OutQuint); } public override void OnSuspending(IScreen next) @@ -383,17 +399,16 @@ namespace osu.Game.Screens.Play return true; } - if ((!AllowPause || HasFailed || !ValidForResume || pauseContainer?.IsPaused.Value != false || RulesetContainer?.HasReplayLoaded.Value != false) && (!pauseContainer?.IsResuming ?? true)) + if ((!AllowPause || HasFailed || !ValidForResume || PauseContainer?.IsPaused.Value != false || RulesetContainer?.HasReplayLoaded.Value != false) && (!PauseContainer?.IsResuming ?? true)) { // In the case of replays, we may have changed the playback rate. applyRateFromMods(); - fadeOut(); return base.OnExiting(next); } if (LoadedBeatmapSuccessfully) - pauseContainer?.Pause(); + PauseContainer?.Pause(); return true; } @@ -402,14 +417,16 @@ namespace osu.Game.Screens.Play { float fadeOutDuration = instant ? 0 : 250; this.FadeOut(fadeOutDuration); - Background?.FadeColour(Color4.White, fadeOutDuration, Easing.OutQuint); + + Background.EnableUserDim.Value = false; + storyboardReplacesBackground.Value = false; } - protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !pauseContainer.IsPaused; + protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !PauseContainer.IsPaused.Value; private void initializeStoryboard(bool asyncLoad) { - if (storyboardContainer == null) + if (StoryboardContainer == null || storyboard != null) return; var beatmap = Beatmap.Value; @@ -418,29 +435,9 @@ namespace osu.Game.Screens.Play storyboard.Masking = true; if (asyncLoad) - LoadComponentAsync(storyboard, storyboardContainer.Add); + LoadComponentAsync(storyboard, StoryboardContainer.Add); else - storyboardContainer.Add(storyboard); - } - - protected override void UpdateBackgroundElements() - { - if (!this.IsCurrentScreen()) return; - - base.UpdateBackgroundElements(); - - if (ShowStoryboard && storyboard == null) - initializeStoryboard(true); - - var beatmap = Beatmap.Value; - var storyboardVisible = ShowStoryboard && beatmap.Storyboard.HasDrawable; - - storyboardContainer? - .FadeColour(OsuColour.Gray(BackgroundOpacity), BACKGROUND_FADE_DURATION, Easing.OutQuint) - .FadeTo(storyboardVisible && BackgroundOpacity > 0 ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint); - - if (storyboardVisible && beatmap.Storyboard.ReplacesBackground) - Background?.FadeColour(Color4.Black, BACKGROUND_FADE_DURATION, Easing.OutQuint); + StoryboardContainer.Add(storyboard); } protected virtual Results CreateResults(ScoreInfo score) => new SoloResults(score); diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index c55c05f61c..5c9acade7b 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -78,7 +78,7 @@ namespace osu.Game.Screens.Play Margin = new MarginPadding(25), Children = new PlayerSettingsGroup[] { - visualSettings = new VisualSettings(), + VisualSettings = new VisualSettings(), new InputSettings() } } @@ -143,8 +143,6 @@ namespace osu.Game.Screens.Play { base.LogoArriving(logo, resuming); - logo.RelativePositionAxes = Axes.Both; - logo.ScaleTo(new Vector2(0.15f), 300, Easing.In); logo.MoveTo(new Vector2(0.5f), 300, Easing.In); logo.FadeIn(350); @@ -153,23 +151,31 @@ namespace osu.Game.Screens.Play } private ScheduledDelegate pushDebounce; - private VisualSettings visualSettings; + protected VisualSettings VisualSettings; private bool readyForPush => player.LoadState == LoadState.Ready && IsHovered && GetContainingInputManager()?.DraggedDrawable == null; protected override bool OnHover(HoverEvent e) { // restore our screen defaults - InitializeBackgroundElements(); + if (this.IsCurrentScreen()) + { + InitializeBackgroundElements(); + Background.EnableUserDim.Value = false; + } + return base.OnHover(e); } protected override void OnHoverLost(HoverLostEvent e) { - if (GetContainingInputManager()?.HoveredDrawables.Contains(visualSettings) == true) + if (GetContainingInputManager()?.HoveredDrawables.Contains(VisualSettings) == true) { - // show user setting preview + // Update background elements is only being called here because blur logic still exists in Player. + // Will need to be removed when resolving https://github.com/ppy/osu/issues/4322 UpdateBackgroundElements(); + if (this.IsCurrentScreen()) + Background.EnableUserDim.Value = true; } base.OnHoverLost(e); @@ -243,6 +249,8 @@ namespace osu.Game.Screens.Play this.FadeOut(150); cancelLoad(); + Background.EnableUserDim.Value = false; + return base.OnExiting(next); } @@ -330,16 +338,14 @@ namespace osu.Game.Screens.Play new OsuSpriteText { Text = new LocalisedString((metadata.TitleUnicode, metadata.Title)), - TextSize = 36, - Font = @"Exo2.0-MediumItalic", + Font = OsuFont.GetFont(size: 36, italics: true), Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, }, new OsuSpriteText { Text = new LocalisedString((metadata.ArtistUnicode, metadata.Artist)), - TextSize = 26, - Font = @"Exo2.0-MediumItalic", + Font = OsuFont.GetFont(size: 26, italics: true), Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, }, @@ -367,8 +373,7 @@ namespace osu.Game.Screens.Play new OsuSpriteText { Text = beatmap?.BeatmapInfo?.Version, - TextSize = 26, - Font = @"Exo2.0-MediumItalic", + Font = OsuFont.GetFont(size: 26, italics: true), Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, Margin = new MarginPadding diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index f752243c52..ebbed299f7 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -1,10 +1,11 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Timing; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; namespace osu.Game.Screens.Play.PlayerSettings @@ -17,7 +18,7 @@ namespace osu.Game.Screens.Play.PlayerSettings public IAdjustableClock AdjustableClock { set; get; } - private readonly PlayerSliderBar sliderbar; + private readonly PlayerSliderBar rateSlider; private readonly OsuSpriteText multiplierText; @@ -42,11 +43,11 @@ namespace osu.Game.Screens.Play.PlayerSettings { Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold), } }, }, - sliderbar = new PlayerSliderBar + rateSlider = new PlayerSliderBar { Bindable = new BindableDouble(1) { @@ -69,9 +70,9 @@ namespace osu.Game.Screens.Play.PlayerSettings var clockRate = AdjustableClock.Rate; // can't trigger this line instantly as the underlying clock may not be ready to accept adjustments yet. - sliderbar.Bindable.ValueChanged += multiplier => AdjustableClock.Rate = clockRate * multiplier; + rateSlider.Bindable.ValueChanged += multiplier => AdjustableClock.Rate = clockRate * multiplier.NewValue; - sliderbar.Bindable.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier:0.0}x", true); + rateSlider.Bindable.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier.NewValue:0.0}x", true); } } } diff --git a/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs b/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs index 7bf3a74f7e..efaeeea79f 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs @@ -34,10 +34,11 @@ namespace osu.Game.Screens.Play.PlayerSettings public bool Expanded { - get { return expanded; } + get => expanded; set { if (expanded == value) return; + expanded = value; content.ClearTransforms(); @@ -94,8 +95,7 @@ namespace osu.Game.Screens.Play.PlayerSettings Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, Text = Title.ToUpperInvariant(), - TextSize = 17, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17), Margin = new MarginPadding { Left = 10 }, }, button = new IconButton diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index 7e01a84da2..328aa1d18e 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -2,11 +2,10 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Screens; using osu.Game.Configuration; -using osu.Game.Graphics; using osu.Game.Screens.Backgrounds; using osuTK; @@ -16,15 +15,12 @@ namespace osu.Game.Screens.Play { protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value); - protected new BackgroundScreenBeatmap Background => base.Background as BackgroundScreenBeatmap; + protected new BackgroundScreenBeatmap Background => (BackgroundScreenBeatmap)base.Background; protected const float BACKGROUND_FADE_DURATION = 800; - protected float BackgroundOpacity => 1 - (float)DimLevel; - #region User Settings - protected Bindable DimLevel; protected Bindable BlurLevel; protected Bindable ShowStoryboard; @@ -33,7 +29,6 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader] private void load(OsuConfigManager config) { - DimLevel = config.GetBindable(OsuSetting.DimLevel); BlurLevel = config.GetBindable(OsuSetting.BlurLevel); ShowStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); } @@ -41,9 +36,7 @@ namespace osu.Game.Screens.Play public override void OnEntering(IScreen last) { base.OnEntering(last); - DimLevel.ValueChanged += _ => UpdateBackgroundElements(); BlurLevel.ValueChanged += _ => UpdateBackgroundElements(); - ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements(); InitializeBackgroundElements(); } @@ -66,7 +59,6 @@ namespace osu.Game.Screens.Play { if (!this.IsCurrentScreen()) return; - Background?.FadeColour(OsuColour.Gray(BackgroundOpacity), BACKGROUND_FADE_DURATION, Easing.OutQuint); Background?.BlurTo(new Vector2((float)BlurLevel.Value * 25), BACKGROUND_FADE_DURATION, Easing.OutQuint); } } diff --git a/osu.Game/Screens/Play/SkipOverlay.cs b/osu.Game/Screens/Play/SkipOverlay.cs index d3db126ae4..010d9228de 100644 --- a/osu.Game/Screens/Play/SkipOverlay.cs +++ b/osu.Game/Screens/Play/SkipOverlay.cs @@ -158,7 +158,7 @@ namespace osu.Game.Screens.Play public Visibility State { - get { return state; } + get => state; set { bool stateChanged = value != state; @@ -273,8 +273,7 @@ namespace osu.Game.Screens.Play Anchor = Anchor.TopCentre, RelativePositionAxes = Axes.Y, Y = 0.7f, - TextSize = 12, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12), Origin = Anchor.Centre, Text = @"SKIP", }, @@ -313,7 +312,7 @@ namespace osu.Game.Screens.Play protected override bool OnClick(ClickEvent e) { - if (!Enabled) + if (!Enabled.Value) return false; sampleConfirm.Play(); diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index ba67882d56..3c7e3b2067 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -9,7 +9,7 @@ using System.Collections.Generic; using osu.Game.Graphics; using osu.Framework.Allocation; using System.Linq; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Timing; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; @@ -35,7 +35,11 @@ namespace osu.Game.Screens.Play public override bool HandlePositionalInput => AllowSeeking; private IClock audioClock; - public IClock AudioClock { set { audioClock = info.AudioClock = value; } } + + public IClock AudioClock + { + set => audioClock = info.AudioClock = value; + } private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; @@ -94,7 +98,7 @@ namespace osu.Game.Screens.Play { Alpha = 0, Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, OnSeek = position => OnSeek?.Invoke(position), }, }; @@ -104,7 +108,7 @@ namespace osu.Game.Screens.Play { State = Visibility.Visible; - replayLoaded.ValueChanged += v => AllowSeeking = v; + replayLoaded.ValueChanged += loaded => AllowSeeking = loaded.NewValue; replayLoaded.TriggerChange(); } @@ -117,11 +121,7 @@ namespace osu.Game.Screens.Play public bool AllowSeeking { - get - { - return allowSeeking; - } - + get => allowSeeking; set { if (allowSeeking == value) return; diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index ee9d711d54..2e7d452fe7 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -20,22 +20,22 @@ namespace osu.Game.Screens.Play public Color4 FillColour { - set { fill.Colour = value; } + set => fill.Colour = value; } public double StartTime { - set { CurrentNumber.MinValue = value; } + set => CurrentNumber.MinValue = value; } public double EndTime { - set { CurrentNumber.MaxValue = value; } + set => CurrentNumber.MaxValue = value; } public double CurrentTime { - set { CurrentNumber.Value = value; } + set => CurrentNumber.Value = value; } public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize) diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index 7471eccff9..369abb53c8 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -29,8 +29,15 @@ namespace osu.Game.Screens.Play public IClock AudioClock; - public double StartTime { set { startTime = value; } } - public double EndTime { set { endTime = value; } } + public double StartTime + { + set => startTime = value; + } + + public double EndTime + { + set => endTime = value; + } [BackgroundDependencyLoader] private void load(OsuColour colours) @@ -42,7 +49,7 @@ namespace osu.Game.Screens.Play Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, Colour = colours.BlueLighter, - Font = @"Venera", + Font = OsuFont.Numeric, Margin = new MarginPadding { Left = margin, @@ -53,14 +60,14 @@ namespace osu.Game.Screens.Play Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, Colour = colours.BlueLighter, - Font = @"Venera", + Font = OsuFont.Numeric, }, timeLeft = new OsuSpriteText { Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, Colour = colours.BlueLighter, - Font = @"Venera", + Font = OsuFont.Numeric, Margin = new MarginPadding { Right = margin, diff --git a/osu.Game/Screens/Play/SquareGraph.cs b/osu.Game/Screens/Play/SquareGraph.cs index ad52c31108..95ac35baa7 100644 --- a/osu.Game/Screens/Play/SquareGraph.cs +++ b/osu.Game/Screens/Play/SquareGraph.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using osu.Framework; using osu.Framework.Caching; using osu.Framework.Extensions.Color4Extensions; @@ -12,22 +13,26 @@ using osu.Framework.Graphics.Containers; using osuTK; using osuTK.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Framework.Allocation; +using osu.Framework.Threading; namespace osu.Game.Screens.Play { - public class SquareGraph : BufferedContainer + public class SquareGraph : Container { - private Column[] columns = { }; + private BufferedContainer columns; - public int ColumnCount => columns.Length; + public int ColumnCount => columns?.Children.Count ?? 0; private int progress; + public int Progress { - get { return progress; } + get => progress; set { if (value == progress) return; + progress = value; redrawProgress(); } @@ -36,36 +41,33 @@ namespace osu.Game.Screens.Play private float[] calculatedValues = { }; // values but adjusted to fit the amount of columns private int[] values; + public int[] Values { - get { return values; } + get => values; set { if (value == values) return; + values = value; layout.Invalidate(); } } private Color4 fillColour; + public Color4 FillColour { - get { return fillColour; } + get => fillColour; set { if (value == fillColour) return; + fillColour = value; redrawFilled(); } } - public SquareGraph() - { - CacheDrawnFrameBuffer = true; - } - - private Cached layout = new Cached(); - public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) { if ((invalidation & Invalidation.DrawSize) > 0) @@ -73,25 +75,70 @@ namespace osu.Game.Screens.Play return base.Invalidate(invalidation, source, shallPropagate); } + private Cached layout = new Cached(); + private ScheduledDelegate scheduledCreate; + protected override void Update() { base.Update(); - if (!layout.IsValid) + if (values != null && !layout.IsValid) { - recreateGraph(); + columns?.FadeOut(500, Easing.OutQuint).Expire(); + + scheduledCreate?.Cancel(); + scheduledCreate = Scheduler.AddDelayed(RecreateGraph, 500); + layout.Validate(); } } + private CancellationTokenSource cts; + + /// + /// Recreates the entire graph. + /// + protected virtual void RecreateGraph() + { + var newColumns = new BufferedContainer + { + CacheDrawnFrameBuffer = true, + RelativeSizeAxes = Axes.Both, + }; + + for (float x = 0; x < DrawWidth; x += Column.WIDTH) + { + newColumns.Add(new Column(DrawHeight) + { + LitColour = fillColour, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Position = new Vector2(x, 0), + State = ColumnState.Dimmed, + }); + } + + cts?.Cancel(); + + LoadComponentAsync(newColumns, c => + { + Child = columns = c; + columns.FadeInFromZero(500, Easing.OutQuint); + + recalculateValues(); + redrawFilled(); + redrawProgress(); + }, (cts = new CancellationTokenSource()).Token); + } + /// /// Redraws all the columns to match their lit/dimmed state. /// private void redrawProgress() { - for (int i = 0; i < columns.Length; i++) + for (int i = 0; i < ColumnCount; i++) columns[i].State = i <= progress ? ColumnState.Lit : ColumnState.Dimmed; - ForceRedraw(); + columns?.ForceRedraw(); } /// @@ -101,7 +148,7 @@ namespace osu.Game.Screens.Play { for (int i = 0; i < ColumnCount; i++) columns[i].Filled = calculatedValues.ElementAtOrDefault(i); - ForceRedraw(); + columns?.ForceRedraw(); } /// @@ -130,34 +177,6 @@ namespace osu.Game.Screens.Play calculatedValues = newValues.ToArray(); } - /// - /// Recreates the entire graph. - /// - private void recreateGraph() - { - var newColumns = new List(); - - for (float x = 0; x < DrawWidth; x += Column.WIDTH) - { - newColumns.Add(new Column - { - LitColour = fillColour, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Height = DrawHeight, - Position = new Vector2(x, 0), - State = ColumnState.Dimmed, - }); - } - - columns = newColumns.ToArray(); - Children = columns; - - recalculateValues(); - redrawFilled(); - redrawProgress(); - } - public class Column : Container, IStateful { protected readonly Color4 EmptyColour = Color4.White.Opacity(20); @@ -174,14 +193,15 @@ namespace osu.Game.Screens.Play private readonly List drawableRows = new List(); private float filled; + public float Filled { - get { return filled; } + get => filled; set { if (value == filled) return; - filled = value; + filled = value; fillActive(); } } @@ -190,12 +210,12 @@ namespace osu.Game.Screens.Play public ColumnState State { - get { return state; } + get => state; set { if (value == state) return; - state = value; + state = value; if (IsLoaded) fillActive(); @@ -203,21 +223,20 @@ namespace osu.Game.Screens.Play } } - public Column() + public Column(float height) { Width = WIDTH; + Height = height; } - protected override void LoadComplete() + [BackgroundDependencyLoader] + private void load() { - for (int r = 0; r < cubeCount; r++) + drawableRows.AddRange(Enumerable.Range(0, (int)cubeCount).Select(r => new Box { - drawableRows.Add(new Box - { - Size = new Vector2(cube_size), - Position = new Vector2(0, r * WIDTH + padding), - }); - } + Size = new Vector2(cube_size), + Position = new Vector2(0, r * WIDTH + padding), + })); Children = drawableRows; diff --git a/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs b/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs index 43c04997e9..043bf55d2b 100644 --- a/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs +++ b/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs @@ -111,8 +111,7 @@ namespace osu.Game.Screens.Ranking.Pages Origin = Anchor.TopCentre, Colour = colours.PinkDarker, Shadow = false, - Font = @"Exo2.0-Bold", - TextSize = 16, + Font = OsuFont.GetFont(weight: FontWeight.Bold), Text = "total score", Margin = new MarginPadding { Bottom = 15 }, }, @@ -214,17 +213,19 @@ namespace osu.Game.Screens.Ranking.Pages { Children = new Drawable[] { - new OsuSpriteText { + new OsuSpriteText + { Text = statistic.Value.ToString().PadLeft(4, '0'), Colour = colours.Gray7, - TextSize = 30, + Font = OsuFont.GetFont(size: 30), Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, - new OsuSpriteText { + new OsuSpriteText + { Text = statistic.Key.GetDescription(), Colour = colours.Gray7, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold), Y = 26, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -307,24 +308,21 @@ namespace osu.Game.Screens.Ranking.Pages Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Shadow = false, - TextSize = 24, - Font = @"Exo2.0-BoldItalic", + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 24, italics: true), }, artist = new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Shadow = false, - TextSize = 20, - Font = @"Exo2.0-BoldItalic", + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 20, italics: true), }, versionMapper = new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Shadow = false, - TextSize = 16, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold), }, } } @@ -338,7 +336,8 @@ namespace osu.Game.Screens.Ranking.Pages versionMapper.Colour = colours.Gray8; var creator = beatmap.Metadata.Author?.Username; - if (!string.IsNullOrEmpty(creator)) { + if (!string.IsNullOrEmpty(creator)) + { versionMapper.Text = $"mapped by {creator}"; if (!string.IsNullOrEmpty(beatmap.Version)) @@ -369,11 +368,10 @@ namespace osu.Game.Screens.Ranking.Pages }, new OsuSpriteText { - Font = @"Exo2.0-RegularItalic", - Text = user.Username, Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, - TextSize = 30, + Text = user.Username, + Font = OsuFont.GetFont(size: 30, weight: FontWeight.Regular, italics: true), Padding = new MarginPadding { Bottom = 10 }, } }; @@ -393,10 +391,11 @@ namespace osu.Game.Screens.Ranking.Pages protected override Easing RollingEasing => Easing.OutPow10; - public SlowScoreCounter(uint leading = 0) : base(leading) + public SlowScoreCounter(uint leading = 0) + : base(leading) { DisplayedCountSpriteText.Shadow = false; - DisplayedCountSpriteText.Font = @"Venera-Light"; + DisplayedCountSpriteText.Font = DisplayedCountSpriteText.Font.With(Typeface.Venera, weight: FontWeight.Light); UseCommaSeparator = true; } } diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index a70d6bd87f..47ac472b9e 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -190,45 +190,43 @@ namespace osu.Game.Screens.Ranking }, new OsuSpriteText { + Anchor = Anchor.CentreLeft, + Origin = Anchor.BottomCentre, Text = $"{Score.MaxCombo}x", - TextSize = 40, RelativePositionAxes = Axes.X, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 40), X = 0.1f, Colour = colours.BlueDarker, - Anchor = Anchor.CentreLeft, - Origin = Anchor.BottomCentre, }, new OsuSpriteText { + Anchor = Anchor.CentreLeft, + Origin = Anchor.TopCentre, Text = "max combo", - TextSize = 20, + Font = OsuFont.GetFont(size: 20), RelativePositionAxes = Axes.X, X = 0.1f, Colour = colours.Gray6, - Anchor = Anchor.CentreLeft, - Origin = Anchor.TopCentre, }, new OsuSpriteText { - Text = $"{Score.Accuracy:P2}", - TextSize = 40, - RelativePositionAxes = Axes.X, - Font = @"Exo2.0-Bold", - X = 0.9f, - Colour = colours.BlueDarker, Anchor = Anchor.CentreLeft, Origin = Anchor.BottomCentre, + Text = $"{Score.Accuracy:P2}", + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 40), + RelativePositionAxes = Axes.X, + X = 0.9f, + Colour = colours.BlueDarker, }, new OsuSpriteText { + Anchor = Anchor.CentreLeft, + Origin = Anchor.TopCentre, Text = "accuracy", - TextSize = 20, + Font = OsuFont.GetFont(size: 20), RelativePositionAxes = Axes.X, X = 0.9f, Colour = colours.Gray6, - Anchor = Anchor.CentreLeft, - Origin = Anchor.TopCentre, }, } }, @@ -268,12 +266,12 @@ namespace osu.Game.Screens.Ranking modeChangeButtons.AddItem(t); modeChangeButtons.Current.Value = modeChangeButtons.Items.FirstOrDefault(); - modeChangeButtons.Current.BindValueChanged(m => + modeChangeButtons.Current.BindValueChanged(page => { currentPage?.FadeOut(); currentPage?.Expire(); - currentPage = m?.CreatePage(); + currentPage = page.NewValue?.CreatePage(); if (currentPage != null) circleInner.Add(currentPage); diff --git a/osu.Game/Screens/ScreenWhiteBox.cs b/osu.Game/Screens/ScreenWhiteBox.cs index d250416b29..b222b91221 100644 --- a/osu.Game/Screens/ScreenWhiteBox.cs +++ b/osu.Game/Screens/ScreenWhiteBox.cs @@ -119,25 +119,25 @@ namespace osu.Game.Screens }, new OsuSpriteText { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, Text = GetType().Name, Colour = getColourFor(GetType()).Lighten(0.8f), - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - TextSize = 50, + Font = OsuFont.GetFont(size: 50), }, new OsuSpriteText { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, Text = "is not yet ready for use!", - TextSize = 20, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, + Font = OsuFont.GetFont(size: 20), }, new OsuSpriteText { - Text = "please check back a bit later.", - TextSize = 14, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, + Text = "please check back a bit later.", + Font = OsuFont.GetFont(size: 14), }, } }, @@ -169,10 +169,7 @@ namespace osu.Game.Screens Text = $@"{t.Name}", BackgroundColour = getColourFor(t), HoverColour = getColourFor(t).Lighten(0.2f), - Action = delegate - { - this.Push(Activator.CreateInstance(t) as Screen); - } + Action = delegate { this.Push(Activator.CreateInstance(t) as Screen); } }); } } diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 1670bf4de8..389f614ef2 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -13,9 +13,9 @@ using osu.Framework.MathUtils; using System.Diagnostics; using System.Threading.Tasks; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Caching; using osu.Framework.Threading; -using osu.Framework.Configuration; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Input.Events; using osu.Game.Beatmaps; @@ -37,7 +37,7 @@ namespace osu.Game.Screens.Select /// public BeatmapInfo SelectedBeatmap => selectedBeatmap?.Beatmap; - private CarouselBeatmap selectedBeatmap => selectedBeatmapSet?.Beatmaps.FirstOrDefault(s => s.State == CarouselItemState.Selected); + private CarouselBeatmap selectedBeatmap => selectedBeatmapSet?.Beatmaps.FirstOrDefault(s => s.State.Value == CarouselItemState.Selected); /// /// The currently selected beatmap set. @@ -130,7 +130,7 @@ namespace osu.Game.Screens.Select config.BindWith(OsuSetting.RandomSelectAlgorithm, RandomAlgorithm); config.BindWith(OsuSetting.SongSelectRightMouseScroll, RightClickScrollingEnabled); - RightClickScrollingEnabled.ValueChanged += v => RightMouseScrollbar = v; + RightClickScrollingEnabled.ValueChanged += enabled => RightMouseScrollbar = enabled.NewValue; RightClickScrollingEnabled.TriggerChange(); } @@ -196,7 +196,7 @@ namespace osu.Game.Screens.Select foreach (CarouselBeatmapSet set in beatmapSets) { - if (!bypassFilters && set.Filtered) + if (!bypassFilters && set.Filtered.Value) continue; var item = set.Beatmaps.FirstOrDefault(p => p.Beatmap.Equals(beatmap)); @@ -205,9 +205,9 @@ namespace osu.Game.Screens.Select // The beatmap that needs to be selected doesn't exist in this set continue; - if (!bypassFilters && item.Filtered) + if (!bypassFilters && item.Filtered.Value) // The beatmap exists in this set but is filtered, so look for the first unfiltered map in the set - item = set.Beatmaps.FirstOrDefault(b => !b.Filtered); + item = set.Beatmaps.FirstOrDefault(b => !b.Filtered.Value); if (item != null) { @@ -226,7 +226,7 @@ namespace osu.Game.Screens.Select /// Whether to skip individual difficulties and only increment over full groups. public void SelectNext(int direction = 1, bool skipDifficulties = true) { - var visibleItems = Items.Where(s => !s.Item.Filtered).ToList(); + var visibleItems = Items.Where(s => !s.Item.Filtered.Value).ToList(); if (!visibleItems.Any()) return; @@ -248,19 +248,20 @@ namespace osu.Game.Screens.Select { var item = visibleItems[currentIndex].Item; - if (item.Filtered || item.State == CarouselItemState.Selected) continue; + if (item.Filtered.Value || item.State.Value == CarouselItemState.Selected) continue; switch (item) { case CarouselBeatmap beatmap: if (skipDifficulties) continue; + select(beatmap); return; case CarouselBeatmapSet set: if (skipDifficulties) select(set); else - select(direction > 0 ? set.Beatmaps.First(b => !b.Filtered) : set.Beatmaps.Last(b => !b.Filtered)); + select(direction > 0 ? set.Beatmaps.First(b => !b.Filtered.Value) : set.Beatmaps.Last(b => !b.Filtered.Value)); return; } } @@ -272,7 +273,7 @@ namespace osu.Game.Screens.Select /// True if a selection could be made, else False. public bool SelectNextRandom() { - var visibleSets = beatmapSets.Where(s => !s.Filtered).ToList(); + var visibleSets = beatmapSets.Where(s => !s.Filtered.Value).ToList(); if (!visibleSets.Any()) return false; @@ -288,7 +289,7 @@ namespace osu.Game.Screens.Select CarouselBeatmapSet set; - if (RandomAlgorithm == RandomSelectAlgorithm.RandomPermutation) + if (RandomAlgorithm.Value == RandomSelectAlgorithm.RandomPermutation) { var notYetVisitedSets = visibleSets.Except(previouslyVisitedRandomSets).ToList(); if (!notYetVisitedSets.Any()) @@ -303,7 +304,7 @@ namespace osu.Game.Screens.Select else set = visibleSets.ElementAt(RNG.Next(visibleSets.Count)); - var visibleBeatmaps = set.Beatmaps.Where(s => !s.Filtered).ToList(); + var visibleBeatmaps = set.Beatmaps.Where(s => !s.Filtered.Value).ToList(); select(visibleBeatmaps[RNG.Next(visibleBeatmaps.Count)]); return true; } @@ -314,9 +315,9 @@ namespace osu.Game.Screens.Select { var beatmap = randomSelectedBeatmaps.Pop(); - if (!beatmap.Filtered) + if (!beatmap.Filtered.Value) { - if (RandomAlgorithm == RandomSelectAlgorithm.RandomPermutation) + if (RandomAlgorithm.Value == RandomSelectAlgorithm.RandomPermutation) previouslyVisitedRandomSets.Remove(selectedBeatmapSet); select(beatmap); break; @@ -327,6 +328,7 @@ namespace osu.Game.Screens.Select private void select(CarouselItem item) { if (item == null) return; + item.State.Value = CarouselItemState.Selected; } @@ -509,9 +511,9 @@ namespace osu.Game.Screens.Select foreach (var c in set.Beatmaps) { - c.State.ValueChanged += v => + c.State.ValueChanged += state => { - if (v == CarouselItemState.Selected) + if (state.NewValue == CarouselItemState.Selected) { selectedBeatmapSet = set; SelectionChanged?.Invoke(c.Beatmap); @@ -549,7 +551,7 @@ namespace osu.Game.Screens.Select case DrawableCarouselBeatmapSet set: lastSet = set; - set.MoveToX(set.Item.State == CarouselItemState.Selected ? -100 : 0, 500, Easing.OutExpo); + set.MoveToX(set.Item.State.Value == CarouselItemState.Selected ? -100 : 0, 500, Easing.OutExpo); set.MoveToY(currentY, 750, Easing.OutExpo); break; case DrawableCarouselBeatmap beatmap: @@ -559,7 +561,7 @@ namespace osu.Game.Screens.Select void performMove(float y, float? startY = null) { if (startY != null) beatmap.MoveTo(new Vector2(0, startY.Value)); - beatmap.MoveToX(beatmap.Item.State == CarouselItemState.Selected ? -50 : 0, 500, Easing.OutExpo); + beatmap.MoveToX(beatmap.Item.State.Value == CarouselItemState.Selected ? -50 : 0, 500, Easing.OutExpo); beatmap.MoveToY(y, 750, Easing.OutExpo); } diff --git a/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs b/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs new file mode 100644 index 0000000000..a37327f2c3 --- /dev/null +++ b/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs @@ -0,0 +1,48 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Game.Beatmaps; +using osu.Game.Graphics; +using osu.Game.Overlays.Dialog; +using osu.Game.Scoring; +using System; +using System.Linq; +using System.Threading.Tasks; + +namespace osu.Game.Screens.Select +{ + public class BeatmapClearScoresDialog : PopupDialog + { + private ScoreManager scoreManager; + + public BeatmapClearScoresDialog(BeatmapInfo beatmap, Action onCompletion) + { + BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}"; + Icon = FontAwesome.fa_eraser; + HeaderText = @"Clearing all local scores. Are you sure?"; + Buttons = new PopupDialogButton[] + { + new PopupDialogOkButton + { + Text = @"Yes. Please.", + Action = () => + { + Task.Run(() => scoreManager.Delete(scoreManager.QueryScores(s => !s.DeletePending && s.Beatmap.ID == beatmap.ID).ToList())) + .ContinueWith(_ => onCompletion); + } + }, + new PopupDialogCancelButton + { + Text = @"No, I'm still attached.", + }, + }; + } + + [BackgroundDependencyLoader] + private void load(ScoreManager scoreManager) + { + this.scoreManager = scoreManager; + } + } +} diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index 03e94c86b6..477037355c 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -20,12 +20,10 @@ namespace osu.Game.Screens.Select public readonly BeatmapLeaderboard Leaderboard; private WorkingBeatmap beatmap; + public WorkingBeatmap Beatmap { - get - { - return beatmap; - } + get => beatmap; set { beatmap = value; diff --git a/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs b/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs index 002633e8b9..f66cd2b29a 100644 --- a/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs +++ b/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs @@ -4,7 +4,7 @@ using System; using osuTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -27,7 +27,7 @@ namespace osu.Game.Screens.Select private void invokeOnFilter() { - OnFilter?.Invoke(tabs.Current, modsCheckbox.Current); + OnFilter?.Invoke(tabs.Current.Value, modsCheckbox.Current.Value); } [BackgroundDependencyLoader] @@ -69,8 +69,8 @@ namespace osu.Game.Screens.Select }, }; - tabs.Current.ValueChanged += item => invokeOnFilter(); - modsCheckbox.Current.ValueChanged += item => invokeOnFilter(); + tabs.Current.ValueChanged += _ => invokeOnFilter(); + modsCheckbox.Current.ValueChanged += _ => invokeOnFilter(); } } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 8877775bba..604d7a132b 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -16,6 +16,7 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Extensions.Color4Extensions; using osu.Game.Screens.Select.Details; using osu.Game.Beatmaps; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; namespace osu.Game.Screens.Select @@ -40,12 +41,14 @@ namespace osu.Game.Screens.Select private ScheduledDelegate pendingBeatmapSwitch; private BeatmapInfo beatmap; + public BeatmapInfo Beatmap { - get { return beatmap; } + get => beatmap; set { if (value == beatmap) return; + beatmap = value; pendingBeatmapSwitch?.Cancel(); @@ -115,6 +118,7 @@ namespace osu.Game.Screens.Select RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, LayoutDuration = transition_duration, + LayoutEasing = Easing.OutQuad, Spacing = new Vector2(spacing * 2), Margin = new MarginPadding { Top = spacing * 2 }, Children = new[] @@ -137,8 +141,7 @@ namespace osu.Game.Screens.Select new OsuSpriteText { Text = "Points of Failure", - Font = @"Exo2.0-Bold", - TextSize = 14, + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14), }, failRetryGraph = new FailRetryGraph { @@ -323,8 +326,7 @@ namespace osu.Game.Screens.Select Child = new OsuSpriteText { Text = title, - Font = @"Exo2.0-Bold", - TextSize = 14, + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14), }, }, }, @@ -337,17 +339,19 @@ namespace osu.Game.Screens.Select { if (string.IsNullOrEmpty(value)) { - textContainer.FadeOut(transition_duration); + this.FadeOut(transition_duration); return; } + this.FadeIn(transition_duration); + setTextAsync(value); } } private void setTextAsync(string text) { - LoadComponentAsync(new OsuTextFlowContainer(s => s.TextSize = 14) + LoadComponentAsync(new OsuTextFlowContainer(s => s.Font = s.Font.With(size: 14)) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index 2a3fc03cc5..32e7215e69 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -8,7 +8,7 @@ using JetBrains.Annotations; using osuTK; using osuTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -203,9 +203,8 @@ namespace osu.Game.Screens.Select { VersionLabel = new OsuSpriteText { - Font = @"Exo2.0-MediumItalic", Text = beatmapInfo.Version, - TextSize = 24, + Font = OsuFont.GetFont(size: 24, italics: true), }, } }, @@ -240,13 +239,11 @@ namespace osu.Game.Screens.Select { TitleLabel = new OsuSpriteText { - Font = @"Exo2.0-MediumItalic", - TextSize = 28, + Font = OsuFont.GetFont(size: 28, italics: true), }, ArtistLabel = new OsuSpriteText { - Font = @"Exo2.0-MediumItalic", - TextSize = 17, + Font = OsuFont.GetFont(size: 17, italics: true), }, MapperContainer = new FillFlowContainer { @@ -266,8 +263,8 @@ namespace osu.Game.Screens.Select } }; - titleBinding.BindValueChanged(value => setMetadata(metadata.Source)); - artistBinding.BindValueChanged(value => setMetadata(metadata.Source), true); + titleBinding.BindValueChanged(_ => setMetadata(metadata.Source)); + artistBinding.BindValueChanged(_ => setMetadata(metadata.Source), true); // no difficulty means it can't have a status to show if (beatmapInfo.Version == null) @@ -345,16 +342,13 @@ namespace osu.Game.Screens.Select { new OsuSpriteText { - Font = @"Exo2.0-Medium", Text = "mapped by ", - TextSize = 15, + Font = OsuFont.GetFont(size: 15), }, new OsuSpriteText { - Font = @"Exo2.0-Bold", - // ReSharper disable once PossibleNullReferenceException (resharper broken?) Text = metadata.Author.Username, - TextSize = 15, + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 15), } }; } @@ -402,10 +396,9 @@ namespace osu.Game.Screens.Select Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Colour = new Color4(255, 221, 85, 255), - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17), Margin = new MarginPadding { Left = 30 }, Text = statistic.Content, - TextSize = 17, } }; } diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs index 206bbeb88e..8e7ea8f964 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs @@ -50,7 +50,7 @@ namespace osu.Game.Screens.Select.Carousel public override void Filter(FilterCriteria criteria) { base.Filter(criteria); - Filtered.Value = InternalChildren.All(i => i.Filtered); + Filtered.Value = InternalChildren.All(i => i.Filtered.Value); } public override string ToString() => BeatmapSet.ToString(); diff --git a/osu.Game/Screens/Select/Carousel/CarouselGroup.cs b/osu.Game/Screens/Select/Carousel/CarouselGroup.cs index dfbbd2d907..5d8f4f0ec6 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselGroup.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselGroup.cs @@ -49,7 +49,7 @@ namespace osu.Game.Screens.Select.Carousel public virtual void AddChild(CarouselItem i) { - i.State.ValueChanged += v => ChildItemStateChanged(i, v); + i.State.ValueChanged += state => ChildItemStateChanged(i, state.NewValue); i.ChildID = ++currentChildID; InternalChildren.Add(i); } @@ -58,9 +58,9 @@ namespace osu.Game.Screens.Select.Carousel { if (items != null) InternalChildren = items; - State.ValueChanged += v => + State.ValueChanged += state => { - switch (v) + switch (state.NewValue) { case CarouselItemState.Collapsed: case CarouselItemState.NotSelected: @@ -69,7 +69,7 @@ namespace osu.Game.Screens.Select.Carousel case CarouselItemState.Selected: InternalChildren.ForEach(c => { - if (c.State == CarouselItemState.Collapsed) c.State.Value = CarouselItemState.NotSelected; + if (c.State.Value == CarouselItemState.Collapsed) c.State.Value = CarouselItemState.NotSelected; }); break; } @@ -96,6 +96,7 @@ namespace osu.Game.Screens.Select.Carousel foreach (var b in InternalChildren) { if (item == b) continue; + b.State.Value = CarouselItemState.NotSelected; } diff --git a/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs b/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs index e32e5fe366..67e8282b76 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs @@ -13,9 +13,9 @@ namespace osu.Game.Screens.Select.Carousel { public CarouselGroupEagerSelect() { - State.ValueChanged += v => + State.ValueChanged += state => { - if (v == CarouselItemState.Selected) + if (state.NewValue == CarouselItemState.Selected) attemptSelection(); }; } @@ -81,10 +81,10 @@ namespace osu.Game.Screens.Select.Carousel if (filteringChildren) return; // we only perform eager selection if we are a currently selected group. - if (State != CarouselItemState.Selected) return; + if (State.Value != CarouselItemState.Selected) return; // we only perform eager selection if none of our children are in a selected state already. - if (Children.Any(i => i.State == CarouselItemState.Selected)) return; + if (Children.Any(i => i.State.Value == CarouselItemState.Selected)) return; PerformSelection(); } @@ -92,8 +92,8 @@ namespace osu.Game.Screens.Select.Carousel protected virtual void PerformSelection() { CarouselItem nextToSelect = - Children.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered) ?? - Children.Reverse().Skip(InternalChildren.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered); + Children.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value) ?? + Children.Reverse().Skip(InternalChildren.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value); if (nextToSelect != null) nextToSelect.State.Value = CarouselItemState.Selected; diff --git a/osu.Game/Screens/Select/Carousel/CarouselItem.cs b/osu.Game/Screens/Select/Carousel/CarouselItem.cs index c7da9d73d0..a0f5969b3c 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselItem.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselItem.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using osu.Framework.Configuration; +using osu.Framework.Bindables; namespace osu.Game.Screens.Select.Carousel { @@ -16,7 +16,7 @@ namespace osu.Game.Screens.Select.Carousel /// /// This item is not in a hidden state. /// - public bool Visible => State.Value != CarouselItemState.Collapsed && !Filtered; + public bool Visible => State.Value != CarouselItemState.Collapsed && !Filtered.Value; public virtual List Drawables { @@ -37,9 +37,9 @@ namespace osu.Game.Screens.Select.Carousel { DrawableRepresentation = new Lazy(CreateDrawableRepresentation); - Filtered.ValueChanged += v => + Filtered.ValueChanged += filtered => { - if (v && State == CarouselItemState.Selected) + if (filtered.NewValue && State.Value == CarouselItemState.Selected) State.Value = CarouselItemState.NotSelected; }; } diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs index 5d28bed4a6..38ca9a9aed 100644 --- a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs +++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs @@ -38,7 +38,8 @@ namespace osu.Game.Screens.Select.Carousel private BeatmapSetOverlay beatmapOverlay; - public DrawableCarouselBeatmap(CarouselBeatmap panel) : base(panel) + public DrawableCarouselBeatmap(CarouselBeatmap panel) + : base(panel) { beatmap = panel.Beatmap; Height *= 0.60f; @@ -100,25 +101,21 @@ namespace osu.Game.Screens.Select.Carousel { new OsuSpriteText { - Font = @"Exo2.0-Medium", Text = beatmap.Version, - TextSize = 20, + Font = OsuFont.GetFont(size: 20), Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft }, new OsuSpriteText { - Font = @"Exo2.0-Medium", Text = "mapped by", - TextSize = 16, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft }, new OsuSpriteText { - Font = @"Exo2.0-MediumItalic", Text = $"{(beatmap.Metadata ?? beatmap.BeatmapSet.Metadata).Author.Username}", - TextSize = 16, + Font = OsuFont.GetFont(italics: true), Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft }, @@ -157,7 +154,7 @@ namespace osu.Game.Screens.Select.Carousel protected override bool OnClick(ClickEvent e) { - if (Item.State == CarouselItemState.Selected) + if (Item.State.Value == CarouselItemState.Selected) startRequested?.Invoke(beatmap); return base.OnClick(e); diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs index e5d12151d8..e01149ebc8 100644 --- a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs +++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; @@ -15,6 +15,7 @@ using osu.Framework.Graphics.UserInterface; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays; @@ -48,11 +49,11 @@ namespace osu.Game.Screens.Select.Carousel Children = new Drawable[] { new DelayedLoadUnloadWrapper(() => - new PanelBackground(manager.GetWorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault())) - { - RelativeSizeAxes = Axes.Both, - OnLoadComplete = d => d.FadeInFromZero(1000, Easing.OutQuint), - }, 300, 5000 + new PanelBackground(manager.GetWorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault())) + { + RelativeSizeAxes = Axes.Both, + OnLoadComplete = d => d.FadeInFromZero(1000, Easing.OutQuint), + }, 300, 5000 ), new FillFlowContainer { @@ -63,16 +64,14 @@ namespace osu.Game.Screens.Select.Carousel { new OsuSpriteText { - Font = @"Exo2.0-BoldItalic", Text = new LocalisedString((beatmapSet.Metadata.TitleUnicode, beatmapSet.Metadata.Title)), - TextSize = 22, + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 22, italics: true), Shadow = true, }, new OsuSpriteText { - Font = @"Exo2.0-SemiBoldItalic", Text = new LocalisedString((beatmapSet.Metadata.ArtistUnicode, beatmapSet.Metadata.Artist)), - TextSize = 17, + Font = OsuFont.GetFont(weight: FontWeight.SemiBold, size: 17, italics: true), Shadow = true, }, new FillFlowContainer @@ -109,7 +108,7 @@ namespace osu.Game.Screens.Select.Carousel { List items = new List(); - if (Item.State == CarouselItemState.NotSelected) + if (Item.State.Value == CarouselItemState.NotSelected) items.Add(new OsuMenuItem("Expand", MenuItemType.Highlighted, () => Item.State.Value = CarouselItemState.Selected)); if (beatmapSet.OnlineBeatmapSetID != null) @@ -189,7 +188,7 @@ namespace osu.Game.Screens.Select.Carousel : base(item.Beatmap) { filtered.BindTo(item.Filtered); - filtered.ValueChanged += v => Schedule(() => this.FadeTo(v ? 0.1f : 1, 100)); + filtered.ValueChanged += isFiltered => Schedule(() => this.FadeTo(isFiltered.NewValue ? 0.1f : 1, 100)); filtered.TriggerChange(); } } diff --git a/osu.Game/Screens/Select/Details/AdvancedStats.cs b/osu.Game/Screens/Select/Details/AdvancedStats.cs index c856f4c85a..52a57dd506 100644 --- a/osu.Game/Screens/Select/Details/AdvancedStats.cs +++ b/osu.Game/Screens/Select/Details/AdvancedStats.cs @@ -20,12 +20,14 @@ namespace osu.Game.Screens.Select.Details private readonly StatisticRow firstValue, hpDrain, accuracy, approachRate, starDifficulty; private BeatmapInfo beatmap; + public BeatmapInfo Beatmap { - get { return beatmap; } + get => beatmap; set { if (value == beatmap) return; + beatmap = value; //mania specific @@ -83,14 +85,15 @@ namespace osu.Game.Screens.Select.Details public string Title { - get { return name.Text; } - set { name.Text = value; } + get => name.Text; + set => name.Text = value; } private float difficultyValue; + public float Value { - get { return difficultyValue; } + get => difficultyValue; set { difficultyValue = value; @@ -101,8 +104,8 @@ namespace osu.Game.Screens.Select.Details public Color4 AccentColour { - get { return bar.AccentColour; } - set { bar.AccentColour = value; } + get => bar.AccentColour; + set => bar.AccentColour = value; } public StatisticRow(float maxValue = 10, bool forceDecimalPlaces = false) @@ -120,7 +123,7 @@ namespace osu.Game.Screens.Select.Details AutoSizeAxes = Axes.Y, Child = name = new OsuSpriteText { - TextSize = 13, + Font = OsuFont.GetFont(size: 13) }, }, bar = new Bar @@ -142,7 +145,7 @@ namespace osu.Game.Screens.Select.Details { Anchor = Anchor.Centre, Origin = Anchor.Centre, - TextSize = 13, + Font = OsuFont.GetFont(size: 13) }, }, }; diff --git a/osu.Game/Screens/Select/Details/FailRetryGraph.cs b/osu.Game/Screens/Select/Details/FailRetryGraph.cs index 32067a69a0..34297d89a4 100644 --- a/osu.Game/Screens/Select/Details/FailRetryGraph.cs +++ b/osu.Game/Screens/Select/Details/FailRetryGraph.cs @@ -17,12 +17,14 @@ namespace osu.Game.Screens.Select.Details private readonly BarGraph retryGraph, failGraph; private BeatmapMetrics metrics; + public BeatmapMetrics Metrics { - get { return metrics; } + get => metrics; set { if (value == metrics) return; + metrics = value; var retries = Metrics?.Retries ?? new int[0]; diff --git a/osu.Game/Screens/Select/Details/UserRatings.cs b/osu.Game/Screens/Select/Details/UserRatings.cs index 70ce6c0e87..b17a3f79e9 100644 --- a/osu.Game/Screens/Select/Details/UserRatings.cs +++ b/osu.Game/Screens/Select/Details/UserRatings.cs @@ -24,10 +24,11 @@ namespace osu.Game.Screens.Select.Details public BeatmapMetrics Metrics { - get { return metrics; } + get => metrics; set { if (value == metrics) return; + metrics = value; const int rating_range = 10; @@ -70,7 +71,7 @@ namespace osu.Game.Screens.Select.Details Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = "User Rating", - TextSize = 13, + Font = OsuFont.GetFont(size: 13) }, ratingsBar = new Bar { @@ -87,14 +88,14 @@ namespace osu.Game.Screens.Select.Details negativeRatings = new OsuSpriteText { Text = "0", - TextSize = 13, + Font = OsuFont.GetFont(size: 13) }, positiveRatings = new OsuSpriteText { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Text = @"0", - TextSize = 13, + Font = OsuFont.GetFont(size: 13) }, }, }, @@ -103,7 +104,7 @@ namespace osu.Game.Screens.Select.Details Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = "Rating Spread", - TextSize = 13, + Font = OsuFont.GetFont(size: 13), Margin = new MarginPadding { Top = 10, Bottom = 5 }, }, }, diff --git a/osu.Game/Screens/Select/Filter/GroupMode.cs b/osu.Game/Screens/Select/Filter/GroupMode.cs index 6abb32bbac..d794c215a3 100644 --- a/osu.Game/Screens/Select/Filter/GroupMode.cs +++ b/osu.Game/Screens/Select/Filter/GroupMode.cs @@ -9,32 +9,46 @@ namespace osu.Game.Screens.Select.Filter { [Description("All")] All, + [Description("Artist")] Artist, + [Description("Author")] Author, + [Description("BPM")] BPM, + [Description("Collections")] Collections, + [Description("Date Added")] DateAdded, + [Description("Difficulty")] Difficulty, + [Description("Favourites")] Favourites, + [Description("Length")] Length, + [Description("My Maps")] MyMaps, + [Description("No Grouping")] NoGrouping, + [Description("Rank Achieved")] RankAchieved, + [Description("Ranked Status")] RankedStatus, + [Description("Recently Played")] RecentlyPlayed, + [Description("Title")] Title } diff --git a/osu.Game/Screens/Select/Filter/SortMode.cs b/osu.Game/Screens/Select/Filter/SortMode.cs index 92ae177011..be76fbc3ba 100644 --- a/osu.Game/Screens/Select/Filter/SortMode.cs +++ b/osu.Game/Screens/Select/Filter/SortMode.cs @@ -9,18 +9,25 @@ namespace osu.Game.Screens.Select.Filter { [Description("Artist")] Artist, + [Description("Author")] Author, + [Description("BPM")] BPM, + [Description("Date Added")] DateAdded, + [Description("Difficulty")] Difficulty, + [Description("Length")] Length, + [Description("Rank Achieved")] RankAchieved, + [Description("Title")] Title } diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 42f6606218..bd0b0dd5cd 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -5,7 +5,7 @@ using System; using osuTK; using osuTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; @@ -32,7 +32,7 @@ namespace osu.Game.Screens.Select public SortMode Sort { - get { return sort; } + get => sort; set { if (sort != value) @@ -47,7 +47,7 @@ namespace osu.Game.Screens.Select public GroupMode Group { - get { return group; } + get => group; set { if (group != value) @@ -63,7 +63,7 @@ namespace osu.Game.Screens.Select Group = group, Sort = sort, SearchText = searchTextBox.Text, - AllowConvertedBeatmaps = showConverted, + AllowConvertedBeatmaps = showConverted.Value, Ruleset = ruleset.Value }; @@ -146,12 +146,12 @@ namespace osu.Game.Screens.Select } }; - searchTextBox.Current.ValueChanged += t => FilterChanged?.Invoke(CreateCriteria()); + searchTextBox.Current.ValueChanged += _ => FilterChanged?.Invoke(CreateCriteria()); groupTabs.PinItem(GroupMode.All); groupTabs.PinItem(GroupMode.RecentlyPlayed); - groupTabs.Current.ValueChanged += val => Group = val; - sortTabs.Current.ValueChanged += val => Sort = val; + groupTabs.Current.ValueChanged += group => Group = group.NewValue; + sortTabs.Current.ValueChanged += sort => Sort = sort.NewValue; } public void Deactivate() @@ -178,7 +178,7 @@ namespace osu.Game.Screens.Select sortTabs.AccentColour = colours.GreenLight; showConverted = config.GetBindable(OsuSetting.ShowConvertedBeatmaps); - showConverted.ValueChanged += val => updateCriteria(); + showConverted.ValueChanged += _ => updateCriteria(); ruleset.BindTo(parentRuleset); ruleset.BindValueChanged(_ => updateCriteria(), true); diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index 4c3b77d483..140010ff54 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -22,7 +22,7 @@ namespace osu.Game.Screens.Select public string SearchText { - get { return searchText; } + get => searchText; set { searchText = value; diff --git a/osu.Game/Screens/Select/FooterButton.cs b/osu.Game/Screens/Select/FooterButton.cs index aa8b48588a..9b98e344ce 100644 --- a/osu.Game/Screens/Select/FooterButton.cs +++ b/osu.Game/Screens/Select/FooterButton.cs @@ -20,7 +20,7 @@ namespace osu.Game.Screens.Select public string Text { - get { return spriteText?.Text; } + get => spriteText?.Text; set { if (spriteText != null) @@ -29,9 +29,10 @@ namespace osu.Game.Screens.Select } private Color4 deselectedColour; + public Color4 DeselectedColour { - get { return deselectedColour; } + get => deselectedColour; set { deselectedColour = value; @@ -41,9 +42,10 @@ namespace osu.Game.Screens.Select } private Color4 selectedColour; + public Color4 SelectedColour { - get { return selectedColour; } + get => selectedColour; set { selectedColour = value; diff --git a/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs b/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs index 9750827553..61370f7ce3 100644 --- a/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs +++ b/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Beatmaps; using osu.Game.Online.API; using osu.Game.Online.API.Requests; @@ -23,7 +23,7 @@ namespace osu.Game.Screens.Select.Leaderboards public BeatmapInfo Beatmap { - get { return beatmap; } + get => beatmap; set { if (beatmap == value) @@ -55,7 +55,7 @@ namespace osu.Game.Screens.Select.Leaderboards { if (Scope == BeatmapLeaderboardScope.Local) { - Scores = scoreManager.QueryScores(s => s.Beatmap.ID == Beatmap.ID).ToArray(); + Scores = scoreManager.QueryScores(s => !s.DeletePending && s.Beatmap.ID == Beatmap.ID).ToArray(); PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores; return null; } diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index cfeaa1785e..f6d758df29 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -2,10 +2,15 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using Humanizer; +using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Screens; +using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; +using osu.Game.Rulesets.Mods; using osu.Game.Screens.Multi; namespace osu.Game.Screens.Select @@ -17,6 +22,15 @@ namespace osu.Game.Screens.Select public string ShortTitle => "song selection"; public override string Title => ShortTitle.Humanize(); + [Resolved(typeof(Room))] + protected Bindable CurrentItem { get; private set; } + + [Resolved] + private Bindable> selectedMods { get; set; } + + [Resolved] + private BeatmapManager beatmaps { get; set; } + public MatchSongSelect() { Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING }; @@ -43,10 +57,17 @@ namespace osu.Game.Screens.Select public override bool OnExiting(IScreen next) { + if (base.OnExiting(next)) + return true; + + Beatmap.Value = beatmaps.GetWorkingBeatmap(CurrentItem.Value?.Beatmap); + Beatmap.Value.Mods.Value = selectedMods.Value = CurrentItem.Value?.RequiredMods; + Ruleset.Value = CurrentItem.Value?.Ruleset; + Beatmap.Disabled = true; Ruleset.Disabled = true; - return base.OnExiting(next); + return false; } public override void OnEntering(IScreen last) diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs index cb1f9234d8..758e1c24c3 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs @@ -28,26 +28,26 @@ namespace osu.Game.Screens.Select.Options public Color4 ButtonColour { - get { return background.Colour; } - set { background.Colour = value; } + get => background.Colour; + set => background.Colour = value; } public FontAwesome Icon { - get { return iconText.Icon; } - set { iconText.Icon = value; } + get => iconText.Icon; + set => iconText.Icon = value; } public string FirstLineText { - get { return firstLine.Text; } - set { firstLine.Text = value; } + get => firstLine.Text; + set => firstLine.Text = value; } public string SecondLineText { - get { return secondLine.Text; } - set { secondLine.Text = value; } + get => secondLine.Text; + set => secondLine.Text = value; } public Key? HotKey; @@ -150,14 +150,14 @@ namespace osu.Game.Screens.Select.Options { Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold), Text = @"", }, secondLine = new OsuSpriteText { Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold), Text = @"", }, }, diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index b5e9cd5f41..d06436c92e 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -65,7 +65,7 @@ namespace osu.Game.Screens.Select LoadComponentAsync(player = new PlayerLoader(() => new Player()), l => { - if (this.IsCurrentScreen())this.Push(player); + if (this.IsCurrentScreen()) this.Push(player); }); return true; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 3be4dd8c0b..866c7e0926 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -1,20 +1,15 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; -using System.Collections.Generic; -using System.Linq; -using osuTK; -using osuTK.Input; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Audio.Track; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Logging; using osu.Framework.Input.Events; +using osu.Framework.Logging; using osu.Framework.Screens; using osu.Framework.Threading; using osu.Game.Beatmaps; @@ -31,7 +26,12 @@ using osu.Game.Screens.Menu; using osu.Game.Screens.Play; using osu.Game.Screens.Select.Options; using osu.Game.Skinning; +using osuTK; using osuTK.Graphics; +using osuTK.Input; +using System; +using System.Collections.Generic; +using System.Linq; namespace osu.Game.Screens.Select { @@ -209,7 +209,7 @@ namespace osu.Game.Screens.Select }); } - BeatmapDetails.Leaderboard.ScoreSelected += s =>this.Push(new SoloResults(s)); + BeatmapDetails.Leaderboard.ScoreSelected += s => this.Push(new SoloResults(s)); } [BackgroundDependencyLoader(true)] @@ -226,7 +226,7 @@ namespace osu.Game.Screens.Select BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.fa_trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue); BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1); - BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2); + BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, () => clearScores(Beatmap.Value.BeatmapInfo), Key.Number2); } if (this.beatmaps == null) @@ -286,7 +286,7 @@ namespace osu.Game.Screens.Select public void Edit(BeatmapInfo beatmap = null) { Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap ?? beatmapNoDebounce); - this.Push(new Editor()); + this.Push(new Editor()); } /// @@ -326,16 +326,16 @@ namespace osu.Game.Screens.Select private ScheduledDelegate selectionChangedDebounce; - private void workingBeatmapChanged(WorkingBeatmap beatmap) + private void workingBeatmapChanged(ValueChangedEvent e) { - if (beatmap is DummyWorkingBeatmap) return; + if (e.NewValue is DummyWorkingBeatmap) return; - if (this.IsCurrentScreen() && !Carousel.SelectBeatmap(beatmap?.BeatmapInfo, false)) + if (this.IsCurrentScreen() && !Carousel.SelectBeatmap(e.NewValue?.BeatmapInfo, false)) // If selecting new beatmap without bypassing filters failed, there's possibly a ruleset mismatch - if (beatmap?.BeatmapInfo?.Ruleset != null && beatmap.BeatmapInfo.Ruleset != decoupledRuleset.Value) + if (e.NewValue?.BeatmapInfo?.Ruleset != null && e.NewValue.BeatmapInfo.Ruleset != decoupledRuleset.Value) { - Ruleset.Value = beatmap.BeatmapInfo.Ruleset; - Carousel.SelectBeatmap(beatmap.BeatmapInfo); + Ruleset.Value = e.NewValue.BeatmapInfo.Ruleset; + Carousel.SelectBeatmap(e.NewValue.BeatmapInfo); } } @@ -444,7 +444,6 @@ namespace osu.Game.Screens.Select { base.LogoArriving(logo, resuming); - logo.RelativePositionAxes = Axes.Both; Vector2 position = new Vector2(0.95f, 0.96f); if (logo.Alpha > 0.8f) @@ -510,13 +509,8 @@ namespace osu.Game.Screens.Select public override bool OnExiting(IScreen next) { - if (ModSelect.State == Visibility.Visible) - { - ModSelect.Hide(); + if (base.OnExiting(next)) return true; - } - - FinaliseSelection(performStartAction: false); beatmapInfoWedge.State = Visibility.Hidden; @@ -530,7 +524,7 @@ namespace osu.Game.Screens.Select SelectedMods.UnbindAll(); Beatmap.Value.Mods.Value = new Mod[] { }; - return base.OnExiting(next); + return false; } protected override void Dispose(bool isDisposing) @@ -599,9 +593,9 @@ namespace osu.Game.Screens.Select { // manual binding to parent ruleset to allow for delayed load in the incoming direction. rulesetNoDebounce = decoupledRuleset.Value = Ruleset.Value; - Ruleset.ValueChanged += updateSelectedRuleset; + Ruleset.ValueChanged += r => updateSelectedRuleset(r.NewValue); - decoupledRuleset.ValueChanged += r => Ruleset.Value = r; + decoupledRuleset.ValueChanged += r => Ruleset.Value = r.NewValue; decoupledRuleset.DisabledChanged += r => Ruleset.Disabled = r; Beatmap.BindDisabledChanged(disabled => Carousel.AllowSelection = !disabled, true); @@ -623,9 +617,19 @@ namespace osu.Game.Screens.Select private void delete(BeatmapSetInfo beatmap) { if (beatmap == null || beatmap.ID <= 0) return; + dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap)); } + private void clearScores(BeatmapInfo beatmap) + { + if (beatmap == null || beatmap.ID <= 0) return; + + dialogOverlay?.Push(new BeatmapClearScoresDialog(beatmap, () => + // schedule done here rather than inside the dialog as the dialog may fade out and never callback. + Schedule(() => BeatmapDetails.Leaderboard.RefreshScores()))); + } + public override bool OnPressed(GlobalAction action) { if (!this.IsCurrentScreen()) return false; diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 5dfefcb777..358b2b222b 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -28,7 +28,8 @@ namespace osu.Game.Skinning { } - protected LegacySkin(SkinInfo skin, IResourceStore storage, AudioManager audioManager, string filename) : base(skin) + protected LegacySkin(SkinInfo skin, IResourceStore storage, AudioManager audioManager, string filename) + : base(skin) { Stream stream = storage.GetStream(filename); if (stream != null) diff --git a/osu.Game/Skinning/LocalSkinOverrideContainer.cs b/osu.Game/Skinning/LocalSkinOverrideContainer.cs index d51c11c5f4..955ef7b65b 100644 --- a/osu.Game/Skinning/LocalSkinOverrideContainer.cs +++ b/osu.Game/Skinning/LocalSkinOverrideContainer.cs @@ -4,7 +4,7 @@ using System; using osu.Framework.Allocation; using osu.Framework.Audio.Sample; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Textures; @@ -33,24 +33,27 @@ namespace osu.Game.Skinning public Drawable GetDrawableComponent(string componentName) { Drawable sourceDrawable; - if (beatmapSkins && (sourceDrawable = source.GetDrawableComponent(componentName)) != null) + if (beatmapSkins.Value && (sourceDrawable = source.GetDrawableComponent(componentName)) != null) return sourceDrawable; + return fallbackSource?.GetDrawableComponent(componentName); } public Texture GetTexture(string componentName) { Texture sourceTexture; - if (beatmapSkins && (sourceTexture = source.GetTexture(componentName)) != null) + if (beatmapSkins.Value && (sourceTexture = source.GetTexture(componentName)) != null) return sourceTexture; + return fallbackSource.GetTexture(componentName); } public SampleChannel GetSample(string sampleName) { SampleChannel sourceChannel; - if (beatmapHitsounds && (sourceChannel = source.GetSample(sampleName)) != null) + if (beatmapHitsounds.Value && (sourceChannel = source.GetSample(sampleName)) != null) return sourceChannel; + return fallbackSource?.GetSample(sampleName); } @@ -58,7 +61,7 @@ namespace osu.Game.Skinning { TValue val; if ((source as Skin)?.Configuration is TConfiguration conf) - if (beatmapSkins && (val = query.Invoke(conf)) != null) + if (beatmapSkins.Value && (val = query.Invoke(conf)) != null) return val; return fallbackSource == null ? default : fallbackSource.GetValue(query); @@ -71,31 +74,27 @@ namespace osu.Game.Skinning var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); fallbackSource = dependencies.Get(); + if (fallbackSource != null) + fallbackSource.SourceChanged += onSourceChanged; + dependencies.CacheAs(this); + var config = dependencies.Get(); + + config.BindWith(OsuSetting.BeatmapSkins, beatmapSkins); + config.BindWith(OsuSetting.BeatmapHitsounds, beatmapHitsounds); + + beatmapSkins.BindValueChanged(_ => onSourceChanged()); + beatmapHitsounds.BindValueChanged(_ => onSourceChanged()); + return dependencies; } - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - config.BindWith(OsuSetting.BeatmapSkins, beatmapSkins); - config.BindWith(OsuSetting.BeatmapHitsounds, beatmapHitsounds); - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - if (fallbackSource != null) - fallbackSource.SourceChanged += onSourceChanged; - - beatmapSkins.BindValueChanged(_ => onSourceChanged()); - beatmapHitsounds.BindValueChanged(_ => onSourceChanged(), true); - } - protected override void Dispose(bool isDisposing) { + // Must be done before base.Dispose() + SourceChanged = null; + base.Dispose(isDisposing); if (fallbackSource != null) diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index de0374f29a..1d14f9cd6a 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -49,6 +49,7 @@ namespace osu.Game.Skinning { if (isDisposed) return; + isDisposed = true; } diff --git a/osu.Game/Skinning/SkinManager.cs b/osu.Game/Skinning/SkinManager.cs index f8831bd26f..f6bbbc8355 100644 --- a/osu.Game/Skinning/SkinManager.cs +++ b/osu.Game/Skinning/SkinManager.cs @@ -8,7 +8,7 @@ using System.Linq.Expressions; using Microsoft.EntityFrameworkCore; using osu.Framework.Audio; using osu.Framework.Audio.Sample; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; using osu.Framework.Platform; @@ -42,10 +42,10 @@ namespace osu.Game.Skinning CurrentSkinInfo.Value = SkinInfo.Default; }; - CurrentSkinInfo.ValueChanged += info => CurrentSkin.Value = getSkin(info); + CurrentSkinInfo.ValueChanged += skin => CurrentSkin.Value = getSkin(skin.NewValue); CurrentSkin.ValueChanged += skin => { - if (skin.SkinInfo != CurrentSkinInfo.Value) + if (skin.NewValue.SkinInfo != CurrentSkinInfo.Value) throw new InvalidOperationException($"Setting {nameof(CurrentSkin)}'s value directly is not supported. Use {nameof(CurrentSkinInfo)} instead."); SourceChanged?.Invoke(); diff --git a/osu.Game/Skinning/SkinStore.cs b/osu.Game/Skinning/SkinStore.cs index e80b03b935..31cadb0a24 100644 --- a/osu.Game/Skinning/SkinStore.cs +++ b/osu.Game/Skinning/SkinStore.cs @@ -1,22 +1,16 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Linq; -using Microsoft.EntityFrameworkCore; using osu.Framework.Platform; using osu.Game.Database; namespace osu.Game.Skinning { - public class SkinStore : MutableDatabaseBackedStore + public class SkinStore : MutableDatabaseBackedStoreWithFileIncludes { public SkinStore(DatabaseContextFactory contextFactory, Storage storage = null) : base(contextFactory, storage) { } - - protected override IQueryable AddIncludesForConsumption(IQueryable query) => - base.AddIncludesForConsumption(query) - .Include(s => s.Files).ThenInclude(f => f.FileInfo); } } diff --git a/osu.Game/Skinning/SkinnableSpriteText.cs b/osu.Game/Skinning/SkinnableSpriteText.cs index b380b74e3d..36e646d743 100644 --- a/osu.Game/Skinning/SkinnableSpriteText.cs +++ b/osu.Game/Skinning/SkinnableSpriteText.cs @@ -30,6 +30,7 @@ namespace osu.Game.Skinning { if (text == value) return; + text = value; if (Drawable is IHasText textDrawable) diff --git a/osu.Game/Storyboards/CommandTimeline.cs b/osu.Game/Storyboards/CommandTimeline.cs index 40e4848874..aa1f137cf3 100644 --- a/osu.Game/Storyboards/CommandTimeline.cs +++ b/osu.Game/Storyboards/CommandTimeline.cs @@ -52,6 +52,7 @@ namespace osu.Game.Storyboards { var result = StartTime.CompareTo(other.StartTime); if (result != 0) return result; + return EndTime.CompareTo(other.EndTime); } diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs index c92fe9812e..f5e1f612ca 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs @@ -20,12 +20,14 @@ namespace osu.Game.Storyboards.Drawables protected override Vector2 DrawScale => new Vector2(Parent.DrawHeight / 480); private bool passing = true; + public bool Passing { - get { return passing; } + get => passing; set { if (passing == value) return; + passing = value; updateLayerVisibility(); } @@ -34,6 +36,7 @@ namespace osu.Game.Storyboards.Drawables public override bool RemoveCompletedTransforms => false; private DependencyContainer dependencies; + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs index 94bb4f2525..0b9ebaf3a7 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs @@ -3,7 +3,7 @@ using osuTK; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Animations; using osu.Framework.Graphics.Textures; @@ -78,6 +78,7 @@ namespace osu.Game.Storyboards.Drawables var texture = textureStore.Get(path); AddFrame(texture, Animation.FrameDelay); } + Animation.ApplyTransforms(this); } } diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs index ac80e5f237..106ebfaf5d 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs @@ -7,7 +7,7 @@ using osu.Framework.Graphics.Containers; namespace osu.Game.Storyboards.Drawables { - public class DrawableStoryboardLayer : Container + public class DrawableStoryboardLayer : LifetimeManagementContainer { public StoryboardLayer Layer { get; private set; } public bool Enabled; @@ -29,7 +29,7 @@ namespace osu.Game.Storyboards.Drawables foreach (var element in Layer.Elements) { if (element.IsDrawable) - Add(element.CreateDrawable()); + AddInternal(element.CreateDrawable()); } } } diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs index 1591823bc1..9fa481b8b6 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs @@ -4,7 +4,7 @@ using System.IO; using osu.Framework.Allocation; using osu.Framework.Audio.Sample; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Beatmaps; diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs index 05cde37eb7..604260a38c 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs @@ -3,7 +3,7 @@ using osuTK; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; diff --git a/osu.Game/Storyboards/Storyboard.cs b/osu.Game/Storyboards/Storyboard.cs index 4128b342c9..0cc753ff7e 100644 --- a/osu.Game/Storyboards/Storyboard.cs +++ b/osu.Game/Storyboards/Storyboard.cs @@ -76,6 +76,7 @@ namespace osu.Game.Storyboards { if (isDisposed) return; + isDisposed = true; } diff --git a/osu.Game/Storyboards/StoryboardSprite.cs b/osu.Game/Storyboards/StoryboardSprite.cs index 3b9ea27e4e..b91b05bd04 100644 --- a/osu.Game/Storyboards/StoryboardSprite.cs +++ b/osu.Game/Storyboards/StoryboardSprite.cs @@ -34,6 +34,7 @@ namespace osu.Game.Storyboards public bool HasCommands => TimelineGroup.HasCommands || loops.Any(l => l.HasCommands); private delegate void DrawablePropertyInitializer(Drawable drawable, T value); + private delegate void DrawableTransformer(Drawable drawable, T value, double duration, Easing easing); public StoryboardSprite(string path, Anchor origin, Vector2 initialPosition) @@ -70,8 +71,7 @@ namespace osu.Game.Storyboards applyCommands(drawable, getCommands(g => g.Alpha, triggeredGroups), (d, value) => d.Alpha = value, (d, value, duration, easing) => d.FadeTo(value, duration, easing)); applyCommands(drawable, getCommands(g => g.BlendingMode, triggeredGroups), (d, value) => d.Blending = value, (d, value, duration, easing) => d.TransformBlendingMode(value, duration), false); - var flippable = drawable as IFlippable; - if (flippable != null) + if (drawable is IFlippable flippable) { applyCommands(drawable, getCommands(g => g.FlipH, triggeredGroups), (d, value) => flippable.FlipH = value, (d, value, duration, easing) => flippable.TransformFlipH(value, duration), false); applyCommands(drawable, getCommands(g => g.FlipV, triggeredGroups), (d, value) => flippable.FlipV = value, (d, value, duration, easing) => flippable.TransformFlipV(value, duration), false); @@ -90,6 +90,7 @@ namespace osu.Game.Storyboards initializeProperty.Invoke(drawable, command.StartValue); initialized = true; } + using (drawable.BeginAbsoluteSequence(command.StartTime)) { transform(drawable, command.StartValue, 0, Easing.None); diff --git a/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs b/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs index be8dff2296..44ac38044d 100644 --- a/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs +++ b/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs @@ -39,6 +39,7 @@ namespace osu.Game.Tests.Beatmaps { if (mappingCounter >= ourResult.Mappings.Count && mappingCounter >= expectedResult.Mappings.Count) break; + if (mappingCounter >= ourResult.Mappings.Count) Assert.Fail($"A conversion did not generate any hitobjects, but should have, for hitobject at time: {expectedResult.Mappings[mappingCounter].StartTime}\n"); else if (mappingCounter >= expectedResult.Mappings.Count) @@ -64,6 +65,7 @@ namespace osu.Game.Tests.Beatmaps { if (objectCounter >= ourMapping.Objects.Count && objectCounter >= expectedMapping.Objects.Count) break; + if (objectCounter >= ourMapping.Objects.Count) Assert.Fail($"The conversion did not generate a hitobject, but should have, for hitobject at time: {expectedMapping.StartTime}:\n" + $"Expected: {JsonConvert.SerializeObject(expectedMapping.Objects[objectCounter])}\n"); @@ -189,7 +191,10 @@ namespace osu.Game.Tests.Beatmaps public List Objects = new List(); [JsonProperty("Objects")] - private List setObjects { set => Objects = value; } + private List setObjects + { + set => Objects = value; + } public virtual bool Equals(ConvertMapping other) => StartTime.Equals(other?.StartTime); } diff --git a/osu.Game/Tests/Beatmaps/DifficultyCalculatorTest.cs b/osu.Game/Tests/Beatmaps/DifficultyCalculatorTest.cs new file mode 100644 index 0000000000..108fa8ff71 --- /dev/null +++ b/osu.Game/Tests/Beatmaps/DifficultyCalculatorTest.cs @@ -0,0 +1,51 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.IO; +using System.Reflection; +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Formats; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Difficulty; +using osu.Game.Rulesets.Mods; + +namespace osu.Game.Tests.Beatmaps +{ + [TestFixture] + public abstract class DifficultyCalculatorTest + { + private const string resource_namespace = "Testing.Beatmaps"; + + protected abstract string ResourceAssembly { get; } + + protected void Test(double expected, string name, params Mod[] mods) + => Assert.AreEqual(expected, CreateDifficultyCalculator(getBeatmap(name)).Calculate(mods).StarRating); + + private WorkingBeatmap getBeatmap(string name) + { + using (var resStream = openResource($"{resource_namespace}.{name}.osu")) + using (var stream = new StreamReader(resStream)) + { + var decoder = Decoder.GetDecoder(stream); + ((LegacyBeatmapDecoder)decoder).ApplyOffsets = false; + + var working = new TestWorkingBeatmap(decoder.Decode(stream)); + working.BeatmapInfo.Ruleset = CreateRuleset().RulesetInfo; + + return working; + } + } + + private Stream openResource(string name) + { + var localPath = Path.GetDirectoryName(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path)); + return Assembly.LoadFrom(Path.Combine(localPath, $"{ResourceAssembly}.dll")).GetManifestResourceStream($@"{ResourceAssembly}.Resources.{name}"); + } + + protected abstract DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap); + + protected abstract Ruleset CreateRuleset(); + } +} diff --git a/osu.Game/Tests/Beatmaps/TestBeatmap.cs b/osu.Game/Tests/Beatmaps/TestBeatmap.cs index c7b24ac83a..d1263984ac 100644 --- a/osu.Game/Tests/Beatmaps/TestBeatmap.cs +++ b/osu.Game/Tests/Beatmaps/TestBeatmap.cs @@ -30,8 +30,7 @@ namespace osu.Game.Tests.Beatmaps return Decoder.GetDecoder(reader).Decode(reader); } - private const string test_beatmap_data = -@"osu file format v14 + private const string test_beatmap_data = @"osu file format v14 [General] AudioLeadIn: 500 diff --git a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs index bfbfed082a..90b5178169 100644 --- a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs @@ -1,29 +1,133 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Audio.Track; using osu.Framework.Graphics.Textures; +using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Rulesets; +using osuTK; namespace osu.Game.Tests.Beatmaps { public class TestWorkingBeatmap : WorkingBeatmap { - public TestWorkingBeatmap(RulesetInfo ruleset) - : this(new TestBeatmap(ruleset)) + private readonly TrackVirtualManual track; + private readonly IBeatmap beatmap; + + /// + /// Create an instance which creates a for the provided ruleset when requested. + /// + /// The target ruleset. + /// A clock which should be used instead of a stopwatch for virtual time progression. + public TestWorkingBeatmap(RulesetInfo ruleset, IFrameBasedClock referenceClock) + : this(new TestBeatmap(ruleset), referenceClock) { } - public TestWorkingBeatmap(IBeatmap beatmap) + /// + /// Create an instance which provides the when requested. + /// + /// The beatmap + /// An optional clock which should be used instead of a stopwatch for virtual time progression. + public TestWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock referenceClock = null) : base(beatmap.BeatmapInfo) { this.beatmap = beatmap; + + if (referenceClock != null) + track = new TrackVirtualManual(referenceClock); } - private readonly IBeatmap beatmap; protected override IBeatmap GetBeatmap() => beatmap; protected override Texture GetBackground() => null; - protected override Track GetTrack() => null; + protected override Track GetTrack() => track; + + /// + /// A virtual track which tracks a reference clock. + /// + public class TrackVirtualManual : Track + { + private readonly IFrameBasedClock referenceClock; + + private readonly ManualClock clock = new ManualClock(); + + private bool running; + + /// + /// Local offset added to the reference clock to resolve correct time. + /// + private double offset; + + public TrackVirtualManual(IFrameBasedClock referenceClock) + { + this.referenceClock = referenceClock; + Length = double.PositiveInfinity; + } + + public override bool Seek(double seek) + { + offset = MathHelper.Clamp(seek, 0, Length); + lastReferenceTime = null; + return true; + } + + public override void Start() + { + running = true; + } + + public override void Reset() + { + Seek(0); + base.Reset(); + } + + public override void Stop() + { + if (running) + { + running = false; + // on stopping, the current value should be transferred out of the clock, as we can no longer rely on + // the referenceClock (which will still be counting time). + offset = clock.CurrentTime; + lastReferenceTime = null; + } + } + + public override bool IsRunning => running; + + private double? lastReferenceTime; + + public override double CurrentTime => clock.CurrentTime; + + protected override void UpdateState() + { + base.UpdateState(); + + if (running) + { + double refTime = referenceClock.CurrentTime; + + if (!lastReferenceTime.HasValue) + { + // if the clock just started running, the current value should be transferred to the offset + // (to zero the progression of time). + offset -= refTime; + } + + lastReferenceTime = refTime; + } + + clock.CurrentTime = Math.Min((lastReferenceTime ?? 0) + offset, Length); + + if (CurrentTime >= Length) + { + Stop(); + RaiseCompleted(); + } + } + } } } diff --git a/osu.Game/Tests/Visual/EditorClockTestCase.cs b/osu.Game/Tests/Visual/EditorClockTestCase.cs index 3ce91ed052..7f36a0e142 100644 --- a/osu.Game/Tests/Visual/EditorClockTestCase.cs +++ b/osu.Game/Tests/Visual/EditorClockTestCase.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Input.Events; using osu.Framework.Timing; using osu.Game.Beatmaps; @@ -41,10 +42,10 @@ namespace osu.Game.Tests.Visual Beatmap.BindValueChanged(beatmapChanged, true); } - private void beatmapChanged(WorkingBeatmap working) + private void beatmapChanged(ValueChangedEvent e) { - Clock.ControlPointInfo = working.Beatmap.ControlPointInfo; - Clock.ChangeSource((IAdjustableClock)working.Track ?? new StopwatchClock()); + Clock.ControlPointInfo = e.NewValue.Beatmap.ControlPointInfo; + Clock.ChangeSource((IAdjustableClock)e.NewValue.Track ?? new StopwatchClock()); Clock.ProcessFrame(); } diff --git a/osu.Game/Tests/Visual/EditorTestCase.cs b/osu.Game/Tests/Visual/EditorTestCase.cs index bc5f937480..67a1cb6de3 100644 --- a/osu.Game/Tests/Visual/EditorTestCase.cs +++ b/osu.Game/Tests/Visual/EditorTestCase.cs @@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual [BackgroundDependencyLoader] private void load() { - Beatmap.Value = new TestWorkingBeatmap(ruleset.RulesetInfo); + Beatmap.Value = new TestWorkingBeatmap(ruleset.RulesetInfo, null); LoadComponentAsync(new Editor(), LoadScreen); } diff --git a/osu.Game/Tests/Visual/MultiplayerTestCase.cs b/osu.Game/Tests/Visual/MultiplayerTestCase.cs index 578ef6632c..bb866cf750 100644 --- a/osu.Game/Tests/Visual/MultiplayerTestCase.cs +++ b/osu.Game/Tests/Visual/MultiplayerTestCase.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Online.Multiplayer; namespace osu.Game.Tests.Visual @@ -14,7 +14,7 @@ namespace osu.Game.Tests.Visual protected Room Room { - get => currentRoom; + get => currentRoom.Value; set => currentRoom.Value = value; } diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index fb50332dbe..90bd86d0ed 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -5,7 +5,7 @@ using System; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Audio; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Platform; using osu.Framework.Testing; using osu.Game.Beatmaps; diff --git a/osu.Game/Tests/Visual/RateAdjustedBeatmapTestCase.cs b/osu.Game/Tests/Visual/RateAdjustedBeatmapTestCase.cs new file mode 100644 index 0000000000..14b4af1e7d --- /dev/null +++ b/osu.Game/Tests/Visual/RateAdjustedBeatmapTestCase.cs @@ -0,0 +1,19 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +namespace osu.Game.Tests.Visual +{ + /// + /// Test case which adjusts the beatmap's rate to match any speed adjustments in visual tests. + /// + public abstract class RateAdjustedBeatmapTestCase : ScreenTestCase + { + protected override void Update() + { + base.Update(); + + // note that this will override any mod rate application + Beatmap.Value.Track.Rate = Clock.Rate; + } + } +} diff --git a/osu.Game/Tests/Visual/ScrollingTestContainer.cs b/osu.Game/Tests/Visual/ScrollingTestContainer.cs index 43cfb61d1b..f2e03208fd 100644 --- a/osu.Game/Tests/Visual/ScrollingTestContainer.cs +++ b/osu.Game/Tests/Visual/ScrollingTestContainer.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; using osu.Framework.Lists; using osu.Game.Configuration; @@ -20,9 +20,15 @@ namespace osu.Game.Tests.Visual { public SortedList ControlPoints => scrollingInfo.Algorithm.ControlPoints; - public ScrollVisualisationMethod ScrollAlgorithm { set => scrollingInfo.Algorithm.Algorithm = value; } + public ScrollVisualisationMethod ScrollAlgorithm + { + set => scrollingInfo.Algorithm.Algorithm = value; + } - public double TimeRange { set => scrollingInfo.TimeRange.Value = value; } + public double TimeRange + { + set => scrollingInfo.TimeRange.Value = value; + } public IScrollingInfo ScrollingInfo => scrollingInfo; diff --git a/osu.Game/Tests/Visual/TestCasePlayer.cs b/osu.Game/Tests/Visual/TestCasePlayer.cs index a926a06295..5ff798c40d 100644 --- a/osu.Game/Tests/Visual/TestCasePlayer.cs +++ b/osu.Game/Tests/Visual/TestCasePlayer.cs @@ -16,7 +16,7 @@ using osuTK.Graphics; namespace osu.Game.Tests.Visual { - public abstract class TestCasePlayer : ScreenTestCase + public abstract class TestCasePlayer : RateAdjustedBeatmapTestCase { private readonly Ruleset ruleset; @@ -99,7 +99,7 @@ namespace osu.Game.Tests.Visual private Player loadPlayerFor(Ruleset r) { var beatmap = CreateBeatmap(r); - var working = new TestWorkingBeatmap(beatmap); + var working = new TestWorkingBeatmap(beatmap, Clock); workingWeakReferences.Add(working); @@ -121,14 +121,6 @@ namespace osu.Game.Tests.Visual return player; } - protected override void Update() - { - base.Update(); - - // note that this will override any mod rate application - Beatmap.Value.Track.Rate = Clock.Rate; - } - protected virtual Player CreatePlayer(Ruleset ruleset) => new Player { AllowPause = false, diff --git a/osu.Game/Users/Avatar.cs b/osu.Game/Users/Avatar.cs index fca1510182..3df5957ff9 100644 --- a/osu.Game/Users/Avatar.cs +++ b/osu.Game/Users/Avatar.cs @@ -3,7 +3,7 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -65,7 +65,7 @@ namespace osu.Game.Users private void openProfile() { - if (!OpenOnClick) + if (!OpenOnClick.Value) return; if (user != null) @@ -78,8 +78,9 @@ namespace osu.Game.Users protected override bool OnClick(ClickEvent e) { - if (!Enabled) + if (!Enabled.Value) return false; + return base.OnClick(e); } } diff --git a/osu.Game/Users/Country.cs b/osu.Game/Users/Country.cs index e17afbc77f..b513b460bc 100644 --- a/osu.Game/Users/Country.cs +++ b/osu.Game/Users/Country.cs @@ -33,9 +33,10 @@ namespace osu.Game.Users private TextureStore textures; private Country country; + public Country Country { - get { return country; } + get => country; set { if (value == country) diff --git a/osu.Game/Users/UpdateableAvatar.cs b/osu.Game/Users/UpdateableAvatar.cs index 31e3de1f27..cefb91797b 100644 --- a/osu.Game/Users/UpdateableAvatar.cs +++ b/osu.Game/Users/UpdateableAvatar.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -23,7 +23,7 @@ namespace osu.Game.Users public User User { - get { return user; } + get => user; set { if (user?.Id == value?.Id) diff --git a/osu.Game/Users/User.cs b/osu.Game/Users/User.cs index acffd5073b..292ac90245 100644 --- a/osu.Game/Users/User.cs +++ b/osu.Game/Users/User.cs @@ -3,7 +3,7 @@ using System; using Newtonsoft.Json; -using osu.Framework.Configuration; +using osu.Framework.Bindables; namespace osu.Game.Users { @@ -34,8 +34,8 @@ namespace osu.Game.Users [JsonProperty(@"cover_url")] public string CoverUrl { - get { return Cover?.Url; } - set { Cover = new UserCover { Url = value }; } + get => Cover?.Url; + set => Cover = new UserCover { Url = value }; } [JsonProperty(@"cover")] diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index b1bf0c15a5..4dfde04e07 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -5,7 +5,7 @@ using System; using osuTK; using osuTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -116,8 +116,7 @@ namespace osu.Game.Users new OsuSpriteText { Text = user.Username, - TextSize = 18, - Font = @"Exo2.0-SemiBoldItalic", + Font = OsuFont.GetFont(weight: FontWeight.SemiBold, size: 18, italics: true), }, infoContainer = new FillFlowContainer { @@ -173,7 +172,7 @@ namespace osu.Game.Users { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Font = @"Exo2.0-Semibold", + Font = OsuFont.GetFont(weight: FontWeight.SemiBold), }, }, }, @@ -191,8 +190,8 @@ namespace osu.Game.Users }); } - Status.ValueChanged += displayStatus; - Status.ValueChanged += status => statusBg.FadeColour(status?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint); + Status.ValueChanged += status => displayStatus(status.NewValue); + Status.ValueChanged += status => statusBg.FadeColour(status.NewValue?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint); base.Action = ViewProfile = () => { diff --git a/osu.Game/Users/UserStatistics.cs b/osu.Game/Users/UserStatistics.cs index 40f9f06cde..2de54ed8be 100644 --- a/osu.Game/Users/UserStatistics.cs +++ b/osu.Game/Users/UserStatistics.cs @@ -23,7 +23,10 @@ namespace osu.Game.Users public decimal? PP; [JsonProperty(@"pp_rank")] // the API sometimes only returns this value in condensed user responses - private int rank { set => Ranks.Global = value; } + private int rank + { + set => Ranks.Global = value; + } [JsonProperty(@"rank")] public UserRanks Ranks; diff --git a/osu.Game/Users/UserStatus.cs b/osu.Game/Users/UserStatus.cs index 1c34303896..14b4538a00 100644 --- a/osu.Game/Users/UserStatus.cs +++ b/osu.Game/Users/UserStatus.cs @@ -39,7 +39,7 @@ namespace osu.Game.Users public override string Message => @"in Multiplayer Lobby"; } - public class UserStatusSoloGame : UserStatusBusy + public class UserStatusSoloGame : UserStatusBusy { public override string Message => @"Solo Game"; } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 6b94fa4f98..8f9a7cd14b 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -16,7 +16,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index d677ef4e21..499878347b 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -35,7 +35,7 @@ prompt 4 - iPhone Developer + iPhone Distribution true true Entitlements.plist @@ -105,12 +105,12 @@ - - + + - \ No newline at end of file + diff --git a/osu.iOS.sln.DotSettings b/osu.iOS.sln.DotSettings index 3f5bd9d34d..3b2b851d45 100644 --- a/osu.iOS.sln.DotSettings +++ b/osu.iOS.sln.DotSettings @@ -221,6 +221,7 @@ QAT BNG UI + False HINT <?xml version="1.0" encoding="utf-16"?> <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> diff --git a/osu.iOS/AppDelegate.cs b/osu.iOS/AppDelegate.cs index 97621e1e52..058e246ed8 100644 --- a/osu.iOS/AppDelegate.cs +++ b/osu.iOS/AppDelegate.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using Foundation; @@ -10,6 +10,6 @@ namespace osu.iOS [Register("AppDelegate")] public class AppDelegate : GameAppDelegate { - protected override Framework.Game CreateGame() => new OsuGame(); + protected override Framework.Game CreateGame() => new OsuGameIOS(); } } diff --git a/osu.iOS/Info.plist b/osu.iOS/Info.plist index fe711fc03c..0627feab78 100644 --- a/osu.iOS/Info.plist +++ b/osu.iOS/Info.plist @@ -2,6 +2,14 @@ + CFBundleIdentifier + sh.ppy.osulazer + CFBundleName + osu! + CFBundleShortVersionString + 0.1 + CFBundleVersion + 0.1.0 LSRequiresIPhoneOS MinimumOSVersion @@ -17,6 +25,10 @@ armv7 + UIRequiresFullScreen + + UIStatusBarHidden + UISupportedInterfaceOrientations UIInterfaceOrientationPortrait @@ -26,17 +38,5 @@ XSAppIconAssets Assets.xcassets/AppIcon.appiconset - UIStatusBarHidden - - UIRequiresFullScreen - - CFBundleIdentifier - sh.ppy.osulazer - CFBundleName - osu! - CFBundleShortVersionString - 0.1 - CFBundleVersion - 0.1.1 diff --git a/osu.iOS/OsuGameIOS.cs b/osu.iOS/OsuGameIOS.cs new file mode 100644 index 0000000000..6cf18df9a6 --- /dev/null +++ b/osu.iOS/OsuGameIOS.cs @@ -0,0 +1,14 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using Foundation; +using osu.Game; + +namespace osu.iOS +{ + public class OsuGameIOS : OsuGame + { + public override Version AssemblyVersion => new Version(NSBundle.MainBundle.InfoDictionary["CFBundleVersion"].ToString()); + } +} diff --git a/osu.iOS/osu.iOS.csproj b/osu.iOS/osu.iOS.csproj index 9c69dd40ba..9df3ad5516 100644 --- a/osu.iOS/osu.iOS.csproj +++ b/osu.iOS/osu.iOS.csproj @@ -48,6 +48,7 @@ + diff --git a/osu.sln.DotSettings b/osu.sln.DotSettings index 5efd16c357..5363d6dddf 100644 --- a/osu.sln.DotSettings +++ b/osu.sln.DotSettings @@ -6,7 +6,11 @@ ExplicitlyExcluded ExplicitlyExcluded SOLUTION - HINT + WARNING + WARNING + WARNING + HINT + HINT WARNING True @@ -16,6 +20,32 @@ HINT HINT HINT + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING WARNING WARNING WARNING @@ -48,6 +78,7 @@ HINT HINT ERROR + WARNING HINT HINT HINT @@ -62,9 +93,17 @@ WARNING WARNING WARNING + WARNING + WARNING + WARNING + WARNING WARNING + WARNING + WARNING + WARNING WARNING HINT + WARNING HINT HINT HINT @@ -75,6 +114,7 @@ WARNING WARNING WARNING + WARNING HINT DO_NOT_SHOW DO_NOT_SHOW @@ -84,6 +124,8 @@ WARNING WARNING WARNING + WARNING + WARNING ERROR WARNING WARNING @@ -137,10 +179,14 @@ WARNING WARNING WARNING + WARNING HINT DO_NOT_SHOW DO_NOT_SHOW DO_NOT_SHOW + WARNING + WARNING + WARNING WARNING WARNING HINT @@ -158,16 +204,22 @@ WARNING WARNING WARNING + + True WARNING WARNING - HINT + WARNING WARNING WARNING HINT HINT WARNING + WARNING <?xml version="1.0" encoding="utf-16"?><Profile name="Code Cleanup (peppy)"><CSArrangeThisQualifier>True</CSArrangeThisQualifier><CSUseVar><BehavourStyle>CAN_CHANGE_TO_EXPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_EXPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_EXPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReformatCode>True</CSReformatCode><CSUpdateFileHeader>True</CSUpdateFileHeader><CSCodeStyleAttributes ArrangeTypeAccessModifier="False" ArrangeTypeMemberAccessModifier="False" SortModifiers="True" RemoveRedundantParentheses="True" AddMissingParentheses="False" ArrangeBraces="False" ArrangeAttributes="False" ArrangeArgumentsStyle="False" /><XAMLCollapseEmptyTags>False</XAMLCollapseEmptyTags><CSFixBuiltinTypeReferences>True</CSFixBuiltinTypeReferences><CSArrangeQualifiers>True</CSArrangeQualifiers></Profile> Code Cleanup (peppy) + ExpressionBody + ExpressionBody + True True True True @@ -223,6 +275,7 @@ QAT BNG UI + False HINT <?xml version="1.0" encoding="utf-16"?> <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns">