1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 23:47:21 +08:00

Merge pull request #30976 from frenzibyte/hide-some-settings

Hide debug settings in release builds
This commit is contained in:
Dean Herbert 2024-12-05 00:24:26 -08:00 committed by GitHub
commit 3d6e766b32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 82 additions and 77 deletions

View File

@ -9,21 +9,6 @@ namespace osu.Game.Localisation
{
private const string prefix = @"osu.Game.Resources.Localisation.DebugSettings";
/// <summary>
/// "Debug"
/// </summary>
public static LocalisableString DebugSectionHeader => new TranslatableString(getKey(@"debug_section_header"), @"Debug");
/// <summary>
/// "Show log overlay"
/// </summary>
public static LocalisableString ShowLogOverlay => new TranslatableString(getKey(@"show_log_overlay"), @"Show log overlay");
/// <summary>
/// "Bypass front-to-back render pass"
/// </summary>
public static LocalisableString BypassFrontToBackPass => new TranslatableString(getKey(@"bypass_front_to_back_pass"), @"Bypass front-to-back render pass");
/// <summary>
/// "Import files"
/// </summary>
@ -34,16 +19,6 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString RunLatencyCertifier => new TranslatableString(getKey(@"run_latency_certifier"), @"Run latency certifier");
/// <summary>
/// "Memory"
/// </summary>
public static LocalisableString MemoryHeader => new TranslatableString(getKey(@"memory_header"), @"Memory");
/// <summary>
/// "Clear all caches"
/// </summary>
public static LocalisableString ClearAllCaches => new TranslatableString(getKey(@"clear_all_caches"), @"Clear all caches");
private static string getKey(string key) => $"{prefix}:{key}";
}
}

View File

@ -5,6 +5,7 @@
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Development;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
@ -90,11 +91,13 @@ namespace osu.Game.Overlays.FirstRunSetup
new GraphicsSection(),
new OnlineSection(),
new MaintenanceSection(),
new DebugSection(),
},
SearchTerm = SettingsItem<bool>.CLASSIC_DEFAULT_SEARCH_TERM,
}
};
if (DebugUtils.IsDebugBuild)
searchContainer.Add(new DebugSection());
}
private void applyClassic()

View File

