5 Commits

13 changed files with 99 additions and 40 deletions

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"dotnet.defaultSolution": "osu.Desktop.slnf"
}

View File

@@ -13,6 +13,7 @@ using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Formats;
using osu.Game.Configuration;
using osu.Game.Collections; using osu.Game.Collections;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions; using osu.Game.Extensions;
@@ -36,8 +37,8 @@ namespace osu.Game.Beatmaps
public ProcessBeatmapDelegate? ProcessBeatmap { private get; set; } public ProcessBeatmapDelegate? ProcessBeatmap { private get; set; }
public BeatmapImporter(Storage storage, RealmAccess realm) public BeatmapImporter(Storage storage, RealmAccess realm, OsuConfigManager? config)
: base(storage, realm) : base(storage, realm, config)
{ {
} }

View File

@@ -17,6 +17,7 @@ using osu.Framework.IO.Stores;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Formats;
using osu.Game.Configuration;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions; using osu.Game.Extensions;
using osu.Game.IO.Archives; using osu.Game.IO.Archives;
@@ -59,7 +60,7 @@ namespace osu.Game.Beatmaps
} }
public BeatmapManager(Storage storage, RealmAccess realm, IAPIProvider? api, AudioManager audioManager, IResourceStore<byte[]> gameResources, GameHost? host = null, public BeatmapManager(Storage storage, RealmAccess realm, IAPIProvider? api, AudioManager audioManager, IResourceStore<byte[]> gameResources, GameHost? host = null,
WorkingBeatmap? defaultBeatmap = null, BeatmapDifficultyCache? difficultyCache = null, bool performOnlineLookups = false) WorkingBeatmap? defaultBeatmap = null, BeatmapDifficultyCache? difficultyCache = null, bool performOnlineLookups = false, OsuConfigManager? config = null)
: base(storage, realm) : base(storage, realm)
{ {
if (performOnlineLookups) if (performOnlineLookups)
@@ -75,7 +76,7 @@ namespace osu.Game.Beatmaps
BeatmapTrackStore = audioManager.GetTrackStore(userResources); BeatmapTrackStore = audioManager.GetTrackStore(userResources);
beatmapImporter = CreateBeatmapImporter(storage, realm); beatmapImporter = CreateBeatmapImporter(storage, realm, config);
beatmapImporter.ProcessBeatmap = (beatmapSet, scope) => ProcessBeatmap?.Invoke(beatmapSet, scope); beatmapImporter.ProcessBeatmap = (beatmapSet, scope) => ProcessBeatmap?.Invoke(beatmapSet, scope);
beatmapImporter.PostNotification = obj => PostNotification?.Invoke(obj); beatmapImporter.PostNotification = obj => PostNotification?.Invoke(obj);
@@ -98,7 +99,7 @@ namespace osu.Game.Beatmaps
return new WorkingBeatmapCache(BeatmapTrackStore, audioManager, resources, storage, defaultBeatmap, host); return new WorkingBeatmapCache(BeatmapTrackStore, audioManager, resources, storage, defaultBeatmap, host);
} }
protected virtual BeatmapImporter CreateBeatmapImporter(Storage storage, RealmAccess realm) => new BeatmapImporter(storage, realm); protected virtual BeatmapImporter CreateBeatmapImporter(Storage storage, RealmAccess realm, OsuConfigManager? config = null) => new BeatmapImporter(storage, realm, config);
/// <summary> /// <summary>
/// Create a new beatmap set, backed by a <see cref="BeatmapSetInfo"/> model, /// Create a new beatmap set, backed by a <see cref="BeatmapSetInfo"/> model,

View File

@@ -202,6 +202,8 @@ namespace osu.Game.Configuration
SetDefault(OsuSetting.DiscordRichPresence, DiscordRichPresenceMode.Full); SetDefault(OsuSetting.DiscordRichPresence, DiscordRichPresenceMode.Full);
SetDefault(OsuSetting.DeleteImportedArchives, true);
SetDefault(OsuSetting.EditorDim, 0.25f, 0f, 0.75f, 0.25f); SetDefault(OsuSetting.EditorDim, 0.25f, 0f, 0.75f, 0.25f);
SetDefault(OsuSetting.EditorWaveformOpacity, 0.25f, 0f, 1f, 0.25f); SetDefault(OsuSetting.EditorWaveformOpacity, 0.25f, 0f, 1f, 0.25f);
SetDefault(OsuSetting.EditorShowHitMarkers, true); SetDefault(OsuSetting.EditorShowHitMarkers, true);
@@ -449,6 +451,7 @@ namespace osu.Game.Configuration
EditorShowHitMarkers, EditorShowHitMarkers,
EditorAutoSeekOnPlacement, EditorAutoSeekOnPlacement,
DiscordRichPresence, DiscordRichPresence,
DeleteImportedArchives,
ShowOnlineExplicitContent, ShowOnlineExplicitContent,
LastProcessedMetadataId, LastProcessedMetadataId,

