Clamp values to avoid potentially weird element

This commit is contained in:
Dean Herbert 2019-04-28 20:13:28 +09:00
parent 8ab5149336
commit f9f6e1f04a

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osuTK;
namespace osu.Game.Overlays.Profile.Header.Components namespace osu.Game.Overlays.Profile.Header.Components
{ {
@ -23,7 +24,9 @@ namespace osu.Game.Overlays.Profile.Header.Components
{ {
set set
{ {
if (value == 0) int count = MathHelper.Clamp(value, 0, 3);
if (count == 0)
{ {
content.Hide(); content.Hide();
} }
@ -31,7 +34,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
{ {
content.Show(); content.Show();
iconContainer.Clear(); iconContainer.Clear();
for (int i = 0; i < value; i++) for (int i = 0; i < count; i++)
{ {
iconContainer.Add(new SpriteIcon iconContainer.Add(new SpriteIcon
{ {