From 8dd04b6e9a699c51fef83384e84bca800a451661 Mon Sep 17 00:00:00 2001 From: OliBomby Date: Thu, 4 Jul 2024 00:39:12 +0200 Subject: [PATCH 1/9] update nodesamples on placement --- osu.Game/Rulesets/Edit/PlacementBlueprint.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs index 5cb9adfd72..a30434638f 100644 --- a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs +++ b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs @@ -163,6 +163,15 @@ namespace osu.Game.Rulesets.Edit if (lastHitNormal != null) HitObject.Samples[0] = lastHitNormal; } + + if (HitObject is IHasRepeats hasRepeats) + { + // Make sure all the node samples are identical to the hit object's samples + for (int i = 0; i < hasRepeats.NodeSamples.Count; i++) + { + hasRepeats.NodeSamples[i] = HitObject.Samples.Select(o => o.With()).ToList(); + } + } } /// From 8f3a30b0b9ba86adfd6b8c0690fc716608abad2c Mon Sep 17 00:00:00 2001 From: OliBomby Date: Thu, 4 Jul 2024 00:56:53 +0200 Subject: [PATCH 2/9] inherit addition bank from last hitobject --- osu.Game/Rulesets/Edit/PlacementBlueprint.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs index 5cb9adfd72..762a714088 100644 --- a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs +++ b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs @@ -158,10 +158,16 @@ namespace osu.Game.Rulesets.Edit if (AutomaticBankAssignment) { - // Take the hitnormal sample of the last hit object - var lastHitNormal = getPreviousHitObject()?.Samples?.FirstOrDefault(o => o.Name == HitSampleInfo.HIT_NORMAL); - if (lastHitNormal != null) - HitObject.Samples[0] = lastHitNormal; + // Create samples based on the sample settings of the previous hit object + var lastHitObject = getPreviousHitObject(); + + if (lastHitObject != null) + { + for (int i = 0; i < HitObject.Samples.Count; i++) + { + HitObject.Samples[i] = lastHitObject.CreateHitSampleInfo(HitObject.Samples[i].Name); + } + } } } From 08a77bfe38e740d0df364107383a8a1db9117be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 4 Jul 2024 15:02:35 +0200 Subject: [PATCH 3/9] Extend test coverage --- .../Editing/TestScenePlacementBlueprint.cs | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Editing/TestScenePlacementBlueprint.cs b/osu.Game.Tests/Visual/Editing/TestScenePlacementBlueprint.cs index c16533126b..ee2855354a 100644 --- a/osu.Game.Tests/Visual/Editing/TestScenePlacementBlueprint.cs +++ b/osu.Game.Tests/Visual/Editing/TestScenePlacementBlueprint.cs @@ -114,10 +114,11 @@ namespace osu.Game.Tests.Visual.Editing Samples = { new HitSampleInfo(name: HitSampleInfo.HIT_NORMAL, bank: HitSampleInfo.BANK_SOFT, volume: 70), - new HitSampleInfo(name: HitSampleInfo.HIT_WHISTLE, bank: HitSampleInfo.BANK_SOFT, volume: 70), + new HitSampleInfo(name: HitSampleInfo.HIT_WHISTLE, bank: HitSampleInfo.BANK_DRUM, volume: 70), } })); - AddStep("seek to 500", () => EditorClock.Seek(500)); + + AddStep("seek to 500", () => EditorClock.Seek(500)); // previous object is the one at time 0 AddStep("enable automatic bank assignment", () => { InputManager.PressKey(Key.LShift); @@ -127,8 +128,28 @@ namespace osu.Game.Tests.Visual.Editing AddStep("select circle placement tool", () => InputManager.Key(Key.Number2)); AddStep("move mouse to center of playfield", () => InputManager.MoveMouseTo(this.ChildrenOfType().Single())); AddStep("place circle", () => InputManager.Click(MouseButton.Left)); - AddAssert("circle has soft bank", () => EditorBeatmap.HitObjects[1].Samples.All(s => s.Bank == HitSampleInfo.BANK_SOFT)); + AddAssert("circle has soft bank", () => EditorBeatmap.HitObjects[1].Samples.Single().Bank, () => Is.EqualTo(HitSampleInfo.BANK_SOFT)); AddAssert("circle inherited volume", () => EditorBeatmap.HitObjects[1].Samples.All(s => s.Volume == 70)); + + AddStep("seek to 250", () => EditorClock.Seek(250)); // previous object is the one at time 0 + AddStep("enable clap addition", () => InputManager.Key(Key.R)); + AddStep("select circle placement tool", () => InputManager.Key(Key.Number2)); + AddStep("move mouse to center of playfield", () => InputManager.MoveMouseTo(this.ChildrenOfType().Single())); + AddStep("place circle", () => InputManager.Click(MouseButton.Left)); + AddAssert("circle has 2 samples", () => EditorBeatmap.HitObjects[1].Samples, () => Has.Count.EqualTo(2)); + AddAssert("normal sample has soft bank", () => EditorBeatmap.HitObjects[1].Samples.Single(s => s.Name == HitSampleInfo.HIT_NORMAL).Bank, + () => Is.EqualTo(HitSampleInfo.BANK_SOFT)); + AddAssert("clap sample has drum bank", () => EditorBeatmap.HitObjects[1].Samples.Single(s => s.Name == HitSampleInfo.HIT_CLAP).Bank, + () => Is.EqualTo(HitSampleInfo.BANK_DRUM)); + AddAssert("circle inherited volume", () => EditorBeatmap.HitObjects[1].Samples.All(s => s.Volume == 70)); + + AddStep("seek to 1000", () => EditorClock.Seek(1000)); // previous object is the one at time 500, which has no additions + AddStep("select circle placement tool", () => InputManager.Key(Key.Number2)); + AddStep("move mouse to center of playfield", () => InputManager.MoveMouseTo(this.ChildrenOfType().Single())); + AddStep("place circle", () => InputManager.Click(MouseButton.Left)); + AddAssert("circle has 2 samples", () => EditorBeatmap.HitObjects[3].Samples, () => Has.Count.EqualTo(2)); + AddAssert("all samples have soft bank", () => EditorBeatmap.HitObjects[3].Samples.All(s => s.Bank == HitSampleInfo.BANK_SOFT)); + AddAssert("circle inherited volume", () => EditorBeatmap.HitObjects[3].Samples.All(s => s.Volume == 70)); } [Test] From e005b46df97397126220167289143e335002535a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 4 Jul 2024 15:19:28 +0200 Subject: [PATCH 4/9] Extend test coverage --- .../Editing/TestScenePlacementBlueprint.cs | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/osu.Game.Tests/Visual/Editing/TestScenePlacementBlueprint.cs b/osu.Game.Tests/Visual/Editing/TestScenePlacementBlueprint.cs index ee2855354a..e9b442f8dd 100644 --- a/osu.Game.Tests/Visual/Editing/TestScenePlacementBlueprint.cs +++ b/osu.Game.Tests/Visual/Editing/TestScenePlacementBlueprint.cs @@ -10,6 +10,7 @@ using osu.Game.Beatmaps; using osu.Game.Input.Bindings; using osu.Game.Rulesets; using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.UI; @@ -176,5 +177,48 @@ namespace osu.Game.Tests.Visual.Editing AddAssert("circle has drum bank", () => EditorBeatmap.HitObjects[1].Samples.All(s => s.Bank == HitSampleInfo.BANK_DRUM)); AddAssert("circle inherited volume", () => EditorBeatmap.HitObjects[1].Samples.All(s => s.Volume == 70)); } + + [Test] + public void TestNodeSamplesAndSamplesAreSame() + { + Playfield playfield = null!; + + AddStep("select drum bank", () => + { + InputManager.PressKey(Key.LShift); + InputManager.Key(Key.R); + InputManager.ReleaseKey(Key.LShift); + }); + AddStep("enable clap addition", () => InputManager.Key(Key.R)); + + AddStep("select slider placement tool", () => InputManager.Key(Key.Number3)); + AddStep("move mouse to top left of playfield", () => + { + playfield = this.ChildrenOfType().Single(); + var location = (3 * playfield.ScreenSpaceDrawQuad.TopLeft + playfield.ScreenSpaceDrawQuad.BottomRight) / 4; + InputManager.MoveMouseTo(location); + }); + AddStep("begin placement", () => InputManager.Click(MouseButton.Left)); + AddStep("move mouse to bottom right of playfield", () => + { + var location = (playfield.ScreenSpaceDrawQuad.TopLeft + 3 * playfield.ScreenSpaceDrawQuad.BottomRight) / 4; + InputManager.MoveMouseTo(location); + }); + AddStep("confirm via global action", () => + { + globalActionContainer.TriggerPressed(GlobalAction.Select); + globalActionContainer.TriggerReleased(GlobalAction.Select); + }); + AddAssert("slider placed", () => EditorBeatmap.HitObjects.Count, () => Is.EqualTo(1)); + + AddAssert("slider samples have drum bank", () => EditorBeatmap.HitObjects[0].Samples.All(s => s.Bank == HitSampleInfo.BANK_DRUM)); + AddAssert("slider node samples have drum bank", + () => ((IHasRepeats)EditorBeatmap.HitObjects[0]).NodeSamples.SelectMany(s => s).All(s => s.Bank == HitSampleInfo.BANK_DRUM)); + + AddAssert("slider samples have clap addition", + () => EditorBeatmap.HitObjects[0].Samples.Select(s => s.Name), () => Does.Contain(HitSampleInfo.HIT_CLAP)); + AddAssert("slider node samples have clap addition", + () => ((IHasRepeats)EditorBeatmap.HitObjects[0]).NodeSamples.All(samples => samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP))); + } } } From 652d2e963313f53b19b97108c3ad6e454910961c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 4 Jul 2024 15:19:36 +0200 Subject: [PATCH 5/9] Adjust code style --- osu.Game/Rulesets/Edit/PlacementBlueprint.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs index 8a3fac6d3a..2817e26abd 100644 --- a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs +++ b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs @@ -183,9 +183,7 @@ namespace osu.Game.Rulesets.Edit { // Make sure all the node samples are identical to the hit object's samples for (int i = 0; i < hasRepeats.NodeSamples.Count; i++) - { hasRepeats.NodeSamples[i] = HitObject.Samples.Select(o => o.With()).ToList(); - } } } From d6c1b5d3991a4e9187e85806697b7f3b1e49206b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 5 Jul 2024 08:54:47 +0200 Subject: [PATCH 6/9] Add failing test coverage --- .../TestSceneHitObjectSampleAdjustments.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/osu.Game.Tests/Visual/Editing/TestSceneHitObjectSampleAdjustments.cs b/osu.Game.Tests/Visual/Editing/TestSceneHitObjectSampleAdjustments.cs index 9988c1cb59..558d8dce94 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneHitObjectSampleAdjustments.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneHitObjectSampleAdjustments.cs @@ -484,6 +484,25 @@ namespace osu.Game.Tests.Visual.Editing hitObjectNodeHasSamples(2, 1, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_WHISTLE); } + [Test] + public void TestSelectingObjectDoesNotMutateSamples() + { + clickSamplePiece(0); + toggleAdditionViaPopover(1); + setAdditionBankViaPopover(HitSampleInfo.BANK_SOFT); + dismissPopover(); + + hitObjectHasSamples(0, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_FINISH); + hitObjectHasSampleNormalBank(0, HitSampleInfo.BANK_NORMAL); + hitObjectHasSampleAdditionBank(0, HitSampleInfo.BANK_SOFT); + + AddStep("select first object", () => EditorBeatmap.SelectedHitObjects.Add(EditorBeatmap.HitObjects[0])); + + hitObjectHasSamples(0, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_FINISH); + hitObjectHasSampleNormalBank(0, HitSampleInfo.BANK_NORMAL); + hitObjectHasSampleAdditionBank(0, HitSampleInfo.BANK_SOFT); + } + private void clickSamplePiece(int objectIndex) => AddStep($"click {objectIndex.ToOrdinalWords()} sample piece", () => { var samplePiece = this.ChildrenOfType().Single(piece => piece.HitObject == EditorBeatmap.HitObjects.ElementAt(objectIndex)); From 4c59ec1d94489857b12705a2d195b59aed019f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 5 Jul 2024 09:10:38 +0200 Subject: [PATCH 7/9] Fix incorrect ternary state computation for bank toggles Closes https://github.com/ppy/osu/issues/28741. Regressed in a7b066f3ee59b9e9f13344ce3af4c5e7cf511e67. The intent of the original change there was to ensure that addition banks being set will put the ternary state toggles in indeterminate state (to at least provide a visual indication that the selection does not use a single bank). This would previously not be the case due to the use of `.All()` in the original condition (a single object/node was considered to have a bank enabled if and only if *all* samples within it used it). However the attempt to fix that via switching to `Any()` was not correct. The logic used in the offending commit operates on extracted `Samples` and `NodeSamples` from the selection, and would consider the ternary toggle: - fully off if none of the samples/node samples contained a sample with the given bank, - indeterminate if the some of the samples/node samples contained a sample with the given bank, - fully on if at least one sample from every samples/node samples contained a sample with the given bank. This is a *two-tiered* process, as in first a *binary* on/off state is extracted from each object's samples/node samples, and *then* a ternary state is extracted from all objects/nodes. This is insufficient to express the *desired* behaviour, which is that the toggle should be: - fully off if *none of the individual samples in the selection* use the given bank, - indeterminate if *at least one individual sample in the selection* uses the given bank, - fully on if *all individual samples in the selection* use the given bank. The second wording is flattened, and no longer tries to consider "nodes" or "objects", it just looks at all of the samples in the selection without concern as to whether they're from separate objects/nodes or not. To explain why this discrepancy caused the bug, consider a single object with a `soft` normal bank and `drum` addition bank. Selecting the object would cause a ternary button state update; as per the incorrect logic, there were two samples on the object and each had its own separate banks, so two ternary toggles would have their state set to `True` (rather than the correct `Indeterminate`), thus triggering a bindable feedback loop that would cause one of these banks to win and actually overwrite the other. Note that the addition indeterminate state computation *still* needs to do the two-tiered process, because there it actually makes sense (for a selection to have an addition fully on rather than indeterminate, *every* object/node *must* contain that addition). --- .../Screens/Edit/Compose/Components/EditorSelectionHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/EditorSelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/EditorSelectionHandler.cs index 70c91b16fd..a4efe66bf8 100644 --- a/osu.Game/Screens/Edit/Compose/Components/EditorSelectionHandler.cs +++ b/osu.Game/Screens/Edit/Compose/Components/EditorSelectionHandler.cs @@ -186,7 +186,7 @@ namespace osu.Game.Screens.Edit.Compose.Components foreach ((string bankName, var bindable) in SelectionBankStates) { - bindable.Value = GetStateFromSelection(samplesInSelection, h => h.Any(s => s.Bank == bankName)); + bindable.Value = GetStateFromSelection(samplesInSelection.SelectMany(s => s), h => h.Bank == bankName); } IEnumerable> enumerateAllSamples(HitObject hitObject) From 9375f79879fe6ccd6e1d1dacc87dba63d33cee9f Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 8 Jul 2024 13:58:42 +0900 Subject: [PATCH 8/9] Add frenzibyte to users that can use diffcalc workflow --- .github/workflows/diffcalc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/diffcalc.yml b/.github/workflows/diffcalc.yml index 7fd0f798cd..9f129a697c 100644 --- a/.github/workflows/diffcalc.yml +++ b/.github/workflows/diffcalc.yml @@ -111,7 +111,7 @@ jobs: steps: - name: Check permissions run: | - ALLOWED_USERS=(smoogipoo peppy bdach) + ALLOWED_USERS=(smoogipoo peppy bdach frenzibyte) for i in "${ALLOWED_USERS[@]}"; do if [[ "${{ github.actor }}" == "$i" ]]; then exit 0 From 03bd6069d88827575f19018c0d599cc3e865972d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 8 Jul 2024 15:50:27 +0900 Subject: [PATCH 9/9] Add slight animation when revert to default button is displayed This also fixes the transforms running too often (could make the initial transform take longer than expected if adjusting a slider bar, for instance). --- osu.Game/Overlays/RevertToDefaultButton.cs | 28 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/RevertToDefaultButton.cs b/osu.Game/Overlays/RevertToDefaultButton.cs index 6fa5209f64..1ebe7b7934 100644 --- a/osu.Game/Overlays/RevertToDefaultButton.cs +++ b/osu.Game/Overlays/RevertToDefaultButton.cs @@ -87,6 +87,7 @@ namespace osu.Game.Overlays protected override void LoadComplete() { base.LoadComplete(); + updateState(); FinishTransforms(true); } @@ -95,33 +96,50 @@ namespace osu.Game.Overlays protected override bool OnHover(HoverEvent e) { - UpdateState(); + updateHover(); return false; } protected override void OnHoverLost(HoverLostEvent e) { - UpdateState(); + updateHover(); } public void UpdateState() => Scheduler.AddOnce(updateState); private const double fade_duration = 200; + private bool? isDisplayed; + private void updateState() { if (current == null) return; - Enabled.Value = !current.Disabled; + // Avoid running animations if we are already in an up-to-date state. + if (Enabled.Value == !current.Disabled && isDisplayed == !current.IsDefault) + return; - if (current.IsDefault) + Enabled.Value = !current.Disabled; + isDisplayed = !current.IsDefault; + + updateHover(); + + if (isDisplayed == false) this.FadeTo(0, fade_duration, Easing.OutQuint); else if (current.Disabled) this.FadeTo(0.2f, fade_duration, Easing.OutQuint); else - this.FadeTo(1, fade_duration, Easing.OutQuint); + { + icon.RotateTo(150).RotateTo(0, fade_duration * 2, Easing.OutQuint); + icon.ScaleTo(0.7f).ScaleTo(1, fade_duration * 2, Easing.OutQuint); + this.FadeTo(1, fade_duration, Easing.OutQuint); + } + } + + private void updateHover() + { if (IsHovered && Enabled.Value) { icon.RotateTo(-40, 500, Easing.OutQuint);