@ -1,19 +1,17 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Development;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Localisation;
using osu.Game.Overlays.Settings.Sections.DebugSettings;
namespace osu.Game.Overlays.Settings.Sections
{
public partial class DebugSection : SettingsSection
{
public override LocalisableString Header => DebugSettingsStrings.DebugSectionHeader;
public override LocalisableString Header => @"Debug";
public override Drawable CreateIcon() => new SpriteIcon
{
@ -22,12 +20,12 @@ namespace osu.Game.Overlays.Settings.Sections
public DebugSection()
{
Add(new GeneralSettings());
if (DebugUtils.IsDebugBuild)
Add(new BatchImportSettings());
Add(new MemorySettings());
Children = new Drawable[]
{
new GeneralSettings(),
new BatchImportSettings(),
new MemorySettings(),
};
}
}
}

View File

@ -5,43 +5,28 @@ using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Framework.Screens;
using osu.Game.Localisation;
using osu.Game.Screens;
using osu.Game.Screens.Import;
using osu.Game.Screens.Utility;
namespace osu.Game.Overlays.Settings.Sections.DebugSettings
{
public partial class GeneralSettings : SettingsSubsection
{
protected override LocalisableString Header => CommonStrings.General;
protected override LocalisableString Header => @"General";
[BackgroundDependencyLoader]
private void load(FrameworkDebugConfigManager config, FrameworkConfigManager frameworkConfig, IPerformFromScreenRunner? performer)
private void load(FrameworkDebugConfigManager config, FrameworkConfigManager frameworkConfig)
{
Children = new Drawable[]
{
new SettingsCheckbox
{
LabelText = DebugSettingsStrings.ShowLogOverlay,
LabelText = @"Show log overlay",
Current = frameworkConfig.GetBindable<bool>(FrameworkSetting.ShowLogOverlay)
},
new SettingsCheckbox
{
LabelText = DebugSettingsStrings.BypassFrontToBackPass,
LabelText = @"Bypass front-to-back render pass",
Current = config.GetBindable<bool>(DebugSetting.BypassFrontToBackPass)
},
new SettingsButton
{
Text = DebugSettingsStrings.ImportFiles,
Action = () => performer?.PerformFromScreen(menu => menu.Push(new FileImportScreen()))
},
new SettingsButton
{
Text = DebugSettingsStrings.RunLatencyCertifier,
Action = () => performer?.PerformFromScreen(menu => menu.Push(new LatencyCertifierScreen()))
}
};
}
}

View File

@ -11,13 +11,12 @@ using osu.Framework.Localisation;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Database;
using osu.Game.Localisation;
namespace osu.Game.Overlays.Settings.Sections.DebugSettings
{
public partial class MemorySettings : SettingsSubsection
{
protected override LocalisableString Header => DebugSettingsStrings.MemoryHeader;
protected override LocalisableString Header => @"Memory";
[BackgroundDependencyLoader]
private void load(GameHost host, RealmAccess realm)
@ -29,27 +28,27 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings
{
new SettingsButton
{
Text = DebugSettingsStrings.ClearAllCaches,
Text = @"Clear all caches",
Action = host.Collect
},
new SettingsButton
{
Text = "Compact realm",
Text = @"Compact realm",
Action = () =>
{
// Blocking operations implicitly causes a Compact().
using (realm.BlockAllOperations("compact"))
using (realm.BlockAllOperations(@"compact"))
{
}
}
},
blockAction = new SettingsButton
{
Text = "Block realm",
Text = @"Block realm",
},
unblockAction = new SettingsButton
{
Text = "Unblock realm",
Text = @"Unblock realm",
},
};
@ -57,7 +56,7 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings
{
try
{
IDisposable? token = realm.BlockAllOperations("maintenance");
IDisposable? token = realm.BlockAllOperations(@"maintenance");
blockAction.Enabled.Value = false;
@ -89,7 +88,7 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings
}
catch (Exception e)
{
Logger.Error(e, "Blocking realm failed");
Logger.Error(e, @"Blocking realm failed");
}
};
}

View File

@ -0,0 +1,36 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Localisation;
using osu.Framework.Screens;
using osu.Game.Localisation;
using osu.Game.Screens;
using osu.Game.Screens.Import;
using osu.Game.Screens.Utility;
namespace osu.Game.Overlays.Settings.Sections.Maintenance
{
public partial class GeneralSettings : SettingsSubsection
{
protected override LocalisableString Header => CommonStrings.General;
[BackgroundDependencyLoader]
private void load(IPerformFromScreenRunner? performer)
{
Children = new[]
{
new SettingsButton
{
Text = DebugSettingsStrings.ImportFiles,
Action = () => performer?.PerformFromScreen(menu => menu.Push(new FileImportScreen()))
},
new SettingsButton
{
Text = DebugSettingsStrings.RunLatencyCertifier,
Action = () => performer?.PerformFromScreen(menu => menu.Push(new LatencyCertifierScreen()))
}
};
}
}
}

View File

@ -23,6 +23,7 @@ namespace osu.Game.Overlays.Settings.Sections
{
Children = new Drawable[]
{
new GeneralSettings(),
new BeatmapSettings(),
new SkinSettings(),
new CollectionsSettings(),

View File

@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Development;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -27,7 +28,9 @@ namespace osu.Game.Overlays
public LocalisableString Title => SettingsStrings.HeaderTitle;
public LocalisableString Description => SettingsStrings.HeaderDescription;
protected override IEnumerable<SettingsSection> CreateSections() => new SettingsSection[]
protected override IEnumerable<SettingsSection> CreateSections()
{
var sections = new List<SettingsSection>
{
// This list should be kept in sync with ScreenBehaviour.
new GeneralSection(),
@ -40,9 +43,14 @@ namespace osu.Game.Overlays
new GraphicsSection(),
new OnlineSection(),
new MaintenanceSection(),
new DebugSection(),
};
if (DebugUtils.IsDebugBuild)
sections.Add(new DebugSection());
return sections;
}
private readonly List<SettingsSubPanel> subPanels = new List<SettingsSubPanel>();
private SettingsSubPanel lastOpenedSubPanel;