Skip to content

Commit

Permalink
Merge branch 'master' into fix-directory-selector-breadcrumb
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Nov 1, 2022
2 parents e104242 + 3f48aff commit 9f031b5
Show file tree
Hide file tree
Showing 17 changed files with 83 additions and 35 deletions.
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Mania/Mods/ManiaModHoldOff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ManiaModHoldOff : Mod, IApplicableAfterBeatmapConversion

public override string Acronym => "HO";

public override double ScoreMultiplier => 1;
public override double ScoreMultiplier => 0.9;

public override LocalisableString Description => @"Replaces all hold notes with normal notes.";

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu.Tests/OsuLegacyModConversionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class OsuLegacyModConversionTest : LegacyModConversionTest
new object[] { LegacyMods.Autoplay, new[] { typeof(OsuModAutoplay) } },
new object[] { LegacyMods.SpunOut, new[] { typeof(OsuModSpunOut) } },
new object[] { LegacyMods.Autopilot, new[] { typeof(OsuModAutopilot) } },
new object[] { LegacyMods.Target, new[] { typeof(OsuModTarget) } },
new object[] { LegacyMods.Target, new[] { typeof(OsuModTargetPractice) } },
new object[] { LegacyMods.HardRock | LegacyMods.DoubleTime, new[] { typeof(OsuModHardRock), typeof(OsuModDoubleTime) } }
};

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu/Mods/OsuModRandom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class OsuModRandom : ModRandom, IApplicableToBeatmap
{
public override LocalisableString Description => "It never gets boring!";

public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModTarget)).ToArray();
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModTargetPractice)).ToArray();

[SettingSource("Angle sharpness", "How sharp angles should be", SettingControlType = typeof(SettingsSlider<float>))]
public BindableFloat AngleSharpness { get; } = new BindableFloat(7)
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu/Mods/OsuModSpunOut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class OsuModSpunOut : Mod, IApplicableToDrawableHitObject
public override ModType Type => ModType.Automation;
public override LocalisableString Description => @"Spinners will be automatically completed.";
public override double ScoreMultiplier => 0.9;
public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(OsuModAutopilot), typeof(OsuModTarget) };
public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(OsuModAutopilot), typeof(OsuModTargetPractice) };

public void ApplyToDrawableHitObject(DrawableHitObject hitObject)
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu/Mods/OsuModStrictTracking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class OsuModStrictTracking : Mod, IApplicableAfterBeatmapConversion, IApp
public override ModType Type => ModType.DifficultyIncrease;
public override LocalisableString Description => @"Once you start a slider, follow precisely or get a miss.";
public override double ScoreMultiplier => 1.0;
public override Type[] IncompatibleMods => new[] { typeof(ModClassic), typeof(OsuModTarget) };
public override Type[] IncompatibleMods => new[] { typeof(ModClassic), typeof(OsuModTargetPractice) };

public void ApplyToDrawableHitObject(DrawableHitObject drawable)
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu/Mods/OsuModSuddenDeath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class OsuModSuddenDeath : ModSuddenDeath
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[]
{
typeof(OsuModAutopilot),
typeof(OsuModTarget),
typeof(OsuModTargetPractice),
}).ToArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,15 @@

