mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 14:42:56 +08:00
Merge branch 'master' into storyboard-sample-rate
This commit is contained in:
commit
1eaa25e75e
@ -1,8 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="CatchRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset">
|
||||
<configuration default="false" name="CatchRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset" activateToolWindowBeforeRun="false">
|
||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Catch.Tests/bin/Debug/netcoreapp3.1/osu.Game.Rulesets.Catch.Tests.dll" />
|
||||
<option name="PROGRAM_PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Catch.Tests" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Catch.Tests/bin/Debug/netcoreapp3.1" />
|
||||
<option name="PASS_PARENT_ENVS" value="1" />
|
||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||
<option name="USE_MONO" value="0" />
|
||||
@ -15,7 +15,7 @@
|
||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.1" />
|
||||
<browser url="http://localhost:5000" />
|
||||
<method v="2">
|
||||
<option name="Build" enabled="true" />
|
||||
<option name="Build" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -1,8 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="ManiaRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset">
|
||||
<configuration default="false" name="ManiaRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset" activateToolWindowBeforeRun="false">
|
||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Mania.Tests/bin/Debug/netcoreapp3.1/osu.Game.Rulesets.Mania.Tests.dll" />
|
||||
<option name="PROGRAM_PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Mania.Tests" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Mania.Tests/bin/Debug/netcoreapp3.1" />
|
||||
<option name="PASS_PARENT_ENVS" value="1" />
|
||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||
<option name="USE_MONO" value="0" />
|
||||
@ -15,7 +15,7 @@
|
||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.1" />
|
||||
<browser url="http://localhost:5000" />
|
||||
<method v="2">
|
||||
<option name="Build" enabled="true" />
|
||||
<option name="Build" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -1,8 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="OsuRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset">
|
||||
<configuration default="false" name="OsuRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset" activateToolWindowBeforeRun="false">
|
||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Osu.Tests/bin/Debug/netcoreapp3.1/osu.Game.Rulesets.Osu.Tests.dll" />
|
||||
<option name="PROGRAM_PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Osu.Tests" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Osu.Tests/bin/Debug/netcoreapp3.1" />
|
||||
<option name="PASS_PARENT_ENVS" value="1" />
|
||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||
<option name="USE_MONO" value="0" />
|
||||
@ -15,7 +15,7 @@
|
||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.1" />
|
||||
<browser url="http://localhost:5000" />
|
||||
<method v="2">
|
||||
<option name="Build" enabled="true" />
|
||||
<option name="Build" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -1,8 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="TaikoRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset">
|
||||
<configuration default="false" name="TaikoRuleset (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Ruleset" activateToolWindowBeforeRun="false">
|
||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Taiko.Tests/bin/Debug/netcoreapp3.1/osu.Game.Rulesets.Taiko.Tests.dll" />
|
||||
<option name="PROGRAM_PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Taiko.Tests" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Taiko.Tests/bin/Debug/netcoreapp3.1" />
|
||||
<option name="PASS_PARENT_ENVS" value="1" />
|
||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||
<option name="USE_MONO" value="0" />
|
||||
@ -15,7 +15,7 @@
|
||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.1" />
|
||||
<browser url="http://localhost:5000" />
|
||||
<method v="2">
|
||||
<option name="Build" enabled="true" />
|
||||
<option name="Build" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -1,8 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Tournament" type="DotNetProject" factoryName=".NET Project" folderName="Tournament">
|
||||
<configuration default="false" name="Tournament" type="DotNetProject" factoryName=".NET Project" folderName="Tournament" activateToolWindowBeforeRun="false">
|
||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Desktop/bin/Debug/netcoreapp3.1/osu!.dll" />
|
||||
<option name="PROGRAM_PARAMETERS" value="--tournament" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Desktop" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Desktop/bin/Debug/netcoreapp3.1" />
|
||||
<option name="PASS_PARENT_ENVS" value="1" />
|
||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||
<option name="USE_MONO" value="0" />
|
||||
@ -14,7 +14,7 @@
|
||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.1" />
|
||||
<method v="2">
|
||||
<option name="Build" enabled="true" />
|
||||
<option name="Build" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -1,8 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Tournament (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Tournament">
|
||||
<configuration default="false" name="Tournament (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="Tournament" activateToolWindowBeforeRun="false">
|
||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Tournament.Tests/bin/Debug/netcoreapp3.1/osu.Game.Tournament.Tests.dll" />
|
||||
<option name="PROGRAM_PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Tournament.Tests" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Tournament.Tests/bin/Debug/netcoreapp3.1" />
|
||||
<option name="PASS_PARENT_ENVS" value="1" />
|
||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||
<option name="USE_MONO" value="0" />
|
||||
@ -15,7 +15,7 @@
|
||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.1" />
|
||||
<browser url="http://localhost:5000" />
|
||||
<method v="2">
|
||||
<option name="Build" enabled="true" />
|
||||
<option name="Build" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -1,8 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="osu!" type="DotNetProject" factoryName=".NET Project" folderName="osu!">
|
||||
<configuration default="false" name="osu!" type="DotNetProject" factoryName=".NET Project" folderName="osu!" activateToolWindowBeforeRun="false">
|
||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Desktop/bin/Debug/netcoreapp3.1/osu!.dll" />
|
||||
<option name="PROGRAM_PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Desktop" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Desktop/bin/Debug/netcoreapp3.1" />
|
||||
<option name="PASS_PARENT_ENVS" value="1" />
|
||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||
<option name="USE_MONO" value="0" />
|
||||
@ -14,7 +14,7 @@
|
||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.1" />
|
||||
<method v="2">
|
||||
<option name="Build" enabled="true" />
|
||||
<option name="Build" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -1,8 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="osu! SDL" type="DotNetProject" factoryName=".NET Project" folderName="osu!">
|
||||
<configuration default="false" name="osu! SDL" type="DotNetProject" factoryName=".NET Project" folderName="osu!" activateToolWindowBeforeRun="false">
|
||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Desktop/bin/Debug/netcoreapp3.1/osu!.dll" />
|
||||
<option name="PROGRAM_PARAMETERS" value="--sdl" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Desktop" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Desktop/bin/Debug/netcoreapp3.1" />
|
||||
<option name="PASS_PARENT_ENVS" value="1" />
|
||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||
<option name="USE_MONO" value="0" />
|
||||
@ -12,9 +12,9 @@
|
||||
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.0" />
|
||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.1" />
|
||||
<method v="2">
|
||||
<option name="Build" enabled="true" />
|
||||
<option name="Build" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -1,8 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="osu! (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="osu!">
|
||||
<configuration default="false" name="osu! (Tests)" type="DotNetProject" factoryName=".NET Project" folderName="osu!" activateToolWindowBeforeRun="false">
|
||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Tests/bin/Debug/netcoreapp3.1/osu.Game.Tests.dll" />
|
||||
<option name="PROGRAM_PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Tests" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Tests/bin/Debug/netcoreapp3.1" />
|
||||
<option name="PASS_PARENT_ENVS" value="1" />
|
||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||
<option name="USE_MONO" value="0" />
|
||||
@ -14,7 +14,7 @@
|
||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.1" />
|
||||
<method v="2">
|
||||
<option name="Build" enabled="true" />
|
||||
<option name="Build" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -51,7 +51,7 @@
|
||||
<Reference Include="Java.Interop" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.602.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.609.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.622.1" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.623.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using Android.App;
|
||||
using Android.OS;
|
||||
using osu.Game;
|
||||
using osu.Game.Updater;
|
||||
|
||||
@ -18,9 +19,32 @@ namespace osu.Android
|
||||
|
||||
try
|
||||
{
|
||||
// todo: needs checking before play store redeploy.
|
||||
string versionName = packageInfo.VersionName;
|
||||
// undo play store version garbling
|
||||
// We store the osu! build number in the "VersionCode" field to better support google play releases.
|
||||
// If we were to use the main build number, it would require a new submission each time (similar to TestFlight).
|
||||
// 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)));
|
||||
}
|
||||
catch
|
||||
@ -33,4 +57,4 @@ namespace osu.Android
|
||||
|
||||
protected override UpdateManager CreateUpdateManager() => new SimpleUpdateManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,8 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
{
|
||||
var store = new NamespacedResourceStore<byte[]>(new DllResourceStore(GetType().Assembly), "Resources/special-skin");
|
||||
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, 74, 35, 255), skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDashAfterImage)?.Value);
|
||||
|
@ -2,26 +2,21 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Humanizer;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Skinning
|
||||
{
|
||||
public class CatchLegacySkinTransformer : ISkin
|
||||
public class CatchLegacySkinTransformer : LegacySkinTransformer
|
||||
{
|
||||
private readonly ISkin source;
|
||||
|
||||
public CatchLegacySkinTransformer(ISkin source)
|
||||
public CatchLegacySkinTransformer(ISkinSource source)
|
||||
: base(source)
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public Drawable GetDrawableComponent(ISkinComponent component)
|
||||
public override Drawable GetDrawableComponent(ISkinComponent component)
|
||||
{
|
||||
if (!(component is CatchSkinComponent catchSkinComponent))
|
||||
return null;
|
||||
@ -61,19 +56,15 @@ namespace osu.Game.Rulesets.Catch.Skinning
|
||||
return null;
|
||||
}
|
||||
|
||||
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
|
||||
|
||||
public SampleChannel GetSample(ISampleInfo sample) => source.GetSample(sample);
|
||||
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
||||
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
||||
{
|
||||
switch (lookup)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,6 @@ namespace osu.Game.Rulesets.Mania.Judgements
|
||||
{
|
||||
public class HoldNoteTickJudgement : ManiaJudgement
|
||||
{
|
||||
public override bool AffectsCombo => false;
|
||||
|
||||
protected override int NumericResultFor(HitResult result) => 20;
|
||||
|
||||
protected override double HealthIncreaseFor(HitResult result)
|
||||
|
@ -25,8 +25,10 @@ namespace osu.Game.Rulesets.Mania.Judgements
|
||||
return 200;
|
||||
|
||||
case HitResult.Great:
|
||||
case HitResult.Perfect:
|
||||
return 300;
|
||||
|
||||
case HitResult.Perfect:
|
||||
return 320;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ namespace osu.Game.Rulesets.Mania
|
||||
|
||||
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 PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
[BackgroundDependencyLoader]
|
||||
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";
|
||||
|
||||
sprite = skin.GetAnimation(imageName, true, true).With(d =>
|
||||
|
@ -32,28 +32,28 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
[BackgroundDependencyLoader]
|
||||
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";
|
||||
|
||||
float leftLineWidth = GetManiaSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.LeftLineWidth)
|
||||
float leftLineWidth = GetColumnSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.LeftLineWidth)
|
||||
?.Value ?? 1;
|
||||
float rightLineWidth = GetManiaSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.RightLineWidth)
|
||||
float rightLineWidth = GetColumnSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.RightLineWidth)
|
||||
?.Value ?? 1;
|
||||
|
||||
bool hasLeftLine = leftLineWidth > 0;
|
||||
bool hasRightLine = rightLineWidth > 0 && skin.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value >= 2.4m
|
||||
|| isLastColumn;
|
||||
|
||||
float lightPosition = GetManiaSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.LightPosition)?.Value
|
||||
float lightPosition = GetColumnSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.LightPosition)?.Value
|
||||
?? 0;
|
||||
|
||||
Color4 lineColour = GetManiaSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.ColumnLineColour)?.Value
|
||||
Color4 lineColour = GetColumnSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.ColumnLineColour)?.Value
|
||||
?? Color4.White;
|
||||
|
||||
Color4 backgroundColour = GetManiaSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.ColumnBackgroundColour)?.Value
|
||||
Color4 backgroundColour = GetColumnSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.ColumnBackgroundColour)?.Value
|
||||
?? Color4.Black;
|
||||
|
||||
Color4 lightColour = GetManiaSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.ColumnLightColour)?.Value
|
||||
Color4 lightColour = GetColumnSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.ColumnLightColour)?.Value
|
||||
?? Color4.White;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
|
@ -26,10 +26,10 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
||||
{
|
||||
string imageName = GetManiaSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.ExplosionImage)?.Value
|
||||
string imageName = GetColumnSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.ExplosionImage)?.Value
|
||||
?? "lightingN";
|
||||
|
||||
float explosionScale = GetManiaSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.ExplosionScale)?.Value
|
||||
float explosionScale = GetColumnSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.ExplosionScale)?.Value
|
||||
?? 1;
|
||||
|
||||
// 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
|
||||
{
|
||||
public class LegacyHitTarget : LegacyManiaElement
|
||||
public class LegacyHitTarget : CompositeDrawable
|
||||
{
|
||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||
|
||||
@ -28,13 +28,13 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
[BackgroundDependencyLoader]
|
||||
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";
|
||||
|
||||
bool showJudgementLine = GetManiaSkinConfig<bool>(skin, LegacyManiaSkinConfigurationLookups.ShowJudgementLine)?.Value
|
||||
bool showJudgementLine = skin.GetManiaSkinConfig<bool>(LegacyManiaSkinConfigurationLookups.ShowJudgementLine)?.Value
|
||||
?? true;
|
||||
|
||||
Color4 lineColour = GetManiaSkinConfig<Color4>(skin, LegacyManiaSkinConfigurationLookups.JudgementLineColour)?.Value
|
||||
Color4 lineColour = skin.GetManiaSkinConfig<Color4>(LegacyManiaSkinConfigurationLookups.JudgementLineColour)?.Value
|
||||
?? Color4.White;
|
||||
|
||||
InternalChild = directionContainer = new Container
|
||||
|
@ -33,10 +33,10 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
[BackgroundDependencyLoader]
|
||||
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}";
|
||||
|
||||
string downImage = GetManiaSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.KeyImageDown)?.Value
|
||||
string downImage = GetColumnSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.KeyImageDown)?.Value
|
||||
?? $"mania-key{FallbackColumnIndex}D";
|
||||
|
||||
InternalChild = directionContainer = new Container
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
/// <summary>
|
||||
/// A <see cref="CompositeDrawable"/> which is placed somewhere within a <see cref="Column"/>.
|
||||
/// </summary>
|
||||
public class LegacyManiaColumnElement : LegacyManiaElement
|
||||
public class LegacyManiaColumnElement : CompositeDrawable
|
||||
{
|
||||
[Resolved]
|
||||
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)
|
||||
=> base.GetManiaSkinConfig<T>(skin, lookup, index ?? Column.Index);
|
||||
protected IBindable<T> GetColumnSkinConfig<T>(ISkin skin, LegacyManiaSkinConfigurationLookups lookup)
|
||||
=> skin.GetManiaSkinConfig<T>(lookup, Column.Index);
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
break;
|
||||
}
|
||||
|
||||
string noteImage = GetManiaSkinConfig<string>(skin, lookup)?.Value
|
||||
string noteImage = GetColumnSkinConfig<string>(skin, lookup)?.Value
|
||||
?? $"mania-note{FallbackColumnIndex}{suffix}";
|
||||
|
||||
return skin.GetTexture(noteImage);
|
||||
|
@ -3,13 +3,14 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Skinning
|
||||
{
|
||||
public class LegacyStageBackground : LegacyManiaElement
|
||||
public class LegacyStageBackground : CompositeDrawable
|
||||
{
|
||||
private Drawable leftSprite;
|
||||
private Drawable rightSprite;
|
||||
@ -22,10 +23,10 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ISkinSource skin)
|
||||
{
|
||||
string leftImage = GetManiaSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.LeftStageImage)?.Value
|
||||
string leftImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.LeftStageImage)?.Value
|
||||
?? "mania-stage-left";
|
||||
|
||||
string rightImage = GetManiaSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.RightStageImage)?.Value
|
||||
string rightImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.RightStageImage)?.Value
|
||||
?? "mania-stage-right";
|
||||
|
||||
InternalChildren = new[]
|
||||
|
@ -4,13 +4,14 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Skinning
|
||||
{
|
||||
public class LegacyStageForeground : LegacyManiaElement
|
||||
public class LegacyStageForeground : CompositeDrawable
|
||||
{
|
||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||
|
||||
@ -24,7 +25,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
[BackgroundDependencyLoader]
|
||||
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";
|
||||
|
||||
sprite = skin.GetAnimation(bottomImage, true, true)?.With(d =>
|
||||
|
@ -3,11 +3,8 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Skinning;
|
||||
@ -15,9 +12,8 @@ using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Skinning
|
||||
{
|
||||
public class ManiaLegacySkinTransformer : ISkin
|
||||
public class ManiaLegacySkinTransformer : LegacySkinTransformer
|
||||
{
|
||||
private readonly ISkin source;
|
||||
private readonly ManiaBeatmap beatmap;
|
||||
|
||||
/// <summary>
|
||||
@ -59,24 +55,23 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
private Lazy<bool> hasKeyTexture;
|
||||
|
||||
public ManiaLegacySkinTransformer(ISkinSource source, IBeatmap beatmap)
|
||||
: base(source)
|
||||
{
|
||||
this.source = source;
|
||||
this.beatmap = (ManiaBeatmap)beatmap;
|
||||
|
||||
source.SourceChanged += sourceChanged;
|
||||
Source.SourceChanged += sourceChanged;
|
||||
sourceChanged();
|
||||
}
|
||||
|
||||
private void sourceChanged()
|
||||
{
|
||||
isLegacySkin = new Lazy<bool>(() => source.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version) != null);
|
||||
hasKeyTexture = new Lazy<bool>(() => source.GetAnimation(
|
||||
GetConfig<ManiaSkinConfigurationLookup, string>(
|
||||
new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.KeyImage, 0))?.Value
|
||||
isLegacySkin = new Lazy<bool>(() => Source.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version) != null);
|
||||
hasKeyTexture = new Lazy<bool>(() => Source.GetAnimation(
|
||||
this.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.KeyImage, 0)?.Value
|
||||
?? "mania-key1", true, true) != null);
|
||||
}
|
||||
|
||||
public Drawable GetDrawableComponent(ISkinComponent component)
|
||||
public override Drawable GetDrawableComponent(ISkinComponent component)
|
||||
{
|
||||
switch (component)
|
||||
{
|
||||
@ -128,23 +123,18 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
|
||||
private Drawable getResult(HitResult result)
|
||||
{
|
||||
string filename = GetConfig<ManiaSkinConfigurationLookup, string>(
|
||||
new ManiaSkinConfigurationLookup(hitresult_mapping[result])
|
||||
)?.Value ?? default_hitresult_skin_filenames[result];
|
||||
string filename = this.GetManiaSkinConfig<string>(hitresult_mapping[result])?.Value
|
||||
?? default_hitresult_skin_filenames[result];
|
||||
|
||||
return this.GetAnimation(filename, true, true);
|
||||
}
|
||||
|
||||
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
|
||||
|
||||
public SampleChannel GetSample(ISampleInfo sample) => source.GetSample(sample);
|
||||
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
||||
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
||||
{
|
||||
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.
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Skinning
|
||||
{
|
||||
/// <summary>
|
||||
/// A mania legacy skin element.
|
||||
/// </summary>
|
||||
public class LegacyManiaElement : CompositeDrawable
|
||||
public static class ManiaSkinConfigExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 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="lookup">The value to retrieve.</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>(
|
||||
new ManiaSkinConfigurationLookup(lookup, index));
|
||||
}
|
@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
if (!drawableRepeat.IsHit)
|
||||
Child.ScaleTo(1.3f).ScaleTo(1f, timingPoint.BeatLength, Easing.Out);
|
||||
|
@ -2,20 +2,15 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Skinning
|
||||
{
|
||||
public class OsuLegacySkinTransformer : ISkin
|
||||
public class OsuLegacySkinTransformer : LegacySkinTransformer
|
||||
{
|
||||
private readonly ISkin source;
|
||||
|
||||
private Lazy<bool> hasHitCircle;
|
||||
|
||||
/// <summary>
|
||||
@ -26,19 +21,18 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
public const float LEGACY_CIRCLE_RADIUS = 64 - 5;
|
||||
|
||||
public OsuLegacySkinTransformer(ISkinSource source)
|
||||
: base(source)
|
||||
{
|
||||
this.source = source;
|
||||
|
||||
source.SourceChanged += sourceChanged;
|
||||
Source.SourceChanged += sourceChanged;
|
||||
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))
|
||||
return null;
|
||||
@ -85,13 +79,13 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
return null;
|
||||
|
||||
case OsuSkinComponents.Cursor:
|
||||
if (source.GetTexture("cursor") != null)
|
||||
if (Source.GetTexture("cursor") != null)
|
||||
return new LegacyCursor();
|
||||
|
||||
return null;
|
||||
|
||||
case OsuSkinComponents.CursorTrail:
|
||||
if (source.GetTexture("cursortrail") != null)
|
||||
if (Source.GetTexture("cursortrail") != null)
|
||||
return new LegacyCursorTrail();
|
||||
|
||||
return null;
|
||||
@ -102,7 +96,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
|
||||
return !hasFont(font)
|
||||
? null
|
||||
: new LegacySpriteText(source, font)
|
||||
: new LegacySpriteText(Source, font)
|
||||
{
|
||||
// stable applies a blanket 0.8x scale to hitcircle fonts
|
||||
Scale = new Vector2(0.8f),
|
||||
@ -113,16 +107,12 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
return null;
|
||||
}
|
||||
|
||||
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
|
||||
|
||||
public SampleChannel GetSample(ISampleInfo sample) => source.GetSample(sample);
|
||||
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
||||
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
||||
{
|
||||
switch (lookup)
|
||||
{
|
||||
case OsuSkinColour colour:
|
||||
return source.GetConfig<SkinCustomColourLookup, TValue>(new SkinCustomColourLookup(colour));
|
||||
return Source.GetConfig<SkinCustomColourLookup, TValue>(new SkinCustomColourLookup(colour));
|
||||
|
||||
case OsuSkinConfiguration osuLookup:
|
||||
switch (osuLookup)
|
||||
@ -136,16 +126,16 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
case OsuSkinConfiguration.HitCircleOverlayAboveNumber:
|
||||
// See https://osu.ppy.sh/help/wiki/Skinning/skin.ini#%5Bgeneral%5D
|
||||
// HitCircleOverlayAboveNumer (with typo) should still be supported for now.
|
||||
return source.GetConfig<OsuSkinConfiguration, TValue>(OsuSkinConfiguration.HitCircleOverlayAboveNumber) ??
|
||||
source.GetConfig<OsuSkinConfiguration, TValue>(OsuSkinConfiguration.HitCircleOverlayAboveNumer);
|
||||
return Source.GetConfig<OsuSkinConfiguration, TValue>(OsuSkinConfiguration.HitCircleOverlayAboveNumber) ??
|
||||
Source.GetConfig<OsuSkinConfiguration, TValue>(OsuSkinConfiguration.HitCircleOverlayAboveNumer);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.Audio.Track;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -8,7 +9,6 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osuTK.Graphics;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
@ -148,7 +148,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
if (!effectPoint.KiaiMode)
|
||||
return;
|
||||
|
@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
|
||||
|
||||
|
@ -6,23 +6,20 @@ using System.Collections.Generic;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Rulesets.Taiko.UI;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Skinning
|
||||
{
|
||||
public class TaikoLegacySkinTransformer : ISkin
|
||||
public class TaikoLegacySkinTransformer : LegacySkinTransformer
|
||||
{
|
||||
private readonly 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))
|
||||
return null;
|
||||
@ -100,7 +97,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning
|
||||
return null;
|
||||
}
|
||||
|
||||
return source.GetDrawableComponent(component);
|
||||
return Source.GetDrawableComponent(component);
|
||||
}
|
||||
|
||||
private string getHitName(TaikoSkinComponents component)
|
||||
@ -120,11 +117,9 @@ namespace osu.Game.Rulesets.Taiko.Skinning
|
||||
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 IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => source.GetConfig<TLookup, TValue>(lookup);
|
||||
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => Source.GetConfig<TLookup, TValue>(lookup);
|
||||
|
||||
private class LegacyTaikoSampleInfo : ISampleInfo
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
lastObjectHit = result.IsHit;
|
||||
}
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
kiaiMode = effectPoint.KiaiMode;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
textureAnimation.Seek(0);
|
||||
}
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
// assume that if the animation is playing on its own, it's independent from the beat and doesn't need to be touched.
|
||||
if (textureAnimation.FrameCount == 0 || textureAnimation.IsPlaying)
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Play;
|
||||
@ -10,6 +11,7 @@ using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
[HeadlessTest]
|
||||
public class TestSceneGameplayClockContainer : OsuTestScene
|
||||
{
|
||||
[Test]
|
||||
|
@ -1,52 +1,21 @@
|
||||
// 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.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.IO.Stores;
|
||||
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.Skinning;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Tests.Visual.Gameplay;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
[HeadlessTest]
|
||||
public class TestSceneHitObjectSamples : OsuPlayerTestScene
|
||||
public class TestSceneHitObjectSamples : HitObjectSampleTest
|
||||
{
|
||||
private readonly SkinInfo userSkinInfo = new SkinInfo();
|
||||
|
||||
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;
|
||||
|
||||
private SkinSourceDependencyContainer dependencies;
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
=> new DependencyContainer(dependencies = new SkinSourceDependencyContainer(base.CreateChildDependencies(parent)));
|
||||
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
||||
protected override IResourceStore<byte[]> Resources => TestResources.GetStore();
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a hitobject which provides no custom sample set retrieves samples from the user skin.
|
||||
@ -56,11 +25,11 @@ namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
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>
|
||||
@ -71,11 +40,11 @@ namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
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>
|
||||
@ -86,11 +55,11 @@ namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
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>
|
||||
@ -102,11 +71,11 @@ namespace osu.Game.Tests.Gameplay
|
||||
[TestCase("normal-hitnormal")]
|
||||
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>
|
||||
@ -118,11 +87,11 @@ namespace osu.Game.Tests.Gameplay
|
||||
[TestCase("normal-hitnormal")]
|
||||
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>
|
||||
@ -133,11 +102,11 @@ namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
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>
|
||||
@ -148,11 +117,11 @@ namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
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>
|
||||
@ -163,11 +132,11 @@ namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
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>
|
||||
@ -177,11 +146,11 @@ namespace osu.Game.Tests.Gameplay
|
||||
[TestCase("normal-hitnormal")]
|
||||
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>
|
||||
@ -192,149 +161,11 @@ namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
AssertBeatmapLookup(expected_sample);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
5
osu.Game.Tests/Resources/skin-zero-alpha-colour.ini
Normal file
5
osu.Game.Tests/Resources/skin-zero-alpha-colour.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[General]
|
||||
Version: latest
|
||||
|
||||
[Colours]
|
||||
Combo1: 255,255,255,0
|
@ -108,5 +108,15 @@ namespace osu.Game.Tests.Skins
|
||||
using (var stream = new LineBufferedReader(resStream))
|
||||
Assert.That(decoder.Decode(stream).LegacyVersion, Is.EqualTo(1.0m));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDecodeColourWithZeroAlpha()
|
||||
{
|
||||
var decoder = new LegacySkinDecoder();
|
||||
|
||||
using (var resStream = TestResources.OpenResource("skin-zero-alpha-colour.ini"))
|
||||
using (var stream = new LineBufferedReader(resStream))
|
||||
Assert.That(decoder.Decode(stream).ComboColours[0].A, Is.EqualTo(1.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,9 +174,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestExitFromGameplay()
|
||||
{
|
||||
AddStep("exit", () => Player.Exit());
|
||||
confirmPaused();
|
||||
|
||||
// an externally triggered exit should immediately exit, skipping all pause logic.
|
||||
AddStep("exit", () => Player.Exit());
|
||||
confirmExited();
|
||||
}
|
||||
|
15
osu.Game.Tests/Visual/Menus/TestSceneIntroWelcome.cs
Normal file
15
osu.Game.Tests/Visual/Menus/TestSceneIntroWelcome.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneIntroWelcome : IntroTestScene
|
||||
{
|
||||
protected override IScreen CreateScreen() => new IntroWelcome();
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osuTK.Graphics;
|
||||
@ -100,6 +101,8 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
|
||||
public new BeatmapManager BeatmapManager => base.BeatmapManager;
|
||||
|
||||
public new ScoreManager ScoreManager => base.ScoreManager;
|
||||
|
||||
public new SettingsPanel Settings => base.Settings;
|
||||
|
||||
public new MusicController MusicController => base.MusicController;
|
||||
|
155
osu.Game.Tests/Visual/Navigation/TestScenePresentScore.cs
Normal file
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -177,7 +177,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
timeSinceLastBeat.Value = TimeSinceLastBeat;
|
||||
}
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
|
||||
|
||||
|
@ -9,7 +9,7 @@ using osu.Game.Tournament.Screens.Gameplay.Components;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Components
|
||||
{
|
||||
public class TestSceneMatchScoreDisplay : LadderTestScene
|
||||
public class TestSceneMatchScoreDisplay : TournamentTestScene
|
||||
{
|
||||
[Cached(Type = typeof(MatchIPCInfo))]
|
||||
private MatchIPCInfo matchInfo = new MatchIPCInfo();
|
||||
|
@ -8,12 +8,11 @@ using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tournament.Components;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Components
|
||||
{
|
||||
public class TestSceneTournamentBeatmapPanel : OsuTestScene
|
||||
public class TestSceneTournamentBeatmapPanel : TournamentTestScene
|
||||
{
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
@ -1,146 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tournament.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public abstract class LadderTestScene : TournamentTestScene
|
||||
{
|
||||
[Cached]
|
||||
protected LadderInfo Ladder { get; private set; } = new LadderInfo();
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesetStore { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Ladder.Ruleset.Value ??= rulesetStore.AvailableRulesets.First();
|
||||
|
||||
Ruleset.BindTo(Ladder.Ruleset);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
TournamentMatch match = CreateSampleMatch();
|
||||
|
||||
Ladder.Rounds.Add(match.Round.Value);
|
||||
Ladder.Matches.Add(match);
|
||||
Ladder.Teams.Add(match.Team1.Value);
|
||||
Ladder.Teams.Add(match.Team2.Value);
|
||||
|
||||
Ladder.CurrentMatch.Value = match;
|
||||
}
|
||||
|
||||
public static TournamentMatch CreateSampleMatch() => new TournamentMatch
|
||||
{
|
||||
Team1 =
|
||||
{
|
||||
Value = new TournamentTeam
|
||||
{
|
||||
FlagName = { Value = "JP" },
|
||||
FullName = { Value = "Japan" },
|
||||
LastYearPlacing = { Value = 10 },
|
||||
Seed = { Value = "Low" },
|
||||
SeedingResults =
|
||||
{
|
||||
new SeedingResult
|
||||
{
|
||||
Mod = { Value = "NM" },
|
||||
Seed = { Value = 10 },
|
||||
Beatmaps =
|
||||
{
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Score = 12345672,
|
||||
Seed = { Value = 24 },
|
||||
},
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Score = 1234567,
|
||||
Seed = { Value = 12 },
|
||||
},
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Score = 1234567,
|
||||
Seed = { Value = 16 },
|
||||
}
|
||||
}
|
||||
},
|
||||
new SeedingResult
|
||||
{
|
||||
Mod = { Value = "DT" },
|
||||
Seed = { Value = 5 },
|
||||
Beatmaps =
|
||||
{
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Score = 234567,
|
||||
Seed = { Value = 3 },
|
||||
},
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Score = 234567,
|
||||
Seed = { Value = 6 },
|
||||
},
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Score = 234567,
|
||||
Seed = { Value = 12 },
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Players =
|
||||
{
|
||||
new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 12 } } },
|
||||
new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 16 } } },
|
||||
new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 20 } } },
|
||||
new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 24 } } },
|
||||
new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 30 } } },
|
||||
}
|
||||
}
|
||||
},
|
||||
Team2 =
|
||||
{
|
||||
Value = new TournamentTeam
|
||||
{
|
||||
FlagName = { Value = "US" },
|
||||
FullName = { Value = "United States" },
|
||||
Players =
|
||||
{
|
||||
new User { Username = "Hello" },
|
||||
new User { Username = "Hello" },
|
||||
new User { Username = "Hello" },
|
||||
new User { Username = "Hello" },
|
||||
new User { Username = "Hello" },
|
||||
}
|
||||
}
|
||||
},
|
||||
Round =
|
||||
{
|
||||
Value = new TournamentRound { Name = { Value = "Quarterfinals" } }
|
||||
}
|
||||
};
|
||||
|
||||
public static BeatmapInfo CreateSampleBeatmapInfo() =>
|
||||
new BeatmapInfo { Metadata = new BeatmapMetadata { Title = "Test Title", Artist = "Test Artist", ID = RNG.Next(0, 1000000) } };
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ using osu.Game.Tournament.Screens.Editors;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
public class TestSceneLadderEditorScreen : LadderTestScene
|
||||
public class TestSceneLadderEditorScreen : TournamentTestScene
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
|
@ -8,7 +8,7 @@ using osu.Game.Tournament.Screens.Ladder;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
public class TestSceneLadderScreen : LadderTestScene
|
||||
public class TestSceneLadderScreen : TournamentTestScene
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
|
@ -12,7 +12,7 @@ using osu.Game.Tournament.Screens.MapPool;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
public class TestSceneMapPoolScreen : LadderTestScene
|
||||
public class TestSceneMapPoolScreen : TournamentTestScene
|
||||
{
|
||||
private MapPoolScreen screen;
|
||||
|
||||
|
@ -5,7 +5,7 @@ using osu.Game.Tournament.Screens.Editors;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
public class TestSceneRoundEditorScreen : LadderTestScene
|
||||
public class TestSceneRoundEditorScreen : TournamentTestScene
|
||||
{
|
||||
public TestSceneRoundEditorScreen()
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ using osu.Game.Tournament.Screens.Editors;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
public class TestSceneSeedingEditorScreen : LadderTestScene
|
||||
public class TestSceneSeedingEditorScreen : TournamentTestScene
|
||||
{
|
||||
[Cached]
|
||||
private readonly LadderInfo ladder = new LadderInfo();
|
||||
|
@ -8,7 +8,7 @@ using osu.Game.Tournament.Screens.TeamIntro;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
public class TestSceneSeedingScreen : LadderTestScene
|
||||
public class TestSceneSeedingScreen : TournamentTestScene
|
||||
{
|
||||
[Cached]
|
||||
private readonly LadderInfo ladder = new LadderInfo();
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ using osu.Game.Tournament.Screens.Editors;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
public class TestSceneTeamEditorScreen : LadderTestScene
|
||||
public class TestSceneTeamEditorScreen : TournamentTestScene
|
||||
{
|
||||
public TestSceneTeamEditorScreen()
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ using osu.Game.Tournament.Screens.TeamIntro;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
public class TestSceneTeamIntroScreen : LadderTestScene
|
||||
public class TestSceneTeamIntroScreen : TournamentTestScene
|
||||
{
|
||||
[Cached]
|
||||
private readonly LadderInfo ladder = new LadderInfo();
|
||||
|
@ -4,25 +4,19 @@
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osu.Game.Tournament.Screens.TeamWin;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
public class TestSceneTeamWinScreen : LadderTestScene
|
||||
public class TestSceneTeamWinScreen : TournamentTestScene
|
||||
{
|
||||
[Cached]
|
||||
private readonly LadderInfo ladder = new LadderInfo();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
var match = new TournamentMatch();
|
||||
match.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "USA");
|
||||
match.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "JPN");
|
||||
var match = Ladder.CurrentMatch.Value;
|
||||
|
||||
match.Round.Value = Ladder.Rounds.FirstOrDefault(g => g.Name.Value == "Finals");
|
||||
match.Completed.Value = true;
|
||||
ladder.CurrentMatch.Value = match;
|
||||
|
||||
Add(new TeamWinScreen
|
||||
{
|
||||
|
@ -1,13 +1,151 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tournament.Tests
|
||||
{
|
||||
public abstract class TournamentTestScene : OsuTestScene
|
||||
{
|
||||
[Cached]
|
||||
protected LadderInfo Ladder { get; private set; } = new LadderInfo();
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesetStore { get; set; }
|
||||
|
||||
[Cached]
|
||||
protected MatchIPCInfo IPCInfo { get; private set; } = new MatchIPCInfo();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(Storage storage)
|
||||
{
|
||||
Ladder.Ruleset.Value ??= rulesetStore.AvailableRulesets.First();
|
||||
|
||||
TournamentMatch match = CreateSampleMatch();
|
||||
|
||||
Ladder.Rounds.Add(match.Round.Value);
|
||||
Ladder.Matches.Add(match);
|
||||
Ladder.Teams.Add(match.Team1.Value);
|
||||
Ladder.Teams.Add(match.Team2.Value);
|
||||
|
||||
Ladder.CurrentMatch.Value = match;
|
||||
|
||||
Ruleset.BindTo(Ladder.Ruleset);
|
||||
Dependencies.CacheAs(new StableInfo(storage));
|
||||
}
|
||||
|
||||
public static TournamentMatch CreateSampleMatch() => new TournamentMatch
|
||||
{
|
||||
Team1 =
|
||||
{
|
||||
Value = new TournamentTeam
|
||||
{
|
||||
Acronym = { Value = "JPN" },
|
||||
FlagName = { Value = "JP" },
|
||||
FullName = { Value = "Japan" },
|
||||
LastYearPlacing = { Value = 10 },
|
||||
Seed = { Value = "Low" },
|
||||
SeedingResults =
|
||||
{
|
||||
new SeedingResult
|
||||
{
|
||||
Mod = { Value = "NM" },
|
||||
Seed = { Value = 10 },
|
||||
Beatmaps =
|
||||
{
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Score = 12345672,
|
||||
Seed = { Value = 24 },
|
||||
},
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Score = 1234567,
|
||||
Seed = { Value = 12 },
|
||||
},
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Score = 1234567,
|
||||
Seed = { Value = 16 },
|
||||
}
|
||||
}
|
||||
},
|
||||
new SeedingResult
|
||||
{
|
||||
Mod = { Value = "DT" },
|
||||
Seed = { Value = 5 },
|
||||
Beatmaps =
|
||||
{
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Score = 234567,
|
||||
Seed = { Value = 3 },
|
||||
},
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Score = 234567,
|
||||
Seed = { Value = 6 },
|
||||
},
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Score = 234567,
|
||||
Seed = { Value = 12 },
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Players =
|
||||
{
|
||||
new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 12 } } },
|
||||
new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 16 } } },
|
||||
new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 20 } } },
|
||||
new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 24 } } },
|
||||
new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 30 } } },
|
||||
}
|
||||
}
|
||||
},
|
||||
Team2 =
|
||||
{
|
||||
Value = new TournamentTeam
|
||||
{
|
||||
Acronym = { Value = "USA" },
|
||||
FlagName = { Value = "US" },
|
||||
FullName = { Value = "United States" },
|
||||
Players =
|
||||
{
|
||||
new User { Username = "Hello" },
|
||||
new User { Username = "Hello" },
|
||||
new User { Username = "Hello" },
|
||||
new User { Username = "Hello" },
|
||||
new User { Username = "Hello" },
|
||||
}
|
||||
}
|
||||
},
|
||||
Round =
|
||||
{
|
||||
Value = new TournamentRound { Name = { Value = "Quarterfinals" } }
|
||||
}
|
||||
};
|
||||
|
||||
public static BeatmapInfo CreateSampleBeatmapInfo() =>
|
||||
new BeatmapInfo { Metadata = new BeatmapMetadata { Title = "Test Title", Artist = "Test Artist", ID = RNG.Next(0, 1000000) } };
|
||||
|
||||
protected override ITestSceneTestRunner CreateRunner() => new TournamentTestSceneTestRunner();
|
||||
|
||||
public class TournamentTestSceneTestRunner : TournamentGameBase, ITestSceneTestRunner
|
||||
|
26
osu.Game.Tournament/Components/IPCErrorDialog.cs
Normal file
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()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.Win32;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Logging;
|
||||
@ -20,6 +21,8 @@ namespace osu.Game.Tournament.IPC
|
||||
{
|
||||
public class FileBasedIPC : MatchIPCInfo
|
||||
{
|
||||
public Storage IPCStorage { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
protected IAPIProvider API { get; private set; }
|
||||
|
||||
@ -32,45 +35,46 @@ namespace osu.Game.Tournament.IPC
|
||||
[Resolved]
|
||||
private LadderInfo ladder { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private StableInfo stableInfo { get; set; }
|
||||
|
||||
private int lastBeatmapId;
|
||||
private ScheduledDelegate scheduled;
|
||||
private GetBeatmapRequest beatmapLookupRequest;
|
||||
|
||||
public Storage Storage { get; private set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
LocateStableStorage();
|
||||
var stablePath = stableInfo.StablePath ?? findStablePath();
|
||||
initialiseIPCStorage(stablePath);
|
||||
}
|
||||
|
||||
public Storage LocateStableStorage()
|
||||
[CanBeNull]
|
||||
private Storage initialiseIPCStorage(string path)
|
||||
{
|
||||
scheduled?.Cancel();
|
||||
|
||||
Storage = null;
|
||||
IPCStorage = null;
|
||||
|
||||
try
|
||||
{
|
||||
var path = findStablePath();
|
||||
|
||||
if (string.IsNullOrEmpty(path))
|
||||
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_state_filename = "ipc-state.txt";
|
||||
const string file_ipc_scores_filename = "ipc-scores.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
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var stream = Storage.GetStream(file_ipc_filename))
|
||||
using (var stream = IPCStorage.GetStream(file_ipc_filename))
|
||||
using (var sr = new StreamReader(stream))
|
||||
{
|
||||
var beatmapId = int.Parse(sr.ReadLine());
|
||||
@ -104,7 +108,7 @@ namespace osu.Game.Tournament.IPC
|
||||
|
||||
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))
|
||||
{
|
||||
ChatChannel.Value = sr.ReadLine();
|
||||
@ -117,7 +121,7 @@ namespace osu.Game.Tournament.IPC
|
||||
|
||||
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))
|
||||
{
|
||||
State.Value = (TourneyState)Enum.Parse(typeof(TourneyState), sr.ReadLine());
|
||||
@ -130,7 +134,7 @@ namespace osu.Game.Tournament.IPC
|
||||
|
||||
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))
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
private string findFromEnvVar()
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.Log("Trying to find stable with environment variables");
|
||||
string stableInstallPath = Environment.GetEnvironmentVariable("OSU_STABLE_PATH");
|
||||
|
||||
if (ipcFileExistsInDirectory(stableInstallPath))
|
||||
return stableInstallPath;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string findFromLocalAppData()
|
||||
{
|
||||
Logger.Log("Trying to find stable in %LOCALAPPDATA%");
|
||||
string stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"osu!");
|
||||
|
||||
if (ipcFileExistsInDirectory(stableInstallPath))
|
||||
return stableInstallPath;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string findFromDotFolder()
|
||||
{
|
||||
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
|
||||
{
|
||||
try
|
||||
{
|
||||
stableInstallPath = Environment.GetEnvironmentVariable("OSU_STABLE_PATH");
|
||||
string stableInstallPath;
|
||||
|
||||
if (checkExists(stableInstallPath))
|
||||
return stableInstallPath;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
using (RegistryKey key = Registry.ClassesRoot.OpenSubKey("osu"))
|
||||
stableInstallPath = key?.OpenSubKey(@"shell\open\command")?.GetValue(string.Empty).ToString().Split('"')[1].Replace("osu!.exe", "");
|
||||
|
||||
try
|
||||
{
|
||||
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!");
|
||||
if (checkExists(stableInstallPath))
|
||||
if (ipcFileExistsInDirectory(stableInstallPath))
|
||||
return stableInstallPath;
|
||||
|
||||
stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".osu");
|
||||
if (checkExists(stableInstallPath))
|
||||
return stableInstallPath;
|
||||
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
catch
|
||||
{
|
||||
Logger.Log($"Stable path for tourney usage: {stableInstallPath}");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
62
osu.Game.Tournament/Models/StableInfo.cs
Normal file
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.Rulesets;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -30,12 +31,18 @@ namespace osu.Game.Tournament.Screens
|
||||
[Resolved]
|
||||
private MatchIPCInfo ipc { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private StableInfo stableInfo { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; }
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private TournamentSceneManager sceneManager { get; set; }
|
||||
|
||||
private Bindable<Size> windowSize;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -53,6 +60,7 @@ namespace osu.Game.Tournament.Screens
|
||||
};
|
||||
|
||||
api.LocalUser.BindValueChanged(_ => Schedule(reload));
|
||||
stableInfo.OnStableInfoSaved += () => Schedule(reload);
|
||||
reload();
|
||||
}
|
||||
|
||||
@ -62,21 +70,16 @@ namespace osu.Game.Tournament.Screens
|
||||
private void reload()
|
||||
{
|
||||
var fileBasedIpc = ipc as FileBasedIPC;
|
||||
|
||||
fillFlow.Children = new Drawable[]
|
||||
{
|
||||
new ActionableInfo
|
||||
{
|
||||
Label = "Current IPC source",
|
||||
ButtonText = "Refresh",
|
||||
Action = () =>
|
||||
{
|
||||
fileBasedIpc?.LocateStableStorage();
|
||||
reload();
|
||||
},
|
||||
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."
|
||||
ButtonText = "Change source",
|
||||
Action = () => sceneManager?.SetScreen(new StablePathSelectScreen()),
|
||||
Value = fileBasedIpc?.IPCStorage?.GetFullPath(string.Empty) ?? "Not found",
|
||||
Failing = fileBasedIpc?.IPCStorage == 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."
|
||||
},
|
||||
new ActionableInfo
|
||||
{
|
||||
|
164
osu.Game.Tournament/Screens/StablePathSelectScreen.cs
Normal file
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -53,6 +53,8 @@ namespace osu.Game.Tournament
|
||||
|
||||
ladder.CurrentMatch.Value = ladder.Matches.FirstOrDefault(p => p.Current.Value);
|
||||
|
||||
dependencies.CacheAs(new StableInfo(storage));
|
||||
|
||||
dependencies.CacheAs<MatchIPCInfo>(ipc = new FileBasedIPC());
|
||||
Add(ipc);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Tournament
|
||||
|
||||
public const float STREAM_AREA_WIDTH = 1366;
|
||||
|
||||
public const double REQUIRED_WIDTH = TournamentSceneManager.CONTROL_AREA_WIDTH * 2 + TournamentSceneManager.STREAM_AREA_WIDTH;
|
||||
public const double REQUIRED_WIDTH = CONTROL_AREA_WIDTH * 2 + STREAM_AREA_WIDTH;
|
||||
|
||||
[Cached]
|
||||
private TournamentMatchChatDisplay chat = new TournamentMatchChatDisplay();
|
||||
|
@ -103,7 +103,12 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
try
|
||||
{
|
||||
colour = new Color4(byte.Parse(split[0]), byte.Parse(split[1]), byte.Parse(split[2]), split.Length == 4 ? byte.Parse(split[3]) : (byte)255);
|
||||
byte alpha = split.Length == 4 ? byte.Parse(split[3]) : (byte)255;
|
||||
|
||||
if (alpha == 0)
|
||||
alpha = 255;
|
||||
|
||||
colour = new Color4(byte.Parse(split[0]), byte.Parse(split[1]), byte.Parse(split[2]), alpha);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
/// </summary>
|
||||
public static class Parsing
|
||||
{
|
||||
public const int MAX_COORDINATE_VALUE = 65536;
|
||||
public const int MAX_COORDINATE_VALUE = 131072;
|
||||
|
||||
public const double MAX_PARSE_VALUE = int.MaxValue;
|
||||
|
||||
|
@ -6,6 +6,7 @@ namespace osu.Game.Configuration
|
||||
public enum IntroSequence
|
||||
{
|
||||
Circles,
|
||||
Welcome,
|
||||
Triangles,
|
||||
Random
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Graphics.Containers
|
||||
private TimingControlPoint lastTimingPoint;
|
||||
|
||||
/// <summary>
|
||||
/// The amount of time before a beat we should fire <see cref="OnNewBeat(int, TimingControlPoint, EffectControlPoint, TrackAmplitudes)"/>.
|
||||
/// The amount of time before a beat we should fire <see cref="OnNewBeat(int, TimingControlPoint, EffectControlPoint, ChannelAmplitudes)"/>.
|
||||
/// This allows for adding easing to animations that may be synchronised to the beat.
|
||||
/// </summary>
|
||||
protected double EarlyActivationMilliseconds;
|
||||
@ -50,7 +50,6 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
private TimingControlPoint defaultTiming;
|
||||
private EffectControlPoint defaultEffect;
|
||||
private TrackAmplitudes defaultAmplitudes;
|
||||
|
||||
protected bool IsBeatSyncedWithTrack { get; private set; }
|
||||
|
||||
@ -107,7 +106,7 @@ namespace osu.Game.Graphics.Containers
|
||||
return;
|
||||
|
||||
using (BeginDelayedSequence(-TimeSinceLastBeat, true))
|
||||
OnNewBeat(beatIndex, timingPoint, effectPoint, track?.CurrentAmplitudes ?? defaultAmplitudes);
|
||||
OnNewBeat(beatIndex, timingPoint, effectPoint, track?.CurrentAmplitudes ?? ChannelAmplitudes.Empty);
|
||||
|
||||
lastBeat = beatIndex;
|
||||
lastTimingPoint = timingPoint;
|
||||
@ -128,16 +127,9 @@ namespace osu.Game.Graphics.Containers
|
||||
KiaiMode = false,
|
||||
OmitFirstBarLine = false
|
||||
};
|
||||
|
||||
defaultAmplitudes = new TrackAmplitudes
|
||||
{
|
||||
FrequencyAmplitudes = new float[256],
|
||||
LeftChannel = 0,
|
||||
RightChannel = 0
|
||||
};
|
||||
}
|
||||
|
||||
protected virtual void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
protected virtual void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ using JetBrains.Annotations;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input.Events;
|
||||
using osuTK.Input;
|
||||
using osu.Framework.Utils;
|
||||
|
||||
namespace osu.Game.Graphics.Cursor
|
||||
@ -74,17 +73,15 @@ namespace osu.Game.Graphics.Cursor
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
// only trigger animation for main mouse buttons
|
||||
if (e.Button <= MouseButton.Right)
|
||||
{
|
||||
activeCursor.Scale = new Vector2(1);
|
||||
activeCursor.ScaleTo(0.90f, 800, Easing.OutQuint);
|
||||
activeCursor.Scale = new Vector2(1);
|
||||
activeCursor.ScaleTo(0.90f, 800, Easing.OutQuint);
|
||||
|
||||
activeCursor.AdditiveLayer.Alpha = 0;
|
||||
activeCursor.AdditiveLayer.FadeInFromZero(800, Easing.OutQuint);
|
||||
}
|
||||
activeCursor.AdditiveLayer.Alpha = 0;
|
||||
activeCursor.AdditiveLayer.FadeInFromZero(800, Easing.OutQuint);
|
||||
|
||||
if (e.Button == MouseButton.Left && cursorRotate.Value)
|
||||
if (cursorRotate.Value && dragRotationState != DragRotationState.Rotating)
|
||||
{
|
||||
// if cursor is already rotating don't reset its rotate origin
|
||||
dragRotationState = DragRotationState.DragStarted;
|
||||
positionMouseDown = e.MousePosition;
|
||||
}
|
||||
@ -94,17 +91,16 @@ namespace osu.Game.Graphics.Cursor
|
||||
|
||||
protected override void OnMouseUp(MouseUpEvent e)
|
||||
{
|
||||
if (!e.IsPressed(MouseButton.Left) && !e.IsPressed(MouseButton.Right))
|
||||
if (!e.HasAnyButtonPressed)
|
||||
{
|
||||
activeCursor.AdditiveLayer.FadeOutFromOne(500, Easing.OutQuint);
|
||||
activeCursor.ScaleTo(1, 500, Easing.OutElastic);
|
||||
}
|
||||
|
||||
if (e.Button == MouseButton.Left)
|
||||
{
|
||||
if (dragRotationState == DragRotationState.Rotating)
|
||||
if (dragRotationState != DragRotationState.NotDragging)
|
||||
{
|
||||
activeCursor.RotateTo(0, 600 * (1 + Math.Abs(activeCursor.Rotation / 720)), Easing.OutElasticHalf);
|
||||
dragRotationState = DragRotationState.NotDragging;
|
||||
dragRotationState = DragRotationState.NotDragging;
|
||||
}
|
||||
}
|
||||
|
||||
base.OnMouseUp(e);
|
||||
|
@ -147,7 +147,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
if (!hasSelection)
|
||||
this.FadeTo(0.7f).FadeTo(0.4f, timingPoint.BeatLength, Easing.InOutSine);
|
||||
|
@ -230,7 +230,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
|
||||
|
||||
|
@ -35,7 +35,6 @@ using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Skinning;
|
||||
@ -43,6 +42,8 @@ using osuTK.Graphics;
|
||||
using osu.Game.Overlays.Volume;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Updater;
|
||||
using osu.Game.Utils;
|
||||
@ -360,7 +361,7 @@ namespace osu.Game
|
||||
/// Present a score's replay immediately.
|
||||
/// The user should have already requested this interactively.
|
||||
/// </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
|
||||
// to ensure all the required data for presenting a replay are present.
|
||||
@ -392,9 +393,19 @@ namespace osu.Game
|
||||
|
||||
PerformFromScreen(screen =>
|
||||
{
|
||||
Ruleset.Value = databasedScore.ScoreInfo.Ruleset;
|
||||
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(databasedBeatmap);
|
||||
|
||||
screen.Push(new ReplayPlayerLoader(databasedScore));
|
||||
switch (presentType)
|
||||
{
|
||||
case ScorePresentType.Gameplay:
|
||||
screen.Push(new ReplayPlayerLoader(databasedScore));
|
||||
break;
|
||||
|
||||
case ScorePresentType.Results:
|
||||
screen.Push(new SoloResultsScreen(databasedScore.ScoreInfo));
|
||||
break;
|
||||
}
|
||||
}, validScreens: new[] { typeof(PlaySongSelect) });
|
||||
}
|
||||
|
||||
@ -1002,4 +1013,10 @@ namespace osu.Game
|
||||
Exit();
|
||||
}
|
||||
}
|
||||
|
||||
public enum ScorePresentType
|
||||
{
|
||||
Results,
|
||||
Gameplay
|
||||
}
|
||||
}
|
||||
|
@ -78,19 +78,10 @@ namespace osu.Game.Overlays.Chat.Tabs
|
||||
/// <param name="channel">The channel that is going to be removed.</param>
|
||||
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);
|
||||
|
||||
if (SelectedTab == null)
|
||||
SelectTab(selectorTab);
|
||||
}
|
||||
|
||||
protected override void SelectTab(TabItem<Channel> tab)
|
||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
private const int bars_per_segment = 4;
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
|
||||
|
||||
|
@ -44,6 +44,7 @@ namespace osu.Game.Rulesets.Scoring
|
||||
private double gameplayEndTime;
|
||||
|
||||
private readonly double drainStartTime;
|
||||
private readonly double drainLenience;
|
||||
|
||||
private readonly List<(double time, double health)> healthIncreases = new List<(double, double)>();
|
||||
private double targetMinimumHealth;
|
||||
@ -55,9 +56,14 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// Creates a new <see cref="DrainingHealthProcessor"/>.
|
||||
/// </summary>
|
||||
/// <param name="drainStartTime">The time after which draining should begin.</param>
|
||||
public DrainingHealthProcessor(double drainStartTime)
|
||||
/// <param name="drainLenience">A lenience to apply to the default drain rate.<br />
|
||||
/// A value of 0 uses the default drain rate.<br />
|
||||
/// A value of 0.5 halves the drain rate.<br />
|
||||
/// A value of 1 completely removes drain.</param>
|
||||
public DrainingHealthProcessor(double drainStartTime, double drainLenience = 0)
|
||||
{
|
||||
this.drainStartTime = drainStartTime;
|
||||
this.drainLenience = drainLenience;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@ -96,6 +102,12 @@ namespace osu.Game.Rulesets.Scoring
|
||||
|
||||
targetMinimumHealth = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, min_health_target, mid_health_target, max_health_target);
|
||||
|
||||
// Add back a portion of the amount of HP to be drained, depending on the lenience requested.
|
||||
targetMinimumHealth += drainLenience * (1 - targetMinimumHealth);
|
||||
|
||||
// Ensure the target HP is within an acceptable range.
|
||||
targetMinimumHealth = Math.Clamp(targetMinimumHealth, 0, 1);
|
||||
|
||||
base.ApplyBeatmap(beatmap);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,10 @@ namespace osu.Game.Scoring
|
||||
{
|
||||
ScoreInfo = score;
|
||||
|
||||
var replayFilename = score.Files.First(f => f.Filename.EndsWith(".osr", StringComparison.InvariantCultureIgnoreCase)).FileInfo.StoragePath;
|
||||
var replayFilename = score.Files.FirstOrDefault(f => f.Filename.EndsWith(".osr", StringComparison.InvariantCultureIgnoreCase))?.FileInfo.StoragePath;
|
||||
|
||||
if (replayFilename == null)
|
||||
return;
|
||||
|
||||
using (var stream = store.GetStream(replayFilename))
|
||||
Replay = new DatabasedLegacyScoreDecoder(rulesets, beatmaps).Parse(stream).Replay;
|
||||
|
@ -13,6 +13,7 @@ using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
@ -82,6 +83,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
foreach (var o in args.OldItems)
|
||||
SelectionBlueprints.FirstOrDefault(b => b.HitObject == o)?.Deselect();
|
||||
|
||||
break;
|
||||
}
|
||||
};
|
||||
@ -250,6 +252,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
blueprint.Deselected -= onBlueprintDeselected;
|
||||
|
||||
SelectionBlueprints.Remove(blueprint);
|
||||
|
||||
if (movementBlueprint == blueprint)
|
||||
finishSelectionMovement();
|
||||
}
|
||||
|
||||
protected virtual void AddBlueprintFor(HitObject hitObject)
|
||||
@ -320,10 +325,22 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
foreach (var blueprint in SelectionBlueprints)
|
||||
{
|
||||
if (blueprint.IsAlive && blueprint.IsPresent && rect.Contains(blueprint.ScreenSpaceSelectionPoint))
|
||||
blueprint.Select();
|
||||
else
|
||||
blueprint.Deselect();
|
||||
// only run when utmost necessary to avoid unnecessary rect computations.
|
||||
bool isValidForSelection() => blueprint.IsAlive && blueprint.IsPresent && rect.Contains(blueprint.ScreenSpaceSelectionPoint);
|
||||
|
||||
switch (blueprint.State)
|
||||
{
|
||||
case SelectionState.NotSelected:
|
||||
if (isValidForSelection())
|
||||
blueprint.Select();
|
||||
break;
|
||||
|
||||
case SelectionState.Selected:
|
||||
// if the editor is playing, we generally don't want to deselect objects even if outside the selection area.
|
||||
if (!editorClock.IsRunning && !isValidForSelection())
|
||||
blueprint.Deselect();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
}
|
||||
};
|
||||
|
||||
private RectangleF? dragRectangle;
|
||||
|
||||
/// <summary>
|
||||
/// Handle a forwarded mouse event.
|
||||
/// </summary>
|
||||
@ -66,15 +68,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
var dragQuad = new Quad(dragStartPosition.X, dragStartPosition.Y, dragPosition.X - dragStartPosition.X, dragPosition.Y - dragStartPosition.Y);
|
||||
|
||||
// We use AABBFloat instead of RectangleF since it handles negative sizes for us
|
||||
var dragRectangle = dragQuad.AABBFloat;
|
||||
var rec = dragQuad.AABBFloat;
|
||||
dragRectangle = rec;
|
||||
|
||||
var topLeft = ToLocalSpace(dragRectangle.TopLeft);
|
||||
var bottomRight = ToLocalSpace(dragRectangle.BottomRight);
|
||||
var topLeft = ToLocalSpace(rec.TopLeft);
|
||||
var bottomRight = ToLocalSpace(rec.BottomRight);
|
||||
|
||||
Box.Position = topLeft;
|
||||
Box.Size = bottomRight - topLeft;
|
||||
|
||||
PerformSelection?.Invoke(dragRectangle);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -93,7 +94,19 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
}
|
||||
}
|
||||
|
||||
public override void Hide() => State = Visibility.Hidden;
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (dragRectangle != null)
|
||||
PerformSelection?.Invoke(dragRectangle.Value);
|
||||
}
|
||||
|
||||
public override void Hide()
|
||||
{
|
||||
State = Visibility.Hidden;
|
||||
dragRectangle = null;
|
||||
}
|
||||
|
||||
public override void Show() => State = Visibility.Visible;
|
||||
|
||||
|
@ -51,6 +51,9 @@ namespace osu.Game.Screens
|
||||
case IntroSequence.Circles:
|
||||
return new IntroCircles();
|
||||
|
||||
case IntroSequence.Welcome:
|
||||
return new IntroWelcome();
|
||||
|
||||
default:
|
||||
return new IntroTriangles();
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -15,7 +16,6 @@ using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
@ -132,7 +132,7 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
private bool rightward;
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Screens.Menu
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
if (MenuVoice.Value)
|
||||
welcome = audio.Samples.Get(@"welcome");
|
||||
welcome = audio.Samples.Get(@"Intro/welcome");
|
||||
}
|
||||
|
||||
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
||||
|
@ -51,6 +51,8 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
private SampleChannel seeya;
|
||||
|
||||
protected virtual string SeeyaSampleName => "Intro/seeya";
|
||||
|
||||
private LeasedBindable<WorkingBeatmap> beatmap;
|
||||
|
||||
private MainMenu mainMenu;
|
||||
@ -72,7 +74,7 @@ namespace osu.Game.Screens.Menu
|
||||
MenuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice);
|
||||
MenuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic);
|
||||
|
||||
seeya = audio.Samples.Get(@"seeya");
|
||||
seeya = audio.Samples.Get(SeeyaSampleName);
|
||||
|
||||
BeatmapSetInfo setInfo = null;
|
||||
|
||||
|
@ -47,7 +47,7 @@ namespace osu.Game.Screens.Menu
|
||||
private void load()
|
||||
{
|
||||
if (MenuVoice.Value && !UsingThemedIntro)
|
||||
welcome = audio.Samples.Get(@"welcome");
|
||||
welcome = audio.Samples.Get(@"Intro/welcome");
|
||||
}
|
||||
|
||||
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
||||
|
150
osu.Game/Screens/Menu/IntroWelcome.cs
Normal file
150
osu.Game/Screens/Menu/IntroWelcome.cs
Normal file
@ -0,0 +1,150 @@
|
||||
// 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 osuTK;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Menu
|
||||
{
|
||||
public class IntroWelcome : IntroScreen
|
||||
{
|
||||
protected override string BeatmapHash => "64e00d7022195959bfa3109d09c2e2276c8f12f486b91fcf6175583e973b48f2";
|
||||
protected override string BeatmapFile => "welcome.osz";
|
||||
private const double delay_step_two = 2142;
|
||||
private SampleChannel welcome;
|
||||
private SampleChannel pianoReverb;
|
||||
protected override string SeeyaSampleName => "Intro/Welcome/seeya";
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => background = new BackgroundScreenDefault(false)
|
||||
{
|
||||
Alpha = 0,
|
||||
};
|
||||
|
||||
private BackgroundScreenDefault background;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
if (MenuVoice.Value)
|
||||
welcome = audio.Samples.Get(@"Intro/Welcome/welcome");
|
||||
|
||||
pianoReverb = audio.Samples.Get(@"Intro/Welcome/welcome_piano");
|
||||
}
|
||||
|
||||
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
||||
{
|
||||
base.LogoArriving(logo, resuming);
|
||||
|
||||
if (!resuming)
|
||||
{
|
||||
LoadComponentAsync(new WelcomeIntroSequence
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}, intro =>
|
||||
{
|
||||
PrepareMenuLoad();
|
||||
|
||||
intro.LogoVisualisation.AddAmplitudeSource(pianoReverb);
|
||||
|
||||
AddInternal(intro);
|
||||
|
||||
welcome?.Play();
|
||||
pianoReverb?.Play();
|
||||
|
||||
Scheduler.AddDelayed(() =>
|
||||
{
|
||||
StartTrack();
|
||||
|
||||
const float fade_in_time = 200;
|
||||
|
||||
logo.ScaleTo(1);
|
||||
logo.FadeIn(fade_in_time);
|
||||
|
||||
background.FadeIn(fade_in_time);
|
||||
|
||||
LoadMenu();
|
||||
}, delay_step_two);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResuming(IScreen last)
|
||||
{
|
||||
base.OnResuming(last);
|
||||
background.FadeOut(100);
|
||||
}
|
||||
|
||||
private class WelcomeIntroSequence : Container
|
||||
{
|
||||
private Sprite welcomeText;
|
||||
private Container scaleContainer;
|
||||
|
||||
public LogoVisualisation LogoVisualisation { get; private set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
Anchor = Anchor.Centre;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
scaleContainer = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
LogoVisualisation = new LogoVisualisation
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Alpha = 0.5f,
|
||||
AccentColour = Color4.DarkBlue,
|
||||
Size = new Vector2(0.96f)
|
||||
},
|
||||
new Circle
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(480),
|
||||
Colour = Color4.Black
|
||||
},
|
||||
welcomeText = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Texture = textures.Get(@"Intro/Welcome/welcome_text")
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
using (BeginDelayedSequence(0, true))
|
||||
{
|
||||
scaleContainer.ScaleTo(0.9f).ScaleTo(1, delay_step_two).OnComplete(_ => Expire());
|
||||
scaleContainer.FadeInFromZero(1800);
|
||||
|
||||
welcomeText.ScaleTo(new Vector2(1, 0)).ScaleTo(Vector2.One, 400, Easing.Out);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,11 @@ using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Utils;
|
||||
|
||||
@ -65,6 +69,11 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
public Color4 AccentColour { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The relative movement of bars based on input amplification. Defaults to 1.
|
||||
/// </summary>
|
||||
public float Magnitude { get; set; } = 1;
|
||||
|
||||
private readonly float[] frequencyAmplitudes = new float[256];
|
||||
|
||||
private IShader shader;
|
||||
@ -76,6 +85,13 @@ namespace osu.Game.Screens.Menu
|
||||
Blending = BlendingParameters.Additive;
|
||||
}
|
||||
|
||||
private readonly List<IHasAmplitudes> amplitudeSources = new List<IHasAmplitudes>();
|
||||
|
||||
public void AddAmplitudeSource(IHasAmplitudes amplitudeSource)
|
||||
{
|
||||
amplitudeSources.Add(amplitudeSource);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ShaderManager shaders, IBindable<WorkingBeatmap> beatmap)
|
||||
{
|
||||
@ -83,27 +99,28 @@ namespace osu.Game.Screens.Menu
|
||||
shader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED);
|
||||
}
|
||||
|
||||
private readonly float[] temporalAmplitudes = new float[ChannelAmplitudes.AMPLITUDES_SIZE];
|
||||
|
||||
private void updateAmplitudes()
|
||||
{
|
||||
var track = beatmap.Value.TrackLoaded ? beatmap.Value.Track : null;
|
||||
var effect = beatmap.Value.BeatmapLoaded ? beatmap.Value.Beatmap?.ControlPointInfo.EffectPointAt(track?.CurrentTime ?? Time.Current) : null;
|
||||
var effect = beatmap.Value.BeatmapLoaded && beatmap.Value.TrackLoaded
|
||||
? beatmap.Value.Beatmap?.ControlPointInfo.EffectPointAt(beatmap.Value.Track.CurrentTime)
|
||||
: null;
|
||||
|
||||
float[] temporalAmplitudes = track?.CurrentAmplitudes.FrequencyAmplitudes;
|
||||
for (int i = 0; i < temporalAmplitudes.Length; i++)
|
||||
temporalAmplitudes[i] = 0;
|
||||
|
||||
if (beatmap.Value.TrackLoaded)
|
||||
addAmplitudesFromSource(beatmap.Value.Track);
|
||||
|
||||
foreach (var source in amplitudeSources)
|
||||
addAmplitudesFromSource(source);
|
||||
|
||||
for (int i = 0; i < bars_per_visualiser; i++)
|
||||
{
|
||||
if (track?.IsRunning ?? false)
|
||||
{
|
||||
float targetAmplitude = (temporalAmplitudes?[(i + indexOffset) % bars_per_visualiser] ?? 0) * (effect?.KiaiMode == true ? 1 : 0.5f);
|
||||
if (targetAmplitude > frequencyAmplitudes[i])
|
||||
frequencyAmplitudes[i] = targetAmplitude;
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = (i + index_change) % bars_per_visualiser;
|
||||
if (frequencyAmplitudes[index] > frequencyAmplitudes[i])
|
||||
frequencyAmplitudes[i] = frequencyAmplitudes[index];
|
||||
}
|
||||
float targetAmplitude = (temporalAmplitudes[(i + indexOffset) % bars_per_visualiser]) * (effect?.KiaiMode == true ? 1 : 0.5f);
|
||||
if (targetAmplitude > frequencyAmplitudes[i])
|
||||
frequencyAmplitudes[i] = targetAmplitude;
|
||||
}
|
||||
|
||||
indexOffset = (indexOffset + index_change) % bars_per_visualiser;
|
||||
@ -136,6 +153,19 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
protected override DrawNode CreateDrawNode() => new VisualisationDrawNode(this);
|
||||
|
||||
private void addAmplitudesFromSource([NotNull] IHasAmplitudes source)
|
||||
{
|
||||
if (source == null) throw new ArgumentNullException(nameof(source));
|
||||
|
||||
var amplitudes = source.CurrentAmplitudes.FrequencyAmplitudes.Span;
|
||||
|
||||
for (int i = 0; i < amplitudes.Length; i++)
|
||||
{
|
||||
if (i < temporalAmplitudes.Length)
|
||||
temporalAmplitudes[i] += amplitudes[i];
|
||||
}
|
||||
}
|
||||
|
||||
private class VisualisationDrawNode : DrawNode
|
||||
{
|
||||
protected new LogoVisualisation Source => (LogoVisualisation)base.Source;
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
@ -16,6 +15,7 @@ using osu.Game.Skinning;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Users;
|
||||
using System;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
|
||||
namespace osu.Game.Screens.Menu
|
||||
@ -89,7 +89,7 @@ namespace osu.Game.Screens.Menu
|
||||
skin.BindValueChanged(_ => updateColour(), true);
|
||||
}
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
if (beatIndex < 0)
|
||||
return;
|
||||
@ -100,7 +100,7 @@ namespace osu.Game.Screens.Menu
|
||||
flash(rightBox, timingPoint.BeatLength, effectPoint.KiaiMode, amplitudes);
|
||||
}
|
||||
|
||||
private void flash(Drawable d, double beatLength, bool kiai, TrackAmplitudes amplitudes)
|
||||
private void flash(Drawable d, double beatLength, bool kiai, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
d.FadeTo(Math.Max(0, ((ReferenceEquals(d, leftBox) ? amplitudes.LeftChannel : amplitudes.RightChannel) - amplitude_dead_zone) / (kiai ? kiai_multiplier : alpha_multiplier)), box_fade_in_time)
|
||||
.Then()
|
||||
|
@ -264,7 +264,7 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
private int lastBeatIndex;
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
|
||||
|
||||
|
@ -125,6 +125,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private GameplayBeatmap gameplayBeatmap;
|
||||
|
||||
private ScreenSuspensionHandler screenSuspension;
|
||||
|
||||
private DependencyContainer dependencies;
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
@ -179,6 +181,7 @@ namespace osu.Game.Screens.Play
|
||||
InternalChild = GameplayClockContainer = new GameplayClockContainer(Beatmap.Value, Mods.Value, DrawableRuleset.GameplayStartTime);
|
||||
|
||||
AddInternal(gameplayBeatmap = new GameplayBeatmap(playableBeatmap));
|
||||
AddInternal(screenSuspension = new ScreenSuspensionHandler(GameplayClockContainer));
|
||||
|
||||
dependencies.CacheAs(gameplayBeatmap);
|
||||
|
||||
@ -628,12 +631,16 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
{
|
||||
screenSuspension?.Expire();
|
||||
|
||||
fadeOut();
|
||||
base.OnSuspending(next);
|
||||
}
|
||||
|
||||
public override bool OnExiting(IScreen next)
|
||||
{
|
||||
screenSuspension?.Expire();
|
||||
|
||||
if (completionProgressDelegate != null && !completionProgressDelegate.Cancelled && !completionProgressDelegate.Completed)
|
||||
{
|
||||
// proceed to result screen if beatmap already finished playing
|
||||
@ -649,12 +656,6 @@ namespace osu.Game.Screens.Play
|
||||
return true;
|
||||
}
|
||||
|
||||
if (canPause)
|
||||
{
|
||||
Pause();
|
||||
return true;
|
||||
}
|
||||
|
||||
// GameplayClockContainer performs seeks / start / stop operations on the beatmap's track.
|
||||
// as we are no longer the current screen, we cannot guarantee the track is still usable.
|
||||
GameplayClockContainer?.StopUsingBeatmapClock();
|
||||
|
@ -9,7 +9,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class ReplayPlayerLoader : PlayerLoader
|
||||
{
|
||||
private readonly ScoreInfo scoreInfo;
|
||||
public readonly ScoreInfo Score;
|
||||
|
||||
public ReplayPlayerLoader(Score score)
|
||||
: base(() => new ReplayPlayer(score))
|
||||
@ -17,14 +17,14 @@ namespace osu.Game.Screens.Play
|
||||
if (score.Replay == null)
|
||||
throw new ArgumentException($"{nameof(score)} must have a non-null {nameof(score.Replay)}.", nameof(score));
|
||||
|
||||
scoreInfo = score.ScoreInfo;
|
||||
Score = score.ScoreInfo;
|
||||
}
|
||||
|
||||
public override void OnEntering(IScreen last)
|
||||
{
|
||||
// these will be reverted thanks to PlayerLoader's lease.
|
||||
Mods.Value = scoreInfo.Mods;
|
||||
Ruleset.Value = scoreInfo.Ruleset;
|
||||
Mods.Value = Score.Mods;
|
||||
Ruleset.Value = Score.Ruleset;
|
||||
|
||||
base.OnEntering(last);
|
||||
}
|
||||
|
52
osu.Game/Screens/Play/ScreenSuspensionHandler.cs
Normal file
52
osu.Game/Screens/Play/ScreenSuspensionHandler.cs
Normal file
@ -0,0 +1,52 @@
|
||||
// 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.Diagnostics;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Platform;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
/// <summary>
|
||||
/// Ensures screen is not suspended / dimmed while gameplay is active.
|
||||
/// </summary>
|
||||
public class ScreenSuspensionHandler : Component
|
||||
{
|
||||
private readonly GameplayClockContainer gameplayClockContainer;
|
||||
private Bindable<bool> isPaused;
|
||||
|
||||
[Resolved]
|
||||
private GameHost host { get; set; }
|
||||
|
||||
public ScreenSuspensionHandler([NotNull] GameplayClockContainer gameplayClockContainer)
|
||||
{
|
||||
this.gameplayClockContainer = gameplayClockContainer ?? throw new ArgumentNullException(nameof(gameplayClockContainer));
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
// This is the only usage game-wide of suspension changes.
|
||||
// Assert to ensure we don't accidentally forget this in the future.
|
||||
Debug.Assert(host.AllowScreenSuspension.Value);
|
||||
|
||||
isPaused = gameplayClockContainer.IsPaused.GetBoundCopy();
|
||||
isPaused.BindValueChanged(paused => host.AllowScreenSuspension.Value = paused.NewValue, true);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
isPaused?.UnbindAll();
|
||||
|
||||
if (host != null)
|
||||
host.AllowScreenSuspension.Value = true;
|
||||
}
|
||||
}
|
||||
}
|
@ -56,7 +56,7 @@ namespace osu.Game.Screens.Ranking
|
||||
switch (State.Value)
|
||||
{
|
||||
case DownloadState.LocallyAvailable:
|
||||
game?.PresentScore(Model.Value);
|
||||
game?.PresentScore(Model.Value, ScorePresentType.Gameplay);
|
||||
break;
|
||||
|
||||
case DownloadState.NotDownloaded:
|
||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Screens.Select
|
||||
public ImportFromStablePopup(Action importFromStable)
|
||||
{
|
||||
HeaderText = @"You have no beatmaps!";
|
||||
BodyText = "An existing copy of osu! was found, though.\nWould you like to import your beatmaps, skins and scores?";
|
||||
BodyText = "An existing copy of osu! was found, though.\nWould you like to import your beatmaps, skins and scores?\nThis will create a second copy of all files on disk.";
|
||||
|
||||
Icon = FontAwesome.Solid.Plane;
|
||||
|
||||
|
35
osu.Game/Skinning/LegacySkinTransformer.cs
Normal file
35
osu.Game/Skinning/LegacySkinTransformer.cs
Normal file
@ -0,0 +1,35 @@
|
||||
// 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.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Audio;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
/// <summary>
|
||||
/// Transformer used to handle support of legacy features for individual rulesets.
|
||||
/// </summary>
|
||||
public abstract class LegacySkinTransformer : ISkin
|
||||
{
|
||||
/// <summary>
|
||||
/// Source of the <see cref="ISkin"/> which is being transformed.
|
||||
/// </summary>
|
||||
protected ISkinSource Source { get; }
|
||||
|
||||
protected LegacySkinTransformer(ISkinSource source)
|
||||
{
|
||||
Source = source;
|
||||
}
|
||||
|
||||
public abstract Drawable GetDrawableComponent(ISkinComponent component);
|
||||
|
||||
public Texture GetTexture(string componentName) => Source.GetTexture(componentName);
|
||||
|
||||
public virtual SampleChannel GetSample(ISampleInfo sampleInfo) => Source.GetSample(sampleInfo);
|
||||
|
||||
public abstract IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup);
|
||||
}
|
||||
}
|
184
osu.Game/Tests/Beatmaps/HitObjectSampleTest.cs
Normal file
184
osu.Game/Tests/Beatmaps/HitObjectSampleTest.cs
Normal file
@ -0,0 +1,184 @@
|
||||
// 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.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Beatmaps
|
||||
{
|
||||
public abstract class HitObjectSampleTest : PlayerTestScene
|
||||
{
|
||||
protected abstract IResourceStore<byte[]> Resources { get; }
|
||||
|
||||
private readonly SkinInfo userSkinInfo = new SkinInfo();
|
||||
|
||||
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();
|
||||
private SkinSourceDependencyContainer dependencies;
|
||||
private IBeatmap currentTestBeatmap;
|
||||
protected sealed override bool HasCustomSteps => true;
|
||||
|
||||
protected sealed override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
=> new DependencyContainer(dependencies = new SkinSourceDependencyContainer(base.CreateChildDependencies(parent)));
|
||||
|
||||
protected sealed override IBeatmap CreateBeatmap(RulesetInfo ruleset) => currentTestBeatmap;
|
||||
|
||||
protected sealed override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
||||
=> new TestWorkingBeatmap(beatmapInfo, beatmapSkinResourceStore, beatmap, storyboard, Clock, Audio);
|
||||
|
||||
protected void CreateTestWithBeatmap(string filename)
|
||||
{
|
||||
CreateTest(() =>
|
||||
{
|
||||
AddStep("clear performed lookups", () =>
|
||||
{
|
||||
userSkinResourceStore.PerformedLookups.Clear();
|
||||
beatmapSkinResourceStore.PerformedLookups.Clear();
|
||||
});
|
||||
|
||||
AddStep($"load {filename}", () =>
|
||||
{
|
||||
using (var reader = new LineBufferedReader(Resources.GetStream($"Resources/SampleLookups/{filename}")))
|
||||
currentTestBeatmap = Decoder.GetDecoder<Beatmap>(reader).Decode(reader);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
protected 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));
|
||||
});
|
||||
}
|
||||
|
||||
protected void AssertBeatmapLookup(string name) => AddAssert($"\"{name}\" looked up from beatmap skin",
|
||||
() => !userSkinResourceStore.PerformedLookups.Contains(name) && beatmapSkinResourceStore.PerformedLookups.Contains(name));
|
||||
|
||||
protected 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,8 +24,8 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.609.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.602.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.623.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.622.1" />
|
||||
<PackageReference Include="Sentry" Version="2.1.3" />
|
||||
<PackageReference Include="SharpCompress" Version="0.25.1" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
|
@ -70,8 +70,8 @@
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.609.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.602.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.623.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.622.1" />
|
||||
</ItemGroup>
|
||||
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
|
||||
<ItemGroup Label="Transitive Dependencies">
|
||||
@ -80,7 +80,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.609.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.623.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.25.1" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user