1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-22 15:22:56 +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"; 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> /// <summary>
/// "Import files" /// "Import files"
/// </summary> /// </summary>
@ -34,16 +19,6 @@ namespace osu.Game.Localisation
/// </summary> /// </summary>
public static LocalisableString RunLatencyCertifier => new TranslatableString(getKey(@"run_latency_certifier"), @"Run latency certifier"); 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}"; private static string getKey(string key) => $"{prefix}:{key}";
} }
} }

View File

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

View File

@ -1,19 +1,17 @@
// 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 osu.Framework.Development;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Localisation;
using osu.Game.Overlays.Settings.Sections.DebugSettings; using osu.Game.Overlays.Settings.Sections.DebugSettings;
namespace osu.Game.Overlays.Settings.Sections namespace osu.Game.Overlays.Settings.Sections
{ {
public partial class DebugSection : SettingsSection public partial class DebugSection : SettingsSection
{ {
public override LocalisableString Header => DebugSettingsStrings.DebugSectionHeader; public override LocalisableString Header => @"Debug";
public override Drawable CreateIcon() => new SpriteIcon public override Drawable CreateIcon() => new SpriteIcon
{ {
@ -22,12 +20,12 @@ namespace osu.Game.Overlays.Settings.Sections
public DebugSection() public DebugSection()
{ {
Add(new GeneralSettings()); Children = new Drawable[]
{
if (DebugUtils.IsDebugBuild) new GeneralSettings(),
Add(new BatchImportSettings()); new BatchImportSettings(),
new MemorySettings(),
Add(new MemorySettings()); };
} }
} }
} }

View File

@ -5,43 +5,28 @@ using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Localisation; 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 namespace osu.Game.Overlays.Settings.Sections.DebugSettings
{ {
public partial class GeneralSettings : SettingsSubsection public partial class GeneralSettings : SettingsSubsection
{ {
protected override LocalisableString Header => CommonStrings.General; protected override LocalisableString Header => @"General";
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(FrameworkDebugConfigManager config, FrameworkConfigManager frameworkConfig, IPerformFromScreenRunner? performer) private void load(FrameworkDebugConfigManager config, FrameworkConfigManager frameworkConfig)
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
new SettingsCheckbox new SettingsCheckbox
{ {
LabelText = DebugSettingsStrings.ShowLogOverlay, LabelText = @"Show log overlay",
Current = frameworkConfig.GetBindable<bool>(FrameworkSetting.ShowLogOverlay) Current = frameworkConfig.GetBindable<bool>(FrameworkSetting.ShowLogOverlay)
}, },
new SettingsCheckbox new SettingsCheckbox
{ {
LabelText = DebugSettingsStrings.BypassFrontToBackPass, LabelText = @"Bypass front-to-back render pass",
Current = config.GetBindable<bool>(DebugSetting.BypassFrontToBackPass) 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.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Localisation;
namespace osu.Game.Overlays.Settings.Sections.DebugSettings namespace osu.Game.Overlays.Settings.Sections.DebugSettings
{ {
public partial class MemorySettings : SettingsSubsection public partial class MemorySettings : SettingsSubsection
{ {
protected override LocalisableString Header => DebugSettingsStrings.MemoryHeader; protected override LocalisableString Header => @"Memory";
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(GameHost host, RealmAccess realm) private void load(GameHost host, RealmAccess realm)
@ -29,27 +28,27 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings
{ {
new SettingsButton new SettingsButton
{ {
Text = DebugSettingsStrings.ClearAllCaches, Text = @"Clear all caches",
Action = host.Collect Action = host.Collect
}, },
new SettingsButton new SettingsButton
{ {
Text = "Compact realm", Text = @"Compact realm",
Action = () => Action = () =>
{ {
// Blocking operations implicitly causes a Compact(). // Blocking operations implicitly causes a Compact().
using (realm.BlockAllOperations("compact")) using (realm.BlockAllOperations(@"compact"))
{ {
} }
} }
}, },
blockAction = new SettingsButton blockAction = new SettingsButton
{ {
Text = "Block realm", Text = @"Block realm",
}, },
unblockAction = new SettingsButton unblockAction = new SettingsButton
{ {
Text = "Unblock realm", Text = @"Unblock realm",
}, },
}; };
@ -57,7 +56,7 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings
{ {
try try
{ {
IDisposable? token = realm.BlockAllOperations("maintenance"); IDisposable? token = realm.BlockAllOperations(@"maintenance");
blockAction.Enabled.Value = false; blockAction.Enabled.Value = false;
@ -89,7 +88,7 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings
} }
catch (Exception e) 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[] Children = new Drawable[]
{ {
new GeneralSettings(),
new BeatmapSettings(), new BeatmapSettings(),
new SkinSettings(), new SkinSettings(),
new CollectionsSettings(), new CollectionsSettings(),

View File

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