namespace osu.Game.Rulesets.Osu.Mods
{
public class OsuModTarget : ModWithVisibilityAdjustment, IApplicableToDrawableRuleset<OsuHitObject>,
IApplicableToHealthProcessor, IApplicableToDifficulty, IApplicableFailOverride,
IHasSeed, IHidesApproachCircles
public class OsuModTargetPractice : ModWithVisibilityAdjustment, IApplicableToDrawableRuleset<OsuHitObject>,
IApplicableToHealthProcessor, IApplicableToDifficulty, IApplicableFailOverride, IHasSeed, IHidesApproachCircles
{
public override string Name => "Target";
public override string Name => "Target Practice";
public override string Acronym => "TP";
public override ModType Type => ModType.Conversion;
public override IconUsage? Icon => OsuIcon.ModTarget;
public override LocalisableString Description => @"Practice keeping up with the beat of the song.";
public override double ScoreMultiplier => 1;
public override double ScoreMultiplier => 0.1;

public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[]
{
Expand Down
6 changes: 3 additions & 3 deletions osu.Game.Rulesets.Osu/OsuRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public override IEnumerable<Mod> ConvertFromLegacyMods(LegacyMods mods)
yield return new OsuModSpunOut();

if (mods.HasFlagFast(LegacyMods.Target))
yield return new OsuModTarget();
yield return new OsuModTargetPractice();

if (mods.HasFlagFast(LegacyMods.TouchDevice))
yield return new OsuModTouchDevice();
Expand All @@ -131,7 +131,7 @@ public override LegacyMods ConvertToLegacyMods(Mod[] mods)
value |= LegacyMods.SpunOut;
break;

case OsuModTarget:
case OsuModTargetPractice:
value |= LegacyMods.Target;
break;

Expand Down Expand Up @@ -170,7 +170,7 @@ public override IEnumerable<Mod> GetModsFor(ModType type)
case ModType.Conversion:
return new Mod[]
{
new OsuModTarget(),
new OsuModTargetPractice(),
new OsuModDifficultyAdjust(),
new OsuModClassic(),
new OsuModRandom(),
Expand Down
8 changes: 6 additions & 2 deletions osu.Game.Rulesets.Osu/Skinning/Argon/ArgonMainCirclePiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@ protected override void LoadComplete()
innerGradient.Colour = ColourInfo.GradientVertical(colour.NewValue.Darken(0.5f), colour.NewValue.Darken(0.6f));
flash.Colour = colour.NewValue;

updateStateTransforms(drawableObject, drawableObject.State.Value);
// Accent colour may be changed many times during a paused gameplay state.
// Schedule the change to avoid transforms piling up.
Scheduler.AddOnce(updateStateTransforms);
}, true);

drawableObject.ApplyCustomUpdateState += updateStateTransforms;
}

private void updateStateTransforms() => updateStateTransforms(drawableObject, drawableObject.State.Value);

private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
{
using (BeginAbsoluteSequence(drawableObject.HitStateUpdateTime))
Expand Down Expand Up @@ -171,7 +175,7 @@ private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedSta
// This is to give it a bomb-like effect, with the border "triggering" its animation when getting close.
using (BeginDelayedSequence(flash_in_duration / 12))
{
outerGradient.ResizeTo(outerGradient.Size * shrink_size, resize_duration, Easing.OutElasticHalf);
outerGradient.ResizeTo(OUTER_GRADIENT_SIZE * shrink_size, resize_duration, Easing.OutElasticHalf);
outerGradient
.FadeColour(Color4.White, 80)
.Then()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
Expand Down Expand Up @@ -66,7 +67,7 @@ public void TestSliderMultiplier(float multiplier)
{
AddStep($"set slider multiplier = {multiplier}", () => composer.EditorBeatmap.Difficulty.SliderMultiplier = multiplier);

assertSnapDistance(100 * multiplier);
assertSnapDistance(100 * multiplier, null, true);
}

[TestCase(1)]
Expand All @@ -79,7 +80,20 @@ public void TestSpeedMultiplierDoesNotChangeDistanceSnap(float multiplier)
{
SliderVelocity = multiplier
}
});
}, false);
}

[TestCase(1)]
[TestCase(2)]
public void TestSpeedMultiplierDoesChangeDistanceSnap(float multiplier)
{
assertSnapDistance(100 * multiplier, new HitObject
{
DifficultyControlPoint = new DifficultyControlPoint
{
SliderVelocity = multiplier
}
}, true);
}

[TestCase(1)]
Expand All @@ -88,7 +102,32 @@ public void TestBeatDivisor(int divisor)
{
AddStep($"set divisor = {divisor}", () => BeatDivisor.Value = divisor);

assertSnapDistance(100f / divisor);
assertSnapDistance(100f / divisor, null, true);
}

/// <summary>
/// The basic distance-duration functions should always include slider velocity of the reference object.
/// </summary>
[Test]
public void TestConversionsWithSliderVelocity()
{
const float base_distance = 100;
const float slider_velocity = 1.2f;

var referenceObject = new HitObject
{
DifficultyControlPoint = new DifficultyControlPoint
{
SliderVelocity = slider_velocity
}
};

assertSnapDistance(base_distance * slider_velocity, referenceObject, true);
assertSnappedDistance(base_distance * slider_velocity + 10, base_distance * slider_velocity, referenceObject);
assertSnappedDuration(base_distance * slider_velocity + 10, 1000, referenceObject);

assertDistanceToDuration(base_distance * slider_velocity, 1000, referenceObject);
assertDurationToDistance(1000, base_distance * slider_velocity, referenceObject);
}

[Test]
Expand Down Expand Up @@ -197,20 +236,20 @@ public void GetSnappedDistanceFromDistance()
assertSnappedDistance(400, 400);
}

private void assertSnapDistance(float expectedDistance, HitObject? hitObject = null)
=> AddAssert($"distance is {expectedDistance}", () => composer.GetBeatSnapDistanceAt(hitObject ?? new HitObject()), () => Is.EqualTo(expectedDistance));
private void assertSnapDistance(float expectedDistance, HitObject? referenceObject, bool includeSliderVelocity)
=> AddAssert($"distance is {expectedDistance}", () => composer.GetBeatSnapDistanceAt(referenceObject ?? new HitObject(), includeSliderVelocity), () => Is.EqualTo(expectedDistance).Within(Precision.FLOAT_EPSILON));

private void assertDurationToDistance(double duration, float expectedDistance)
=> AddAssert($"duration = {duration} -> distance = {expectedDistance}", () => composer.DurationToDistance(new HitObject(), duration) == expectedDistance);
private void assertDurationToDistance(double duration, float expectedDistance, HitObject? referenceObject = null)
=> AddAssert($"duration = {duration} -> distance = {expectedDistance}", () => composer.DurationToDistance(referenceObject ?? new HitObject(), duration), () => Is.EqualTo(expectedDistance).Within(Precision.FLOAT_EPSILON));

private void assertDistanceToDuration(float distance, double expectedDuration)
=> AddAssert($"distance = {distance} -> duration = {expectedDuration}", () => composer.DistanceToDuration(new HitObject(), distance) == expectedDuration);
private void assertDistanceToDuration(float distance, double expectedDuration, HitObject? referenceObject = null)
=> AddAssert($"distance = {distance} -> duration = {expectedDuration}", () => composer.DistanceToDuration(referenceObject ?? new HitObject(), distance), () => Is.EqualTo(expectedDuration).Within(Precision.FLOAT_EPSILON));

private void assertSnappedDuration(float distance, double expectedDuration)
=> AddAssert($"distance = {distance} -> duration = {expectedDuration} (snapped)", () => composer.FindSnappedDuration(new HitObject(), distance) == expectedDuration);
private void assertSnappedDuration(float distance, double expectedDuration, HitObject? referenceObject = null)
=> AddAssert($"distance = {distance} -> duration = {expectedDuration} (snapped)", () => composer.FindSnappedDuration(referenceObject ?? new HitObject(), distance), () => Is.EqualTo(expectedDuration).Within(Precision.FLOAT_EPSILON));

private void assertSnappedDistance(float distance, float expectedDistance)
=> AddAssert($"distance = {distance} -> distance = {expectedDistance} (snapped)", () => composer.FindSnappedDistance(new HitObject(), distance) == expectedDistance);
private void assertSnappedDistance(float distance, float expectedDistance, HitObject? referenceObject = null)
=> AddAssert($"distance = {distance} -> distance = {expectedDistance} (snapped)", () => composer.FindSnappedDistance(referenceObject ?? new HitObject(), distance), () => Is.EqualTo(expectedDistance).Within(Precision.FLOAT_EPSILON));

private class TestHitObjectComposer : OsuHitObjectComposer
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tests/Visual/Editing/TestSceneDistanceSnapGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private class SnapProvider : IDistanceSnapProvider

IBindable<double> IDistanceSnapProvider.DistanceSpacingMultiplier => DistanceSpacingMultiplier;

