Skip to content

Commit e37d415

Browse files
committed
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 ppy#28970.
1 parent c15490e commit e37d415

File tree

4 files changed

+50
-2
lines changed

4 files changed

+50
-2
lines changed

osu.Game/Configuration/OsuConfigManager.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ protected override void InitialiseDefaults()
206206
SetDefault(OsuSetting.EditorTimelineShowTimingChanges, true);
207207
SetDefault(OsuSetting.EditorTimelineShowTicks, true);
208208

209+
SetDefault(OsuSetting.EditorContractSidebars, false);
210+
209211
SetDefault(OsuSetting.AlwaysShowHoldForMenuButton, false);
210212
}
211213

@@ -431,6 +433,7 @@ public enum OsuSetting
431433
HideCountryFlags,
432434
EditorTimelineShowTimingChanges,
433435
EditorTimelineShowTicks,
434-
AlwaysShowHoldForMenuButton
436+
AlwaysShowHoldForMenuButton,
437+
EditorContractSidebars
435438
}
436439
}

osu.Game/Localisation/EditorStrings.cs

+5
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ public static class EditorStrings
114114
/// </summary>
115115
public static LocalisableString LimitedDistanceSnap => new TranslatableString(getKey(@"limited_distance_snap_grid"), @"Limit distance snap placement to current time");
116116

117+
/// <summary>
118+
/// "Contract sidebars when not hovered"
119+
/// </summary>
120+
public static LocalisableString ContractSidebars => new TranslatableString(getKey(@"contract_sidebars"), @"Contract sidebars when not hovered");
121+
117122
/// <summary>
118123
/// "Must be in edit mode to handle editor links"
119124
/// </summary>

osu.Game/Rulesets/Edit/ExpandingToolboxContainer.cs

+34
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
22
// See the LICENCE file in the repository root for full licence text.
33

4+
using osu.Framework.Allocation;
5+
using osu.Framework.Bindables;
46
using osu.Framework.Graphics;
57
using osu.Framework.Input.Events;
8+
using osu.Game.Configuration;
69
using osu.Game.Graphics.Containers;
10+
using osu.Game.Screens.Edit;
711
using osuTK;
812

913
namespace osu.Game.Rulesets.Edit
@@ -12,13 +16,43 @@ public partial class ExpandingToolboxContainer : ExpandingContainer
1216
{
1317
protected override double HoverExpansionDelay => 250;
1418

19+
protected override bool ExpandOnHover => expandOnHover;
20+
21+
private readonly Bindable<bool> contractSidebars = new Bindable<bool>();
22+
23+
private bool expandOnHover;
24+
25+
[Resolved]
26+
private Editor? editor { get; set; }
27+
1528
public ExpandingToolboxContainer(float contractedWidth, float expandedWidth)
1629
: base(contractedWidth, expandedWidth)
1730
{
1831
RelativeSizeAxes = Axes.Y;
1932

2033
FillFlow.Spacing = new Vector2(5);
2134
FillFlow.Padding = new MarginPadding { Vertical = 5 };
35+
36+
Expanded.Value = true;
37+
}
38+
39+
[BackgroundDependencyLoader]
40+
private void load(OsuConfigManager config)
41+
{
42+
config.BindWith(OsuSetting.EditorContractSidebars, contractSidebars);
43+
}
44+
45+
protected override void Update()
46+
{
47+
base.Update();
48+
49+
bool requireContracting = contractSidebars.Value || editor?.DrawSize.X / editor?.DrawSize.Y < 1.7f;
50+
51+
if (expandOnHover != requireContracting)
52+
{
53+
expandOnHover = requireContracting;
54+
Expanded.Value = !expandOnHover;
55+
}
2256
}
2357

2458
protected override bool ReceivePositionalInputAtSubTree(Vector2 screenSpacePos) => base.ReceivePositionalInputAtSubTree(screenSpacePos) && anyToolboxHovered(screenSpacePos);

osu.Game/Screens/Edit/Editor.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
215215
private Bindable<bool> editorLimitedDistanceSnap;
216216
private Bindable<bool> editorTimelineShowTimingChanges;
217217
private Bindable<bool> editorTimelineShowTicks;
218+
private Bindable<bool> editorContractSidebars;
218219

219220
/// <summary>
220221
/// This controls the opacity of components like the timelines, sidebars, etc.
@@ -323,6 +324,7 @@ private void load(OsuConfigManager config)
323324
editorLimitedDistanceSnap = config.GetBindable<bool>(OsuSetting.EditorLimitedDistanceSnap);
324325
editorTimelineShowTimingChanges = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTimingChanges);
325326
editorTimelineShowTicks = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTicks);
327+
editorContractSidebars = config.GetBindable<bool>(OsuSetting.EditorContractSidebars);
326328

327329
AddInternal(new OsuContextMenuContainer
328330
{
@@ -402,7 +404,11 @@ private void load(OsuConfigManager config)
402404
new ToggleMenuItem(EditorStrings.LimitedDistanceSnap)
403405
{
404406
State = { BindTarget = editorLimitedDistanceSnap },
405-
}
407+
},
408+
new ToggleMenuItem(EditorStrings.ContractSidebars)
409+
{
410+
State = { BindTarget = editorContractSidebars }
411+
},
406412
}
407413
},
408414
new MenuItem(EditorStrings.Timing)

0 commit comments

Comments
 (0)