mirror of https://github.com/ppy/osu
Remove `repeat` and simplify `getMinSliderMargin`
This commit is contained in:
parent
f59263932a
commit
b214f2ae0e
|
@ -151,31 +151,23 @@ private void moveSliderIntoPlayfield(Slider slider, RandomObjectInfo currentObje
|
|||
/// </summary>
|
||||
private MarginPadding getMinSliderMargin(Slider slider)
|
||||
{
|
||||
var minMargin = new MarginPadding();
|
||||
|
||||
var pathPositions = new List<Vector2>();
|
||||
slider.Path.GetPathToProgress(pathPositions, 0, 1);
|
||||
|
||||
var minMargin = new MarginPadding();
|
||||
|
||||
foreach (var pos in pathPositions)
|
||||
updateMargin(pos);
|
||||
|
||||
var repeat = (SliderRepeat)slider.NestedHitObjects.FirstOrDefault(o => o is SliderRepeat);
|
||||
|
||||
if (repeat != null)
|
||||
updateMargin(repeat.Position - slider.Position);
|
||||
|
||||
minMargin.Left = Math.Min(minMargin.Left, OsuPlayfield.BASE_SIZE.X - minMargin.Right);
|
||||
minMargin.Top = Math.Min(minMargin.Top, OsuPlayfield.BASE_SIZE.Y - minMargin.Bottom);
|
||||
|
||||
return minMargin;
|
||||
|
||||
void updateMargin(Vector2 pos)
|
||||
{
|
||||
minMargin.Left = Math.Max(minMargin.Left, -pos.X);
|
||||
minMargin.Right = Math.Max(minMargin.Right, pos.X);
|
||||
minMargin.Top = Math.Max(minMargin.Top, -pos.Y);
|
||||
minMargin.Bottom = Math.Max(minMargin.Bottom, pos.Y);
|
||||
}
|
||||
|
||||
minMargin.Left = Math.Min(minMargin.Left, OsuPlayfield.BASE_SIZE.X - minMargin.Right);
|
||||
minMargin.Top = Math.Min(minMargin.Top, OsuPlayfield.BASE_SIZE.Y - minMargin.Bottom);
|
||||
|
||||
return minMargin;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue