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

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.
This commit is contained in:
Dean Herbert 2024-10-22 20:08:05 +09:00
parent c15490ed58
commit e37d415c6f
No known key found for this signature in database
4 changed files with 50 additions and 2 deletions

View File

@ -206,6 +206,8 @@ namespace osu.Game.Configuration
SetDefault(OsuSetting.EditorTimelineShowTimingChanges, true);
SetDefault(OsuSetting.EditorTimelineShowTicks, true);
SetDefault(OsuSetting.EditorContractSidebars, false);
SetDefault(OsuSetting.AlwaysShowHoldForMenuButton, false);
}
@ -431,6 +433,7 @@ namespace osu.Game.Configuration
HideCountryFlags,
EditorTimelineShowTimingChanges,
EditorTimelineShowTicks,
AlwaysShowHoldForMenuButton
AlwaysShowHoldForMenuButton,
EditorContractSidebars
}
}

View File

@ -114,6 +114,11 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString LimitedDistanceSnap => new TranslatableString(getKey(@"limited_distance_snap_grid"), @"Limit distance snap placement to current time");
/// <summary>
/// "Contract sidebars when not hovered"
/// </summary>
public static LocalisableString ContractSidebars => new TranslatableString(getKey(@"contract_sidebars"), @"Contract sidebars when not hovered");
/// <summary>
/// "Must be in edit mode to handle editor links"
/// </summary>

View File

@ -1,9 +1,13 @@
// 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.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 @@ namespace osu.Game.Rulesets.Edit
{
protected override double HoverExpansionDelay => 250;
protected override bool ExpandOnHover => expandOnHover;
private readonly Bindable<bool> contractSidebars = new Bindable<bool>();
private bool expandOnHover;
[Resolved]
private Editor? editor { get; set; }
public ExpandingToolboxContainer(float contractedWidth, float expandedWidth)
: base(contractedWidth, expandedWidth)
{
@ -19,6 +32,27 @@ namespace osu.Game.Rulesets.Edit
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);

View File

@ -215,6 +215,7 @@ namespace osu.Game.Screens.Edit
private Bindable<bool> editorLimitedDistanceSnap;
private Bindable<bool> editorTimelineShowTimingChanges;
private Bindable<bool> editorTimelineShowTicks;
private Bindable<bool> editorContractSidebars;
/// <summary>
/// This controls the opacity of components like the timelines, sidebars, etc.
@ -323,6 +324,7 @@ namespace osu.Game.Screens.Edit
editorLimitedDistanceSnap = config.GetBindable<bool>(OsuSetting.EditorLimitedDistanceSnap);
editorTimelineShowTimingChanges = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTimingChanges);
editorTimelineShowTicks = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTicks);
editorContractSidebars = config.GetBindable<bool>(OsuSetting.EditorContractSidebars);
AddInternal(new OsuContextMenuContainer
{
@ -402,7 +404,11 @@ namespace osu.Game.Screens.Edit
new ToggleMenuItem(EditorStrings.LimitedDistanceSnap)
{
State = { BindTarget = editorLimitedDistanceSnap },
}
},
new ToggleMenuItem(EditorStrings.ContractSidebars)
{
State = { BindTarget = editorContractSidebars }
},
}
},
new MenuItem(EditorStrings.Timing)