Merge branch 'master' into audio-ducking-fx

This commit is contained in:
Salman Ahmed 2024-07-08 12:26:10 +03:00 committed by GitHub
commit 784a9ae743
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 131 additions and 16 deletions

View File

@ -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

View File

@ -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<SamplePointPiece>().Single(piece => piece.HitObject == EditorBeatmap.HitObjects.ElementAt(objectIndex));

View File

@ -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;
@ -114,10 +115,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 +129,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<Playfield>().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<Playfield>().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<Playfield>().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]
@ -155,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<Playfield>().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)));
}
}
}

View File

@ -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);

View File

@ -156,22 +156,35 @@ namespace osu.Game.Rulesets.Edit
comboInformation.UpdateComboInformation(getPreviousHitObject() as IHasComboInformation);
}
var lastHitNormal = getPreviousHitObject()?.Samples?.FirstOrDefault(o => o.Name == HitSampleInfo.HIT_NORMAL);
var lastHitObject = getPreviousHitObject();
if (lastHitNormal != null)
if (AutomaticBankAssignment)
{
if (AutomaticBankAssignment)
// Create samples based on the sample settings of the previous hit object
if (lastHitObject != null)
{
// Take the hitnormal sample of the last hit object
HitObject.Samples[0] = lastHitNormal;
for (int i = 0; i < HitObject.Samples.Count; i++)
HitObject.Samples[i] = lastHitObject.CreateHitSampleInfo(HitObject.Samples[i].Name);
}
else
}
else
{
var lastHitNormal = lastHitObject?.Samples?.FirstOrDefault(o => o.Name == HitSampleInfo.HIT_NORMAL);
if (lastHitNormal != null)
{
// Only inherit the volume from the previous hit object
for (int i = 0; i < HitObject.Samples.Count; i++)
HitObject.Samples[i] = HitObject.Samples[i].With(newVolume: lastHitNormal.Volume);
}
}
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();
}
}
/// <summary>

View File

@ -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<IList<HitSampleInfo>> enumerateAllSamples(HitObject hitObject)