public float GetBeatSnapDistanceAt(HitObject referenceObject) => beat_snap_distance;
public float GetBeatSnapDistanceAt(HitObject referenceObject, bool useReferenceSliderVelocity = true) => beat_snap_distance;

public float DurationToDistance(HitObject referenceObject, double duration) => (float)duration;

Expand Down
1 change: 1 addition & 0 deletions osu.Game/Beatmaps/BeatmapConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public IBeatmap Convert(CancellationToken cancellationToken = default)
// Shallow clone isn't enough to ensure we don't mutate beatmap info unexpectedly.
// Can potentially be removed after `Beatmap.Difficulty` doesn't save back to `Beatmap.BeatmapInfo`.
original.BeatmapInfo = original.BeatmapInfo.Clone();
original.ControlPointInfo = original.ControlPointInfo.DeepClone();

return ConvertBeatmap(original, cancellationToken);
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/OsuGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ private void load()
Beatmap.BindValueChanged(beatmapChanged, true);

applySafeAreaConsiderations = LocalConfig.GetBindable<bool>(OsuSetting.SafeAreaConsiderations);
applySafeAreaConsiderations.BindValueChanged(apply => SafeAreaContainer.SafeAreaOverrideEdges = apply.NewValue ? SafeAreaOverrideEdges : Edges.All);
applySafeAreaConsiderations.BindValueChanged(apply => SafeAreaContainer.SafeAreaOverrideEdges = apply.NewValue ? SafeAreaOverrideEdges : Edges.All, true);
}

private ExternalLinkOpener externalLinkOpener;
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Rulesets/Edit/DistancedHitObjectComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ protected virtual bool AdjustDistanceSpacing(GlobalAction action, float amount)
return true;
}

public virtual float GetBeatSnapDistanceAt(HitObject referenceObject)
public virtual float GetBeatSnapDistanceAt(HitObject referenceObject, bool useReferenceSliderVelocity = true)
{
return (float)(100 * EditorBeatmap.Difficulty.SliderMultiplier * 1 / BeatSnapProvider.BeatDivisor);
return (float)(100 * (useReferenceSliderVelocity ? referenceObject.DifficultyControlPoint.SliderVelocity : 1) * EditorBeatmap.Difficulty.SliderMultiplier * 1 / BeatSnapProvider.BeatDivisor);
}

public virtual float DurationToDistance(HitObject referenceObject, double duration)
Expand Down
3 changes: 2 additions & 1 deletion osu.Game/Rulesets/Edit/IDistanceSnapProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ public interface IDistanceSnapProvider : IPositionSnapProvider
/// Retrieves the distance between two points within a timing point that are one beat length apart.
/// </summary>
/// <param name="referenceObject">An object to be used as a reference point for this operation.</param>
/// <param name="useReferenceSliderVelocity">Whether the <paramref name="referenceObject"/>'s slider velocity should be factored into the returned distance.</param>
/// <returns>The distance between two points residing in the timing point that are one beat length apart.</returns>
float GetBeatSnapDistanceAt(HitObject referenceObject);
float GetBeatSnapDistanceAt(HitObject referenceObject, bool useReferenceSliderVelocity = true);

/// <summary>
/// Converts a duration to a distance without applying any snapping.
Expand Down
4 changes: 4 additions & 0 deletions osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ protected sealed override void OnApply(HitObjectLifetimeEntry entry)
updateState(ArmedState.Miss, true);
else
updateState(ArmedState.Idle, true);

// Combo colour may have been applied via a bindable flow while no object entry was attached.
// Update here to ensure we're in a good state.
UpdateComboColour();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected override void LoadComplete()
private void updateSpacing()
{
float distanceSpacingMultiplier = (float)DistanceSpacingMultiplier.Value;
float beatSnapDistance = SnapProvider.GetBeatSnapDistanceAt(ReferenceObject);
float beatSnapDistance = SnapProvider.GetBeatSnapDistanceAt(ReferenceObject, false);

DistanceBetweenTicks = beatSnapDistance * distanceSpacingMultiplier;

Expand Down

0 comments on commit 9f031b5

Please sign in to comment.