View File

@@ -8,11 +8,14 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Humanizer; using Humanizer;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Configuration;
using osu.Game.Extensions; using osu.Game.Extensions;
using osu.Game.IO.Archives; using osu.Game.IO.Archives;
using osu.Game.Models; using osu.Game.Models;
@@ -77,11 +80,19 @@ namespace osu.Game.Database
/// </summary> /// </summary>
public Action<Notification>? PostNotification { get; set; } public Action<Notification>? PostNotification { get; set; }
protected RealmArchiveModelImporter(Storage storage, RealmAccess realm) private readonly OsuConfigManager? config;
private Bindable<bool>? deleteImportedArchives;
protected RealmArchiveModelImporter(Storage storage, RealmAccess realm, OsuConfigManager? config = null)
{ {
Realm = realm; Realm = realm;
Files = new RealmFileStore(realm, storage); Files = new RealmFileStore(realm, storage);
deleteImportedArchives = config?.GetBindable<bool>(OsuSetting.DeleteImportedArchives);
this.config = config;
} }
public Task Import(params string[] paths) => Import(paths.Select(p => new ImportTask(p)).ToArray()); public Task Import(params string[] paths) => Import(paths.Select(p => new ImportTask(p)).ToArray());
@@ -241,9 +252,10 @@ namespace osu.Game.Database
// e.g. reconstructing/repairing database with items from default storage. // e.g. reconstructing/repairing database with items from default storage.
// Also, not always a single file, i.e. for LegacyFilesystemReader // Also, not always a single file, i.e. for LegacyFilesystemReader
// TODO: Add a check to prevent files from storage to be deleted. // TODO: Add a check to prevent files from storage to be deleted.
bool allowDelete = deleteImportedArchives?.Value ?? true;
try try
{ {
if (import != null && ShouldDeleteArchive(task.Path)) if (import != null && ShouldDeleteArchive(task.Path) && allowDelete)
task.DeleteFile(); task.DeleteFile();
} }
catch (Exception e) catch (Exception e)

View File

@@ -59,9 +59,9 @@ namespace osu.Game.Graphics.Backgrounds
/// <summary> /// <summary>
/// Public method to trigger a refresh of categories from the UI. /// Public method to trigger a refresh of categories from the UI.
/// </summary> /// </summary>
public void RefreshCategories() public void RefreshCategories(bool ignoreSuccess = false)
{ {
fetchCategories(); fetchCategories(ignoreSuccess);
} }
private void fetchCategories(bool ignoreSuccess = false) private void fetchCategories(bool ignoreSuccess = false)
@@ -76,7 +76,8 @@ namespace osu.Game.Graphics.Backgrounds
AvailableCategories.Value = serverCategories.Distinct(StringComparer.OrdinalIgnoreCase).ToList(); AvailableCategories.Value = serverCategories.Distinct(StringComparer.OrdinalIgnoreCase).ToList();
if (!AvailableCategories.Value.Any()) { if (!AvailableCategories.Value.Any())
{
selectedCategory.Value = ""; selectedCategory.Value = "";
return; // we don't have any categories!!! return; // we don't have any categories!!!
} }

View File

@@ -298,7 +298,7 @@ namespace osu.Game
Audio.Samples.PlaybackConcurrency = SAMPLE_CONCURRENCY; Audio.Samples.PlaybackConcurrency = SAMPLE_CONCURRENCY;
dependencies.Cache(SkinManager = new SkinManager(Storage, realm, Host, Resources, Audio, Scheduler)); dependencies.Cache(SkinManager = new SkinManager(Storage, realm, Host, Resources, Audio, Scheduler, LocalConfig));
dependencies.CacheAs<ISkinSource>(SkinManager); dependencies.CacheAs<ISkinSource>(SkinManager);
EndpointConfiguration endpoints = CreateEndpoints(); EndpointConfiguration endpoints = CreateEndpoints();
@@ -322,7 +322,7 @@ namespace osu.Game
// ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup() // ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup()
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, realm, API, LocalConfig)); dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, realm, API, LocalConfig));
dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, realm, API, Audio, Resources, Host, defaultBeatmap, difficultyCache, performOnlineLookups: true)); dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, realm, API, Audio, Resources, Host, defaultBeatmap, difficultyCache, performOnlineLookups: true, config: LocalConfig));
dependencies.CacheAs<IWorkingBeatmapCache>(BeatmapManager); dependencies.CacheAs<IWorkingBeatmapCache>(BeatmapManager);
dependencies.Cache(BeatmapDownloader = new BeatmapModelDownloader(BeatmapManager, API)); dependencies.Cache(BeatmapDownloader = new BeatmapModelDownloader(BeatmapManager, API));

