Skip to content

Commit

Permalink
Merge pull request #30976 from frenzibyte/hide-some-settings
Browse files Browse the repository at this point in the history
Hide debug settings in release builds
  • Loading branch information
peppy authored Dec 5, 2024
2 parents 791416c + 1b1e7b6 commit 3d6e766
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 77 deletions.
25 changes: 0 additions & 25 deletions osu.Game/Localisation/DebugSettingsStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@ public static class DebugSettingsStrings
{
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>
Expand All @@ -34,16 +19,6 @@ public static class DebugSettingsStrings
/// </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}";
}
}
5 changes: 4 additions & 1 deletion osu.Game/Overlays/FirstRunSetup/ScreenBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -90,11 +91,13 @@ private void load(OsuColour colours)
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()
Expand Down
16 changes: 7 additions & 9 deletions osu.Game/Overlays/Settings/Sections/DebugSection.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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
{
Expand All @@ -22,12 +20,12 @@ public partial class DebugSection : SettingsSection

public DebugSection()
{
Add(new GeneralSettings());

if (DebugUtils.IsDebugBuild)
Add(new BatchImportSettings());

Add(new MemorySettings());
Children = new Drawable[]
{
new GeneralSettings(),
new BatchImportSettings(),
new MemorySettings(),
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,28 @@
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()))
}
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
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)
Expand All @@ -29,35 +28,35 @@ private void load(GameHost host, RealmAccess realm)
{
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",
},
};

blockAction.Action = () =>
{
try
{
IDisposable? token = realm.BlockAllOperations("maintenance");
IDisposable? token = realm.BlockAllOperations(@"maintenance");

blockAction.Enabled.Value = false;

Expand Down Expand Up @@ -89,7 +88,7 @@ void unblock()
}
catch (Exception e)
{
Logger.Error(e, "Blocking realm failed");
Logger.Error(e, @"Blocking realm failed");
}
};
}
Expand Down
36 changes: 36 additions & 0 deletions osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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()))
}
};
}
}
}
1 change: 1 addition & 0 deletions osu.Game/Overlays/Settings/Sections/MaintenanceSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public MaintenanceSection()
{
Children = new Drawable[]
{
new GeneralSettings(),
new BeatmapSettings(),
new SkinSettings(),
new CollectionsSettings(),
Expand Down
36 changes: 22 additions & 14 deletions osu.Game/Overlays/SettingsOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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;
Expand All @@ -27,21 +28,28 @@ public partial class SettingsOverlay : SettingsPanel, INamedOverlayComponent
public LocalisableString Title => SettingsStrings.HeaderTitle;
public LocalisableString Description => SettingsStrings.HeaderDescription;

protected override IEnumerable<SettingsSection> CreateSections() => new SettingsSection[]
protected override IEnumerable<SettingsSection> CreateSections()
{
// This list should be kept in sync with ScreenBehaviour.
new GeneralSection(),
new SkinSection(),
new InputSection(createSubPanel(new KeyBindingPanel())),
new UserInterfaceSection(),
new GameplaySection(),
new RulesetSection(),
new AudioSection(),
new GraphicsSection(),
new OnlineSection(),
new MaintenanceSection(),
new DebugSection(),
};
var sections = new List<SettingsSection>
{
// This list should be kept in sync with ScreenBehaviour.
new GeneralSection(),
new SkinSection(),
new InputSection(createSubPanel(new KeyBindingPanel())),
new UserInterfaceSection(),
new GameplaySection(),
new RulesetSection(),
new AudioSection(),
new GraphicsSection(),
new OnlineSection(),
new MaintenanceSection(),
};

if (DebugUtils.IsDebugBuild)
sections.Add(new DebugSection());

return sections;
}

private readonly List<SettingsSubPanel> subPanels = new List<SettingsSubPanel>();

Expand Down

0 comments on commit 3d6e766

Please sign in to comment.