From b0c5b3cb1097861506b11862b996b91afe7a384a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 10 Nov 2023 14:15:42 +0900 Subject: [PATCH 01/21] Add `Size` to serialised components of a `SerialisedDrawableInfo` --- osu.Game/Skinning/SerialisableDrawableExtensions.cs | 3 +++ osu.Game/Skinning/SerialisedDrawableInfo.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/osu.Game/Skinning/SerialisableDrawableExtensions.cs b/osu.Game/Skinning/SerialisableDrawableExtensions.cs index 51b57a000d..0b44db9bdc 100644 --- a/osu.Game/Skinning/SerialisableDrawableExtensions.cs +++ b/osu.Game/Skinning/SerialisableDrawableExtensions.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Configuration; using osu.Game.Extensions; +using osuTK; namespace osu.Game.Skinning { @@ -18,6 +19,8 @@ namespace osu.Game.Skinning // todo: can probably make this better via deserialisation directly using a common interface. component.Position = drawableInfo.Position; component.Rotation = drawableInfo.Rotation; + if (drawableInfo.Size != Vector2.Zero && (component as CompositeDrawable)?.AutoSizeAxes == Axes.None) + component.Size = drawableInfo.Size; component.Scale = drawableInfo.Scale; component.Anchor = drawableInfo.Anchor; component.Origin = drawableInfo.Origin; diff --git a/osu.Game/Skinning/SerialisedDrawableInfo.cs b/osu.Game/Skinning/SerialisedDrawableInfo.cs index c515f228f7..0705e91d6d 100644 --- a/osu.Game/Skinning/SerialisedDrawableInfo.cs +++ b/osu.Game/Skinning/SerialisedDrawableInfo.cs @@ -35,6 +35,8 @@ namespace osu.Game.Skinning public Vector2 Scale { get; set; } + public Vector2 Size { get; set; } + public Anchor Anchor { get; set; } public Anchor Origin { get; set; } @@ -62,6 +64,7 @@ namespace osu.Game.Skinning Position = component.Position; Rotation = component.Rotation; Scale = component.Scale; + Size = component.Size; Anchor = component.Anchor; Origin = component.Origin; From ec3b6e47fb7c6b302e633132362bfe54873a58a6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 10 Nov 2023 14:17:11 +0900 Subject: [PATCH 02/21] Change selection handling to adjust `Size` instead of `Scale` for edge nodes --- .../Edit/OsuSelectionHandler.cs | 1 + .../SkinEditor/SkinSelectionHandler.cs | 40 +++++++++++++++++-- .../Edit/Compose/Components/SelectionBox.cs | 19 ++++++++- 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs index e81941d254..4da640a971 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs @@ -42,6 +42,7 @@ namespace osu.Game.Rulesets.Osu.Edit SelectionBox.CanFlipX = SelectionBox.CanScaleX = quad.Width > 0; SelectionBox.CanFlipY = SelectionBox.CanScaleY = quad.Height > 0; + SelectionBox.CanScaleProportionally = SelectionBox.CanScaleX && SelectionBox.CanScaleY; SelectionBox.CanReverse = EditorBeatmap.SelectedHitObjects.Count > 1 || EditorBeatmap.SelectedHitObjects.Any(s => s is Slider); } diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index df73b15101..bf03906e56 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -7,6 +7,7 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; using osu.Framework.Utils; @@ -31,8 +32,38 @@ namespace osu.Game.Overlays.SkinEditor UpdatePosition = updateDrawablePosition }; + private bool allSelectedSupportManualSizing => SelectedItems.All(b => (b as CompositeDrawable)?.AutoSizeAxes == Axes.None); + public override bool HandleScale(Vector2 scale, Anchor anchor) { + bool adjustSize; + + switch (anchor) + { + // for corners, adjust scale. + case Anchor.TopLeft: + case Anchor.TopRight: + case Anchor.BottomLeft: + case Anchor.BottomRight: + adjustSize = false; + break; + + // for edges, adjust size. + case Anchor.TopCentre: + case Anchor.CentreLeft: + case Anchor.CentreRight: + case Anchor.BottomCentre: + // autosize elements can't be easily handled so just disable sizing for now. + if (!allSelectedSupportManualSizing) + return false; + + adjustSize = true; + break; + + default: + throw new ArgumentOutOfRangeException(nameof(anchor), anchor, null); + } + // convert scale to screen space scale = ToScreenSpace(scale) - ToScreenSpace(Vector2.Zero); @@ -120,7 +151,10 @@ namespace osu.Game.Overlays.SkinEditor if (Precision.AlmostEquals(MathF.Abs(drawableItem.Rotation) % 180, 90)) currentScaledDelta = new Vector2(scaledDelta.Y, scaledDelta.X); - drawableItem.Scale *= currentScaledDelta; + if (adjustSize) + drawableItem.Size *= currentScaledDelta; + else + drawableItem.Scale *= currentScaledDelta; } return true; @@ -169,8 +203,8 @@ namespace osu.Game.Overlays.SkinEditor { base.OnSelectionChanged(); - SelectionBox.CanScaleX = true; - SelectionBox.CanScaleY = true; + SelectionBox.CanScaleX = SelectionBox.CanScaleY = allSelectedSupportManualSizing; + SelectionBox.CanScaleProportionally = true; SelectionBox.CanFlipX = true; SelectionBox.CanFlipY = true; SelectionBox.CanReverse = false; diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs index 72d96213ee..0917867a61 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs @@ -91,6 +91,23 @@ namespace osu.Game.Screens.Edit.Compose.Components } } + private bool canScaleProportionally; + + /// + /// Whether vertical scaling support should be enabled. + /// + public bool CanScaleProportionally + { + get => canScaleProportionally; + set + { + if (canScaleProportionally == value) return; + + canScaleProportionally = value; + recreate(); + } + } + private bool canFlipX; /// @@ -245,7 +262,7 @@ namespace osu.Game.Screens.Edit.Compose.Components }; if (CanScaleX) addXScaleComponents(); - if (CanScaleX && CanScaleY) addFullScaleComponents(); + if (CanScaleProportionally) addFullScaleComponents(); if (CanScaleY) addYScaleComponents(); if (CanFlipX) addXFlipComponents(); if (CanFlipY) addYFlipComponents(); From fb361a4e0a8152bb35fe16cdc98bf06993f64a67 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 10 Nov 2023 14:25:55 +0900 Subject: [PATCH 03/21] Reset size along with scale for relative items --- osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index bf03906e56..dab8c1c558 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -249,7 +249,12 @@ namespace osu.Game.Overlays.SkinEditor yield return new OsuMenuItem("Reset scale", MenuItemType.Standard, () => { foreach (var blueprint in SelectedBlueprints) - ((Drawable)blueprint.Item).Scale = Vector2.One; + { + var blueprintItem = ((Drawable)blueprint.Item); + blueprintItem.Scale = Vector2.One; + if (RelativeSizeAxes == Axes.Both) + blueprintItem.Size = Vector2.One; + } }); yield return new EditorMenuItemSpacer(); From 0add035c674d59bd36ef129d474a76550e3ced92 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 10 Nov 2023 14:31:02 +0900 Subject: [PATCH 04/21] Disable resizing of `LegacySongProgress` Because it looks bad. --- osu.Game/Skinning/LegacySongProgress.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game/Skinning/LegacySongProgress.cs b/osu.Game/Skinning/LegacySongProgress.cs index 22aea99291..26004ff111 100644 --- a/osu.Game/Skinning/LegacySongProgress.cs +++ b/osu.Game/Skinning/LegacySongProgress.cs @@ -19,11 +19,14 @@ namespace osu.Game.Skinning public override bool HandleNonPositionalInput => false; public override bool HandlePositionalInput => false; + public LegacySongProgress() + { + AutoSizeAxes = Axes.Both; + } + [BackgroundDependencyLoader] private void load() { - Size = new Vector2(33); - InternalChildren = new Drawable[] { new Container @@ -39,7 +42,7 @@ namespace osu.Game.Skinning }, new CircularContainer { - RelativeSizeAxes = Axes.Both, + Size = new Vector2(33), Masking = true, BorderColour = Colour4.White, BorderThickness = 2, From 175dae49c623bfa8632608e204cac168d0b9723a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 10 Nov 2023 14:43:51 +0900 Subject: [PATCH 05/21] Reset scale per axis --- osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index dab8c1c558..77e522a925 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -252,8 +252,11 @@ namespace osu.Game.Overlays.SkinEditor { var blueprintItem = ((Drawable)blueprint.Item); blueprintItem.Scale = Vector2.One; - if (RelativeSizeAxes == Axes.Both) - blueprintItem.Size = Vector2.One; + + if (blueprintItem.RelativeSizeAxes.HasFlagFast(Axes.X)) + blueprintItem.Width = 1; + if (blueprintItem.RelativeSizeAxes.HasFlagFast(Axes.Y)) + blueprintItem.Height = 1; } }); From 8690b0876928570e5df1d25a1568db6ec703ee05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 10 Nov 2023 16:08:45 +0900 Subject: [PATCH 06/21] Fix compose select box test failures --- osu.Game.Tests/Visual/Editing/TestSceneComposeSelectBox.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Tests/Visual/Editing/TestSceneComposeSelectBox.cs b/osu.Game.Tests/Visual/Editing/TestSceneComposeSelectBox.cs index 80c69aacf6..9e8d75efea 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneComposeSelectBox.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneComposeSelectBox.cs @@ -47,6 +47,7 @@ namespace osu.Game.Tests.Visual.Editing CanScaleX = true, CanScaleY = true, + CanScaleProportionally = true, CanFlipX = true, CanFlipY = true, From 46a219e01010e32827f3772aae77fece7de8bccf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 10 Nov 2023 17:53:02 +0900 Subject: [PATCH 07/21] Add comment explaining `AutoSize` change in `LegacySongProgress` --- osu.Game/Skinning/LegacySongProgress.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Skinning/LegacySongProgress.cs b/osu.Game/Skinning/LegacySongProgress.cs index 26004ff111..fa6ee38fee 100644 --- a/osu.Game/Skinning/LegacySongProgress.cs +++ b/osu.Game/Skinning/LegacySongProgress.cs @@ -21,6 +21,8 @@ namespace osu.Game.Skinning public LegacySongProgress() { + // User shouldn't be able to adjust width/height of this as `CircularProgress` doesn't + // handle stretched cases ell. AutoSizeAxes = Axes.Both; } From f25489cc7be71426891f50046b70aefdc24578de Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 10 Nov 2023 17:53:56 +0900 Subject: [PATCH 08/21] Check X/Y sizing available separately to fix weird edge cases --- .../SkinEditor/SkinSelectionHandler.cs | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index 77e522a925..a4d530a4d9 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -32,11 +32,11 @@ namespace osu.Game.Overlays.SkinEditor UpdatePosition = updateDrawablePosition }; - private bool allSelectedSupportManualSizing => SelectedItems.All(b => (b as CompositeDrawable)?.AutoSizeAxes == Axes.None); + private bool allSelectedSupportManualSizing(Axes axis) => SelectedItems.All(b => (b as CompositeDrawable)?.AutoSizeAxes.HasFlagFast(axis) == false); public override bool HandleScale(Vector2 scale, Anchor anchor) { - bool adjustSize; + Axes adjustAxis; switch (anchor) { @@ -45,19 +45,25 @@ namespace osu.Game.Overlays.SkinEditor case Anchor.TopRight: case Anchor.BottomLeft: case Anchor.BottomRight: - adjustSize = false; + adjustAxis = Axes.Both; break; // for edges, adjust size. + // autosize elements can't be easily handled so just disable sizing for now. case Anchor.TopCentre: - case Anchor.CentreLeft: - case Anchor.CentreRight: case Anchor.BottomCentre: - // autosize elements can't be easily handled so just disable sizing for now. - if (!allSelectedSupportManualSizing) + if (!allSelectedSupportManualSizing(Axes.Y)) return false; - adjustSize = true; + adjustAxis = Axes.Y; + break; + + case Anchor.CentreLeft: + case Anchor.CentreRight: + if (!allSelectedSupportManualSizing(Axes.X)) + return false; + + adjustAxis = Axes.X; break; default: @@ -151,10 +157,20 @@ namespace osu.Game.Overlays.SkinEditor if (Precision.AlmostEquals(MathF.Abs(drawableItem.Rotation) % 180, 90)) currentScaledDelta = new Vector2(scaledDelta.Y, scaledDelta.X); - if (adjustSize) - drawableItem.Size *= currentScaledDelta; - else - drawableItem.Scale *= currentScaledDelta; + switch (adjustAxis) + { + case Axes.X: + drawableItem.Width *= currentScaledDelta.X; + break; + + case Axes.Y: + drawableItem.Height *= currentScaledDelta.Y; + break; + + case Axes.Both: + drawableItem.Scale *= currentScaledDelta; + break; + } } return true; @@ -203,7 +219,8 @@ namespace osu.Game.Overlays.SkinEditor { base.OnSelectionChanged(); - SelectionBox.CanScaleX = SelectionBox.CanScaleY = allSelectedSupportManualSizing; + SelectionBox.CanScaleX = allSelectedSupportManualSizing(Axes.X); + SelectionBox.CanScaleY = allSelectedSupportManualSizing(Axes.Y); SelectionBox.CanScaleProportionally = true; SelectionBox.CanFlipX = true; SelectionBox.CanFlipY = true; From 35e11c7c63b83122a45f5f9820aa6909ffb892bd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 10 Nov 2023 17:51:30 +0900 Subject: [PATCH 09/21] Rename diagonal scale variable and update xmldoc --- .../Edit/OsuSelectionHandler.cs | 2 +- .../Editing/TestSceneComposeSelectBox.cs | 2 +- .../SkinEditor/SkinSelectionHandler.cs | 2 +- .../Edit/Compose/Components/SelectionBox.cs | 22 +++++++++++-------- osu.sln.DotSettings | 1 + 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs index 4da640a971..4765f615ce 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs @@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Osu.Edit SelectionBox.CanFlipX = SelectionBox.CanScaleX = quad.Width > 0; SelectionBox.CanFlipY = SelectionBox.CanScaleY = quad.Height > 0; - SelectionBox.CanScaleProportionally = SelectionBox.CanScaleX && SelectionBox.CanScaleY; + SelectionBox.CanScaleDiagonally = SelectionBox.CanScaleX && SelectionBox.CanScaleY; SelectionBox.CanReverse = EditorBeatmap.SelectedHitObjects.Count > 1 || EditorBeatmap.SelectedHitObjects.Any(s => s is Slider); } diff --git a/osu.Game.Tests/Visual/Editing/TestSceneComposeSelectBox.cs b/osu.Game.Tests/Visual/Editing/TestSceneComposeSelectBox.cs index 9e8d75efea..f6637d0e80 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneComposeSelectBox.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneComposeSelectBox.cs @@ -47,7 +47,7 @@ namespace osu.Game.Tests.Visual.Editing CanScaleX = true, CanScaleY = true, - CanScaleProportionally = true, + CanScaleDiagonally = true, CanFlipX = true, CanFlipY = true, diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index a4d530a4d9..52c012a15a 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -221,7 +221,7 @@ namespace osu.Game.Overlays.SkinEditor SelectionBox.CanScaleX = allSelectedSupportManualSizing(Axes.X); SelectionBox.CanScaleY = allSelectedSupportManualSizing(Axes.Y); - SelectionBox.CanScaleProportionally = true; + SelectionBox.CanScaleDiagonally = true; SelectionBox.CanFlipX = true; SelectionBox.CanFlipY = true; SelectionBox.CanReverse = false; diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs index 0917867a61..0b16941bc4 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs @@ -60,7 +60,7 @@ namespace osu.Game.Screens.Edit.Compose.Components private bool canScaleX; /// - /// Whether horizontal scaling support should be enabled. + /// Whether horizontal scaling (from the left or right edge) support should be enabled. /// public bool CanScaleX { @@ -77,7 +77,7 @@ namespace osu.Game.Screens.Edit.Compose.Components private bool canScaleY; /// - /// Whether vertical scaling support should be enabled. + /// Whether vertical scaling (from the top or bottom edge) support should be enabled. /// public bool CanScaleY { @@ -91,19 +91,23 @@ namespace osu.Game.Screens.Edit.Compose.Components } } - private bool canScaleProportionally; + private bool canScaleDiagonally; /// - /// Whether vertical scaling support should be enabled. + /// Whether diagonal scaling (from a corner) support should be enabled. /// - public bool CanScaleProportionally + /// + /// There are some cases where we only want to allow proportional resizing, and not allow + /// one or both explicit directions of scale. + /// + public bool CanScaleDiagonally { - get => canScaleProportionally; + get => canScaleDiagonally; set { - if (canScaleProportionally == value) return; + if (canScaleDiagonally == value) return; - canScaleProportionally = value; + canScaleDiagonally = value; recreate(); } } @@ -262,7 +266,7 @@ namespace osu.Game.Screens.Edit.Compose.Components }; if (CanScaleX) addXScaleComponents(); - if (CanScaleProportionally) addFullScaleComponents(); + if (CanScaleDiagonally) addFullScaleComponents(); if (CanScaleY) addYScaleComponents(); if (CanFlipX) addXFlipComponents(); if (CanFlipY) addYFlipComponents(); diff --git a/osu.sln.DotSettings b/osu.sln.DotSettings index c2778ca5b1..342bc8aa79 100644 --- a/osu.sln.DotSettings +++ b/osu.sln.DotSettings @@ -823,6 +823,7 @@ See the LICENCE file in the repository root for full licence text. True True True + True True True True From 2c1f304f3b4faaa645edb3c138b915ad351c9fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 10 Nov 2023 18:13:36 +0900 Subject: [PATCH 10/21] Fix test failures due to fluctuations in needlessly-serialised automatic sizings --- osu.Game/Skinning/SerialisableDrawableExtensions.cs | 7 +++++-- osu.Game/Skinning/SerialisedDrawableInfo.cs | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/osu.Game/Skinning/SerialisableDrawableExtensions.cs b/osu.Game/Skinning/SerialisableDrawableExtensions.cs index 0b44db9bdc..609dd9c8ab 100644 --- a/osu.Game/Skinning/SerialisableDrawableExtensions.cs +++ b/osu.Game/Skinning/SerialisableDrawableExtensions.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Bindables; +using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Configuration; @@ -19,8 +20,10 @@ namespace osu.Game.Skinning // todo: can probably make this better via deserialisation directly using a common interface. component.Position = drawableInfo.Position; component.Rotation = drawableInfo.Rotation; - if (drawableInfo.Size != Vector2.Zero && (component as CompositeDrawable)?.AutoSizeAxes == Axes.None) - component.Size = drawableInfo.Size; + if (drawableInfo.Width is float width && width != 0 && (component as CompositeDrawable)?.AutoSizeAxes.HasFlagFast(Axes.X) == false) + component.Width = width; + if (drawableInfo.Height is float height && height != 0 && (component as CompositeDrawable)?.AutoSizeAxes.HasFlagFast(Axes.Y) == false) + component.Height = height; component.Scale = drawableInfo.Scale; component.Anchor = drawableInfo.Anchor; component.Origin = drawableInfo.Origin; diff --git a/osu.Game/Skinning/SerialisedDrawableInfo.cs b/osu.Game/Skinning/SerialisedDrawableInfo.cs index 0705e91d6d..b2237acc5a 100644 --- a/osu.Game/Skinning/SerialisedDrawableInfo.cs +++ b/osu.Game/Skinning/SerialisedDrawableInfo.cs @@ -35,7 +35,9 @@ namespace osu.Game.Skinning public Vector2 Scale { get; set; } - public Vector2 Size { get; set; } + public float? Width { get; set; } + + public float? Height { get; set; } public Anchor Anchor { get; set; } @@ -64,7 +66,8 @@ namespace osu.Game.Skinning Position = component.Position; Rotation = component.Rotation; Scale = component.Scale; - Size = component.Size; + Height = component.Height; + Width = component.Width; Anchor = component.Anchor; Origin = component.Origin; From 374e13b496dc3780e03f2c9f76a850ab0a8050e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 10 Nov 2023 18:18:45 +0900 Subject: [PATCH 11/21] Remove argon health display bar length setting It is no longer needed. Intentionally not doing backwards migration to simplify things; users can fix their skins. --- osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs b/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs index 793d43f7ef..b4002343d3 100644 --- a/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs +++ b/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs @@ -35,14 +35,6 @@ namespace osu.Game.Screens.Play.HUD Precision = 1 }; - [SettingSource("Bar length")] - public BindableFloat BarLength { get; } = new BindableFloat(0.98f) - { - MinValue = 0.2f, - MaxValue = 1, - Precision = 0.01f, - }; - private BarPath mainBar = null!; /// @@ -140,7 +132,6 @@ namespace osu.Game.Screens.Play.HUD Current.BindValueChanged(_ => Scheduler.AddOnce(updateCurrent), true); - BarLength.BindValueChanged(l => Width = l.NewValue, true); BarHeight.BindValueChanged(_ => updatePath()); updatePath(); } From 43a4b34295471a2a4c0103aa9383ef75cbb8dc56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 10 Nov 2023 18:20:14 +0900 Subject: [PATCH 12/21] Fix typo --- osu.Game/Skinning/LegacySongProgress.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Skinning/LegacySongProgress.cs b/osu.Game/Skinning/LegacySongProgress.cs index fa6ee38fee..4295060a3a 100644 --- a/osu.Game/Skinning/LegacySongProgress.cs +++ b/osu.Game/Skinning/LegacySongProgress.cs @@ -22,7 +22,7 @@ namespace osu.Game.Skinning public LegacySongProgress() { // User shouldn't be able to adjust width/height of this as `CircularProgress` doesn't - // handle stretched cases ell. + // handle stretched cases well. AutoSizeAxes = Axes.Both; } From 26eae0bdeeed6670fc3a47b81abdc75afceda434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 10 Nov 2023 18:25:39 +0900 Subject: [PATCH 13/21] Remove unused using directive --- osu.Game/Skinning/SerialisableDrawableExtensions.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Skinning/SerialisableDrawableExtensions.cs b/osu.Game/Skinning/SerialisableDrawableExtensions.cs index 609dd9c8ab..6938ed4091 100644 --- a/osu.Game/Skinning/SerialisableDrawableExtensions.cs +++ b/osu.Game/Skinning/SerialisableDrawableExtensions.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Configuration; using osu.Game.Extensions; -using osuTK; namespace osu.Game.Skinning { From ec2200d54fff1cf823355571c2a3c827c3a19ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 10 Nov 2023 18:26:08 +0900 Subject: [PATCH 14/21] Remove another reference to bar length --- .../Visual/Gameplay/TestSceneArgonHealthDisplay.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneArgonHealthDisplay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneArgonHealthDisplay.cs index 7bad623d7f..f51577bc84 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneArgonHealthDisplay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneArgonHealthDisplay.cs @@ -47,12 +47,6 @@ namespace osu.Game.Tests.Visual.Gameplay }; }); - AddSliderStep("Width", 0, 1f, 1f, val => - { - if (healthDisplay.IsNotNull()) - healthDisplay.BarLength.Value = val; - }); - AddSliderStep("Height", 0, 64, 0, val => { if (healthDisplay.IsNotNull()) From b7acbde719744a3aac166c676b792e9d87699612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 10 Nov 2023 19:12:26 +0900 Subject: [PATCH 15/21] Only store width/height of serialised drawable if it isn't automatically computed --- osu.Game/Skinning/SerialisedDrawableInfo.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game/Skinning/SerialisedDrawableInfo.cs b/osu.Game/Skinning/SerialisedDrawableInfo.cs index b2237acc5a..2d6113ff70 100644 --- a/osu.Game/Skinning/SerialisedDrawableInfo.cs +++ b/osu.Game/Skinning/SerialisedDrawableInfo.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; using osu.Framework.Bindables; +using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Logging; @@ -66,8 +67,13 @@ namespace osu.Game.Skinning Position = component.Position; Rotation = component.Rotation; Scale = component.Scale; - Height = component.Height; - Width = component.Width; + + if ((component as CompositeDrawable)?.AutoSizeAxes.HasFlagFast(Axes.X) != true) + Width = component.Width; + + if ((component as CompositeDrawable)?.AutoSizeAxes.HasFlagFast(Axes.Y) != true) + Height = component.Height; + Anchor = component.Anchor; Origin = component.Origin; From 57cd5194ce06b16e03dc0dea32a0e81da80b1029 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 10 Nov 2023 20:00:20 +0900 Subject: [PATCH 16/21] Flip comparison to allow non-composite drawables to still get resized --- osu.Game/Skinning/SerialisableDrawableExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Skinning/SerialisableDrawableExtensions.cs b/osu.Game/Skinning/SerialisableDrawableExtensions.cs index 6938ed4091..97c4cc8f73 100644 --- a/osu.Game/Skinning/SerialisableDrawableExtensions.cs +++ b/osu.Game/Skinning/SerialisableDrawableExtensions.cs @@ -19,9 +19,9 @@ namespace osu.Game.Skinning // todo: can probably make this better via deserialisation directly using a common interface. component.Position = drawableInfo.Position; component.Rotation = drawableInfo.Rotation; - if (drawableInfo.Width is float width && width != 0 && (component as CompositeDrawable)?.AutoSizeAxes.HasFlagFast(Axes.X) == false) + if (drawableInfo.Width is float width && width != 0 && (component as CompositeDrawable)?.AutoSizeAxes.HasFlagFast(Axes.X) != true) component.Width = width; - if (drawableInfo.Height is float height && height != 0 && (component as CompositeDrawable)?.AutoSizeAxes.HasFlagFast(Axes.Y) == false) + if (drawableInfo.Height is float height && height != 0 && (component as CompositeDrawable)?.AutoSizeAxes.HasFlagFast(Axes.Y) != true) component.Height = height; component.Scale = drawableInfo.Scale; component.Anchor = drawableInfo.Anchor; From 2e48569982039c9c1e6cb722190a6669ea09aee7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 10 Nov 2023 20:00:51 +0900 Subject: [PATCH 17/21] Improve test comparison logic Doesn't really help that much with nunit output, but at least you can breakpoint and see the json kinda. --- .../Visual/Gameplay/TestSceneSkinEditor.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs index 4e5db5d46e..bd56a95809 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs @@ -4,6 +4,9 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; +using System.Text.Unicode; +using Newtonsoft.Json; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; @@ -214,7 +217,11 @@ namespace osu.Game.Tests.Visual.Gameplay }); AddStep("Press undo", () => InputManager.Keys(PlatformAction.Undo)); - AddAssert("Nothing changed", () => defaultState.SequenceEqual(changeHandler.GetCurrentState())); + + AddAssert("Nothing changed", + () => JsonConvert.DeserializeObject>(Encoding.UTF8.GetString(defaultState)), + () => Is.EqualTo(JsonConvert.DeserializeObject>(Encoding.UTF8.GetString(changeHandler.GetCurrentState()))) + ); AddStep("Add components", () => { @@ -243,7 +250,11 @@ namespace osu.Game.Tests.Visual.Gameplay void revertAndCheckUnchanged() { AddStep("Revert changes", () => changeHandler.RestoreState(int.MinValue)); - AddAssert("Current state is same as default", () => defaultState.SequenceEqual(changeHandler.GetCurrentState())); + + AddAssert("Current state is same as default", + () => JsonConvert.DeserializeObject>(Encoding.UTF8.GetString(defaultState)), + () => Is.EqualTo(JsonConvert.DeserializeObject>(Encoding.UTF8.GetString(changeHandler.GetCurrentState()))) + ); } } From 21e1d68b15960c448d9876baaec51776febde22c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 11 Nov 2023 15:52:24 +0900 Subject: [PATCH 18/21] Remove unused using directive --- osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs index bd56a95809..08019c90e1 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; -using System.Text.Unicode; using Newtonsoft.Json; using NUnit.Framework; using osu.Framework.Allocation; From b247b94ecbdb5405de16ba489ef7a62b36cd7656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 11 Nov 2023 19:15:20 +0900 Subject: [PATCH 19/21] Revert test changes They were broken because `SerialisedDrawableInfo` is a reference type and as such equality checks will use reference equality rather than member equality. --- .../Visual/Gameplay/TestSceneSkinEditor.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs index 08019c90e1..4e5db5d46e 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs @@ -4,8 +4,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; -using Newtonsoft.Json; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; @@ -216,11 +214,7 @@ namespace osu.Game.Tests.Visual.Gameplay }); AddStep("Press undo", () => InputManager.Keys(PlatformAction.Undo)); - - AddAssert("Nothing changed", - () => JsonConvert.DeserializeObject>(Encoding.UTF8.GetString(defaultState)), - () => Is.EqualTo(JsonConvert.DeserializeObject>(Encoding.UTF8.GetString(changeHandler.GetCurrentState()))) - ); + AddAssert("Nothing changed", () => defaultState.SequenceEqual(changeHandler.GetCurrentState())); AddStep("Add components", () => { @@ -249,11 +243,7 @@ namespace osu.Game.Tests.Visual.Gameplay void revertAndCheckUnchanged() { AddStep("Revert changes", () => changeHandler.RestoreState(int.MinValue)); - - AddAssert("Current state is same as default", - () => JsonConvert.DeserializeObject>(Encoding.UTF8.GetString(defaultState)), - () => Is.EqualTo(JsonConvert.DeserializeObject>(Encoding.UTF8.GetString(changeHandler.GetCurrentState()))) - ); + AddAssert("Current state is same as default", () => defaultState.SequenceEqual(changeHandler.GetCurrentState())); } } From ee56b4d205f916ea9cf45543c72cce34f53b8a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 11 Nov 2023 20:55:47 +0900 Subject: [PATCH 20/21] Use barely better assertion fail message in test --- osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs index 4e5db5d46e..92f28288ca 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; @@ -243,7 +244,9 @@ namespace osu.Game.Tests.Visual.Gameplay void revertAndCheckUnchanged() { AddStep("Revert changes", () => changeHandler.RestoreState(int.MinValue)); - AddAssert("Current state is same as default", () => defaultState.SequenceEqual(changeHandler.GetCurrentState())); + AddAssert("Current state is same as default", + () => Encoding.UTF8.GetString(defaultState), + () => Is.EqualTo(Encoding.UTF8.GetString(changeHandler.GetCurrentState()))); } } From 50789d2e18a43dd3b2a2e99ea9487851972f35f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 11 Nov 2023 21:28:04 +0900 Subject: [PATCH 21/21] Fix song progress bars not sizing vertically properly --- .../Screens/Play/HUD/ArgonSongProgress.cs | 66 +++++++++++-------- .../Screens/Play/HUD/DefaultSongProgress.cs | 49 ++++++++------ 2 files changed, 65 insertions(+), 50 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs b/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs index be2ce3b272..cb38854bca 100644 --- a/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs +++ b/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs @@ -19,6 +19,7 @@ namespace osu.Game.Screens.Play.HUD private readonly ArgonSongProgressGraph graph; private readonly ArgonSongProgressBar bar; private readonly Container graphContainer; + private readonly Container content; private const float bar_height = 10; @@ -30,43 +31,50 @@ namespace osu.Game.Screens.Play.HUD public ArgonSongProgress() { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Anchor = Anchor.BottomCentre; Origin = Anchor.BottomCentre; Masking = true; CornerRadius = 5; - Children = new Drawable[] + + Child = content = new Container { - info = new SongProgressInfo + RelativeSizeAxes = Axes.X, + Children = new Drawable[] { - Origin = Anchor.TopLeft, - Name = "Info", - Anchor = Anchor.TopLeft, - RelativeSizeAxes = Axes.X, - ShowProgress = false - }, - bar = new ArgonSongProgressBar(bar_height) - { - Name = "Seek bar", - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - OnSeek = time => player?.Seek(time), - }, - graphContainer = new Container - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Masking = true, - CornerRadius = 5, - Child = graph = new ArgonSongProgressGraph + info = new SongProgressInfo { - Name = "Difficulty graph", - RelativeSizeAxes = Axes.Both, - Blending = BlendingParameters.Additive + Origin = Anchor.TopLeft, + Name = "Info", + Anchor = Anchor.TopLeft, + RelativeSizeAxes = Axes.X, + ShowProgress = false }, - RelativeSizeAxes = Axes.X, - }, + bar = new ArgonSongProgressBar(bar_height) + { + Name = "Seek bar", + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + OnSeek = time => player?.Seek(time), + }, + graphContainer = new Container + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Masking = true, + CornerRadius = 5, + Child = graph = new ArgonSongProgressGraph + { + Name = "Difficulty graph", + RelativeSizeAxes = Axes.Both, + Blending = BlendingParameters.Additive + }, + RelativeSizeAxes = Axes.X, + }, + } }; - RelativeSizeAxes = Axes.X; } [BackgroundDependencyLoader] @@ -100,7 +108,7 @@ namespace osu.Game.Screens.Play.HUD protected override void Update() { base.Update(); - Height = bar.Height + bar_height + info.Height; + content.Height = bar.Height + bar_height + info.Height; graphContainer.Height = bar.Height; } diff --git a/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs b/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs index 202ead2d66..48809796f3 100644 --- a/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs +++ b/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Utils; using osu.Game.Configuration; using osu.Game.Graphics; @@ -27,6 +28,7 @@ namespace osu.Game.Screens.Play.HUD private readonly DefaultSongProgressBar bar; private readonly DefaultSongProgressGraph graph; private readonly SongProgressInfo info; + private readonly Container content; [SettingSource(typeof(SongProgressStrings), nameof(SongProgressStrings.ShowGraph), nameof(SongProgressStrings.ShowGraphDescription))] public Bindable ShowGraph { get; } = new BindableBool(true); @@ -37,31 +39,36 @@ namespace osu.Game.Screens.Play.HUD public DefaultSongProgress() { RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; Anchor = Anchor.BottomRight; Origin = Anchor.BottomRight; - Children = new Drawable[] + Child = content = new Container { - info = new SongProgressInfo + RelativeSizeAxes = Axes.X, + Children = new Drawable[] { - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - }, - graph = new DefaultSongProgressGraph - { - RelativeSizeAxes = Axes.X, - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - Height = graph_height, - Margin = new MarginPadding { Bottom = bottom_bar_height }, - }, - bar = new DefaultSongProgressBar(bottom_bar_height, graph_height, handle_size) - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - OnSeek = time => player?.Seek(time), - }, + info = new SongProgressInfo + { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + }, + graph = new DefaultSongProgressGraph + { + RelativeSizeAxes = Axes.X, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Height = graph_height, + Margin = new MarginPadding { Bottom = bottom_bar_height }, + }, + bar = new DefaultSongProgressBar(bottom_bar_height, graph_height, handle_size) + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + OnSeek = time => player?.Seek(time), + }, + } }; } @@ -107,7 +114,7 @@ namespace osu.Game.Screens.Play.HUD float newHeight = bottom_bar_height + graph_height + handle_size.Y + info.Height - graph.Y; if (!Precision.AlmostEquals(Height, newHeight, 5f)) - Height = newHeight; + content.Height = newHeight; } private void updateBarVisibility()