mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 19:53:23 +08:00
Merge branch 'master' into clock
This commit is contained in:
commit
e658b63dbc
@ -26,14 +26,6 @@
|
|||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Label="Project">
|
|
||||||
<!--
|
|
||||||
NU1701:
|
|
||||||
DeepEqual is not netstandard-compatible. This is fine since we run tests with .NET Framework anyway.
|
|
||||||
This is required due to https://github.com/NuGet/Home/issues/5740
|
|
||||||
-->
|
|
||||||
<NoWarn>$(NoWarn);NU1701</NoWarn>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Label="Nuget">
|
<PropertyGroup Label="Nuget">
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
<Authors>ppy Pty Ltd</Authors>
|
<Authors>ppy Pty Ltd</Authors>
|
||||||
@ -42,7 +34,7 @@
|
|||||||
<RepositoryUrl>https://github.com/ppy/osu</RepositoryUrl>
|
<RepositoryUrl>https://github.com/ppy/osu</RepositoryUrl>
|
||||||
<PackageReleaseNotes>Automated release.</PackageReleaseNotes>
|
<PackageReleaseNotes>Automated release.</PackageReleaseNotes>
|
||||||
<Company>ppy Pty Ltd</Company>
|
<Company>ppy Pty Ltd</Company>
|
||||||
<Copyright>Copyright (c) 2021 ppy Pty Ltd</Copyright>
|
<Copyright>Copyright (c) 2022 ppy Pty Ltd</Copyright>
|
||||||
<PackageTags>osu game</PackageTags>
|
<PackageTags>osu game</PackageTags>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
2
LICENCE
2
LICENCE
@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2021 ppy Pty Ltd <contact@ppy.sh>.
|
Copyright (c) 2022 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<PackageProjectUrl>https://github.com/ppy/osu/blob/master/Templates</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/ppy/osu/blob/master/Templates</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/ppy/osu</RepositoryUrl>
|
<RepositoryUrl>https://github.com/ppy/osu</RepositoryUrl>
|
||||||
<PackageReleaseNotes>Automated release.</PackageReleaseNotes>
|
<PackageReleaseNotes>Automated release.</PackageReleaseNotes>
|
||||||
<copyright>Copyright (c) 2021 ppy Pty Ltd</copyright>
|
<copyright>Copyright (c) 2022 ppy Pty Ltd</copyright>
|
||||||
<Description>Templates to use when creating a ruleset for consumption in osu!.</Description>
|
<Description>Templates to use when creating a ruleset for consumption in osu!.</Description>
|
||||||
<PackageTags>dotnet-new;templates;osu</PackageTags>
|
<PackageTags>dotnet-new;templates;osu</PackageTags>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
|
@ -51,8 +51,8 @@
|
|||||||
<Reference Include="Java.Interop" />
|
<Reference Include="Java.Interop" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.405.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.407.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.404.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.405.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Transitive Dependencies">
|
<ItemGroup Label="Transitive Dependencies">
|
||||||
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->
|
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="Clowd.Squirrel" Version="2.8.28-pre" />
|
<PackageReference Include="Clowd.Squirrel" Version="2.8.28-pre" />
|
||||||
<PackageReference Include="Microsoft.NETCore.Targets" Version="5.0.0" />
|
|
||||||
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
|
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
|
||||||
<PackageReference Include="System.IO.Packaging" Version="6.0.0" />
|
<PackageReference Include="System.IO.Packaging" Version="6.0.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" />
|
||||||
@ -33,7 +32,6 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
|
|
||||||
<PackageReference Include="DiscordRichPresence" Version="1.0.175" />
|
<PackageReference Include="DiscordRichPresence" Version="1.0.175" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Resources">
|
<ItemGroup Label="Resources">
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||||
<description>A free-to-win rhythm game. Rhythm is just a *click* away!</description>
|
<description>A free-to-win rhythm game. Rhythm is just a *click* away!</description>
|
||||||
<releaseNotes>testing</releaseNotes>
|
<releaseNotes>testing</releaseNotes>
|
||||||
<copyright>Copyright (c) 2021 ppy Pty Ltd</copyright>
|
<copyright>Copyright (c) 2022 ppy Pty Ltd</copyright>
|
||||||
<language>en-AU</language>
|
<language>en-AU</language>
|
||||||
</metadata>
|
</metadata>
|
||||||
<files>
|
<files>
|
||||||
|
@ -69,6 +69,34 @@ namespace osu.Game.Tests.NonVisual.Skinning
|
|||||||
"Gameplay/osu/followpoint",
|
"Gameplay/osu/followpoint",
|
||||||
"followpoint", 1
|
"followpoint", 1
|
||||||
},
|
},
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
// Looking up a filename with extension specified should work.
|
||||||
|
new[] { "followpoint.png" },
|
||||||
|
"followpoint.png",
|
||||||
|
"followpoint.png", 1
|
||||||
|
},
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
// Looking up a filename with extension specified should also work with @2x sprites.
|
||||||
|
new[] { "followpoint@2x.png" },
|
||||||
|
"followpoint.png",
|
||||||
|
"followpoint@2x.png", 2
|
||||||
|
},
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
// Looking up a path with extension specified should work.
|
||||||
|
new[] { "Gameplay/osu/followpoint.png" },
|
||||||
|
"Gameplay/osu/followpoint.png",
|
||||||
|
"Gameplay/osu/followpoint.png", 1
|
||||||
|
},
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
// Looking up a path with extension specified should also work with @2x sprites.
|
||||||
|
new[] { "Gameplay/osu/followpoint@2x.png" },
|
||||||
|
"Gameplay/osu/followpoint.png",
|
||||||
|
"Gameplay/osu/followpoint@2x.png", 2
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
[TestCaseSource(nameof(fallbackTestCases))]
|
[TestCaseSource(nameof(fallbackTestCases))]
|
||||||
|
@ -150,10 +150,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddStep("import score", () => imported = scoreManager.Import(getScoreInfo(true)));
|
AddStep("import score", () => imported = scoreManager.Import(getScoreInfo(true)));
|
||||||
|
|
||||||
AddUntilStep("state is available", () => downloadButton.State.Value == DownloadState.LocallyAvailable);
|
AddUntilStep("state is available", () => downloadButton.State.Value == DownloadState.LocallyAvailable);
|
||||||
|
AddAssert("button is enabled", () => downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
|
||||||
|
|
||||||
AddStep("delete score", () => scoreManager.Delete(imported.Value));
|
AddStep("delete score", () => scoreManager.Delete(imported.Value));
|
||||||
|
|
||||||
AddUntilStep("state is not downloaded", () => downloadButton.State.Value == DownloadState.NotDownloaded);
|
AddUntilStep("state is not downloaded", () => downloadButton.State.Value == DownloadState.NotDownloaded);
|
||||||
|
AddAssert("button is not enabled", () => !downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -8,13 +8,12 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Framework.Extensions.TypeExtensions;
|
using osu.Framework.Extensions.TypeExtensions;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Database;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Overlays.Mods;
|
using osu.Game.Overlays.Mods;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -27,6 +26,7 @@ using osu.Game.Rulesets.Taiko.Mods;
|
|||||||
using osu.Game.Screens.OnlinePlay;
|
using osu.Game.Screens.OnlinePlay;
|
||||||
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
|
using osu.Game.Tests.Resources;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
@ -35,10 +35,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
private BeatmapManager manager;
|
private BeatmapManager manager;
|
||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
|
|
||||||
private List<BeatmapInfo> beatmaps;
|
private IList<BeatmapInfo> beatmaps => importedBeatmapSet?.PerformRead(s => s.Beatmaps) ?? new List<BeatmapInfo>();
|
||||||
|
|
||||||
private TestMultiplayerMatchSongSelect songSelect;
|
private TestMultiplayerMatchSongSelect songSelect;
|
||||||
|
|
||||||
|
private Live<BeatmapSetInfo> importedBeatmapSet;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(GameHost host, AudioManager audio)
|
private void load(GameHost host, AudioManager audio)
|
||||||
{
|
{
|
||||||
@ -46,44 +48,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, Realm, rulesets, null, audio, Resources, host, Beatmap.Default));
|
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, Realm, rulesets, null, audio, Resources, host, Beatmap.Default));
|
||||||
Dependencies.Cache(Realm);
|
Dependencies.Cache(Realm);
|
||||||
|
|
||||||
beatmaps = new List<BeatmapInfo>();
|
importedBeatmapSet = manager.Import(TestResources.CreateTestBeatmapSetInfo(8, rulesets.AvailableRulesets.ToArray()));
|
||||||
|
|
||||||
var metadata = new BeatmapMetadata
|
|
||||||
{
|
|
||||||
Artist = "Some Artist",
|
|
||||||
Title = "Some Beatmap",
|
|
||||||
Author = { Username = "Some Author" },
|
|
||||||
};
|
|
||||||
|
|
||||||
var beatmapSetInfo = new BeatmapSetInfo
|
|
||||||
{
|
|
||||||
OnlineID = 10,
|
|
||||||
Hash = Guid.NewGuid().ToString().ComputeMD5Hash(),
|
|
||||||
DateAdded = DateTimeOffset.UtcNow
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
|
||||||
{
|
|
||||||
int beatmapId = 10 * 10 + i;
|
|
||||||
|
|
||||||
int length = RNG.Next(30000, 200000);
|
|
||||||
double bpm = RNG.NextSingle(80, 200);
|
|
||||||
|
|
||||||
var beatmap = new BeatmapInfo
|
|
||||||
{
|
|
||||||
Ruleset = rulesets.GetRuleset(i % 4) ?? throw new InvalidOperationException(),
|
|
||||||
OnlineID = beatmapId,
|
|
||||||
Length = length,
|
|
||||||
BPM = bpm,
|
|
||||||
Metadata = metadata,
|
|
||||||
Difficulty = new BeatmapDifficulty()
|
|
||||||
};
|
|
||||||
|
|
||||||
beatmaps.Add(beatmap);
|
|
||||||
beatmapSetInfo.Beatmaps.Add(beatmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
manager.Import(beatmapSetInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetUpSteps()
|
public override void SetUpSteps()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
@ -17,7 +16,6 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Models;
|
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Online.Leaderboards;
|
using osu.Game.Online.Leaderboards;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
@ -60,20 +58,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Size = new Vector2(550f, 450f),
|
Size = new Vector2(550f, 450f),
|
||||||
Scope = BeatmapLeaderboardScope.Local,
|
Scope = BeatmapLeaderboardScope.Local,
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = TestResources.CreateTestBeatmapSetInfo().Beatmaps.First()
|
||||||
{
|
|
||||||
ID = Guid.NewGuid(),
|
|
||||||
Metadata = new BeatmapMetadata
|
|
||||||
{
|
|
||||||
Title = "TestSong",
|
|
||||||
Artist = "TestArtist",
|
|
||||||
Author = new RealmUser
|
|
||||||
{
|
|
||||||
Username = "TestAuthor"
|
|
||||||
},
|
|
||||||
},
|
|
||||||
DifficultyName = "Insane"
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dialogOverlay = new DialogOverlay()
|
dialogOverlay = new DialogOverlay()
|
||||||
|
140
osu.Game.Tests/Visual/UserInterface/TestSceneModSelectScreen.cs
Normal file
140
osu.Game.Tests/Visual/UserInterface/TestSceneModSelectScreen.cs
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
// 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.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Overlays.Mods;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestSceneModSelectScreen : OsuManualInputManagerTestScene
|
||||||
|
{
|
||||||
|
[Resolved]
|
||||||
|
private RulesetStore rulesetStore { get; set; }
|
||||||
|
|
||||||
|
private ModSelectScreen modSelectScreen;
|
||||||
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public void SetUpSteps()
|
||||||
|
{
|
||||||
|
AddStep("clear contents", Clear);
|
||||||
|
AddStep("reset ruleset", () => Ruleset.Value = rulesetStore.GetRuleset(0));
|
||||||
|
AddStep("reset mods", () => SelectedMods.SetDefault());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createScreen()
|
||||||
|
{
|
||||||
|
AddStep("create screen", () => Child = modSelectScreen = new ModSelectScreen
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
State = { Value = Visibility.Visible },
|
||||||
|
SelectedMods = { BindTarget = SelectedMods }
|
||||||
|
});
|
||||||
|
waitForColumnLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestStateChange()
|
||||||
|
{
|
||||||
|
createScreen();
|
||||||
|
AddStep("toggle state", () => modSelectScreen.ToggleVisibility());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestPreexistingSelection()
|
||||||
|
{
|
||||||
|
AddStep("set mods", () => SelectedMods.Value = new Mod[] { new OsuModAlternate(), new OsuModDaycore() });
|
||||||
|
createScreen();
|
||||||
|
AddUntilStep("two panels active", () => modSelectScreen.ChildrenOfType<ModPanel>().Count(panel => panel.Active.Value) == 2);
|
||||||
|
AddAssert("mod multiplier correct", () =>
|
||||||
|
{
|
||||||
|
double multiplier = SelectedMods.Value.Aggregate(1d, (m, mod) => m * mod.ScoreMultiplier);
|
||||||
|
return Precision.AlmostEquals(multiplier, modSelectScreen.ChildrenOfType<DifficultyMultiplierDisplay>().Single().Current.Value);
|
||||||
|
});
|
||||||
|
assertCustomisationToggleState(disabled: false, active: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestExternalSelection()
|
||||||
|
{
|
||||||
|
createScreen();
|
||||||
|
AddStep("set mods", () => SelectedMods.Value = new Mod[] { new OsuModAlternate(), new OsuModDaycore() });
|
||||||
|
AddUntilStep("two panels active", () => modSelectScreen.ChildrenOfType<ModPanel>().Count(panel => panel.Active.Value) == 2);
|
||||||
|
AddAssert("mod multiplier correct", () =>
|
||||||
|
{
|
||||||
|
double multiplier = SelectedMods.Value.Aggregate(1d, (m, mod) => m * mod.ScoreMultiplier);
|
||||||
|
return Precision.AlmostEquals(multiplier, modSelectScreen.ChildrenOfType<DifficultyMultiplierDisplay>().Single().Current.Value);
|
||||||
|
});
|
||||||
|
assertCustomisationToggleState(disabled: false, active: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRulesetChange()
|
||||||
|
{
|
||||||
|
createScreen();
|
||||||
|
changeRuleset(0);
|
||||||
|
changeRuleset(1);
|
||||||
|
changeRuleset(2);
|
||||||
|
changeRuleset(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCustomisationToggleState()
|
||||||
|
{
|
||||||
|
createScreen();
|
||||||
|
assertCustomisationToggleState(disabled: true, active: false);
|
||||||
|
|
||||||
|
AddStep("select customisable mod", () => SelectedMods.Value = new[] { new OsuModDoubleTime() });
|
||||||
|
assertCustomisationToggleState(disabled: false, active: false);
|
||||||
|
|
||||||
|
AddStep("select mod requiring configuration", () => SelectedMods.Value = new[] { new OsuModDifficultyAdjust() });
|
||||||
|
assertCustomisationToggleState(disabled: false, active: true);
|
||||||
|
|
||||||
|
AddStep("dismiss mod customisation", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(modSelectScreen.ChildrenOfType<ShearedToggleButton>().Single());
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("append another mod not requiring config", () => SelectedMods.Value = SelectedMods.Value.Append(new OsuModFlashlight()).ToArray());
|
||||||
|
assertCustomisationToggleState(disabled: false, active: false);
|
||||||
|
|
||||||
|
AddStep("select mod without configuration", () => SelectedMods.Value = new[] { new OsuModAutoplay() });
|
||||||
|
assertCustomisationToggleState(disabled: true, active: false);
|
||||||
|
|
||||||
|
AddStep("select mod requiring configuration", () => SelectedMods.Value = new[] { new OsuModDifficultyAdjust() });
|
||||||
|
assertCustomisationToggleState(disabled: false, active: true);
|
||||||
|
|
||||||
|
AddStep("select mod without configuration", () => SelectedMods.Value = new[] { new OsuModAutoplay() });
|
||||||
|
assertCustomisationToggleState(disabled: true, active: false); // config was dismissed without explicit user action.
|
||||||
|
}
|
||||||
|
|
||||||
|
private void waitForColumnLoad() => AddUntilStep("all column content loaded",
|
||||||
|
() => modSelectScreen.ChildrenOfType<ModColumn>().Any() && modSelectScreen.ChildrenOfType<ModColumn>().All(column => column.IsLoaded && column.ItemsLoaded));
|
||||||
|
|
||||||
|
private void changeRuleset(int id)
|
||||||
|
{
|
||||||
|
AddStep($"set ruleset to {id}", () => Ruleset.Value = rulesetStore.GetRuleset(id));
|
||||||
|
waitForColumnLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertCustomisationToggleState(bool disabled, bool active)
|
||||||
|
{
|
||||||
|
ShearedToggleButton getToggle() => modSelectScreen.ChildrenOfType<ShearedToggleButton>().Single();
|
||||||
|
|
||||||
|
AddAssert($"customisation toggle is {(disabled ? "" : "not ")}disabled", () => getToggle().Active.Disabled == disabled);
|
||||||
|
AddAssert($"customisation toggle is {(active ? "" : "not ")}active", () => getToggle().Active.Value == active);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,6 @@ using osu.Framework.Logging;
|
|||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
@ -152,24 +151,7 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
const double excess_length = 1000;
|
const double excess_length = 1000;
|
||||||
|
|
||||||
var lastObject = Beatmap?.HitObjects.LastOrDefault();
|
double length = (BeatmapInfo?.Length + excess_length) ?? emptyLength;
|
||||||
|
|
||||||
double length;
|
|
||||||
|
|
||||||
switch (lastObject)
|
|
||||||
{
|
|
||||||
case null:
|
|
||||||
length = emptyLength;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IHasDuration endTime:
|
|
||||||
length = endTime.EndTime + excess_length;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
length = lastObject.StartTime + excess_length;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return audioManager.Tracks.GetVirtual(length);
|
return audioManager.Tracks.GetVirtual(length);
|
||||||
}
|
}
|
||||||
|
44
osu.Game/Online/Multiplayer/MultiplayerClientExtensions.cs
Normal file
44
osu.Game/Online/Multiplayer/MultiplayerClientExtensions.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
using osu.Framework.Logging;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.Multiplayer
|
||||||
|
{
|
||||||
|
public static class MultiplayerClientExtensions
|
||||||
|
{
|
||||||
|
public static void FireAndForget(this Task task, Action? onSuccess = null, Action<Exception>? onError = null) =>
|
||||||
|
task.ContinueWith(t =>
|
||||||
|
{
|
||||||
|
if (t.IsFaulted)
|
||||||
|
{
|
||||||
|
Exception? exception = t.Exception;
|
||||||
|
|
||||||
|
if (exception is AggregateException ae)
|
||||||
|
exception = ae.InnerException;
|
||||||
|
|
||||||
|
Debug.Assert(exception != null);
|
||||||
|
|
||||||
|
string message = exception is HubException
|
||||||
|
// HubExceptions arrive with additional message context added, but we want to display the human readable message:
|
||||||
|
// "An unexpected error occurred invoking 'AddPlaylistItem' on the server.InvalidStateException: Can't enqueue more than 3 items at once."
|
||||||
|
// We generally use the message field for a user-parseable error (eventually to be replaced), so drop the first part for now.
|
||||||
|
? exception.Message.Substring(exception.Message.IndexOf(':') + 1).Trim()
|
||||||
|
: exception.Message;
|
||||||
|
|
||||||
|
Logger.Log(message, level: LogLevel.Important);
|
||||||
|
onError?.Invoke(exception);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
onSuccess?.Invoke();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
public class DifficultyMultiplierDisplay : CompositeDrawable, IHasCurrentValue<double>
|
public class DifficultyMultiplierDisplay : CompositeDrawable, IHasCurrentValue<double>
|
||||||
{
|
{
|
||||||
|
public const float HEIGHT = 42;
|
||||||
|
|
||||||
public Bindable<double> Current
|
public Bindable<double> Current
|
||||||
{
|
{
|
||||||
get => current.Current;
|
get => current.Current;
|
||||||
@ -42,13 +44,12 @@ namespace osu.Game.Overlays.Mods
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private OverlayColourProvider colourProvider { get; set; }
|
private OverlayColourProvider colourProvider { get; set; }
|
||||||
|
|
||||||
private const float height = 42;
|
|
||||||
private const float multiplier_value_area_width = 56;
|
private const float multiplier_value_area_width = 56;
|
||||||
private const float transition_duration = 200;
|
private const float transition_duration = 200;
|
||||||
|
|
||||||
public DifficultyMultiplierDisplay()
|
public DifficultyMultiplierDisplay()
|
||||||
{
|
{
|
||||||
Height = height;
|
Height = HEIGHT;
|
||||||
AutoSizeAxes = Axes.X;
|
AutoSizeAxes = Axes.X;
|
||||||
|
|
||||||
InternalChild = new Container
|
InternalChild = new Container
|
||||||
@ -145,8 +146,9 @@ namespace osu.Game.Overlays.Mods
|
|||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
current.BindValueChanged(_ => updateState(), true);
|
current.BindValueChanged(_ => updateState(), true);
|
||||||
FinishTransforms(true);
|
|
||||||
// required to prevent the counter initially rolling up from 0 to 1
|
// required to prevent the counter initially rolling up from 0 to 1
|
||||||
// due to `Current.Value` having a nonstandard default value of 1.
|
// due to `Current.Value` having a nonstandard default value of 1.
|
||||||
multiplierCounter.SetCountWithoutRolling(Current.Value);
|
multiplierCounter.SetCountWithoutRolling(Current.Value);
|
||||||
|
@ -31,6 +31,10 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
public class ModColumn : CompositeDrawable
|
public class ModColumn : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
public readonly Container TopLevelContent;
|
||||||
|
|
||||||
|
public readonly ModType ModType;
|
||||||
|
|
||||||
private Func<Mod, bool>? filter;
|
private Func<Mod, bool>? filter;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -48,7 +52,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly ModType modType;
|
public Bindable<IReadOnlyList<Mod>> SelectedMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||||
|
|
||||||
private readonly Key[]? toggleKeys;
|
private readonly Key[]? toggleKeys;
|
||||||
|
|
||||||
private readonly Bindable<Dictionary<ModType, IReadOnlyList<Mod>>> availableMods = new Bindable<Dictionary<ModType, IReadOnlyList<Mod>>>();
|
private readonly Bindable<Dictionary<ModType, IReadOnlyList<Mod>>> availableMods = new Bindable<Dictionary<ModType, IReadOnlyList<Mod>>>();
|
||||||
@ -69,95 +74,103 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
public ModColumn(ModType modType, bool allowBulkSelection, Key[]? toggleKeys = null)
|
public ModColumn(ModType modType, bool allowBulkSelection, Key[]? toggleKeys = null)
|
||||||
{
|
{
|
||||||
this.modType = modType;
|
ModType = modType;
|
||||||
this.toggleKeys = toggleKeys;
|
this.toggleKeys = toggleKeys;
|
||||||
|
|
||||||
Width = 320;
|
Width = 320;
|
||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
Shear = new Vector2(ModPanel.SHEAR_X, 0);
|
Shear = new Vector2(ModPanel.SHEAR_X, 0);
|
||||||
CornerRadius = ModPanel.CORNER_RADIUS;
|
|
||||||
Masking = true;
|
|
||||||
|
|
||||||
Container controlContainer;
|
Container controlContainer;
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Container
|
TopLevelContent = new Container
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Height = header_height + ModPanel.CORNER_RADIUS,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
headerBackground = new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Height = header_height + ModPanel.CORNER_RADIUS
|
|
||||||
},
|
|
||||||
headerText = new OsuTextFlowContainer(t =>
|
|
||||||
{
|
|
||||||
t.Font = OsuFont.TorusAlternate.With(size: 17);
|
|
||||||
t.Shadow = false;
|
|
||||||
t.Colour = Colour4.Black;
|
|
||||||
})
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
Shear = new Vector2(-ModPanel.SHEAR_X, 0),
|
|
||||||
Padding = new MarginPadding
|
|
||||||
{
|
|
||||||
Horizontal = 17,
|
|
||||||
Bottom = ModPanel.CORNER_RADIUS
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Container
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding { Top = header_height },
|
CornerRadius = ModPanel.CORNER_RADIUS,
|
||||||
Child = contentContainer = new Container
|
Masking = true,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
new Container
|
||||||
Masking = true,
|
|
||||||
CornerRadius = ModPanel.CORNER_RADIUS,
|
|
||||||
BorderThickness = 3,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
contentBackground = new Box
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = header_height + ModPanel.CORNER_RADIUS,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both
|
headerBackground = new Box
|
||||||
},
|
{
|
||||||
new GridContainer
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = header_height + ModPanel.CORNER_RADIUS
|
||||||
|
},
|
||||||
|
headerText = new OsuTextFlowContainer(t =>
|
||||||
|
{
|
||||||
|
t.Font = OsuFont.TorusAlternate.With(size: 17);
|
||||||
|
t.Shadow = false;
|
||||||
|
t.Colour = Colour4.Black;
|
||||||
|
})
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Shear = new Vector2(-ModPanel.SHEAR_X, 0),
|
||||||
|
Padding = new MarginPadding
|
||||||
|
{
|
||||||
|
Horizontal = 17,
|
||||||
|
Bottom = ModPanel.CORNER_RADIUS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding { Top = header_height },
|
||||||
|
Child = contentContainer = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
RowDimensions = new[]
|
Masking = true,
|
||||||
|
CornerRadius = ModPanel.CORNER_RADIUS,
|
||||||
|
BorderThickness = 3,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Dimension(GridSizeMode.AutoSize),
|
contentBackground = new Box
|
||||||
new Dimension()
|
|
||||||
},
|
|
||||||
Content = new[]
|
|
||||||
{
|
|
||||||
new Drawable[]
|
|
||||||
{
|
{
|
||||||
controlContainer = new Container
|
RelativeSizeAxes = Axes.Both
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Padding = new MarginPadding { Horizontal = 14 }
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
new Drawable[]
|
new GridContainer
|
||||||
{
|
{
|
||||||
new OsuScrollContainer
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
RowDimensions = new[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
ScrollbarOverlapsContent = false,
|
new Dimension()
|
||||||
Child = panelFlow = new FillFlowContainer<ModPanel>
|
},
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
controlContainer = new Container
|
||||||
AutoSizeAxes = Axes.Y,
|
{
|
||||||
Spacing = new Vector2(0, 7),
|
RelativeSizeAxes = Axes.X,
|
||||||
Padding = new MarginPadding(7)
|
Padding = new MarginPadding { Horizontal = 14 }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new NestedVerticalScrollContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
ClampExtension = 100,
|
||||||
|
ScrollbarOverlapsContent = false,
|
||||||
|
Child = panelFlow = new FillFlowContainer<ModPanel>
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Spacing = new Vector2(0, 7),
|
||||||
|
Padding = new MarginPadding(7)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,7 +206,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
private void createHeaderText()
|
private void createHeaderText()
|
||||||
{
|
{
|
||||||
IEnumerable<string> headerTextWords = modType.Humanize(LetterCasing.Title).Split(' ');
|
IEnumerable<string> headerTextWords = ModType.Humanize(LetterCasing.Title).Split(' ');
|
||||||
|
|
||||||
if (headerTextWords.Count() > 1)
|
if (headerTextWords.Count() > 1)
|
||||||
{
|
{
|
||||||
@ -209,7 +222,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
availableMods.BindTo(game.AvailableMods);
|
availableMods.BindTo(game.AvailableMods);
|
||||||
|
|
||||||
headerBackground.Colour = accentColour = colours.ForModType(modType);
|
headerBackground.Colour = accentColour = colours.ForModType(ModType);
|
||||||
|
|
||||||
if (toggleAllCheckbox != null)
|
if (toggleAllCheckbox != null)
|
||||||
{
|
{
|
||||||
@ -225,6 +238,12 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
availableMods.BindValueChanged(_ => Scheduler.AddOnce(updateMods));
|
availableMods.BindValueChanged(_ => Scheduler.AddOnce(updateMods));
|
||||||
|
SelectedMods.BindValueChanged(_ =>
|
||||||
|
{
|
||||||
|
// if a load is in progress, don't try to update the selection - the load flow will do so.
|
||||||
|
if (latestLoadTask == null)
|
||||||
|
updateActiveState();
|
||||||
|
});
|
||||||
updateMods();
|
updateMods();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +251,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
private void updateMods()
|
private void updateMods()
|
||||||
{
|
{
|
||||||
var newMods = ModUtils.FlattenMods(availableMods.Value.GetValueOrDefault(modType) ?? Array.Empty<Mod>()).ToList();
|
var newMods = ModUtils.FlattenMods(availableMods.Value.GetValueOrDefault(ModType) ?? Array.Empty<Mod>()).ToList();
|
||||||
|
|
||||||
if (newMods.SequenceEqual(panelFlow.Children.Select(p => p.Mod)))
|
if (newMods.SequenceEqual(panelFlow.Children.Select(p => p.Mod)))
|
||||||
return;
|
return;
|
||||||
@ -250,11 +269,20 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
panelFlow.ChildrenEnumerable = loaded;
|
panelFlow.ChildrenEnumerable = loaded;
|
||||||
|
|
||||||
foreach (var panel in panelFlow)
|
updateActiveState();
|
||||||
panel.Active.BindValueChanged(_ => updateToggleState());
|
updateToggleAllState();
|
||||||
updateToggleState();
|
|
||||||
|
|
||||||
updateFilter();
|
updateFilter();
|
||||||
|
|
||||||
|
foreach (var panel in panelFlow)
|
||||||
|
{
|
||||||
|
panel.Active.BindValueChanged(_ =>
|
||||||
|
{
|
||||||
|
updateToggleAllState();
|
||||||
|
SelectedMods.Value = panel.Active.Value
|
||||||
|
? SelectedMods.Value.Append(panel.Mod).ToArray()
|
||||||
|
: SelectedMods.Value.Except(new[] { panel.Mod }).ToArray();
|
||||||
|
});
|
||||||
|
}
|
||||||
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
|
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
|
||||||
loadTask.ContinueWith(_ =>
|
loadTask.ContinueWith(_ =>
|
||||||
{
|
{
|
||||||
@ -263,6 +291,12 @@ namespace osu.Game.Overlays.Mods
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateActiveState()
|
||||||
|
{
|
||||||
|
foreach (var panel in panelFlow)
|
||||||
|
panel.Active.Value = SelectedMods.Value.Contains(panel.Mod, EqualityComparer<Mod>.Default);
|
||||||
|
}
|
||||||
|
|
||||||
#region Bulk select / deselect
|
#region Bulk select / deselect
|
||||||
|
|
||||||
private const double initial_multiple_selection_delay = 120;
|
private const double initial_multiple_selection_delay = 120;
|
||||||
@ -297,7 +331,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateToggleState()
|
private void updateToggleAllState()
|
||||||
{
|
{
|
||||||
if (toggleAllCheckbox != null && !SelectionAnimationRunning)
|
if (toggleAllCheckbox != null && !SelectionAnimationRunning)
|
||||||
{
|
{
|
||||||
@ -399,7 +433,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
foreach (var modPanel in panelFlow)
|
foreach (var modPanel in panelFlow)
|
||||||
modPanel.ApplyFilter(Filter);
|
modPanel.ApplyFilter(Filter);
|
||||||
|
|
||||||
updateToggleState();
|
updateToggleAllState();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
392
osu.Game/Overlays/Mods/ModSelectScreen.cs
Normal file
392
osu.Game/Overlays/Mods/ModSelectScreen.cs
Normal file
@ -0,0 +1,392 @@
|
|||||||
|
// 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.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Layout;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Mods
|
||||||
|
{
|
||||||
|
public class ModSelectScreen : OsuFocusedOverlayContainer
|
||||||
|
{
|
||||||
|
[Cached]
|
||||||
|
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
public Bindable<IReadOnlyList<Mod>> SelectedMods { get; private set; } = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||||
|
|
||||||
|
protected override bool StartHidden => true;
|
||||||
|
|
||||||
|
private readonly BindableBool customisationVisible = new BindableBool();
|
||||||
|
|
||||||
|
private DifficultyMultiplierDisplay multiplierDisplay;
|
||||||
|
private ModSettingsArea modSettingsArea;
|
||||||
|
private FillFlowContainer<ModColumn> columnFlow;
|
||||||
|
private GridContainer grid;
|
||||||
|
private Container mainContent;
|
||||||
|
|
||||||
|
private PopupScreenTitle header;
|
||||||
|
private Container footer;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
RelativePositionAxes = Axes.Both;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
mainContent = new Container
|
||||||
|
{
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
grid = new GridContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
RowDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(),
|
||||||
|
new Dimension(GridSizeMode.Absolute, 75),
|
||||||
|
},
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
header = new PopupScreenTitle
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Title = "Mod Select",
|
||||||
|
Description = "Mods provide different ways to enjoy gameplay. Some have an effect on the score you can achieve during ranked play. Others are just for fun.",
|
||||||
|
Close = Hide
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
RelativePositionAxes = Axes.X,
|
||||||
|
X = 0.3f,
|
||||||
|
Height = DifficultyMultiplierDisplay.HEIGHT,
|
||||||
|
Margin = new MarginPadding
|
||||||
|
{
|
||||||
|
Horizontal = 100,
|
||||||
|
Vertical = 10
|
||||||
|
},
|
||||||
|
Child = multiplierDisplay = new DifficultyMultiplierDisplay
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Depth = float.MaxValue,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
RelativePositionAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuScrollContainer(Direction.Horizontal)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = false,
|
||||||
|
ClampExtension = 100,
|
||||||
|
ScrollbarOverlapsContent = false,
|
||||||
|
Child = columnFlow = new ModColumnContainer
|
||||||
|
{
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
Spacing = new Vector2(10, 0),
|
||||||
|
Margin = new MarginPadding { Right = 70 },
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new ModColumn(ModType.DifficultyReduction, false, new[] { Key.Q, Key.W, Key.E, Key.R, Key.T, Key.Y, Key.U, Key.I, Key.O, Key.P }),
|
||||||
|
new ModColumn(ModType.DifficultyIncrease, false, new[] { Key.A, Key.S, Key.D, Key.F, Key.G, Key.H, Key.J, Key.K, Key.L }),
|
||||||
|
new ModColumn(ModType.Automation, false, new[] { Key.Z, Key.X, Key.C, Key.V, Key.B, Key.N, Key.M }),
|
||||||
|
new ModColumn(ModType.Conversion, false),
|
||||||
|
new ModColumn(ModType.Fun, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new[] { Empty() }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
footer = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 50,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Colour = colourProvider.Background5
|
||||||
|
},
|
||||||
|
new ShearedToggleButton(200)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Margin = new MarginPadding { Vertical = 14, Left = 70 },
|
||||||
|
Text = "Mod Customisation",
|
||||||
|
Active = { BindTarget = customisationVisible }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new ClickToReturnContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
HandleMouse = { BindTarget = customisationVisible },
|
||||||
|
OnClicked = () => customisationVisible.Value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modSettingsArea = new ModSettingsArea
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Height = 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
columnFlow.Shear = new Vector2(ModPanel.SHEAR_X, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
((IBindable<IReadOnlyList<Mod>>)modSettingsArea.SelectedMods).BindTo(SelectedMods);
|
||||||
|
|
||||||
|
SelectedMods.BindValueChanged(val =>
|
||||||
|
{
|
||||||
|
updateMultiplier();
|
||||||
|
updateCustomisation(val);
|
||||||
|
updateSelectionFromBindable();
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
foreach (var column in columnFlow)
|
||||||
|
{
|
||||||
|
column.SelectedMods.BindValueChanged(_ => updateBindableFromSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
customisationVisible.BindValueChanged(_ => updateCustomisationVisualState(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateMultiplier()
|
||||||
|
{
|
||||||
|
double multiplier = 1.0;
|
||||||
|
|
||||||
|
foreach (var mod in SelectedMods.Value)
|
||||||
|
multiplier *= mod.ScoreMultiplier;
|
||||||
|
|
||||||
|
multiplierDisplay.Current.Value = multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCustomisation(ValueChangedEvent<IReadOnlyList<Mod>> valueChangedEvent)
|
||||||
|
{
|
||||||
|
bool anyCustomisableMod = false;
|
||||||
|
bool anyModWithRequiredCustomisationAdded = false;
|
||||||
|
|
||||||
|
foreach (var mod in SelectedMods.Value)
|
||||||
|
{
|
||||||
|
anyCustomisableMod |= mod.GetSettingsSourceProperties().Any();
|
||||||
|
anyModWithRequiredCustomisationAdded |= !valueChangedEvent.OldValue.Contains(mod) && mod.RequiresConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (anyCustomisableMod)
|
||||||
|
{
|
||||||
|
customisationVisible.Disabled = false;
|
||||||
|
|
||||||
|
if (anyModWithRequiredCustomisationAdded && !customisationVisible.Value)
|
||||||
|
customisationVisible.Value = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (customisationVisible.Value)
|
||||||
|
customisationVisible.Value = false;
|
||||||
|
|
||||||
|
customisationVisible.Disabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCustomisationVisualState()
|
||||||
|
{
|
||||||
|
const double transition_duration = 300;
|
||||||
|
|
||||||
|
grid.FadeColour(customisationVisible.Value ? Colour4.Gray : Colour4.White, transition_duration, Easing.InOutCubic);
|
||||||
|
|
||||||
|
float modAreaHeight = customisationVisible.Value ? ModSettingsArea.HEIGHT : 0;
|
||||||
|
|
||||||
|
modSettingsArea.ResizeHeightTo(modAreaHeight, transition_duration, Easing.InOutCubic);
|
||||||
|
mainContent.TransformTo(nameof(Margin), new MarginPadding { Bottom = modAreaHeight }, transition_duration, Easing.InOutCubic);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool selectionBindableSyncInProgress;
|
||||||
|
|
||||||
|
private void updateSelectionFromBindable()
|
||||||
|
{
|
||||||
|
if (selectionBindableSyncInProgress)
|
||||||
|
return;
|
||||||
|
|
||||||
|
selectionBindableSyncInProgress = true;
|
||||||
|
|
||||||
|
foreach (var column in columnFlow)
|
||||||
|
column.SelectedMods.Value = SelectedMods.Value.Where(mod => mod.Type == column.ModType).ToArray();
|
||||||
|
|
||||||
|
selectionBindableSyncInProgress = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBindableFromSelection()
|
||||||
|
{
|
||||||
|
if (selectionBindableSyncInProgress)
|
||||||
|
return;
|
||||||
|
|
||||||
|
selectionBindableSyncInProgress = true;
|
||||||
|
|
||||||
|
SelectedMods.Value = columnFlow.SelectMany(column => column.SelectedMods.Value).ToArray();
|
||||||
|
|
||||||
|
selectionBindableSyncInProgress = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PopIn()
|
||||||
|
{
|
||||||
|
const double fade_in_duration = 400;
|
||||||
|
|
||||||
|
base.PopIn();
|
||||||
|
this.FadeIn(fade_in_duration, Easing.OutQuint);
|
||||||
|
|
||||||
|
header.MoveToY(0, fade_in_duration, Easing.OutQuint);
|
||||||
|
footer.MoveToY(0, fade_in_duration, Easing.OutQuint);
|
||||||
|
|
||||||
|
multiplierDisplay
|
||||||
|
.Delay(fade_in_duration * 0.65f)
|
||||||
|
.FadeIn(fade_in_duration / 2, Easing.OutQuint)
|
||||||
|
.ScaleTo(1, fade_in_duration, Easing.OutElastic);
|
||||||
|
|
||||||
|
for (int i = 0; i < columnFlow.Count; i++)
|
||||||
|
{
|
||||||
|
columnFlow[i].TopLevelContent
|
||||||
|
.Delay(i * 30)
|
||||||
|
.MoveToY(0, fade_in_duration, Easing.OutQuint)
|
||||||
|
.FadeIn(fade_in_duration, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PopOut()
|
||||||
|
{
|
||||||
|
const double fade_out_duration = 500;
|
||||||
|
|
||||||
|
base.PopOut();
|
||||||
|
this.FadeOut(fade_out_duration, Easing.OutQuint);
|
||||||
|
|
||||||
|
multiplierDisplay
|
||||||
|
.FadeOut(fade_out_duration / 2, Easing.OutQuint)
|
||||||
|
.ScaleTo(0.75f, fade_out_duration, Easing.OutQuint);
|
||||||
|
|
||||||
|
header.MoveToY(-header.DrawHeight, fade_out_duration, Easing.OutQuint);
|
||||||
|
footer.MoveToY(footer.DrawHeight, fade_out_duration, Easing.OutQuint);
|
||||||
|
|
||||||
|
for (int i = 0; i < columnFlow.Count; i++)
|
||||||
|
{
|
||||||
|
const float distance = 700;
|
||||||
|
|
||||||
|
columnFlow[i].TopLevelContent
|
||||||
|
.MoveToY(i % 2 == 0 ? -distance : distance, fade_out_duration, Easing.OutQuint)
|
||||||
|
.FadeOut(fade_out_duration, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ModColumnContainer : FillFlowContainer<ModColumn>
|
||||||
|
{
|
||||||
|
private readonly LayoutValue drawSizeLayout = new LayoutValue(Invalidation.DrawSize);
|
||||||
|
|
||||||
|
public ModColumnContainer()
|
||||||
|
{
|
||||||
|
AddLayout(drawSizeLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Add(ModColumn column)
|
||||||
|
{
|
||||||
|
base.Add(column);
|
||||||
|
|
||||||
|
Debug.Assert(column != null);
|
||||||
|
column.Shear = Vector2.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (!drawSizeLayout.IsValid)
|
||||||
|
{
|
||||||
|
Padding = new MarginPadding
|
||||||
|
{
|
||||||
|
Left = DrawHeight * ModPanel.SHEAR_X,
|
||||||
|
Bottom = 10
|
||||||
|
};
|
||||||
|
|
||||||
|
drawSizeLayout.Validate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ClickToReturnContainer : Container
|
||||||
|
{
|
||||||
|
public BindableBool HandleMouse { get; } = new BindableBool();
|
||||||
|
|
||||||
|
public Action OnClicked { get; set; }
|
||||||
|
|
||||||
|
protected override bool Handle(UIEvent e)
|
||||||
|
{
|
||||||
|
if (!HandleMouse.Value)
|
||||||
|
return base.Handle(e);
|
||||||
|
|
||||||
|
switch (e)
|
||||||
|
{
|
||||||
|
case ClickEvent _:
|
||||||
|
OnClicked?.Invoke();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case MouseEvent _:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.Handle(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
public Bindable<IReadOnlyList<Mod>> SelectedMods { get; } = new Bindable<IReadOnlyList<Mod>>();
|
public Bindable<IReadOnlyList<Mod>> SelectedMods { get; } = new Bindable<IReadOnlyList<Mod>>();
|
||||||
|
|
||||||
|
public const float HEIGHT = 250;
|
||||||
|
|
||||||
private readonly Box background;
|
private readonly Box background;
|
||||||
private readonly FillFlowContainer modSettingsFlow;
|
private readonly FillFlowContainer modSettingsFlow;
|
||||||
|
|
||||||
@ -32,7 +34,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
public ModSettingsArea()
|
public ModSettingsArea()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = 250;
|
Height = HEIGHT;
|
||||||
|
|
||||||
Anchor = Anchor.BottomRight;
|
Anchor = Anchor.BottomRight;
|
||||||
Origin = Anchor.BottomRight;
|
Origin = Anchor.BottomRight;
|
||||||
@ -52,6 +54,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
ScrollbarOverlapsContent = false,
|
ScrollbarOverlapsContent = false,
|
||||||
|
ClampExtension = 100,
|
||||||
Child = modSettingsFlow = new FillFlowContainer
|
Child = modSettingsFlow = new FillFlowContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.X,
|
AutoSizeAxes = Axes.X,
|
||||||
@ -155,9 +158,10 @@ namespace osu.Game.Overlays.Mods
|
|||||||
new[] { Empty() },
|
new[] { Empty() },
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
{
|
{
|
||||||
new OsuScrollContainer(Direction.Vertical)
|
new NestedVerticalScrollContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
ClampExtension = 100,
|
||||||
Child = new FillFlowContainer
|
Child = new FillFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
48
osu.Game/Overlays/Mods/NestedVerticalScrollContainer.cs
Normal file
48
osu.Game/Overlays/Mods/NestedVerticalScrollContainer.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Mods
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A scroll container that handles the case of vertically scrolling content inside a larger horizontally scrolling parent container.
|
||||||
|
/// </summary>
|
||||||
|
public class NestedVerticalScrollContainer : OsuScrollContainer
|
||||||
|
{
|
||||||
|
private OsuScrollContainer? parentScrollContainer;
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
parentScrollContainer = this.FindClosestParent<OsuScrollContainer>();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnScroll(ScrollEvent e)
|
||||||
|
{
|
||||||
|
if (parentScrollContainer == null)
|
||||||
|
return base.OnScroll(e);
|
||||||
|
|
||||||
|
bool topRightInView = parentScrollContainer.ScreenSpaceDrawQuad.Contains(ScreenSpaceDrawQuad.TopRight);
|
||||||
|
bool bottomLeftInView = parentScrollContainer.ScreenSpaceDrawQuad.Contains(ScreenSpaceDrawQuad.BottomLeft);
|
||||||
|
|
||||||
|
// If not completely on-screen, handle scroll but also allow parent to scroll at the same time (to hopefully bring our content into full view).
|
||||||
|
if (!topRightInView || !bottomLeftInView)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool scrollingPastEnd = e.ScrollDelta.Y < 0 && IsScrolledToEnd();
|
||||||
|
bool scrollingPastStart = e.ScrollDelta.Y > 0 && Target <= 0;
|
||||||
|
|
||||||
|
// If at either of our extents, delegate scroll to the horizontal parent container.
|
||||||
|
if (scrollingPastStart || scrollingPastEnd)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return base.OnScroll(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -147,7 +147,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
bool loadThemedIntro()
|
bool loadThemedIntro()
|
||||||
{
|
{
|
||||||
var setInfo = beatmaps.QueryBeatmapSet(b => b.Hash == BeatmapHash);
|
var setInfo = beatmaps.QueryBeatmapSet(b => b.Protected && b.Hash == BeatmapHash);
|
||||||
|
|
||||||
if (setInfo == null)
|
if (setInfo == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -114,18 +114,17 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
|
|
||||||
bool isReady() => Client.LocalUser?.State == MultiplayerUserState.Ready || Client.LocalUser?.State == MultiplayerUserState.Spectating;
|
bool isReady() => Client.LocalUser?.State == MultiplayerUserState.Ready || Client.LocalUser?.State == MultiplayerUserState.Spectating;
|
||||||
|
|
||||||
void toggleReady() => Client.ToggleReady().ContinueWith(_ => endOperation());
|
void toggleReady() => Client.ToggleReady().FireAndForget(
|
||||||
|
onSuccess: endOperation,
|
||||||
|
onError: _ => endOperation());
|
||||||
|
|
||||||
void startMatch() => Client.StartMatch().ContinueWith(t =>
|
void startMatch() => Client.StartMatch().FireAndForget(onSuccess: () =>
|
||||||
{
|
{
|
||||||
// accessing Exception here silences any potential errors from the antecedent task
|
|
||||||
if (t.Exception != null)
|
|
||||||
{
|
|
||||||
// gameplay was not started due to an exception; unblock button.
|
|
||||||
endOperation();
|
|
||||||
}
|
|
||||||
|
|
||||||
// gameplay is starting, the button will be unblocked on load requested.
|
// gameplay is starting, the button will be unblocked on load requested.
|
||||||
|
}, onError: _ =>
|
||||||
|
{
|
||||||
|
// gameplay was not started due to an exception; unblock button.
|
||||||
|
endOperation();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,13 +30,15 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
private MultiplayerRoom room => multiplayerClient.Room;
|
private MultiplayerRoom room => multiplayerClient.Room;
|
||||||
|
|
||||||
private Sample countdownTickSample;
|
private Sample countdownTickSample;
|
||||||
|
private Sample countdownWarnSample;
|
||||||
|
private Sample countdownWarnFinalSample;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio)
|
private void load(AudioManager audio)
|
||||||
{
|
{
|
||||||
countdownTickSample = audio.Samples.Get(@"Multiplayer/countdown-tick");
|
countdownTickSample = audio.Samples.Get(@"Multiplayer/countdown-tick");
|
||||||
// disabled for now pending further work on sound effect
|
countdownWarnSample = audio.Samples.Get(@"Multiplayer/countdown-warn");
|
||||||
// countdownTickFinalSample = audio.Samples.Get(@"Multiplayer/countdown-tick-final");
|
countdownWarnFinalSample = audio.Samples.Get(@"Multiplayer/countdown-warn-final");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -102,8 +104,14 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
private void playTickSound(int secondsRemaining)
|
private void playTickSound(int secondsRemaining)
|
||||||
{
|
{
|
||||||
if (secondsRemaining < 10) countdownTickSample?.Play();
|
if (secondsRemaining < 10) countdownTickSample?.Play();
|
||||||
// disabled for now pending further work on sound effect
|
|
||||||
// if (secondsRemaining <= 3) countdownTickFinalSample?.Play();
|
if (secondsRemaining <= 3)
|
||||||
|
{
|
||||||
|
if (secondsRemaining > 0)
|
||||||
|
countdownWarnSample?.Play();
|
||||||
|
else
|
||||||
|
countdownWarnFinalSample?.Play();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateButtonText()
|
private void updateButtonText()
|
||||||
|
@ -62,7 +62,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
RequestDeletion = item => multiplayerClient.RemovePlaylistItem(item.ID);
|
RequestDeletion = item => multiplayerClient.RemovePlaylistItem(item.ID).FireAndForget();
|
||||||
|
|
||||||
multiplayerClient.RoomUpdated += onRoomUpdated;
|
multiplayerClient.RoomUpdated += onRoomUpdated;
|
||||||
onRoomUpdated();
|
onRoomUpdated();
|
||||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
// If gameplay wasn't finished, then we have a simple path back to the idle state by aborting gameplay.
|
// If gameplay wasn't finished, then we have a simple path back to the idle state by aborting gameplay.
|
||||||
if (!playerLoader.GameplayPassed)
|
if (!playerLoader.GameplayPassed)
|
||||||
{
|
{
|
||||||
client.AbortGameplay();
|
client.AbortGameplay().FireAndForget();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Logging;
|
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -76,40 +72,18 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
|
|
||||||
Task task = itemToEdit != null ? client.EditPlaylistItem(multiplayerItem) : client.AddPlaylistItem(multiplayerItem);
|
Task task = itemToEdit != null ? client.EditPlaylistItem(multiplayerItem) : client.AddPlaylistItem(multiplayerItem);
|
||||||
|
|
||||||
task.ContinueWith(t =>
|
task.FireAndForget(onSuccess: () => Schedule(() =>
|
||||||
{
|
{
|
||||||
Schedule(() =>
|
loadingLayer.Hide();
|
||||||
{
|
|
||||||
// If an error or server side trigger occurred this screen may have already exited by external means.
|
|
||||||
if (!this.IsCurrentScreen())
|
|
||||||
return;
|
|
||||||
|
|
||||||
loadingLayer.Hide();
|
|
||||||
|
|
||||||
if (t.IsFaulted)
|
|
||||||
{
|
|
||||||
Exception exception = t.Exception;
|
|
||||||
|
|
||||||
if (exception is AggregateException ae)
|
|
||||||
exception = ae.InnerException;
|
|
||||||
|
|
||||||
Debug.Assert(exception != null);
|
|
||||||
|
|
||||||
string message = exception is HubException
|
|
||||||
// HubExceptions arrive with additional message context added, but we want to display the human readable message:
|
|
||||||
// "An unexpected error occurred invoking 'AddPlaylistItem' on the server.InvalidStateException: Can't enqueue more than 3 items at once."
|
|
||||||
// We generally use the message field for a user-parseable error (eventually to be replaced), so drop the first part for now.
|
|
||||||
? exception.Message.Substring(exception.Message.IndexOf(':') + 1).Trim()
|
|
||||||
: exception.Message;
|
|
||||||
|
|
||||||
Logger.Log(message, level: LogLevel.Important);
|
|
||||||
Carousel.AllowSelection = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// If an error or server side trigger occurred this screen may have already exited by external means.
|
||||||
|
if (this.IsCurrentScreen())
|
||||||
this.Exit();
|
this.Exit();
|
||||||
});
|
}), onError: _ => Schedule(() =>
|
||||||
});
|
{
|
||||||
|
loadingLayer.Hide();
|
||||||
|
Carousel.AllowSelection = true;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -281,7 +281,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
if (client.Room == null)
|
if (client.Room == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
client.ChangeUserMods(mods.NewValue);
|
client.ChangeUserMods(mods.NewValue).FireAndForget();
|
||||||
|
|
||||||
modSettingChangeTracker = new ModSettingChangeTracker(mods.NewValue);
|
modSettingChangeTracker = new ModSettingChangeTracker(mods.NewValue);
|
||||||
modSettingChangeTracker.SettingChanged += onModSettingsChanged;
|
modSettingChangeTracker.SettingChanged += onModSettingsChanged;
|
||||||
@ -296,7 +296,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
if (client.Room == null)
|
if (client.Room == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
client.ChangeUserMods(UserMods.Value);
|
client.ChangeUserMods(UserMods.Value).FireAndForget();
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
if (client.Room == null)
|
if (client.Room == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
client.ChangeBeatmapAvailability(availability.NewValue);
|
client.ChangeBeatmapAvailability(availability.NewValue).FireAndForget();
|
||||||
|
|
||||||
if (availability.NewValue.State != DownloadState.LocallyAvailable)
|
if (availability.NewValue.State != DownloadState.LocallyAvailable)
|
||||||
{
|
{
|
||||||
|
@ -169,7 +169,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
Margin = new MarginPadding(4),
|
Margin = new MarginPadding(4),
|
||||||
Action = () => Client.KickUser(User.UserID),
|
Action = () => Client.KickUser(User.UserID).FireAndForget(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
|||||||
if (!Client.IsHost)
|
if (!Client.IsHost)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Client.TransferHost(targetUser);
|
Client.TransferHost(targetUser).FireAndForget();
|
||||||
}),
|
}),
|
||||||
new OsuMenuItem("Kick", MenuItemType.Destructive, () =>
|
new OsuMenuItem("Kick", MenuItemType.Destructive, () =>
|
||||||
{
|
{
|
||||||
@ -239,7 +239,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
|||||||
if (!Client.IsHost)
|
if (!Client.IsHost)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Client.KickUser(targetUser);
|
Client.KickUser(targetUser).FireAndForget();
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
|||||||
Client.SendMatchRequest(new ChangeTeamRequest
|
Client.SendMatchRequest(new ChangeTeamRequest
|
||||||
{
|
{
|
||||||
TeamID = ((Client.LocalUser?.MatchState as TeamVersusUserState)?.TeamID + 1) % 2 ?? 0,
|
TeamID = ((Client.LocalUser?.MatchState as TeamVersusUserState)?.TeamID + 1) % 2 ?? 0,
|
||||||
});
|
}).FireAndForget();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int? DisplayedTeam { get; private set; }
|
public int? DisplayedTeam { get; private set; }
|
||||||
|
@ -87,31 +87,33 @@ namespace osu.Game.Screens.Ranking
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
button.Enabled.Value = replayAvailability != ReplayAvailability.NotAvailable;
|
updateState();
|
||||||
updateTooltip();
|
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
State.BindValueChanged(state =>
|
State.BindValueChanged(state =>
|
||||||
{
|
{
|
||||||
button.State.Value = state.NewValue;
|
button.State.Value = state.NewValue;
|
||||||
updateTooltip();
|
updateState();
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTooltip()
|
private void updateState()
|
||||||
{
|
{
|
||||||
switch (replayAvailability)
|
switch (replayAvailability)
|
||||||
{
|
{
|
||||||
case ReplayAvailability.Local:
|
case ReplayAvailability.Local:
|
||||||
button.TooltipText = @"watch replay";
|
button.TooltipText = @"watch replay";
|
||||||
|
button.Enabled.Value = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ReplayAvailability.Online:
|
case ReplayAvailability.Online:
|
||||||
button.TooltipText = @"download replay";
|
button.TooltipText = @"download replay";
|
||||||
|
button.Enabled.Value = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
button.TooltipText = @"replay unavailable";
|
button.TooltipText = @"replay unavailable";
|
||||||
|
button.Enabled.Value = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -443,7 +443,9 @@ namespace osu.Game.Skinning
|
|||||||
string lookupName = name.Replace(@"@2x", string.Empty);
|
string lookupName = name.Replace(@"@2x", string.Empty);
|
||||||
|
|
||||||
float ratio = 2;
|
float ratio = 2;
|
||||||
var texture = Textures?.Get(@$"{lookupName}@2x", wrapModeS, wrapModeT);
|
string twoTimesFilename = $"{Path.ChangeExtension(lookupName, null)}@2x{Path.GetExtension(lookupName)}";
|
||||||
|
|
||||||
|
var texture = Textures?.Get(twoTimesFilename, wrapModeS, wrapModeT);
|
||||||
|
|
||||||
if (texture == null)
|
if (texture == null)
|
||||||
{
|
{
|
||||||
|
@ -5,8 +5,10 @@ using System;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Animations;
|
using osu.Framework.Graphics.Animations;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Storyboards.Drawables
|
namespace osu.Game.Storyboards.Drawables
|
||||||
@ -88,6 +90,14 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
LifetimeEnd = animation.EndTime;
|
LifetimeEnd = animation.EndTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override Vector2 GetCurrentDisplaySize()
|
||||||
|
{
|
||||||
|
Texture texture = (CurrentFrame as Sprite)?.Texture
|
||||||
|
?? ((CurrentFrame as SkinnableSprite)?.Drawable as Sprite)?.Texture;
|
||||||
|
|
||||||
|
return new Vector2(texture?.DisplayWidth ?? 0, texture?.DisplayHeight ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textureStore, Storyboard storyboard)
|
private void load(TextureStore textureStore, Storyboard storyboard)
|
||||||
{
|
{
|
||||||
|
@ -29,15 +29,14 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="5.0.14" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="5.0.14" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
|
||||||
<PackageReference Include="Microsoft.NETCore.Targets" Version="3.1.0" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
<PackageReference Include="ppy.LocalisationAnalyser" Version="2022.320.0">
|
<PackageReference Include="ppy.LocalisationAnalyser" Version="2022.320.0">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Realm" Version="10.10.0" />
|
<PackageReference Include="Realm" Version="10.10.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2022.404.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2022.405.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.405.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.407.0" />
|
||||||
<PackageReference Include="Sentry" Version="3.14.1" />
|
<PackageReference Include="Sentry" Version="3.14.1" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.30.1" />
|
<PackageReference Include="SharpCompress" Version="0.30.1" />
|
||||||
<PackageReference Include="NUnit" Version="3.13.2" />
|
<PackageReference Include="NUnit" Version="3.13.2" />
|
||||||
|
@ -61,8 +61,8 @@
|
|||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.404.0" />
|
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.405.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.405.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.407.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net6.0) -->
|
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net6.0) -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
@ -84,7 +84,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="5.0.14" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="5.0.14" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2022.404.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2022.405.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.30.1" />
|
<PackageReference Include="SharpCompress" Version="0.30.1" />
|
||||||
<PackageReference Include="NUnit" Version="3.13.2" />
|
<PackageReference Include="NUnit" Version="3.13.2" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
|
Loading…
Reference in New Issue
Block a user