Skip to content

Commit

Permalink
Keep editor sidebars expanded by default
Browse files Browse the repository at this point in the history
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 ppy#28970.
  • Loading branch information
peppy committed Oct 22, 2024
1 parent c15490e commit e37d415
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
5 changes: 4 additions & 1 deletion osu.Game/Configuration/OsuConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ protected override void InitialiseDefaults()
SetDefault(OsuSetting.EditorTimelineShowTimingChanges, true);
SetDefault(OsuSetting.EditorTimelineShowTicks, true);

SetDefault(OsuSetting.EditorContractSidebars, false);

SetDefault(OsuSetting.AlwaysShowHoldForMenuButton, false);
}

Expand Down Expand Up @@ -431,6 +433,7 @@ public enum OsuSetting
HideCountryFlags,
EditorTimelineShowTimingChanges,
EditorTimelineShowTicks,
AlwaysShowHoldForMenuButton
AlwaysShowHoldForMenuButton,
EditorContractSidebars
}
}
5 changes: 5 additions & 0 deletions osu.Game/Localisation/EditorStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ public static class EditorStrings
/// </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>
Expand Down
34 changes: 34 additions & 0 deletions osu.Game/Rulesets/Edit/ExpandingToolboxContainer.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,13 +16,43 @@ public partial class ExpandingToolboxContainer : ExpandingContainer
{
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)
{
RelativeSizeAxes = Axes.Y;

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);
Expand Down
8 changes: 7 additions & 1 deletion osu.Game/Screens/Edit/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
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.
Expand Down Expand Up @@ -323,6 +324,7 @@ private void load(OsuConfigManager config)
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
{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e37d415

Please sign in to comment.