Merge branch 'master' of https://github.com/ppy/osu into tourney-asset-refactor
72
Gemfile.lock
@ -5,6 +5,22 @@ GEM
|
|||||||
addressable (2.7.0)
|
addressable (2.7.0)
|
||||||
public_suffix (>= 2.0.2, < 5.0)
|
public_suffix (>= 2.0.2, < 5.0)
|
||||||
atomos (0.1.3)
|
atomos (0.1.3)
|
||||||
|
aws-eventstream (1.1.0)
|
||||||
|
aws-partitions (1.329.0)
|
||||||
|
aws-sdk-core (3.99.2)
|
||||||
|
aws-eventstream (~> 1, >= 1.0.2)
|
||||||
|
aws-partitions (~> 1, >= 1.239.0)
|
||||||
|
aws-sigv4 (~> 1.1)
|
||||||
|
jmespath (~> 1.0)
|
||||||
|
aws-sdk-kms (1.34.1)
|
||||||
|
aws-sdk-core (~> 3, >= 3.99.0)
|
||||||
|
aws-sigv4 (~> 1.1)
|
||||||
|
aws-sdk-s3 (1.68.1)
|
||||||
|
aws-sdk-core (~> 3, >= 3.99.0)
|
||||||
|
aws-sdk-kms (~> 1)
|
||||||
|
aws-sigv4 (~> 1.1)
|
||||||
|
aws-sigv4 (1.1.4)
|
||||||
|
aws-eventstream (~> 1.0, >= 1.0.2)
|
||||||
babosa (1.0.3)
|
babosa (1.0.3)
|
||||||
claide (1.0.3)
|
claide (1.0.3)
|
||||||
colored (1.2)
|
colored (1.2)
|
||||||
@ -13,23 +29,24 @@ GEM
|
|||||||
highline (~> 1.7.2)
|
highline (~> 1.7.2)
|
||||||
declarative (0.0.10)
|
declarative (0.0.10)
|
||||||
declarative-option (0.1.0)
|
declarative-option (0.1.0)
|
||||||
digest-crc (0.4.1)
|
digest-crc (0.5.1)
|
||||||
domain_name (0.5.20190701)
|
domain_name (0.5.20190701)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
dotenv (2.7.5)
|
dotenv (2.7.5)
|
||||||
emoji_regex (1.0.1)
|
emoji_regex (1.0.1)
|
||||||
excon (0.71.1)
|
excon (0.74.0)
|
||||||
faraday (0.17.3)
|
faraday (1.0.1)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
faraday-cookie_jar (0.0.6)
|
faraday-cookie_jar (0.0.6)
|
||||||
faraday (>= 0.7.4)
|
faraday (>= 0.7.4)
|
||||||
http-cookie (~> 1.0.0)
|
http-cookie (~> 1.0.0)
|
||||||
faraday_middleware (0.13.1)
|
faraday_middleware (1.0.0)
|
||||||
faraday (>= 0.7.4, < 1.0)
|
faraday (~> 1.0)
|
||||||
fastimage (2.1.7)
|
fastimage (2.1.7)
|
||||||
fastlane (2.140.0)
|
fastlane (2.149.1)
|
||||||
CFPropertyList (>= 2.3, < 4.0.0)
|
CFPropertyList (>= 2.3, < 4.0.0)
|
||||||
addressable (>= 2.3, < 3.0.0)
|
addressable (>= 2.3, < 3.0.0)
|
||||||
|
aws-sdk-s3 (~> 1.0)
|
||||||
babosa (>= 1.0.2, < 2.0.0)
|
babosa (>= 1.0.2, < 2.0.0)
|
||||||
bundler (>= 1.12.0, < 3.0.0)
|
bundler (>= 1.12.0, < 3.0.0)
|
||||||
colored
|
colored
|
||||||
@ -37,12 +54,12 @@ GEM
|
|||||||
dotenv (>= 2.1.1, < 3.0.0)
|
dotenv (>= 2.1.1, < 3.0.0)
|
||||||
emoji_regex (>= 0.1, < 2.0)
|
emoji_regex (>= 0.1, < 2.0)
|
||||||
excon (>= 0.71.0, < 1.0.0)
|
excon (>= 0.71.0, < 1.0.0)
|
||||||
faraday (~> 0.17)
|
faraday (>= 0.17, < 2.0)
|
||||||
faraday-cookie_jar (~> 0.0.6)
|
faraday-cookie_jar (~> 0.0.6)
|
||||||
faraday_middleware (~> 0.13.1)
|
faraday_middleware (>= 0.13.1, < 2.0)
|
||||||
fastimage (>= 2.1.0, < 3.0.0)
|
fastimage (>= 2.1.0, < 3.0.0)
|
||||||
gh_inspector (>= 1.1.2, < 2.0.0)
|
gh_inspector (>= 1.1.2, < 2.0.0)
|
||||||
google-api-client (>= 0.29.2, < 0.37.0)
|
google-api-client (>= 0.37.0, < 0.39.0)
|
||||||
google-cloud-storage (>= 1.15.0, < 2.0.0)
|
google-cloud-storage (>= 1.15.0, < 2.0.0)
|
||||||
highline (>= 1.7.2, < 2.0.0)
|
highline (>= 1.7.2, < 2.0.0)
|
||||||
json (< 3.0.0)
|
json (< 3.0.0)
|
||||||
@ -69,7 +86,7 @@ GEM
|
|||||||
souyuz (= 0.9.1)
|
souyuz (= 0.9.1)
|
||||||
fastlane-plugin-xamarin (0.6.3)
|
fastlane-plugin-xamarin (0.6.3)
|
||||||
gh_inspector (1.1.3)
|
gh_inspector (1.1.3)
|
||||||
google-api-client (0.36.4)
|
google-api-client (0.38.0)
|
||||||
addressable (~> 2.5, >= 2.5.1)
|
addressable (~> 2.5, >= 2.5.1)
|
||||||
googleauth (~> 0.9)
|
googleauth (~> 0.9)
|
||||||
httpclient (>= 2.8.1, < 3.0)
|
httpclient (>= 2.8.1, < 3.0)
|
||||||
@ -80,27 +97,28 @@ GEM
|
|||||||
google-cloud-core (1.5.0)
|
google-cloud-core (1.5.0)
|
||||||
google-cloud-env (~> 1.0)
|
google-cloud-env (~> 1.0)
|
||||||
google-cloud-errors (~> 1.0)
|
google-cloud-errors (~> 1.0)
|
||||||
google-cloud-env (1.3.0)
|
google-cloud-env (1.3.2)
|
||||||
faraday (~> 0.11)
|
faraday (>= 0.17.3, < 2.0)
|
||||||
google-cloud-errors (1.0.0)
|
google-cloud-errors (1.0.1)
|
||||||
google-cloud-storage (1.25.1)
|
google-cloud-storage (1.26.2)
|
||||||
addressable (~> 2.5)
|
addressable (~> 2.5)
|
||||||
digest-crc (~> 0.4)
|
digest-crc (~> 0.4)
|
||||||
google-api-client (~> 0.33)
|
google-api-client (~> 0.33)
|
||||||
google-cloud-core (~> 1.2)
|
google-cloud-core (~> 1.2)
|
||||||
googleauth (~> 0.9)
|
googleauth (~> 0.9)
|
||||||
mini_mime (~> 1.0)
|
mini_mime (~> 1.0)
|
||||||
googleauth (0.10.0)
|
googleauth (0.12.0)
|
||||||
faraday (~> 0.12)
|
faraday (>= 0.17.3, < 2.0)
|
||||||
jwt (>= 1.4, < 3.0)
|
jwt (>= 1.4, < 3.0)
|
||||||
memoist (~> 0.16)
|
memoist (~> 0.16)
|
||||||
multi_json (~> 1.11)
|
multi_json (~> 1.11)
|
||||||
os (>= 0.9, < 2.0)
|
os (>= 0.9, < 2.0)
|
||||||
signet (~> 0.12)
|
signet (~> 0.14)
|
||||||
highline (1.7.10)
|
highline (1.7.10)
|
||||||
http-cookie (1.0.3)
|
http-cookie (1.0.3)
|
||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
httpclient (2.8.3)
|
httpclient (2.8.3)
|
||||||
|
jmespath (1.4.0)
|
||||||
json (2.3.0)
|
json (2.3.0)
|
||||||
jwt (2.1.0)
|
jwt (2.1.0)
|
||||||
memoist (0.16.2)
|
memoist (0.16.2)
|
||||||
@ -114,7 +132,7 @@ GEM
|
|||||||
naturally (2.2.0)
|
naturally (2.2.0)
|
||||||
nokogiri (1.10.7)
|
nokogiri (1.10.7)
|
||||||
mini_portile2 (~> 2.4.0)
|
mini_portile2 (~> 2.4.0)
|
||||||
os (1.0.1)
|
os (1.1.0)
|
||||||
plist (3.5.0)
|
plist (3.5.0)
|
||||||
public_suffix (2.0.5)
|
public_suffix (2.0.5)
|
||||||
representable (3.0.4)
|
representable (3.0.4)
|
||||||
@ -125,12 +143,12 @@ GEM
|
|||||||
rouge (2.0.7)
|
rouge (2.0.7)
|
||||||
rubyzip (1.3.0)
|
rubyzip (1.3.0)
|
||||||
security (0.1.3)
|
security (0.1.3)
|
||||||
signet (0.12.0)
|
signet (0.14.0)
|
||||||
addressable (~> 2.3)
|
addressable (~> 2.3)
|
||||||
faraday (~> 0.9)
|
faraday (>= 0.17.3, < 2.0)
|
||||||
jwt (>= 1.5, < 3.0)
|
jwt (>= 1.5, < 3.0)
|
||||||
multi_json (~> 1.10)
|
multi_json (~> 1.10)
|
||||||
simctl (1.6.7)
|
simctl (1.6.8)
|
||||||
CFPropertyList
|
CFPropertyList
|
||||||
naturally
|
naturally
|
||||||
slack-notifier (2.3.2)
|
slack-notifier (2.3.2)
|
||||||
@ -141,17 +159,17 @@ GEM
|
|||||||
terminal-notifier (2.0.0)
|
terminal-notifier (2.0.0)
|
||||||
terminal-table (1.8.0)
|
terminal-table (1.8.0)
|
||||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||||
tty-cursor (0.7.0)
|
tty-cursor (0.7.1)
|
||||||
tty-screen (0.7.0)
|
tty-screen (0.8.0)
|
||||||
tty-spinner (0.9.2)
|
tty-spinner (0.9.3)
|
||||||
tty-cursor (~> 0.7)
|
tty-cursor (~> 0.7)
|
||||||
uber (0.1.0)
|
uber (0.1.0)
|
||||||
unf (0.1.4)
|
unf (0.1.4)
|
||||||
unf_ext
|
unf_ext
|
||||||
unf_ext (0.0.7.6)
|
unf_ext (0.0.7.7)
|
||||||
unicode-display_width (1.6.1)
|
unicode-display_width (1.7.0)
|
||||||
word_wrap (1.0.0)
|
word_wrap (1.0.0)
|
||||||
xcodeproj (1.14.0)
|
xcodeproj (1.16.0)
|
||||||
CFPropertyList (>= 2.3.3, < 4.0)
|
CFPropertyList (>= 2.3.3, < 4.0)
|
||||||
atomos (~> 0.1.3)
|
atomos (~> 0.1.3)
|
||||||
claide (>= 1.0.2, < 2.0)
|
claide (>= 1.0.2, < 2.0)
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
"version": "3.1.100"
|
"version": "3.1.100"
|
||||||
},
|
},
|
||||||
"msbuild-sdks": {
|
"msbuild-sdks": {
|
||||||
"Microsoft.Build.Traversal": "2.0.48"
|
"Microsoft.Build.Traversal": "2.0.50"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -52,6 +52,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.602.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.602.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.609.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.619.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Android.App;
|
using Android.App;
|
||||||
|
using Android.OS;
|
||||||
using osu.Game;
|
using osu.Game;
|
||||||
using osu.Game.Updater;
|
using osu.Game.Updater;
|
||||||
|
|
||||||
@ -18,9 +19,32 @@ namespace osu.Android
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// todo: needs checking before play store redeploy.
|
// We store the osu! build number in the "VersionCode" field to better support google play releases.
|
||||||
string versionName = packageInfo.VersionName;
|
// If we were to use the main build number, it would require a new submission each time (similar to TestFlight).
|
||||||
// undo play store version garbling
|
// In order to do this, we should split it up and pad the numbers to still ensure sequential increase over time.
|
||||||
|
//
|
||||||
|
// We also need to be aware that older SDK versions store this as a 32bit int.
|
||||||
|
//
|
||||||
|
// Basic conversion format (as done in Fastfile): 2020.606.0 -> 202006060
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/52977079/android-sdk-28-versioncode-in-packageinfo-has-been-deprecated
|
||||||
|
string versionName = string.Empty;
|
||||||
|
|
||||||
|
if (Build.VERSION.SdkInt >= BuildVersionCodes.P)
|
||||||
|
{
|
||||||
|
versionName = packageInfo.LongVersionCode.ToString();
|
||||||
|
// ensure we only read the trailing portion of long (the part we are interested in).
|
||||||
|
versionName = versionName.Substring(versionName.Length - 9);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
|
// this is required else older SDKs will report missing method exception.
|
||||||
|
versionName = packageInfo.VersionCode.ToString();
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
}
|
||||||
|
|
||||||
|
// undo play store version garbling (as mentioned above).
|
||||||
return new Version(int.Parse(versionName.Substring(0, 4)), int.Parse(versionName.Substring(4, 4)), int.Parse(versionName.Substring(8, 1)));
|
return new Version(int.Parse(versionName.Substring(0, 4)), int.Parse(versionName.Substring(4, 4)), int.Parse(versionName.Substring(8, 1)));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
@ -10,7 +10,6 @@ using Microsoft.Win32;
|
|||||||
using osu.Desktop.Overlays;
|
using osu.Desktop.Overlays;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game;
|
using osu.Game;
|
||||||
using osuTK.Input;
|
|
||||||
using osu.Desktop.Updater;
|
using osu.Desktop.Updater;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
@ -122,21 +121,27 @@ namespace osu.Desktop
|
|||||||
{
|
{
|
||||||
base.SetHost(host);
|
base.SetHost(host);
|
||||||
|
|
||||||
if (host.Window is DesktopGameWindow desktopWindow)
|
switch (host.Window)
|
||||||
{
|
{
|
||||||
desktopWindow.CursorState |= CursorState.Hidden;
|
// Legacy osuTK DesktopGameWindow
|
||||||
|
case DesktopGameWindow desktopGameWindow:
|
||||||
|
desktopGameWindow.CursorState |= CursorState.Hidden;
|
||||||
|
desktopGameWindow.SetIconFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), "lazer.ico"));
|
||||||
|
desktopGameWindow.Title = Name;
|
||||||
|
desktopGameWindow.FileDrop += (_, e) => fileDrop(e.FileNames);
|
||||||
|
break;
|
||||||
|
|
||||||
desktopWindow.SetIconFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), "lazer.ico"));
|
// SDL2 DesktopWindow
|
||||||
|
case DesktopWindow desktopWindow:
|
||||||
|
desktopWindow.CursorState.Value |= CursorState.Hidden;
|
||||||
desktopWindow.Title = Name;
|
desktopWindow.Title = Name;
|
||||||
|
desktopWindow.DragDrop += f => fileDrop(new[] { f });
|
||||||
desktopWindow.FileDrop += fileDrop;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fileDrop(object sender, FileDropEventArgs e)
|
private void fileDrop(string[] filePaths)
|
||||||
{
|
{
|
||||||
var filePaths = e.FileNames;
|
|
||||||
|
|
||||||
var firstExtension = Path.GetExtension(filePaths.First());
|
var firstExtension = Path.GetExtension(filePaths.First());
|
||||||
|
|
||||||
if (filePaths.Any(f => Path.GetExtension(f) != firstExtension)) return;
|
if (filePaths.Any(f => Path.GetExtension(f) != firstExtension)) return;
|
||||||
|
@ -30,18 +30,16 @@ namespace osu.Desktop.Updater
|
|||||||
private static readonly Logger logger = Logger.GetLogger("updater");
|
private static readonly Logger logger = Logger.GetLogger("updater");
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(NotificationOverlay notification, OsuGameBase game)
|
private void load(NotificationOverlay notification)
|
||||||
{
|
{
|
||||||
notificationOverlay = notification;
|
notificationOverlay = notification;
|
||||||
|
|
||||||
if (game.IsDeployedBuild)
|
|
||||||
{
|
|
||||||
Splat.Locator.CurrentMutable.Register(() => new SquirrelLogger(), typeof(Splat.ILogger));
|
Splat.Locator.CurrentMutable.Register(() => new SquirrelLogger(), typeof(Splat.ILogger));
|
||||||
Schedule(() => Task.Run(() => checkForUpdateAsync()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null)
|
protected override async Task PerformUpdateCheck() => await checkForUpdateAsync();
|
||||||
|
|
||||||
|
private async Task checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null)
|
||||||
{
|
{
|
||||||
// should we schedule a retry on completion of this check?
|
// should we schedule a retry on completion of this check?
|
||||||
bool scheduleRecheck = true;
|
bool scheduleRecheck = true;
|
||||||
@ -83,7 +81,7 @@ namespace osu.Desktop.Updater
|
|||||||
|
|
||||||
// could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959)
|
// could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959)
|
||||||
// try again without deltas.
|
// try again without deltas.
|
||||||
checkForUpdateAsync(false, notification);
|
await checkForUpdateAsync(false, notification);
|
||||||
scheduleRecheck = false;
|
scheduleRecheck = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -102,7 +100,7 @@ namespace osu.Desktop.Updater
|
|||||||
if (scheduleRecheck)
|
if (scheduleRecheck)
|
||||||
{
|
{
|
||||||
// check again in 30 minutes.
|
// check again in 30 minutes.
|
||||||
Scheduler.AddDelayed(() => checkForUpdateAsync(), 60000 * 30);
|
Scheduler.AddDelayed(async () => await checkForUpdateAsync(), 60000 * 30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,10 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
|
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
|
||||||
<PackageReference Include="DiscordRichPresence" Version="1.0.150" />
|
<PackageReference Include="DiscordRichPresence" Version="1.0.150" />
|
||||||
|
<!-- .NET 3.1 SDK seems to cause issues with a runtime specification. This will likely be resolved in .NET 5. -->
|
||||||
|
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.Runtime.Handles" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Resources">
|
<ItemGroup Label="Resources">
|
||||||
<EmbeddedResource Include="lazer.ico" />
|
<EmbeddedResource Include="lazer.ico" />
|
||||||
|
@ -17,7 +17,8 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
{
|
{
|
||||||
var store = new NamespacedResourceStore<byte[]>(new DllResourceStore(GetType().Assembly), "Resources/special-skin");
|
var store = new NamespacedResourceStore<byte[]>(new DllResourceStore(GetType().Assembly), "Resources/special-skin");
|
||||||
var rawSkin = new TestLegacySkin(new SkinInfo { Name = "special-skin" }, store);
|
var rawSkin = new TestLegacySkin(new SkinInfo { Name = "special-skin" }, store);
|
||||||
var skin = new CatchLegacySkinTransformer(rawSkin);
|
var skinSource = new SkinProvidingContainer(rawSkin);
|
||||||
|
var skin = new CatchLegacySkinTransformer(skinSource);
|
||||||
|
|
||||||
Assert.AreEqual(new Color4(232, 185, 35, 255), skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDash)?.Value);
|
Assert.AreEqual(new Color4(232, 185, 35, 255), skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDash)?.Value);
|
||||||
Assert.AreEqual(new Color4(232, 74, 35, 255), skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDashAfterImage)?.Value);
|
Assert.AreEqual(new Color4(232, 74, 35, 255), skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDashAfterImage)?.Value);
|
||||||
|
@ -13,8 +13,10 @@ namespace osu.Game.Rulesets.Catch.Tests.Mods
|
|||||||
{
|
{
|
||||||
public class TestSceneCatchModPerfect : ModPerfectTestScene
|
public class TestSceneCatchModPerfect : ModPerfectTestScene
|
||||||
{
|
{
|
||||||
|
protected override Ruleset CreatePlayerRuleset() => new CatchRuleset();
|
||||||
|
|
||||||
public TestSceneCatchModPerfect()
|
public TestSceneCatchModPerfect()
|
||||||
: base(new CatchRuleset(), new CatchModPerfect())
|
: base(new CatchModPerfect())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,13 +12,8 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
{
|
{
|
||||||
public class TestSceneAutoJuiceStream : PlayerTestScene
|
public class TestSceneAutoJuiceStream : TestSceneCatchPlayer
|
||||||
{
|
{
|
||||||
public TestSceneAutoJuiceStream()
|
|
||||||
: base(new CatchRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
||||||
{
|
{
|
||||||
var beatmap = new Beatmap
|
var beatmap = new Beatmap
|
||||||
|
@ -4,18 +4,12 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneBananaShower : PlayerTestScene
|
public class TestSceneBananaShower : TestSceneCatchPlayer
|
||||||
{
|
{
|
||||||
public TestSceneBananaShower()
|
|
||||||
: base(new CatchRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestBananaShower()
|
public void TestBananaShower()
|
||||||
{
|
{
|
||||||
|
@ -9,9 +9,6 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneCatchPlayer : PlayerTestScene
|
public class TestSceneCatchPlayer : PlayerTestScene
|
||||||
{
|
{
|
||||||
public TestSceneCatchPlayer()
|
protected override Ruleset CreatePlayerRuleset() => new CatchRuleset();
|
||||||
: base(new CatchRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,18 +4,12 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneCatchStacker : PlayerTestScene
|
public class TestSceneCatchStacker : TestSceneCatchPlayer
|
||||||
{
|
{
|
||||||
public TestSceneCatchStacker()
|
|
||||||
: base(new CatchRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
||||||
{
|
{
|
||||||
var beatmap = new Beatmap
|
var beatmap = new Beatmap
|
||||||
|
@ -9,19 +9,13 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osu.Game.Rulesets.Catch.UI;
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneHyperDash : PlayerTestScene
|
public class TestSceneHyperDash : TestSceneCatchPlayer
|
||||||
{
|
{
|
||||||
public TestSceneHyperDash()
|
|
||||||
: base(new CatchRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool Autoplay => true;
|
protected override bool Autoplay => true;
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -7,18 +7,12 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
{
|
{
|
||||||
public class TestSceneJuiceStream : PlayerTestScene
|
public class TestSceneJuiceStream : TestSceneCatchPlayer
|
||||||
{
|
{
|
||||||
public TestSceneJuiceStream()
|
|
||||||
: base(new CatchRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestJuiceStreamEndingCombo()
|
public void TestJuiceStreamEndingCombo()
|
||||||
{
|
{
|
||||||
|
@ -2,26 +2,21 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
using osu.Framework.Audio.Sample;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Game.Audio;
|
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Skinning
|
namespace osu.Game.Rulesets.Catch.Skinning
|
||||||
{
|
{
|
||||||
public class CatchLegacySkinTransformer : ISkin
|
public class CatchLegacySkinTransformer : LegacySkinTransformer
|
||||||
{
|
{
|
||||||
private readonly ISkin source;
|
public CatchLegacySkinTransformer(ISkinSource source)
|
||||||
|
: base(source)
|
||||||
public CatchLegacySkinTransformer(ISkin source)
|
|
||||||
{
|
{
|
||||||
this.source = source;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable GetDrawableComponent(ISkinComponent component)
|
public override Drawable GetDrawableComponent(ISkinComponent component)
|
||||||
{
|
{
|
||||||
if (!(component is CatchSkinComponent catchSkinComponent))
|
if (!(component is CatchSkinComponent catchSkinComponent))
|
||||||
return null;
|
return null;
|
||||||
@ -61,19 +56,15 @@ namespace osu.Game.Rulesets.Catch.Skinning
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
|
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
||||||
|
|
||||||
public SampleChannel GetSample(ISampleInfo sample) => source.GetSample(sample);
|
|
||||||
|
|
||||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
|
||||||
{
|
{
|
||||||
switch (lookup)
|
switch (lookup)
|
||||||
{
|
{
|
||||||
case CatchSkinColour colour:
|
case CatchSkinColour colour:
|
||||||
return source.GetConfig<SkinCustomColourLookup, TValue>(new SkinCustomColourLookup(colour));
|
return Source.GetConfig<SkinCustomColourLookup, TValue>(new SkinCustomColourLookup(colour));
|
||||||
}
|
}
|
||||||
|
|
||||||
return source.GetConfig<TLookup, TValue>(lookup);
|
return Source.GetConfig<TLookup, TValue>(lookup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,10 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
|
|||||||
{
|
{
|
||||||
public class TestSceneManiaModPerfect : ModPerfectTestScene
|
public class TestSceneManiaModPerfect : ModPerfectTestScene
|
||||||
{
|
{
|
||||||
|
protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();
|
||||||
|
|
||||||
public TestSceneManiaModPerfect()
|
public TestSceneManiaModPerfect()
|
||||||
: base(new ManiaRuleset(), new ManiaModPerfect())
|
: base(new ManiaModPerfect())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 65 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 56 KiB |
@ -1,6 +1,12 @@
|
|||||||
[General]
|
[General]
|
||||||
Version: 2.4
|
Version: 2.5
|
||||||
|
|
||||||
[Mania]
|
[Mania]
|
||||||
Keys: 4
|
Keys: 4
|
||||||
ColumnLineWidth: 3,1,3,1,1
|
ColumnLineWidth: 3,1,3,1,1
|
||||||
|
Hit0: mania/hit0
|
||||||
|
Hit50: mania/hit50
|
||||||
|
Hit100: mania/hit100
|
||||||
|
Hit200: mania/hit200
|
||||||
|
Hit300: mania/hit300
|
||||||
|
Hit300g: mania/hit300g
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Mania.Scoring;
|
||||||
using osu.Game.Rulesets.Mania.UI;
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -16,7 +17,11 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
|
|||||||
{
|
{
|
||||||
public TestSceneDrawableJudgement()
|
public TestSceneDrawableJudgement()
|
||||||
{
|
{
|
||||||
|
var hitWindows = new ManiaHitWindows();
|
||||||
|
|
||||||
foreach (HitResult result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Skip(1))
|
foreach (HitResult result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Skip(1))
|
||||||
|
{
|
||||||
|
if (hitWindows.IsHitResultAllowed(result))
|
||||||
{
|
{
|
||||||
AddStep("Show " + result.GetDescription(), () => SetContents(() =>
|
AddStep("Show " + result.GetDescription(), () => SetContents(() =>
|
||||||
new DrawableManiaJudgement(new JudgementResult(new HitObject(), new Judgement()) { Type = result }, null)
|
new DrawableManiaJudgement(new JudgementResult(new HitObject(), new Judgement()) { Type = result }, null)
|
||||||
@ -28,3 +33,4 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -15,8 +15,9 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
{
|
{
|
||||||
private readonly Bindable<ManiaScrollingDirection> direction = new Bindable<ManiaScrollingDirection>();
|
private readonly Bindable<ManiaScrollingDirection> direction = new Bindable<ManiaScrollingDirection>();
|
||||||
|
|
||||||
|
protected override Ruleset CreateEditorRuleset() => new ManiaRuleset();
|
||||||
|
|
||||||
public TestSceneEditor()
|
public TestSceneEditor()
|
||||||
: base(new ManiaRuleset())
|
|
||||||
{
|
{
|
||||||
AddStep("upwards scroll", () => direction.Value = ManiaScrollingDirection.Up);
|
AddStep("upwards scroll", () => direction.Value = ManiaScrollingDirection.Up);
|
||||||
AddStep("downwards scroll", () => direction.Value = ManiaScrollingDirection.Down);
|
AddStep("downwards scroll", () => direction.Value = ManiaScrollingDirection.Down);
|
||||||
|
@ -5,11 +5,8 @@ using osu.Game.Tests.Visual;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Tests
|
namespace osu.Game.Rulesets.Mania.Tests
|
||||||
{
|
{
|
||||||
public class TestScenePlayer : PlayerTestScene
|
public class TestSceneManiaPlayer : PlayerTestScene
|
||||||
{
|
|
||||||
public TestScenePlayer()
|
|
||||||
: base(new ManiaRuleset())
|
|
||||||
{
|
{
|
||||||
}
|
protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,8 +7,6 @@ namespace osu.Game.Rulesets.Mania.Judgements
|
|||||||
{
|
{
|
||||||
public class HoldNoteTickJudgement : ManiaJudgement
|
public class HoldNoteTickJudgement : ManiaJudgement
|
||||||
{
|
{
|
||||||
public override bool AffectsCombo => false;
|
|
||||||
|
|
||||||
protected override int NumericResultFor(HitResult result) => 20;
|
protected override int NumericResultFor(HitResult result) => 20;
|
||||||
|
|
||||||
protected override double HealthIncreaseFor(HitResult result)
|
protected override double HealthIncreaseFor(HitResult result)
|
||||||
|
@ -44,6 +44,8 @@ namespace osu.Game.Rulesets.Mania
|
|||||||
|
|
||||||
public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor();
|
public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor();
|
||||||
|
|
||||||
|
public override HealthProcessor CreateHealthProcessor(double drainStartTime) => new DrainingHealthProcessor(drainStartTime, 0.2);
|
||||||
|
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap, this);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap, this);
|
||||||
|
|
||||||
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(ISkinSource skin, IScrollingInfo scrollingInfo, DrawableHitObject drawableObject)
|
private void load(ISkinSource skin, IScrollingInfo scrollingInfo, DrawableHitObject drawableObject)
|
||||||
{
|
{
|
||||||
string imageName = GetManiaSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.HoldNoteBodyImage)?.Value
|
string imageName = GetColumnSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.HoldNoteBodyImage)?.Value
|
||||||
?? $"mania-note{FallbackColumnIndex}L";
|
?? $"mania-note{FallbackColumnIndex}L";
|
||||||
|
|
||||||
sprite = skin.GetAnimation(imageName, true, true).With(d =>
|
sprite = skin.GetAnimation(imageName, true, true).With(d =>
|
||||||
|
@ -32,28 +32,28 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
||||||
{
|
{
|
||||||
string lightImage = GetManiaSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.LightImage, 0)?.Value
|
string lightImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.LightImage)?.Value
|
||||||
?? "mania-stage-light";
|
?? "mania-stage-light";
|
||||||
|
|
||||||
float leftLineWidth = GetManiaSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.LeftLineWidth)
|
float leftLineWidth = GetColumnSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.LeftLineWidth)
|
||||||
?.Value ?? 1;
|
?.Value ?? 1;
|
||||||
float rightLineWidth = GetManiaSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.RightLineWidth)
|
float rightLineWidth = GetColumnSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.RightLineWidth)
|
||||||
?.Value ?? 1;
|
?.Value ?? 1;
|
||||||
|
|
||||||
bool hasLeftLine = leftLineWidth > 0;
|
bool hasLeftLine = leftLineWidth > 0;
|
||||||
bool hasRightLine = rightLineWidth > 0 && skin.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value >= 2.4m
|
bool hasRightLine = rightLineWidth > 0 && skin.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value >= 2.4m
|
||||||
|| isLastColumn;
|
|| isLastColumn;
|
||||||
|
|
||||||
float lightPosition = GetManiaSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.LightPosition)?.Value
|
float lightPosition = GetColumnSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.LightPosition)?.Value
|
||||||
?? 0;
|
?? 0;
|
||||||
|
|
||||||
Color4 lineColour = GetManiaSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.ColumnLineColour)?.Value
|
Color4 lineColour = GetColumnSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.ColumnLineColour)?.Value
|
||||||
?? Color4.White;
|
?? Color4.White;
|
||||||
|
|
||||||
Color4 backgroundColour = GetManiaSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.ColumnBackgroundColour)?.Value
|
Color4 backgroundColour = GetColumnSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.ColumnBackgroundColour)?.Value
|
||||||
?? Color4.Black;
|
?? Color4.Black;
|
||||||
|
|
||||||
Color4 lightColour = GetManiaSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.ColumnLightColour)?.Value
|
Color4 lightColour = GetColumnSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.ColumnLightColour)?.Value
|
||||||
?? Color4.White;
|
?? Color4.White;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
|
@ -26,10 +26,10 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
||||||
{
|
{
|
||||||
string imageName = GetManiaSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.ExplosionImage)?.Value
|
string imageName = GetColumnSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.ExplosionImage)?.Value
|
||||||
?? "lightingN";
|
?? "lightingN";
|
||||||
|
|
||||||
float explosionScale = GetManiaSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.ExplosionScale)?.Value
|
float explosionScale = GetColumnSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.ExplosionScale)?.Value
|
||||||
?? 1;
|
?? 1;
|
||||||
|
|
||||||
// Create a temporary animation to retrieve the number of frames, in an effort to calculate the intended frame length.
|
// Create a temporary animation to retrieve the number of frames, in an effort to calculate the intended frame length.
|
||||||
|
@ -14,7 +14,7 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Skinning
|
namespace osu.Game.Rulesets.Mania.Skinning
|
||||||
{
|
{
|
||||||
public class LegacyHitTarget : LegacyManiaElement
|
public class LegacyHitTarget : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||||
|
|
||||||
@ -28,13 +28,13 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
||||||
{
|
{
|
||||||
string targetImage = GetManiaSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.HitTargetImage)?.Value
|
string targetImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.HitTargetImage)?.Value
|
||||||
?? "mania-stage-hint";
|
?? "mania-stage-hint";
|
||||||
|
|
||||||
bool showJudgementLine = GetManiaSkinConfig<bool>(skin, LegacyManiaSkinConfigurationLookups.ShowJudgementLine)?.Value
|
bool showJudgementLine = skin.GetManiaSkinConfig<bool>(LegacyManiaSkinConfigurationLookups.ShowJudgementLine)?.Value
|
||||||
?? true;
|
?? true;
|
||||||
|
|
||||||
Color4 lineColour = GetManiaSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.JudgementLineColour)?.Value
|
Color4 lineColour = skin.GetManiaSkinConfig<Color4>(LegacyManiaSkinConfigurationLookups.JudgementLineColour)?.Value
|
||||||
?? Color4.White;
|
?? Color4.White;
|
||||||
|
|
||||||
InternalChild = directionContainer = new Container
|
InternalChild = directionContainer = new Container
|
||||||
|
@ -33,10 +33,10 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
||||||
{
|
{
|
||||||
string upImage = GetManiaSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.KeyImage)?.Value
|
string upImage = GetColumnSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.KeyImage)?.Value
|
||||||
?? $"mania-key{FallbackColumnIndex}";
|
?? $"mania-key{FallbackColumnIndex}";
|
||||||
|
|
||||||
string downImage = GetManiaSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.KeyImageDown)?.Value
|
string downImage = GetColumnSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.KeyImageDown)?.Value
|
||||||
?? $"mania-key{FallbackColumnIndex}D";
|
?? $"mania-key{FallbackColumnIndex}D";
|
||||||
|
|
||||||
InternalChild = directionContainer = new Container
|
InternalChild = directionContainer = new Container
|
||||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A <see cref="CompositeDrawable"/> which is placed somewhere within a <see cref="Column"/>.
|
/// A <see cref="CompositeDrawable"/> which is placed somewhere within a <see cref="Column"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class LegacyManiaColumnElement : LegacyManiaElement
|
public class LegacyManiaColumnElement : CompositeDrawable
|
||||||
{
|
{
|
||||||
[Resolved]
|
[Resolved]
|
||||||
protected Column Column { get; private set; }
|
protected Column Column { get; private set; }
|
||||||
@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IBindable<T> GetManiaSkinConfig<T>(ISkin skin, LegacyManiaSkinConfigurationLookups lookup, int? index = null)
|
protected IBindable<T> GetColumnSkinConfig<T>(ISkin skin, LegacyManiaSkinConfigurationLookups lookup)
|
||||||
=> base.GetManiaSkinConfig<T>(skin, lookup, index ?? Column.Index);
|
=> skin.GetManiaSkinConfig<T>(lookup, Column.Index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
string noteImage = GetManiaSkinConfig<string>(skin, lookup)?.Value
|
string noteImage = GetColumnSkinConfig<string>(skin, lookup)?.Value
|
||||||
?? $"mania-note{FallbackColumnIndex}{suffix}";
|
?? $"mania-note{FallbackColumnIndex}{suffix}";
|
||||||
|
|
||||||
return skin.GetTexture(noteImage);
|
return skin.GetTexture(noteImage);
|
||||||
|
@ -3,13 +3,14 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Skinning
|
namespace osu.Game.Rulesets.Mania.Skinning
|
||||||
{
|
{
|
||||||
public class LegacyStageBackground : LegacyManiaElement
|
public class LegacyStageBackground : CompositeDrawable
|
||||||
{
|
{
|
||||||
private Drawable leftSprite;
|
private Drawable leftSprite;
|
||||||
private Drawable rightSprite;
|
private Drawable rightSprite;
|
||||||
@ -22,10 +23,10 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(ISkinSource skin)
|
private void load(ISkinSource skin)
|
||||||
{
|
{
|
||||||
string leftImage = GetManiaSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.LeftStageImage)?.Value
|
string leftImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.LeftStageImage)?.Value
|
||||||
?? "mania-stage-left";
|
?? "mania-stage-left";
|
||||||
|
|
||||||
string rightImage = GetManiaSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.RightStageImage)?.Value
|
string rightImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.RightStageImage)?.Value
|
||||||
?? "mania-stage-right";
|
?? "mania-stage-right";
|
||||||
|
|
||||||
InternalChildren = new[]
|
InternalChildren = new[]
|
||||||
|
@ -4,13 +4,14 @@
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Skinning
|
namespace osu.Game.Rulesets.Mania.Skinning
|
||||||
{
|
{
|
||||||
public class LegacyStageForeground : LegacyManiaElement
|
public class LegacyStageForeground : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
||||||
{
|
{
|
||||||
string bottomImage = GetManiaSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.BottomStageImage)?.Value
|
string bottomImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.BottomStageImage)?.Value
|
||||||
?? "mania-stage-bottom";
|
?? "mania-stage-bottom";
|
||||||
|
|
||||||
sprite = skin.GetAnimation(bottomImage, true, true)?.With(d =>
|
sprite = skin.GetAnimation(bottomImage, true, true)?.With(d =>
|
||||||
|
@ -3,22 +3,49 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Framework.Audio.Sample;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Audio;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Skinning
|
namespace osu.Game.Rulesets.Mania.Skinning
|
||||||
{
|
{
|
||||||
public class ManiaLegacySkinTransformer : ISkin
|
public class ManiaLegacySkinTransformer : LegacySkinTransformer
|
||||||
{
|
{
|
||||||
private readonly ISkin source;
|
|
||||||
private readonly ManiaBeatmap beatmap;
|
private readonly ManiaBeatmap beatmap;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mapping of <see cref="HitResult"/> to their corresponding
|
||||||
|
/// <see cref="LegacyManiaSkinConfigurationLookups"/> value.
|
||||||
|
/// </summary>
|
||||||
|
private static readonly IReadOnlyDictionary<HitResult, LegacyManiaSkinConfigurationLookups> hitresult_mapping
|
||||||
|
= new Dictionary<HitResult, LegacyManiaSkinConfigurationLookups>
|
||||||
|
{
|
||||||
|
{ HitResult.Perfect, LegacyManiaSkinConfigurationLookups.Hit300g },
|
||||||
|
{ HitResult.Great, LegacyManiaSkinConfigurationLookups.Hit300 },
|
||||||
|
{ HitResult.Good, LegacyManiaSkinConfigurationLookups.Hit200 },
|
||||||
|
{ HitResult.Ok, LegacyManiaSkinConfigurationLookups.Hit100 },
|
||||||
|
{ HitResult.Meh, LegacyManiaSkinConfigurationLookups.Hit50 },
|
||||||
|
{ HitResult.Miss, LegacyManiaSkinConfigurationLookups.Hit0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mapping of <see cref="HitResult"/> to their corresponding
|
||||||
|
/// default filenames.
|
||||||
|
/// </summary>
|
||||||
|
private static readonly IReadOnlyDictionary<HitResult, string> default_hitresult_skin_filenames
|
||||||
|
= new Dictionary<HitResult, string>
|
||||||
|
{
|
||||||
|
{ HitResult.Perfect, "mania-hit300g" },
|
||||||
|
{ HitResult.Great, "mania-hit300" },
|
||||||
|
{ HitResult.Good, "mania-hit200" },
|
||||||
|
{ HitResult.Ok, "mania-hit100" },
|
||||||
|
{ HitResult.Meh, "mania-hit50" },
|
||||||
|
{ HitResult.Miss, "mania-hit0" }
|
||||||
|
};
|
||||||
|
|
||||||
private Lazy<bool> isLegacySkin;
|
private Lazy<bool> isLegacySkin;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -28,29 +55,28 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
private Lazy<bool> hasKeyTexture;
|
private Lazy<bool> hasKeyTexture;
|
||||||
|
|
||||||
public ManiaLegacySkinTransformer(ISkinSource source, IBeatmap beatmap)
|
public ManiaLegacySkinTransformer(ISkinSource source, IBeatmap beatmap)
|
||||||
|
: base(source)
|
||||||
{
|
{
|
||||||
this.source = source;
|
|
||||||
this.beatmap = (ManiaBeatmap)beatmap;
|
this.beatmap = (ManiaBeatmap)beatmap;
|
||||||
|
|
||||||
source.SourceChanged += sourceChanged;
|
Source.SourceChanged += sourceChanged;
|
||||||
sourceChanged();
|
sourceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sourceChanged()
|
private void sourceChanged()
|
||||||
{
|
{
|
||||||
isLegacySkin = new Lazy<bool>(() => source.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version) != null);
|
isLegacySkin = new Lazy<bool>(() => Source.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version) != null);
|
||||||
hasKeyTexture = new Lazy<bool>(() => source.GetAnimation(
|
hasKeyTexture = new Lazy<bool>(() => Source.GetAnimation(
|
||||||
GetConfig<ManiaSkinConfigurationLookup, string>(
|
this.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.KeyImage, 0)?.Value
|
||||||
new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.KeyImage, 0))?.Value
|
|
||||||
?? "mania-key1", true, true) != null);
|
?? "mania-key1", true, true) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable GetDrawableComponent(ISkinComponent component)
|
public override Drawable GetDrawableComponent(ISkinComponent component)
|
||||||
{
|
{
|
||||||
switch (component)
|
switch (component)
|
||||||
{
|
{
|
||||||
case GameplaySkinComponent<HitResult> resultComponent:
|
case GameplaySkinComponent<HitResult> resultComponent:
|
||||||
return getResult(resultComponent);
|
return getResult(resultComponent.Component);
|
||||||
|
|
||||||
case ManiaSkinComponent maniaComponent:
|
case ManiaSkinComponent maniaComponent:
|
||||||
if (!isLegacySkin.Value || !hasKeyTexture.Value)
|
if (!isLegacySkin.Value || !hasKeyTexture.Value)
|
||||||
@ -95,42 +121,20 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getResult(GameplaySkinComponent<HitResult> resultComponent)
|
private Drawable getResult(HitResult result)
|
||||||
{
|
{
|
||||||
switch (resultComponent.Component)
|
string filename = this.GetManiaSkinConfig<string>(hitresult_mapping[result])?.Value
|
||||||
{
|
?? default_hitresult_skin_filenames[result];
|
||||||
case HitResult.Miss:
|
|
||||||
return this.GetAnimation("mania-hit0", true, true);
|
|
||||||
|
|
||||||
case HitResult.Meh:
|
return this.GetAnimation(filename, true, true);
|
||||||
return this.GetAnimation("mania-hit50", true, true);
|
|
||||||
|
|
||||||
case HitResult.Ok:
|
|
||||||
return this.GetAnimation("mania-hit100", true, true);
|
|
||||||
|
|
||||||
case HitResult.Good:
|
|
||||||
return this.GetAnimation("mania-hit200", true, true);
|
|
||||||
|
|
||||||
case HitResult.Great:
|
|
||||||
return this.GetAnimation("mania-hit300", true, true);
|
|
||||||
|
|
||||||
case HitResult.Perfect:
|
|
||||||
return this.GetAnimation("mania-hit300g", true, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
||||||
}
|
|
||||||
|
|
||||||
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
|
|
||||||
|
|
||||||
public SampleChannel GetSample(ISampleInfo sample) => source.GetSample(sample);
|
|
||||||
|
|
||||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
|
||||||
{
|
{
|
||||||
if (lookup is ManiaSkinConfigurationLookup maniaLookup)
|
if (lookup is ManiaSkinConfigurationLookup maniaLookup)
|
||||||
return source.GetConfig<LegacyManiaSkinConfigurationLookup, TValue>(new LegacyManiaSkinConfigurationLookup(beatmap.TotalColumns, maniaLookup.Lookup, maniaLookup.TargetColumn));
|
return Source.GetConfig<LegacyManiaSkinConfigurationLookup, TValue>(new LegacyManiaSkinConfigurationLookup(beatmap.TotalColumns, maniaLookup.Lookup, maniaLookup.TargetColumn));
|
||||||
|
|
||||||
return source.GetConfig<TLookup, TValue>(lookup);
|
return Source.GetConfig<TLookup, TValue>(lookup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,11 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Skinning
|
namespace osu.Game.Rulesets.Mania.Skinning
|
||||||
{
|
{
|
||||||
/// <summary>
|
public static class ManiaSkinConfigExtensions
|
||||||
/// A mania legacy skin element.
|
|
||||||
/// </summary>
|
|
||||||
public class LegacyManiaElement : CompositeDrawable
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve a per-column-count skin configuration.
|
/// Retrieve a per-column-count skin configuration.
|
||||||
@ -18,7 +14,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
/// <param name="skin">The skin from which configuration is retrieved.</param>
|
/// <param name="skin">The skin from which configuration is retrieved.</param>
|
||||||
/// <param name="lookup">The value to retrieve.</param>
|
/// <param name="lookup">The value to retrieve.</param>
|
||||||
/// <param name="index">If not null, denotes the index of the column to which the entry applies.</param>
|
/// <param name="index">If not null, denotes the index of the column to which the entry applies.</param>
|
||||||
protected virtual IBindable<T> GetManiaSkinConfig<T>(ISkin skin, LegacyManiaSkinConfigurationLookups lookup, int? index = null)
|
public static IBindable<T> GetManiaSkinConfig<T>(this ISkin skin, LegacyManiaSkinConfigurationLookups lookup, int? index = null)
|
||||||
=> skin.GetConfig<ManiaSkinConfigurationLookup, T>(
|
=> skin.GetConfig<ManiaSkinConfigurationLookup, T>(
|
||||||
new ManiaSkinConfigurationLookup(lookup, index));
|
new ManiaSkinConfigurationLookup(lookup, index));
|
||||||
}
|
}
|
12
osu.Game.Rulesets.Osu.Tests/Mods/OsuModTestScene.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||||
|
{
|
||||||
|
public class OsuModTestScene : ModTestScene
|
||||||
|
{
|
||||||
|
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
||||||
|
}
|
||||||
|
}
|
@ -9,17 +9,11 @@ using osu.Framework.Utils;
|
|||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||||
{
|
{
|
||||||
public class TestSceneOsuModDifficultyAdjust : ModTestScene
|
public class TestSceneOsuModDifficultyAdjust : OsuModTestScene
|
||||||
{
|
{
|
||||||
public TestSceneOsuModDifficultyAdjust()
|
|
||||||
: base(new OsuRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestNoAdjustment() => CreateModTest(new ModTestData
|
public void TestNoAdjustment() => CreateModTest(new ModTestData
|
||||||
{
|
{
|
||||||
|
@ -4,17 +4,11 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||||
{
|
{
|
||||||
public class TestSceneOsuModDoubleTime : ModTestScene
|
public class TestSceneOsuModDoubleTime : OsuModTestScene
|
||||||
{
|
{
|
||||||
public TestSceneOsuModDoubleTime()
|
|
||||||
: base(new OsuRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestCase(0.5)]
|
[TestCase(0.5)]
|
||||||
[TestCase(1.01)]
|
[TestCase(1.01)]
|
||||||
[TestCase(1.5)]
|
[TestCase(1.5)]
|
||||||
|
@ -8,18 +8,12 @@ using osu.Game.Rulesets.Objects;
|
|||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||||
{
|
{
|
||||||
public class TestSceneOsuModHidden : ModTestScene
|
public class TestSceneOsuModHidden : OsuModTestScene
|
||||||
{
|
{
|
||||||
public TestSceneOsuModHidden()
|
|
||||||
: base(new OsuRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDefaultBeatmapTest() => CreateModTest(new ModTestData
|
public void TestDefaultBeatmapTest() => CreateModTest(new ModTestData
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,10 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
|
|||||||
{
|
{
|
||||||
public class TestSceneOsuModPerfect : ModPerfectTestScene
|
public class TestSceneOsuModPerfect : ModPerfectTestScene
|
||||||
{
|
{
|
||||||
|
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
||||||
|
|
||||||
public TestSceneOsuModPerfect()
|
public TestSceneOsuModPerfect()
|
||||||
: base(new OsuRuleset(), new OsuModPerfect())
|
: base(new OsuModPerfect())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,6 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneEditor : EditorTestScene
|
public class TestSceneEditor : EditorTestScene
|
||||||
{
|
{
|
||||||
public TestSceneEditor()
|
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
|
||||||
: base(new OsuRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,13 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Tests
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneHitCircleLongCombo : PlayerTestScene
|
public class TestSceneHitCircleLongCombo : TestSceneOsuPlayer
|
||||||
{
|
{
|
||||||
public TestSceneHitCircleLongCombo()
|
|
||||||
: base(new OsuRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
||||||
{
|
{
|
||||||
var beatmap = new Beatmap
|
var beatmap = new Beatmap
|
||||||
|
@ -19,10 +19,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
public class TestSceneMissHitWindowJudgements : ModTestScene
|
public class TestSceneMissHitWindowJudgements : ModTestScene
|
||||||
{
|
{
|
||||||
public TestSceneMissHitWindowJudgements()
|
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
||||||
: base(new OsuRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestMissViaEarlyHit()
|
public void TestMissViaEarlyHit()
|
||||||
|
@ -9,9 +9,6 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneOsuPlayer : PlayerTestScene
|
public class TestSceneOsuPlayer : PlayerTestScene
|
||||||
{
|
{
|
||||||
public TestSceneOsuPlayer()
|
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
||||||
: base(new OsuRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,12 @@ using osu.Game.Tests.Visual;
|
|||||||
namespace osu.Game.Rulesets.Osu.Tests
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneSkinFallbacks : PlayerTestScene
|
public class TestSceneSkinFallbacks : TestSceneOsuPlayer
|
||||||
{
|
{
|
||||||
private readonly TestSource testUserSkin;
|
private readonly TestSource testUserSkin;
|
||||||
private readonly TestSource testBeatmapSkin;
|
private readonly TestSource testBeatmapSkin;
|
||||||
|
|
||||||
public TestSceneSkinFallbacks()
|
public TestSceneSkinFallbacks()
|
||||||
: base(new OsuRuleset())
|
|
||||||
{
|
{
|
||||||
testUserSkin = new TestSource("user");
|
testUserSkin = new TestSource("user");
|
||||||
testBeatmapSkin = new TestSource("beatmap");
|
testBeatmapSkin = new TestSource("beatmap");
|
||||||
|
@ -2,20 +2,15 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Audio.Sample;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Game.Audio;
|
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Skinning
|
namespace osu.Game.Rulesets.Osu.Skinning
|
||||||
{
|
{
|
||||||
public class OsuLegacySkinTransformer : ISkin
|
public class OsuLegacySkinTransformer : LegacySkinTransformer
|
||||||
{
|
{
|
||||||
private readonly ISkin source;
|
|
||||||
|
|
||||||
private Lazy<bool> hasHitCircle;
|
private Lazy<bool> hasHitCircle;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -26,19 +21,18 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
public const float LEGACY_CIRCLE_RADIUS = 64 - 5;
|
public const float LEGACY_CIRCLE_RADIUS = 64 - 5;
|
||||||
|
|
||||||
public OsuLegacySkinTransformer(ISkinSource source)
|
public OsuLegacySkinTransformer(ISkinSource source)
|
||||||
|
: base(source)
|
||||||
{
|
{
|
||||||
this.source = source;
|
Source.SourceChanged += sourceChanged;
|
||||||
|
|
||||||
source.SourceChanged += sourceChanged;
|
|
||||||
sourceChanged();
|
sourceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sourceChanged()
|
private void sourceChanged()
|
||||||
{
|
{
|
||||||
hasHitCircle = new Lazy<bool>(() => source.GetTexture("hitcircle") != null);
|
hasHitCircle = new Lazy<bool>(() => Source.GetTexture("hitcircle") != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable GetDrawableComponent(ISkinComponent component)
|
public override Drawable GetDrawableComponent(ISkinComponent component)
|
||||||
{
|
{
|
||||||
if (!(component is OsuSkinComponent osuComponent))
|
if (!(component is OsuSkinComponent osuComponent))
|
||||||
return null;
|
return null;
|
||||||
@ -85,13 +79,13 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
case OsuSkinComponents.Cursor:
|
case OsuSkinComponents.Cursor:
|
||||||
if (source.GetTexture("cursor") != null)
|
if (Source.GetTexture("cursor") != null)
|
||||||
return new LegacyCursor();
|
return new LegacyCursor();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
case OsuSkinComponents.CursorTrail:
|
case OsuSkinComponents.CursorTrail:
|
||||||
if (source.GetTexture("cursortrail") != null)
|
if (Source.GetTexture("cursortrail") != null)
|
||||||
return new LegacyCursorTrail();
|
return new LegacyCursorTrail();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -102,7 +96,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
|
|
||||||
return !hasFont(font)
|
return !hasFont(font)
|
||||||
? null
|
? null
|
||||||
: new LegacySpriteText(source, font)
|
: new LegacySpriteText(Source, font)
|
||||||
{
|
{
|
||||||
// stable applies a blanket 0.8x scale to hitcircle fonts
|
// stable applies a blanket 0.8x scale to hitcircle fonts
|
||||||
Scale = new Vector2(0.8f),
|
Scale = new Vector2(0.8f),
|
||||||
@ -113,16 +107,12 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
|
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
||||||
|
|
||||||
public SampleChannel GetSample(ISampleInfo sample) => source.GetSample(sample);
|
|
||||||
|
|
||||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
|
||||||
{
|
{
|
||||||
switch (lookup)
|
switch (lookup)
|
||||||
{
|
{
|
||||||
case OsuSkinColour colour:
|
case OsuSkinColour colour:
|
||||||
return source.GetConfig<SkinCustomColourLookup, TValue>(new SkinCustomColourLookup(colour));
|
return Source.GetConfig<SkinCustomColourLookup, TValue>(new SkinCustomColourLookup(colour));
|
||||||
|
|
||||||
case OsuSkinConfiguration osuLookup:
|
case OsuSkinConfiguration osuLookup:
|
||||||
switch (osuLookup)
|
switch (osuLookup)
|
||||||
@ -136,16 +126,16 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
case OsuSkinConfiguration.HitCircleOverlayAboveNumber:
|
case OsuSkinConfiguration.HitCircleOverlayAboveNumber:
|
||||||
// See https://osu.ppy.sh/help/wiki/Skinning/skin.ini#%5Bgeneral%5D
|
// See https://osu.ppy.sh/help/wiki/Skinning/skin.ini#%5Bgeneral%5D
|
||||||
// HitCircleOverlayAboveNumer (with typo) should still be supported for now.
|
// HitCircleOverlayAboveNumer (with typo) should still be supported for now.
|
||||||
return source.GetConfig<OsuSkinConfiguration, TValue>(OsuSkinConfiguration.HitCircleOverlayAboveNumber) ??
|
return Source.GetConfig<OsuSkinConfiguration, TValue>(OsuSkinConfiguration.HitCircleOverlayAboveNumber) ??
|
||||||
source.GetConfig<OsuSkinConfiguration, TValue>(OsuSkinConfiguration.HitCircleOverlayAboveNumer);
|
Source.GetConfig<OsuSkinConfiguration, TValue>(OsuSkinConfiguration.HitCircleOverlayAboveNumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return source.GetConfig<TLookup, TValue>(lookup);
|
return Source.GetConfig<TLookup, TValue>(lookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool hasFont(string fontName) => source.GetTexture($"{fontName}-0") != null;
|
private bool hasFont(string fontName) => Source.GetTexture($"{fontName}-0") != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,10 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
|
|||||||
{
|
{
|
||||||
public class TestSceneTaikoModPerfect : ModPerfectTestScene
|
public class TestSceneTaikoModPerfect : ModPerfectTestScene
|
||||||
{
|
{
|
||||||
|
protected override Ruleset CreatePlayerRuleset() => new TestTaikoRuleset();
|
||||||
|
|
||||||
public TestSceneTaikoModPerfect()
|
public TestSceneTaikoModPerfect()
|
||||||
: base(new TestTaikoRuleset(), new TaikoModPerfect())
|
: base(new TaikoModPerfect())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,6 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneEditor : EditorTestScene
|
public class TestSceneEditor : EditorTestScene
|
||||||
{
|
{
|
||||||
public TestSceneEditor()
|
protected override Ruleset CreateEditorRuleset() => new TaikoRuleset();
|
||||||
: base(new TaikoRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ using osu.Framework.Testing;
|
|||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Tests
|
namespace osu.Game.Rulesets.Taiko.Tests
|
||||||
{
|
{
|
||||||
@ -14,13 +13,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
/// Taiko has some interesting rules for legacy mappings.
|
/// Taiko has some interesting rules for legacy mappings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HeadlessTest]
|
[HeadlessTest]
|
||||||
public class TestSceneSampleOutput : PlayerTestScene
|
public class TestSceneSampleOutput : TestSceneTaikoPlayer
|
||||||
{
|
{
|
||||||
public TestSceneSampleOutput()
|
|
||||||
: base(new TaikoRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SetUpSteps()
|
public override void SetUpSteps()
|
||||||
{
|
{
|
||||||
base.SetUpSteps();
|
base.SetUpSteps();
|
||||||
|
@ -5,17 +5,11 @@ using System.Linq;
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Taiko.Objects;
|
using osu.Game.Rulesets.Taiko.Objects;
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Tests
|
namespace osu.Game.Rulesets.Taiko.Tests
|
||||||
{
|
{
|
||||||
public class TestSceneSwellJudgements : PlayerTestScene
|
public class TestSceneSwellJudgements : TestSceneTaikoPlayer
|
||||||
{
|
{
|
||||||
public TestSceneSwellJudgements()
|
|
||||||
: base(new TaikoRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestZeroTickTimeOffsets()
|
public void TestZeroTickTimeOffsets()
|
||||||
{
|
{
|
||||||
|
12
osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayer.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Taiko.Tests
|
||||||
|
{
|
||||||
|
public class TestSceneTaikoPlayer : PlayerTestScene
|
||||||
|
{
|
||||||
|
protected override Ruleset CreatePlayerRuleset() => new TaikoRuleset();
|
||||||
|
}
|
||||||
|
}
|
@ -11,13 +11,8 @@ using osu.Game.Tests.Visual;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Tests
|
namespace osu.Game.Rulesets.Taiko.Tests
|
||||||
{
|
{
|
||||||
public class TestSceneTaikoSuddenDeath : PlayerTestScene
|
public class TestSceneTaikoSuddenDeath : TestSceneTaikoPlayer
|
||||||
{
|
{
|
||||||
public TestSceneTaikoSuddenDeath()
|
|
||||||
: base(new TaikoRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool AllowFail => true;
|
protected override bool AllowFail => true;
|
||||||
|
|
||||||
protected override TestPlayer CreatePlayer(Ruleset ruleset)
|
protected override TestPlayer CreatePlayer(Ruleset ruleset)
|
||||||
|
@ -6,23 +6,20 @@ using System.Collections.Generic;
|
|||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Rulesets.Taiko.UI;
|
using osu.Game.Rulesets.Taiko.UI;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Skinning
|
namespace osu.Game.Rulesets.Taiko.Skinning
|
||||||
{
|
{
|
||||||
public class TaikoLegacySkinTransformer : ISkin
|
public class TaikoLegacySkinTransformer : LegacySkinTransformer
|
||||||
{
|
{
|
||||||
private readonly ISkinSource source;
|
|
||||||
|
|
||||||
public TaikoLegacySkinTransformer(ISkinSource source)
|
public TaikoLegacySkinTransformer(ISkinSource source)
|
||||||
|
: base(source)
|
||||||
{
|
{
|
||||||
this.source = source;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable GetDrawableComponent(ISkinComponent component)
|
public override Drawable GetDrawableComponent(ISkinComponent component)
|
||||||
{
|
{
|
||||||
if (!(component is TaikoSkinComponent taikoComponent))
|
if (!(component is TaikoSkinComponent taikoComponent))
|
||||||
return null;
|
return null;
|
||||||
@ -100,7 +97,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return source.GetDrawableComponent(component);
|
return Source.GetDrawableComponent(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string getHitName(TaikoSkinComponents component)
|
private string getHitName(TaikoSkinComponents component)
|
||||||
@ -120,11 +117,9 @@ namespace osu.Game.Rulesets.Taiko.Skinning
|
|||||||
throw new ArgumentOutOfRangeException(nameof(component), "Invalid result type");
|
throw new ArgumentOutOfRangeException(nameof(component), "Invalid result type");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
|
public override SampleChannel GetSample(ISampleInfo sampleInfo) => Source.GetSample(new LegacyTaikoSampleInfo(sampleInfo));
|
||||||
|
|
||||||
public SampleChannel GetSample(ISampleInfo sampleInfo) => source.GetSample(new LegacyTaikoSampleInfo(sampleInfo));
|
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => Source.GetConfig<TLookup, TValue>(lookup);
|
||||||
|
|
||||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => source.GetConfig<TLookup, TValue>(lookup);
|
|
||||||
|
|
||||||
private class LegacyTaikoSampleInfo : ISampleInfo
|
private class LegacyTaikoSampleInfo : ISampleInfo
|
||||||
{
|
{
|
||||||
|
27
osu.Game.Tests/Gameplay/TestSceneGameplayClockContainer.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Gameplay
|
||||||
|
{
|
||||||
|
[HeadlessTest]
|
||||||
|
public class TestSceneGameplayClockContainer : OsuTestScene
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestStartThenElapsedTime()
|
||||||
|
{
|
||||||
|
GameplayClockContainer gcc = null;
|
||||||
|
|
||||||
|
AddStep("create container", () => Add(gcc = new GameplayClockContainer(CreateWorkingBeatmap(new OsuRuleset().RulesetInfo), Array.Empty<Mod>(), 0)));
|
||||||
|
AddStep("start track", () => gcc.Start());
|
||||||
|
AddUntilStep("elapsed greater than zero", () => gcc.GameplayClock.ElapsedFrameTime > 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,58 +1,21 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Timing;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Beatmaps.Formats;
|
|
||||||
using osu.Game.IO;
|
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Tests.Beatmaps;
|
||||||
using osu.Game.Storyboards;
|
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
using osu.Game.Users;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Gameplay
|
namespace osu.Game.Tests.Gameplay
|
||||||
{
|
{
|
||||||
[HeadlessTest]
|
[HeadlessTest]
|
||||||
public class TestSceneHitObjectSamples : PlayerTestScene
|
public class TestSceneHitObjectSamples : HitObjectSampleTest
|
||||||
{
|
{
|
||||||
private readonly SkinInfo userSkinInfo = new SkinInfo();
|
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
||||||
|
protected override IResourceStore<byte[]> Resources => TestResources.GetStore();
|
||||||
private readonly BeatmapInfo beatmapInfo = new BeatmapInfo
|
|
||||||
{
|
|
||||||
BeatmapSet = new BeatmapSetInfo(),
|
|
||||||
Metadata = new BeatmapMetadata
|
|
||||||
{
|
|
||||||
Author = User.SYSTEM_USER
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private readonly TestResourceStore userSkinResourceStore = new TestResourceStore();
|
|
||||||
private readonly TestResourceStore beatmapSkinResourceStore = new TestResourceStore();
|
|
||||||
|
|
||||||
protected override bool HasCustomSteps => true;
|
|
||||||
|
|
||||||
public TestSceneHitObjectSamples()
|
|
||||||
: base(new OsuRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private SkinSourceDependencyContainer dependencies;
|
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
=> new DependencyContainer(dependencies = new SkinSourceDependencyContainer(base.CreateChildDependencies(parent)));
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests that a hitobject which provides no custom sample set retrieves samples from the user skin.
|
/// Tests that a hitobject which provides no custom sample set retrieves samples from the user skin.
|
||||||
@ -62,11 +25,11 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
{
|
{
|
||||||
const string expected_sample = "normal-hitnormal";
|
const string expected_sample = "normal-hitnormal";
|
||||||
|
|
||||||
setupSkins(expected_sample, expected_sample);
|
SetupSkins(expected_sample, expected_sample);
|
||||||
|
|
||||||
createTestWithBeatmap("hitobject-skin-sample.osu");
|
CreateTestWithBeatmap("hitobject-skin-sample.osu");
|
||||||
|
|
||||||
assertUserLookup(expected_sample);
|
AssertUserLookup(expected_sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -77,11 +40,11 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
{
|
{
|
||||||
const string expected_sample = "normal-hitnormal";
|
const string expected_sample = "normal-hitnormal";
|
||||||
|
|
||||||
setupSkins(expected_sample, expected_sample);
|
SetupSkins(expected_sample, expected_sample);
|
||||||
|
|
||||||
createTestWithBeatmap("hitobject-beatmap-sample.osu");
|
CreateTestWithBeatmap("hitobject-beatmap-sample.osu");
|
||||||
|
|
||||||
assertBeatmapLookup(expected_sample);
|
AssertBeatmapLookup(expected_sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -92,11 +55,11 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
{
|
{
|
||||||
const string expected_sample = "normal-hitnormal";
|
const string expected_sample = "normal-hitnormal";
|
||||||
|
|
||||||
setupSkins(null, expected_sample);
|
SetupSkins(null, expected_sample);
|
||||||
|
|
||||||
createTestWithBeatmap("hitobject-beatmap-sample.osu");
|
CreateTestWithBeatmap("hitobject-beatmap-sample.osu");
|
||||||
|
|
||||||
assertUserLookup(expected_sample);
|
AssertUserLookup(expected_sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -108,11 +71,11 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
[TestCase("normal-hitnormal")]
|
[TestCase("normal-hitnormal")]
|
||||||
public void TestDefaultCustomSampleFromBeatmap(string expectedSample)
|
public void TestDefaultCustomSampleFromBeatmap(string expectedSample)
|
||||||
{
|
{
|
||||||
setupSkins(expectedSample, expectedSample);
|
SetupSkins(expectedSample, expectedSample);
|
||||||
|
|
||||||
createTestWithBeatmap("hitobject-beatmap-custom-sample.osu");
|
CreateTestWithBeatmap("hitobject-beatmap-custom-sample.osu");
|
||||||
|
|
||||||
assertBeatmapLookup(expectedSample);
|
AssertBeatmapLookup(expectedSample);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -124,11 +87,11 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
[TestCase("normal-hitnormal")]
|
[TestCase("normal-hitnormal")]
|
||||||
public void TestDefaultCustomSampleFromUserSkinFallback(string expectedSample)
|
public void TestDefaultCustomSampleFromUserSkinFallback(string expectedSample)
|
||||||
{
|
{
|
||||||
setupSkins(string.Empty, expectedSample);
|
SetupSkins(string.Empty, expectedSample);
|
||||||
|
|
||||||
createTestWithBeatmap("hitobject-beatmap-custom-sample.osu");
|
CreateTestWithBeatmap("hitobject-beatmap-custom-sample.osu");
|
||||||
|
|
||||||
assertUserLookup(expectedSample);
|
AssertUserLookup(expectedSample);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -139,11 +102,11 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
{
|
{
|
||||||
const string expected_sample = "hit_1.wav";
|
const string expected_sample = "hit_1.wav";
|
||||||
|
|
||||||
setupSkins(expected_sample, expected_sample);
|
SetupSkins(expected_sample, expected_sample);
|
||||||
|
|
||||||
createTestWithBeatmap("file-beatmap-sample.osu");
|
CreateTestWithBeatmap("file-beatmap-sample.osu");
|
||||||
|
|
||||||
assertBeatmapLookup(expected_sample);
|
AssertBeatmapLookup(expected_sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -154,11 +117,11 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
{
|
{
|
||||||
const string expected_sample = "normal-hitnormal";
|
const string expected_sample = "normal-hitnormal";
|
||||||
|
|
||||||
setupSkins(expected_sample, expected_sample);
|
SetupSkins(expected_sample, expected_sample);
|
||||||
|
|
||||||
createTestWithBeatmap("controlpoint-skin-sample.osu");
|
CreateTestWithBeatmap("controlpoint-skin-sample.osu");
|
||||||
|
|
||||||
assertUserLookup(expected_sample);
|
AssertUserLookup(expected_sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -169,11 +132,11 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
{
|
{
|
||||||
const string expected_sample = "normal-hitnormal";
|
const string expected_sample = "normal-hitnormal";
|
||||||
|
|
||||||
setupSkins(expected_sample, expected_sample);
|
SetupSkins(expected_sample, expected_sample);
|
||||||
|
|
||||||
createTestWithBeatmap("controlpoint-beatmap-sample.osu");
|
CreateTestWithBeatmap("controlpoint-beatmap-sample.osu");
|
||||||
|
|
||||||
assertBeatmapLookup(expected_sample);
|
AssertBeatmapLookup(expected_sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -183,11 +146,11 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
[TestCase("normal-hitnormal")]
|
[TestCase("normal-hitnormal")]
|
||||||
public void TestControlPointCustomSampleFromBeatmap(string sampleName)
|
public void TestControlPointCustomSampleFromBeatmap(string sampleName)
|
||||||
{
|
{
|
||||||
setupSkins(sampleName, sampleName);
|
SetupSkins(sampleName, sampleName);
|
||||||
|
|
||||||
createTestWithBeatmap("controlpoint-beatmap-custom-sample.osu");
|
CreateTestWithBeatmap("controlpoint-beatmap-custom-sample.osu");
|
||||||
|
|
||||||
assertBeatmapLookup(sampleName);
|
AssertBeatmapLookup(sampleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -198,149 +161,11 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
{
|
{
|
||||||
const string expected_sample = "normal-hitnormal3";
|
const string expected_sample = "normal-hitnormal3";
|
||||||
|
|
||||||
setupSkins(expected_sample, expected_sample);
|
SetupSkins(expected_sample, expected_sample);
|
||||||
|
|
||||||
createTestWithBeatmap("hitobject-beatmap-custom-sample-override.osu");
|
CreateTestWithBeatmap("hitobject-beatmap-custom-sample-override.osu");
|
||||||
|
|
||||||
assertBeatmapLookup(expected_sample);
|
AssertBeatmapLookup(expected_sample);
|
||||||
}
|
|
||||||
|
|
||||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => currentTestBeatmap;
|
|
||||||
|
|
||||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
|
||||||
=> new TestWorkingBeatmap(beatmapInfo, beatmapSkinResourceStore, beatmap, storyboard, Clock, Audio);
|
|
||||||
|
|
||||||
private IBeatmap currentTestBeatmap;
|
|
||||||
|
|
||||||
private void createTestWithBeatmap(string filename)
|
|
||||||
{
|
|
||||||
CreateTest(() =>
|
|
||||||
{
|
|
||||||
AddStep("clear performed lookups", () =>
|
|
||||||
{
|
|
||||||
userSkinResourceStore.PerformedLookups.Clear();
|
|
||||||
beatmapSkinResourceStore.PerformedLookups.Clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
AddStep($"load {filename}", () =>
|
|
||||||
{
|
|
||||||
using (var reader = new LineBufferedReader(TestResources.OpenResource($"SampleLookups/{filename}")))
|
|
||||||
currentTestBeatmap = Decoder.GetDecoder<Beatmap>(reader).Decode(reader);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupSkins(string beatmapFile, string userFile)
|
|
||||||
{
|
|
||||||
AddStep("setup skins", () =>
|
|
||||||
{
|
|
||||||
userSkinInfo.Files = new List<SkinFileInfo>
|
|
||||||
{
|
|
||||||
new SkinFileInfo
|
|
||||||
{
|
|
||||||
Filename = userFile,
|
|
||||||
FileInfo = new IO.FileInfo { Hash = userFile }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
beatmapInfo.BeatmapSet.Files = new List<BeatmapSetFileInfo>
|
|
||||||
{
|
|
||||||
new BeatmapSetFileInfo
|
|
||||||
{
|
|
||||||
Filename = beatmapFile,
|
|
||||||
FileInfo = new IO.FileInfo { Hash = beatmapFile }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Need to refresh the cached skin source to refresh the skin resource store.
|
|
||||||
dependencies.SkinSource = new SkinProvidingContainer(new LegacySkin(userSkinInfo, userSkinResourceStore, Audio));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertBeatmapLookup(string name) => AddAssert($"\"{name}\" looked up from beatmap skin",
|
|
||||||
() => !userSkinResourceStore.PerformedLookups.Contains(name) && beatmapSkinResourceStore.PerformedLookups.Contains(name));
|
|
||||||
|
|
||||||
private void assertUserLookup(string name) => AddAssert($"\"{name}\" looked up from user skin",
|
|
||||||
() => !beatmapSkinResourceStore.PerformedLookups.Contains(name) && userSkinResourceStore.PerformedLookups.Contains(name));
|
|
||||||
|
|
||||||
private class SkinSourceDependencyContainer : IReadOnlyDependencyContainer
|
|
||||||
{
|
|
||||||
public ISkinSource SkinSource;
|
|
||||||
|
|
||||||
private readonly IReadOnlyDependencyContainer fallback;
|
|
||||||
|
|
||||||
public SkinSourceDependencyContainer(IReadOnlyDependencyContainer fallback)
|
|
||||||
{
|
|
||||||
this.fallback = fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object Get(Type type)
|
|
||||||
{
|
|
||||||
if (type == typeof(ISkinSource))
|
|
||||||
return SkinSource;
|
|
||||||
|
|
||||||
return fallback.Get(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public object Get(Type type, CacheInfo info)
|
|
||||||
{
|
|
||||||
if (type == typeof(ISkinSource))
|
|
||||||
return SkinSource;
|
|
||||||
|
|
||||||
return fallback.Get(type, info);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Inject<T>(T instance) where T : class
|
|
||||||
{
|
|
||||||
// Never used directly
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestResourceStore : IResourceStore<byte[]>
|
|
||||||
{
|
|
||||||
public readonly List<string> PerformedLookups = new List<string>();
|
|
||||||
|
|
||||||
public byte[] Get(string name)
|
|
||||||
{
|
|
||||||
markLookup(name);
|
|
||||||
return Array.Empty<byte>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<byte[]> GetAsync(string name)
|
|
||||||
{
|
|
||||||
markLookup(name);
|
|
||||||
return Task.FromResult(Array.Empty<byte>());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Stream GetStream(string name)
|
|
||||||
{
|
|
||||||
markLookup(name);
|
|
||||||
return new MemoryStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void markLookup(string name) => PerformedLookups.Add(name.Substring(name.LastIndexOf(Path.DirectorySeparatorChar) + 1));
|
|
||||||
|
|
||||||
public IEnumerable<string> GetAvailableResources() => Enumerable.Empty<string>();
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestWorkingBeatmap : ClockBackedTestWorkingBeatmap
|
|
||||||
{
|
|
||||||
private readonly BeatmapInfo skinBeatmapInfo;
|
|
||||||
private readonly IResourceStore<byte[]> resourceStore;
|
|
||||||
|
|
||||||
public TestWorkingBeatmap(BeatmapInfo skinBeatmapInfo, IResourceStore<byte[]> resourceStore, IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio,
|
|
||||||
double length = 60000)
|
|
||||||
: base(beatmap, storyboard, referenceClock, audio, length)
|
|
||||||
{
|
|
||||||
this.skinBeatmapInfo = skinBeatmapInfo;
|
|
||||||
this.resourceStore = resourceStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override ISkin GetSkin() => new LegacyBeatmapSkin(skinBeatmapInfo, resourceStore, AudioManager);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -10,7 +11,12 @@ using osu.Framework.Audio.Sample;
|
|||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
using osu.Game.Storyboards;
|
||||||
|
using osu.Game.Storyboards.Drawables;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
@ -43,6 +49,27 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
AddAssert("sample is non-null", () => channel != null);
|
AddAssert("sample is non-null", () => channel != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSamplePlaybackAtZero()
|
||||||
|
{
|
||||||
|
GameplayClockContainer gameplayContainer = null;
|
||||||
|
DrawableStoryboardSample sample = null;
|
||||||
|
|
||||||
|
AddStep("create container", () =>
|
||||||
|
{
|
||||||
|
Add(gameplayContainer = new GameplayClockContainer(CreateWorkingBeatmap(new OsuRuleset().RulesetInfo), Array.Empty<Mod>(), 0));
|
||||||
|
|
||||||
|
gameplayContainer.Add(sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
||||||
|
{
|
||||||
|
Clock = gameplayContainer.GameplayClock
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("start time", () => gameplayContainer.Start());
|
||||||
|
|
||||||
|
AddUntilStep("sample playback succeeded", () => sample.LifetimeEnd < double.MaxValue);
|
||||||
|
}
|
||||||
|
|
||||||
private class TestSkin : LegacySkin
|
private class TestSkin : LegacySkin
|
||||||
{
|
{
|
||||||
public TestSkin(string resourceName, AudioManager audioManager)
|
public TestSkin(string resourceName, AudioManager audioManager)
|
||||||
@ -60,11 +87,11 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
this.resourceName = resourceName;
|
this.resourceName = resourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] Get(string name) => name == resourceName ? TestResources.GetStore().Get("Resources/test-sample.mp3") : null;
|
public byte[] Get(string name) => name == resourceName ? TestResources.GetStore().Get("Resources/Samples/test-sample.mp3") : null;
|
||||||
|
|
||||||
public Task<byte[]> GetAsync(string name) => name == resourceName ? TestResources.GetStore().GetAsync("Resources/test-sample.mp3") : null;
|
public Task<byte[]> GetAsync(string name) => name == resourceName ? TestResources.GetStore().GetAsync("Resources/Samples/test-sample.mp3") : null;
|
||||||
|
|
||||||
public Stream GetStream(string name) => name == resourceName ? TestResources.GetStore().GetStream("Resources/test-sample.mp3") : null;
|
public Stream GetStream(string name) => name == resourceName ? TestResources.GetStore().GetStream("Resources/Samples/test-sample.mp3") : null;
|
||||||
|
|
||||||
public IEnumerable<string> GetAvailableResources() => new[] { resourceName };
|
public IEnumerable<string> GetAvailableResources() => new[] { resourceName };
|
||||||
|
|
||||||
|
BIN
osu.Game.Tests/Resources/Textures/test-image.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
95
osu.Game.Tests/Testing/TestSceneRulesetDependencies.cs
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio.Track;
|
||||||
|
using osu.Framework.Configuration.Tracking;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Framework.IO.Stores;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Configuration;
|
||||||
|
using osu.Game.Rulesets.Difficulty;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Tests.Resources;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Testing
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A test scene ensuring the dependencies for the
|
||||||
|
/// provided ruleset below are cached at the base implementation.
|
||||||
|
/// </summary>
|
||||||
|
[HeadlessTest]
|
||||||
|
public class TestSceneRulesetDependencies : OsuTestScene
|
||||||
|
{
|
||||||
|
protected override Ruleset CreateRuleset() => new TestRuleset();
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRetrieveTexture()
|
||||||
|
{
|
||||||
|
AddAssert("ruleset texture retrieved", () =>
|
||||||
|
Dependencies.Get<TextureStore>().Get(@"test-image") != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRetrieveSample()
|
||||||
|
{
|
||||||
|
AddAssert("ruleset sample retrieved", () =>
|
||||||
|
Dependencies.Get<ISampleStore>().Get(@"test-sample") != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestResolveConfigManager()
|
||||||
|
{
|
||||||
|
AddAssert("ruleset config resolved", () =>
|
||||||
|
Dependencies.Get<TestRulesetConfigManager>() != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestRuleset : Ruleset
|
||||||
|
{
|
||||||
|
public override string Description => string.Empty;
|
||||||
|
public override string ShortName => string.Empty;
|
||||||
|
|
||||||
|
public TestRuleset()
|
||||||
|
{
|
||||||
|
// temporary ID to let RulesetConfigCache pass our
|
||||||
|
// config manager to the ruleset dependencies.
|
||||||
|
RulesetInfo.ID = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IResourceStore<byte[]> CreateResourceStore() => new NamespacedResourceStore<byte[]>(TestResources.GetStore(), @"Resources");
|
||||||
|
public override IRulesetConfigManager CreateConfig(SettingsStore settings) => new TestRulesetConfigManager();
|
||||||
|
|
||||||
|
public override IEnumerable<Mod> GetModsFor(ModType type) => Array.Empty<Mod>();
|
||||||
|
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => null;
|
||||||
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => null;
|
||||||
|
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestRulesetConfigManager : IRulesetConfigManager
|
||||||
|
{
|
||||||
|
public void Load()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Save() => true;
|
||||||
|
|
||||||
|
public TrackedSettings CreateTrackedSettings() => new TrackedSettings();
|
||||||
|
|
||||||
|
public void LoadInto(TrackedSettings settings)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,7 @@ using osu.Game.Graphics;
|
|||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
@ -27,6 +28,7 @@ using osu.Game.Screens.Play;
|
|||||||
using osu.Game.Screens.Play.PlayerSettings;
|
using osu.Game.Screens.Play.PlayerSettings;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -186,9 +188,15 @@ namespace osu.Game.Tests.Visual.Background
|
|||||||
public void TestTransition()
|
public void TestTransition()
|
||||||
{
|
{
|
||||||
performFullSetup();
|
performFullSetup();
|
||||||
|
|
||||||
FadeAccessibleResults results = null;
|
FadeAccessibleResults results = null;
|
||||||
AddStep("Transition to Results", () => player.Push(results =
|
|
||||||
new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } })));
|
AddStep("Transition to Results", () => player.Push(results = new FadeAccessibleResults(new ScoreInfo
|
||||||
|
{
|
||||||
|
User = new User { Username = "osu!" },
|
||||||
|
Beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo
|
||||||
|
})));
|
||||||
|
|
||||||
AddUntilStep("Wait for results is current", () => results.IsCurrentScreen());
|
AddUntilStep("Wait for results is current", () => results.IsCurrentScreen());
|
||||||
AddUntilStep("Screen is undimmed, original background retained", () =>
|
AddUntilStep("Screen is undimmed, original background retained", () =>
|
||||||
songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect());
|
songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect());
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
@ -13,13 +14,10 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
public class TestSceneEditorChangeStates : EditorTestScene
|
public class TestSceneEditorChangeStates : EditorTestScene
|
||||||
{
|
{
|
||||||
public TestSceneEditorChangeStates()
|
|
||||||
: base(new OsuRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private EditorBeatmap editorBeatmap;
|
private EditorBeatmap editorBeatmap;
|
||||||
|
|
||||||
|
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
|
||||||
|
|
||||||
public override void SetUpSteps()
|
public override void SetUpSteps()
|
||||||
{
|
{
|
||||||
base.SetUpSteps();
|
base.SetUpSteps();
|
||||||
|
16
osu.Game.Tests/Visual/Gameplay/OsuPlayerTestScene.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A <see cref="PlayerTestScene"/> with an arbitrary ruleset value to test with.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class OsuPlayerTestScene : PlayerTestScene
|
||||||
|
{
|
||||||
|
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
||||||
|
}
|
||||||
|
}
|
@ -10,14 +10,13 @@ using osu.Framework.Testing;
|
|||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Osu;
|
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
public class TestSceneCompletionCancellation : PlayerTestScene
|
public class TestSceneCompletionCancellation : OsuPlayerTestScene
|
||||||
{
|
{
|
||||||
private Track track;
|
private Track track;
|
||||||
|
|
||||||
@ -29,11 +28,6 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
protected override bool AllowFail => false;
|
protected override bool AllowFail => false;
|
||||||
|
|
||||||
public TestSceneCompletionCancellation()
|
|
||||||
: base(new OsuRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
public override void SetUpSteps()
|
public override void SetUpSteps()
|
||||||
{
|
{
|
||||||
|
@ -10,23 +10,17 @@ using osu.Framework.Utils;
|
|||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Osu;
|
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
public class TestSceneGameplayRewinding : PlayerTestScene
|
public class TestSceneGameplayRewinding : OsuPlayerTestScene
|
||||||
{
|
{
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private AudioManager audioManager { get; set; }
|
private AudioManager audioManager { get; set; }
|
||||||
|
|
||||||
public TestSceneGameplayRewinding()
|
|
||||||
: base(new OsuRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private Track track;
|
private Track track;
|
||||||
|
|
||||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
||||||
|
@ -10,14 +10,13 @@ using osu.Framework.Testing;
|
|||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Osu;
|
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
public class TestScenePause : PlayerTestScene
|
public class TestScenePause : OsuPlayerTestScene
|
||||||
{
|
{
|
||||||
protected new PausePlayer Player => (PausePlayer)base.Player;
|
protected new PausePlayer Player => (PausePlayer)base.Player;
|
||||||
|
|
||||||
@ -26,7 +25,6 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
public TestScenePause()
|
public TestScenePause()
|
||||||
: base(new OsuRuleset())
|
|
||||||
{
|
{
|
||||||
base.Content.Add(content = new MenuCursorContainer { RelativeSizeAxes = Axes.Both });
|
base.Content.Add(content = new MenuCursorContainer { RelativeSizeAxes = Axes.Both });
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,11 @@ using osu.Framework.Platform;
|
|||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Osu;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
[HeadlessTest] // we alter unsafe properties on the game host to test inactive window state.
|
[HeadlessTest] // we alter unsafe properties on the game host to test inactive window state.
|
||||||
public class TestScenePauseWhenInactive : PlayerTestScene
|
public class TestScenePauseWhenInactive : OsuPlayerTestScene
|
||||||
{
|
{
|
||||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
||||||
{
|
{
|
||||||
@ -27,11 +26,6 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private GameHost host { get; set; }
|
private GameHost host { get; set; }
|
||||||
|
|
||||||
public TestScenePauseWhenInactive()
|
|
||||||
: base(new OsuRuleset())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDoesntPauseDuringIntro()
|
public void TestDoesntPauseDuringIntro()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,124 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Screens.Multi.Ranking;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
|
{
|
||||||
|
public class TestSceneTimeshiftResultsScreen : ScreenTestScene
|
||||||
|
{
|
||||||
|
private bool roomsReceived;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup() => Schedule(() =>
|
||||||
|
{
|
||||||
|
roomsReceived = false;
|
||||||
|
bindHandler();
|
||||||
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestShowResultsWithScore()
|
||||||
|
{
|
||||||
|
createResults(new TestScoreInfo(new OsuRuleset().RulesetInfo));
|
||||||
|
AddWaitStep("wait for display", 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestShowResultsNullScore()
|
||||||
|
{
|
||||||
|
createResults(null);
|
||||||
|
AddWaitStep("wait for display", 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestShowResultsNullScoreWithDelay()
|
||||||
|
{
|
||||||
|
AddStep("bind delayed handler", () => bindHandler(3000));
|
||||||
|
createResults(null);
|
||||||
|
AddUntilStep("wait for rooms to be received", () => roomsReceived);
|
||||||
|
AddWaitStep("wait for display", 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createResults(ScoreInfo score)
|
||||||
|
{
|
||||||
|
AddStep("load results", () =>
|
||||||
|
{
|
||||||
|
LoadScreen(new TimeshiftResultsScreen(score, 1, new PlaylistItem
|
||||||
|
{
|
||||||
|
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
||||||
|
Ruleset = { Value = new OsuRuleset().RulesetInfo }
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bindHandler(double delay = 0)
|
||||||
|
{
|
||||||
|
var roomScores = new List<RoomScore>();
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
roomScores.Add(new RoomScore
|
||||||
|
{
|
||||||
|
ID = i,
|
||||||
|
Accuracy = 0.9 - 0.01 * i,
|
||||||
|
EndedAt = DateTimeOffset.Now.Subtract(TimeSpan.FromHours(i)),
|
||||||
|
Passed = true,
|
||||||
|
Rank = ScoreRank.B,
|
||||||
|
MaxCombo = 999,
|
||||||
|
TotalScore = 999999 - i * 1000,
|
||||||
|
User = new User
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
Username = $"peppy{i}",
|
||||||
|
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||||
|
},
|
||||||
|
Statistics =
|
||||||
|
{
|
||||||
|
{ HitResult.Miss, 1 },
|
||||||
|
{ HitResult.Meh, 50 },
|
||||||
|
{ HitResult.Good, 100 },
|
||||||
|
{ HitResult.Great, 300 },
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
((DummyAPIAccess)API).HandleRequest = request =>
|
||||||
|
{
|
||||||
|
switch (request)
|
||||||
|
{
|
||||||
|
case GetRoomPlaylistScoresRequest r:
|
||||||
|
if (delay == 0)
|
||||||
|
success();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await Task.Delay(TimeSpan.FromMilliseconds(delay));
|
||||||
|
Schedule(success);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void success()
|
||||||
|
{
|
||||||
|
r.TriggerSuccess(new RoomPlaylistScores { Scores = roomScores });
|
||||||
|
roomsReceived = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@ using osu.Game.Graphics.UserInterface;
|
|||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.Menu;
|
using osu.Game.Screens.Menu;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -100,6 +101,8 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
|
|
||||||
public new BeatmapManager BeatmapManager => base.BeatmapManager;
|
public new BeatmapManager BeatmapManager => base.BeatmapManager;
|
||||||
|
|
||||||
|
public new ScoreManager ScoreManager => base.ScoreManager;
|
||||||
|
|
||||||
public new SettingsPanel Settings => base.Settings;
|
public new SettingsPanel Settings => base.Settings;
|
||||||
|
|
||||||
public new MusicController MusicController => base.MusicController;
|
public new MusicController MusicController => base.MusicController;
|
||||||
|
155
osu.Game.Tests/Visual/Navigation/TestScenePresentScore.cs
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Screens;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Mania;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Screens.Menu;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Screens.Ranking;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Navigation
|
||||||
|
{
|
||||||
|
public class TestScenePresentScore : OsuGameTestScene
|
||||||
|
{
|
||||||
|
private BeatmapSetInfo beatmap;
|
||||||
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public new void SetUpSteps()
|
||||||
|
{
|
||||||
|
AddStep("import beatmap", () =>
|
||||||
|
{
|
||||||
|
var difficulty = new BeatmapDifficulty();
|
||||||
|
var metadata = new BeatmapMetadata
|
||||||
|
{
|
||||||
|
Artist = "SomeArtist",
|
||||||
|
AuthorString = "SomeAuthor",
|
||||||
|
Title = "import"
|
||||||
|
};
|
||||||
|
|
||||||
|
beatmap = Game.BeatmapManager.Import(new BeatmapSetInfo
|
||||||
|
{
|
||||||
|
Hash = Guid.NewGuid().ToString(),
|
||||||
|
OnlineBeatmapSetID = 1,
|
||||||
|
Metadata = metadata,
|
||||||
|
Beatmaps = new List<BeatmapInfo>
|
||||||
|
{
|
||||||
|
new BeatmapInfo
|
||||||
|
{
|
||||||
|
OnlineBeatmapID = 1 * 1024,
|
||||||
|
Metadata = metadata,
|
||||||
|
BaseDifficulty = difficulty,
|
||||||
|
Ruleset = new OsuRuleset().RulesetInfo
|
||||||
|
},
|
||||||
|
new BeatmapInfo
|
||||||
|
{
|
||||||
|
OnlineBeatmapID = 1 * 2048,
|
||||||
|
Metadata = metadata,
|
||||||
|
BaseDifficulty = difficulty,
|
||||||
|
Ruleset = new OsuRuleset().RulesetInfo
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}).Result;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFromMainMenu([Values] ScorePresentType type)
|
||||||
|
{
|
||||||
|
var firstImport = importScore(1);
|
||||||
|
var secondimport = importScore(3);
|
||||||
|
|
||||||
|
presentAndConfirm(firstImport, type);
|
||||||
|
returnToMenu();
|
||||||
|
presentAndConfirm(secondimport, type);
|
||||||
|
returnToMenu();
|
||||||
|
returnToMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFromMainMenuDifferentRuleset([Values] ScorePresentType type)
|
||||||
|
{
|
||||||
|
var firstImport = importScore(1);
|
||||||
|
var secondimport = importScore(3, new ManiaRuleset().RulesetInfo);
|
||||||
|
|
||||||
|
presentAndConfirm(firstImport, type);
|
||||||
|
returnToMenu();
|
||||||
|
presentAndConfirm(secondimport, type);
|
||||||
|
returnToMenu();
|
||||||
|
returnToMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFromSongSelect([Values] ScorePresentType type)
|
||||||
|
{
|
||||||
|
var firstImport = importScore(1);
|
||||||
|
presentAndConfirm(firstImport, type);
|
||||||
|
|
||||||
|
var secondimport = importScore(3);
|
||||||
|
presentAndConfirm(secondimport, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFromSongSelectDifferentRuleset([Values] ScorePresentType type)
|
||||||
|
{
|
||||||
|
var firstImport = importScore(1);
|
||||||
|
presentAndConfirm(firstImport, type);
|
||||||
|
|
||||||
|
var secondimport = importScore(3, new ManiaRuleset().RulesetInfo);
|
||||||
|
presentAndConfirm(secondimport, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void returnToMenu()
|
||||||
|
{
|
||||||
|
AddStep("return to menu", () => Game.ScreenStack.CurrentScreen.Exit());
|
||||||
|
AddUntilStep("wait for menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Func<ScoreInfo> importScore(int i, RulesetInfo ruleset = null)
|
||||||
|
{
|
||||||
|
ScoreInfo imported = null;
|
||||||
|
AddStep($"import score {i}", () =>
|
||||||
|
{
|
||||||
|
imported = Game.ScoreManager.Import(new ScoreInfo
|
||||||
|
{
|
||||||
|
Hash = Guid.NewGuid().ToString(),
|
||||||
|
OnlineScoreID = i,
|
||||||
|
Beatmap = beatmap.Beatmaps.First(),
|
||||||
|
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
||||||
|
}).Result;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert($"import {i} succeeded", () => imported != null);
|
||||||
|
|
||||||
|
return () => imported;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void presentAndConfirm(Func<ScoreInfo> getImport, ScorePresentType type)
|
||||||
|
{
|
||||||
|
AddStep("present score", () => Game.PresentScore(getImport(), type));
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case ScorePresentType.Results:
|
||||||
|
AddUntilStep("wait for results", () => Game.ScreenStack.CurrentScreen is ResultsScreen);
|
||||||
|
AddUntilStep("correct score displayed", () => ((ResultsScreen)Game.ScreenStack.CurrentScreen).Score.ID == getImport().ID);
|
||||||
|
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.ID == getImport().Ruleset.ID);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScorePresentType.Gameplay:
|
||||||
|
AddUntilStep("wait for player loader", () => Game.ScreenStack.CurrentScreen is ReplayPlayerLoader);
|
||||||
|
AddUntilStep("correct score displayed", () => ((ReplayPlayerLoader)Game.ScreenStack.CurrentScreen).Score.ID == getImport().ID);
|
||||||
|
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.ID == getImport().Ruleset.ID);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,52 +1,128 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Online.API.Requests;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Game.Overlays.Comments;
|
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Users;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osu.Game.Overlays.Comments;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Online
|
namespace osu.Game.Tests.Visual.Online
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneCommentsContainer : OsuTestScene
|
public class TestSceneCommentsContainer : OsuTestScene
|
||||||
{
|
{
|
||||||
protected override bool UseOnlineAPI => true;
|
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||||
|
|
||||||
public TestSceneCommentsContainer()
|
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
|
||||||
{
|
|
||||||
BasicScrollContainer scroll;
|
|
||||||
TestCommentsContainer comments;
|
|
||||||
|
|
||||||
Add(scroll = new BasicScrollContainer
|
private CommentsContainer commentsContainer;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void SetUp() => Schedule(() =>
|
||||||
|
Child = new BasicScrollContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = comments = new TestCommentsContainer()
|
Child = commentsContainer = new CommentsContainer()
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("Big Black comments", () => comments.ShowComments(CommentableType.Beatmapset, 41823));
|
[Test]
|
||||||
AddStep("Airman comments", () => comments.ShowComments(CommentableType.Beatmapset, 24313));
|
public void TestIdleState()
|
||||||
AddStep("Lazer build comments", () => comments.ShowComments(CommentableType.Build, 4772));
|
|
||||||
AddStep("News comments", () => comments.ShowComments(CommentableType.NewsPost, 715));
|
|
||||||
AddStep("Trigger user change", comments.User.TriggerChange);
|
|
||||||
AddStep("Idle state", () =>
|
|
||||||
{
|
{
|
||||||
scroll.Clear();
|
AddUntilStep("loading spinner shown",
|
||||||
scroll.Add(comments = new TestCommentsContainer());
|
() => commentsContainer.ChildrenOfType<CommentsShowMoreButton>().Single().IsLoading);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestCommentsContainer : CommentsContainer
|
[Test]
|
||||||
|
public void TestSingleCommentsPage()
|
||||||
{
|
{
|
||||||
public new Bindable<User> User => base.User;
|
setUpCommentsResponse(exampleComments);
|
||||||
}
|
AddStep("show comments", () => commentsContainer.ShowComments(CommentableType.Beatmapset, 123));
|
||||||
|
AddUntilStep("show more button hidden",
|
||||||
|
() => commentsContainer.ChildrenOfType<CommentsShowMoreButton>().Single().Alpha == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMultipleCommentPages()
|
||||||
|
{
|
||||||
|
var comments = exampleComments;
|
||||||
|
comments.HasMore = true;
|
||||||
|
comments.TopLevelCount = 10;
|
||||||
|
|
||||||
|
setUpCommentsResponse(comments);
|
||||||
|
AddStep("show comments", () => commentsContainer.ShowComments(CommentableType.Beatmapset, 123));
|
||||||
|
AddUntilStep("show more button visible",
|
||||||
|
() => commentsContainer.ChildrenOfType<CommentsShowMoreButton>().Single().Alpha == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMultipleLoads()
|
||||||
|
{
|
||||||
|
var comments = exampleComments;
|
||||||
|
int topLevelCommentCount = exampleComments.Comments.Count(comment => comment.IsTopLevel);
|
||||||
|
|
||||||
|
AddStep("hide container", () => commentsContainer.Hide());
|
||||||
|
setUpCommentsResponse(comments);
|
||||||
|
AddRepeatStep("show comments multiple times",
|
||||||
|
() => commentsContainer.ShowComments(CommentableType.Beatmapset, 456), 2);
|
||||||
|
AddStep("show container", () => commentsContainer.Show());
|
||||||
|
AddUntilStep("comment count is correct",
|
||||||
|
() => commentsContainer.ChildrenOfType<DrawableComment>().Count() == topLevelCommentCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUpCommentsResponse(CommentBundle commentBundle)
|
||||||
|
=> AddStep("set up response", () =>
|
||||||
|
{
|
||||||
|
dummyAPI.HandleRequest = request =>
|
||||||
|
{
|
||||||
|
if (!(request is GetCommentsRequest getCommentsRequest))
|
||||||
|
return;
|
||||||
|
|
||||||
|
getCommentsRequest.TriggerSuccess(commentBundle);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
private CommentBundle exampleComments => new CommentBundle
|
||||||
|
{
|
||||||
|
Comments = new List<Comment>
|
||||||
|
{
|
||||||
|
new Comment
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Message = "This is a comment",
|
||||||
|
LegacyName = "FirstUser",
|
||||||
|
CreatedAt = DateTimeOffset.Now,
|
||||||
|
VotesCount = 19,
|
||||||
|
RepliesCount = 1
|
||||||
|
},
|
||||||
|
new Comment
|
||||||
|
{
|
||||||
|
Id = 5,
|
||||||
|
ParentId = 1,
|
||||||
|
Message = "This is a child comment",
|
||||||
|
LegacyName = "SecondUser",
|
||||||
|
CreatedAt = DateTimeOffset.Now,
|
||||||
|
VotesCount = 4,
|
||||||
|
},
|
||||||
|
new Comment
|
||||||
|
{
|
||||||
|
Id = 10,
|
||||||
|
Message = "This is another comment",
|
||||||
|
LegacyName = "ThirdUser",
|
||||||
|
CreatedAt = DateTimeOffset.Now,
|
||||||
|
VotesCount = 0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
IncludedComments = new List<Comment>(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -33,7 +32,10 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
{
|
{
|
||||||
var author = new User { Username = "mapper_name" };
|
var author = new User { Username = "mapper_name" };
|
||||||
|
|
||||||
AddStep("show example score", () => showPanel(createTestBeatmap(author), new TestScoreInfo(new OsuRuleset().RulesetInfo)));
|
AddStep("show example score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo)
|
||||||
|
{
|
||||||
|
Beatmap = createTestBeatmap(author)
|
||||||
|
}));
|
||||||
|
|
||||||
AddAssert("mapper name present", () => this.ChildrenOfType<OsuSpriteText>().Any(spriteText => spriteText.Text == "mapper_name"));
|
AddAssert("mapper name present", () => this.ChildrenOfType<OsuSpriteText>().Any(spriteText => spriteText.Text == "mapper_name"));
|
||||||
}
|
}
|
||||||
@ -41,38 +43,34 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestMapWithUnknownMapper()
|
public void TestMapWithUnknownMapper()
|
||||||
{
|
{
|
||||||
AddStep("show example score", () => showPanel(createTestBeatmap(null), new TestScoreInfo(new OsuRuleset().RulesetInfo)));
|
AddStep("show example score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo)
|
||||||
|
{
|
||||||
|
Beatmap = createTestBeatmap(null)
|
||||||
|
}));
|
||||||
|
|
||||||
AddAssert("mapped by text not present", () =>
|
AddAssert("mapped by text not present", () =>
|
||||||
this.ChildrenOfType<OsuSpriteText>().All(spriteText => !containsAny(spriteText.Text, "mapped", "by")));
|
this.ChildrenOfType<OsuSpriteText>().All(spriteText => !containsAny(spriteText.Text, "mapped", "by")));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPanel(WorkingBeatmap workingBeatmap, ScoreInfo score)
|
private void showPanel(ScoreInfo score) => Child = new ExpandedPanelMiddleContentContainer(score);
|
||||||
{
|
|
||||||
Child = new ExpandedPanelMiddleContentContainer(workingBeatmap, score);
|
|
||||||
}
|
|
||||||
|
|
||||||
private WorkingBeatmap createTestBeatmap(User author)
|
private BeatmapInfo createTestBeatmap(User author)
|
||||||
{
|
{
|
||||||
var beatmap = new TestBeatmap(rulesetStore.GetRuleset(0));
|
var beatmap = new TestBeatmap(rulesetStore.GetRuleset(0)).BeatmapInfo;
|
||||||
|
|
||||||
beatmap.Metadata.Author = author;
|
beatmap.Metadata.Author = author;
|
||||||
beatmap.Metadata.Title = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap title";
|
beatmap.Metadata.Title = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap title";
|
||||||
beatmap.Metadata.Artist = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap artist";
|
beatmap.Metadata.Artist = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap artist";
|
||||||
|
|
||||||
return new TestWorkingBeatmap(beatmap);
|
return beatmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool containsAny(string text, params string[] stringsToMatch) => stringsToMatch.Any(text.Contains);
|
private bool containsAny(string text, params string[] stringsToMatch) => stringsToMatch.Any(text.Contains);
|
||||||
|
|
||||||
private class ExpandedPanelMiddleContentContainer : Container
|
private class ExpandedPanelMiddleContentContainer : Container
|
||||||
{
|
{
|
||||||
[Cached]
|
public ExpandedPanelMiddleContentContainer(ScoreInfo score)
|
||||||
private Bindable<WorkingBeatmap> workingBeatmap { get; set; }
|
|
||||||
|
|
||||||
public ExpandedPanelMiddleContentContainer(WorkingBeatmap beatmap, ScoreInfo score)
|
|
||||||
{
|
{
|
||||||
workingBeatmap = new Bindable<WorkingBeatmap>(beatmap);
|
|
||||||
|
|
||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
Size = new Vector2(ScorePanel.EXPANDED_WIDTH, 700);
|
Size = new Vector2(ScorePanel.EXPANDED_WIDTH, 700);
|
||||||
|
@ -38,13 +38,9 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
public class TestScenePlaySongSelect : ScreenTestScene
|
public class TestScenePlaySongSelect : ScreenTestScene
|
||||||
{
|
{
|
||||||
private BeatmapManager manager;
|
private BeatmapManager manager;
|
||||||
|
|
||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
|
|
||||||
private MusicController music;
|
private MusicController music;
|
||||||
|
|
||||||
private WorkingBeatmap defaultBeatmap;
|
private WorkingBeatmap defaultBeatmap;
|
||||||
|
|
||||||
private TestSongSelect songSelect;
|
private TestSongSelect songSelect;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -308,15 +304,13 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
|
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
|
||||||
|
|
||||||
var sortMode = config.GetBindable<SortMode>(OsuSetting.SongSelectSortingMode);
|
AddStep(@"Sort by Artist", () => config.Set(OsuSetting.SongSelectSortingMode, SortMode.Artist));
|
||||||
|
AddStep(@"Sort by Title", () => config.Set(OsuSetting.SongSelectSortingMode, SortMode.Title));
|
||||||
AddStep(@"Sort by Artist", delegate { sortMode.Value = SortMode.Artist; });
|
AddStep(@"Sort by Author", () => config.Set(OsuSetting.SongSelectSortingMode, SortMode.Author));
|
||||||
AddStep(@"Sort by Title", delegate { sortMode.Value = SortMode.Title; });
|
AddStep(@"Sort by DateAdded", () => config.Set(OsuSetting.SongSelectSortingMode, SortMode.DateAdded));
|
||||||
AddStep(@"Sort by Author", delegate { sortMode.Value = SortMode.Author; });
|
AddStep(@"Sort by BPM", () => config.Set(OsuSetting.SongSelectSortingMode, SortMode.BPM));
|
||||||
AddStep(@"Sort by DateAdded", delegate { sortMode.Value = SortMode.DateAdded; });
|
AddStep(@"Sort by Length", () => config.Set(OsuSetting.SongSelectSortingMode, SortMode.Length));
|
||||||
AddStep(@"Sort by BPM", delegate { sortMode.Value = SortMode.BPM; });
|
AddStep(@"Sort by Difficulty", () => config.Set(OsuSetting.SongSelectSortingMode, SortMode.Difficulty));
|
||||||
AddStep(@"Sort by Length", delegate { sortMode.Value = SortMode.Length; });
|
|
||||||
AddStep(@"Sort by Difficulty", delegate { sortMode.Value = SortMode.Difficulty; });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Game.Tournament.Screens;
|
||||||
|
|
||||||
|
namespace osu.Game.Tournament.Tests.Screens
|
||||||
|
{
|
||||||
|
public class TestSceneStablePathSelectScreen : TournamentTestScene
|
||||||
|
{
|
||||||
|
public TestSceneStablePathSelectScreen()
|
||||||
|
{
|
||||||
|
AddStep("Add screen", () => Add(new StablePathSelectTestScreen()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class StablePathSelectTestScreen : StablePathSelectScreen
|
||||||
|
{
|
||||||
|
protected override void ChangePath()
|
||||||
|
{
|
||||||
|
Expire();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void AutoDetect()
|
||||||
|
{
|
||||||
|
Expire();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
osu.Game.Tournament/Components/IPCErrorDialog.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Overlays.Dialog;
|
||||||
|
|
||||||
|
namespace osu.Game.Tournament.Components
|
||||||
|
{
|
||||||
|
public class IPCErrorDialog : PopupDialog
|
||||||
|
{
|
||||||
|
public IPCErrorDialog(string headerText, string bodyText)
|
||||||
|
{
|
||||||
|
Icon = FontAwesome.Regular.SadTear;
|
||||||
|
HeaderText = headerText;
|
||||||
|
BodyText = bodyText;
|
||||||
|
Buttons = new PopupDialogButton[]
|
||||||
|
{
|
||||||
|
new PopupDialogOkButton
|
||||||
|
{
|
||||||
|
Text = @"Alright.",
|
||||||
|
Action = () => Expire()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -77,6 +77,8 @@ namespace osu.Game.Tournament.Components
|
|||||||
flow = new FillFlowContainer
|
flow = new FillFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
// Todo: This is a hack for https://github.com/ppy/osu-framework/issues/3617 since this container is at the very edge of the screen and potentially initially masked away.
|
||||||
|
Height = 1,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
LayoutDuration = 500,
|
LayoutDuration = 500,
|
||||||
LayoutEasing = Easing.OutQuint,
|
LayoutEasing = Easing.OutQuint,
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
@ -20,6 +21,8 @@ namespace osu.Game.Tournament.IPC
|
|||||||
{
|
{
|
||||||
public class FileBasedIPC : MatchIPCInfo
|
public class FileBasedIPC : MatchIPCInfo
|
||||||
{
|
{
|
||||||
|
public Storage IPCStorage { get; private set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
protected IAPIProvider API { get; private set; }
|
protected IAPIProvider API { get; private set; }
|
||||||
|
|
||||||
@ -32,45 +35,46 @@ namespace osu.Game.Tournament.IPC
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private LadderInfo ladder { get; set; }
|
private LadderInfo ladder { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private StableInfo stableInfo { get; set; }
|
||||||
|
|
||||||
private int lastBeatmapId;
|
private int lastBeatmapId;
|
||||||
private ScheduledDelegate scheduled;
|
private ScheduledDelegate scheduled;
|
||||||
private GetBeatmapRequest beatmapLookupRequest;
|
private GetBeatmapRequest beatmapLookupRequest;
|
||||||
|
|
||||||
public Storage Storage { get; private set; }
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
LocateStableStorage();
|
var stablePath = stableInfo.StablePath ?? findStablePath();
|
||||||
|
initialiseIPCStorage(stablePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Storage LocateStableStorage()
|
[CanBeNull]
|
||||||
|
private Storage initialiseIPCStorage(string path)
|
||||||
{
|
{
|
||||||
scheduled?.Cancel();
|
scheduled?.Cancel();
|
||||||
|
|
||||||
Storage = null;
|
IPCStorage = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var path = findStablePath();
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Storage = new DesktopStorage(path, host as DesktopGameHost);
|
IPCStorage = new DesktopStorage(path, host as DesktopGameHost);
|
||||||
|
|
||||||
const string file_ipc_filename = "ipc.txt";
|
const string file_ipc_filename = "ipc.txt";
|
||||||
const string file_ipc_state_filename = "ipc-state.txt";
|
const string file_ipc_state_filename = "ipc-state.txt";
|
||||||
const string file_ipc_scores_filename = "ipc-scores.txt";
|
const string file_ipc_scores_filename = "ipc-scores.txt";
|
||||||
const string file_ipc_channel_filename = "ipc-channel.txt";
|
const string file_ipc_channel_filename = "ipc-channel.txt";
|
||||||
|
|
||||||
if (Storage.Exists(file_ipc_filename))
|
if (IPCStorage.Exists(file_ipc_filename))
|
||||||
{
|
{
|
||||||
scheduled = Scheduler.AddDelayed(delegate
|
scheduled = Scheduler.AddDelayed(delegate
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var stream = Storage.GetStream(file_ipc_filename))
|
using (var stream = IPCStorage.GetStream(file_ipc_filename))
|
||||||
using (var sr = new StreamReader(stream))
|
using (var sr = new StreamReader(stream))
|
||||||
{
|
{
|
||||||
var beatmapId = int.Parse(sr.ReadLine());
|
var beatmapId = int.Parse(sr.ReadLine());
|
||||||
@ -104,7 +108,7 @@ namespace osu.Game.Tournament.IPC
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var stream = Storage.GetStream(file_ipc_channel_filename))
|
using (var stream = IPCStorage.GetStream(file_ipc_channel_filename))
|
||||||
using (var sr = new StreamReader(stream))
|
using (var sr = new StreamReader(stream))
|
||||||
{
|
{
|
||||||
ChatChannel.Value = sr.ReadLine();
|
ChatChannel.Value = sr.ReadLine();
|
||||||
@ -117,7 +121,7 @@ namespace osu.Game.Tournament.IPC
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var stream = Storage.GetStream(file_ipc_state_filename))
|
using (var stream = IPCStorage.GetStream(file_ipc_state_filename))
|
||||||
using (var sr = new StreamReader(stream))
|
using (var sr = new StreamReader(stream))
|
||||||
{
|
{
|
||||||
State.Value = (TourneyState)Enum.Parse(typeof(TourneyState), sr.ReadLine());
|
State.Value = (TourneyState)Enum.Parse(typeof(TourneyState), sr.ReadLine());
|
||||||
@ -130,7 +134,7 @@ namespace osu.Game.Tournament.IPC
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var stream = Storage.GetStream(file_ipc_scores_filename))
|
using (var stream = IPCStorage.GetStream(file_ipc_scores_filename))
|
||||||
using (var sr = new StreamReader(stream))
|
using (var sr = new StreamReader(stream))
|
||||||
{
|
{
|
||||||
Score1.Value = int.Parse(sr.ReadLine());
|
Score1.Value = int.Parse(sr.ReadLine());
|
||||||
@ -149,54 +153,106 @@ namespace osu.Game.Tournament.IPC
|
|||||||
Logger.Error(e, "Stable installation could not be found; disabling file based IPC");
|
Logger.Error(e, "Stable installation could not be found; disabling file based IPC");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Storage;
|
return IPCStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Manually sets the path to the directory used for inter-process communication with a cutting-edge install.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to the IPC directory</param>
|
||||||
|
/// <returns>Whether the supplied path was a valid IPC directory.</returns>
|
||||||
|
public bool SetIPCLocation(string path)
|
||||||
|
{
|
||||||
|
if (path == null || !ipcFileExistsInDirectory(path))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var newStorage = initialiseIPCStorage(stableInfo.StablePath = path);
|
||||||
|
if (newStorage == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
stableInfo.SaveChanges();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tries to automatically detect the path to the directory used for inter-process communication
|
||||||
|
/// with a cutting-edge install.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Whether an IPC directory was successfully auto-detected.</returns>
|
||||||
|
public bool AutoDetectIPCLocation() => SetIPCLocation(findStablePath());
|
||||||
|
|
||||||
|
private static bool ipcFileExistsInDirectory(string p) => p != null && File.Exists(Path.Combine(p, "ipc.txt"));
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
private string findStablePath()
|
private string findStablePath()
|
||||||
{
|
{
|
||||||
static bool checkExists(string p) => File.Exists(Path.Combine(p, "ipc.txt"));
|
var stableInstallPath = findFromEnvVar() ??
|
||||||
|
findFromRegistry() ??
|
||||||
|
findFromLocalAppData() ??
|
||||||
|
findFromDotFolder();
|
||||||
|
|
||||||
string stableInstallPath = string.Empty;
|
Logger.Log($"Stable path for tourney usage: {stableInstallPath}");
|
||||||
|
return stableInstallPath;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
private string findFromEnvVar()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
stableInstallPath = Environment.GetEnvironmentVariable("OSU_STABLE_PATH");
|
Logger.Log("Trying to find stable with environment variables");
|
||||||
|
string stableInstallPath = Environment.GetEnvironmentVariable("OSU_STABLE_PATH");
|
||||||
|
|
||||||
if (checkExists(stableInstallPath))
|
if (ipcFileExistsInDirectory(stableInstallPath))
|
||||||
return stableInstallPath;
|
return stableInstallPath;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
return null;
|
||||||
{
|
|
||||||
using (RegistryKey key = Registry.ClassesRoot.OpenSubKey("osu"))
|
|
||||||
stableInstallPath = key?.OpenSubKey(@"shell\open\command")?.GetValue(string.Empty).ToString().Split('"')[1].Replace("osu!.exe", "");
|
|
||||||
|
|
||||||
if (checkExists(stableInstallPath))
|
|
||||||
return stableInstallPath;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"osu!");
|
private string findFromLocalAppData()
|
||||||
if (checkExists(stableInstallPath))
|
{
|
||||||
return stableInstallPath;
|
Logger.Log("Trying to find stable in %LOCALAPPDATA%");
|
||||||
|
string stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"osu!");
|
||||||
|
|
||||||
stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".osu");
|
if (ipcFileExistsInDirectory(stableInstallPath))
|
||||||
if (checkExists(stableInstallPath))
|
|
||||||
return stableInstallPath;
|
return stableInstallPath;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
|
private string findFromDotFolder()
|
||||||
{
|
{
|
||||||
Logger.Log($"Stable path for tourney usage: {stableInstallPath}");
|
Logger.Log("Trying to find stable in dotfolders");
|
||||||
}
|
string stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".osu");
|
||||||
|
|
||||||
|
if (ipcFileExistsInDirectory(stableInstallPath))
|
||||||
|
return stableInstallPath;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string findFromRegistry()
|
||||||
|
{
|
||||||
|
Logger.Log("Trying to find stable in registry");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string stableInstallPath;
|
||||||
|
|
||||||
|
using (RegistryKey key = Registry.ClassesRoot.OpenSubKey("osu"))
|
||||||
|
stableInstallPath = key?.OpenSubKey(@"shell\open\command")?.GetValue(string.Empty).ToString().Split('"')[1].Replace("osu!.exe", "");
|
||||||
|
|
||||||
|
if (ipcFileExistsInDirectory(stableInstallPath))
|
||||||
|
return stableInstallPath;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
62
osu.Game.Tournament/Models/StableInfo.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using osu.Framework.Platform;
|
||||||
|
|
||||||
|
namespace osu.Game.Tournament.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Holds the path to locate the osu! stable cutting-edge installation.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class StableInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Path to the IPC directory used by the stable (cutting-edge) install.
|
||||||
|
/// </summary>
|
||||||
|
public string StablePath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fired whenever stable info is successfully saved to file.
|
||||||
|
/// </summary>
|
||||||
|
public event Action OnStableInfoSaved;
|
||||||
|
|
||||||
|
private const string config_path = "tournament/stable.json";
|
||||||
|
|
||||||
|
private readonly Storage storage;
|
||||||
|
|
||||||
|
public StableInfo(Storage storage)
|
||||||
|
{
|
||||||
|
this.storage = storage;
|
||||||
|
|
||||||
|
if (!storage.Exists(config_path))
|
||||||
|
return;
|
||||||
|
|
||||||
|
using (Stream stream = storage.GetStream(config_path, FileAccess.Read, FileMode.Open))
|
||||||
|
using (var sr = new StreamReader(stream))
|
||||||
|
{
|
||||||
|
JsonConvert.PopulateObject(sr.ReadToEnd(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveChanges()
|
||||||
|
{
|
||||||
|
using (var stream = storage.GetStream(config_path, FileAccess.Write, FileMode.Create))
|
||||||
|
using (var sw = new StreamWriter(stream))
|
||||||
|
{
|
||||||
|
sw.Write(JsonConvert.SerializeObject(this,
|
||||||
|
new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
Formatting = Formatting.Indented,
|
||||||
|
NullValueHandling = NullValueHandling.Ignore,
|
||||||
|
DefaultValueHandling = DefaultValueHandling.Ignore,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
OnStableInfoSaved?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ using osu.Game.Online.API;
|
|||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Tournament.IPC;
|
using osu.Game.Tournament.IPC;
|
||||||
|
using osu.Game.Tournament.Models;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
@ -30,12 +31,18 @@ namespace osu.Game.Tournament.Screens
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private MatchIPCInfo ipc { get; set; }
|
private MatchIPCInfo ipc { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private StableInfo stableInfo { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private RulesetStore rulesets { get; set; }
|
private RulesetStore rulesets { get; set; }
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private TournamentSceneManager sceneManager { get; set; }
|
||||||
|
|
||||||
private Bindable<Size> windowSize;
|
private Bindable<Size> windowSize;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -53,6 +60,7 @@ namespace osu.Game.Tournament.Screens
|
|||||||
};
|
};
|
||||||
|
|
||||||
api.LocalUser.BindValueChanged(_ => Schedule(reload));
|
api.LocalUser.BindValueChanged(_ => Schedule(reload));
|
||||||
|
stableInfo.OnStableInfoSaved += () => Schedule(reload);
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,21 +70,16 @@ namespace osu.Game.Tournament.Screens
|
|||||||
private void reload()
|
private void reload()
|
||||||
{
|
{
|
||||||
var fileBasedIpc = ipc as FileBasedIPC;
|
var fileBasedIpc = ipc as FileBasedIPC;
|
||||||
|
|
||||||
fillFlow.Children = new Drawable[]
|
fillFlow.Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new ActionableInfo
|
new ActionableInfo
|
||||||
{
|
{
|
||||||
Label = "Current IPC source",
|
Label = "Current IPC source",
|
||||||
ButtonText = "Refresh",
|
ButtonText = "Change source",
|
||||||
Action = () =>
|
Action = () => sceneManager?.SetScreen(new StablePathSelectScreen()),
|
||||||
{
|
Value = fileBasedIpc?.IPCStorage?.GetFullPath(string.Empty) ?? "Not found",
|
||||||
fileBasedIpc?.LocateStableStorage();
|
Failing = fileBasedIpc?.IPCStorage == null,
|
||||||
reload();
|
Description = "The osu!stable installation which is currently being used as a data source. If a source is not found, make sure you have created an empty ipc.txt in your stable cutting-edge installation."
|
||||||
},
|
|
||||||
Value = fileBasedIpc?.Storage?.GetFullPath(string.Empty) ?? "Not found",
|
|
||||||
Failing = fileBasedIpc?.Storage == null,
|
|
||||||
Description = "The osu!stable installation which is currently being used as a data source. If a source is not found, make sure you have created an empty ipc.txt in your stable cutting-edge installation, and that it is registered as the default osu! install."
|
|
||||||
},
|
},
|
||||||
new ActionableInfo
|
new ActionableInfo
|
||||||
{
|
{
|
||||||
|
164
osu.Game.Tournament/Screens/StablePathSelectScreen.cs
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.IO;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Logging;
|
||||||
|
using osu.Framework.Platform;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Tournament.IPC;
|
||||||
|
using osu.Game.Tournament.Components;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Tournament.Screens
|
||||||
|
{
|
||||||
|
public class StablePathSelectScreen : TournamentScreen
|
||||||
|
{
|
||||||
|
[Resolved]
|
||||||
|
private GameHost host { get; set; }
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private TournamentSceneManager sceneManager { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private MatchIPCInfo ipc { get; set; }
|
||||||
|
|
||||||
|
private DirectorySelector directorySelector;
|
||||||
|
private DialogOverlay overlay;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader(true)]
|
||||||
|
private void load(Storage storage, OsuColour colours)
|
||||||
|
{
|
||||||
|
var initialStorage = (ipc as FileBasedIPC)?.IPCStorage ?? storage;
|
||||||
|
var initialPath = new DirectoryInfo(initialStorage.GetFullPath(string.Empty)).Parent?.FullName;
|
||||||
|
|
||||||
|
AddRangeInternal(new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Masking = true,
|
||||||
|
CornerRadius = 10,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(0.5f, 0.8f),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Colour = colours.GreySeafoamDark,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
new GridContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
RowDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(),
|
||||||
|
new Dimension(GridSizeMode.Relative, 0.8f),
|
||||||
|
new Dimension(),
|
||||||
|
},
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Text = "Please select a new location",
|
||||||
|
Font = OsuFont.Default.With(size: 40)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
directorySelector = new DirectorySelector(initialPath)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(20),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new TriangleButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Width = 300,
|
||||||
|
Text = "Select stable path",
|
||||||
|
Action = ChangePath
|
||||||
|
},
|
||||||
|
new TriangleButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Width = 300,
|
||||||
|
Text = "Auto detect",
|
||||||
|
Action = AutoDetect
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new BackButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
State = { Value = Visibility.Visible },
|
||||||
|
Action = () => sceneManager?.SetScreen(typeof(SetupScreen))
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void ChangePath()
|
||||||
|
{
|
||||||
|
var target = directorySelector.CurrentDirectory.Value.FullName;
|
||||||
|
var fileBasedIpc = ipc as FileBasedIPC;
|
||||||
|
Logger.Log($"Changing Stable CE location to {target}");
|
||||||
|
|
||||||
|
if (!fileBasedIpc?.SetIPCLocation(target) ?? true)
|
||||||
|
{
|
||||||
|
overlay = new DialogOverlay();
|
||||||
|
overlay.Push(new IPCErrorDialog("This is an invalid IPC Directory", "Select a directory that contains an osu! stable cutting edge installation and make sure it has an empty ipc.txt file in it."));
|
||||||
|
AddInternal(overlay);
|
||||||
|
Logger.Log("Folder is not an osu! stable CE directory");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sceneManager?.SetScreen(typeof(SetupScreen));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void AutoDetect()
|
||||||
|
{
|
||||||
|
var fileBasedIpc = ipc as FileBasedIPC;
|
||||||
|
|
||||||
|
if (!fileBasedIpc?.AutoDetectIPCLocation() ?? true)
|
||||||
|
{
|
||||||
|
overlay = new DialogOverlay();
|
||||||
|
overlay.Push(new IPCErrorDialog("Failed to auto detect", "An osu! stable cutting-edge installation could not be auto detected.\nPlease try and manually point to the directory."));
|
||||||
|
AddInternal(overlay);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sceneManager?.SetScreen(typeof(SetupScreen));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -47,6 +47,8 @@ namespace osu.Game.Tournament
|
|||||||
|
|
||||||
ladder.CurrentMatch.Value = ladder.Matches.FirstOrDefault(p => p.Current.Value);
|
ladder.CurrentMatch.Value = ladder.Matches.FirstOrDefault(p => p.Current.Value);
|
||||||
|
|
||||||
|
dependencies.CacheAs(new StableInfo(storage));
|
||||||
|
|
||||||
dependencies.CacheAs<MatchIPCInfo>(ipc = new FileBasedIPC());
|
dependencies.CacheAs<MatchIPCInfo>(ipc = new FileBasedIPC());
|
||||||
Add(ipc);
|
Add(ipc);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
private readonly SpriteIcon spinner;
|
private readonly SpriteIcon spinner;
|
||||||
|
|
||||||
|
protected override bool StartHidden => true;
|
||||||
|
|
||||||
protected Container MainContents;
|
protected Container MainContents;
|
||||||
|
|
||||||
public const float TRANSITION_DURATION = 500;
|
public const float TRANSITION_DURATION = 500;
|
||||||
|
@ -39,6 +39,8 @@ namespace osu.Game.Input.Bindings
|
|||||||
new KeyBinding(InputKey.Escape, GlobalAction.Back),
|
new KeyBinding(InputKey.Escape, GlobalAction.Back),
|
||||||
new KeyBinding(InputKey.ExtraMouseButton1, GlobalAction.Back),
|
new KeyBinding(InputKey.ExtraMouseButton1, GlobalAction.Back),
|
||||||
|
|
||||||
|
new KeyBinding(new[] { InputKey.Alt, InputKey.Home }, GlobalAction.Home),
|
||||||
|
|
||||||
new KeyBinding(InputKey.Up, GlobalAction.SelectPrevious),
|
new KeyBinding(InputKey.Up, GlobalAction.SelectPrevious),
|
||||||
new KeyBinding(InputKey.Down, GlobalAction.SelectNext),
|
new KeyBinding(InputKey.Down, GlobalAction.SelectNext),
|
||||||
|
|
||||||
@ -152,5 +154,8 @@ namespace osu.Game.Input.Bindings
|
|||||||
|
|
||||||
[Description("Next Selection")]
|
[Description("Next Selection")]
|
||||||
SelectNext,
|
SelectNext,
|
||||||
|
|
||||||
|
[Description("Home")]
|
||||||
|
Home,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
28
osu.Game/Online/API/Requests/GetRoomPlaylistScoresRequest.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.API.Requests
|
||||||
|
{
|
||||||
|
public class GetRoomPlaylistScoresRequest : APIRequest<RoomPlaylistScores>
|
||||||
|
{
|
||||||
|
private readonly int roomId;
|
||||||
|
private readonly int playlistItemId;
|
||||||
|
|
||||||
|
public GetRoomPlaylistScoresRequest(int roomId, int playlistItemId)
|
||||||
|
{
|
||||||
|
this.roomId = roomId;
|
||||||
|
this.playlistItemId = playlistItemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string Target => $@"rooms/{roomId}/playlist/{playlistItemId}/scores";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RoomPlaylistScores
|
||||||
|
{
|
||||||
|
[JsonProperty("scores")]
|
||||||
|
public List<RoomScore> Scores { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ using osu.Game.Scoring;
|
|||||||
|
|
||||||
namespace osu.Game.Online.API.Requests
|
namespace osu.Game.Online.API.Requests
|
||||||
{
|
{
|
||||||
public class SubmitRoomScoreRequest : APIRequest
|
public class SubmitRoomScoreRequest : APIRequest<RoomScore>
|
||||||
{
|
{
|
||||||
private readonly int scoreId;
|
private readonly int scoreId;
|
||||||
private readonly int roomId;
|
private readonly int roomId;
|
||||||
|
75
osu.Game/Online/API/RoomScore.cs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Converters;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.API
|
||||||
|
{
|
||||||
|
public class RoomScore
|
||||||
|
{
|
||||||
|
[JsonProperty("id")]
|
||||||
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("user")]
|
||||||
|
public User User { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("rank")]
|
||||||
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
public ScoreRank Rank { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("total_score")]
|
||||||
|
public long TotalScore { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("accuracy")]
|
||||||
|
public double Accuracy { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("max_combo")]
|
||||||
|
public int MaxCombo { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("mods")]
|
||||||
|
public APIMod[] Mods { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("statistics")]
|
||||||
|
public Dictionary<HitResult, int> Statistics = new Dictionary<HitResult, int>();
|
||||||
|
|
||||||
|
[JsonProperty("passed")]
|
||||||
|
public bool Passed { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("ended_at")]
|
||||||
|
public DateTimeOffset EndedAt { get; set; }
|
||||||
|
|
||||||
|
public ScoreInfo CreateScoreInfo(PlaylistItem playlistItem)
|
||||||
|
{
|
||||||
|
var rulesetInstance = playlistItem.Ruleset.Value.CreateInstance();
|
||||||
|
|
||||||
|
var scoreInfo = new ScoreInfo
|
||||||
|
{
|
||||||
|
OnlineScoreID = ID,
|
||||||
|
TotalScore = TotalScore,
|
||||||
|
MaxCombo = MaxCombo,
|
||||||
|
Beatmap = playlistItem.Beatmap.Value,
|
||||||
|
BeatmapInfoID = playlistItem.BeatmapID,
|
||||||
|
Ruleset = playlistItem.Ruleset.Value,
|
||||||
|
RulesetID = playlistItem.RulesetID,
|
||||||
|
Statistics = Statistics,
|
||||||
|
User = User,
|
||||||
|
Accuracy = Accuracy,
|
||||||
|
Date = EndedAt,
|
||||||
|
Hash = string.Empty, // todo: temporary?
|
||||||
|
Rank = Rank,
|
||||||
|
Mods = Mods?.Select(m => m.ToMod(rulesetInstance)).ToArray() ?? Array.Empty<Mod>()
|
||||||
|
};
|
||||||
|
|
||||||
|
return scoreInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -35,7 +35,6 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Input;
|
using osu.Game.Input;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Screens.Play;
|
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
@ -43,6 +42,8 @@ using osuTK.Graphics;
|
|||||||
using osu.Game.Overlays.Volume;
|
using osu.Game.Overlays.Volume;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
using osu.Game.Updater;
|
using osu.Game.Updater;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
@ -360,7 +361,7 @@ namespace osu.Game
|
|||||||
/// Present a score's replay immediately.
|
/// Present a score's replay immediately.
|
||||||
/// The user should have already requested this interactively.
|
/// The user should have already requested this interactively.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PresentScore(ScoreInfo score)
|
public void PresentScore(ScoreInfo score, ScorePresentType presentType = ScorePresentType.Results)
|
||||||
{
|
{
|
||||||
// The given ScoreInfo may have missing properties if it was retrieved from online data. Re-retrieve it from the database
|
// The given ScoreInfo may have missing properties if it was retrieved from online data. Re-retrieve it from the database
|
||||||
// to ensure all the required data for presenting a replay are present.
|
// to ensure all the required data for presenting a replay are present.
|
||||||
@ -392,9 +393,19 @@ namespace osu.Game
|
|||||||
|
|
||||||
PerformFromScreen(screen =>
|
PerformFromScreen(screen =>
|
||||||
{
|
{
|
||||||
|
Ruleset.Value = databasedScore.ScoreInfo.Ruleset;
|
||||||
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(databasedBeatmap);
|
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(databasedBeatmap);
|
||||||
|
|
||||||
|
switch (presentType)
|
||||||
|
{
|
||||||
|
case ScorePresentType.Gameplay:
|
||||||
screen.Push(new ReplayPlayerLoader(databasedScore));
|
screen.Push(new ReplayPlayerLoader(databasedScore));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScorePresentType.Results:
|
||||||
|
screen.Push(new SoloResultsScreen(databasedScore.ScoreInfo));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}, validScreens: new[] { typeof(PlaySongSelect) });
|
}, validScreens: new[] { typeof(PlaySongSelect) });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,6 +622,9 @@ namespace osu.Game
|
|||||||
|
|
||||||
loadComponentSingleFile(screenshotManager, Add);
|
loadComponentSingleFile(screenshotManager, Add);
|
||||||
|
|
||||||
|
// dependency on notification overlay, dependent by settings overlay
|
||||||
|
loadComponentSingleFile(CreateUpdateManager(), Add, true);
|
||||||
|
|
||||||
// overlay elements
|
// overlay elements
|
||||||
loadComponentSingleFile(beatmapListing = new BeatmapListingOverlay(), overlayContent.Add, true);
|
loadComponentSingleFile(beatmapListing = new BeatmapListingOverlay(), overlayContent.Add, true);
|
||||||
loadComponentSingleFile(dashboard = new DashboardOverlay(), overlayContent.Add, true);
|
loadComponentSingleFile(dashboard = new DashboardOverlay(), overlayContent.Add, true);
|
||||||
@ -643,7 +657,6 @@ namespace osu.Game
|
|||||||
chatOverlay.State.ValueChanged += state => channelManager.HighPollRate.Value = state.NewValue == Visibility.Visible;
|
chatOverlay.State.ValueChanged += state => channelManager.HighPollRate.Value = state.NewValue == Visibility.Visible;
|
||||||
|
|
||||||
Add(externalLinkOpener = new ExternalLinkOpener());
|
Add(externalLinkOpener = new ExternalLinkOpener());
|
||||||
Add(CreateUpdateManager()); // dependency on notification overlay
|
|
||||||
|
|
||||||
// side overlays which cancel each other.
|
// side overlays which cancel each other.
|
||||||
var singleDisplaySideOverlays = new OverlayContainer[] { Settings, notifications };
|
var singleDisplaySideOverlays = new OverlayContainer[] { Settings, notifications };
|
||||||
@ -1000,4 +1013,10 @@ namespace osu.Game
|
|||||||
Exit();
|
Exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ScorePresentType
|
||||||
|
{
|
||||||
|
Results,
|
||||||
|
Gameplay
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,10 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
|
|
||||||
[Description("Hip Hop")]
|
[Description("Hip Hop")]
|
||||||
HipHop = 9,
|
HipHop = 9,
|
||||||
Electronic = 10
|
Electronic = 10,
|
||||||
|
Metal = 11,
|
||||||
|
Classical = 12,
|
||||||
|
Folk = 13,
|
||||||
|
Jazz = 14
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
[Order(0)]
|
[Order(0)]
|
||||||
Any,
|
Any,
|
||||||
|
|
||||||
[Order(11)]
|
[Order(14)]
|
||||||
Other,
|
Unspecified,
|
||||||
|
|
||||||
[Order(1)]
|
[Order(1)]
|
||||||
English,
|
English,
|
||||||
@ -23,7 +23,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
[Order(2)]
|
[Order(2)]
|
||||||
Chinese,
|
Chinese,
|
||||||
|
|
||||||
[Order(10)]
|
[Order(12)]
|
||||||
Instrumental,
|
Instrumental,
|
||||||
|
|
||||||
[Order(7)]
|
[Order(7)]
|
||||||
@ -42,6 +42,15 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
Spanish,
|
Spanish,
|
||||||
|
|
||||||
[Order(5)]
|
[Order(5)]
|
||||||
Italian
|
Italian,
|
||||||
|
|
||||||
|
[Order(10)]
|
||||||
|
Russian,
|
||||||
|
|
||||||
|
[Order(11)]
|
||||||
|
Polish,
|
||||||
|
|
||||||
|
[Order(13)]
|
||||||
|
Other
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,19 +78,10 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
/// <param name="channel">The channel that is going to be removed.</param>
|
/// <param name="channel">The channel that is going to be removed.</param>
|
||||||
public void RemoveChannel(Channel channel)
|
public void RemoveChannel(Channel channel)
|
||||||
{
|
{
|
||||||
if (Current.Value == channel)
|
|
||||||
{
|
|
||||||
var allChannels = TabContainer.AllTabItems.Select(tab => tab.Value).ToList();
|
|
||||||
var isNextTabSelector = allChannels[allChannels.IndexOf(channel) + 1] == selectorTab.Value;
|
|
||||||
|
|
||||||
// selectorTab is not switchable, so we have to explicitly select it if it's the only tab left
|
|
||||||
if (isNextTabSelector && allChannels.Count == 2)
|
|
||||||
SelectTab(selectorTab);
|
|
||||||
else
|
|
||||||
SwitchTab(isNextTabSelector ? -1 : 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
RemoveItem(channel);
|
RemoveItem(channel);
|
||||||
|
|
||||||
|
if (SelectedTab == null)
|
||||||
|
SelectTab(selectorTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SelectTab(TabItem<Channel> tab)
|
protected override void SelectTab(TabItem<Channel> tab)
|
||||||
|
@ -12,6 +12,7 @@ using osu.Game.Online.API.Requests.Responses;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Comments
|
namespace osu.Game.Overlays.Comments
|
||||||
@ -30,6 +31,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
private IAPIProvider api { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
private GetCommentsRequest request;
|
private GetCommentsRequest request;
|
||||||
|
private ScheduledDelegate scheduledCommentsLoad;
|
||||||
private CancellationTokenSource loadCancellation;
|
private CancellationTokenSource loadCancellation;
|
||||||
private int currentPage;
|
private int currentPage;
|
||||||
|
|
||||||
@ -152,8 +154,9 @@ namespace osu.Game.Overlays.Comments
|
|||||||
|
|
||||||
request?.Cancel();
|
request?.Cancel();
|
||||||
loadCancellation?.Cancel();
|
loadCancellation?.Cancel();
|
||||||
|
scheduledCommentsLoad?.Cancel();
|
||||||
request = new GetCommentsRequest(id.Value, type.Value, Sort.Value, currentPage++, 0);
|
request = new GetCommentsRequest(id.Value, type.Value, Sort.Value, currentPage++, 0);
|
||||||
request.Success += res => Schedule(() => onSuccess(res));
|
request.Success += res => scheduledCommentsLoad = Schedule(() => onSuccess(res));
|
||||||
api.PerformAsync(request);
|
api.PerformAsync(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,26 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Threading.Tasks;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Overlays.Settings.Sections.Maintenance;
|
using osu.Game.Overlays.Settings.Sections.Maintenance;
|
||||||
|
using osu.Game.Updater;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Settings.Sections.General
|
namespace osu.Game.Overlays.Settings.Sections.General
|
||||||
{
|
{
|
||||||
public class UpdateSettings : SettingsSubsection
|
public class UpdateSettings : SettingsSubsection
|
||||||
{
|
{
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private UpdateManager updateManager { get; set; }
|
||||||
|
|
||||||
protected override string Header => "Updates";
|
protected override string Header => "Updates";
|
||||||
|
|
||||||
|
private SettingsButton checkForUpdatesButton;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(Storage storage, OsuConfigManager config, OsuGame game)
|
private void load(Storage storage, OsuConfigManager config, OsuGame game)
|
||||||
{
|
{
|
||||||
@ -23,6 +30,19 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
Bindable = config.GetBindable<ReleaseStream>(OsuSetting.ReleaseStream),
|
Bindable = config.GetBindable<ReleaseStream>(OsuSetting.ReleaseStream),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (updateManager?.CanCheckForUpdate == true)
|
||||||
|
{
|
||||||
|
Add(checkForUpdatesButton = new SettingsButton
|
||||||
|
{
|
||||||
|
Text = "Check for updates",
|
||||||
|
Action = () =>
|
||||||
|
{
|
||||||
|
checkForUpdatesButton.Enabled.Value = false;
|
||||||
|
Task.Run(updateManager.CheckForUpdateAsync).ContinueWith(t => Schedule(() => checkForUpdatesButton.Enabled.Value = true));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (RuntimeInfo.IsDesktop)
|
if (RuntimeInfo.IsDesktop)
|
||||||
{
|
{
|
||||||
Add(new SettingsButton
|
Add(new SettingsButton
|
||||||
|
@ -62,6 +62,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
protected ConstrainedIconContainer IconContainer;
|
protected ConstrainedIconContainer IconContainer;
|
||||||
protected SpriteText DrawableText;
|
protected SpriteText DrawableText;
|
||||||
protected Box HoverBackground;
|
protected Box HoverBackground;
|
||||||
|
private readonly Box flashBackground;
|
||||||
private readonly FillFlowContainer tooltipContainer;
|
private readonly FillFlowContainer tooltipContainer;
|
||||||
private readonly SpriteText tooltip1;
|
private readonly SpriteText tooltip1;
|
||||||
private readonly SpriteText tooltip2;
|
private readonly SpriteText tooltip2;
|
||||||
@ -82,6 +83,13 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
Blending = BlendingParameters.Additive,
|
Blending = BlendingParameters.Additive,
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
},
|
},
|
||||||
|
flashBackground = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0,
|
||||||
|
Colour = Color4.White.Opacity(100),
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
},
|
||||||
Flow = new FillFlowContainer
|
Flow = new FillFlowContainer
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
@ -139,7 +147,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
HoverBackground.FlashColour(Color4.White.Opacity(100), 500, Easing.OutQuint);
|
flashBackground.FadeOutFromOne(800, Easing.OutQuint);
|
||||||
tooltipContainer.FadeOut(100);
|
tooltipContainer.FadeOut(100);
|
||||||
return base.OnClick(e);
|
return base.OnClick(e);
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Toolbar
|
namespace osu.Game.Overlays.Toolbar
|
||||||
{
|
{
|
||||||
public class ToolbarHomeButton : ToolbarButton
|
public class ToolbarHomeButton : ToolbarButton, IKeyBindingHandler<GlobalAction>
|
||||||
{
|
{
|
||||||
public ToolbarHomeButton()
|
public ToolbarHomeButton()
|
||||||
{
|
{
|
||||||
@ -13,5 +15,20 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
TooltipMain = "Home";
|
TooltipMain = "Home";
|
||||||
TooltipSub = "Return to the main menu";
|
TooltipSub = "Return to the main menu";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(GlobalAction action)
|
||||||
|
{
|
||||||
|
if (action == GlobalAction.Home)
|
||||||
|
{
|
||||||
|
Click();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnReleased(GlobalAction action)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,9 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
[SettingSource("Final rate", "The final speed to ramp to")]
|
[SettingSource("Final rate", "The final speed to ramp to")]
|
||||||
public abstract BindableNumber<double> FinalRate { get; }
|
public abstract BindableNumber<double> FinalRate { get; }
|
||||||
|
|
||||||
|
[SettingSource("Adjust pitch", "Should pitch be adjusted with speed")]
|
||||||
|
public abstract BindableBool AdjustPitch { get; }
|
||||||
|
|
||||||
public override string SettingDescription => $"{InitialRate.Value:N2}x to {FinalRate.Value:N2}x";
|
public override string SettingDescription => $"{InitialRate.Value:N2}x to {FinalRate.Value:N2}x";
|
||||||
|
|
||||||
private double finalRateTime;
|
private double finalRateTime;
|
||||||
@ -43,15 +46,16 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
protected ModTimeRamp()
|
protected ModTimeRamp()
|
||||||
{
|
{
|
||||||
// for preview purpose at song select. eventually we'll want to be able to update every frame.
|
// for preview purpose at song select. eventually we'll want to be able to update every frame.
|
||||||
FinalRate.BindValueChanged(val => applyAdjustment(1), true);
|
FinalRate.BindValueChanged(val => applyRateAdjustment(1), true);
|
||||||
|
AdjustPitch.BindValueChanged(applyPitchAdjustment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ApplyToTrack(Track track)
|
public void ApplyToTrack(Track track)
|
||||||
{
|
{
|
||||||
this.track = track;
|
this.track = track;
|
||||||
track.AddAdjustment(AdjustableProperty.Frequency, SpeedChange);
|
|
||||||
|
|
||||||
FinalRate.TriggerChange();
|
FinalRate.TriggerChange();
|
||||||
|
AdjustPitch.TriggerChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ApplyToBeatmap(IBeatmap beatmap)
|
public virtual void ApplyToBeatmap(IBeatmap beatmap)
|
||||||
@ -66,14 +70,25 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
|
|
||||||
public virtual void Update(Playfield playfield)
|
public virtual void Update(Playfield playfield)
|
||||||
{
|
{
|
||||||
applyAdjustment((track.CurrentTime - beginRampTime) / finalRateTime);
|
applyRateAdjustment((track.CurrentTime - beginRampTime) / finalRateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adjust the rate along the specified ramp
|
/// Adjust the rate along the specified ramp
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="amount">The amount of adjustment to apply (from 0..1).</param>
|
/// <param name="amount">The amount of adjustment to apply (from 0..1).</param>
|
||||||
private void applyAdjustment(double amount) =>
|
private void applyRateAdjustment(double amount) =>
|
||||||
SpeedChange.Value = InitialRate.Value + (FinalRate.Value - InitialRate.Value) * Math.Clamp(amount, 0, 1);
|
SpeedChange.Value = InitialRate.Value + (FinalRate.Value - InitialRate.Value) * Math.Clamp(amount, 0, 1);
|
||||||
|
|
||||||
|
private void applyPitchAdjustment(ValueChangedEvent<bool> adjustPitchSetting)
|
||||||
|
{
|
||||||
|
// remove existing old adjustment
|
||||||
|
track.RemoveAdjustment(adjustmentForPitchSetting(adjustPitchSetting.OldValue), SpeedChange);
|
||||||
|
|
||||||
|
track.AddAdjustment(adjustmentForPitchSetting(adjustPitchSetting.NewValue), SpeedChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AdjustableProperty adjustmentForPitchSetting(bool adjustPitchSettingValue)
|
||||||
|
=> adjustPitchSettingValue ? AdjustableProperty.Frequency : AdjustableProperty.Tempo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|