1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-12 15:52:55 +08:00

Merge pull request #31026 from frenzibyte/ios-system-file-import

Add special handling for file import button on iOS
This commit is contained in:
Dean Herbert 2025-01-21 17:33:03 +09:00 committed by GitHub
commit 704c2ea0cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,8 +1,12 @@
// 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.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Platform;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Localisation; using osu.Game.Localisation;
using osu.Game.Screens; using osu.Game.Screens;
@ -15,22 +19,33 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
{ {
protected override LocalisableString Header => CommonStrings.General; protected override LocalisableString Header => CommonStrings.General;
private ISystemFileSelector? selector;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(IPerformFromScreenRunner? performer) private void load(OsuGameBase game, GameHost host, IPerformFromScreenRunner? performer)
{ {
Children = new[] if ((selector = host.CreateSystemFileSelector(game.HandledExtensions.ToArray())) != null)
selector.Selected += f => Task.Run(() => game.Import(f.FullName));
AddRange(new Drawable[]
{ {
new SettingsButton new SettingsButton
{ {
Text = DebugSettingsStrings.ImportFiles, Text = DebugSettingsStrings.ImportFiles,
Action = () => performer?.PerformFromScreen(menu => menu.Push(new FileImportScreen())) Action = () =>
{
if (selector != null)
selector.Present();
else
performer?.PerformFromScreen(menu => menu.Push(new FileImportScreen()));
},
}, },
new SettingsButton new SettingsButton
{ {
Text = DebugSettingsStrings.RunLatencyCertifier, Text = DebugSettingsStrings.RunLatencyCertifier,
Action = () => performer?.PerformFromScreen(menu => menu.Push(new LatencyCertifierScreen())) Action = () => performer?.PerformFromScreen(menu => menu.Push(new LatencyCertifierScreen()))
} }
}; });
} }
} }
} }