From deba6e2508359d484b63edf51236915681e69a20 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jul 2023 02:22:46 +0900 Subject: [PATCH 01/10] Fix osu!taiko editor playfield missing a piece Regressed with recent centering changes in https://github.com/ppy/osu/pull/24220 --- osu.Game.Rulesets.Taiko/Edit/TaikoHitObjectComposer.cs | 2 ++ osu.Game/Rulesets/Edit/HitObjectComposer.cs | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Taiko/Edit/TaikoHitObjectComposer.cs b/osu.Game.Rulesets.Taiko/Edit/TaikoHitObjectComposer.cs index cff5731181..add10b0ac5 100644 --- a/osu.Game.Rulesets.Taiko/Edit/TaikoHitObjectComposer.cs +++ b/osu.Game.Rulesets.Taiko/Edit/TaikoHitObjectComposer.cs @@ -11,6 +11,8 @@ namespace osu.Game.Rulesets.Taiko.Edit { public partial class TaikoHitObjectComposer : HitObjectComposer { + protected override bool ApplyVerticalCentering => false; + public TaikoHitObjectComposer(TaikoRuleset ruleset) : base(ruleset) { diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index bad7c55883..6fbc39c8ae 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -44,6 +44,11 @@ namespace osu.Game.Rulesets.Edit public abstract partial class HitObjectComposer : HitObjectComposer, IPlacementHandler where TObject : HitObject { + /// + /// Whether the playfield should be centered vertically. Should be disabled for playfields which span the full horizontal width. + /// + protected virtual bool ApplyVerticalCentering => true; + protected IRulesetConfigManager Config { get; private set; } // Provides `Playfield` @@ -242,7 +247,7 @@ namespace osu.Game.Rulesets.Edit base.Update(); // Ensure that the playfield is always centered but also doesn't get cut off by toolboxes. - PlayfieldContentContainer.Width = Math.Max(1024, DrawWidth) - TOOLBOX_CONTRACTED_SIZE_RIGHT * 2; + PlayfieldContentContainer.Width = Math.Max(1024, DrawWidth) - (ApplyVerticalCentering ? TOOLBOX_CONTRACTED_SIZE_RIGHT : TOOLBOX_CONTRACTED_SIZE_LEFT) * 2; } public override Playfield Playfield => drawableRulesetWrapper.Playfield; From 0e4db9b4390198a4619ac04399960bedcedafd14 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2023 16:25:40 +0900 Subject: [PATCH 02/10] Add safety in `RectangularPositionSnapGrid` that size is greater than zero Would crash otherwise --- .../Compose/Components/RectangularPositionSnapGrid.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs b/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs index 063ea23281..bec1d148be 100644 --- a/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs +++ b/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs @@ -54,8 +54,12 @@ namespace osu.Game.Screens.Edit.Compose.Components if (!gridCache.IsValid) { ClearInternal(); - createContent(); - gridCache.Validate(); + + if (DrawSize != Vector2.Zero) + { + createContent(); + gridCache.Validate(); + } } } From b5f0d739e63ce9324baa689701b0227b873f5b97 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2023 16:25:52 +0900 Subject: [PATCH 03/10] Allow ladder editor grid to scale with content Closes https://github.com/ppy/osu/issues/24378. --- .../Screens/Editors/LadderEditorScreen.cs | 16 ++++++++++++++-- .../Screens/Ladder/LadderScreen.cs | 7 +++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs index 62d18ac9e5..f3c5566565 100644 --- a/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs @@ -37,6 +37,8 @@ namespace osu.Game.Tournament.Screens.Editors private WarningBox rightClickMessage; + private RectangularPositionSnapGrid grid; + [Resolved(canBeNull: true)] [CanBeNull] private IDialogOverlay dialogOverlay { get; set; } @@ -53,10 +55,12 @@ namespace osu.Game.Tournament.Screens.Editors AddInternal(rightClickMessage = new WarningBox("Right click to place and link matches")); - ScrollContent.Add(new RectangularPositionSnapGrid(Vector2.Zero) + ScrollContent.Add(grid = new RectangularPositionSnapGrid(Vector2.Zero) { Spacing = new Vector2(GRID_SPACING), - RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + BypassAutoSizeAxes = Axes.Both, Depth = float.MaxValue }); @@ -64,6 +68,14 @@ namespace osu.Game.Tournament.Screens.Editors updateMessage(); } + protected override void Update() + { + base.Update(); + + // Expand grid with the content to allow going beyond the bounds of the screen. + grid.Size = ScrollContent.Size + new Vector2(GRID_SPACING * 2); + } + private void updateMessage() { rightClickMessage.Alpha = LadderInfo.Matches.Count > 0 ? 0 : 1; diff --git a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs index a74c9a9429..2d5281b893 100644 --- a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs +++ b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs @@ -57,12 +57,15 @@ namespace osu.Game.Tournament.Screens.Ladder }, ScrollContent = new LadderDragContainer { - RelativeSizeAxes = Axes.Both, + AutoSizeAxes = Axes.Both, Children = new Drawable[] { paths = new Container { RelativeSizeAxes = Axes.Both }, headings = new Container { RelativeSizeAxes = Axes.Both }, - MatchesContainer = new Container { RelativeSizeAxes = Axes.Both }, + MatchesContainer = new Container + { + AutoSizeAxes = Axes.Both + }, } }, } From b5c3e2a648e78a62729033b8229f5360f1d176dd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2023 16:29:39 +0900 Subject: [PATCH 04/10] Fix placing new match via right click not using original click position --- .../Screens/Editors/LadderEditorScreen.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs index f3c5566565..2ff86ab17c 100644 --- a/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs @@ -76,6 +76,14 @@ namespace osu.Game.Tournament.Screens.Editors grid.Size = ScrollContent.Size + new Vector2(GRID_SPACING * 2); } + private Vector2 lastMatchesContainerMouseDownPosition; + + protected override bool OnMouseDown(MouseDownEvent e) + { + lastMatchesContainerMouseDownPosition = MatchesContainer.ToLocalSpace(e.ScreenSpaceMouseDownPosition); + return base.OnMouseDown(e); + } + private void updateMessage() { rightClickMessage.Alpha = LadderInfo.Matches.Count > 0 ? 0 : 1; @@ -97,7 +105,8 @@ namespace osu.Game.Tournament.Screens.Editors { new OsuMenuItem("Create new match", MenuItemType.Highlighted, () => { - Vector2 pos = MatchesContainer.ToLocalSpace(GetContainingInputManager().CurrentState.Mouse.Position); + Vector2 pos = lastMatchesContainerMouseDownPosition; + TournamentMatch newMatch = new TournamentMatch { Position = { Value = new Point((int)pos.X, (int)pos.Y) } }; LadderInfo.Matches.Add(newMatch); From aa910005053d3ff51ba124cf07480e16b6642072 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2023 16:29:55 +0900 Subject: [PATCH 05/10] Always place first match at (0,0) --- osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs index 2ff86ab17c..9411892dc5 100644 --- a/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs @@ -105,7 +105,7 @@ namespace osu.Game.Tournament.Screens.Editors { new OsuMenuItem("Create new match", MenuItemType.Highlighted, () => { - Vector2 pos = lastMatchesContainerMouseDownPosition; + Vector2 pos = MatchesContainer.Count == 0 ? Vector2.Zero : lastMatchesContainerMouseDownPosition; TournamentMatch newMatch = new TournamentMatch { Position = { Value = new Point((int)pos.X, (int)pos.Y) } }; From c9155f85ab83d12771621dc82240320f2f09ec19 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2023 16:40:14 +0900 Subject: [PATCH 06/10] Fix playfield not taking up full width correclty when not vertically centered --- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 6fbc39c8ae..dbca8694ae 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -124,8 +124,6 @@ namespace osu.Game.Rulesets.Edit { Name = "Playfield content", RelativeSizeAxes = Axes.Y, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, Children = new Drawable[] { // layers below playfield @@ -247,7 +245,22 @@ namespace osu.Game.Rulesets.Edit base.Update(); // Ensure that the playfield is always centered but also doesn't get cut off by toolboxes. - PlayfieldContentContainer.Width = Math.Max(1024, DrawWidth) - (ApplyVerticalCentering ? TOOLBOX_CONTRACTED_SIZE_RIGHT : TOOLBOX_CONTRACTED_SIZE_LEFT) * 2; + if (ApplyVerticalCentering) + { + PlayfieldContentContainer.Anchor = Anchor.Centre; + PlayfieldContentContainer.Origin = Anchor.Centre; + + PlayfieldContentContainer.Width = Math.Max(1024, DrawWidth) - TOOLBOX_CONTRACTED_SIZE_RIGHT * 2; + PlayfieldContentContainer.X = 0; + } + else + { + PlayfieldContentContainer.Anchor = Anchor.CentreLeft; + PlayfieldContentContainer.Origin = Anchor.CentreLeft; + + PlayfieldContentContainer.Width = Math.Max(1024, DrawWidth) - (TOOLBOX_CONTRACTED_SIZE_LEFT + TOOLBOX_CONTRACTED_SIZE_RIGHT); + PlayfieldContentContainer.X = TOOLBOX_CONTRACTED_SIZE_LEFT; + } } public override Playfield Playfield => drawableRulesetWrapper.Playfield; From f58c69e639b1bc5f72c4680f48d90cedb0d7a718 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2023 17:17:14 +0900 Subject: [PATCH 07/10] Fix potential startup crash due to early application of animations This was always haphazard code, but by luck it never triggered before drawable load until now. With the recently nullability changes, this would be triggered when `flash` is not yet constructed. Switching to `AddOnce` seems safer to avoid multiple applications, regardless. --- osu.Game.Tournament/Components/TournamentBeatmapPanel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs index 6933eafc29..49478a2174 100644 --- a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs +++ b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs @@ -136,11 +136,11 @@ namespace osu.Game.Tournament.Components if (match.NewValue != null) match.NewValue.PicksBans.CollectionChanged += picksBansOnCollectionChanged; - updateState(); + Scheduler.AddOnce(updateState); } private void picksBansOnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) - => updateState(); + => Scheduler.AddOnce(updateState); private BeatmapChoice? choice; From 6d018c08afc1573a921e3cfb28e1e13b67f45cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 28 Jul 2023 22:09:28 +0200 Subject: [PATCH 08/10] Rename `Apply{Vertical -> Horizontal}Centering` to match common understanding --- osu.Game.Rulesets.Taiko/Edit/TaikoHitObjectComposer.cs | 2 +- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Edit/TaikoHitObjectComposer.cs b/osu.Game.Rulesets.Taiko/Edit/TaikoHitObjectComposer.cs index add10b0ac5..3e63d624e7 100644 --- a/osu.Game.Rulesets.Taiko/Edit/TaikoHitObjectComposer.cs +++ b/osu.Game.Rulesets.Taiko/Edit/TaikoHitObjectComposer.cs @@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Taiko.Edit { public partial class TaikoHitObjectComposer : HitObjectComposer { - protected override bool ApplyVerticalCentering => false; + protected override bool ApplyHorizontalCentering => false; public TaikoHitObjectComposer(TaikoRuleset ruleset) : base(ruleset) diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index dbca8694ae..71ca13e4ba 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -45,9 +45,9 @@ namespace osu.Game.Rulesets.Edit where TObject : HitObject { /// - /// Whether the playfield should be centered vertically. Should be disabled for playfields which span the full horizontal width. + /// Whether the playfield should be centered horizontally. Should be disabled for playfields which span the full horizontal width. /// - protected virtual bool ApplyVerticalCentering => true; + protected virtual bool ApplyHorizontalCentering => true; protected IRulesetConfigManager Config { get; private set; } @@ -245,7 +245,7 @@ namespace osu.Game.Rulesets.Edit base.Update(); // Ensure that the playfield is always centered but also doesn't get cut off by toolboxes. - if (ApplyVerticalCentering) + if (ApplyHorizontalCentering) { PlayfieldContentContainer.Anchor = Anchor.Centre; PlayfieldContentContainer.Origin = Anchor.Centre; From caad931a16c3712130f01b1bc54a3c58a3728c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 28 Jul 2023 22:10:10 +0200 Subject: [PATCH 09/10] Move comment to more fitting place --- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 71ca13e4ba..c967187b5c 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -244,12 +244,12 @@ namespace osu.Game.Rulesets.Edit { base.Update(); - // Ensure that the playfield is always centered but also doesn't get cut off by toolboxes. if (ApplyHorizontalCentering) { PlayfieldContentContainer.Anchor = Anchor.Centre; PlayfieldContentContainer.Origin = Anchor.Centre; + // Ensure that the playfield is always centered but also doesn't get cut off by toolboxes. PlayfieldContentContainer.Width = Math.Max(1024, DrawWidth) - TOOLBOX_CONTRACTED_SIZE_RIGHT * 2; PlayfieldContentContainer.X = 0; } From c6f0cf50caa0a310ff9dc3f1533302cce269ea90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 28 Jul 2023 22:57:02 +0200 Subject: [PATCH 10/10] Use better safety in rectangular grid - Checking `DrawSize != Vector2.Zero` is too specific. It could also crash on zero-height-but-non-zero-width, or zero-width-but-non-zero-height. - Take the `gridCache.Validate()` call out of the zero checks, because even if the width or height are zero, not generating anything is valid and there is no reason to validate every frame until `gridCache` gets invalidated again. --- .../Edit/Compose/Components/RectangularPositionSnapGrid.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs b/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs index bec1d148be..cfc01fe17b 100644 --- a/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs +++ b/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs @@ -55,11 +55,10 @@ namespace osu.Game.Screens.Edit.Compose.Components { ClearInternal(); - if (DrawSize != Vector2.Zero) - { + if (DrawWidth > 0 && DrawHeight > 0) createContent(); - gridCache.Validate(); - } + + gridCache.Validate(); } }