diff --git a/.github/workflows/test-diffcalc.yml b/.github/workflows/test-diffcalc.yml
new file mode 100644
index 0000000000..4274d01bab
--- /dev/null
+++ b/.github/workflows/test-diffcalc.yml
@@ -0,0 +1,163 @@
+# Listens for new PR comments containing !pp check [id], and runs a diffcalc comparison against master.
+# Usage:
+# !pp check 0 | Runs only the osu! ruleset.
+# !pp check 0 2 | Runs only the osu! and catch rulesets.
+#
+
+name: Diffcalc Consistency Checks
+on:
+ issue_comment:
+ types: [ created ]
+
+env:
+ DB_USER: root
+ DB_HOST: 127.0.0.1
+ CONCURRENCY: 4
+ ALLOW_DOWNLOAD: 1
+ SAVE_DOWNLOADED: 1
+
+jobs:
+ diffcalc:
+ name: Diffcalc
+ runs-on: ubuntu-latest
+ continue-on-error: true
+
+ if: |
+ github.event.issue.pull_request &&
+ contains(github.event.comment.body, '!pp check') &&
+ (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER')
+
+ strategy:
+ fail-fast: false
+ matrix:
+ ruleset:
+ - { name: osu, id: 0 }
+ - { name: taiko, id: 1 }
+ - { name: catch, id: 2 }
+ - { name: mania, id: 3 }
+
+ services:
+ mysql:
+ image: mysql:8.0
+ env:
+ MYSQL_ALLOW_EMPTY_PASSWORD: yes
+ ports:
+ - 3306:3306
+ options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
+
+ steps:
+ - name: Verify ruleset
+ if: contains(github.event.comment.body, matrix.ruleset.id) == false
+ run: |
+ echo "${{ github.event.comment.body }} doesn't contain ${{ matrix.ruleset.id }}"
+ exit 1
+
+ - name: Verify MySQL connection from host
+ run: |
+ sudo apt-get install -y mysql-client
+ mysql --host ${{ env.DB_HOST }} -u${{ env.DB_USER }} -e "SHOW DATABASES"
+
+ - name: Create directory structure
+ run: |
+ mkdir -p $GITHUB_WORKSPACE/master/
+ mkdir -p $GITHUB_WORKSPACE/pr/
+
+ # Checkout osu
+ - name: Checkout osu (master)
+ uses: actions/checkout@v2
+ with:
+ repository: ppy/osu
+ path: 'master/osu'
+ - name: Checkout osu (pr)
+ uses: actions/checkout@v2
+ with:
+ path: 'pr/osu'
+
+ # Checkout osu-difficulty-calculator
+ - name: Checkout osu-difficulty-calculator (master)
+ uses: actions/checkout@v2
+ with:
+ repository: ppy/osu-difficulty-calculator
+ path: 'master/osu-difficulty-calculator'
+ - name: Checkout osu-difficulty-calculator (pr)
+ uses: actions/checkout@v2
+ with:
+ repository: ppy/osu-difficulty-calculator
+ path: 'pr/osu-difficulty-calculator'
+
+ - name: Install .NET 5.0.x
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: "5.0.x"
+
+ # Sanity checks to make sure diffcalc is not run when incompatible.
+ - name: Build diffcalc (master)
+ run: |
+ cd $GITHUB_WORKSPACE/master/osu-difficulty-calculator
+ ./UseLocalOsu.sh
+ dotnet build
+ - name: Build diffcalc (pr)
+ run: |
+ cd $GITHUB_WORKSPACE/pr/osu-difficulty-calculator
+ ./UseLocalOsu.sh
+ dotnet build
+
+ # Initial data imports
+ - name: Download + import data
+ run: |
+ PERFORMANCE_DATA_NAME=$(curl https://data.ppy.sh/ | grep performance_${{ matrix.ruleset.name }}_top | tail -1 | awk -F "\"" '{print $2}' | sed 's/\.tar\.bz2//g')
+ BEATMAPS_DATA_NAME=$(curl https://data.ppy.sh/ | grep osu_files | tail -1 | awk -F "\"" '{print $2}' | sed 's/\.tar\.bz2//g')
+
+ # Set env variable for further steps.
+ echo "BEATMAPS_PATH=$GITHUB_WORKSPACE/$BEATMAPS_DATA_NAME" >> $GITHUB_ENV
+
+ cd $GITHUB_WORKSPACE
+
+ wget https://data.ppy.sh/$PERFORMANCE_DATA_NAME.tar.bz2
+ wget https://data.ppy.sh/$BEATMAPS_DATA_NAME.tar.bz2
+ tar -xf $PERFORMANCE_DATA_NAME.tar.bz2
+ tar -xf $BEATMAPS_DATA_NAME.tar.bz2
+
+ cd $GITHUB_WORKSPACE/$PERFORMANCE_DATA_NAME
+
+ mysql --host ${{ env.DB_HOST }} -u${{ env.DB_USER }} -e "CREATE DATABASE osu_master"
+ mysql --host ${{ env.DB_HOST }} -u${{ env.DB_USER }} -e "CREATE DATABASE osu_pr"
+
+ cat *.sql | mysql --host ${{ env.DB_HOST }} -u${{ env.DB_USER }} --database=osu_master
+ cat *.sql | mysql --host ${{ env.DB_HOST }} -u${{ env.DB_USER }} --database=osu_pr
+
+ # Run diffcalc
+ - name: Run diffcalc (master)
+ env:
+ DB_NAME: osu_master
+ run: |
+ cd $GITHUB_WORKSPACE/master/osu-difficulty-calculator/osu.Server.DifficultyCalculator
+ dotnet run -c:Release -- all -m ${{ matrix.ruleset.id }} -ac -c ${{ env.CONCURRENCY }}
+ - name: Run diffcalc (pr)
+ env:
+ DB_NAME: osu_pr
+ run: |
+ cd $GITHUB_WORKSPACE/pr/osu-difficulty-calculator/osu.Server.DifficultyCalculator
+ dotnet run -c:Release -- all -m ${{ matrix.ruleset.id }} -ac -c ${{ env.CONCURRENCY }}
+
+ # Print diffs
+ - name: Print diffs
+ run: |
+ mysql --host ${{ env.DB_HOST }} -u${{ env.DB_USER }} -e "
+ SELECT
+ m.beatmap_id,
+ m.mods,
+ m.diff_unified as 'sr_master',
+ p.diff_unified as 'sr_pr',
+ (p.diff_unified - m.diff_unified) as 'diff'
+ FROM osu_master.osu_beatmap_difficulty m
+ JOIN osu_pr.osu_beatmap_difficulty p
+ ON m.beatmap_id = p.beatmap_id
+ AND m.mode = p.mode
+ AND m.mods = p.mods
+ WHERE abs(m.diff_unified - p.diff_unified) > 0.1
+ ORDER BY abs(m.diff_unified - p.diff_unified)
+ DESC
+ LIMIT 10000;"
+
+ # Todo: Run ppcalc
\ No newline at end of file
diff --git a/.idea/.idea.osu.Desktop/.idea/runConfigurations/Benchmarks.xml b/.idea/.idea.osu.Desktop/.idea/runConfigurations/Benchmarks.xml
index 8fa7608b8e..498a710df9 100644
--- a/.idea/.idea.osu.Desktop/.idea/runConfigurations/Benchmarks.xml
+++ b/.idea/.idea.osu.Desktop/.idea/runConfigurations/Benchmarks.xml
@@ -1,8 +1,8 @@
-
-
-
+
+
+
@@ -14,7 +14,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/.idea.osu/.idea/indexLayout.xml b/.idea/.idea.osu/.idea/indexLayout.xml
index 27ba142e96..7b08163ceb 100644
--- a/.idea/.idea.osu/.idea/indexLayout.xml
+++ b/.idea/.idea.osu/.idea/indexLayout.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/README.md b/README.md
index 8f922f74a7..786ce2589d 100644
--- a/README.md
+++ b/README.md
@@ -31,12 +31,11 @@ If you are looking to install or test osu! without setting up a development envi
**Latest build:**
-| [Windows (x64)](https://github.com/ppy/osu/releases/latest/download/install.exe) | [macOS 10.12+](https://github.com/ppy/osu/releases/latest/download/osu.app.zip) | [Linux (x64)](https://github.com/ppy/osu/releases/latest/download/osu.AppImage) | [iOS(iOS 10+)](https://osu.ppy.sh/home/testflight) | [Android (5+)](https://github.com/ppy/osu/releases/latest/download/sh.ppy.osulazer.apk)
+| [Windows 8.1+ (x64)](https://github.com/ppy/osu/releases/latest/download/install.exe) | [macOS 10.12+](https://github.com/ppy/osu/releases/latest/download/osu.app.zip) | [Linux (x64)](https://github.com/ppy/osu/releases/latest/download/osu.AppImage) | [iOS 10+](https://osu.ppy.sh/home/testflight) | [Android 5+](https://github.com/ppy/osu/releases/latest/download/sh.ppy.osulazer.apk)
| ------------- | ------------- | ------------- | ------------- | ------------- |
- The iOS testflight link may fill up (Apple has a hard limit of 10,000 users). We reset it occasionally when this happens. Please do not ask about this. Check back regularly for link resets or follow [peppy](https://twitter.com/ppy) on twitter for announcements of link resets.
-- When running on Windows 7 or 8.1, *[additional prerequisites](https://docs.microsoft.com/en-us/dotnet/core/install/windows?tabs=net50&pivots=os-windows#dependencies)** may be required to correctly run .NET 5 applications if your operating system is not up-to-date with the latest service packs.
If your platform is not listed above, there is still a chance you can manually build it by following the instructions below.
## Developing a custom ruleset
diff --git a/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/TestSceneOsuGame.cs b/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/TestSceneOsuGame.cs
index 9c512a01ea..536fdfc6df 100644
--- a/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/TestSceneOsuGame.cs
+++ b/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/TestSceneOsuGame.cs
@@ -15,9 +15,6 @@ namespace osu.Game.Rulesets.EmptyFreeform.Tests
[BackgroundDependencyLoader]
private void load(GameHost host, OsuGameBase gameBase)
{
- OsuGame game = new OsuGame();
- game.SetHost(host);
-
Children = new Drawable[]
{
new Box
@@ -25,8 +22,9 @@ namespace osu.Game.Rulesets.EmptyFreeform.Tests
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
- game
};
+
+ AddGame(new OsuGame());
}
}
}
diff --git a/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/osu.Game.Rulesets.EmptyFreeform.Tests.csproj b/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/osu.Game.Rulesets.EmptyFreeform.Tests.csproj
index 3dd6be7307..e28053d0ca 100644
--- a/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/osu.Game.Rulesets.EmptyFreeform.Tests.csproj
+++ b/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/osu.Game.Rulesets.EmptyFreeform.Tests.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs b/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs
index 270d906b01..3cdf44e6f1 100644
--- a/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs
+++ b/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs
@@ -15,9 +15,6 @@ namespace osu.Game.Rulesets.Pippidon.Tests
[BackgroundDependencyLoader]
private void load(GameHost host, OsuGameBase gameBase)
{
- OsuGame game = new OsuGame();
- game.SetHost(host);
-
Children = new Drawable[]
{
new Box
@@ -25,8 +22,9 @@ namespace osu.Game.Rulesets.Pippidon.Tests
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
- game
};
+
+ AddGame(new OsuGame());
}
}
}
diff --git a/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj b/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj
index 0c4bfe0ed7..027bd0b7e2 100644
--- a/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj
+++ b/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/TestSceneOsuGame.cs b/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/TestSceneOsuGame.cs
index aed6abb6bf..4d3f5086d9 100644
--- a/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/TestSceneOsuGame.cs
+++ b/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/TestSceneOsuGame.cs
@@ -15,9 +15,6 @@ namespace osu.Game.Rulesets.EmptyScrolling.Tests
[BackgroundDependencyLoader]
private void load(GameHost host, OsuGameBase gameBase)
{
- OsuGame game = new OsuGame();
- game.SetHost(host);
-
Children = new Drawable[]
{
new Box
@@ -25,8 +22,9 @@ namespace osu.Game.Rulesets.EmptyScrolling.Tests
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
- game
};
+
+ AddGame(new OsuGame());
}
}
}
diff --git a/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/osu.Game.Rulesets.EmptyScrolling.Tests.csproj b/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/osu.Game.Rulesets.EmptyScrolling.Tests.csproj
index bb0a487274..e2c715d385 100644
--- a/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/osu.Game.Rulesets.EmptyScrolling.Tests.csproj
+++ b/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/osu.Game.Rulesets.EmptyScrolling.Tests.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs b/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs
index 270d906b01..3cdf44e6f1 100644
--- a/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs
+++ b/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/TestSceneOsuGame.cs
@@ -15,9 +15,6 @@ namespace osu.Game.Rulesets.Pippidon.Tests
[BackgroundDependencyLoader]
private void load(GameHost host, OsuGameBase gameBase)
{
- OsuGame game = new OsuGame();
- game.SetHost(host);
-
Children = new Drawable[]
{
new Box
@@ -25,8 +22,9 @@ namespace osu.Game.Rulesets.Pippidon.Tests
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
- game
};
+
+ AddGame(new OsuGame());
}
}
}
diff --git a/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj b/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj
index 0c4bfe0ed7..027bd0b7e2 100644
--- a/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj
+++ b/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/osu.Game.Rulesets.Pippidon.Tests.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon/UI/PippidonCharacter.cs b/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon/UI/PippidonCharacter.cs
index dd0a20f1b4..98dba622d0 100644
--- a/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon/UI/PippidonCharacter.cs
+++ b/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon/UI/PippidonCharacter.cs
@@ -8,6 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Containers;
using osuTK;
@@ -61,9 +62,9 @@ namespace osu.Game.Rulesets.Pippidon.UI
}
}
- public bool OnPressed(PippidonAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
- switch (action)
+ switch (e.Action)
{
case PippidonAction.MoveUp:
changeLane(-1);
@@ -78,7 +79,7 @@ namespace osu.Game.Rulesets.Pippidon.UI
}
}
- public void OnReleased(PippidonAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
}
diff --git a/osu.Android.props b/osu.Android.props
index 8a9bf1b9cd..4859510e6c 100644
--- a/osu.Android.props
+++ b/osu.Android.props
@@ -51,11 +51,11 @@
-
-
+
+
-
+
diff --git a/osu.Game.Benchmarks/BenchmarkMod.cs b/osu.Game.Benchmarks/BenchmarkMod.cs
index 050ddf36d5..c5375e9f09 100644
--- a/osu.Game.Benchmarks/BenchmarkMod.cs
+++ b/osu.Game.Benchmarks/BenchmarkMod.cs
@@ -14,9 +14,9 @@ namespace osu.Game.Benchmarks
[Params(1, 10, 100)]
public int Times { get; set; }
- [GlobalSetup]
- public void GlobalSetup()
+ public override void SetUp()
{
+ base.SetUp();
mod = new OsuModDoubleTime();
}
diff --git a/osu.Game.Benchmarks/BenchmarkRuleset.cs b/osu.Game.Benchmarks/BenchmarkRuleset.cs
new file mode 100644
index 0000000000..2835ec9499
--- /dev/null
+++ b/osu.Game.Benchmarks/BenchmarkRuleset.cs
@@ -0,0 +1,62 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using BenchmarkDotNet.Attributes;
+using BenchmarkDotNet.Engines;
+using osu.Game.Online.API;
+using osu.Game.Rulesets.Mods;
+using osu.Game.Rulesets.Osu;
+
+namespace osu.Game.Benchmarks
+{
+ public class BenchmarkRuleset : BenchmarkTest
+ {
+ private OsuRuleset ruleset;
+ private APIMod apiModDoubleTime;
+ private APIMod apiModDifficultyAdjust;
+
+ public override void SetUp()
+ {
+ base.SetUp();
+ ruleset = new OsuRuleset();
+ apiModDoubleTime = new APIMod { Acronym = "DT" };
+ apiModDifficultyAdjust = new APIMod { Acronym = "DA" };
+ }
+
+ [Benchmark]
+ public void BenchmarkToModDoubleTime()
+ {
+ apiModDoubleTime.ToMod(ruleset);
+ }
+
+ [Benchmark]
+ public void BenchmarkToModDifficultyAdjust()
+ {
+ apiModDifficultyAdjust.ToMod(ruleset);
+ }
+
+ [Benchmark]
+ public void BenchmarkGetAllMods()
+ {
+ ruleset.CreateAllMods().Consume(new Consumer());
+ }
+
+ [Benchmark]
+ public void BenchmarkGetAllModsForReference()
+ {
+ ruleset.AllMods.Consume(new Consumer());
+ }
+
+ [Benchmark]
+ public void BenchmarkGetForAcronym()
+ {
+ ruleset.CreateModFromAcronym("DT");
+ }
+
+ [Benchmark]
+ public void BenchmarkGetForType()
+ {
+ ruleset.CreateMod();
+ }
+ }
+}
diff --git a/osu.Game.Benchmarks/Program.cs b/osu.Game.Benchmarks/Program.cs
index c55075fea6..439ced53ab 100644
--- a/osu.Game.Benchmarks/Program.cs
+++ b/osu.Game.Benchmarks/Program.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 BenchmarkDotNet.Configs;
using BenchmarkDotNet.Running;
namespace osu.Game.Benchmarks
@@ -11,7 +12,7 @@ namespace osu.Game.Benchmarks
{
BenchmarkSwitcher
.FromAssembly(typeof(Program).Assembly)
- .Run(args);
+ .Run(args, DefaultConfig.Instance.WithOption(ConfigOptions.DisableOptimizationsValidator, true));
}
}
}
diff --git a/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj b/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj
index da8a0540f4..03f39f226c 100644
--- a/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj
+++ b/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj b/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj
index 484da8e22e..6457ec92da 100644
--- a/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj
+++ b/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj
@@ -2,7 +2,7 @@
-
+
diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs b/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
index 73b60f51a4..d0a94767d1 100644
--- a/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
+++ b/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
@@ -44,9 +44,9 @@ namespace osu.Game.Rulesets.Catch.Mods
}
// disable keyboard controls
- public bool OnPressed(CatchAction action) => true;
+ public bool OnPressed(KeyBindingPressEvent e) => true;
- public void OnReleased(CatchAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
}
diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs
index b30c3d82a4..604e878782 100644
--- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs
+++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs
@@ -5,6 +5,7 @@ using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Catch.Objects.Drawables;
using osu.Game.Rulesets.Catch.Replays;
@@ -144,9 +145,9 @@ namespace osu.Game.Rulesets.Catch.UI
Catcher.VisualDirection = Direction.Left;
}
- public bool OnPressed(CatchAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
- switch (action)
+ switch (e.Action)
{
case CatchAction.MoveLeft:
currentDirection--;
@@ -164,9 +165,9 @@ namespace osu.Game.Rulesets.Catch.UI
return false;
}
- public void OnReleased(CatchAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
- switch (action)
+ switch (e.Action)
{
case CatchAction.MoveLeft:
currentDirection++;
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note1-0@2x.png b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note1-0@2x.png
new file mode 100644
index 0000000000..2db5d76e78
Binary files /dev/null and b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note1-0@2x.png differ
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note1-1@2x.png b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note1-1@2x.png
new file mode 100644
index 0000000000..6e7aded39f
Binary files /dev/null and b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note1-1@2x.png differ
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note1H-0@2x.png b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note1H-0@2x.png
new file mode 100644
index 0000000000..f11fb4f853
Binary files /dev/null and b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note1H-0@2x.png differ
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note1H-1@2x.png b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note1H-1@2x.png
new file mode 100644
index 0000000000..4eac5f6f2a
Binary files /dev/null and b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note1H-1@2x.png differ
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note2-0@2x.png b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note2-0@2x.png
new file mode 100644
index 0000000000..456cee5382
Binary files /dev/null and b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note2-0@2x.png differ
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note2-1@2x.png b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note2-1@2x.png
new file mode 100644
index 0000000000..71a09cb4bb
Binary files /dev/null and b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note2-1@2x.png differ
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note2H@2x.png b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note2H@2x.png
new file mode 100644
index 0000000000..e6da7a1055
Binary files /dev/null and b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-note2H@2x.png differ
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-noteS@2x.png b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-noteS@2x.png
new file mode 100644
index 0000000000..c9bc23e8d9
Binary files /dev/null and b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-noteS@2x.png differ
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-noteSH@2x.png b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-noteSH@2x.png
new file mode 100644
index 0000000000..c9bc23e8d9
Binary files /dev/null and b/osu.Game.Rulesets.Mania.Tests/Resources/metrics-skin/mania-noteSH@2x.png differ
diff --git a/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaHitObjectTestScene.cs b/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaHitObjectTestScene.cs
index b7d7af6b8c..68cf3b67df 100644
--- a/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaHitObjectTestScene.cs
+++ b/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaHitObjectTestScene.cs
@@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
{
c.Add(CreateHitObject().With(h =>
{
- h.HitObject.StartTime = START_TIME;
+ h.HitObject.StartTime = Time.Current + 5000;
h.AccentColour.Value = Color4.Orange;
}));
})
@@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
{
c.Add(CreateHitObject().With(h =>
{
- h.HitObject.StartTime = START_TIME;
+ h.HitObject.StartTime = Time.Current + 5000;
h.AccentColour.Value = Color4.Orange;
}));
})
diff --git a/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaSkinnableTestScene.cs b/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaSkinnableTestScene.cs
index 1d84a2dfcb..ddfd057cd8 100644
--- a/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaSkinnableTestScene.cs
+++ b/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaSkinnableTestScene.cs
@@ -19,8 +19,6 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
///
public abstract class ManiaSkinnableTestScene : SkinnableTestScene
{
- protected const double START_TIME = 1000000000;
-
[Cached(Type = typeof(IScrollingInfo))]
private readonly TestScrollingInfo scrollingInfo = new TestScrollingInfo();
@@ -55,27 +53,8 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
public readonly Bindable Direction = new Bindable();
IBindable IScrollingInfo.Direction => Direction;
- IBindable IScrollingInfo.TimeRange { get; } = new Bindable(1000);
- IScrollAlgorithm IScrollingInfo.Algorithm { get; } = new ZeroScrollAlgorithm();
- }
-
- private class ZeroScrollAlgorithm : IScrollAlgorithm
- {
- public double GetDisplayStartTime(double originTime, float offset, double timeRange, float scrollLength)
- => double.MinValue;
-
- public float GetLength(double startTime, double endTime, double timeRange, float scrollLength)
- => scrollLength;
-
- public float PositionAt(double time, double currentTime, double timeRange, float scrollLength)
- => (float)((time - START_TIME) / timeRange) * scrollLength;
-
- public double TimeAt(float position, double currentTime, double timeRange, float scrollLength)
- => 0;
-
- public void Reset()
- {
- }
+ IBindable IScrollingInfo.TimeRange { get; } = new Bindable(5000);
+ IScrollAlgorithm IScrollingInfo.Algorithm { get; } = new ConstantScrollAlgorithm();
}
}
}
diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneDrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneDrawableManiaHitObject.cs
index 4a6c59e297..92c95b8fde 100644
--- a/osu.Game.Rulesets.Mania.Tests/TestSceneDrawableManiaHitObject.cs
+++ b/osu.Game.Rulesets.Mania.Tests/TestSceneDrawableManiaHitObject.cs
@@ -3,6 +3,7 @@
using NUnit.Framework;
using osu.Framework.Graphics;
+using osu.Framework.Input.Events;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
@@ -58,7 +59,7 @@ namespace osu.Game.Rulesets.Mania.Tests
AddStep("Hold key", () =>
{
clock.CurrentTime = 0;
- note.OnPressed(ManiaAction.Key1);
+ note.OnPressed(new KeyBindingPressEvent(GetContainingInputManager().CurrentState, ManiaAction.Key1));
});
AddStep("progress time", () => clock.CurrentTime = 500);
AddAssert("head is visible", () => note.Head.Alpha == 1);
diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneTimingBasedNoteColouring.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneTimingBasedNoteColouring.cs
index e14ad92842..449a6ff23d 100644
--- a/osu.Game.Rulesets.Mania.Tests/TestSceneTimingBasedNoteColouring.cs
+++ b/osu.Game.Rulesets.Mania.Tests/TestSceneTimingBasedNoteColouring.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.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Allocation;
@@ -13,6 +14,10 @@ using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Configuration;
using osu.Framework.Bindables;
+using osu.Framework.Testing;
+using osu.Framework.Utils;
+using osu.Game.Rulesets.Mania.Objects.Drawables;
+using osu.Game.Rulesets.Mania.UI;
namespace osu.Game.Rulesets.Mania.Tests
{
@@ -22,14 +27,65 @@ namespace osu.Game.Rulesets.Mania.Tests
[Resolved]
private RulesetConfigCache configCache { get; set; }
- private readonly Bindable configTimingBasedNoteColouring = new Bindable();
+ private Bindable configTimingBasedNoteColouring;
- protected override void LoadComplete()
+ private ManualClock clock;
+ private DrawableManiaRuleset drawableRuleset;
+
+ [SetUpSteps]
+ public void SetUpSteps()
+ {
+ AddStep("setup hierarchy", () => Child = new Container
+ {
+ Clock = new FramedClock(clock = new ManualClock()),
+ RelativeSizeAxes = Axes.Both,
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Children = new[]
+ {
+ drawableRuleset = (DrawableManiaRuleset)Ruleset.Value.CreateInstance().CreateDrawableRulesetWith(createTestBeatmap())
+ }
+ });
+ AddStep("retrieve config bindable", () =>
+ {
+ var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance());
+ configTimingBasedNoteColouring = config.GetBindable(ManiaRulesetSetting.TimingBasedNoteColouring);
+ });
+ }
+
+ [Test]
+ public void TestSimple()
+ {
+ AddStep("enable", () => configTimingBasedNoteColouring.Value = true);
+ AddStep("disable", () => configTimingBasedNoteColouring.Value = false);
+ }
+
+ [Test]
+ public void TestToggleOffScreen()
+ {
+ AddStep("enable", () => configTimingBasedNoteColouring.Value = true);
+
+ seekTo(10000);
+ AddStep("disable", () => configTimingBasedNoteColouring.Value = false);
+ seekTo(0);
+ AddAssert("all notes not coloured", () => this.ChildrenOfType().All(note => note.Colour == Colour4.White));
+
+ seekTo(10000);
+ AddStep("enable again", () => configTimingBasedNoteColouring.Value = true);
+ seekTo(0);
+ AddAssert("some notes coloured", () => this.ChildrenOfType().Any(note => note.Colour != Colour4.White));
+ }
+
+ private void seekTo(double time)
+ {
+ AddStep($"seek to {time}", () => clock.CurrentTime = time);
+ AddUntilStep("wait for seek", () => Precision.AlmostEquals(drawableRuleset.FrameStableClock.CurrentTime, time, 1));
+ }
+
+ private ManiaBeatmap createTestBeatmap()
{
const double beat_length = 500;
- var ruleset = new ManiaRuleset();
-
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 })
{
HitObjects =
@@ -45,7 +101,7 @@ namespace osu.Game.Rulesets.Mania.Tests
new Note { StartTime = beat_length }
},
ControlPointInfo = new ControlPointInfo(),
- BeatmapInfo = { Ruleset = ruleset.RulesetInfo },
+ BeatmapInfo = { Ruleset = Ruleset.Value },
};
foreach (var note in beatmap.HitObjects)
@@ -57,24 +113,7 @@ namespace osu.Game.Rulesets.Mania.Tests
{
BeatLength = beat_length
});
-
- Child = new Container
- {
- Clock = new FramedClock(new ManualClock()),
- RelativeSizeAxes = Axes.Both,
- Anchor = Anchor.Centre,
- Origin = Anchor.Centre,
- Children = new[]
- {
- ruleset.CreateDrawableRulesetWith(beatmap)
- }
- };
-
- var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance());
- config.BindWith(ManiaRulesetSetting.TimingBasedNoteColouring, configTimingBasedNoteColouring);
-
- AddStep("Enable", () => configTimingBasedNoteColouring.Value = true);
- AddStep("Disable", () => configTimingBasedNoteColouring.Value = false);
+ return beatmap;
}
}
}
diff --git a/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj b/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj
index 6df555617b..674a22df98 100644
--- a/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj
+++ b/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj
@@ -2,7 +2,7 @@
-
+
diff --git a/osu.Game.Rulesets.Mania/Edit/Setup/ManiaSetupSection.cs b/osu.Game.Rulesets.Mania/Edit/Setup/ManiaSetupSection.cs
new file mode 100644
index 0000000000..a206aafb8a
--- /dev/null
+++ b/osu.Game.Rulesets.Mania/Edit/Setup/ManiaSetupSection.cs
@@ -0,0 +1,46 @@
+// 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.Graphics;
+using osu.Game.Graphics.UserInterfaceV2;
+using osu.Game.Screens.Edit.Setup;
+
+namespace osu.Game.Rulesets.Mania.Edit.Setup
+{
+ public class ManiaSetupSection : RulesetSetupSection
+ {
+ private LabelledSwitchButton specialStyle;
+
+ public ManiaSetupSection()
+ : base(new ManiaRuleset().RulesetInfo)
+ {
+ }
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ Children = new Drawable[]
+ {
+ specialStyle = new LabelledSwitchButton
+ {
+ Label = "Use special (N+1) style",
+ Description = "Changes one column to act as a classic \"scratch\" or \"special\" column, which can be moved around by the user's skin (to the left/right/centre). Generally used in 5k (4+1) or 8key (7+1) configurations.",
+ Current = { Value = Beatmap.BeatmapInfo.SpecialStyle }
+ }
+ };
+ }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+
+ specialStyle.Current.BindValueChanged(_ => updateBeatmap());
+ }
+
+ private void updateBeatmap()
+ {
+ Beatmap.BeatmapInfo.SpecialStyle = specialStyle.Current.Value;
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs
index f4b6e10af4..1f79dae280 100644
--- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs
+++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs
@@ -27,11 +27,13 @@ using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Configuration;
using osu.Game.Rulesets.Mania.Difficulty;
using osu.Game.Rulesets.Mania.Edit;
+using osu.Game.Rulesets.Mania.Edit.Setup;
using osu.Game.Rulesets.Mania.Scoring;
using osu.Game.Rulesets.Mania.Skinning.Legacy;
using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning;
using osu.Game.Scoring;
+using osu.Game.Screens.Edit.Setup;
using osu.Game.Screens.Ranking.Statistics;
namespace osu.Game.Rulesets.Mania
@@ -390,6 +392,8 @@ namespace osu.Game.Rulesets.Mania
{
return new ManiaFilterCriteria();
}
+
+ public override RulesetSetupSection CreateEditorSetupSection() => new ManiaSetupSection();
}
public enum PlayfieldType
diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs
index 2923a2af2f..4e9781f336 100644
--- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs
+++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs
@@ -7,6 +7,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.Mania.Skinning.Default;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
@@ -253,12 +254,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
HoldBrokenTime = Time.Current;
}
- public bool OnPressed(ManiaAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
if (AllJudged)
return false;
- if (action != Action.Value)
+ if (e.Action != Action.Value)
return false;
// do not run any of this logic when rewinding, as it inverts order of presses/releases.
@@ -288,12 +289,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
isHitting.Value = true;
}
- public void OnReleased(ManiaAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
if (AllJudged)
return;
- if (action != Action.Value)
+ if (e.Action != Action.Value)
return;
// do not run any of this logic when rewinding, as it inverts order of presses/releases.
diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteHead.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteHead.cs
index 8458345998..6722ad8ab8 100644
--- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteHead.cs
+++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteHead.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Rulesets.Mania.Objects.Drawables
@@ -43,9 +44,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
// it will be hidden along with its parenting hold note when required.
}
- public override bool OnPressed(ManiaAction action) => false; // Handled by the hold note
+ public override bool OnPressed(KeyBindingPressEvent e) => false; // Handled by the hold note
- public override void OnReleased(ManiaAction action)
+ public override void OnReleased(KeyBindingReleaseEvent e)
{
}
}
diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTail.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTail.cs
index 18aa3f66d4..803685363c 100644
--- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTail.cs
+++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTail.cs
@@ -3,6 +3,7 @@
using System.Diagnostics;
using osu.Framework.Graphics;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Mania.Objects.Drawables
@@ -68,9 +69,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
});
}
- public override bool OnPressed(ManiaAction action) => false; // Handled by the hold note
+ public override bool OnPressed(KeyBindingPressEvent e) => false; // Handled by the hold note
- public override void OnReleased(ManiaAction action)
+ public override void OnReleased(KeyBindingReleaseEvent e)
{
}
}
diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs
index 33d872dfb6..51727908c9 100644
--- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs
+++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs
@@ -6,6 +6,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mania.Configuration;
@@ -66,6 +67,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
StartTimeBindable.BindValueChanged(_ => updateSnapColour(), true);
}
+ protected override void OnApply()
+ {
+ base.OnApply();
+ updateSnapColour();
+ }
+
protected override void OnDirectionChanged(ValueChangedEvent e)
{
base.OnDirectionChanged(e);
@@ -91,9 +98,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
ApplyResult(r => r.Type = result);
}
- public virtual bool OnPressed(ManiaAction action)
+ public virtual bool OnPressed(KeyBindingPressEvent e)
{
- if (action != Action.Value)
+ if (e.Action != Action.Value)
return false;
if (CheckHittable?.Invoke(this, Time.Current) == false)
@@ -102,7 +109,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
return UpdateResult(true);
}
- public virtual void OnReleased(ManiaAction action)
+ public virtual void OnReleased(KeyBindingReleaseEvent e)
{
}
diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyColumnBackground.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyColumnBackground.cs
index 661e7f66f4..54ddcbd5fe 100644
--- a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyColumnBackground.cs
+++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyColumnBackground.cs
@@ -7,6 +7,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning;
using osuTK;
@@ -76,9 +77,9 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
}
}
- public bool OnPressed(ManiaAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
- if (action == Column.Action.Value)
+ if (e.Action == Column.Action.Value)
{
light.FadeIn();
light.ScaleTo(Vector2.One);
@@ -87,12 +88,12 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
return false;
}
- public void OnReleased(ManiaAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
// Todo: Should be 400 * 100 / CurrentBPM
const double animation_length = 250;
- if (action == Column.Action.Value)
+ if (e.Action == Column.Action.Value)
{
light.FadeTo(0, animation_length);
light.ScaleTo(new Vector2(1, 0), animation_length);
diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyHoldNoteHeadPiece.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyHoldNoteHeadPiece.cs
index 21e5bdd5d6..1e75533442 100644
--- a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyHoldNoteHeadPiece.cs
+++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyHoldNoteHeadPiece.cs
@@ -1,18 +1,18 @@
// 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.Textures;
+using osu.Framework.Graphics;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Mania.Skinning.Legacy
{
public class LegacyHoldNoteHeadPiece : LegacyNotePiece
{
- protected override Texture GetTexture(ISkinSource skin)
+ protected override Drawable GetAnimation(ISkinSource skin)
{
// TODO: Should fallback to the head from default legacy skin instead of note.
- return GetTextureFromLookup(skin, LegacyManiaSkinConfigurationLookups.HoldNoteHeadImage)
- ?? GetTextureFromLookup(skin, LegacyManiaSkinConfigurationLookups.NoteImage);
+ return GetAnimationFromLookup(skin, LegacyManiaSkinConfigurationLookups.HoldNoteHeadImage)
+ ?? GetAnimationFromLookup(skin, LegacyManiaSkinConfigurationLookups.NoteImage);
}
}
}
diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyHoldNoteTailPiece.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyHoldNoteTailPiece.cs
index 232b47ae27..e6d4291d79 100644
--- a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyHoldNoteTailPiece.cs
+++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyHoldNoteTailPiece.cs
@@ -2,7 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Bindables;
-using osu.Framework.Graphics.Textures;
+using osu.Framework.Graphics;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning;
@@ -18,12 +18,12 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
: new ValueChangedEvent(ScrollingDirection.Up, ScrollingDirection.Up));
}
- protected override Texture GetTexture(ISkinSource skin)
+ protected override Drawable GetAnimation(ISkinSource skin)
{
// TODO: Should fallback to the head from default legacy skin instead of note.
- return GetTextureFromLookup(skin, LegacyManiaSkinConfigurationLookups.HoldNoteTailImage)
- ?? GetTextureFromLookup(skin, LegacyManiaSkinConfigurationLookups.HoldNoteHeadImage)
- ?? GetTextureFromLookup(skin, LegacyManiaSkinConfigurationLookups.NoteImage);
+ return GetAnimationFromLookup(skin, LegacyManiaSkinConfigurationLookups.HoldNoteTailImage)
+ ?? GetAnimationFromLookup(skin, LegacyManiaSkinConfigurationLookups.HoldNoteHeadImage)
+ ?? GetAnimationFromLookup(skin, LegacyManiaSkinConfigurationLookups.NoteImage);
}
}
}
diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs
index 10319a7d4d..9c339345c4 100644
--- a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs
+++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs
@@ -7,6 +7,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning;
@@ -86,9 +87,9 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
}
}
- public bool OnPressed(ManiaAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
- if (action == column.Action.Value)
+ if (e.Action == column.Action.Value)
{
upSprite.FadeTo(0);
downSprite.FadeTo(1);
@@ -97,9 +98,9 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
return false;
}
- public void OnReleased(ManiaAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
- if (action == column.Action.Value)
+ if (e.Action == column.Action.Value)
{
upSprite.Delay(LegacyHitExplosion.FADE_IN_DURATION).FadeTo(1);
downSprite.Delay(LegacyHitExplosion.FADE_IN_DURATION).FadeTo(0);
diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyNotePiece.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyNotePiece.cs
index 31279796ce..321a87f8b1 100644
--- a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyNotePiece.cs
+++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyNotePiece.cs
@@ -1,9 +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 JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
+using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.OpenGL.Textures;
using osu.Framework.Graphics.Sprites;
@@ -19,7 +21,9 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
private readonly IBindable direction = new Bindable();
private Container directionContainer;
- private Sprite noteSprite;
+
+ [CanBeNull]
+ private Drawable noteAnimation;
private float? minimumColumnWidth;
@@ -39,7 +43,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
- Child = noteSprite = new Sprite { Texture = GetTexture(skin) }
+ Child = noteAnimation = GetAnimation(skin) ?? Empty()
};
direction.BindTo(scrollingInfo.Direction);
@@ -50,12 +54,18 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
{
base.Update();
- if (noteSprite.Texture != null)
+ Texture texture = null;
+
+ if (noteAnimation is Sprite sprite)
+ texture = sprite.Texture;
+ else if (noteAnimation is TextureAnimation textureAnimation && textureAnimation.FrameCount > 0)
+ texture = textureAnimation.CurrentFrame;
+
+ if (texture != null)
{
// The height is scaled to the minimum column width, if provided.
float minimumWidth = minimumColumnWidth ?? DrawWidth;
-
- noteSprite.Scale = Vector2.Divide(new Vector2(DrawWidth, minimumWidth), noteSprite.Texture.DisplayWidth);
+ noteAnimation.Scale = Vector2.Divide(new Vector2(DrawWidth, minimumWidth), texture.DisplayWidth);
}
}
@@ -73,9 +83,11 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
}
}
- protected virtual Texture GetTexture(ISkinSource skin) => GetTextureFromLookup(skin, LegacyManiaSkinConfigurationLookups.NoteImage);
+ [CanBeNull]
+ protected virtual Drawable GetAnimation(ISkinSource skin) => GetAnimationFromLookup(skin, LegacyManiaSkinConfigurationLookups.NoteImage);
- protected Texture GetTextureFromLookup(ISkin skin, LegacyManiaSkinConfigurationLookups lookup)
+ [CanBeNull]
+ protected Drawable GetAnimationFromLookup(ISkin skin, LegacyManiaSkinConfigurationLookups lookup)
{
string suffix = string.Empty;
@@ -93,7 +105,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
string noteImage = GetColumnSkinConfig(skin, lookup)?.Value
?? $"mania-note{FallbackColumnIndex}{suffix}";
- return skin.GetTexture(noteImage, WrapMode.ClampToEdge, WrapMode.ClampToEdge);
+ return skin.GetAnimation(noteImage, WrapMode.ClampToEdge, WrapMode.ClampToEdge, true, true);
}
}
}
diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs
index f5e30efd91..9d060944cd 100644
--- a/osu.Game.Rulesets.Mania/UI/Column.cs
+++ b/osu.Game.Rulesets.Mania/UI/Column.cs
@@ -10,6 +10,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Pooling;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.UI.Components;
using osu.Game.Rulesets.UI.Scrolling;
@@ -122,16 +123,16 @@ namespace osu.Game.Rulesets.Mania.UI
HitObjectArea.Explosions.Add(hitExplosionPool.Get(e => e.Apply(result)));
}
- public bool OnPressed(ManiaAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
- if (action != Action.Value)
+ if (e.Action != Action.Value)
return false;
sampleTriggerSource.Play();
return true;
}
- public void OnReleased(ManiaAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
}
diff --git a/osu.Game.Rulesets.Mania/UI/Components/ColumnBackground.cs b/osu.Game.Rulesets.Mania/UI/Components/ColumnBackground.cs
index 75cc351310..77ddc6fbbf 100644
--- a/osu.Game.Rulesets.Mania/UI/Components/ColumnBackground.cs
+++ b/osu.Game.Rulesets.Mania/UI/Components/ColumnBackground.cs
@@ -9,6 +9,7 @@ using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Rulesets.UI.Scrolling;
using osuTK.Graphics;
@@ -91,16 +92,16 @@ namespace osu.Game.Rulesets.Mania.UI.Components
direction.Value == ScrollingDirection.Up ? dimPoint : brightPoint);
}
- public bool OnPressed(ManiaAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
- if (action == this.action.Value)
+ if (e.Action == action.Value)
backgroundOverlay.FadeTo(1, 50, Easing.OutQuint).Then().FadeTo(0.5f, 250, Easing.OutQuint);
return false;
}
- public void OnReleased(ManiaAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
- if (action == this.action.Value)
+ if (e.Action == action.Value)
backgroundOverlay.FadeTo(0, 250, Easing.OutQuint);
}
}
diff --git a/osu.Game.Rulesets.Mania/UI/Components/DefaultColumnBackground.cs b/osu.Game.Rulesets.Mania/UI/Components/DefaultColumnBackground.cs
index 4b4bc157d5..807f6a77d9 100644
--- a/osu.Game.Rulesets.Mania/UI/Components/DefaultColumnBackground.cs
+++ b/osu.Game.Rulesets.Mania/UI/Components/DefaultColumnBackground.cs
@@ -9,6 +9,7 @@ using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.UI.Scrolling;
using osuTK.Graphics;
@@ -74,16 +75,16 @@ namespace osu.Game.Rulesets.Mania.UI.Components
}
}
- public bool OnPressed(ManiaAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
- if (action == column.Action.Value)
+ if (e.Action == column.Action.Value)
backgroundOverlay.FadeTo(1, 50, Easing.OutQuint).Then().FadeTo(0.5f, 250, Easing.OutQuint);
return false;
}
- public void OnReleased(ManiaAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
- if (action == column.Action.Value)
+ if (e.Action == column.Action.Value)
backgroundOverlay.FadeTo(0, 250, Easing.OutQuint);
}
}
diff --git a/osu.Game.Rulesets.Mania/UI/Components/DefaultKeyArea.cs b/osu.Game.Rulesets.Mania/UI/Components/DefaultKeyArea.cs
index 47cb9bd45a..267ed1f5f4 100644
--- a/osu.Game.Rulesets.Mania/UI/Components/DefaultKeyArea.cs
+++ b/osu.Game.Rulesets.Mania/UI/Components/DefaultKeyArea.cs
@@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.UI.Scrolling;
using osuTK;
using osuTK.Graphics;
@@ -101,16 +102,16 @@ namespace osu.Game.Rulesets.Mania.UI.Components
}
}
- public bool OnPressed(ManiaAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
- if (action == column.Action.Value)
+ if (e.Action == column.Action.Value)
keyIcon.ScaleTo(1.4f, 50, Easing.OutQuint).Then().ScaleTo(1.3f, 250, Easing.OutQuint);
return false;
}
- public void OnReleased(ManiaAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
- if (action == column.Action.Value)
+ if (e.Action == column.Action.Value)
keyIcon.ScaleTo(1f, 125, Easing.OutQuint);
}
}
diff --git a/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs b/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs
index 34d972e60f..8581f016b1 100644
--- a/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs
+++ b/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs
@@ -37,12 +37,11 @@ namespace osu.Game.Rulesets.Mania.UI
public override void PlayAnimation()
{
- base.PlayAnimation();
-
switch (Result)
{
case HitResult.None:
case HitResult.Miss:
+ base.PlayAnimation();
break;
default:
@@ -52,6 +51,8 @@ namespace osu.Game.Rulesets.Mania.UI
this.Delay(50)
.ScaleTo(0.75f, 250)
.FadeOut(200);
+
+ // osu!mania uses a custom fade length, so the base call is intentionally omitted.
break;
}
}
diff --git a/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs b/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs
index 8d8387378e..19881b5c33 100644
--- a/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs
+++ b/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs
@@ -15,13 +15,13 @@ namespace osu.Game.Rulesets.Osu.Tests
{
protected override string ResourceAssembly => "osu.Game.Rulesets.Osu";
- [TestCase(6.7568168283591499d, "diffcalc-test")]
- [TestCase(1.0348244046058293d, "zero-length-sliders")]
+ [TestCase(6.6634445062299665d, "diffcalc-test")]
+ [TestCase(1.0414203870195022d, "zero-length-sliders")]
public void Test(double expected, string name)
=> base.Test(expected, name);
- [TestCase(8.4783236764532557d, "diffcalc-test")]
- [TestCase(1.2708532136987165d, "zero-length-sliders")]
+ [TestCase(8.3858089051603368d, "diffcalc-test")]
+ [TestCase(1.2723279173428435d, "zero-length-sliders")]
public void TestClockRateAdjusted(double expected, string name)
=> Test(expected, name, new OsuModDoubleTime());
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneCursorParticles.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneCursorParticles.cs
new file mode 100644
index 0000000000..11b1f5b2af
--- /dev/null
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneCursorParticles.cs
@@ -0,0 +1,174 @@
+// 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 NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Testing;
+using osu.Game.Beatmaps;
+using osu.Game.Beatmaps.ControlPoints;
+using osu.Game.Beatmaps.Timing;
+using osu.Game.Rulesets.Objects;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Rulesets.Osu.Objects.Drawables;
+using osu.Game.Rulesets.Osu.Skinning.Legacy;
+using osu.Game.Rulesets.Osu.UI;
+using osu.Game.Skinning;
+using osuTK;
+using osuTK.Input;
+
+namespace osu.Game.Rulesets.Osu.Tests
+{
+ public class TestSceneCursorParticles : TestSceneOsuPlayer
+ {
+ protected override bool Autoplay => autoplay;
+ protected override bool HasCustomSteps => true;
+
+ private bool autoplay;
+ private IBeatmap currentBeatmap;
+
+ [Resolved]
+ private SkinManager skinManager { get; set; }
+
+ protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => currentBeatmap ?? base.CreateBeatmap(ruleset);
+
+ [Test]
+ public void TestLegacyBreakParticles()
+ {
+ LegacyCursorParticles cursorParticles = null;
+
+ createLegacyTest(false, () => new Beatmap
+ {
+ Breaks =
+ {
+ new BreakPeriod(8500, 10000),
+ },
+ HitObjects =
+ {
+ new HitCircle
+ {
+ StartTime = 8000,
+ Position = OsuPlayfield.BASE_SIZE / 2,
+ },
+ new HitCircle
+ {
+ StartTime = 11000,
+ Position = OsuPlayfield.BASE_SIZE / 2,
+ },
+ }
+ });
+
+ AddUntilStep("fetch cursor particles", () =>
+ {
+ cursorParticles = this.ChildrenOfType().SingleOrDefault();
+ return cursorParticles != null;
+ });
+
+ AddStep("move mouse to centre", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.Centre));
+
+ AddAssert("particles are being spawned", () => cursorParticles.Active);
+
+ AddStep("press left mouse button", () => InputManager.PressButton(MouseButton.Left));
+ AddWaitStep("wait a bit", 5);
+ AddStep("press right mouse button", () => InputManager.PressButton(MouseButton.Right));
+ AddWaitStep("wait a bit", 5);
+ AddStep("release left mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
+ AddWaitStep("wait a bit", 5);
+ AddStep("release right mouse button", () => InputManager.ReleaseButton(MouseButton.Right));
+
+ AddUntilStep("wait for beatmap start", () => !Player.IsBreakTime.Value);
+ AddAssert("particle spawning stopped", () => !cursorParticles.Active);
+
+ AddUntilStep("wait for break", () => Player.IsBreakTime.Value);
+ AddAssert("particles are being spawned", () => cursorParticles.Active);
+
+ AddUntilStep("wait for break end", () => !Player.IsBreakTime.Value);
+ AddAssert("particle spawning stopped", () => !cursorParticles.Active);
+ }
+
+ [Test]
+ public void TestLegacyKiaiParticles()
+ {
+ LegacyCursorParticles cursorParticles = null;
+ DrawableSpinner spinner = null;
+ DrawableSlider slider = null;
+
+ createLegacyTest(true, () =>
+ {
+ var controlPointInfo = new ControlPointInfo();
+ controlPointInfo.Add(0, new EffectControlPoint { KiaiMode = true });
+
+ return new Beatmap
+ {
+ ControlPointInfo = controlPointInfo,
+ HitObjects =
+ {
+ new Spinner
+ {
+ StartTime = 0,
+ Duration = 1000,
+ Position = OsuPlayfield.BASE_SIZE / 2,
+ },
+ new Slider
+ {
+ StartTime = 2500,
+ RepeatCount = 0,
+ Position = OsuPlayfield.BASE_SIZE / 2,
+ Path = new SliderPath(new[]
+ {
+ new PathControlPoint(Vector2.Zero),
+ new PathControlPoint(new Vector2(100, 0)),
+ })
+ },
+ new HitCircle
+ {
+ StartTime = 4500,
+ Position = OsuPlayfield.BASE_SIZE / 2,
+ },
+ },
+ };
+ }
+ );
+
+ AddUntilStep("fetch cursor particles", () =>
+ {
+ cursorParticles = this.ChildrenOfType().SingleOrDefault();
+ return cursorParticles != null;
+ });
+
+ AddUntilStep("wait for spinner tracking", () =>
+ {
+ spinner = this.ChildrenOfType().SingleOrDefault();
+ return spinner?.RotationTracker.Tracking == true;
+ });
+ AddAssert("particles are being spawned", () => cursorParticles.Active);
+
+ AddUntilStep("spinner tracking stopped", () => !spinner.RotationTracker.Tracking);
+ AddAssert("particle spawning stopped", () => !cursorParticles.Active);
+
+ AddUntilStep("wait for slider tracking", () =>
+ {
+ slider = this.ChildrenOfType().SingleOrDefault();
+ return slider?.Tracking.Value == true;
+ });
+ AddAssert("particles are being spawned", () => cursorParticles.Active);
+
+ AddUntilStep("slider tracking stopped", () => !slider.Tracking.Value);
+ AddAssert("particle spawning stopped", () => !cursorParticles.Active);
+ }
+
+ private void createLegacyTest(bool autoplay, Func beatmap) => CreateTest(() =>
+ {
+ AddStep("set beatmap", () =>
+ {
+ this.autoplay = autoplay;
+ currentBeatmap = beatmap();
+ });
+ AddStep("setup default legacy skin", () =>
+ {
+ skinManager.CurrentSkinInfo.Value = skinManager.DefaultLegacySkin.SkinInfo;
+ });
+ });
+ }
+}
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs
index 2326a0c391..f9dc9abd75 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs
@@ -12,6 +12,7 @@ using osu.Framework.Graphics.OpenGL.Textures;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
+using osu.Framework.Input.Events;
using osu.Framework.Testing.Input;
using osu.Framework.Utils;
using osu.Game.Audio;
@@ -143,9 +144,9 @@ namespace osu.Game.Rulesets.Osu.Tests
pressed = value;
if (value)
- OnPressed(OsuAction.LeftButton);
+ OnPressed(new KeyBindingPressEvent(GetContainingInputManager().CurrentState, OsuAction.LeftButton));
else
- OnReleased(OsuAction.LeftButton);
+ OnReleased(new KeyBindingReleaseEvent(GetContainingInputManager().CurrentState, OsuAction.LeftButton));
}
}
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleArea.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleArea.cs
index 1fdcd73dde..575523b168 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleArea.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleArea.cs
@@ -4,6 +4,7 @@
using System;
using NUnit.Framework;
using osu.Framework.Graphics;
+using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Osu.Objects;
@@ -97,7 +98,7 @@ namespace osu.Game.Rulesets.Osu.Tests
private void scheduleHit() => AddStep("schedule action", () =>
{
var delay = hitCircle.StartTime - hitCircle.HitWindows.WindowFor(HitResult.Great) - Time.Current;
- Scheduler.AddDelayed(() => hitAreaReceptor.OnPressed(OsuAction.LeftButton), delay);
+ Scheduler.AddDelayed(() => hitAreaReceptor.OnPressed(new KeyBindingPressEvent(GetContainingInputManager().CurrentState, OsuAction.LeftButton)), delay);
});
}
}
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs
index 662cbaee68..0f362851a9 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs
@@ -20,6 +20,7 @@ using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Osu.Objects.Drawables;
+using osu.Game.Rulesets.Osu.Skinning.Default;
using osu.Game.Skinning;
using osu.Game.Storyboards;
using osu.Game.Tests.Visual;
@@ -86,9 +87,9 @@ namespace osu.Game.Rulesets.Osu.Tests
if (firstObject == null)
return false;
- var skinnable = firstObject.ApproachCircle.Child as SkinnableDrawable;
+ var skinnable = firstObject.ApproachCircle;
- if (skin == null && skinnable?.Drawable is Sprite)
+ if (skin == null && skinnable?.Drawable is DefaultApproachCircle)
// check for default skin provider
return true;
diff --git a/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj b/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj
index 68be34d153..f5f1159542 100644
--- a/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj
+++ b/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj
@@ -2,7 +2,7 @@
-
+
diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs
index e47f82fb39..da879cb02e 100644
--- a/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs
+++ b/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs
@@ -34,7 +34,11 @@ namespace osu.Game.Rulesets.Osu.Difficulty
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;
+
+ double baseAimPerformance = Math.Pow(5 * Math.Max(1, aimRating / 0.0675) - 4, 3) / 100000;
+ double baseSpeedPerformance = Math.Pow(5 * Math.Max(1, speedRating / 0.0675) - 4, 3) / 100000;
+ double basePerformance = Math.Pow(Math.Pow(baseAimPerformance, 1.1) + Math.Pow(baseSpeedPerformance, 1.1), 1 / 1.1);
+ double starRating = basePerformance > 0.00001 ? Math.Cbrt(1.12) * 0.027 * (Math.Cbrt(100000 / Math.Pow(2, 1 / 1.1) * basePerformance) + 4) : 0;
HitWindows hitWindows = new OsuHitWindows();
hitWindows.SetDifficulty(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty);
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs
index 6269a41350..1be9b5bf2e 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs
@@ -127,9 +127,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
return false;
}
- public bool OnPressed(PlatformAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
- switch (action)
+ switch (e.Action)
{
case PlatformAction.Delete:
return DeleteSelected();
@@ -138,7 +138,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
return false;
}
- public void OnReleased(PlatformAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
}
diff --git a/osu.Game.Rulesets.Osu/Edit/Setup/OsuSetupSection.cs b/osu.Game.Rulesets.Osu/Edit/Setup/OsuSetupSection.cs
new file mode 100644
index 0000000000..8cb778a2e1
--- /dev/null
+++ b/osu.Game.Rulesets.Osu/Edit/Setup/OsuSetupSection.cs
@@ -0,0 +1,52 @@
+// 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.Game.Graphics.UserInterfaceV2;
+using osu.Game.Screens.Edit.Setup;
+
+namespace osu.Game.Rulesets.Osu.Edit.Setup
+{
+ public class OsuSetupSection : RulesetSetupSection
+ {
+ private LabelledSliderBar stackLeniency;
+
+ public OsuSetupSection()
+ : base(new OsuRuleset().RulesetInfo)
+ {
+ }
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ Children = new[]
+ {
+ stackLeniency = new LabelledSliderBar
+ {
+ Label = "Stack Leniency",
+ Description = "In play mode, osu! automatically stacks notes which occur at the same location. Increasing this value means it is more likely to snap notes of further time-distance.",
+ Current = new BindableFloat(Beatmap.BeatmapInfo.StackLeniency)
+ {
+ Default = 0.7f,
+ MinValue = 0,
+ MaxValue = 1,
+ Precision = 0.1f
+ }
+ }
+ };
+ }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+
+ stackLeniency.Current.BindValueChanged(_ => updateBeatmap());
+ }
+
+ private void updateBeatmap()
+ {
+ Beatmap.BeatmapInfo.StackLeniency = stackLeniency.Current.Value;
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs
index 46fc8f99b2..f05aea0df4 100644
--- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs
@@ -9,6 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Judgements;
@@ -25,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public OsuAction? HitAction => HitArea.HitAction;
protected virtual OsuSkinComponents CirclePieceComponent => OsuSkinComponents.HitCircle;
- public ApproachCircle ApproachCircle { get; private set; }
+ public SkinnableDrawable ApproachCircle { get; private set; }
public HitReceptor HitArea { get; private set; }
public SkinnableDrawable CirclePiece { get; private set; }
@@ -74,8 +75,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
- ApproachCircle = new ApproachCircle
+ ApproachCircle = new ProxyableSkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.ApproachCircle), _ => new DefaultApproachCircle())
{
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ RelativeSizeAxes = Axes.Both,
Alpha = 0,
Scale = new Vector2(4),
}
@@ -88,7 +92,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
PositionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
StackHeightBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
ScaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue));
- AccentColour.BindValueChanged(accent => ApproachCircle.Colour = accent.NewValue);
}
protected override void LoadComplete()
@@ -228,15 +231,15 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
CornerExponent = 2;
}
- public bool OnPressed(OsuAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
- switch (action)
+ switch (e.Action)
{
case OsuAction.LeftButton:
case OsuAction.RightButton:
if (IsHovered && (Hit?.Invoke() ?? false))
{
- HitAction = action;
+ HitAction = e.Action;
return true;
}
@@ -246,7 +249,17 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
return false;
}
- public void OnReleased(OsuAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
+ {
+ }
+ }
+
+ private class ProxyableSkinnableDrawable : SkinnableDrawable
+ {
+ public override bool RemoveWhenNotAlive => false;
+
+ public ProxyableSkinnableDrawable(ISkinComponent component, Func defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling)
+ : base(component, defaultImplementation, confineMode)
{
}
}
diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuJudgement.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuJudgement.cs
index b23087a1f3..e4df41a4fe 100644
--- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuJudgement.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuJudgement.cs
@@ -74,10 +74,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public override void PlayAnimation()
{
- base.PlayAnimation();
-
if (Result != HitResult.Miss)
- JudgementText.ScaleTo(new Vector2(0.8f, 1)).Then().ScaleTo(new Vector2(1.2f, 1), 1800, Easing.OutQuint);
+ {
+ JudgementText
+ .ScaleTo(new Vector2(0.8f, 1))
+ .ScaleTo(new Vector2(1.2f, 1), 1800, Easing.OutQuint);
+ }
+
+ base.PlayAnimation();
}
}
}
diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs
index b13cdff1ec..f4a93a571d 100644
--- a/osu.Game.Rulesets.Osu/OsuRuleset.cs
+++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs
@@ -30,9 +30,11 @@ using osu.Game.Skinning;
using System;
using System.Linq;
using osu.Framework.Extensions.EnumExtensions;
+using osu.Game.Rulesets.Osu.Edit.Setup;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Skinning.Legacy;
using osu.Game.Rulesets.Osu.Statistics;
+using osu.Game.Screens.Edit.Setup;
using osu.Game.Screens.Ranking.Statistics;
namespace osu.Game.Rulesets.Osu
@@ -305,5 +307,7 @@ namespace osu.Game.Rulesets.Osu
}
};
}
+
+ public override RulesetSetupSection CreateEditorSetupSection() => new OsuSetupSection();
}
}
diff --git a/osu.Game.Rulesets.Osu/OsuSkinComponents.cs b/osu.Game.Rulesets.Osu/OsuSkinComponents.cs
index 46e501758b..71657ed532 100644
--- a/osu.Game.Rulesets.Osu/OsuSkinComponents.cs
+++ b/osu.Game.Rulesets.Osu/OsuSkinComponents.cs
@@ -9,6 +9,7 @@ namespace osu.Game.Rulesets.Osu
FollowPoint,
Cursor,
CursorTrail,
+ CursorParticles,
SliderScorePoint,
ReverseArrow,
HitCircleText,
@@ -18,5 +19,6 @@ namespace osu.Game.Rulesets.Osu
SliderBall,
SliderBody,
SpinnerBody,
+ ApproachCircle,
}
}
diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/ApproachCircle.cs b/osu.Game.Rulesets.Osu/Skinning/Default/ApproachCircle.cs
deleted file mode 100644
index 62f00a2b49..0000000000
--- a/osu.Game.Rulesets.Osu/Skinning/Default/ApproachCircle.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 osu.Framework.Allocation;
-using osu.Framework.Graphics;
-using osu.Framework.Graphics.Containers;
-using osu.Framework.Graphics.Textures;
-using osu.Game.Skinning;
-using osuTK;
-
-namespace osu.Game.Rulesets.Osu.Skinning.Default
-{
- public class ApproachCircle : Container
- {
- public override bool RemoveWhenNotAlive => false;
-
- public ApproachCircle()
- {
- Anchor = Anchor.Centre;
- Origin = Anchor.Centre;
-
- RelativeSizeAxes = Axes.Both;
- }
-
- [BackgroundDependencyLoader]
- private void load(TextureStore textures)
- {
- Child = new SkinnableApproachCircle();
- }
-
- private class SkinnableApproachCircle : SkinnableSprite
- {
- public SkinnableApproachCircle()
- : base("Gameplay/osu/approachcircle")
- {
- }
-
- protected override Drawable CreateDefault(ISkinComponent component)
- {
- var drawable = base.CreateDefault(component);
-
- // account for the sprite being used for the default approach circle being taken from stable,
- // when hitcircles have 5px padding on each size. this should be removed if we update the sprite.
- drawable.Scale = new Vector2(128 / 118f);
-
- return drawable;
- }
- }
- }
-}
diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultApproachCircle.cs b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultApproachCircle.cs
new file mode 100644
index 0000000000..a522367fe6
--- /dev/null
+++ b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultApproachCircle.cs
@@ -0,0 +1,49 @@
+// 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.Game.Rulesets.Objects.Drawables;
+using osu.Game.Skinning;
+using osuTK;
+using osuTK.Graphics;
+
+namespace osu.Game.Rulesets.Osu.Skinning.Default
+{
+ public class DefaultApproachCircle : SkinnableSprite
+ {
+ private readonly IBindable accentColour = new Bindable();
+
+ [Resolved]
+ private DrawableHitObject drawableObject { get; set; }
+
+ public DefaultApproachCircle()
+ : base("Gameplay/osu/approachcircle")
+ {
+ }
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ accentColour.BindTo(drawableObject.AccentColour);
+ }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+ accentColour.BindValueChanged(colour => Colour = colour.NewValue, true);
+ }
+
+ protected override Drawable CreateDefault(ISkinComponent component)
+ {
+ var drawable = base.CreateDefault(component);
+
+ // Although this is a non-legacy component, osu-resources currently stores approach circle as a legacy-like texture.
+ // See LegacyApproachCircle for documentation as to why this is required.
+ drawable.Scale = new Vector2(128 / 118f);
+
+ return drawable;
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/PlaySliderBody.cs b/osu.Game.Rulesets.Osu/Skinning/Default/PlaySliderBody.cs
index 4dd7b2d69c..8602ebc88b 100644
--- a/osu.Game.Rulesets.Osu/Skinning/Default/PlaySliderBody.cs
+++ b/osu.Game.Rulesets.Osu/Skinning/Default/PlaySliderBody.cs
@@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
pathVersion.BindValueChanged(_ => Refresh());
accentColour = drawableObject.AccentColour.GetBoundCopy();
- accentColour.BindValueChanged(accent => updateAccentColour(skin, accent.NewValue), true);
+ accentColour.BindValueChanged(accent => AccentColour = GetBodyAccentColour(skin, accent.NewValue), true);
config?.BindWith(OsuRulesetSetting.SnakingInSliders, SnakingIn);
config?.BindWith(OsuRulesetSetting.SnakingOutSliders, configSnakingOut);
@@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
}
}
- private void updateAccentColour(ISkinSource skin, Color4 defaultAccentColour)
- => AccentColour = skin.GetConfig(OsuSkinColour.SliderTrackOverride)?.Value ?? defaultAccentColour;
+ protected virtual Color4 GetBodyAccentColour(ISkinSource skin, Color4 hitObjectAccentColour) =>
+ skin.GetConfig(OsuSkinColour.SliderTrackOverride)?.Value ?? hitObjectAccentColour;
}
}
diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/SnakingSliderBody.cs b/osu.Game.Rulesets.Osu/Skinning/Default/SnakingSliderBody.cs
index ed4e04184b..7b7a89d5e2 100644
--- a/osu.Game.Rulesets.Osu/Skinning/Default/SnakingSliderBody.cs
+++ b/osu.Game.Rulesets.Osu/Skinning/Default/SnakingSliderBody.cs
@@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
///
/// A which changes its curve depending on the snaking progress.
///
- public class SnakingSliderBody : SliderBody, ISliderProgress
+ public abstract class SnakingSliderBody : SliderBody, ISliderProgress
{
public readonly List CurrentCurve = new List();
diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyApproachCircle.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyApproachCircle.cs
new file mode 100644
index 0000000000..6a2cb871b1
--- /dev/null
+++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyApproachCircle.cs
@@ -0,0 +1,49 @@
+// 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.Game.Rulesets.Objects.Drawables;
+using osu.Game.Skinning;
+using osuTK;
+using osuTK.Graphics;
+
+namespace osu.Game.Rulesets.Osu.Skinning.Legacy
+{
+ public class LegacyApproachCircle : SkinnableSprite
+ {
+ private readonly IBindable accentColour = new Bindable();
+
+ [Resolved]
+ private DrawableHitObject drawableObject { get; set; }
+
+ public LegacyApproachCircle()
+ : base("Gameplay/osu/approachcircle")
+ {
+ }
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ accentColour.BindTo(drawableObject.AccentColour);
+ }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+ accentColour.BindValueChanged(colour => Colour = LegacyColourCompatibility.DisallowZeroAlpha(colour.NewValue), true);
+ }
+
+ protected override Drawable CreateDefault(ISkinComponent component)
+ {
+ var drawable = base.CreateDefault(component);
+
+ // account for the sprite being used for the default approach circle being taken from stable,
+ // when hitcircles have 5px padding on each size. this should be removed if we update the sprite.
+ drawable.Scale = new Vector2(128 / 118f);
+
+ return drawable;
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyCursorParticles.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyCursorParticles.cs
new file mode 100644
index 0000000000..2b0dfba1dd
--- /dev/null
+++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyCursorParticles.cs
@@ -0,0 +1,256 @@
+// 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.Bindables;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Textures;
+using osu.Framework.Input;
+using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
+using osu.Framework.Utils;
+using osu.Game.Graphics;
+using osu.Game.Rulesets.Objects.Drawables;
+using osu.Game.Rulesets.Osu.Objects.Drawables;
+using osu.Game.Rulesets.Osu.UI;
+using osu.Game.Screens.Play;
+using osu.Game.Skinning;
+using osuTK;
+using osuTK.Graphics;
+
+namespace osu.Game.Rulesets.Osu.Skinning.Legacy
+{
+ public class LegacyCursorParticles : CompositeDrawable, IKeyBindingHandler
+ {
+ public bool Active => breakSpewer?.Active.Value == true || kiaiSpewer?.Active.Value == true;
+
+ private LegacyCursorParticleSpewer breakSpewer;
+ private LegacyCursorParticleSpewer kiaiSpewer;
+
+ [Resolved(canBeNull: true)]
+ private Player player { get; set; }
+
+ [Resolved(canBeNull: true)]
+ private OsuPlayfield playfield { get; set; }
+
+ [Resolved(canBeNull: true)]
+ private GameplayBeatmap gameplayBeatmap { get; set; }
+
+ [Resolved(canBeNull: true)]
+ private GameplayClock gameplayClock { get; set; }
+
+ [BackgroundDependencyLoader]
+ private void load(ISkinSource skin, OsuColour colours)
+ {
+ var texture = skin.GetTexture("star2");
+ var starBreakAdditive = skin.GetConfig(OsuSkinColour.StarBreakAdditive)?.Value ?? new Color4(255, 182, 193, 255);
+
+ if (texture != null)
+ {
+ // stable "magic ratio". see OsuPlayfieldAdjustmentContainer for full explanation.
+ texture.ScaleAdjust *= 1.6f;
+ }
+
+ InternalChildren = new[]
+ {
+ breakSpewer = new LegacyCursorParticleSpewer(texture, 20)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Colour = starBreakAdditive,
+ Direction = SpewDirection.None,
+ },
+ kiaiSpewer = new LegacyCursorParticleSpewer(texture, 60)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Colour = starBreakAdditive,
+ Direction = SpewDirection.None,
+ },
+ };
+
+ if (player != null)
+ ((IBindable)breakSpewer.Active).BindTo(player.IsBreakTime);
+ }
+
+ protected override void Update()
+ {
+ if (playfield == null || gameplayBeatmap == null) return;
+
+ DrawableHitObject kiaiHitObject = null;
+
+ // Check whether currently in a kiai section first. This is only done as an optimisation to avoid enumerating AliveObjects when not necessary.
+ if (gameplayBeatmap.ControlPointInfo.EffectPointAt(gameplayBeatmap.Time.Current).KiaiMode)
+ kiaiHitObject = playfield.HitObjectContainer.AliveObjects.FirstOrDefault(isTracking);
+
+ kiaiSpewer.Active.Value = kiaiHitObject != null;
+ }
+
+ private bool isTracking(DrawableHitObject h)
+ {
+ if (!h.HitObject.Kiai)
+ return false;
+
+ switch (h)
+ {
+ case DrawableSlider slider:
+ return slider.Tracking.Value;
+
+ case DrawableSpinner spinner:
+ return spinner.RotationTracker.Tracking;
+ }
+
+ return false;
+ }
+
+ public bool OnPressed(KeyBindingPressEvent e)
+ {
+ handleInput(e.Action, true);
+ return false;
+ }
+
+ public void OnReleased(KeyBindingReleaseEvent e)
+ {
+ handleInput(e.Action, false);
+ }
+
+ private bool leftPressed;
+ private bool rightPressed;
+
+ private void handleInput(OsuAction action, bool pressed)
+ {
+ switch (action)
+ {
+ case OsuAction.LeftButton:
+ leftPressed = pressed;
+ break;
+
+ case OsuAction.RightButton:
+ rightPressed = pressed;
+ break;
+ }
+
+ if (leftPressed && rightPressed)
+ breakSpewer.Direction = SpewDirection.Omni;
+ else if (leftPressed)
+ breakSpewer.Direction = SpewDirection.Left;
+ else if (rightPressed)
+ breakSpewer.Direction = SpewDirection.Right;
+ else
+ breakSpewer.Direction = SpewDirection.None;
+ }
+
+ private class LegacyCursorParticleSpewer : ParticleSpewer, IRequireHighFrequencyMousePosition
+ {
+ private const int particle_duration_min = 300;
+ private const int particle_duration_max = 1000;
+
+ public SpewDirection Direction { get; set; }
+
+ protected override bool CanSpawnParticles => base.CanSpawnParticles && cursorScreenPosition.HasValue;
+ protected override float ParticleGravity => 240;
+
+ public LegacyCursorParticleSpewer(Texture texture, int perSecond)
+ : base(texture, perSecond, particle_duration_max)
+ {
+ Active.BindValueChanged(_ => resetVelocityCalculation());
+ }
+
+ private Vector2? cursorScreenPosition;
+ private Vector2 cursorVelocity;
+
+ private const double max_velocity_frame_length = 15;
+ private double velocityFrameLength;
+ private Vector2 totalPosDifference;
+
+ public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
+
+ protected override bool OnMouseMove(MouseMoveEvent e)
+ {
+ if (cursorScreenPosition == null)
+ {
+ cursorScreenPosition = e.ScreenSpaceMousePosition;
+ return base.OnMouseMove(e);
+ }
+
+ // calculate cursor velocity.
+ totalPosDifference += e.ScreenSpaceMousePosition - cursorScreenPosition.Value;
+ cursorScreenPosition = e.ScreenSpaceMousePosition;
+
+ velocityFrameLength += Math.Abs(Clock.ElapsedFrameTime);
+
+ if (velocityFrameLength > max_velocity_frame_length)
+ {
+ cursorVelocity = totalPosDifference / (float)velocityFrameLength;
+
+ totalPosDifference = Vector2.Zero;
+ velocityFrameLength = 0;
+ }
+
+ return base.OnMouseMove(e);
+ }
+
+ private void resetVelocityCalculation()
+ {
+ cursorScreenPosition = null;
+ totalPosDifference = Vector2.Zero;
+ velocityFrameLength = 0;
+ }
+
+ protected override FallingParticle CreateParticle() =>
+ new FallingParticle
+ {
+ StartPosition = ToLocalSpace(cursorScreenPosition ?? Vector2.Zero),
+ Duration = RNG.NextSingle(particle_duration_min, particle_duration_max),
+ StartAngle = (float)(RNG.NextDouble() * 4 - 2),
+ EndAngle = RNG.NextSingle(-2f, 2f),
+ EndScale = RNG.NextSingle(2f),
+ Velocity = getVelocity(),
+ };
+
+ private Vector2 getVelocity()
+ {
+ Vector2 velocity = Vector2.Zero;
+
+ switch (Direction)
+ {
+ case SpewDirection.Left:
+ velocity = new Vector2(
+ RNG.NextSingle(-460f, 0),
+ RNG.NextSingle(-40f, 40f)
+ );
+ break;
+
+ case SpewDirection.Right:
+ velocity = new Vector2(
+ RNG.NextSingle(0, 460f),
+ RNG.NextSingle(-40f, 40f)
+ );
+ break;
+
+ case SpewDirection.Omni:
+ velocity = new Vector2(
+ RNG.NextSingle(-460f, 460f),
+ RNG.NextSingle(-160f, 160f)
+ );
+ break;
+ }
+
+ velocity += cursorVelocity * 40;
+
+ return velocity;
+ }
+ }
+
+ private enum SpewDirection
+ {
+ None,
+ Left,
+ Right,
+ Omni,
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs
index 1c8dfeac52..29a0745193 100644
--- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs
+++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs
@@ -5,6 +5,7 @@ using System;
using osu.Framework.Extensions.Color4Extensions;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Skinning.Default;
+using osu.Game.Skinning;
using osu.Game.Utils;
using osuTK.Graphics;
@@ -14,6 +15,12 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{
protected override DrawableSliderPath CreateSliderPath() => new LegacyDrawableSliderPath();
+ protected override Color4 GetBodyAccentColour(ISkinSource skin, Color4 hitObjectAccentColour)
+ {
+ // legacy skins use a constant value for slider track alpha, regardless of the source colour.
+ return base.GetBodyAccentColour(skin, hitObjectAccentColour).Opacity(0.7f);
+ }
+
private class LegacyDrawableSliderPath : DrawableSliderPath
{
private const float shadow_portion = 1 - (OsuLegacySkinTransformer.LEGACY_CIRCLE_RADIUS / OsuHitObject.OBJECT_RADIUS);
@@ -22,8 +29,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
// Roughly matches osu!stable's slider border portions.
=> base.CalculatedBorderPortion * 0.77f;
- public new Color4 AccentColour => new Color4(base.AccentColour.R, base.AccentColour.G, base.AccentColour.B, 0.7f);
-
protected override Color4 ColourAt(float position)
{
float realBorderPortion = shadow_portion + CalculatedBorderPortion;
diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs
index 8df8001d42..8a24e36420 100644
--- a/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs
+++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs
@@ -95,6 +95,12 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
return null;
+ case OsuSkinComponents.CursorParticles:
+ if (GetTexture("star2") != null)
+ return new LegacyCursorParticles();
+
+ return null;
+
case OsuSkinComponents.HitCircleText:
if (!this.HasFont(LegacyFont.HitCircle))
return null;
@@ -114,6 +120,9 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
return new LegacyOldStyleSpinner();
return null;
+
+ case OsuSkinComponents.ApproachCircle:
+ return new LegacyApproachCircle();
}
}
diff --git a/osu.Game.Rulesets.Osu/Skinning/OsuSkinColour.cs b/osu.Game.Rulesets.Osu/Skinning/OsuSkinColour.cs
index f7ba8b9fc4..24f9217a5f 100644
--- a/osu.Game.Rulesets.Osu/Skinning/OsuSkinColour.cs
+++ b/osu.Game.Rulesets.Osu/Skinning/OsuSkinColour.cs
@@ -9,5 +9,6 @@ namespace osu.Game.Rulesets.Osu.Skinning
SliderBorder,
SliderBall,
SpinnerBackground,
+ StarBreakAdditive,
}
}
diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
index 5812e8cf75..83bcc88e5f 100644
--- a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
+++ b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
@@ -8,6 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets.Osu.Configuration;
@@ -42,7 +43,11 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
InternalChild = fadeContainer = new Container
{
RelativeSizeAxes = Axes.Both,
- Child = cursorTrail = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.CursorTrail), _ => new DefaultCursorTrail(), confineMode: ConfineMode.NoScaling)
+ Children = new[]
+ {
+ cursorTrail = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.CursorTrail), _ => new DefaultCursorTrail(), confineMode: ConfineMode.NoScaling),
+ new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.CursorParticles), confineMode: ConfineMode.NoScaling),
+ }
};
}
@@ -115,9 +120,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
(ActiveCursor as OsuCursor)?.Contract();
}
- public bool OnPressed(OsuAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
- switch (action)
+ switch (e.Action)
{
case OsuAction.LeftButton:
case OsuAction.RightButton:
@@ -129,9 +134,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
return false;
}
- public void OnReleased(OsuAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
- switch (action)
+ switch (e.Action)
{
case OsuAction.LeftButton:
case OsuAction.RightButton:
diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs
index c1c2ea2299..2233a547b9 100644
--- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs
+++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs
@@ -24,6 +24,7 @@ using osuTK;
namespace osu.Game.Rulesets.Osu.UI
{
+ [Cached]
public class OsuPlayfield : Playfield
{
private readonly PlayfieldBorder playfieldBorder;
diff --git a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
index 27d48d1296..4d4340936d 100644
--- a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
+++ b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
@@ -89,9 +89,9 @@ namespace osu.Game.Rulesets.Osu.UI
base.OnHoverLost(e);
}
- public bool OnPressed(OsuAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
- switch (action)
+ switch (e.Action)
{
case OsuAction.LeftButton:
case OsuAction.RightButton:
@@ -106,7 +106,7 @@ namespace osu.Game.Rulesets.Osu.UI
return false;
}
- public void OnReleased(OsuAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
}
diff --git a/osu.Game.Rulesets.Taiko.Tests/DrawableTestHit.cs b/osu.Game.Rulesets.Taiko.Tests/DrawableTestHit.cs
index f048cad18c..6d4cac0ebe 100644
--- a/osu.Game.Rulesets.Taiko.Tests/DrawableTestHit.cs
+++ b/osu.Game.Rulesets.Taiko.Tests/DrawableTestHit.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.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Scoring;
@@ -37,6 +38,6 @@ namespace osu.Game.Rulesets.Taiko.Tests
Result.Type = Type;
}
- public override bool OnPressed(TaikoAction action) => false;
+ public override bool OnPressed(KeyBindingPressEvent e) => false;
}
}
diff --git a/osu.Game.Rulesets.Taiko.Tests/DrawableTestStrongHit.cs b/osu.Game.Rulesets.Taiko.Tests/DrawableTestStrongHit.cs
index 829bcf34a1..ea877c9e17 100644
--- a/osu.Game.Rulesets.Taiko.Tests/DrawableTestStrongHit.cs
+++ b/osu.Game.Rulesets.Taiko.Tests/DrawableTestStrongHit.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Objects.Drawables;
@@ -30,6 +31,6 @@ namespace osu.Game.Rulesets.Taiko.Tests
nestedStrongHit.Result.Type = hitBoth ? Type : HitResult.Miss;
}
- public override bool OnPressed(TaikoAction action) => false;
+ public override bool OnPressed(KeyBindingPressEvent e) => false;
}
}
diff --git a/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj b/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj
index 532fdc5cb0..b9b295767e 100644
--- a/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj
+++ b/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj
@@ -2,7 +2,7 @@
-
+
diff --git a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs
index 1253b7c8ae..0a325f174e 100644
--- a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs
+++ b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs
@@ -36,24 +36,27 @@ namespace osu.Game.Rulesets.Taiko.Mods
public TaikoFlashlight(TaikoPlayfield taikoPlayfield)
{
this.taikoPlayfield = taikoPlayfield;
- FlashlightSize = new Vector2(0, getSizeFor(0));
+ FlashlightSize = getSizeFor(0);
AddLayout(flashlightProperties);
}
- private float getSizeFor(int combo)
+ private Vector2 getSizeFor(int combo)
{
+ float size = default_flashlight_size;
+
if (combo > 200)
- return default_flashlight_size * 0.8f;
+ size *= 0.8f;
else if (combo > 100)
- return default_flashlight_size * 0.9f;
- else
- return default_flashlight_size;
+ size *= 0.9f;
+
+ // Preserve flashlight size through the playfield's aspect adjustment.
+ return new Vector2(0, size * taikoPlayfield.DrawHeight / TaikoPlayfield.DEFAULT_HEIGHT);
}
protected override void OnComboChange(ValueChangedEvent e)
{
- this.TransformTo(nameof(FlashlightSize), new Vector2(0, getSizeFor(e.NewValue)), FLASHLIGHT_FADE_DURATION);
+ this.TransformTo(nameof(FlashlightSize), getSizeFor(e.NewValue), FLASHLIGHT_FADE_DURATION);
}
protected override string FragmentShader => "CircularFlashlight";
@@ -64,7 +67,11 @@ namespace osu.Game.Rulesets.Taiko.Mods
if (!flashlightProperties.IsValid)
{
- FlashlightPosition = taikoPlayfield.HitTarget.ToSpaceOfOtherDrawable(taikoPlayfield.HitTarget.OriginPosition, this);
+ FlashlightPosition = ToLocalSpace(taikoPlayfield.HitTarget.ScreenSpaceDrawQuad.Centre);
+
+ ClearTransforms(targetMember: nameof(FlashlightSize));
+ FlashlightSize = getSizeFor(Combo.Value);
+
flashlightProperties.Validate();
}
}
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs
index d066abf767..521189d36c 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs
@@ -11,6 +11,7 @@ using osu.Game.Rulesets.Objects.Drawables;
using osuTK.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
@@ -112,7 +113,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.DrumRollBody),
_ => new ElongatedCirclePiece());
- public override bool OnPressed(TaikoAction action) => false;
+ public override bool OnPressed(KeyBindingPressEvent e) => false;
private void onNewResult(DrawableHitObject obj, JudgementResult result)
{
@@ -196,7 +197,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
ApplyResult(r => r.Type = ParentHitObject.IsHit ? r.Judgement.MaxResult : r.Judgement.MinResult);
}
- public override bool OnPressed(TaikoAction action) => false;
+ public override bool OnPressed(KeyBindingPressEvent e) => false;
}
}
}
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs
index 0df45c424d..dc2ed200a1 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs
@@ -4,6 +4,7 @@
using System;
using JetBrains.Annotations;
using osu.Framework.Graphics;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Skinning.Default;
using osu.Game.Skinning;
@@ -61,9 +62,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
}
}
- public override bool OnPressed(TaikoAction action)
+ public override bool OnPressed(KeyBindingPressEvent e)
{
- JudgementType = action == TaikoAction.LeftRim || action == TaikoAction.RightRim ? HitType.Rim : HitType.Centre;
+ JudgementType = e.Action == TaikoAction.LeftRim || e.Action == TaikoAction.RightRim ? HitType.Rim : HitType.Centre;
return UpdateResult(true);
}
@@ -91,7 +92,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
ApplyResult(r => r.Type = ParentHitObject.IsHit ? r.Judgement.MaxResult : r.Judgement.MinResult);
}
- public override bool OnPressed(TaikoAction action) => false;
+ public override bool OnPressed(KeyBindingPressEvent e) => false;
}
}
}
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs
index 1e9fc187eb..97adc5f197 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs
@@ -8,6 +8,7 @@ using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
+using osu.Framework.Input.Events;
using osu.Game.Audio;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
@@ -145,19 +146,19 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
ApplyResult(r => r.Type = result);
}
- public override bool OnPressed(TaikoAction action)
+ public override bool OnPressed(KeyBindingPressEvent e)
{
if (pressHandledThisFrame)
return true;
if (Judged)
return false;
- validActionPressed = HitActions.Contains(action);
+ validActionPressed = HitActions.Contains(e.Action);
// Only count this as handled if the new judgement is a hit
var result = UpdateResult(true);
if (IsHit)
- HitAction = action;
+ HitAction = e.Action;
// Regardless of whether we've hit or not, any secondary key presses in the same frame should be discarded
// E.g. hitting a non-strong centre as a strong should not fall through and perform a hit on the next note
@@ -165,11 +166,11 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
return result;
}
- public override void OnReleased(TaikoAction action)
+ public override void OnReleased(KeyBindingReleaseEvent e)
{
- if (action == HitAction)
+ if (e.Action == HitAction)
HitAction = null;
- base.OnReleased(action);
+ base.OnReleased(e);
}
protected override void Update()
@@ -265,7 +266,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
ApplyResult(r => r.Type = r.Judgement.MaxResult);
}
- public override bool OnPressed(TaikoAction action)
+ public override bool OnPressed(KeyBindingPressEvent e)
{
// Don't process actions until the main hitobject is hit
if (!ParentHitObject.IsHit)
@@ -276,7 +277,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
return false;
// Don't handle invalid hit action presses
- if (!ParentHitObject.HitActions.Contains(action))
+ if (!ParentHitObject.HitActions.Contains(e.Action))
return false;
return UpdateResult(true);
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs
index 888f47d341..2d19296d06 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs
@@ -12,6 +12,7 @@ using osu.Game.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osuTK.Graphics;
using osu.Framework.Graphics.Shapes;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Skinning.Default;
@@ -266,13 +267,13 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
private bool? lastWasCentre;
- public override bool OnPressed(TaikoAction action)
+ public override bool OnPressed(KeyBindingPressEvent e)
{
// Don't handle keys before the swell starts
if (Time.Current < HitObject.StartTime)
return false;
- var isCentre = action == TaikoAction.LeftCentre || action == TaikoAction.RightCentre;
+ var isCentre = e.Action == TaikoAction.LeftCentre || e.Action == TaikoAction.RightCentre;
// Ensure alternating centre and rim hits
if (lastWasCentre == isCentre)
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwellTick.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwellTick.cs
index 47fc7e5ab3..d4ea9ed29f 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwellTick.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwellTick.cs
@@ -3,6 +3,7 @@
using JetBrains.Annotations;
using osu.Framework.Graphics;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.Taiko.Skinning.Default;
using osu.Game.Skinning;
@@ -34,7 +35,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
}
- public override bool OnPressed(TaikoAction action) => false;
+ public override bool OnPressed(KeyBindingPressEvent e) => false;
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.DrumRollTick),
_ => new TickPiece());
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs
index 6a8d8a611c..eb64ba72f2 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs
@@ -8,6 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Audio;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Skinning;
@@ -76,9 +77,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
///
public Drawable CreateProxiedContent() => proxiedContent.CreateProxy();
- public abstract bool OnPressed(TaikoAction action);
+ public abstract bool OnPressed(KeyBindingPressEvent e);
- public virtual void OnReleased(TaikoAction action)
+ public virtual void OnReleased(KeyBindingReleaseEvent e)
{
}
diff --git a/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyInputDrum.cs b/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyInputDrum.cs
index 9d35093591..86be40dea8 100644
--- a/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyInputDrum.cs
+++ b/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyInputDrum.cs
@@ -7,6 +7,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.UI;
using osu.Game.Skinning;
@@ -141,16 +142,16 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
Centre.Texture = skin.GetTexture(@"taiko-drum-inner");
}
- public bool OnPressed(TaikoAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
Drawable target = null;
- if (action == CentreAction)
+ if (e.Action == CentreAction)
{
target = Centre;
sampleTriggerSource.Play(HitType.Centre);
}
- else if (action == RimAction)
+ else if (e.Action == RimAction)
{
target = Rim;
sampleTriggerSource.Play(HitType.Rim);
@@ -173,7 +174,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
return false;
}
- public void OnReleased(TaikoAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
}
}
diff --git a/osu.Game.Rulesets.Taiko/UI/DrawableTaikoJudgement.cs b/osu.Game.Rulesets.Taiko/UI/DrawableTaikoJudgement.cs
index 1ad1e4495c..876fa207bf 100644
--- a/osu.Game.Rulesets.Taiko/UI/DrawableTaikoJudgement.cs
+++ b/osu.Game.Rulesets.Taiko/UI/DrawableTaikoJudgement.cs
@@ -3,6 +3,7 @@
using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements;
+using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Taiko.UI
{
@@ -16,5 +17,26 @@ namespace osu.Game.Rulesets.Taiko.UI
this.MoveToY(-100, 500);
base.ApplyHitAnimations();
}
+
+ protected override Drawable CreateDefaultJudgement(HitResult result) => new TaikoJudgementPiece(result);
+
+ private class TaikoJudgementPiece : DefaultJudgementPiece
+ {
+ public TaikoJudgementPiece(HitResult result)
+ : base(result)
+ {
+ }
+
+ public override void PlayAnimation()
+ {
+ if (Result != HitResult.Miss)
+ {
+ JudgementText.ScaleTo(0.9f);
+ JudgementText.ScaleTo(1, 500, Easing.OutElastic);
+ }
+
+ base.PlayAnimation();
+ }
+ }
}
}
diff --git a/osu.Game.Rulesets.Taiko/UI/InputDrum.cs b/osu.Game.Rulesets.Taiko/UI/InputDrum.cs
index ddfaf64549..861b800038 100644
--- a/osu.Game.Rulesets.Taiko/UI/InputDrum.cs
+++ b/osu.Game.Rulesets.Taiko/UI/InputDrum.cs
@@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.UI;
@@ -151,19 +152,19 @@ namespace osu.Game.Rulesets.Taiko.UI
[Resolved(canBeNull: true)]
private GameplayClock gameplayClock { get; set; }
- public bool OnPressed(TaikoAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
Drawable target = null;
Drawable back = null;
- if (action == CentreAction)
+ if (e.Action == CentreAction)
{
target = centreHit;
back = centre;
sampleTriggerSource.Play(HitType.Centre);
}
- else if (action == RimAction)
+ else if (e.Action == RimAction)
{
target = rimHit;
back = rim;
@@ -195,7 +196,7 @@ namespace osu.Game.Rulesets.Taiko.UI
return false;
}
- public void OnReleased(TaikoAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
}
}
diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs
index 12633ee8c9..a4bf8c92e3 100644
--- a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs
+++ b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs
@@ -3,15 +3,12 @@
using System;
using System.IO;
-using NUnit.Framework;
-using osuTK;
-using osuTK.Graphics;
-using osu.Game.Tests.Resources;
using System.Linq;
+using NUnit.Framework;
using osu.Game.Audio;
using osu.Game.Beatmaps;
-using osu.Game.Rulesets.Objects.Types;
using osu.Game.Beatmaps.Formats;
+using osu.Game.Beatmaps.Legacy;
using osu.Game.Beatmaps.Timing;
using osu.Game.IO;
using osu.Game.Rulesets.Catch;
@@ -19,9 +16,13 @@ using osu.Game.Rulesets.Catch.Beatmaps;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Legacy;
+using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Beatmaps;
using osu.Game.Skinning;
+using osu.Game.Tests.Resources;
+using osuTK;
+using osuTK.Graphics;
namespace osu.Game.Tests.Beatmaps.Formats
{
@@ -63,6 +64,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.IsFalse(beatmapInfo.LetterboxInBreaks);
Assert.IsFalse(beatmapInfo.SpecialStyle);
Assert.IsFalse(beatmapInfo.WidescreenStoryboard);
+ Assert.IsFalse(beatmapInfo.SamplesMatchPlaybackRate);
Assert.AreEqual(CountdownType.None, beatmapInfo.Countdown);
Assert.AreEqual(0, beatmapInfo.CountdownOffset);
}
@@ -166,7 +168,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
using (var stream = new LineBufferedReader(resStream))
{
var beatmap = decoder.Decode(stream);
- var controlPoints = beatmap.ControlPointInfo;
+ var controlPoints = (LegacyControlPointInfo)beatmap.ControlPointInfo;
Assert.AreEqual(4, controlPoints.TimingPoints.Count);
Assert.AreEqual(5, controlPoints.DifficultyPoints.Count);
@@ -240,7 +242,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
using (var resStream = TestResources.OpenResource("overlapping-control-points.osu"))
using (var stream = new LineBufferedReader(resStream))
{
- var controlPoints = decoder.Decode(stream).ControlPointInfo;
+ var controlPoints = (LegacyControlPointInfo)decoder.Decode(stream).ControlPointInfo;
Assert.That(controlPoints.TimingPoints.Count, Is.EqualTo(4));
Assert.That(controlPoints.DifficultyPoints.Count, Is.EqualTo(3));
diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapEncoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapEncoderTest.cs
index 96986f06d5..896aa53f82 100644
--- a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapEncoderTest.cs
+++ b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapEncoderTest.cs
@@ -14,6 +14,7 @@ using osu.Framework.IO.Stores;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Formats;
+using osu.Game.Beatmaps.Legacy;
using osu.Game.IO;
using osu.Game.IO.Serialization;
using osu.Game.Rulesets.Catch;
@@ -65,6 +66,47 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.IsTrue(areComboColoursEqual(decodedAfterEncode.beatmapSkin.Configuration, decoded.beatmapSkin.Configuration));
}
+ [TestCaseSource(nameof(allBeatmaps))]
+ public void TestEncodeDecodeStabilityWithNonLegacyControlPoints(string name)
+ {
+ var decoded = decodeFromLegacy(beatmaps_resource_store.GetStream(name), name);
+
+ // we are testing that the transfer of relevant data to hitobjects (from legacy control points) sticks through encode/decode.
+ // before the encode step, the legacy information is removed here.
+ decoded.beatmap.ControlPointInfo = removeLegacyControlPointTypes(decoded.beatmap.ControlPointInfo);
+
+ var decodedAfterEncode = decodeFromLegacy(encodeToLegacy(decoded), name);
+
+ // in this process, we may lose some detail in the control points section.
+ // let's focus on only the hitobjects.
+ var originalHitObjects = decoded.beatmap.HitObjects.Serialize();
+ var newHitObjects = decodedAfterEncode.beatmap.HitObjects.Serialize();
+
+ Assert.That(newHitObjects, Is.EqualTo(originalHitObjects));
+
+ ControlPointInfo removeLegacyControlPointTypes(ControlPointInfo controlPointInfo)
+ {
+ // emulate non-legacy control points by cloning the non-legacy portion.
+ // the assertion is that the encoder can recreate this losslessly from hitobject data.
+ Assert.IsInstanceOf(controlPointInfo);
+
+ var newControlPoints = new ControlPointInfo();
+
+ foreach (var point in controlPointInfo.AllControlPoints)
+ {
+ // completely ignore "legacy" types, which have been moved to HitObjects.
+ // even though these would mostly be ignored by the Add call, they will still be available in groups,
+ // which isn't what we want to be testing here.
+ if (point is SampleControlPoint)
+ continue;
+
+ newControlPoints.Add(point.Time, point.DeepClone());
+ }
+
+ return newControlPoints;
+ }
+ }
+
[Test]
public void TestEncodeMultiSegmentSliderWithFloatingPointError()
{
@@ -132,7 +174,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
}
}
- private Stream encodeToLegacy((IBeatmap beatmap, ISkin beatmapSkin) fullBeatmap)
+ private MemoryStream encodeToLegacy((IBeatmap beatmap, ISkin beatmapSkin) fullBeatmap)
{
var (beatmap, beatmapSkin) = fullBeatmap;
var stream = new MemoryStream();
diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs
index 5dc25d6643..b2bd60d342 100644
--- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs
+++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs
@@ -424,14 +424,14 @@ namespace osu.Game.Tests.Beatmaps.IO
checkBeatmapCount(osu, 12);
checkSingleReferencedFileCount(osu, 18);
- var breakTemp = TestResources.GetTestBeatmapForImport();
+ var brokenTempFilename = TestResources.GetTestBeatmapForImport();
MemoryStream brokenOsu = new MemoryStream();
- MemoryStream brokenOsz = new MemoryStream(await File.ReadAllBytesAsync(breakTemp));
+ MemoryStream brokenOsz = new MemoryStream(await File.ReadAllBytesAsync(brokenTempFilename));
- File.Delete(breakTemp);
+ File.Delete(brokenTempFilename);
- using (var outStream = File.Open(breakTemp, FileMode.CreateNew))
+ using (var outStream = File.Open(brokenTempFilename, FileMode.CreateNew))
using (var zip = ZipArchive.Open(brokenOsz))
{
zip.AddEntry("broken.osu", brokenOsu, false);
@@ -441,7 +441,7 @@ namespace osu.Game.Tests.Beatmaps.IO
// this will trigger purging of the existing beatmap (online set id match) but should rollback due to broken osu.
try
{
- await manager.Import(new ImportTask(breakTemp));
+ await manager.Import(new ImportTask(brokenTempFilename));
}
catch
{
@@ -456,6 +456,8 @@ namespace osu.Game.Tests.Beatmaps.IO
checkSingleReferencedFileCount(osu, 18);
Assert.AreEqual(1, loggedExceptionCount);
+
+ File.Delete(brokenTempFilename);
}
finally
{
diff --git a/osu.Game.Tests/Database/TestRealmKeyBindingStore.cs b/osu.Game.Tests/Database/TestRealmKeyBindingStore.cs
index 642ecf00b8..8be74f1a7c 100644
--- a/osu.Game.Tests/Database/TestRealmKeyBindingStore.cs
+++ b/osu.Game.Tests/Database/TestRealmKeyBindingStore.cs
@@ -11,6 +11,7 @@ using osu.Framework.Platform;
using osu.Game.Database;
using osu.Game.Input;
using osu.Game.Input.Bindings;
+using osu.Game.Rulesets;
using Realms;
namespace osu.Game.Tests.Database
@@ -42,7 +43,7 @@ namespace osu.Game.Tests.Database
KeyBindingContainer testContainer = new TestKeyBindingContainer();
- keyBindingStore.Register(testContainer);
+ keyBindingStore.Register(testContainer, Enumerable.Empty());
Assert.That(queryCount(), Is.EqualTo(3));
@@ -66,7 +67,7 @@ namespace osu.Game.Tests.Database
{
KeyBindingContainer testContainer = new TestKeyBindingContainer();
- keyBindingStore.Register(testContainer);
+ keyBindingStore.Register(testContainer, Enumerable.Empty());
using (var primaryUsage = realmContextFactory.GetForRead())
{
diff --git a/osu.Game.Tests/Editing/Checks/CheckMutedObjectsTest.cs b/osu.Game.Tests/Editing/Checks/CheckMutedObjectsTest.cs
index 41a8f72305..4ab6e5cef6 100644
--- a/osu.Game.Tests/Editing/Checks/CheckMutedObjectsTest.cs
+++ b/osu.Game.Tests/Editing/Checks/CheckMutedObjectsTest.cs
@@ -7,6 +7,7 @@ using NUnit.Framework;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
+using osu.Game.Beatmaps.Legacy;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Checks;
using osu.Game.Rulesets.Objects;
@@ -30,7 +31,7 @@ namespace osu.Game.Tests.Editing.Checks
{
check = new CheckMutedObjects();
- cpi = new ControlPointInfo();
+ cpi = new LegacyControlPointInfo();
cpi.Add(0, new SampleControlPoint { SampleVolume = volume_regular });
cpi.Add(1000, new SampleControlPoint { SampleVolume = volume_low });
cpi.Add(2000, new SampleControlPoint { SampleVolume = volume_muted });
diff --git a/osu.Game.Tests/Mods/ModSettingsEqualityComparison.cs b/osu.Game.Tests/Mods/ModSettingsEqualityComparison.cs
index 7a5789f01a..ce6b3a68a5 100644
--- a/osu.Game.Tests/Mods/ModSettingsEqualityComparison.cs
+++ b/osu.Game.Tests/Mods/ModSettingsEqualityComparison.cs
@@ -3,6 +3,7 @@
using NUnit.Framework;
using osu.Game.Online.API;
+using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods;
namespace osu.Game.Tests.Mods
@@ -11,26 +12,42 @@ namespace osu.Game.Tests.Mods
public class ModSettingsEqualityComparison
{
[Test]
- public void Test()
+ public void TestAPIMod()
{
+ var apiMod1 = new APIMod(new OsuModDoubleTime { SpeedChange = { Value = 1.25 } });
+ var apiMod2 = new APIMod(new OsuModDoubleTime { SpeedChange = { Value = 1.26 } });
+ var apiMod3 = new APIMod(new OsuModDoubleTime { SpeedChange = { Value = 1.26 } });
+
+ Assert.That(apiMod1, Is.Not.EqualTo(apiMod2));
+ Assert.That(apiMod2, Is.EqualTo(apiMod2));
+ Assert.That(apiMod2, Is.EqualTo(apiMod3));
+ Assert.That(apiMod3, Is.EqualTo(apiMod2));
+ }
+
+ [Test]
+ public void TestMod()
+ {
+ var ruleset = new OsuRuleset();
+
var mod1 = new OsuModDoubleTime { SpeedChange = { Value = 1.25 } };
var mod2 = new OsuModDoubleTime { SpeedChange = { Value = 1.26 } };
var mod3 = new OsuModDoubleTime { SpeedChange = { Value = 1.26 } };
- var apiMod1 = new APIMod(mod1);
- var apiMod2 = new APIMod(mod2);
- var apiMod3 = new APIMod(mod3);
+
+ var doubleConvertedMod1 = new APIMod(mod1).ToMod(ruleset);
+ var doulbeConvertedMod2 = new APIMod(mod2).ToMod(ruleset);
+ var doulbeConvertedMod3 = new APIMod(mod3).ToMod(ruleset);
Assert.That(mod1, Is.Not.EqualTo(mod2));
- Assert.That(apiMod1, Is.Not.EqualTo(apiMod2));
+ Assert.That(doubleConvertedMod1, Is.Not.EqualTo(doulbeConvertedMod2));
Assert.That(mod2, Is.EqualTo(mod2));
- Assert.That(apiMod2, Is.EqualTo(apiMod2));
+ Assert.That(doulbeConvertedMod2, Is.EqualTo(doulbeConvertedMod2));
Assert.That(mod2, Is.EqualTo(mod3));
- Assert.That(apiMod2, Is.EqualTo(apiMod3));
+ Assert.That(doulbeConvertedMod2, Is.EqualTo(doulbeConvertedMod3));
Assert.That(mod3, Is.EqualTo(mod2));
- Assert.That(apiMod3, Is.EqualTo(apiMod2));
+ Assert.That(doulbeConvertedMod3, Is.EqualTo(doulbeConvertedMod2));
}
}
}
diff --git a/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs b/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs
index 240ae4a90c..fabb016d5f 100644
--- a/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs
+++ b/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs
@@ -4,6 +4,7 @@
using System.Linq;
using NUnit.Framework;
using osu.Game.Beatmaps.ControlPoints;
+using osu.Game.Beatmaps.Legacy;
namespace osu.Game.Tests.NonVisual
{
@@ -64,7 +65,7 @@ namespace osu.Game.Tests.NonVisual
[Test]
public void TestAddRedundantSample()
{
- var cpi = new ControlPointInfo();
+ var cpi = new LegacyControlPointInfo();
cpi.Add(0, new SampleControlPoint()); // is *not* redundant, special exception for first sample point
cpi.Add(1000, new SampleControlPoint()); // is redundant
@@ -142,7 +143,7 @@ namespace osu.Game.Tests.NonVisual
[Test]
public void TestRemoveGroupAlsoRemovedControlPoints()
{
- var cpi = new ControlPointInfo();
+ var cpi = new LegacyControlPointInfo();
var group = cpi.GroupAt(1000, true);
diff --git a/osu.Game.Tests/NonVisual/Skinning/LegacySkinAnimationTest.cs b/osu.Game.Tests/NonVisual/Skinning/LegacySkinAnimationTest.cs
index e45b8f7dc5..785f31386d 100644
--- a/osu.Game.Tests/NonVisual/Skinning/LegacySkinAnimationTest.cs
+++ b/osu.Game.Tests/NonVisual/Skinning/LegacySkinAnimationTest.cs
@@ -40,10 +40,10 @@ namespace osu.Game.Tests.NonVisual.Skinning
assertPlaybackPosition(0);
AddStep("set start time to 1000", () => animationTimeReference.AnimationStartTime.Value = 1000);
- assertPlaybackPosition(-1000);
+ assertPlaybackPosition(0);
AddStep("set current time to 500", () => animationTimeReference.ManualClock.CurrentTime = 500);
- assertPlaybackPosition(-500);
+ assertPlaybackPosition(0);
}
private void assertPlaybackPosition(double expectedPosition)
diff --git a/osu.Game.Tests/Resources/TestResources.cs b/osu.Game.Tests/Resources/TestResources.cs
index 7170a76b8b..839366d98e 100644
--- a/osu.Game.Tests/Resources/TestResources.cs
+++ b/osu.Game.Tests/Resources/TestResources.cs
@@ -1,9 +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 System;
using System.IO;
using NUnit.Framework;
using osu.Framework.IO.Stores;
+using osu.Framework.Testing;
namespace osu.Game.Tests.Resources
{
@@ -11,6 +13,8 @@ namespace osu.Game.Tests.Resources
{
public const double QUICK_BEATMAP_LENGTH = 10000;
+ private static readonly TemporaryNativeStorage temp_storage = new TemporaryNativeStorage("TestResources");
+
public static DllResourceStore GetStore() => new DllResourceStore(typeof(TestResources).Assembly);
public static Stream OpenResource(string name) => GetStore().GetStream($"Resources/{name}");
@@ -25,7 +29,7 @@ namespace osu.Game.Tests.Resources
/// A path to a copy of a beatmap archive (osz). Should be deleted after use.
public static string GetQuickTestBeatmapForImport()
{
- var tempPath = Path.GetTempFileName() + ".osz";
+ var tempPath = getTempFilename();
using (var stream = OpenResource("Archives/241526 Soleily - Renatus_virtual_quick.osz"))
using (var newFile = File.Create(tempPath))
stream.CopyTo(newFile);
@@ -41,7 +45,7 @@ namespace osu.Game.Tests.Resources
/// A path to a copy of a beatmap archive (osz). Should be deleted after use.
public static string GetTestBeatmapForImport(bool virtualTrack = false)
{
- var tempPath = Path.GetTempFileName() + ".osz";
+ var tempPath = getTempFilename();
using (var stream = GetTestBeatmapStream(virtualTrack))
using (var newFile = File.Create(tempPath))
@@ -50,5 +54,7 @@ namespace osu.Game.Tests.Resources
Assert.IsTrue(File.Exists(tempPath));
return tempPath;
}
+
+ private static string getTempFilename() => temp_storage.GetFullPath(Guid.NewGuid() + ".osz");
}
}
diff --git a/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs b/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs
index 184a94912a..f0d9ece06f 100644
--- a/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs
+++ b/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs
@@ -36,9 +36,9 @@ namespace osu.Game.Tests.Rulesets.Scoring
[TestCase(ScoringMode.Standardised, HitResult.Meh, 750_000)]
[TestCase(ScoringMode.Standardised, HitResult.Ok, 800_000)]
[TestCase(ScoringMode.Standardised, HitResult.Great, 1_000_000)]
- [TestCase(ScoringMode.Classic, HitResult.Meh, 50)]
- [TestCase(ScoringMode.Classic, HitResult.Ok, 100)]
- [TestCase(ScoringMode.Classic, HitResult.Great, 300)]
+ [TestCase(ScoringMode.Classic, HitResult.Meh, 41)]
+ [TestCase(ScoringMode.Classic, HitResult.Ok, 46)]
+ [TestCase(ScoringMode.Classic, HitResult.Great, 72)]
public void TestSingleOsuHit(ScoringMode scoringMode, HitResult hitResult, int expectedScore)
{
scoreProcessor.Mode.Value = scoringMode;
@@ -85,19 +85,18 @@ namespace osu.Game.Tests.Rulesets.Scoring
[TestCase(ScoringMode.Standardised, HitResult.LargeTickHit, HitResult.LargeTickHit, 575_000)] // (3 * 30) / (4 * 30) * 300_000 + (0 / 4) * 700_000
[TestCase(ScoringMode.Standardised, HitResult.SmallBonus, HitResult.SmallBonus, 1_000_030)] // 1 * 300_000 + 700_000 (max combo 0) + 3 * 10 (bonus points)
[TestCase(ScoringMode.Standardised, HitResult.LargeBonus, HitResult.LargeBonus, 1_000_150)] // 1 * 300_000 + 700_000 (max combo 0) + 3 * 50 (bonus points)
- [TestCase(ScoringMode.Classic, HitResult.Miss, HitResult.Great, 0)] // (0 * 4 * 300) * (1 + 0 / 25)
- [TestCase(ScoringMode.Classic, HitResult.Meh, HitResult.Great, 156)] // (((3 * 50) / (4 * 300)) * 4 * 300) * (1 + 1 / 25)
- [TestCase(ScoringMode.Classic, HitResult.Ok, HitResult.Great, 312)] // (((3 * 100) / (4 * 300)) * 4 * 300) * (1 + 1 / 25)
- [TestCase(ScoringMode.Classic, HitResult.Good, HitResult.Perfect, 594)] // (((3 * 200) / (4 * 350)) * 4 * 300) * (1 + 1 / 25)
- [TestCase(ScoringMode.Classic, HitResult.Great, HitResult.Great, 936)] // (((3 * 300) / (4 * 300)) * 4 * 300) * (1 + 1 / 25)
- [TestCase(ScoringMode.Classic, HitResult.Perfect, HitResult.Perfect, 936)] // (((3 * 350) / (4 * 350)) * 4 * 300) * (1 + 1 / 25)
- [TestCase(ScoringMode.Classic, HitResult.SmallTickMiss, HitResult.SmallTickHit, 0)] // (0 * 1 * 300) * (1 + 0 / 25)
- [TestCase(ScoringMode.Classic, HitResult.SmallTickHit, HitResult.SmallTickHit, 225)] // (((3 * 10) / (4 * 10)) * 1 * 300) * (1 + 0 / 25)
- [TestCase(ScoringMode.Classic, HitResult.LargeTickMiss, HitResult.LargeTickHit, 0)] // (0 * 4 * 300) * (1 + 0 / 25)
- [TestCase(ScoringMode.Classic, HitResult.LargeTickHit, HitResult.LargeTickHit, 936)] // (((3 * 50) / (4 * 50)) * 4 * 300) * (1 + 1 / 25)
- // TODO: The following two cases don't match expectations currently (a single hit is registered in acc portion when it shouldn't be). See https://github.com/ppy/osu/issues/12604.
- [TestCase(ScoringMode.Classic, HitResult.SmallBonus, HitResult.SmallBonus, 330)] // (1 * 1 * 300) * (1 + 0 / 25) + 3 * 10 (bonus points)
- [TestCase(ScoringMode.Classic, HitResult.LargeBonus, HitResult.LargeBonus, 450)] // (1 * 1 * 300) * (1 + 0 / 25) + 3 * 50 (bonus points)
+ [TestCase(ScoringMode.Classic, HitResult.Miss, HitResult.Great, 0)]
+ [TestCase(ScoringMode.Classic, HitResult.Meh, HitResult.Great, 68)]
+ [TestCase(ScoringMode.Classic, HitResult.Ok, HitResult.Great, 81)]
+ [TestCase(ScoringMode.Classic, HitResult.Good, HitResult.Perfect, 109)]
+ [TestCase(ScoringMode.Classic, HitResult.Great, HitResult.Great, 149)]
+ [TestCase(ScoringMode.Classic, HitResult.Perfect, HitResult.Perfect, 149)]
+ [TestCase(ScoringMode.Classic, HitResult.SmallTickMiss, HitResult.SmallTickHit, 9)]
+ [TestCase(ScoringMode.Classic, HitResult.SmallTickHit, HitResult.SmallTickHit, 15)]
+ [TestCase(ScoringMode.Classic, HitResult.LargeTickMiss, HitResult.LargeTickHit, 0)]
+ [TestCase(ScoringMode.Classic, HitResult.LargeTickHit, HitResult.LargeTickHit, 149)]
+ [TestCase(ScoringMode.Classic, HitResult.SmallBonus, HitResult.SmallBonus, 18)]
+ [TestCase(ScoringMode.Classic, HitResult.LargeBonus, HitResult.LargeBonus, 18)]
public void TestFourVariousResultsOneMiss(ScoringMode scoringMode, HitResult hitResult, HitResult maxResult, int expectedScore)
{
var minResult = new TestJudgement(hitResult).MinResult;
@@ -129,8 +128,8 @@ namespace osu.Game.Tests.Rulesets.Scoring
///
[TestCase(ScoringMode.Standardised, HitResult.SmallTickHit, 978_571)] // (3 * 10 + 100) / (4 * 10 + 100) * 300_000 + (1 / 1) * 700_000
[TestCase(ScoringMode.Standardised, HitResult.SmallTickMiss, 914_286)] // (3 * 0 + 100) / (4 * 10 + 100) * 300_000 + (1 / 1) * 700_000
- [TestCase(ScoringMode.Classic, HitResult.SmallTickHit, 279)] // (((3 * 10 + 100) / (4 * 10 + 100)) * 1 * 300) * (1 + 0 / 25)
- [TestCase(ScoringMode.Classic, HitResult.SmallTickMiss, 214)] // (((3 * 0 + 100) / (4 * 10 + 100)) * 1 * 300) * (1 + 0 / 25)
+ [TestCase(ScoringMode.Classic, HitResult.SmallTickHit, 69)] // (((3 * 10 + 100) / (4 * 10 + 100)) * 1 * 300) * (1 + 0 / 25)
+ [TestCase(ScoringMode.Classic, HitResult.SmallTickMiss, 60)] // (((3 * 0 + 100) / (4 * 10 + 100)) * 1 * 300) * (1 + 0 / 25)
public void TestSmallTicksAccuracy(ScoringMode scoringMode, HitResult hitResult, int expectedScore)
{
IEnumerable hitObjects = Enumerable
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneDifficultySwitching.cs b/osu.Game.Tests/Visual/Editing/TestSceneDifficultySwitching.cs
new file mode 100644
index 0000000000..c81a1abfbc
--- /dev/null
+++ b/osu.Game.Tests/Visual/Editing/TestSceneDifficultySwitching.cs
@@ -0,0 +1,177 @@
+// 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 NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Testing;
+using osu.Game.Beatmaps;
+using osu.Game.Overlays.Dialog;
+using osu.Game.Rulesets;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Screens.Edit;
+using osu.Game.Tests.Beatmaps.IO;
+
+namespace osu.Game.Tests.Visual.Editing
+{
+ public class TestSceneDifficultySwitching : EditorTestScene
+ {
+ protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
+
+ protected override bool IsolateSavingFromDatabase => false;
+
+ [Resolved]
+ private OsuGameBase game { get; set; }
+
+ [Resolved]
+ private BeatmapManager beatmaps { get; set; }
+
+ private BeatmapSetInfo importedBeatmapSet;
+
+ public override void SetUpSteps()
+ {
+ AddStep("import test beatmap", () => importedBeatmapSet = ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).Result);
+ base.SetUpSteps();
+ }
+
+ protected override void LoadEditor()
+ {
+ Beatmap.Value = beatmaps.GetWorkingBeatmap(importedBeatmapSet.Beatmaps.First());
+ base.LoadEditor();
+ }
+
+ [Test]
+ public void TestBasicSwitch()
+ {
+ BeatmapInfo targetDifficulty = null;
+
+ AddStep("set target difficulty", () => targetDifficulty = importedBeatmapSet.Beatmaps.Last(beatmap => !beatmap.Equals(Beatmap.Value.BeatmapInfo)));
+ switchToDifficulty(() => targetDifficulty);
+ confirmEditingBeatmap(() => targetDifficulty);
+
+ AddStep("exit editor", () => Stack.Exit());
+ // ensure editor loader didn't resume.
+ AddAssert("stack empty", () => Stack.CurrentScreen == null);
+ }
+
+ [Test]
+ public void TestClockPositionPreservedBetweenSwitches()
+ {
+ BeatmapInfo targetDifficulty = null;
+ AddStep("seek editor to 00:05:00", () => EditorClock.Seek(5000));
+
+ AddStep("set target difficulty", () => targetDifficulty = importedBeatmapSet.Beatmaps.Last(beatmap => !beatmap.Equals(Beatmap.Value.BeatmapInfo)));
+ switchToDifficulty(() => targetDifficulty);
+ confirmEditingBeatmap(() => targetDifficulty);
+ AddAssert("editor clock at 00:05:00", () => EditorClock.CurrentTime == 5000);
+
+ AddStep("exit editor", () => Stack.Exit());
+ // ensure editor loader didn't resume.
+ AddAssert("stack empty", () => Stack.CurrentScreen == null);
+ }
+
+ [Test]
+ public void TestClipboardPreservedAfterSwitch([Values] bool sameRuleset)
+ {
+ BeatmapInfo targetDifficulty = null;
+
+ AddStep("select first object", () => EditorBeatmap.SelectedHitObjects.Add(EditorBeatmap.HitObjects.First()));
+ AddStep("copy object", () => Editor.Copy());
+
+ AddStep("set target difficulty", () =>
+ {
+ targetDifficulty = sameRuleset
+ ? importedBeatmapSet.Beatmaps.Last(beatmap => !beatmap.Equals(Beatmap.Value.BeatmapInfo) && beatmap.RulesetID == Beatmap.Value.BeatmapInfo.RulesetID)
+ : importedBeatmapSet.Beatmaps.Last(beatmap => !beatmap.Equals(Beatmap.Value.BeatmapInfo) && beatmap.RulesetID != Beatmap.Value.BeatmapInfo.RulesetID);
+ });
+ switchToDifficulty(() => targetDifficulty);
+ confirmEditingBeatmap(() => targetDifficulty);
+
+ AddAssert("no objects selected", () => !EditorBeatmap.SelectedHitObjects.Any());
+ AddStep("paste object", () => Editor.Paste());
+
+ if (sameRuleset)
+ AddAssert("object was pasted", () => EditorBeatmap.SelectedHitObjects.Any());
+ else
+ AddAssert("object was not pasted", () => !EditorBeatmap.SelectedHitObjects.Any());
+
+ AddStep("exit editor", () => Stack.Exit());
+
+ if (sameRuleset)
+ {
+ AddUntilStep("prompt for save dialog shown", () => DialogOverlay.CurrentDialog is PromptForSaveDialog);
+ AddStep("discard changes", () => ((PromptForSaveDialog)DialogOverlay.CurrentDialog).PerformOkAction());
+ }
+
+ // ensure editor loader didn't resume.
+ AddAssert("stack empty", () => Stack.CurrentScreen == null);
+ }
+
+ [Test]
+ public void TestPreventSwitchDueToUnsavedChanges()
+ {
+ BeatmapInfo targetDifficulty = null;
+ PromptForSaveDialog saveDialog = null;
+
+ AddStep("remove first hitobject", () => EditorBeatmap.RemoveAt(0));
+
+ AddStep("set target difficulty", () => targetDifficulty = importedBeatmapSet.Beatmaps.Last(beatmap => !beatmap.Equals(Beatmap.Value.BeatmapInfo)));
+ switchToDifficulty(() => targetDifficulty);
+
+ AddUntilStep("prompt for save dialog shown", () =>
+ {
+ saveDialog = this.ChildrenOfType().Single();
+ return saveDialog != null;
+ });
+ AddStep("continue editing", () =>
+ {
+ var continueButton = saveDialog.ChildrenOfType().Last();
+ continueButton.TriggerClick();
+ });
+
+ confirmEditingBeatmap(() => importedBeatmapSet.Beatmaps.First());
+
+ AddRepeatStep("exit editor forcefully", () => Stack.Exit(), 2);
+ // ensure editor loader didn't resume.
+ AddAssert("stack empty", () => Stack.CurrentScreen == null);
+ }
+
+ [Test]
+ public void TestAllowSwitchAfterDiscardingUnsavedChanges()
+ {
+ BeatmapInfo targetDifficulty = null;
+ PromptForSaveDialog saveDialog = null;
+
+ AddStep("remove first hitobject", () => EditorBeatmap.RemoveAt(0));
+
+ AddStep("set target difficulty", () => targetDifficulty = importedBeatmapSet.Beatmaps.Last(beatmap => !beatmap.Equals(Beatmap.Value.BeatmapInfo)));
+ switchToDifficulty(() => targetDifficulty);
+
+ AddUntilStep("prompt for save dialog shown", () =>
+ {
+ saveDialog = this.ChildrenOfType().Single();
+ return saveDialog != null;
+ });
+ AddStep("discard changes", () =>
+ {
+ var continueButton = saveDialog.ChildrenOfType().Single();
+ continueButton.TriggerClick();
+ });
+
+ confirmEditingBeatmap(() => targetDifficulty);
+
+ AddStep("exit editor forcefully", () => Stack.Exit());
+ // ensure editor loader didn't resume.
+ AddAssert("stack empty", () => Stack.CurrentScreen == null);
+ }
+
+ private void switchToDifficulty(Func difficulty) => AddStep("switch to difficulty", () => Editor.SwitchToDifficulty(difficulty.Invoke()));
+
+ private void confirmEditingBeatmap(Func targetDifficulty)
+ {
+ AddUntilStep("current beatmap is correct", () => Beatmap.Value.BeatmapInfo.Equals(targetDifficulty.Invoke()));
+ AddUntilStep("current screen is editor", () => Stack.CurrentScreen == Editor && Editor?.IsLoaded == true);
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs
index b6ae91844a..440d66ff9f 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs
@@ -11,6 +11,7 @@ using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
+using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Setup;
using osu.Game.Tests.Resources;
using SharpCompress.Archives;
@@ -55,6 +56,9 @@ namespace osu.Game.Tests.Visual.Editing
[Test]
public void TestExitWithoutSave()
{
+ EditorBeatmap editorBeatmap = null;
+
+ AddStep("store editor beatmap", () => editorBeatmap = EditorBeatmap);
AddStep("exit without save", () =>
{
Editor.Exit();
@@ -62,7 +66,7 @@ namespace osu.Game.Tests.Visual.Editing
});
AddUntilStep("wait for exit", () => !Editor.IsCurrentScreen());
- AddAssert("new beatmap not persisted", () => beatmapManager.QueryBeatmapSet(s => s.ID == EditorBeatmap.BeatmapInfo.BeatmapSet.ID)?.DeletePending == true);
+ AddAssert("new beatmap not persisted", () => beatmapManager.QueryBeatmapSet(s => s.ID == editorBeatmap.BeatmapInfo.BeatmapSet.ID)?.DeletePending == true);
}
[Test]
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorSeeking.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorSeeking.cs
index 96ce418851..ff741a8ed5 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneEditorSeeking.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorSeeking.cs
@@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual.Editing
beatmap.BeatmapInfo.BeatDivisor = 1;
- beatmap.ControlPointInfo = new ControlPointInfo();
+ beatmap.ControlPointInfo.Clear();
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 1000 });
beatmap.ControlPointInfo.Add(2000, new TimingControlPoint { BeatLength = 500 });
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs b/osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs
index 9253023c9a..c3c803ff23 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs
@@ -4,8 +4,13 @@
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
+using osu.Game.Rulesets;
+using osu.Game.Rulesets.Catch;
using osu.Game.Rulesets.Edit;
+using osu.Game.Rulesets.Mania;
+using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Beatmaps;
+using osu.Game.Rulesets.Taiko;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Setup;
@@ -23,15 +28,31 @@ namespace osu.Game.Tests.Visual.Editing
editorBeatmap = new EditorBeatmap(new OsuBeatmap());
}
- [BackgroundDependencyLoader]
- private void load()
- {
- Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
+ [Test]
+ public void TestOsu() => runForRuleset(new OsuRuleset().RulesetInfo);
- Child = new SetupScreen
+ [Test]
+ public void TestTaiko() => runForRuleset(new TaikoRuleset().RulesetInfo);
+
+ [Test]
+ public void TestCatch() => runForRuleset(new CatchRuleset().RulesetInfo);
+
+ [Test]
+ public void TestMania() => runForRuleset(new ManiaRuleset().RulesetInfo);
+
+ private void runForRuleset(RulesetInfo rulesetInfo)
+ {
+ AddStep("create screen", () =>
{
- State = { Value = Visibility.Visible },
- };
+ editorBeatmap.BeatmapInfo.Ruleset = rulesetInfo;
+
+ Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
+
+ Child = new SetupScreen
+ {
+ State = { Value = Visibility.Visible },
+ };
+ });
}
}
}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneAllRulesetPlayers.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneAllRulesetPlayers.cs
index b7dcad3825..00b5c38e20 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneAllRulesetPlayers.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneAllRulesetPlayers.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 System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Game.Configuration;
@@ -71,7 +70,7 @@ namespace osu.Game.Tests.Visual.Gameplay
var working = CreateWorkingBeatmap(rulesetInfo);
Beatmap.Value = working;
- SelectedMods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) };
+ SelectedMods.Value = new[] { ruleset.CreateMod() };
Player = CreatePlayer(ruleset);
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs
index 7accaef818..1ba0965ceb 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs
@@ -7,6 +7,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
+using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
@@ -137,6 +138,23 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("no circle added", () => !this.ChildrenOfType().Any());
}
+ [Test]
+ public void TestClear()
+ {
+ AddStep("OD 1", () => recreateDisplay(new OsuHitWindows(), 1));
+
+ AddStep("hit", () => newJudgement(0.2D));
+ AddAssert("bar added", () => this.ChildrenOfType().All(
+ meter => meter.ChildrenOfType().Count() == 1));
+ AddAssert("circle added", () => this.ChildrenOfType().All(
+ meter => meter.ChildrenOfType().Count() == 1));
+
+ AddStep("clear", () => this.ChildrenOfType().ForEach(meter => meter.Clear()));
+
+ AddAssert("bar cleared", () => !this.ChildrenOfType().Any());
+ AddAssert("colour cleared", () => !this.ChildrenOfType().Any());
+ }
+
private void recreateDisplay(HitWindows hitWindows, float overallDifficulty)
{
hitWindows?.SetDifficulty(overallDifficulty);
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyBindings.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyBindings.cs
index 6de85499c5..0a39d94027 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyBindings.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyBindings.cs
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Input.Bindings;
@@ -80,13 +81,13 @@ namespace osu.Game.Tests.Visual.Gameplay
{
public bool ReceivedAction;
- public bool OnPressed(TestAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
- ReceivedAction = action == TestAction.Down;
+ ReceivedAction = e.Action == TestAction.Down;
return true;
}
- public void OnReleased(TestAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
}
}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneParticleSpewer.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneParticleSpewer.cs
new file mode 100644
index 0000000000..ce5cd629e0
--- /dev/null
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneParticleSpewer.cs
@@ -0,0 +1,128 @@
+// 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.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Textures;
+using osu.Framework.Testing;
+using osu.Framework.Timing;
+using osu.Framework.Utils;
+using osu.Game.Graphics;
+using osu.Game.Skinning;
+using osuTK;
+
+namespace osu.Game.Tests.Visual.Gameplay
+{
+ [TestFixture]
+ public class TestSceneParticleSpewer : OsuTestScene
+ {
+ private TestParticleSpewer spewer;
+
+ [Resolved]
+ private SkinManager skinManager { get; set; }
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ Child = spewer = createSpewer();
+
+ AddToggleStep("toggle spawning", value => spewer.Active.Value = value);
+ AddSliderStep("particle gravity", 0f, 1f, 0f, value => spewer.Gravity = value);
+ AddSliderStep("particle velocity", 0f, 1f, 0.5f, value => spewer.MaxVelocity = value);
+ AddStep("move to new location", () =>
+ {
+ spewer.TransformTo(nameof(spewer.SpawnPosition), new Vector2(RNG.NextSingle(), RNG.NextSingle()), 1000, Easing.Out);
+ });
+ }
+
+ [SetUpSteps]
+ public void SetUpSteps()
+ {
+ AddStep("create spewer", () => Child = spewer = createSpewer());
+ }
+
+ [Test]
+ public void TestPresence()
+ {
+ AddStep("start spewer", () => spewer.Active.Value = true);
+ AddAssert("is present", () => spewer.IsPresent);
+
+ AddWaitStep("wait for some particles", 3);
+ AddStep("stop spewer", () => spewer.Active.Value = false);
+
+ AddWaitStep("wait for clean screen", 8);
+ AddAssert("is not present", () => !spewer.IsPresent);
+ }
+
+ [Test]
+ public void TestTimeJumps()
+ {
+ ManualClock testClock = new ManualClock();
+
+ AddStep("prepare clock", () =>
+ {
+ testClock.CurrentTime = TestParticleSpewer.MAX_DURATION * -3;
+ spewer.Clock = new FramedClock(testClock);
+ });
+ AddStep("start spewer", () => spewer.Active.Value = true);
+ AddAssert("spawned first particle", () => spewer.TotalCreatedParticles == 1);
+
+ AddStep("move clock forward", () => testClock.CurrentTime = TestParticleSpewer.MAX_DURATION * 3);
+ AddAssert("spawned second particle", () => spewer.TotalCreatedParticles == 2);
+
+ AddStep("move clock backwards", () => testClock.CurrentTime = TestParticleSpewer.MAX_DURATION * -1);
+ AddAssert("spawned third particle", () => spewer.TotalCreatedParticles == 3);
+ }
+
+ private TestParticleSpewer createSpewer() =>
+ new TestParticleSpewer(skinManager.DefaultLegacySkin.GetTexture("star2"))
+ {
+ Origin = Anchor.Centre,
+ RelativePositionAxes = Axes.Both,
+ RelativeSizeAxes = Axes.Both,
+ Position = new Vector2(0.5f),
+ Size = new Vector2(0.5f),
+ };
+
+ private class TestParticleSpewer : ParticleSpewer
+ {
+ public const int MAX_DURATION = 1500;
+ private const int rate = 250;
+
+ public int TotalCreatedParticles { get; private set; }
+
+ public float Gravity;
+
+ public float MaxVelocity = 0.25f;
+
+ public Vector2 SpawnPosition { get; set; } = new Vector2(0.5f);
+
+ protected override float ParticleGravity => Gravity;
+
+ public TestParticleSpewer(Texture texture)
+ : base(texture, rate, MAX_DURATION)
+ {
+ }
+
+ protected override FallingParticle CreateParticle()
+ {
+ TotalCreatedParticles++;
+
+ return new FallingParticle
+ {
+ Velocity = new Vector2(
+ RNG.NextSingle(-MaxVelocity, MaxVelocity),
+ RNG.NextSingle(-MaxVelocity, MaxVelocity)
+ ),
+ StartPosition = SpawnPosition,
+ Duration = RNG.NextSingle(MAX_DURATION),
+ StartAngle = RNG.NextSingle(MathF.PI * 2),
+ EndAngle = RNG.NextSingle(MathF.PI * 2),
+ EndScale = RNG.NextSingle(0.5f, 1.5f)
+ };
+ }
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs
index b38f7a998d..0a3fedaf8e 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs
@@ -54,7 +54,11 @@ namespace osu.Game.Tests.Visual.Gameplay
{
recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{
- Recorder = recorder = new TestReplayRecorder(new Score { Replay = replay })
+ Recorder = recorder = new TestReplayRecorder(new Score
+ {
+ Replay = replay,
+ ScoreInfo = { Beatmap = gameplayBeatmap.BeatmapInfo }
+ })
{
ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos),
},
@@ -222,13 +226,13 @@ namespace osu.Game.Tests.Visual.Gameplay
return base.OnMouseMove(e);
}
- public bool OnPressed(TestAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
box.Colour = Color4.White;
return true;
}
- public void OnReleased(TestAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
box.Colour = Color4.Black;
}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs
index 6e338b7202..dfd5e2dc58 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs
@@ -45,7 +45,11 @@ namespace osu.Game.Tests.Visual.Gameplay
{
recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{
- Recorder = new TestReplayRecorder(new Score { Replay = replay })
+ Recorder = new TestReplayRecorder(new Score
+ {
+ Replay = replay,
+ ScoreInfo = { Beatmap = gameplayBeatmap.BeatmapInfo }
+ })
{
ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos)
},
@@ -155,13 +159,13 @@ namespace osu.Game.Tests.Visual.Gameplay
return base.OnMouseMove(e);
}
- public bool OnPressed(TestAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
box.Colour = Color4.White;
return true;
}
- public void OnReleased(TestAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
box.Colour = Color4.Black;
}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs
index bb577886cc..6f5f774758 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs
@@ -279,13 +279,13 @@ namespace osu.Game.Tests.Visual.Gameplay
return base.OnMouseMove(e);
}
- public bool OnPressed(TestAction action)
+ public bool OnPressed(KeyBindingPressEvent e)
{
box.Colour = Color4.White;
return true;
}
- public void OnReleased(TestAction action)
+ public void OnReleased(KeyBindingReleaseEvent e)
{
box.Colour = Color4.Black;
}
@@ -354,7 +354,7 @@ namespace osu.Game.Tests.Visual.Gameplay
internal class TestReplayRecorder : ReplayRecorder
{
public TestReplayRecorder()
- : base(new Score())
+ : base(new Score { ScoreInfo = { Beatmap = new BeatmapInfo() } })
{
}
diff --git a/osu.Game.Tests/Visual/Menus/TestSceneLoginPanel.cs b/osu.Game.Tests/Visual/Menus/TestSceneLoginPanel.cs
new file mode 100644
index 0000000000..5fdadfc2fb
--- /dev/null
+++ b/osu.Game.Tests/Visual/Menus/TestSceneLoginPanel.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.Linq;
+using NUnit.Framework;
+using osu.Framework.Graphics;
+using osu.Framework.Testing;
+using osu.Game.Graphics.UserInterface;
+using osu.Game.Overlays.Login;
+
+namespace osu.Game.Tests.Visual.Menus
+{
+ [TestFixture]
+ public class TestSceneLoginPanel : OsuManualInputManagerTestScene
+ {
+ private LoginPanel loginPanel;
+
+ [SetUpSteps]
+ public void SetUpSteps()
+ {
+ AddStep("create login dialog", () =>
+ {
+ Add(loginPanel = new LoginPanel
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Width = 0.5f,
+ });
+ });
+ }
+
+ [Test]
+ public void TestBasicLogin()
+ {
+ AddStep("logout", () => API.Logout());
+
+ AddStep("enter password", () => loginPanel.ChildrenOfType().First().Text = "password");
+ AddStep("submit", () => loginPanel.ChildrenOfType().First(b => b.Text.ToString() == "Sign in").TriggerClick());
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoom.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoom.cs
index 3973dc57b2..b1f5781f6f 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoom.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoom.cs
@@ -130,6 +130,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
Type = { Value = MatchType.HeadToHead },
}));
+ AddUntilStep("wait for panel load", () => drawableRoom.ChildrenOfType().Any());
+
AddAssert("password icon hidden", () => Precision.AlmostEquals(0, drawableRoom.ChildrenOfType().Single().Alpha));
AddStep("set password", () => room.Password.Value = "password");
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerLoungeSubScreen.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerLoungeSubScreen.cs
index 99f6ab1ae1..b7da31a2b5 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerLoungeSubScreen.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerLoungeSubScreen.cs
@@ -3,6 +3,7 @@
using System.Linq;
using NUnit.Framework;
+using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Screens;
using osu.Framework.Testing;
@@ -51,6 +52,24 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("room join password correct", () => lastJoinedPassword == null);
}
+ [Test]
+ public void TestPopoverHidesOnBackButton()
+ {
+ AddStep("add room", () => RoomManager.AddRooms(1, withPassword: true));
+ AddStep("select room", () => InputManager.Key(Key.Down));
+ AddStep("attempt join room", () => InputManager.Key(Key.Enter));
+
+ AddUntilStep("password prompt appeared", () => InputManager.ChildrenOfType().Any());
+
+ AddAssert("textbox has focus", () => InputManager.FocusedDrawable is OsuPasswordTextBox);
+
+ AddStep("hit escape", () => InputManager.Key(Key.Escape));
+ AddAssert("textbox lost focus", () => InputManager.FocusedDrawable is SearchTextBox);
+
+ AddStep("hit escape", () => InputManager.Key(Key.Escape));
+ AddUntilStep("password prompt hidden", () => !InputManager.ChildrenOfType().Any());
+ }
+
[Test]
public void TestPopoverHidesOnLeavingScreen()
{
@@ -64,7 +83,41 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
[Test]
- public void TestJoinRoomWithPassword()
+ public void TestJoinRoomWithIncorrectPasswordViaButton()
+ {
+ DrawableLoungeRoom.PasswordEntryPopover passwordEntryPopover = null;
+
+ AddStep("add room", () => RoomManager.AddRooms(1, withPassword: true));
+ AddStep("select room", () => InputManager.Key(Key.Down));
+ AddStep("attempt join room", () => InputManager.Key(Key.Enter));
+ AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType().FirstOrDefault()) != null);
+ AddStep("enter password in text box", () => passwordEntryPopover.ChildrenOfType().First().Text = "wrong");
+ AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType().First().TriggerClick());
+
+ AddAssert("room not joined", () => loungeScreen.IsCurrentScreen());
+ AddUntilStep("password prompt still visible", () => passwordEntryPopover.State.Value == Visibility.Visible);
+ AddAssert("textbox still focused", () => InputManager.FocusedDrawable is OsuPasswordTextBox);
+ }
+
+ [Test]
+ public void TestJoinRoomWithIncorrectPasswordViaEnter()
+ {
+ DrawableLoungeRoom.PasswordEntryPopover passwordEntryPopover = null;
+
+ AddStep("add room", () => RoomManager.AddRooms(1, withPassword: true));
+ AddStep("select room", () => InputManager.Key(Key.Down));
+ AddStep("attempt join room", () => InputManager.Key(Key.Enter));
+ AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType().FirstOrDefault()) != null);
+ AddStep("enter password in text box", () => passwordEntryPopover.ChildrenOfType().First().Text = "wrong");
+ AddStep("press enter", () => InputManager.Key(Key.Enter));
+
+ AddAssert("room not joined", () => loungeScreen.IsCurrentScreen());
+ AddUntilStep("password prompt still visible", () => passwordEntryPopover.State.Value == Visibility.Visible);
+ AddAssert("textbox still focused", () => InputManager.FocusedDrawable is OsuPasswordTextBox);
+ }
+
+ [Test]
+ public void TestJoinRoomWithCorrectPassword()
{
DrawableLoungeRoom.PasswordEntryPopover passwordEntryPopover = null;
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchFooter.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchFooter.cs
index 4e08ffef17..44a8d7b439 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchFooter.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchFooter.cs
@@ -3,6 +3,7 @@
using NUnit.Framework;
using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
@@ -15,11 +16,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
SelectedRoom.Value = new Room();
- Child = new MultiplayerMatchFooter
+ Child = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
- Height = 50
+ RelativeSizeAxes = Axes.X,
+ Height = 50,
+ Child = new MultiplayerMatchFooter()
};
});
}
diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneOsuGame.cs b/osu.Game.Tests/Visual/Navigation/TestSceneOsuGame.cs
index b8232837b5..e2baa82ba0 100644
--- a/osu.Game.Tests/Visual/Navigation/TestSceneOsuGame.cs
+++ b/osu.Game.Tests/Visual/Navigation/TestSceneOsuGame.cs
@@ -75,7 +75,6 @@ namespace osu.Game.Tests.Visual.Navigation
typeof(FileStore),
typeof(ScoreManager),
typeof(BeatmapManager),
- typeof(SettingsStore),
typeof(RulesetConfigCache),
typeof(OsuColour),
typeof(IBindable),
@@ -97,9 +96,6 @@ namespace osu.Game.Tests.Visual.Navigation
{
AddStep("create game", () =>
{
- game = new OsuGame();
- game.SetHost(host);
-
Children = new Drawable[]
{
new Box
@@ -107,8 +103,9 @@ namespace osu.Game.Tests.Visual.Navigation
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
- game
};
+
+ AddGame(game = new OsuGame());
});
AddUntilStep("wait for load", () => game.IsLoaded);
diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs
index b536233ff0..aeb800f58a 100644
--- a/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs
+++ b/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs
@@ -15,6 +15,7 @@ using osu.Game.Overlays.Mods;
using osu.Game.Overlays.Toolbar;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
+using osu.Game.Screens.Menu;
using osu.Game.Screens.OnlinePlay.Components;
using osu.Game.Screens.OnlinePlay.Lounge;
using osu.Game.Screens.Play;
@@ -76,7 +77,13 @@ namespace osu.Game.Tests.Visual.Navigation
AddStep("press enter", () => InputManager.Key(Key.Enter));
- AddUntilStep("wait for player", () => (player = Game.ScreenStack.CurrentScreen as Player) != null);
+ AddUntilStep("wait for player", () =>
+ {
+ // dismiss any notifications that may appear (ie. muted notification).
+ clickMouseInCentre();
+ return (player = Game.ScreenStack.CurrentScreen as Player) != null;
+ });
+
AddAssert("retry count is 0", () => player.RestartCount == 0);
AddStep("attempt to retry", () => player.ChildrenOfType().First().Action());
@@ -103,7 +110,14 @@ namespace osu.Game.Tests.Visual.Navigation
AddStep("set mods", () => Game.SelectedMods.Value = new Mod[] { new OsuModNoFail(), new OsuModDoubleTime { SpeedChange = { Value = 2 } } });
AddStep("press enter", () => InputManager.Key(Key.Enter));
- AddUntilStep("wait for player", () => (player = Game.ScreenStack.CurrentScreen as Player) != null);
+
+ AddUntilStep("wait for player", () =>
+ {
+ // dismiss any notifications that may appear (ie. muted notification).
+ clickMouseInCentre();
+ return (player = Game.ScreenStack.CurrentScreen as Player) != null;
+ });
+
AddUntilStep("wait for track playing", () => beatmap().Track.IsRunning);
AddStep("seek to near end", () => player.ChildrenOfType().First().Seek(beatmap().Beatmap.HitObjects[^1].StartTime - 1000));
AddUntilStep("wait for pass", () => (results = Game.ScreenStack.CurrentScreen as ResultsScreen) != null && results.IsLoaded);
@@ -130,7 +144,13 @@ namespace osu.Game.Tests.Visual.Navigation
AddStep("press enter", () => InputManager.Key(Key.Enter));
- AddUntilStep("wait for player", () => (player = Game.ScreenStack.CurrentScreen as Player) != null);
+ AddUntilStep("wait for player", () =>
+ {
+ // dismiss any notifications that may appear (ie. muted notification).
+ clickMouseInCentre();
+ return (player = Game.ScreenStack.CurrentScreen as Player) != null;
+ });
+
AddUntilStep("wait for fail", () => player.HasFailed);
AddUntilStep("wait for track stop", () => !Game.MusicController.IsPlaying);
@@ -388,6 +408,27 @@ namespace osu.Game.Tests.Visual.Navigation
AddAssert("now playing is hidden", () => nowPlayingOverlay.State.Value == Visibility.Hidden);
}
+ [Test]
+ public void TestExitGameFromSongSelect()
+ {
+ PushAndConfirm(() => new TestPlaySongSelect());
+ exitViaEscapeAndConfirm();
+
+ pushEscape(); // returns to osu! logo
+
+ AddStep("Hold escape", () => InputManager.PressKey(Key.Escape));
+ AddUntilStep("Wait for intro", () => Game.ScreenStack.CurrentScreen is IntroTriangles);
+ AddStep("Release escape", () => InputManager.ReleaseKey(Key.Escape));
+ AddUntilStep("Wait for game exit", () => Game.ScreenStack.CurrentScreen == null);
+ AddStep("test dispose doesn't crash", () => Game.Dispose());
+ }
+
+ private void clickMouseInCentre()
+ {
+ InputManager.MoveMouseTo(Game.ScreenSpaceDrawQuad.Centre);
+ InputManager.Click(MouseButton.Left);
+ }
+
private void pushEscape() =>
AddStep("Press escape", () => InputManager.Key(Key.Escape));
diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapListingOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapListingOverlay.cs
index 5bfb676f81..963809ebe1 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapListingOverlay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapListingOverlay.cs
@@ -5,10 +5,10 @@ using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
-using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
+using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
@@ -17,10 +17,11 @@ using osu.Game.Overlays.BeatmapListing;
using osu.Game.Rulesets;
using osu.Game.Scoring;
using osu.Game.Users;
+using osuTK.Input;
namespace osu.Game.Tests.Visual.Online
{
- public class TestSceneBeatmapListingOverlay : OsuTestScene
+ public class TestSceneBeatmapListingOverlay : OsuManualInputManagerTestScene
{
private readonly List setsForResponse = new List();
@@ -28,27 +29,33 @@ namespace osu.Game.Tests.Visual.Online
private BeatmapListingSearchControl searchControl => overlay.ChildrenOfType().Single();
- [BackgroundDependencyLoader]
- private void load()
+ [SetUpSteps]
+ public void SetUpSteps()
{
- Child = overlay = new BeatmapListingOverlay { State = { Value = Visibility.Visible } };
-
- ((DummyAPIAccess)API).HandleRequest = req =>
+ AddStep("setup overlay", () =>
{
- if (!(req is SearchBeatmapSetsRequest searchBeatmapSetsRequest)) return false;
-
- searchBeatmapSetsRequest.TriggerSuccess(new SearchBeatmapSetsResponse
- {
- BeatmapSets = setsForResponse,
- });
-
- return true;
- };
+ Child = overlay = new BeatmapListingOverlay { State = { Value = Visibility.Visible } };
+ setsForResponse.Clear();
+ });
AddStep("initialize dummy", () =>
{
+ var api = (DummyAPIAccess)API;
+
+ api.HandleRequest = req =>
+ {
+ if (!(req is SearchBeatmapSetsRequest searchBeatmapSetsRequest)) return false;
+
+ searchBeatmapSetsRequest.TriggerSuccess(new SearchBeatmapSetsResponse
+ {
+ BeatmapSets = setsForResponse,
+ });
+
+ return true;
+ };
+
// non-supporter user
- ((DummyAPIAccess)API).LocalUser.Value = new User
+ api.LocalUser.Value = new User
{
Username = "TestBot",
Id = API.LocalUser.Value.Id + 1,
@@ -56,6 +63,51 @@ namespace osu.Game.Tests.Visual.Online
});
}
+ [Test]
+ public void TestHideViaBack()
+ {
+ AddAssert("is visible", () => overlay.State.Value == Visibility.Visible);
+ AddStep("hide", () => InputManager.Key(Key.Escape));
+ AddUntilStep("is hidden", () => overlay.State.Value == Visibility.Hidden);
+ }
+
+ [Test]
+ public void TestHideViaBackWithSearch()
+ {
+ AddAssert("is visible", () => overlay.State.Value == Visibility.Visible);
+
+ AddStep("search something", () => overlay.ChildrenOfType().First().Text = "search");
+
+ AddStep("kill search", () => InputManager.Key(Key.Escape));
+
+ AddAssert("search textbox empty", () => string.IsNullOrEmpty(overlay.ChildrenOfType().First().Text));
+ AddAssert("is visible", () => overlay.State.Value == Visibility.Visible);
+
+ AddStep("hide", () => InputManager.Key(Key.Escape));
+ AddUntilStep("is hidden", () => overlay.State.Value == Visibility.Hidden);
+ }
+
+ [Test]
+ public void TestHideViaBackWithScrolledSearch()
+ {
+ AddAssert("is visible", () => overlay.State.Value == Visibility.Visible);
+
+ AddStep("show many results", () => fetchFor(Enumerable.Repeat(CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet, 100).ToArray()));
+
+ AddUntilStep("placeholder hidden", () => !overlay.ChildrenOfType().Any(d => d.IsPresent));
+
+ AddStep("scroll to bottom", () => overlay.ChildrenOfType().First().ScrollToEnd());
+
+ AddStep("kill search", () => InputManager.Key(Key.Escape));
+
+ AddUntilStep("search textbox empty", () => string.IsNullOrEmpty(overlay.ChildrenOfType().First().Text));
+ AddUntilStep("is scrolled to top", () => overlay.ChildrenOfType().First().Current == 0);
+ AddAssert("is visible", () => overlay.State.Value == Visibility.Visible);
+
+ AddStep("hide", () => InputManager.Key(Key.Escape));
+ AddUntilStep("is hidden", () => overlay.State.Value == Visibility.Hidden);
+ }
+
[Test]
public void TestNoBeatmapsPlaceholder()
{
@@ -63,7 +115,7 @@ namespace osu.Game.Tests.Visual.Online
AddUntilStep("placeholder shown", () => overlay.ChildrenOfType().SingleOrDefault()?.IsPresent == true);
AddStep("fetch for 1 beatmap", () => fetchFor(CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet));
- AddUntilStep("placeholder hidden", () => !overlay.ChildrenOfType().Any());
+ AddUntilStep("placeholder hidden", () => !overlay.ChildrenOfType().Any(d => d.IsPresent));
AddStep("fetch for 0 beatmaps", () => fetchFor());
AddUntilStep("placeholder shown", () => overlay.ChildrenOfType().SingleOrDefault()?.IsPresent == true);
@@ -193,13 +245,15 @@ namespace osu.Game.Tests.Visual.Online
noPlaceholderShown();
}
+ private static int searchCount;
+
private void fetchFor(params BeatmapSetInfo[] beatmaps)
{
setsForResponse.Clear();
setsForResponse.AddRange(beatmaps.Select(b => new TestAPIBeatmapSet(b)));
// trigger arbitrary change for fetching.
- searchControl.Query.TriggerChange();
+ searchControl.Query.Value = $"search {searchCount++}";
}
private void setRankAchievedFilter(ScoreRank[] ranks)
@@ -229,8 +283,8 @@ namespace osu.Game.Tests.Visual.Online
private void noPlaceholderShown()
{
AddUntilStep("no placeholder shown", () =>
- !overlay.ChildrenOfType().Any()
- && !overlay.ChildrenOfType().Any());
+ !overlay.ChildrenOfType().Any(d => d.IsPresent)
+ && !overlay.ChildrenOfType().Any(d => d.IsPresent));
}
private class TestAPIBeatmapSet : APIBeatmapSet
diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs
index edc1696456..f420ad976b 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs
@@ -21,6 +21,8 @@ namespace osu.Game.Tests.Visual.Online
protected override bool UseOnlineAPI => true;
+ private int nextBeatmapSetId = 1;
+
public TestSceneBeatmapSetOverlay()
{
Add(overlay = new TestBeatmapSetOverlay());
@@ -240,12 +242,23 @@ namespace osu.Game.Tests.Visual.Online
{
AddStep("show explicit map", () =>
{
- var beatmapSet = CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet;
+ var beatmapSet = getBeatmapSet();
beatmapSet.OnlineInfo.HasExplicitContent = true;
overlay.ShowBeatmapSet(beatmapSet);
});
}
+ [Test]
+ public void TestFeaturedBeatmap()
+ {
+ AddStep("show featured map", () =>
+ {
+ var beatmapSet = getBeatmapSet();
+ beatmapSet.OnlineInfo.TrackId = 1;
+ overlay.ShowBeatmapSet(beatmapSet);
+ });
+ }
+
[Test]
public void TestHide()
{
@@ -308,6 +321,14 @@ namespace osu.Game.Tests.Visual.Online
};
}
+ private BeatmapSetInfo getBeatmapSet()
+ {
+ var beatmapSet = CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet;
+ // Make sure the overlay is reloaded (see `BeatmapSetInfo.Equals`).
+ beatmapSet.OnlineBeatmapSetID = nextBeatmapSetId++;
+ return beatmapSet;
+ }
+
private void downloadAssert(bool shown)
{
AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.Header.HeaderContent.DownloadButtonsVisible == shown);
diff --git a/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs
index 7cfca31167..609e637914 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.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.Collections.Generic;
using System.Linq;
using NUnit.Framework;
@@ -85,6 +86,22 @@ namespace osu.Game.Tests.Visual.Online
case JoinChannelRequest joinChannel:
joinChannel.TriggerSuccess();
return true;
+
+ case GetUserRequest getUser:
+ if (getUser.Lookup.Equals("some body", StringComparison.OrdinalIgnoreCase))
+ {
+ getUser.TriggerSuccess(new User
+ {
+ Username = "some body",
+ Id = 1,
+ });
+ }
+ else
+ {
+ getUser.TriggerFailure(new Exception());
+ }
+
+ return true;
}
return false;
@@ -322,6 +339,27 @@ namespace osu.Game.Tests.Visual.Online
AddAssert("Current channel is channel 1", () => currentChannel == channel1);
}
+ [Test]
+ public void TestChatCommand()
+ {
+ AddStep("Join channel 1", () => channelManager.JoinChannel(channel1));
+ AddStep("Select channel 1", () => clickDrawable(chatOverlay.TabMap[channel1]));
+
+ AddStep("Open chat with user", () => channelManager.PostCommand("chat some body"));
+ AddAssert("PM channel is selected", () =>
+ channelManager.CurrentChannel.Value.Type == ChannelType.PM && channelManager.CurrentChannel.Value.Users.Single().Username == "some body");
+
+ AddStep("Open chat with non-existent user", () => channelManager.PostCommand("chat nobody"));
+ AddAssert("Last message is error", () => channelManager.CurrentChannel.Value.Messages.Last() is ErrorMessage);
+
+ // Make sure no unnecessary requests are made when the PM channel is already open.
+ AddStep("Select channel 1", () => clickDrawable(chatOverlay.TabMap[channel1]));
+ AddStep("Unregister request handling", () => ((DummyAPIAccess)API).HandleRequest = null);
+ AddStep("Open chat with user", () => channelManager.PostCommand("chat some body"));
+ AddAssert("PM channel is selected", () =>
+ channelManager.CurrentChannel.Value.Type == ChannelType.PM && channelManager.CurrentChannel.Value.Users.Single().Username == "some body");
+ }
+
private void pressChannelHotkey(int number)
{
var channelKey = Key.Number0 + number;
diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs
index fd5f306e07..722010ace2 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs
@@ -99,16 +99,23 @@ namespace osu.Game.Tests.Visual.Online
[BackgroundDependencyLoader]
private void load(RulesetStore rulesets)
{
- var normal = CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet;
+ var normal = getBeatmapSet();
normal.OnlineInfo.HasVideo = true;
normal.OnlineInfo.HasStoryboard = true;
var undownloadable = getUndownloadableBeatmapSet();
var manyDifficulties = getManyDifficultiesBeatmapSet(rulesets);
- var explicitMap = CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet;
+ var explicitMap = getBeatmapSet();
explicitMap.OnlineInfo.HasExplicitContent = true;
+ var featuredMap = getBeatmapSet();
+ featuredMap.OnlineInfo.TrackId = 1;
+
+ var explicitFeaturedMap = getBeatmapSet();
+ explicitFeaturedMap.OnlineInfo.HasExplicitContent = true;
+ explicitFeaturedMap.OnlineInfo.TrackId = 2;
+
Child = new BasicScrollContainer
{
RelativeSizeAxes = Axes.Both,
@@ -125,13 +132,19 @@ namespace osu.Game.Tests.Visual.Online
new GridBeatmapPanel(undownloadable),
new GridBeatmapPanel(manyDifficulties),
new GridBeatmapPanel(explicitMap),
+ new GridBeatmapPanel(featuredMap),
+ new GridBeatmapPanel(explicitFeaturedMap),
new ListBeatmapPanel(normal),
new ListBeatmapPanel(undownloadable),
new ListBeatmapPanel(manyDifficulties),
- new ListBeatmapPanel(explicitMap)
+ new ListBeatmapPanel(explicitMap),
+ new ListBeatmapPanel(featuredMap),
+ new ListBeatmapPanel(explicitFeaturedMap)
},
},
};
+
+ BeatmapSetInfo getBeatmapSet() => CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet;
}
}
}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs
index 03d079261d..70271b0b08 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs
@@ -104,6 +104,9 @@ namespace osu.Game.Tests.Visual.Online
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c4.jpg"
}, api.IsLoggedIn));
+ AddStep("Show ppy from username", () => profile.ShowUser(@"peppy"));
+ AddStep("Show flyte from username", () => profile.ShowUser(@"flyte"));
+
AddStep("Hide", profile.Hide);
AddStep("Show without reload", profile.Show);
}
diff --git a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs
index dafa8300f6..5c248163d7 100644
--- a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs
+++ b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs
@@ -32,6 +32,12 @@ namespace osu.Game.Tests.Visual.Playlists
private RoomsContainer roomsContainer => loungeScreen.ChildrenOfType().First();
+ [Test]
+ public void TestManyRooms()
+ {
+ AddStep("add rooms", () => RoomManager.AddRooms(500));
+ }
+
[Test]
public void TestScrollByDraggingRooms()
{
diff --git a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs
index 61d49e4018..4bcc887b9f 100644
--- a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs
+++ b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs
@@ -160,11 +160,14 @@ namespace osu.Game.Tests.Visual.Playlists
Ruleset = { Value = new OsuRuleset().RulesetInfo }
}));
});
+
+ AddUntilStep("wait for load", () => resultsScreen.ChildrenOfType().FirstOrDefault()?.AllPanelsVisible == true);
}
private void waitForDisplay()
{
AddUntilStep("wait for request to complete", () => requestComplete);
+ AddUntilStep("wait for panels to be visible", () => resultsScreen.ChildrenOfType().FirstOrDefault()?.AllPanelsVisible == true);
AddWaitStep("wait for display", 5);
}
diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs b/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs
index ba6b6bd529..631455b727 100644
--- a/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs
+++ b/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs
@@ -99,7 +99,7 @@ namespace osu.Game.Tests.Visual.Ranking
TestResultsScreen screen = null;
AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
- AddUntilStep("wait for loaded", () => screen.IsLoaded);
+ AddUntilStep("wait for load", () => this.ChildrenOfType().Single().AllPanelsVisible);
AddStep("click expanded panel", () =>
{
@@ -138,7 +138,7 @@ namespace osu.Game.Tests.Visual.Ranking
TestResultsScreen screen = null;
AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
- AddUntilStep("wait for loaded", () => screen.IsLoaded);
+ AddUntilStep("wait for load", () => this.ChildrenOfType().Single().AllPanelsVisible);
AddStep("click expanded panel", () =>
{
@@ -177,7 +177,7 @@ namespace osu.Game.Tests.Visual.Ranking
TestResultsScreen screen = null;
AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
- AddUntilStep("wait for loaded", () => screen.IsLoaded);
+ AddUntilStep("wait for load", () => this.ChildrenOfType().Single().AllPanelsVisible);
ScorePanel expandedPanel = null;
ScorePanel contractedPanel = null;
@@ -223,6 +223,7 @@ namespace osu.Game.Tests.Visual.Ranking
TestResultsScreen screen = null;
AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
+ AddUntilStep("wait for load", () => this.ChildrenOfType().Single().AllPanelsVisible);
AddAssert("download button is disabled", () => !screen.ChildrenOfType().Last().Enabled.Value);
diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneScorePanelList.cs b/osu.Game.Tests/Visual/Ranking/TestSceneScorePanelList.cs
index e65dcb19b1..6f3b3028be 100644
--- a/osu.Game.Tests/Visual/Ranking/TestSceneScorePanelList.cs
+++ b/osu.Game.Tests/Visual/Ranking/TestSceneScorePanelList.cs
@@ -159,6 +159,9 @@ namespace osu.Game.Tests.Visual.Ranking
var firstScore = new TestScoreInfo(new OsuRuleset().RulesetInfo);
var secondScore = new TestScoreInfo(new OsuRuleset().RulesetInfo);
+ firstScore.User.Username = "A";
+ secondScore.User.Username = "B";
+
createListStep(() => new ScorePanelList());
AddStep("add scores and select first", () =>
@@ -168,6 +171,8 @@ namespace osu.Game.Tests.Visual.Ranking
list.SelectedScore.Value = firstScore;
});
+ AddUntilStep("wait for load", () => list.AllPanelsVisible);
+
assertScoreState(firstScore, true);
assertScoreState(secondScore, false);
@@ -182,6 +187,87 @@ namespace osu.Game.Tests.Visual.Ranking
assertExpandedPanelCentred();
}
+ [Test]
+ public void TestAddScoreImmediately()
+ {
+ var score = new TestScoreInfo(new OsuRuleset().RulesetInfo);
+
+ createListStep(() =>
+ {
+ var newList = new ScorePanelList { SelectedScore = { Value = score } };
+ newList.AddScore(score);
+ return newList;
+ });
+
+ assertScoreState(score, true);
+ assertExpandedPanelCentred();
+ }
+
+ [Test]
+ public void TestKeyboardNavigation()
+ {
+ var lowestScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { MaxCombo = 100 };
+ var middleScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { MaxCombo = 200 };
+ var highestScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { MaxCombo = 300 };
+
+ createListStep(() => new ScorePanelList());
+
+ AddStep("add scores and select middle", () =>
+ {
+ // order of addition purposefully scrambled.
+ list.AddScore(middleScore);
+ list.AddScore(lowestScore);
+ list.AddScore(highestScore);
+ list.SelectedScore.Value = middleScore;
+ });
+
+ assertScoreState(highestScore, false);
+ assertScoreState(middleScore, true);
+ assertScoreState(lowestScore, false);
+
+ AddStep("press left", () => InputManager.Key(Key.Left));
+
+ assertScoreState(highestScore, true);
+ assertScoreState(middleScore, false);
+ assertScoreState(lowestScore, false);
+ assertExpandedPanelCentred();
+
+ AddStep("press left at start of list", () => InputManager.Key(Key.Left));
+
+ assertScoreState(highestScore, true);
+ assertScoreState(middleScore, false);
+ assertScoreState(lowestScore, false);
+ assertExpandedPanelCentred();
+
+ AddStep("press right", () => InputManager.Key(Key.Right));
+
+ assertScoreState(highestScore, false);
+ assertScoreState(middleScore, true);
+ assertScoreState(lowestScore, false);
+ assertExpandedPanelCentred();
+
+ AddStep("press right again", () => InputManager.Key(Key.Right));
+
+ assertScoreState(highestScore, false);
+ assertScoreState(middleScore, false);
+ assertScoreState(lowestScore, true);
+ assertExpandedPanelCentred();
+
+ AddStep("press right at end of list", () => InputManager.Key(Key.Right));
+
+ assertScoreState(highestScore, false);
+ assertScoreState(middleScore, false);
+ assertScoreState(lowestScore, true);
+ assertExpandedPanelCentred();
+
+ AddStep("press left", () => InputManager.Key(Key.Left));
+
+ assertScoreState(highestScore, false);
+ assertScoreState(middleScore, true);
+ assertScoreState(lowestScore, false);
+ assertExpandedPanelCentred();
+ }
+
private void createListStep(Func creationFunc)
{
AddStep("create list", () => Child = list = creationFunc().With(d =>
diff --git a/osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs b/osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs
index 57ba051214..168d9fafcf 100644
--- a/osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs
+++ b/osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs
@@ -234,7 +234,7 @@ namespace osu.Game.Tests.Visual.Settings
{
AddAssert($"Check {name} is bound to {keyName}", () =>
{
- var firstRow = panel.ChildrenOfType().First(r => r.ChildrenOfType().Any(s => s.Text == name));
+ var firstRow = panel.ChildrenOfType().First(r => r.ChildrenOfType().Any(s => s.Text.ToString() == name));
var firstButton = firstRow.ChildrenOfType().First();
return firstButton.Text.Text == keyName;
@@ -247,7 +247,7 @@ namespace osu.Game.Tests.Visual.Settings
AddStep($"Scroll to {name}", () =>
{
- var firstRow = panel.ChildrenOfType().First(r => r.ChildrenOfType().Any(s => s.Text == name));
+ var firstRow = panel.ChildrenOfType().First(r => r.ChildrenOfType().Any(s => s.Text.ToString() == name));
firstButton = firstRow.ChildrenOfType().First();
panel.ChildrenOfType().First().ScrollTo(firstButton);
diff --git a/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs b/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs
index da474a64ba..997eac709d 100644
--- a/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs
+++ b/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs
@@ -1,14 +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.Linq;
using NUnit.Framework;
-using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input.Handlers.Tablet;
-using osu.Framework.Platform;
+using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Overlays;
+using osu.Game.Overlays.Settings;
using osu.Game.Overlays.Settings.Sections.Input;
using osuTK;
@@ -17,22 +18,34 @@ namespace osu.Game.Tests.Visual.Settings
[TestFixture]
public class TestSceneTabletSettings : OsuTestScene
{
- [BackgroundDependencyLoader]
- private void load(GameHost host)
- {
- var tabletHandler = new TestTabletHandler();
+ private TestTabletHandler tabletHandler;
+ private TabletSettings settings;
- AddRange(new Drawable[]
+ [SetUpSteps]
+ public void SetUpSteps()
+ {
+ AddStep("create settings", () =>
{
- new TabletSettings(tabletHandler)
+ tabletHandler = new TestTabletHandler();
+
+ Children = new Drawable[]
{
- RelativeSizeAxes = Axes.None,
- Width = SettingsPanel.PANEL_WIDTH,
- Anchor = Anchor.TopCentre,
- Origin = Anchor.TopCentre,
- }
+ settings = new TabletSettings(tabletHandler)
+ {
+ RelativeSizeAxes = Axes.None,
+ Width = SettingsPanel.PANEL_WIDTH,
+ Anchor = Anchor.TopCentre,
+ Origin = Anchor.TopCentre,
+ }
+ };
});
+ AddStep("set square size", () => tabletHandler.SetTabletSize(new Vector2(100, 100)));
+ }
+
+ [Test]
+ public void TestVariousTabletSizes()
+ {
AddStep("Test with wide tablet", () => tabletHandler.SetTabletSize(new Vector2(160, 100)));
AddStep("Test with square tablet", () => tabletHandler.SetTabletSize(new Vector2(300, 300)));
AddStep("Test with tall tablet", () => tabletHandler.SetTabletSize(new Vector2(100, 300)));
@@ -40,6 +53,71 @@ namespace osu.Game.Tests.Visual.Settings
AddStep("Test no tablet present", () => tabletHandler.SetTabletSize(Vector2.Zero));
}
+ [Test]
+ public void TestWideAspectRatioValidity()
+ {
+ AddStep("Test with wide tablet", () => tabletHandler.SetTabletSize(new Vector2(160, 100)));
+
+ AddStep("Reset to full area", () => settings.ChildrenOfType().First().TriggerClick());
+ ensureValid();
+
+ AddStep("rotate 10", () => tabletHandler.Rotation.Value = 10);
+ ensureInvalid();
+
+ AddStep("scale down", () => tabletHandler.AreaSize.Value *= 0.9f);
+ ensureInvalid();
+
+ AddStep("scale down", () => tabletHandler.AreaSize.Value *= 0.9f);
+ ensureInvalid();
+
+ AddStep("scale down", () => tabletHandler.AreaSize.Value *= 0.9f);
+ ensureValid();
+ }
+
+ [Test]
+ public void TestRotationValidity()
+ {
+ AddAssert("area valid", () => settings.AreaSelection.IsWithinBounds);
+
+ AddStep("rotate 90", () => tabletHandler.Rotation.Value = 90);
+ ensureValid();
+
+ AddStep("rotate 180", () => tabletHandler.Rotation.Value = 180);
+
+ ensureValid();
+
+ AddStep("rotate 270", () => tabletHandler.Rotation.Value = 270);
+
+ ensureValid();
+
+ AddStep("rotate 360", () => tabletHandler.Rotation.Value = 360);
+
+ ensureValid();
+
+ AddStep("rotate 0", () => tabletHandler.Rotation.Value = 0);
+ ensureValid();
+
+ AddStep("rotate 45", () => tabletHandler.Rotation.Value = 45);
+ ensureInvalid();
+
+ AddStep("rotate 0", () => tabletHandler.Rotation.Value = 0);
+ ensureValid();
+ }
+
+ [Test]
+ public void TestOffsetValidity()
+ {
+ ensureValid();
+ AddStep("move right", () => tabletHandler.AreaOffset.Value = Vector2.Zero);
+ ensureInvalid();
+ AddStep("move back", () => tabletHandler.AreaOffset.Value = tabletHandler.AreaSize.Value / 2);
+ ensureValid();
+ }
+
+ private void ensureValid() => AddAssert("area valid", () => settings.AreaSelection.IsWithinBounds);
+
+ private void ensureInvalid() => AddAssert("area invalid", () => !settings.AreaSelection.IsWithinBounds);
+
public class TestTabletHandler : ITabletHandler
{
public Bindable AreaOffset { get; } = new Bindable();
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs
index 40b2f66d74..dcc2111ad3 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs
@@ -89,7 +89,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("select EZ mod", () =>
{
var ruleset = advancedStats.Beatmap.Ruleset.CreateInstance();
- SelectedMods.Value = new[] { ruleset.GetAllMods().OfType().Single() };
+ SelectedMods.Value = new[] { ruleset.CreateMod() };
});
AddAssert("circle size bar is blue", () => barIsBlue(advancedStats.FirstValue));
@@ -106,7 +106,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("select HR mod", () =>
{
var ruleset = advancedStats.Beatmap.Ruleset.CreateInstance();
- SelectedMods.Value = new[] { ruleset.GetAllMods().OfType().Single() };
+ SelectedMods.Value = new[] { ruleset.CreateMod() };
});
AddAssert("circle size bar is red", () => barIsRed(advancedStats.FirstValue));
@@ -123,7 +123,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("select unchanged Difficulty Adjust mod", () =>
{
var ruleset = advancedStats.Beatmap.Ruleset.CreateInstance();
- var difficultyAdjustMod = ruleset.GetAllMods().OfType().Single();
+ var difficultyAdjustMod = ruleset.CreateMod();
difficultyAdjustMod.ReadFromDifficulty(advancedStats.Beatmap.BaseDifficulty);
SelectedMods.Value = new[] { difficultyAdjustMod };
});
@@ -142,7 +142,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("select changed Difficulty Adjust mod", () =>
{
var ruleset = advancedStats.Beatmap.Ruleset.CreateInstance();
- var difficultyAdjustMod = ruleset.GetAllMods().OfType().Single();
+ var difficultyAdjustMod = ruleset.CreateMod();
var originalDifficulty = advancedStats.Beatmap.BaseDifficulty;
difficultyAdjustMod.ReadFromDifficulty(originalDifficulty);
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs
index 184a2e59da..29815ce9ff 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs
@@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.SongSelect
dependencies.Cache(rulesetStore = new RulesetStore(ContextFactory));
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesetStore, null, dependencies.Get(), Resources, dependencies.Get(), Beatmap.Default));
- dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, null, ContextFactory));
+ dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, null, ContextFactory, Scheduler));
return dependencies;
}
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapMetadataDisplay.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapMetadataDisplay.cs
index 66ac700c51..f91d3f595b 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapMetadataDisplay.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapMetadataDisplay.cs
@@ -92,7 +92,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
AddStep("setup display", () =>
{
- var randomMods = Ruleset.Value.CreateInstance().GetAllMods().OrderBy(_ => RNG.Next()).Take(5).ToList();
+ var randomMods = Ruleset.Value.CreateInstance().CreateAllMods().OrderBy(_ => RNG.Next()).Take(5).ToList();
OsuLogo logo = new OsuLogo { Scale = new Vector2(0.15f) };
diff --git a/osu.Game.Tests/Visual/TestSceneOsuScreenStack.cs b/osu.Game.Tests/Visual/TestSceneOsuScreenStack.cs
index c55988d1bb..7729ad0ff3 100644
--- a/osu.Game.Tests/Visual/TestSceneOsuScreenStack.cs
+++ b/osu.Game.Tests/Visual/TestSceneOsuScreenStack.cs
@@ -5,8 +5,8 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Screens;
-using osu.Framework.Testing;
using osu.Game.Graphics.Sprites;
+using osu.Game.Overlays;
using osu.Game.Screens;
using osu.Game.Screens.Play;
using osuTK.Graphics;
@@ -18,10 +18,18 @@ namespace osu.Game.Tests.Visual
{
private TestOsuScreenStack stack;
- [SetUpSteps]
- public void SetUpSteps()
+ [Cached]
+ private MusicController musicController = new MusicController();
+
+ [BackgroundDependencyLoader]
+ private void load()
{
- AddStep("Create new screen stack", () => { Child = stack = new TestOsuScreenStack { RelativeSizeAxes = Axes.Both }; });
+ stack = new TestOsuScreenStack { RelativeSizeAxes = Axes.Both };
+
+ Add(musicController);
+ Add(stack);
+
+ LoadComponent(stack);
}
[Test]
@@ -42,6 +50,44 @@ namespace osu.Game.Tests.Visual
AddAssert("Parallax is off", () => stack.ParallaxAmount == 0);
}
+ [Test]
+ public void AllowTrackAdjustmentsTest()
+ {
+ AddStep("push allowing screen", () => stack.Push(loadNewScreen()));
+ AddAssert("allows adjustments 1", () => musicController.AllowTrackAdjustments);
+
+ AddStep("push inheriting screen", () => stack.Push(loadNewScreen()));
+ AddAssert("allows adjustments 2", () => musicController.AllowTrackAdjustments);
+
+ AddStep("push disallowing screen", () => stack.Push(loadNewScreen()));
+ AddAssert("disallows adjustments 3", () => !musicController.AllowTrackAdjustments);
+
+ AddStep("push inheriting screen", () => stack.Push(loadNewScreen()));
+ AddAssert("disallows adjustments 4", () => !musicController.AllowTrackAdjustments);
+
+ AddStep("push inheriting screen", () => stack.Push(loadNewScreen()));
+ AddAssert("disallows adjustments 5", () => !musicController.AllowTrackAdjustments);
+
+ AddStep("push allowing screen", () => stack.Push(loadNewScreen()));
+ AddAssert("allows adjustments 6", () => musicController.AllowTrackAdjustments);
+
+ // Now start exiting from screens
+ AddStep("exit screen", () => stack.Exit());
+ AddAssert("disallows adjustments 7", () => !musicController.AllowTrackAdjustments);
+
+ AddStep("exit screen", () => stack.Exit());
+ AddAssert("disallows adjustments 8", () => !musicController.AllowTrackAdjustments);
+
+ AddStep("exit screen", () => stack.Exit());
+ AddAssert("disallows adjustments 9", () => !musicController.AllowTrackAdjustments);
+
+ AddStep("exit screen", () => stack.Exit());
+ AddAssert("allows adjustments 10", () => musicController.AllowTrackAdjustments);
+
+ AddStep("exit screen", () => stack.Exit());
+ AddAssert("allows adjustments 11", () => musicController.AllowTrackAdjustments);
+ }
+
public class TestScreen : ScreenWithBeatmapBackground
{
private readonly string screenText;
@@ -78,5 +124,26 @@ namespace osu.Game.Tests.Visual
{
public new float ParallaxAmount => base.ParallaxAmount;
}
+
+ private class AllowScreen : OsuScreen
+ {
+ public override bool? AllowTrackAdjustments => true;
+ }
+
+ public class DisallowScreen : OsuScreen
+ {
+ public override bool? AllowTrackAdjustments => false;
+ }
+
+ private class InheritScreen : OsuScreen
+ {
+ }
+
+ private OsuScreen loadNewScreen() where T : OsuScreen, new()
+ {
+ OsuScreen screen = new T();
+ LoadComponent(screen);
+ return screen;
+ }
}
}
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSearchControl.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSearchControl.cs
index abd1baf0ac..008d91f649 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSearchControl.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSearchControl.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
+using Humanizer;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@@ -73,7 +74,7 @@ namespace osu.Game.Tests.Visual.UserInterface
};
control.Query.BindValueChanged(q => query.Text = $"Query: {q.NewValue}", true);
- control.General.BindCollectionChanged((u, v) => general.Text = $"General: {(control.General.Any() ? string.Join('.', control.General.Select(i => i.ToString().ToLowerInvariant())) : "")}", true);
+ control.General.BindCollectionChanged((u, v) => general.Text = $"General: {(control.General.Any() ? string.Join('.', control.General.Select(i => i.ToString().Underscore())) : "")}", true);
control.Ruleset.BindValueChanged(r => ruleset.Text = $"Ruleset: {r.NewValue}", true);
control.Category.BindValueChanged(c => category.Text = $"Category: {c.NewValue}", true);
control.Genre.BindValueChanged(g => genre.Text = $"Genre: {g.NewValue}", true);
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs
index 3f9e0048dd..2e30ed9827 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs
@@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual.UserInterface
private BeatmapManager beatmapManager;
private ScoreManager scoreManager;
- private readonly List scores = new List();
+ private readonly List importedScores = new List();
private BeatmapInfo beatmap;
[Cached]
@@ -82,7 +82,7 @@ namespace osu.Game.Tests.Visual.UserInterface
dependencies.Cache(rulesetStore = new RulesetStore(ContextFactory));
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesetStore, null, dependencies.Get(), Resources, dependencies.Get(), Beatmap.Default));
- dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, null, ContextFactory));
+ dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, null, ContextFactory, Scheduler));
beatmap = beatmapManager.Import(new ImportTask(TestResources.GetQuickTestBeatmapForImport())).Result.Beatmaps[0];
@@ -100,11 +100,9 @@ namespace osu.Game.Tests.Visual.UserInterface
User = new User { Username = "TestUser" },
};
- scores.Add(scoreManager.Import(score).Result);
+ importedScores.Add(scoreManager.Import(score).Result);
}
- scores.Sort(Comparer.Create((s1, s2) => s2.TotalScore.CompareTo(s1.TotalScore)));
-
return dependencies;
}
@@ -134,9 +132,14 @@ namespace osu.Game.Tests.Visual.UserInterface
[Test]
public void TestDeleteViaRightClick()
{
+ ScoreInfo scoreBeingDeleted = null;
AddStep("open menu for top score", () =>
{
- InputManager.MoveMouseTo(leaderboard.ChildrenOfType().First());
+ var leaderboardScore = leaderboard.ChildrenOfType().First();
+
+ scoreBeingDeleted = leaderboardScore.Score;
+
+ InputManager.MoveMouseTo(leaderboardScore);
InputManager.Click(MouseButton.Right);
});
@@ -158,14 +161,14 @@ namespace osu.Game.Tests.Visual.UserInterface
InputManager.Click(MouseButton.Left);
});
- AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineScoreID != scores[0].OnlineScoreID));
+ AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineScoreID != scoreBeingDeleted.OnlineScoreID));
}
[Test]
public void TestDeleteViaDatabase()
{
- AddStep("delete top score", () => scoreManager.Delete(scores[0]));
- AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineScoreID != scores[0].OnlineScoreID));
+ AddStep("delete top score", () => scoreManager.Delete(importedScores[0]));
+ AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineScoreID != importedScores[0].OnlineScoreID));
}
}
}
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModFlowDisplay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModFlowDisplay.cs
index 8f057c663b..10eab148de 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneModFlowDisplay.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModFlowDisplay.cs
@@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.UserInterface
Width = 200,
Current =
{
- Value = new OsuRuleset().GetAllMods().ToArray(),
+ Value = new OsuRuleset().CreateAllMods().ToArray(),
}
};
});
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModIcon.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModIcon.cs
index e7fa7d9235..513eb2fafc 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneModIcon.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModIcon.cs
@@ -1,7 +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 System.Linq;
using NUnit.Framework;
+using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.UI;
@@ -17,5 +19,16 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("create mod icon", () => Child = icon = new ModIcon(new OsuModDoubleTime()));
AddStep("change mod", () => icon.Mod = new OsuModEasy());
}
+
+ [Test]
+ public void TestInterfaceModType()
+ {
+ ModIcon icon = null;
+
+ var ruleset = new OsuRuleset();
+
+ AddStep("create mod icon", () => Child = icon = new ModIcon(ruleset.AllMods.First(m => m.Acronym == "DT")));
+ AddStep("change mod", () => icon.Mod = ruleset.AllMods.First(m => m.Acronym == "EZ"));
+ }
}
}
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs
index 9e253e089d..4f7aec3b67 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs
@@ -158,8 +158,8 @@ namespace osu.Game.Tests.Visual.UserInterface
var mania = new ManiaRuleset();
testModsWithSameBaseType(
- mania.GetAllMods().Single(m => m.GetType() == typeof(ManiaModFadeIn)),
- mania.GetAllMods().Single(m => m.GetType() == typeof(ManiaModHidden)));
+ mania.CreateMod(),
+ mania.CreateMod());
}
[Test]
diff --git a/osu.Game.Tests/osu.Game.Tests.csproj b/osu.Game.Tests/osu.Game.Tests.csproj
index 161e248d96..696f930467 100644
--- a/osu.Game.Tests/osu.Game.Tests.csproj
+++ b/osu.Game.Tests/osu.Game.Tests.csproj
@@ -3,7 +3,7 @@
-
+
diff --git a/osu.Game.Tournament.Tests/Components/TestSceneTournamentModDisplay.cs b/osu.Game.Tournament.Tests/Components/TestSceneTournamentModDisplay.cs
index b4d9fa4222..47e7ed9b61 100644
--- a/osu.Game.Tournament.Tests/Components/TestSceneTournamentModDisplay.cs
+++ b/osu.Game.Tournament.Tests/Components/TestSceneTournamentModDisplay.cs
@@ -45,7 +45,7 @@ namespace osu.Game.Tournament.Tests.Components
private void success(APIBeatmap apiBeatmap)
{
beatmap = apiBeatmap.ToBeatmap(rulesets);
- var mods = rulesets.GetRuleset(Ladder.Ruleset.Value.ID ?? 0).CreateInstance().GetAllMods();
+ var mods = rulesets.GetRuleset(Ladder.Ruleset.Value.ID ?? 0).CreateInstance().AllMods;
foreach (var mod in mods)
{
diff --git a/osu.Game.Tournament.Tests/osu.Game.Tournament.Tests.csproj b/osu.Game.Tournament.Tests/osu.Game.Tournament.Tests.csproj
index ba096abd36..2673c9ec9f 100644
--- a/osu.Game.Tournament.Tests/osu.Game.Tournament.Tests.csproj
+++ b/osu.Game.Tournament.Tests/osu.Game.Tournament.Tests.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/osu.Game.Tournament/Components/TournamentModIcon.cs b/osu.Game.Tournament/Components/TournamentModIcon.cs
index 43ac92d285..7c4e9c69a2 100644
--- a/osu.Game.Tournament/Components/TournamentModIcon.cs
+++ b/osu.Game.Tournament/Components/TournamentModIcon.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 System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@@ -49,7 +48,7 @@ namespace osu.Game.Tournament.Components
}
var ruleset = rulesets.GetRuleset(ladderInfo.Ruleset.Value?.ID ?? 0);
- var modIcon = ruleset?.CreateInstance().GetAllMods().FirstOrDefault(mod => mod.Acronym == modAcronym);
+ var modIcon = ruleset?.CreateInstance().CreateModFromAcronym(modAcronym);
if (modIcon == null)
return;
diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs
index 3eb766a667..8cb5da8083 100644
--- a/osu.Game/Beatmaps/BeatmapInfo.cs
+++ b/osu.Game/Beatmaps/BeatmapInfo.cs
@@ -93,6 +93,12 @@ namespace osu.Game.Beatmaps
public bool WidescreenStoryboard { get; set; }
public bool EpilepsyWarning { get; set; }
+ ///
+ /// Whether or not sound samples should change rate when playing with speed-changing mods.
+ /// TODO: only read/write supported for now, requires implementation in gameplay.
+ ///
+ public bool SamplesMatchPlaybackRate { get; set; }
+
public CountdownType Countdown { get; set; } = CountdownType.Normal;
///
diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs
index 27aa874dc9..bd85017d58 100644
--- a/osu.Game/Beatmaps/BeatmapManager.cs
+++ b/osu.Game/Beatmaps/BeatmapManager.cs
@@ -129,6 +129,7 @@ namespace osu.Game.Beatmaps
Ruleset = ruleset,
Metadata = metadata,
WidescreenStoryboard = true,
+ SamplesMatchPlaybackRate = true,
}
}
};
diff --git a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs
index 48f1f0ce68..3658dbab83 100644
--- a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs
+++ b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs
@@ -90,6 +90,12 @@ namespace osu.Game.Beatmaps
/// The song language of this beatmap set.
///
public BeatmapSetOnlineLanguage Language { get; set; }
+
+ ///
+ /// The track ID of this beatmap set.
+ /// Non-null only if the track is linked to a featured artist track entry.
+ ///
+ public int? TrackId { get; set; }
}
public class BeatmapSetOnlineGenre
diff --git a/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs
index 643c5d9adb..8203f2e968 100644
--- a/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs
+++ b/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
+using Newtonsoft.Json;
using osu.Game.Graphics;
using osu.Game.Utils;
using osuTK.Graphics;
@@ -13,6 +14,7 @@ namespace osu.Game.Beatmaps.ControlPoints
///
/// The time at which the control point takes effect.
///
+ [JsonIgnore]
public double Time => controlPointGroup?.Time ?? 0;
private ControlPointGroup controlPointGroup;
diff --git a/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs b/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs
index 2d0fc17a7b..3ff40fe194 100644
--- a/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs
+++ b/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs
@@ -41,14 +41,6 @@ namespace osu.Game.Beatmaps.ControlPoints
private readonly SortedList difficultyPoints = new SortedList(Comparer.Default);
- ///
- /// All sound points.
- ///
- [JsonProperty]
- public IBindableList SamplePoints => samplePoints;
-
- private readonly BindableList samplePoints = new BindableList();
-
///
/// All effect points.
///
@@ -69,7 +61,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// The time to find the difficulty control point at.
/// The difficulty control point.
[NotNull]
- public DifficultyControlPoint DifficultyPointAt(double time) => binarySearchWithFallback(DifficultyPoints, time, DifficultyControlPoint.DEFAULT);
+ public DifficultyControlPoint DifficultyPointAt(double time) => BinarySearchWithFallback(DifficultyPoints, time, DifficultyControlPoint.DEFAULT);
///
/// Finds the effect control point that is active at .
@@ -77,15 +69,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// The time to find the effect control point at.
/// The effect control point.
[NotNull]
- public EffectControlPoint EffectPointAt(double time) => binarySearchWithFallback(EffectPoints, time, EffectControlPoint.DEFAULT);
-
- ///
- /// Finds the sound control point that is active at .
- ///
- /// The time to find the sound control point at.
- /// The sound control point.
- [NotNull]
- public SampleControlPoint SamplePointAt(double time) => binarySearchWithFallback(SamplePoints, time, SamplePoints.Count > 0 ? SamplePoints[0] : SampleControlPoint.DEFAULT);
+ public EffectControlPoint EffectPointAt(double time) => BinarySearchWithFallback(EffectPoints, time, EffectControlPoint.DEFAULT);
///
/// Finds the timing control point that is active at .
@@ -93,7 +77,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// The time to find the timing control point at.
/// The timing control point.
[NotNull]
- public TimingControlPoint TimingPointAt(double time) => binarySearchWithFallback(TimingPoints, time, TimingPoints.Count > 0 ? TimingPoints[0] : TimingControlPoint.DEFAULT);
+ public TimingControlPoint TimingPointAt(double time) => BinarySearchWithFallback(TimingPoints, time, TimingPoints.Count > 0 ? TimingPoints[0] : TimingControlPoint.DEFAULT);
///
/// Finds the maximum BPM represented by any timing control point.
@@ -112,12 +96,11 @@ namespace osu.Game.Beatmaps.ControlPoints
///
/// Remove all s and return to a pristine state.
///
- public void Clear()
+ public virtual void Clear()
{
groups.Clear();
timingPoints.Clear();
difficultyPoints.Clear();
- samplePoints.Clear();
effectPoints.Clear();
}
@@ -129,7 +112,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// Whether the control point was added.
public bool Add(double time, ControlPoint controlPoint)
{
- if (checkAlreadyExisting(time, controlPoint))
+ if (CheckAlreadyExisting(time, controlPoint))
return false;
GroupAt(time, true).Add(controlPoint);
@@ -147,8 +130,8 @@ namespace osu.Game.Beatmaps.ControlPoints
if (addIfNotExisting)
{
- newGroup.ItemAdded += groupItemAdded;
- newGroup.ItemRemoved += groupItemRemoved;
+ newGroup.ItemAdded += GroupItemAdded;
+ newGroup.ItemRemoved += GroupItemRemoved;
groups.Insert(~i, newGroup);
return newGroup;
@@ -162,8 +145,8 @@ namespace osu.Game.Beatmaps.ControlPoints
foreach (var item in group.ControlPoints.ToArray())
group.Remove(item);
- group.ItemAdded -= groupItemAdded;
- group.ItemRemoved -= groupItemRemoved;
+ group.ItemAdded -= GroupItemAdded;
+ group.ItemRemoved -= GroupItemRemoved;
groups.Remove(group);
}
@@ -228,10 +211,10 @@ namespace osu.Game.Beatmaps.ControlPoints
/// The time to find the control point at.
/// The control point to use when is before any control points.
/// The active control point at , or a fallback if none found.
- private T binarySearchWithFallback(IReadOnlyList list, double time, T fallback)
+ protected T BinarySearchWithFallback(IReadOnlyList list, double time, T fallback)
where T : ControlPoint
{
- return binarySearch(list, time) ?? fallback;
+ return BinarySearch(list, time) ?? fallback;
}
///
@@ -240,7 +223,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// The list to search.
/// The time to find the control point at.
/// The active control point at .
- private T binarySearch(IReadOnlyList list, double time)
+ protected virtual T BinarySearch(IReadOnlyList list, double time)
where T : ControlPoint
{
if (list == null)
@@ -280,7 +263,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// The time to find the timing control point at.
/// A point to be added.
/// Whether the new point should be added.
- private bool checkAlreadyExisting(double time, ControlPoint newPoint)
+ protected virtual bool CheckAlreadyExisting(double time, ControlPoint newPoint)
{
ControlPoint existing = null;
@@ -288,17 +271,13 @@ namespace osu.Game.Beatmaps.ControlPoints
{
case TimingControlPoint _:
// Timing points are a special case and need to be added regardless of fallback availability.
- existing = binarySearch(TimingPoints, time);
+ existing = BinarySearch(TimingPoints, time);
break;
case EffectControlPoint _:
existing = EffectPointAt(time);
break;
- case SampleControlPoint _:
- existing = binarySearch(SamplePoints, time);
- break;
-
case DifficultyControlPoint _:
existing = DifficultyPointAt(time);
break;
@@ -307,7 +286,7 @@ namespace osu.Game.Beatmaps.ControlPoints
return newPoint?.IsRedundant(existing) == true;
}
- private void groupItemAdded(ControlPoint controlPoint)
+ protected virtual void GroupItemAdded(ControlPoint controlPoint)
{
switch (controlPoint)
{
@@ -319,17 +298,13 @@ namespace osu.Game.Beatmaps.ControlPoints
effectPoints.Add(typed);
break;
- case SampleControlPoint typed:
- samplePoints.Add(typed);
- break;
-
case DifficultyControlPoint typed:
difficultyPoints.Add(typed);
break;
}
}
- private void groupItemRemoved(ControlPoint controlPoint)
+ protected virtual void GroupItemRemoved(ControlPoint controlPoint)
{
switch (controlPoint)
{
@@ -341,10 +316,6 @@ namespace osu.Game.Beatmaps.ControlPoints
effectPoints.Remove(typed);
break;
- case SampleControlPoint typed:
- samplePoints.Remove(typed);
- break;
-
case DifficultyControlPoint typed:
difficultyPoints.Remove(typed);
break;
@@ -353,7 +324,7 @@ namespace osu.Game.Beatmaps.ControlPoints
public ControlPointInfo DeepClone()
{
- var controlPointInfo = new ControlPointInfo();
+ var controlPointInfo = (ControlPointInfo)Activator.CreateInstance(GetType());
foreach (var point in AllControlPoints)
controlPointInfo.Add(point.Time, point.DeepClone());
diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
index 0ddc9e4c48..4b5eaafa4a 100644
--- a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
+++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
@@ -44,6 +44,13 @@ namespace osu.Game.Beatmaps.Formats
offset = FormatVersion < 5 ? 24 : 0;
}
+ protected override Beatmap CreateTemplateObject()
+ {
+ var templateBeatmap = base.CreateTemplateObject();
+ templateBeatmap.ControlPointInfo = new LegacyControlPointInfo();
+ return templateBeatmap;
+ }
+
protected override void ParseStreamInto(LineBufferedReader stream, Beatmap beatmap)
{
this.beatmap = beatmap;
@@ -173,6 +180,10 @@ namespace osu.Game.Beatmaps.Formats
beatmap.BeatmapInfo.EpilepsyWarning = Parsing.ParseInt(pair.Value) == 1;
break;
+ case @"SamplesMatchPlaybackRate":
+ beatmap.BeatmapInfo.SamplesMatchPlaybackRate = Parsing.ParseInt(pair.Value) == 1;
+ break;
+
case @"Countdown":
beatmap.BeatmapInfo.Countdown = (CountdownType)Enum.Parse(typeof(CountdownType), pair.Value);
break;
@@ -430,8 +441,13 @@ namespace osu.Game.Beatmaps.Formats
parser ??= new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser(getOffsetTime(), FormatVersion);
var obj = parser.Parse(line);
+
if (obj != null)
+ {
+ obj.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty);
+
beatmap.HitObjects.Add(obj);
+ }
}
private int getOffsetTime(int time) => time + (ApplyOffsets ? offset : 0);
diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs
index fb6806a13d..aef13b8872 100644
--- a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs
+++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs
@@ -86,7 +86,7 @@ namespace osu.Game.Beatmaps.Formats
writer.WriteLine(FormattableString.Invariant($"AudioLeadIn: {beatmap.BeatmapInfo.AudioLeadIn}"));
writer.WriteLine(FormattableString.Invariant($"PreviewTime: {beatmap.Metadata.PreviewTime}"));
writer.WriteLine(FormattableString.Invariant($"Countdown: {(int)beatmap.BeatmapInfo.Countdown}"));
- writer.WriteLine(FormattableString.Invariant($"SampleSet: {toLegacySampleBank(beatmap.ControlPointInfo.SamplePointAt(double.MinValue).SampleBank)}"));
+ writer.WriteLine(FormattableString.Invariant($"SampleSet: {toLegacySampleBank((beatmap.HitObjects.FirstOrDefault()?.SampleControlPoint ?? SampleControlPoint.DEFAULT).SampleBank)}"));
writer.WriteLine(FormattableString.Invariant($"StackLeniency: {beatmap.BeatmapInfo.StackLeniency}"));
writer.WriteLine(FormattableString.Invariant($"Mode: {beatmap.BeatmapInfo.RulesetID}"));
writer.WriteLine(FormattableString.Invariant($"LetterboxInBreaks: {(beatmap.BeatmapInfo.LetterboxInBreaks ? '1' : '0')}"));
@@ -105,8 +105,8 @@ namespace osu.Game.Beatmaps.Formats
if (beatmap.BeatmapInfo.RulesetID == 3)
writer.WriteLine(FormattableString.Invariant($"SpecialStyle: {(beatmap.BeatmapInfo.SpecialStyle ? '1' : '0')}"));
writer.WriteLine(FormattableString.Invariant($"WidescreenStoryboard: {(beatmap.BeatmapInfo.WidescreenStoryboard ? '1' : '0')}"));
- // if (b.SamplesMatchPlaybackRate)
- // writer.WriteLine(@"SamplesMatchPlaybackRate: 1");
+ if (beatmap.BeatmapInfo.SamplesMatchPlaybackRate)
+ writer.WriteLine(@"SamplesMatchPlaybackRate: 1");
}
private void handleEditor(TextWriter writer)
@@ -172,6 +172,30 @@ namespace osu.Game.Beatmaps.Formats
writer.WriteLine("[TimingPoints]");
+ if (!(beatmap.ControlPointInfo is LegacyControlPointInfo))
+ {
+ var legacyControlPoints = new LegacyControlPointInfo();
+
+ foreach (var point in beatmap.ControlPointInfo.AllControlPoints)
+ legacyControlPoints.Add(point.Time, point.DeepClone());
+
+ beatmap.ControlPointInfo = legacyControlPoints;
+
+ SampleControlPoint lastRelevantSamplePoint = null;
+
+ // iterate over hitobjects and pull out all required sample changes
+ foreach (var h in beatmap.HitObjects)
+ {
+ var hSamplePoint = h.SampleControlPoint;
+
+ if (!hSamplePoint.IsRedundant(lastRelevantSamplePoint))
+ {
+ legacyControlPoints.Add(hSamplePoint.Time, hSamplePoint);
+ lastRelevantSamplePoint = hSamplePoint;
+ }
+ }
+ }
+
foreach (var group in beatmap.ControlPointInfo.Groups)
{
var groupTimingPoint = group.ControlPoints.OfType().FirstOrDefault();
@@ -181,19 +205,19 @@ namespace osu.Game.Beatmaps.Formats
{
writer.Write(FormattableString.Invariant($"{groupTimingPoint.Time},"));
writer.Write(FormattableString.Invariant($"{groupTimingPoint.BeatLength},"));
- outputControlPointEffectsAt(groupTimingPoint.Time, true);
+ outputControlPointAt(groupTimingPoint.Time, true);
}
// Output any remaining effects as secondary non-timing control point.
var difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(group.Time);
writer.Write(FormattableString.Invariant($"{group.Time},"));
writer.Write(FormattableString.Invariant($"{-100 / difficultyPoint.SpeedMultiplier},"));
- outputControlPointEffectsAt(group.Time, false);
+ outputControlPointAt(group.Time, false);
}
- void outputControlPointEffectsAt(double time, bool isTimingPoint)
+ void outputControlPointAt(double time, bool isTimingPoint)
{
- var samplePoint = beatmap.ControlPointInfo.SamplePointAt(time);
+ var samplePoint = ((LegacyControlPointInfo)beatmap.ControlPointInfo).SamplePointAt(time);
var effectPoint = beatmap.ControlPointInfo.EffectPointAt(time);
// Apply the control point to a hit sample to uncover legacy properties (e.g. suffix)
diff --git a/osu.Game/Beatmaps/Legacy/LegacyControlPointInfo.cs b/osu.Game/Beatmaps/Legacy/LegacyControlPointInfo.cs
new file mode 100644
index 0000000000..ff0ca5ebe1
--- /dev/null
+++ b/osu.Game/Beatmaps/Legacy/LegacyControlPointInfo.cs
@@ -0,0 +1,62 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using JetBrains.Annotations;
+using Newtonsoft.Json;
+using osu.Framework.Bindables;
+using osu.Game.Beatmaps.ControlPoints;
+
+namespace osu.Game.Beatmaps.Legacy
+{
+ public class LegacyControlPointInfo : ControlPointInfo
+ {
+ ///
+ /// All sound points.
+ ///
+ [JsonProperty]
+ public IBindableList SamplePoints => samplePoints;
+
+ private readonly BindableList samplePoints = new BindableList();
+
+ ///