1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:13:21 +08:00

Merge branch 'master' into mania-element-lookup-refactor

This commit is contained in:
Dan Balasescu 2020-06-21 22:36:53 +09:00 committed by GitHub
commit 9c7031965f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
83 changed files with 1009 additions and 370 deletions

View File

@ -5,6 +5,6 @@
"version": "3.1.100"
},
"msbuild-sdks": {
"Microsoft.Build.Traversal": "2.0.48"
"Microsoft.Build.Traversal": "2.0.50"
}
}

View File

@ -52,6 +52,6 @@
</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.Framework.Android" Version="2020.619.0" />
</ItemGroup>
</Project>

View File

@ -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();
}
}
}

View File

@ -30,18 +30,16 @@ namespace osu.Desktop.Updater
private static readonly Logger logger = Logger.GetLogger("updater");
[BackgroundDependencyLoader]
private void load(NotificationOverlay notification, OsuGameBase game)
private void load(NotificationOverlay notification)
{
notificationOverlay = notification;
if (game.IsDeployedBuild)
{
Splat.Locator.CurrentMutable.Register(() => new SquirrelLogger(), typeof(Splat.ILogger));
Schedule(() => Task.Run(() => checkForUpdateAsync()));
}
Splat.Locator.CurrentMutable.Register(() => new SquirrelLogger(), typeof(Splat.ILogger));
}
private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null)
protected override async Task PerformUpdateCheck() => await checkForUpdateAsync();
private async Task checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null)
{
// should we schedule a retry on completion of this check?
bool scheduleRecheck = true;
@ -83,7 +81,7 @@ namespace osu.Desktop.Updater
// could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959)
// try again without deltas.
checkForUpdateAsync(false, notification);
await checkForUpdateAsync(false, notification);
scheduleRecheck = false;
}
else
@ -102,7 +100,7 @@ namespace osu.Desktop.Updater
if (scheduleRecheck)
{
// check again in 30 minutes.
Scheduler.AddDelayed(() => checkForUpdateAsync(), 60000 * 30);
Scheduler.AddDelayed(async () => await checkForUpdateAsync(), 60000 * 30);
}
}
}

View File

