From 7d78a99991e79b40396f13b5da5bdbd70cd7e20c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 Oct 2024 20:08:05 +0900 Subject: [PATCH] Keep editor sidebars expanded by default They will not only contract if the user chooses to have them contract (new setting in the `View` menu) or if the game isn't wide enough to allow full interaction with the playfield while they are expanded. Addressess https://github.com/ppy/osu/discussions/28970. --- osu.Game/Configuration/OsuConfigManager.cs | 5 ++- osu.Game/Localisation/EditorStrings.cs | 5 +++ .../Edit/ExpandingToolboxContainer.cs | 34 +++++++++++++++++++ osu.Game/Screens/Edit/Editor.cs | 8 ++++- 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 8d6c244b350c..a16abe5c55f5 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -206,6 +206,8 @@ protected override void InitialiseDefaults() SetDefault(OsuSetting.EditorTimelineShowTimingChanges, true); SetDefault(OsuSetting.EditorTimelineShowTicks, true); + SetDefault(OsuSetting.EditorContractSidebars, false); + SetDefault(OsuSetting.AlwaysShowHoldForMenuButton, false); } @@ -431,6 +433,7 @@ public enum OsuSetting HideCountryFlags, EditorTimelineShowTimingChanges, EditorTimelineShowTicks, - AlwaysShowHoldForMenuButton + AlwaysShowHoldForMenuButton, + EditorContractSidebars } } diff --git a/osu.Game/Localisation/EditorStrings.cs b/osu.Game/Localisation/EditorStrings.cs index bcffc18d4d3c..f6cce554e97e 100644 --- a/osu.Game/Localisation/EditorStrings.cs +++ b/osu.Game/Localisation/EditorStrings.cs @@ -114,6 +114,11 @@ public static class EditorStrings /// public static LocalisableString LimitedDistanceSnap => new TranslatableString(getKey(@"limited_distance_snap_grid"), @"Limit distance snap placement to current time"); + /// + /// "Contract sidebars when not hovered" + /// + public static LocalisableString ContractSidebars => new TranslatableString(getKey(@"contract_sidebars"), @"Contract sidebars when not hovered"); + /// /// "Must be in edit mode to handle editor links" /// diff --git a/osu.Game/Rulesets/Edit/ExpandingToolboxContainer.cs b/osu.Game/Rulesets/Edit/ExpandingToolboxContainer.cs index c2ab5a6eb9be..9ae038dfb9ba 100644 --- a/osu.Game/Rulesets/Edit/ExpandingToolboxContainer.cs +++ b/osu.Game/Rulesets/Edit/ExpandingToolboxContainer.cs @@ -1,9 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Input.Events; +using osu.Game.Configuration; using osu.Game.Graphics.Containers; +using osu.Game.Screens.Edit; using osuTK; namespace osu.Game.Rulesets.Edit @@ -12,6 +16,15 @@ public partial class ExpandingToolboxContainer : ExpandingContainer { protected override double HoverExpansionDelay => 250; + protected override bool ExpandOnHover => expandOnHover; + + private readonly Bindable contractSidebars = new Bindable(); + + private bool expandOnHover; + + [Resolved] + private Editor editor { get; set; } = null!; + public ExpandingToolboxContainer(float contractedWidth, float expandedWidth) : base(contractedWidth, expandedWidth) { @@ -19,6 +32,27 @@ public ExpandingToolboxContainer(float contractedWidth, float expandedWidth) FillFlow.Spacing = new Vector2(5); FillFlow.Padding = new MarginPadding { Vertical = 5 }; + + Expanded.Value = true; + } + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + config.BindWith(OsuSetting.EditorContractSidebars, contractSidebars); + } + + protected override void Update() + { + base.Update(); + + bool requireContracting = contractSidebars.Value || editor.DrawSize.X / editor.DrawSize.Y < 1.7f; + + if (expandOnHover != requireContracting) + { + expandOnHover = requireContracting; + Expanded.Value = !expandOnHover; + } } protected override bool ReceivePositionalInputAtSubTree(Vector2 screenSpacePos) => base.ReceivePositionalInputAtSubTree(screenSpacePos) && anyToolboxHovered(screenSpacePos); diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index e9bcd3050bfc..e2dfbbcaf13e 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -215,6 +215,7 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl private Bindable editorLimitedDistanceSnap; private Bindable editorTimelineShowTimingChanges; private Bindable editorTimelineShowTicks; + private Bindable editorContractSidebars; /// /// This controls the opacity of components like the timelines, sidebars, etc. @@ -323,6 +324,7 @@ private void load(OsuConfigManager config) editorLimitedDistanceSnap = config.GetBindable(OsuSetting.EditorLimitedDistanceSnap); editorTimelineShowTimingChanges = config.GetBindable(OsuSetting.EditorTimelineShowTimingChanges); editorTimelineShowTicks = config.GetBindable(OsuSetting.EditorTimelineShowTicks); + editorContractSidebars = config.GetBindable(OsuSetting.EditorContractSidebars); AddInternal(new OsuContextMenuContainer { @@ -402,7 +404,11 @@ private void load(OsuConfigManager config) new ToggleMenuItem(EditorStrings.LimitedDistanceSnap) { State = { BindTarget = editorLimitedDistanceSnap }, - } + }, + new ToggleMenuItem(EditorStrings.ContractSidebars) + { + State = { BindTarget = editorContractSidebars } + }, } }, new MenuItem(EditorStrings.Timing)