View File

@@ -8,6 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Configuration;
using osu.Game.Localisation; using osu.Game.Localisation;
using osu.Game.Screens; using osu.Game.Screens;
using osu.Game.Screens.Import; using osu.Game.Screens.Import;
@@ -22,13 +23,19 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
private ISystemFileSelector? selector; private ISystemFileSelector? selector;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuGameBase game, GameHost host, IPerformFromScreenRunner? performer) private void load(OsuGameBase game, GameHost host, IPerformFromScreenRunner? performer, OsuConfigManager config)
{ {
if ((selector = host.CreateSystemFileSelector(game.HandledExtensions.ToArray())) != null) if ((selector = host.CreateSystemFileSelector(game.HandledExtensions.ToArray())) != null)
selector.Selected += f => Task.Run(() => game.Import(f.FullName)); selector.Selected += f => Task.Run(() => game.Import(f.FullName));
AddRange(new Drawable[] AddRange(new Drawable[]
{ {
new SettingsCheckbox
{
LabelText = "Delete archives on import",
Current = config.GetBindable<bool>(OsuSetting.DeleteImportedArchives),
ClassicDefault = true
},
new SettingsButton new SettingsButton
{ {
Text = DebugSettingsStrings.ImportFiles, Text = DebugSettingsStrings.ImportFiles,
@@ -44,7 +51,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
{ {
Text = DebugSettingsStrings.RunLatencyCertifier, Text = DebugSettingsStrings.RunLatencyCertifier,
Action = () => performer?.PerformFromScreen(menu => menu.Push(new LatencyCertifierScreen())) Action = () => performer?.PerformFromScreen(menu => menu.Push(new LatencyCertifierScreen()))
} },
}); });
} }
} }

View File

@@ -5,16 +5,13 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Backgrounds;
using osu.Game.Localisation; using osu.Game.Localisation;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Settings;
namespace osu.Game.Overlays.Settings.Sections.UserInterface namespace osu.Game.Overlays.Settings.Sections.UserInterface
{ {
@@ -29,13 +26,13 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
private SettingsEnumDropdown<BackgroundSource> backgroundSourceDropdown; private SettingsEnumDropdown<BackgroundSource> backgroundSourceDropdown;
private Bindable<bool> useSeasonalBackgrounds;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config, IAPIProvider api) private void load(OsuConfigManager config, IAPIProvider api)
{ {
user = api.LocalUser.GetBoundCopy(); user = api.LocalUser.GetBoundCopy();
useSeasonalBackgrounds = config.GetBindable<bool>(OsuSetting.UseSeasonalBackgroundsV2);
var backgroundModeBindable = config.GetBindable<SeasonalBackgroundMode>(OsuSetting.SeasonalBackgroundMode);
var enabledProxyBindable = new Bindable<bool>();
var backgroundToggle = new SettingsCheckbox var backgroundToggle = new SettingsCheckbox
{ {
@@ -56,28 +53,21 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
Action = () => backgroundLoader.RefreshCategories() Action = () => backgroundLoader.RefreshCategories()
}; };
backgroundLoader.AvailableCategories.BindValueChanged(categories => categoryDropdown.Items = categories.NewValue, true); // TODO: the category dropdown disappear if no backgrounds (e.g. when first enabling the setting)
refreshButton.CanBeShown.BindTo(useSeasonalBackgrounds);
categoryDropdown.CanBeShown.BindTo(useSeasonalBackgrounds);
useSeasonalBackgrounds.BindValueChanged(
_ => backgroundLoader.RefreshCategories(true)
);
backgroundModeBindable.BindValueChanged(mode => backgroundLoader.AvailableCategories.BindValueChanged(categories => categoryDropdown.Items = categories.NewValue, true);
{
if (mode.NewValue == SeasonalBackgroundMode.Always)
{
categoryDropdown.Show();
refreshButton.Show();
}
else
{
categoryDropdown.Hide();
refreshButton.Hide();
}
}, true);
Children = new Drawable[] Children = new Drawable[]
{ {
new SettingsCheckbox new SettingsCheckbox
{ {
LabelText = UserInterfaceStrings.ShowMenuTips, LabelText = UserInterfaceStrings.ShowMenuTips,
Current = config.GetBindable<bool>(OsuSetting.MenuTips) Current = config.GetBindable<bool>(OsuSetting.MenuTips),
}, },
new SettingsCheckbox new SettingsCheckbox
{ {

View File

@@ -40,6 +40,7 @@ using osu.Game.Localisation;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Dialog;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
using osu.Game.Overlays.OSD; using osu.Game.Overlays.OSD;
using osu.Game.Rulesets; using osu.Game.Rulesets;
@@ -1312,6 +1313,8 @@ namespace osu.Game.Screens.Edit
yield return upload; yield return upload;
} }
yield return new EditorMenuItem("Remove all online IDs", MenuItemType.Destructive, anonymizeBeatmap);
if (editorBeatmap.BeatmapInfo.OnlineID > 0) if (editorBeatmap.BeatmapInfo.OnlineID > 0)
{ {
yield return new OsuMenuItemSpacer(); yield return new OsuMenuItemSpacer();
@@ -1396,6 +1399,41 @@ namespace osu.Game.Screens.Edit
void startSubmission() => this.Push(new BeatmapSubmissionScreen()); void startSubmission() => this.Push(new BeatmapSubmissionScreen());
} }
private void anonymizeBeatmap()
{
dialogOverlay.Push(new ConfirmDialog(
"Really remove online IDs?", () => attemptAsyncMutationOperation(anonymizeMaps))
);
Task anonymizeMaps()
{
var maps = editorBeatmap.BeatmapInfo.BeatmapSet.Beatmaps;
foreach (BeatmapInfo map in maps)
{
try
{
map.OnlineID = -1;
map.BeatmapSet.OnlineID = -1;
map.ResetOnlineInfo(true);
beatmapManager.Save(
map,
beatmapManager.GetWorkingBeatmap(map, true).Beatmap,
editorBeatmap.BeatmapSkin
);
}
catch (Exception ex)
{
Logger.Error(ex, ex.Message);
notifications?.Post(new SimpleErrorNotification { Text = "Failed to update beatmap difficulty!\nCheck logs for details" });
throw; // we don't want to handle it further, task will do it for us
}
}
updateLastSavedHash();
onScreenDisplay?.Display(new BeatmapEditorToast("Online IDs removed", editorBeatmap.BeatmapInfo.GetDisplayTitle()));
return Task.CompletedTask;
}
}
private void exportBeatmap(bool legacy) private void exportBeatmap(bool legacy)
{ {
if (HasUnsavedChanges) if (HasUnsavedChanges)

View File

@@ -260,7 +260,8 @@ namespace osu.Game.Screens.Menu
}; };
} }
public void UpdateColour() { public void UpdateColour()
{
if (triangles == null || colourBox == null) if (triangles == null || colourBox == null)
return; // we're still loading return; // we're still loading

View File

@@ -11,6 +11,7 @@ using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions; using osu.Game.Extensions;
using osu.Game.IO; using osu.Game.IO;
@@ -28,8 +29,8 @@ namespace osu.Game.Skinning
private readonly ModelManager<SkinInfo> modelManager; private readonly ModelManager<SkinInfo> modelManager;
public SkinImporter(Storage storage, RealmAccess realm, IStorageResourceProvider skinResources) public SkinImporter(Storage storage, RealmAccess realm, IStorageResourceProvider skinResources, OsuConfigManager? config = null)
: base(storage, realm) : base(storage, realm, config)
{ {
this.skinResources = skinResources; this.skinResources = skinResources;

View File

@@ -21,6 +21,7 @@ using osu.Framework.Platform;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Configuration;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
@@ -74,7 +75,7 @@ namespace osu.Game.Skinning
} }
} }
public SkinManager(Storage storage, RealmAccess realm, GameHost host, IResourceStore<byte[]> resources, AudioManager audio, Scheduler scheduler) public SkinManager(Storage storage, RealmAccess realm, GameHost host, IResourceStore<byte[]> resources, AudioManager audio, Scheduler scheduler, OsuConfigManager config)
: base(storage, realm) : base(storage, realm)
{ {
this.audio = audio; this.audio = audio;
@@ -84,7 +85,7 @@ namespace osu.Game.Skinning
userFiles = new StorageBackedResourceStore(storage.GetStorageForDirectory("files")); userFiles = new StorageBackedResourceStore(storage.GetStorageForDirectory("files"));
skinImporter = new SkinImporter(storage, realm, this) skinImporter = new SkinImporter(storage, realm, this, config)
{ {
PostNotification = obj => PostNotification?.Invoke(obj), PostNotification = obj => PostNotification?.Invoke(obj),
}; };