mirror of
https://github.com/ppy/osu.git
synced 2025-01-08 03:12:57 +08:00
Merge pull request #8521 from peppy/remove-scale-down-to-fit
Remove ScaleDownToFit as it was implemented without enough safety
This commit is contained in:
commit
f653d37058
@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
public CatcherSprite(CatcherAnimationState state)
|
public CatcherSprite(CatcherAnimationState state)
|
||||||
: base(new CatchSkinComponent(componentFromState(state)), _ =>
|
: base(new CatchSkinComponent(componentFromState(state)), _ =>
|
||||||
new DefaultCatcherSprite(state), confineMode: ConfineMode.ScaleDownToFit)
|
new DefaultCatcherSprite(state), confineMode: ConfineMode.ScaleToFit)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.None;
|
RelativeSizeAxes = Axes.None;
|
||||||
Size = new Vector2(CatcherArea.CATCHER_SIZE);
|
Size = new Vector2(CatcherArea.CATCHER_SIZE);
|
||||||
|
@ -43,16 +43,15 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
new ExposedSkinnableDrawable("default", _ => new DefaultBox(), _ => true),
|
new ExposedSkinnableDrawable("default", _ => new DefaultBox(), _ => true),
|
||||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true),
|
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true),
|
||||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.ScaleToFit),
|
|
||||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.NoScaling)
|
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.NoScaling)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("check sizes", () => fill.Children.Select(c => c.Drawable.DrawWidth).SequenceEqual(new float[] { 30, 30, 30, 50 }));
|
AddAssert("check sizes", () => fill.Children.Select(c => c.Drawable.DrawWidth).SequenceEqual(new float[] { 30, 30, 50 }));
|
||||||
AddStep("adjust scale", () => fill.Scale = new Vector2(2));
|
AddStep("adjust scale", () => fill.Scale = new Vector2(2));
|
||||||
AddAssert("check sizes unchanged by scale", () => fill.Children.Select(c => c.Drawable.DrawWidth).SequenceEqual(new float[] { 30, 30, 30, 50 }));
|
AddAssert("check sizes unchanged by scale", () => fill.Children.Select(c => c.Drawable.DrawWidth).SequenceEqual(new float[] { 30, 30, 50 }));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -74,7 +73,6 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new ExposedSkinnableDrawable("default", _ => new DefaultBox(), _ => true),
|
new ExposedSkinnableDrawable("default", _ => new DefaultBox(), _ => true),
|
||||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true),
|
|
||||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.ScaleToFit),
|
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.ScaleToFit),
|
||||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.NoScaling)
|
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.NoScaling)
|
||||||
}
|
}
|
||||||
@ -82,9 +80,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("check sizes", () => fill.Children.Select(c => c.Drawable.DrawWidth).SequenceEqual(new float[] { 50, 30, 50, 30 }));
|
AddAssert("check sizes", () => fill.Children.Select(c => c.Drawable.DrawWidth).SequenceEqual(new float[] { 50, 50, 30 }));
|
||||||
AddStep("adjust scale", () => fill.Scale = new Vector2(2));
|
AddStep("adjust scale", () => fill.Scale = new Vector2(2));
|
||||||
AddAssert("check sizes unchanged by scale", () => fill.Children.Select(c => c.Drawable.DrawWidth).SequenceEqual(new float[] { 50, 30, 50, 30 }));
|
AddAssert("check sizes unchanged by scale", () => fill.Children.Select(c => c.Drawable.DrawWidth).SequenceEqual(new float[] { 50, 50, 30 }));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -182,7 +180,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
public new Drawable Drawable => base.Drawable;
|
public new Drawable Drawable => base.Drawable;
|
||||||
|
|
||||||
public ExposedSkinnableDrawable(string name, Func<ISkinComponent, Drawable> defaultImplementation, Func<ISkinSource, bool> allowFallback = null,
|
public ExposedSkinnableDrawable(string name, Func<ISkinComponent, Drawable> defaultImplementation, Func<ISkinSource, bool> allowFallback = null,
|
||||||
ConfineMode confineMode = ConfineMode.ScaleDownToFit)
|
ConfineMode confineMode = ConfineMode.ScaleToFit)
|
||||||
: base(new TestSkinComponent(name), defaultImplementation, allowFallback, confineMode)
|
: base(new TestSkinComponent(name), defaultImplementation, allowFallback, confineMode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -92,20 +92,13 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
switch (confineMode)
|
switch (confineMode)
|
||||||
{
|
{
|
||||||
case ConfineMode.NoScaling:
|
case ConfineMode.ScaleToFit:
|
||||||
return;
|
Drawable.RelativeSizeAxes = Axes.Both;
|
||||||
|
Drawable.Size = Vector2.One;
|
||||||
case ConfineMode.ScaleDownToFit:
|
Drawable.Scale = Vector2.One;
|
||||||
if (Drawable.DrawSize.X <= DrawSize.X && Drawable.DrawSize.Y <= DrawSize.Y)
|
Drawable.FillMode = FillMode.Fit;
|
||||||
return;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Drawable.RelativeSizeAxes = Axes.Both;
|
|
||||||
Drawable.Size = Vector2.One;
|
|
||||||
Drawable.Scale = Vector2.One;
|
|
||||||
Drawable.FillMode = FillMode.Fit;
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -121,7 +114,6 @@ namespace osu.Game.Skinning
|
|||||||
/// Don't apply any scaling. This allows the user element to be of any size, exceeding specified bounds.
|
/// Don't apply any scaling. This allows the user element to be of any size, exceeding specified bounds.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
NoScaling,
|
NoScaling,
|
||||||
ScaleDownToFit,
|
|
||||||
ScaleToFit,
|
ScaleToFit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user