Merge pull request #16423 from peppy/realm/manual-compact

Add button to compact realm on demand
This commit is contained in:
Dan Balasescu 2022-01-12 16:23:00 +09:00 committed by GitHub
commit 2e34887999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -44,6 +44,11 @@ public static class DebugSettingsStrings
/// </summary>
public static LocalisableString ClearAllCaches => new TranslatableString(getKey(@"clear_all_caches"), @"Clear all caches");
/// <summary>
/// "Compact realm"
/// </summary>
public static LocalisableString CompactRealm => new TranslatableString(getKey(@"compact_realm"), @"Compact realm");
private static string getKey(string key) => $"{prefix}:{key}";
}
}

View File

@ -6,6 +6,7 @@
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Framework.Platform;
using osu.Game.Database;
using osu.Game.Localisation;
namespace osu.Game.Overlays.Settings.Sections.DebugSettings
@ -15,7 +16,7 @@ public class MemorySettings : SettingsSubsection
protected override LocalisableString Header => DebugSettingsStrings.MemoryHeader;
[BackgroundDependencyLoader]
private void load(FrameworkDebugConfigManager config, GameHost host)
private void load(FrameworkDebugConfigManager config, GameHost host, RealmContextFactory realmFactory)
{
Children = new Drawable[]
{
@ -24,6 +25,17 @@ private void load(FrameworkDebugConfigManager config, GameHost host)
Text = DebugSettingsStrings.ClearAllCaches,
Action = host.Collect
},
new SettingsButton
{
Text = DebugSettingsStrings.CompactRealm,
Action = () =>
{
// Blocking operations implicitly causes a Compact().
using (realmFactory.BlockAllOperations())
{
}
}
},
};
}
}