@ -13,8 +13,10 @@ namespace osu.Game.Rulesets.Catch.Tests.Mods
{
public class TestSceneCatchModPerfect : ModPerfectTestScene
{
protected override Ruleset CreatePlayerRuleset() => new CatchRuleset();
public TestSceneCatchModPerfect()
: base(new CatchRuleset(), new CatchModPerfect())
: base(new CatchModPerfect())
{
}

View File

@ -12,13 +12,8 @@ using osuTK;
namespace osu.Game.Rulesets.Catch.Tests
{
public class TestSceneAutoJuiceStream : PlayerTestScene
public class TestSceneAutoJuiceStream : TestSceneCatchPlayer
{
public TestSceneAutoJuiceStream()
: base(new CatchRuleset())
{
}
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{
var beatmap = new Beatmap

View File

@ -4,18 +4,12 @@
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Catch.Tests
{
[TestFixture]
public class TestSceneBananaShower : PlayerTestScene
public class TestSceneBananaShower : TestSceneCatchPlayer
{
public TestSceneBananaShower()
: base(new CatchRuleset())
{
}
[Test]
public void TestBananaShower()
{

View File

@ -9,9 +9,6 @@ namespace osu.Game.Rulesets.Catch.Tests
[TestFixture]
public class TestSceneCatchPlayer : PlayerTestScene
{
public TestSceneCatchPlayer()
: base(new CatchRuleset())
{
}
protected override Ruleset CreatePlayerRuleset() => new CatchRuleset();
}
}

View File

@ -4,18 +4,12 @@
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Catch.Tests
{
[TestFixture]
public class TestSceneCatchStacker : PlayerTestScene
public class TestSceneCatchStacker : TestSceneCatchPlayer
{
public TestSceneCatchStacker()
: base(new CatchRuleset())
{
}
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{
var beatmap = new Beatmap

View File

@ -9,19 +9,13 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Rulesets.Catch.Tests
{
[TestFixture]
public class TestSceneHyperDash : PlayerTestScene
public class TestSceneHyperDash : TestSceneCatchPlayer
{
public TestSceneHyperDash()
: base(new CatchRuleset())
{
}
protected override bool Autoplay => true;
[Test]

View File

@ -7,18 +7,12 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Rulesets.Catch.Tests
{
public class TestSceneJuiceStream : PlayerTestScene
public class TestSceneJuiceStream : TestSceneCatchPlayer
{
public TestSceneJuiceStream()
: base(new CatchRuleset())
{
}
[Test]
public void TestJuiceStreamEndingCombo()
{

View File

@ -10,8 +10,10 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
{
public class TestSceneManiaModPerfect : ModPerfectTestScene
{
protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();
public TestSceneManiaModPerfect()
: base(new ManiaRuleset(), new ManiaModPerfect())
: base(new ManiaModPerfect())
{
}

View File

@ -15,8 +15,9 @@ namespace osu.Game.Rulesets.Mania.Tests
{
private readonly Bindable<ManiaScrollingDirection> direction = new Bindable<ManiaScrollingDirection>();
protected override Ruleset CreateEditorRuleset() => new ManiaRuleset();
public TestSceneEditor()
: base(new ManiaRuleset())
{
AddStep("upwards scroll", () => direction.Value = ManiaScrollingDirection.Up);
AddStep("downwards scroll", () => direction.Value = ManiaScrollingDirection.Down);

View File

@ -5,11 +5,8 @@ using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Mania.Tests
{
public class TestScenePlayer : PlayerTestScene
public class TestSceneManiaPlayer : PlayerTestScene
{
public TestScenePlayer()
: base(new ManiaRuleset())
{
}
protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();
}
}

View File

@ -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)

View File

@ -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);

View File

@ -0,0 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests.Mods
{
public class OsuModTestScene : ModTestScene
{
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
}
}

View File

@ -9,17 +9,11 @@ using osu.Framework.Utils;
using osu.Game.Graphics.Containers;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests.Mods
{
public class TestSceneOsuModDifficultyAdjust : ModTestScene
public class TestSceneOsuModDifficultyAdjust : OsuModTestScene
{
public TestSceneOsuModDifficultyAdjust()
: base(new OsuRuleset())
{
}
[Test]
public void TestNoAdjustment() => CreateModTest(new ModTestData
{

View File

@ -4,17 +4,11 @@
using NUnit.Framework;
using osu.Framework.Utils;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests.Mods
{
public class TestSceneOsuModDoubleTime : ModTestScene
public class TestSceneOsuModDoubleTime : OsuModTestScene
{
public TestSceneOsuModDoubleTime()
: base(new OsuRuleset())
{
}
[TestCase(0.5)]
[TestCase(1.01)]
[TestCase(1.5)]

View File

@ -8,18 +8,12 @@ using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Rulesets.Osu.Tests.Mods
{
public class TestSceneOsuModHidden : ModTestScene
public class TestSceneOsuModHidden : OsuModTestScene
{
public TestSceneOsuModHidden()
: base(new OsuRuleset())
{
}
[Test]
public void TestDefaultBeatmapTest() => CreateModTest(new ModTestData
{

View File

@ -13,8 +13,10 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
{
public class TestSceneOsuModPerfect : ModPerfectTestScene
{
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
public TestSceneOsuModPerfect()
: base(new OsuRuleset(), new OsuModPerfect())
: base(new OsuModPerfect())
{
}

View File

@ -9,9 +9,6 @@ namespace osu.Game.Rulesets.Osu.Tests
[TestFixture]
public class TestSceneEditor : EditorTestScene
{
public TestSceneEditor()
: base(new OsuRuleset())
{
}
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
}
}

View File

@ -4,19 +4,13 @@
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Rulesets.Osu.Tests
{
[TestFixture]
public class TestSceneHitCircleLongCombo : PlayerTestScene
public class TestSceneHitCircleLongCombo : TestSceneOsuPlayer
{
public TestSceneHitCircleLongCombo()
: base(new OsuRuleset())
{
}
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{
var beatmap = new Beatmap

View File

@ -19,10 +19,7 @@ namespace osu.Game.Rulesets.Osu.Tests
{
public class TestSceneMissHitWindowJudgements : ModTestScene
{
public TestSceneMissHitWindowJudgements()
: base(new OsuRuleset())
{
}
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
[Test]
public void TestMissViaEarlyHit()

View File

@ -9,9 +9,6 @@ namespace osu.Game.Rulesets.Osu.Tests
[TestFixture]
public class TestSceneOsuPlayer : PlayerTestScene
{
public TestSceneOsuPlayer()
: base(new OsuRuleset())
{
}
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
}
}

View File

@ -25,13 +25,12 @@ using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests
{
[TestFixture]
public class TestSceneSkinFallbacks : PlayerTestScene
public class TestSceneSkinFallbacks : TestSceneOsuPlayer
{
private readonly TestSource testUserSkin;
private readonly TestSource testBeatmapSkin;
public TestSceneSkinFallbacks()
: base(new OsuRuleset())
{
testUserSkin = new TestSource("user");
testBeatmapSkin = new TestSource("beatmap");

View File

@ -12,8 +12,10 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
{
public class TestSceneTaikoModPerfect : ModPerfectTestScene
{
protected override Ruleset CreatePlayerRuleset() => new TestTaikoRuleset();
public TestSceneTaikoModPerfect()
: base(new TestTaikoRuleset(), new TaikoModPerfect())
: base(new TaikoModPerfect())
{
}

View File

@ -9,9 +9,6 @@ namespace osu.Game.Rulesets.Taiko.Tests
[TestFixture]
public class TestSceneEditor : EditorTestScene
{
public TestSceneEditor()
: base(new TaikoRuleset())
{
}
protected override Ruleset CreateEditorRuleset() => new TaikoRuleset();
}
}

View File

@ -6,7 +6,6 @@ using osu.Framework.Testing;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests
{
@ -14,13 +13,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
/// Taiko has some interesting rules for legacy mappings.
/// </summary>
[HeadlessTest]
public class TestSceneSampleOutput : PlayerTestScene
public class TestSceneSampleOutput : TestSceneTaikoPlayer
{
public TestSceneSampleOutput()
: base(new TaikoRuleset())
{
}
public override void SetUpSteps()
{
base.SetUpSteps();

View File

@ -5,17 +5,11 @@ using System.Linq;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests
{
public class TestSceneSwellJudgements : PlayerTestScene
public class TestSceneSwellJudgements : TestSceneTaikoPlayer
{
public TestSceneSwellJudgements()
: base(new TaikoRuleset())
{
}
[Test]
public void TestZeroTickTimeOffsets()
{

View File

@ -0,0 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests
{
public class TestSceneTaikoPlayer : PlayerTestScene
{
protected override Ruleset CreatePlayerRuleset() => new TaikoRuleset();
}
}

View File

@ -11,13 +11,8 @@ using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests
{
public class TestSceneTaikoSuddenDeath : PlayerTestScene
public class TestSceneTaikoSuddenDeath : TestSceneTaikoPlayer
{
public TestSceneTaikoSuddenDeath()
: base(new TaikoRuleset())
{
}
protected override bool AllowFail => true;
protected override TestPlayer CreatePlayer(Ruleset ruleset)

View File

@ -0,0 +1,27 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Play;
using osu.Game.Tests.Visual;
namespace osu.Game.Tests.Gameplay
{
[HeadlessTest]
public class TestSceneGameplayClockContainer : OsuTestScene
{
[Test]
public void TestStartThenElapsedTime()
{
GameplayClockContainer gcc = null;
AddStep("create container", () => Add(gcc = new GameplayClockContainer(CreateWorkingBeatmap(new OsuRuleset().RulesetInfo), Array.Empty<Mod>(), 0)));
AddStep("start track", () => gcc.Start());
AddUntilStep("elapsed greater than zero", () => gcc.GameplayClock.ElapsedFrameTime > 0);
}
}
}

View File

@ -16,17 +16,16 @@ using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Formats;
using osu.Game.IO;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Skinning;
using osu.Game.Storyboards;
using osu.Game.Tests.Resources;
using osu.Game.Tests.Visual;
using osu.Game.Tests.Visual.Gameplay;
using osu.Game.Users;
namespace osu.Game.Tests.Gameplay
{
[HeadlessTest]
public class TestSceneHitObjectSamples : PlayerTestScene
public class TestSceneHitObjectSamples : OsuPlayerTestScene
{
private readonly SkinInfo userSkinInfo = new SkinInfo();
@ -44,11 +43,6 @@ namespace osu.Game.Tests.Gameplay
protected override bool HasCustomSteps => true;
public TestSceneHitObjectSamples()
: base(new OsuRuleset())
{
}
private SkinSourceDependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)

View File

@ -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 System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
@ -10,7 +11,12 @@ using osu.Framework.Audio.Sample;
using osu.Framework.IO.Stores;
using osu.Framework.Testing;
using osu.Game.Audio;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Play;
using osu.Game.Skinning;
using osu.Game.Storyboards;
using osu.Game.Storyboards.Drawables;
using osu.Game.Tests.Resources;
using osu.Game.Tests.Visual;
@ -43,6 +49,27 @@ namespace osu.Game.Tests.Gameplay
AddAssert("sample is non-null", () => channel != null);
}
[Test]
public void TestSamplePlaybackAtZero()
{
GameplayClockContainer gameplayContainer = null;
DrawableStoryboardSample sample = null;
AddStep("create container", () =>
{
Add(gameplayContainer = new GameplayClockContainer(CreateWorkingBeatmap(new OsuRuleset().RulesetInfo), Array.Empty<Mod>(), 0));
gameplayContainer.Add(sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
{
Clock = gameplayContainer.GameplayClock
});
});
AddStep("start time", () => gameplayContainer.Start());
AddUntilStep("sample playback succeeded", () => sample.LifetimeEnd < double.MaxValue);
}
private class TestSkin : LegacySkin
{
public TestSkin(string resourceName, AudioManager audioManager)
@ -60,11 +87,11 @@ namespace osu.Game.Tests.Gameplay
this.resourceName = resourceName;
}
public byte[] Get(string name) => name == resourceName ? TestResources.GetStore().Get("Resources/test-sample.mp3") : null;
public byte[] Get(string name) => name == resourceName ? TestResources.GetStore().Get("Resources/Samples/test-sample.mp3") : null;
public Task<byte[]> GetAsync(string name) => name == resourceName ? TestResources.GetStore().GetAsync("Resources/test-sample.mp3") : null;
public Task<byte[]> GetAsync(string name) => name == resourceName ? TestResources.GetStore().GetAsync("Resources/Samples/test-sample.mp3") : null;
public Stream GetStream(string name) => name == resourceName ? TestResources.GetStore().GetStream("Resources/test-sample.mp3") : null;
public Stream GetStream(string name) => name == resourceName ? TestResources.GetStore().GetStream("Resources/Samples/test-sample.mp3") : null;
public IEnumerable<string> GetAvailableResources() => new[] { resourceName };

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -0,0 +1,95 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Configuration.Tracking;
using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Configuration;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
using osu.Game.Tests.Resources;
using osu.Game.Tests.Visual;
namespace osu.Game.Tests.Testing
{
/// <summary>
/// A test scene ensuring the dependencies for the
/// provided ruleset below are cached at the base implementation.
/// </summary>
[HeadlessTest]
public class TestSceneRulesetDependencies : OsuTestScene
{
protected override Ruleset CreateRuleset() => new TestRuleset();
[Test]
public void TestRetrieveTexture()
{
AddAssert("ruleset texture retrieved", () =>
Dependencies.Get<TextureStore>().Get(@"test-image") != null);
}
[Test]
public void TestRetrieveSample()
{
AddAssert("ruleset sample retrieved", () =>
Dependencies.Get<ISampleStore>().Get(@"test-sample") != null);
}
[Test]
public void TestResolveConfigManager()
{
AddAssert("ruleset config resolved", () =>
Dependencies.Get<TestRulesetConfigManager>() != null);
}
private class TestRuleset : Ruleset
{
public override string Description => string.Empty;
public override string ShortName => string.Empty;
public TestRuleset()
{
// temporary ID to let RulesetConfigCache pass our
// config manager to the ruleset dependencies.
RulesetInfo.ID = -1;
}
public override IResourceStore<byte[]> CreateResourceStore() => new NamespacedResourceStore<byte[]>(TestResources.GetStore(), @"Resources");
public override IRulesetConfigManager CreateConfig(SettingsStore settings) => new TestRulesetConfigManager();
public override IEnumerable<Mod> GetModsFor(ModType type) => Array.Empty<Mod>();
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => null;
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => null;
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => null;
}
private class TestRulesetConfigManager : IRulesetConfigManager
{
public void Load()
{
}
public bool Save() => true;
public TrackedSettings CreateTrackedSettings() => new TrackedSettings();
public void LoadInto(TrackedSettings settings)
{
}
public void Dispose()
{
}
}
}
}

View File

@ -4,6 +4,7 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects;
@ -13,13 +14,10 @@ namespace osu.Game.Tests.Visual.Editing
{
public class TestSceneEditorChangeStates : EditorTestScene
{
public TestSceneEditorChangeStates()
: base(new OsuRuleset())
{
}
private EditorBeatmap editorBeatmap;
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
public override void SetUpSteps()
{
base.SetUpSteps();

View File

@ -0,0 +1,16 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
namespace osu.Game.Tests.Visual.Gameplay
{
/// <summary>
/// A <see cref="PlayerTestScene"/> with an arbitrary ruleset value to test with.
/// </summary>
public abstract class OsuPlayerTestScene : PlayerTestScene
{
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
}
}

View File

@ -10,14 +10,13 @@ using osu.Framework.Testing;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Storyboards;
using osuTK;
namespace osu.Game.Tests.Visual.Gameplay
{
public class TestSceneCompletionCancellation : PlayerTestScene
public class TestSceneCompletionCancellation : OsuPlayerTestScene
{
private Track track;
@ -29,11 +28,6 @@ namespace osu.Game.Tests.Visual.Gameplay
protected override bool AllowFail => false;
public TestSceneCompletionCancellation()
: base(new OsuRuleset())
{
}
[SetUpSteps]
public override void SetUpSteps()
{

View File

@ -10,23 +10,17 @@ using osu.Framework.Utils;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Storyboards;
using osuTK;
namespace osu.Game.Tests.Visual.Gameplay
{
public class TestSceneGameplayRewinding : PlayerTestScene
public class TestSceneGameplayRewinding : OsuPlayerTestScene
{
[Resolved]
private AudioManager audioManager { get; set; }
public TestSceneGameplayRewinding()
: base(new OsuRuleset())
{
}
private Track track;
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)

View File

@ -10,14 +10,13 @@ using osu.Framework.Testing;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Play;
using osuTK;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Gameplay
{
public class TestScenePause : PlayerTestScene
public class TestScenePause : OsuPlayerTestScene
{
protected new PausePlayer Player => (PausePlayer)base.Player;
@ -26,7 +25,6 @@ namespace osu.Game.Tests.Visual.Gameplay
protected override Container<Drawable> Content => content;
public TestScenePause()
: base(new OsuRuleset())
{
base.Content.Add(content = new MenuCursorContainer { RelativeSizeAxes = Axes.Both });
}

View File

@ -8,12 +8,11 @@ using osu.Framework.Platform;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
namespace osu.Game.Tests.Visual.Gameplay
{
[HeadlessTest] // we alter unsafe properties on the game host to test inactive window state.
public class TestScenePauseWhenInactive : PlayerTestScene
public class TestScenePauseWhenInactive : OsuPlayerTestScene
{
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{
@ -27,11 +26,6 @@ namespace osu.Game.Tests.Visual.Gameplay
[Resolved]
private GameHost host { get; set; }
public TestScenePauseWhenInactive()
: base(new OsuRuleset())
{
}
[Test]
public void TestDoesntPauseDuringIntro()
{

View File

@ -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;

View 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;
}
}
}
}

View File

@ -1,52 +1,128 @@
// 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.Game.Online.API.Requests;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Game.Overlays.Comments;
using osu.Game.Overlays;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Users;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Comments;
namespace osu.Game.Tests.Visual.Online
{
[TestFixture]
public class TestSceneCommentsContainer : OsuTestScene
{
protected override bool UseOnlineAPI => true;
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
public TestSceneCommentsContainer()
{
BasicScrollContainer scroll;
TestCommentsContainer comments;
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
Add(scroll = new BasicScrollContainer
private CommentsContainer commentsContainer;
[SetUp]
public void SetUp() => Schedule(() =>
Child = new BasicScrollContainer
{
RelativeSizeAxes = Axes.Both,
Child = comments = new TestCommentsContainer()
Child = commentsContainer = new CommentsContainer()
});
AddStep("Big Black comments", () => comments.ShowComments(CommentableType.Beatmapset, 41823));
AddStep("Airman comments", () => comments.ShowComments(CommentableType.Beatmapset, 24313));
AddStep("Lazer build comments", () => comments.ShowComments(CommentableType.Build, 4772));
AddStep("News comments", () => comments.ShowComments(CommentableType.NewsPost, 715));
AddStep("Trigger user change", comments.User.TriggerChange);
AddStep("Idle state", () =>
{
scroll.Clear();
scroll.Add(comments = new TestCommentsContainer());
});
}
private class TestCommentsContainer : CommentsContainer
[Test]
public void TestIdleState()
{
public new Bindable<User> User => base.User;
AddUntilStep("loading spinner shown",
() => commentsContainer.ChildrenOfType<CommentsShowMoreButton>().Single().IsLoading);
}
[Test]
public void TestSingleCommentsPage()
{
setUpCommentsResponse(exampleComments);
AddStep("show comments", () => commentsContainer.ShowComments(CommentableType.Beatmapset, 123));
AddUntilStep("show more button hidden",
() => commentsContainer.ChildrenOfType<CommentsShowMoreButton>().Single().Alpha == 0);
}
[Test]
public void TestMultipleCommentPages()
{
var comments = exampleComments;
comments.HasMore = true;
comments.TopLevelCount = 10;
setUpCommentsResponse(comments);
AddStep("show comments", () => commentsContainer.ShowComments(CommentableType.Beatmapset, 123));
AddUntilStep("show more button visible",
() => commentsContainer.ChildrenOfType<CommentsShowMoreButton>().Single().Alpha == 1);
}
[Test]
public void TestMultipleLoads()
{
var comments = exampleComments;
int topLevelCommentCount = exampleComments.Comments.Count(comment => comment.IsTopLevel);
AddStep("hide container", () => commentsContainer.Hide());
setUpCommentsResponse(comments);
AddRepeatStep("show comments multiple times",
() => commentsContainer.ShowComments(CommentableType.Beatmapset, 456), 2);
AddStep("show container", () => commentsContainer.Show());
AddUntilStep("comment count is correct",
() => commentsContainer.ChildrenOfType<DrawableComment>().Count() == topLevelCommentCount);
}
private void setUpCommentsResponse(CommentBundle commentBundle)
=> AddStep("set up response", () =>
{
dummyAPI.HandleRequest = request =>
{
if (!(request is GetCommentsRequest getCommentsRequest))
return;
getCommentsRequest.TriggerSuccess(commentBundle);
};
});
private CommentBundle exampleComments => new CommentBundle
{
Comments = new List<Comment>
{
new Comment
{
Id = 1,
Message = "This is a comment",
LegacyName = "FirstUser",
CreatedAt = DateTimeOffset.Now,
VotesCount = 19,
RepliesCount = 1
},
new Comment
{
Id = 5,
ParentId = 1,
Message = "This is a child comment",
LegacyName = "SecondUser",
CreatedAt = DateTimeOffset.Now,
VotesCount = 4,
},
new Comment
{
Id = 10,
Message = "This is another comment",
LegacyName = "ThirdUser",
CreatedAt = DateTimeOffset.Now,
VotesCount = 0
},
},
IncludedComments = new List<Comment>(),
};
}
}

View File

@ -77,6 +77,8 @@ namespace osu.Game.Tournament.Components
flow = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
// Todo: This is a hack for https://github.com/ppy/osu-framework/issues/3617 since this container is at the very edge of the screen and potentially initially masked away.
Height = 1,
AutoSizeAxes = Axes.Y,
LayoutDuration = 500,
LayoutEasing = Easing.OutQuint,

View File

@ -39,6 +39,8 @@ namespace osu.Game.Input.Bindings
new KeyBinding(InputKey.Escape, GlobalAction.Back),
new KeyBinding(InputKey.ExtraMouseButton1, GlobalAction.Back),
new KeyBinding(new[] { InputKey.Alt, InputKey.Home }, GlobalAction.Home),
new KeyBinding(InputKey.Up, GlobalAction.SelectPrevious),
new KeyBinding(InputKey.Down, GlobalAction.SelectNext),
@ -152,5 +154,8 @@ namespace osu.Game.Input.Bindings
[Description("Next Selection")]
SelectNext,
[Description("Home")]
Home,
}
}

View File

@ -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) });
}
@ -611,6 +622,9 @@ namespace osu.Game
loadComponentSingleFile(screenshotManager, Add);
// dependency on notification overlay, dependent by settings overlay
loadComponentSingleFile(CreateUpdateManager(), Add, true);
// overlay elements
loadComponentSingleFile(beatmapListing = new BeatmapListingOverlay(), overlayContent.Add, true);
loadComponentSingleFile(dashboard = new DashboardOverlay(), overlayContent.Add, true);
@ -643,7 +657,6 @@ namespace osu.Game
chatOverlay.State.ValueChanged += state => channelManager.HighPollRate.Value = state.NewValue == Visibility.Visible;
Add(externalLinkOpener = new ExternalLinkOpener());
Add(CreateUpdateManager()); // dependency on notification overlay
// side overlays which cancel each other.
var singleDisplaySideOverlays = new OverlayContainer[] { Settings, notifications };
@ -1000,4 +1013,10 @@ namespace osu.Game
Exit();
}
}
public enum ScorePresentType
{
Results,
Gameplay
}
}

View File

@ -20,6 +20,10 @@ namespace osu.Game.Overlays.BeatmapListing
[Description("Hip Hop")]
HipHop = 9,
Electronic = 10
Electronic = 10,
Metal = 11,
Classical = 12,
Folk = 13,
Jazz = 14
}
}

View File

@ -11,8 +11,8 @@ namespace osu.Game.Overlays.BeatmapListing
[Order(0)]
Any,
[Order(11)]
Other,
[Order(14)]
Unspecified,
[Order(1)]
English,
@ -23,7 +23,7 @@ namespace osu.Game.Overlays.BeatmapListing
[Order(2)]
Chinese,
[Order(10)]
[Order(12)]
Instrumental,
[Order(7)]
@ -42,6 +42,15 @@ namespace osu.Game.Overlays.BeatmapListing
Spanish,
[Order(5)]
Italian
Italian,
[Order(10)]
Russian,
[Order(11)]
Polish,
[Order(13)]
Other
}
}

View File

@ -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)

View File

@ -12,6 +12,7 @@ using osu.Game.Online.API.Requests.Responses;
using System.Threading;
using System.Linq;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Threading;
using osu.Game.Users;
namespace osu.Game.Overlays.Comments
@ -30,6 +31,7 @@ namespace osu.Game.Overlays.Comments
private IAPIProvider api { get; set; }
private GetCommentsRequest request;
private ScheduledDelegate scheduledCommentsLoad;
private CancellationTokenSource loadCancellation;
private int currentPage;
@ -152,8 +154,9 @@ namespace osu.Game.Overlays.Comments
request?.Cancel();
loadCancellation?.Cancel();
scheduledCommentsLoad?.Cancel();
request = new GetCommentsRequest(id.Value, type.Value, Sort.Value, currentPage++, 0);
request.Success += res => Schedule(() => onSuccess(res));
request.Success += res => scheduledCommentsLoad = Schedule(() => onSuccess(res));
api.PerformAsync(request);
}

View File

@ -1,19 +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 System.Threading.Tasks;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Game.Configuration;
using osu.Game.Overlays.Settings.Sections.Maintenance;
using osu.Game.Updater;
namespace osu.Game.Overlays.Settings.Sections.General
{
public class UpdateSettings : SettingsSubsection
{
[Resolved(CanBeNull = true)]
private UpdateManager updateManager { get; set; }
protected override string Header => "Updates";
private SettingsButton checkForUpdatesButton;
[BackgroundDependencyLoader(true)]
private void load(Storage storage, OsuConfigManager config, OsuGame game)
{
@ -23,6 +30,19 @@ namespace osu.Game.Overlays.Settings.Sections.General
Bindable = config.GetBindable<ReleaseStream>(OsuSetting.ReleaseStream),
});
if (updateManager?.CanCheckForUpdate == true)
{
Add(checkForUpdatesButton = new SettingsButton
{
Text = "Check for updates",
Action = () =>
{
checkForUpdatesButton.Enabled.Value = false;
Task.Run(updateManager.CheckForUpdateAsync).ContinueWith(t => Schedule(() => checkForUpdatesButton.Enabled.Value = true));
}
});
}
if (RuntimeInfo.IsDesktop)
{
Add(new SettingsButton

View File

@ -62,6 +62,7 @@ namespace osu.Game.Overlays.Toolbar
protected ConstrainedIconContainer IconContainer;
protected SpriteText DrawableText;
protected Box HoverBackground;
private readonly Box flashBackground;
private readonly FillFlowContainer tooltipContainer;
private readonly SpriteText tooltip1;
private readonly SpriteText tooltip2;
@ -82,6 +83,13 @@ namespace osu.Game.Overlays.Toolbar
Blending = BlendingParameters.Additive,
Alpha = 0,
},
flashBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Colour = Color4.White.Opacity(100),
Blending = BlendingParameters.Additive,
},
Flow = new FillFlowContainer
{
Direction = FillDirection.Horizontal,
@ -139,7 +147,7 @@ namespace osu.Game.Overlays.Toolbar
protected override bool OnClick(ClickEvent e)
{
HoverBackground.FlashColour(Color4.White.Opacity(100), 500, Easing.OutQuint);
flashBackground.FadeOutFromOne(800, Easing.OutQuint);
tooltipContainer.FadeOut(100);
return base.OnClick(e);
}

View File

@ -2,10 +2,12 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar
{
public class ToolbarHomeButton : ToolbarButton
public class ToolbarHomeButton : ToolbarButton, IKeyBindingHandler<GlobalAction>
{
public ToolbarHomeButton()
{
@ -13,5 +15,20 @@ namespace osu.Game.Overlays.Toolbar
TooltipMain = "Home";
TooltipSub = "Return to the main menu";
}
public bool OnPressed(GlobalAction action)
{
if (action == GlobalAction.Home)
{
Click();
return true;
}
return false;
}
public void OnReleased(GlobalAction action)
{
}
}
}

View File

@ -26,6 +26,9 @@ namespace osu.Game.Rulesets.Mods
[SettingSource("Final rate", "The final speed to ramp to")]
public abstract BindableNumber<double> FinalRate { get; }
[SettingSource("Adjust pitch", "Should pitch be adjusted with speed")]
public abstract BindableBool AdjustPitch { get; }
public override string SettingDescription => $"{InitialRate.Value:N2}x to {FinalRate.Value:N2}x";
private double finalRateTime;
@ -43,15 +46,16 @@ namespace osu.Game.Rulesets.Mods
protected ModTimeRamp()
{
// for preview purpose at song select. eventually we'll want to be able to update every frame.
FinalRate.BindValueChanged(val => applyAdjustment(1), true);
FinalRate.BindValueChanged(val => applyRateAdjustment(1), true);
AdjustPitch.BindValueChanged(applyPitchAdjustment);
}
public void ApplyToTrack(Track track)
{
this.track = track;
track.AddAdjustment(AdjustableProperty.Frequency, SpeedChange);
FinalRate.TriggerChange();
AdjustPitch.TriggerChange();
}
public virtual void ApplyToBeatmap(IBeatmap beatmap)
@ -66,14 +70,25 @@ namespace osu.Game.Rulesets.Mods
public virtual void Update(Playfield playfield)
{
applyAdjustment((track.CurrentTime - beginRampTime) / finalRateTime);
applyRateAdjustment((track.CurrentTime - beginRampTime) / finalRateTime);
}
/// <summary>
/// Adjust the rate along the specified ramp
/// </summary>
/// <param name="amount">The amount of adjustment to apply (from 0..1).</param>
private void applyAdjustment(double amount) =>
private void applyRateAdjustment(double amount) =>
SpeedChange.Value = InitialRate.Value + (FinalRate.Value - InitialRate.Value) * Math.Clamp(amount, 0, 1);
private void applyPitchAdjustment(ValueChangedEvent<bool> adjustPitchSetting)
{
// remove existing old adjustment
track.RemoveAdjustment(adjustmentForPitchSetting(adjustPitchSetting.OldValue), SpeedChange);
track.AddAdjustment(adjustmentForPitchSetting(adjustPitchSetting.NewValue), SpeedChange);
}
private AdjustableProperty adjustmentForPitchSetting(bool adjustPitchSettingValue)
=> adjustPitchSettingValue ? AdjustableProperty.Frequency : AdjustableProperty.Tempo;
}
}

View File

@ -37,6 +37,13 @@ namespace osu.Game.Rulesets.Mods
Precision = 0.01,
};
[SettingSource("Adjust pitch", "Should pitch be adjusted with speed")]
public override BindableBool AdjustPitch { get; } = new BindableBool
{
Default = true,
Value = true
};
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModWindUp)).ToArray();
}
}

View File

@ -37,6 +37,13 @@ namespace osu.Game.Rulesets.Mods
Precision = 0.01,
};
[SettingSource("Adjust pitch", "Should pitch be adjusted with speed")]
public override BindableBool AdjustPitch { get; } = new BindableBool
{
Default = true,
Value = true
};
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModWindDown)).ToArray();
}
}

View File

@ -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);
}

View File

@ -11,20 +11,13 @@ using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
using osu.Framework.Input.Events;
using osu.Framework.IO.Stores;
using osu.Game.Configuration;
using osu.Game.Graphics.Cursor;
using osu.Game.Input.Handlers;
@ -63,10 +56,6 @@ namespace osu.Game.Rulesets.UI
private readonly Lazy<Playfield> playfield;
private TextureStore textureStore;
private ISampleStore localSampleStore;
/// <summary>
/// The playfield.
/// </summary>
@ -113,6 +102,8 @@ namespace osu.Game.Rulesets.UI
private OnScreenDisplay onScreenDisplay;
private DrawableRulesetDependencies dependencies;
/// <summary>
/// Creates a ruleset visualisation for the provided ruleset and beatmap.
/// </summary>
@ -147,30 +138,13 @@ namespace osu.Game.Rulesets.UI
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies = new DrawableRulesetDependencies(Ruleset, base.CreateChildDependencies(parent));
var resources = Ruleset.CreateResourceStore();
if (resources != null)
{
textureStore = new TextureStore(new TextureLoaderStore(new NamespacedResourceStore<byte[]>(resources, "Textures")));
textureStore.AddStore(dependencies.Get<TextureStore>());
dependencies.Cache(textureStore);
localSampleStore = dependencies.Get<AudioManager>().GetSampleStore(new NamespacedResourceStore<byte[]>(resources, "Samples"));
localSampleStore.PlaybackConcurrency = OsuGameBase.SAMPLE_CONCURRENCY;
dependencies.CacheAs<ISampleStore>(new FallbackSampleStore(localSampleStore, dependencies.Get<ISampleStore>()));
}
Config = dependencies.RulesetConfigManager;
onScreenDisplay = dependencies.Get<OnScreenDisplay>();
Config = dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset);
if (Config != null)
{
dependencies.Cache(Config);
onScreenDisplay?.BeginTracking(this, Config);
}
return dependencies;
}
@ -362,13 +336,14 @@ namespace osu.Game.Rulesets.UI
{
base.Dispose(isDisposing);
localSampleStore?.Dispose();
if (Config != null)
{
onScreenDisplay?.StopTracking(this, Config);
Config = null;
}
// Dispose the components created by this dependency container.
dependencies?.Dispose();
}
}
@ -524,62 +499,4 @@ namespace osu.Game.Rulesets.UI
{
}
}
/// <summary>
/// A sample store which adds a fallback source.
/// </summary>
/// <remarks>
/// This is a temporary implementation to workaround ISampleStore limitations.
/// </remarks>
public class FallbackSampleStore : ISampleStore
{
private readonly ISampleStore primary;
private readonly ISampleStore secondary;
public FallbackSampleStore(ISampleStore primary, ISampleStore secondary)
{
this.primary = primary;
this.secondary = secondary;
}
public SampleChannel Get(string name) => primary.Get(name) ?? secondary.Get(name);
public Task<SampleChannel> GetAsync(string name) => primary.GetAsync(name) ?? secondary.GetAsync(name);
public Stream GetStream(string name) => primary.GetStream(name) ?? secondary.GetStream(name);
public IEnumerable<string> GetAvailableResources() => throw new NotSupportedException();
public void AddAdjustment(AdjustableProperty type, BindableNumber<double> adjustBindable) => throw new NotSupportedException();
public void RemoveAdjustment(AdjustableProperty type, BindableNumber<double> adjustBindable) => throw new NotSupportedException();
public BindableNumber<double> Volume => throw new NotSupportedException();
public BindableNumber<double> Balance => throw new NotSupportedException();
public BindableNumber<double> Frequency => throw new NotSupportedException();
public BindableNumber<double> Tempo => throw new NotSupportedException();
public IBindable<double> GetAggregate(AdjustableProperty type) => throw new NotSupportedException();
public IBindable<double> AggregateVolume => throw new NotSupportedException();
public IBindable<double> AggregateBalance => throw new NotSupportedException();
public IBindable<double> AggregateFrequency => throw new NotSupportedException();
public IBindable<double> AggregateTempo => throw new NotSupportedException();
public int PlaybackConcurrency
{
get => throw new NotSupportedException();
set => throw new NotSupportedException();
}
public void Dispose()
{
}
}
}

View File

@ -0,0 +1,148 @@
// 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.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores;
using osu.Game.Rulesets.Configuration;
namespace osu.Game.Rulesets.UI
{
public class DrawableRulesetDependencies : DependencyContainer, IDisposable
{
/// <summary>
/// The texture store to be used for the ruleset.
/// </summary>
public TextureStore TextureStore { get; }
/// <summary>
/// The sample store to be used for the ruleset.
/// </summary>
/// <remarks>
/// This is the local sample store pointing to the ruleset sample resources,
/// the cached sample store (<see cref="FallbackSampleStore"/>) retrieves from
/// this store and falls back to the parent store if this store doesn't have the requested sample.
/// </remarks>
public ISampleStore SampleStore { get; }
/// <summary>
/// The ruleset config manager.
/// </summary>
public IRulesetConfigManager RulesetConfigManager { get; private set; }
public DrawableRulesetDependencies(Ruleset ruleset, IReadOnlyDependencyContainer parent)
: base(parent)
{
var resources = ruleset.CreateResourceStore();
if (resources != null)
{
TextureStore = new TextureStore(new TextureLoaderStore(new NamespacedResourceStore<byte[]>(resources, @"Textures")));
TextureStore.AddStore(parent.Get<TextureStore>());
Cache(TextureStore);
SampleStore = parent.Get<AudioManager>().GetSampleStore(new NamespacedResourceStore<byte[]>(resources, @"Samples"));
SampleStore.PlaybackConcurrency = OsuGameBase.SAMPLE_CONCURRENCY;
CacheAs<ISampleStore>(new FallbackSampleStore(SampleStore, parent.Get<ISampleStore>()));
}
RulesetConfigManager = parent.Get<RulesetConfigCache>().GetConfigFor(ruleset);
if (RulesetConfigManager != null)
Cache(RulesetConfigManager);
}
#region Disposal
~DrawableRulesetDependencies()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private bool isDisposed;
protected void Dispose(bool disposing)
{
if (isDisposed)
return;
isDisposed = true;
SampleStore?.Dispose();
RulesetConfigManager = null;
}
#endregion
}
/// <summary>
/// A sample store which adds a fallback source.
/// </summary>
/// <remarks>
/// This is a temporary implementation to workaround ISampleStore limitations.
/// </remarks>
public class FallbackSampleStore : ISampleStore
{
private readonly ISampleStore primary;
private readonly ISampleStore secondary;
public FallbackSampleStore(ISampleStore primary, ISampleStore secondary)
{
this.primary = primary;
this.secondary = secondary;
}
public SampleChannel Get(string name) => primary.Get(name) ?? secondary.Get(name);
public Task<SampleChannel> GetAsync(string name) => primary.GetAsync(name) ?? secondary.GetAsync(name);
public Stream GetStream(string name) => primary.GetStream(name) ?? secondary.GetStream(name);
public IEnumerable<string> GetAvailableResources() => throw new NotSupportedException();
public void AddAdjustment(AdjustableProperty type, BindableNumber<double> adjustBindable) => throw new NotSupportedException();
public void RemoveAdjustment(AdjustableProperty type, BindableNumber<double> adjustBindable) => throw new NotSupportedException();
public BindableNumber<double> Volume => throw new NotSupportedException();
public BindableNumber<double> Balance => throw new NotSupportedException();
public BindableNumber<double> Frequency => throw new NotSupportedException();
public BindableNumber<double> Tempo => throw new NotSupportedException();
public IBindable<double> GetAggregate(AdjustableProperty type) => throw new NotSupportedException();
public IBindable<double> AggregateVolume => throw new NotSupportedException();
public IBindable<double> AggregateBalance => throw new NotSupportedException();
public IBindable<double> AggregateFrequency => throw new NotSupportedException();
public IBindable<double> AggregateTempo => throw new NotSupportedException();
public int PlaybackConcurrency
{
get => throw new NotSupportedException();
set => throw new NotSupportedException();
}
public void Dispose()
{
}
}
}

View File

@ -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;

View File

@ -18,6 +18,8 @@ namespace osu.Game.Scoring
protected override IQueryable<ScoreInfo> AddIncludesForConsumption(IQueryable<ScoreInfo> query)
=> base.AddIncludesForConsumption(query)
.Include(s => s.Beatmap)
.Include(s => s.Beatmap).ThenInclude(b => b.Metadata)
.Include(s => s.Beatmap).ThenInclude(b => b.BeatmapSet).ThenInclude(s => s.Metadata)
.Include(s => s.Ruleset);
}
}

View File

@ -44,8 +44,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
private readonly BindableList<HitObject> selectedHitObjects = new BindableList<HitObject>();
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
[Resolved(canBeNull: true)]
private IPositionSnapProvider snapProvider { get; set; }

View File

@ -11,6 +11,7 @@ using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osuTK;
namespace osu.Game.Screens.Edit.Compose.Components
{
@ -26,6 +27,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
private readonly Container<PlacementBlueprint> placementBlueprintContainer;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
private InputManager inputManager;
private readonly IEnumerable<DrawableHitObject> drawableHitObjects;

View File

@ -251,8 +251,9 @@ namespace osu.Game.Screens.Play
private class HardwareCorrectionOffsetClock : FramedOffsetClock
{
// we always want to apply the same real-time offset, so it should be adjusted by the playback rate to achieve this.
public override double CurrentTime => SourceTime + Offset * Rate;
// we always want to apply the same real-time offset, so it should be adjusted by the difference in playback rate (from realtime) to achieve this.
// base implementation already adds offset at 1.0 rate, so we only add the difference from that here.
public override double CurrentTime => base.CurrentTime + Offset * (Rate - 1);
public HardwareCorrectionOffsetClock(IClock source, bool processSource = true)
: base(source, processSource)

View File

@ -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

View File

@ -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);
}

View 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;
}
}
}

View File

@ -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:

View File

@ -51,7 +51,7 @@ namespace osu.Game.Storyboards.Drawables
LifetimeStart = sampleInfo.StartTime;
LifetimeEnd = double.MaxValue;
}
else if (Time.Current - Time.Elapsed < sampleInfo.StartTime)
else if (Time.Current - Time.Elapsed <= sampleInfo.StartTime)
{
// We've passed the start time of the sample. We only play the sample if we're within an allowable range
// from the sample's start, to reduce layering if we've been fast-forwarded far into the future

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Testing;
using osu.Game.Rulesets;
@ -15,17 +16,10 @@ namespace osu.Game.Tests.Visual
{
protected Editor Editor { get; private set; }
private readonly Ruleset ruleset;
protected EditorTestScene(Ruleset ruleset)
{
this.ruleset = ruleset;
}
[BackgroundDependencyLoader]
private void load()
{
Beatmap.Value = CreateWorkingBeatmap(ruleset.RulesetInfo);
Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
}
public override void SetUpSteps()
@ -37,6 +31,14 @@ namespace osu.Game.Tests.Visual
&& Editor.ChildrenOfType<TimelineArea>().FirstOrDefault()?.IsLoaded == true);
}
/// <summary>
/// Creates the ruleset for providing a corresponding beatmap to load the editor on.
/// </summary>
[NotNull]
protected abstract Ruleset CreateEditorRuleset();
protected sealed override Ruleset CreateRuleset() => CreateEditorRuleset();
protected virtual Editor CreateEditor() => new Editor();
}
}

View File

@ -10,13 +10,10 @@ namespace osu.Game.Tests.Visual
{
public abstract class ModPerfectTestScene : ModTestScene
{
private readonly Ruleset ruleset;
private readonly ModPerfect mod;
protected ModPerfectTestScene(Ruleset ruleset, ModPerfect mod)
: base(ruleset)
protected ModPerfectTestScene(ModPerfect mod)
{
this.ruleset = ruleset;
this.mod = mod;
}
@ -25,7 +22,7 @@ namespace osu.Game.Tests.Visual
Mod = mod,
Beatmap = new Beatmap
{
BeatmapInfo = { Ruleset = ruleset.RulesetInfo },
BeatmapInfo = { Ruleset = CreatePlayerRuleset().RulesetInfo },
HitObjects = { testData.HitObject }
},
Autoplay = !shouldMiss,

View File

@ -14,11 +14,6 @@ namespace osu.Game.Tests.Visual
{
protected sealed override bool HasCustomSteps => true;
protected ModTestScene(Ruleset ruleset)
: base(ruleset)
{
}
private ModTestData currentTestData;
protected void CreateModTest(ModTestData testData) => CreateTest(() =>

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@ -21,6 +22,7 @@ using osu.Game.Database;
using osu.Game.Online.API;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
using osu.Game.Screens;
using osu.Game.Storyboards;
using osu.Game.Tests.Beatmaps;
@ -37,6 +39,8 @@ namespace osu.Game.Tests.Visual
protected new OsuScreenDependencies Dependencies { get; private set; }
private DrawableRulesetDependencies rulesetDependencies;
private Lazy<Storage> localStorage;
protected Storage LocalStorage => localStorage.Value;
@ -65,7 +69,13 @@ namespace osu.Game.Tests.Visual
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
Dependencies = new OsuScreenDependencies(false, base.CreateChildDependencies(parent));
var baseDependencies = base.CreateChildDependencies(parent);
var providedRuleset = CreateRuleset();
if (providedRuleset != null)
baseDependencies = rulesetDependencies = new DrawableRulesetDependencies(providedRuleset, baseDependencies);
Dependencies = new OsuScreenDependencies(false, baseDependencies);
Beatmap = Dependencies.Beatmap;
Beatmap.SetDefault();
@ -125,6 +135,15 @@ namespace osu.Game.Tests.Visual
[Resolved]
protected AudioManager Audio { get; private set; }
/// <summary>
/// Creates the ruleset to be used for this test scene.
/// </summary>
/// <remarks>
/// When testing against ruleset-specific components, this method must be overriden to their corresponding ruleset.
/// </remarks>
[CanBeNull]
protected virtual Ruleset CreateRuleset() => null;
protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset);
protected WorkingBeatmap CreateWorkingBeatmap(RulesetInfo ruleset) =>
@ -136,13 +155,15 @@ namespace osu.Game.Tests.Visual
[BackgroundDependencyLoader]
private void load(RulesetStore rulesets)
{
Ruleset.Value = rulesets.AvailableRulesets.First();
Ruleset.Value = CreateRuleset()?.RulesetInfo ?? rulesets.AvailableRulesets.First();
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
rulesetDependencies?.Dispose();
if (Beatmap?.Value.TrackLoaded == true)
Beatmap.Value.Track.Stop();

View File

@ -3,6 +3,7 @@
using System;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Testing;
@ -19,15 +20,8 @@ namespace osu.Game.Tests.Visual
/// </summary>
protected virtual bool HasCustomSteps { get; } = false;
private readonly Ruleset ruleset;
protected TestPlayer Player;
protected PlayerTestScene(Ruleset ruleset)
{
this.ruleset = ruleset;
}
protected OsuConfigManager LocalConfig;
[BackgroundDependencyLoader]
@ -53,7 +47,7 @@ namespace osu.Game.Tests.Visual
action?.Invoke();
AddStep(ruleset.RulesetInfo.Name, LoadPlayer);
AddStep(CreatePlayerRuleset().Description, LoadPlayer);
AddUntilStep("player loaded", () => Player.IsLoaded && Player.Alpha == 1);
}
@ -63,11 +57,10 @@ namespace osu.Game.Tests.Visual
protected void LoadPlayer()
{
var ruleset = Ruleset.Value.CreateInstance();
var beatmap = CreateBeatmap(ruleset.RulesetInfo);
Beatmap.Value = CreateWorkingBeatmap(beatmap);
Ruleset.Value = ruleset.RulesetInfo;
SelectedMods.Value = Array.Empty<Mod>();
if (!AllowFail)
@ -88,6 +81,14 @@ namespace osu.Game.Tests.Visual
LoadScreen(Player);
}
/// <summary>
/// Creates the ruleset for setting up the <see cref="Player"/> component.
/// </summary>
[NotNull]
protected abstract Ruleset CreatePlayerRuleset();
protected sealed override Ruleset CreateRuleset() => CreatePlayerRuleset();
protected virtual TestPlayer CreatePlayer(Ruleset ruleset) => new TestPlayer(false, false);
}
}

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Graphics;
@ -32,9 +33,6 @@ namespace osu.Game.Tests.Visual
{
}
// Required to be part of the per-ruleset implementation to construct the newer version of the Ruleset.
protected abstract Ruleset CreateRulesetForSkinProvider();
[BackgroundDependencyLoader]
private void load(AudioManager audio, SkinManager skinManager)
{
@ -107,7 +105,7 @@ namespace osu.Game.Tests.Visual
{
new OutlineBox { Alpha = autoSize ? 1 : 0 },
mainProvider.WithChild(
new SkinProvidingContainer(CreateRulesetForSkinProvider().CreateLegacySkinProvider(mainProvider, beatmap))
new SkinProvidingContainer(Ruleset.Value.CreateInstance().CreateLegacySkinProvider(mainProvider, beatmap))
{
Child = created,
RelativeSizeAxes = !autoSize ? Axes.Both : Axes.None,
@ -120,6 +118,14 @@ namespace osu.Game.Tests.Visual
};
}
/// <summary>
/// Creates the ruleset for adding the corresponding skin transforming component.
/// </summary>
[NotNull]
protected abstract Ruleset CreateRulesetForSkinProvider();
protected sealed override Ruleset CreateRuleset() => CreateRulesetForSkinProvider();
protected virtual IBeatmap CreateBeatmapForSkinProvider() => CreateWorkingBeatmap(Ruleset.Value).GetPlayableBeatmap(Ruleset.Value);
private class OutlineBox : CompositeDrawable

View File

@ -28,12 +28,9 @@ namespace osu.Game.Updater
private void load(OsuGameBase game)
{
version = game.Version;
if (game.IsDeployedBuild)
Schedule(() => Task.Run(checkForUpdateAsync));
}
private async void checkForUpdateAsync()
protected override async Task PerformUpdateCheck()
{
try
{

View File

@ -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 System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -16,6 +17,13 @@ namespace osu.Game.Updater
/// </summary>
public class UpdateManager : CompositeDrawable
{
/// <summary>
/// Whether this UpdateManager should be or is capable of checking for updates.
/// </summary>
public bool CanCheckForUpdate => game.IsDeployedBuild &&
// only implementations will actually check for updates.
GetType() != typeof(UpdateManager);
[Resolved]
private OsuConfigManager config { get; set; }
@ -29,7 +37,10 @@ namespace osu.Game.Updater
{
base.LoadComplete();
Schedule(() => Task.Run(CheckForUpdateAsync));
var version = game.Version;
var lastVersion = config.Get<string>(OsuSetting.Version);
if (game.IsDeployedBuild && version != lastVersion)
@ -44,6 +55,28 @@ namespace osu.Game.Updater
config.Set(OsuSetting.Version, version);
}
private readonly object updateTaskLock = new object();
private Task updateCheckTask;
public async Task CheckForUpdateAsync()
{
if (!CanCheckForUpdate)
return;
Task waitTask;
lock (updateTaskLock)
waitTask = (updateCheckTask ??= PerformUpdateCheck());
await waitTask;
lock (updateTaskLock)
updateCheckTask = null;
}
protected virtual Task PerformUpdateCheck() => Task.CompletedTask;
private class UpdateCompleteNotification : SimpleNotification
{
private readonly string version;

View File

@ -24,7 +24,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.619.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.602.0" />
<PackageReference Include="Sentry" Version="2.1.3" />
<PackageReference Include="SharpCompress" Version="0.25.1" />

View File

@ -70,7 +70,7 @@
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.609.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.619.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.602.0" />
</ItemGroup>
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
@ -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.619.0" />
<PackageReference Include="SharpCompress" Version="0.25.1" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />