Fix SliderBody's accent colour and thread-safety.

This commit is contained in:
Dean Herbert
2017-03-23 17:11:51 +09:00
parent 2c76a2350c
commit 4644f6afdb
2 changed files with 6 additions and 7 deletions

View File

@ -39,6 +39,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{ {
body = new SliderBody(s) body = new SliderBody(s)
{ {
AccentColour = AccentColour,
Position = s.StackedPosition, Position = s.StackedPosition,
PathWidth = s.Scale * 64, PathWidth = s.Scale * 64,
}, },

View File

@ -44,7 +44,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
return; return;
accentColour = value; accentColour = value;
reloadTexture(); if (LoadState == LoadState.Loaded)
Schedule(reloadTexture);
} }
} }
@ -99,15 +100,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
snakingIn = config.GetBindable<bool>(OsuConfig.SnakingInSliders); snakingIn = config.GetBindable<bool>(OsuConfig.SnakingInSliders);
snakingOut = config.GetBindable<bool>(OsuConfig.SnakingOutSliders); snakingOut = config.GetBindable<bool>(OsuConfig.SnakingOutSliders);
path.Texture = new Texture(textureWidth, 1);
reloadTexture(); reloadTexture();
} }
private void reloadTexture() private void reloadTexture()
{ {
if (path.Texture == null) var texture = new Texture(textureWidth, 1);
return;
//initialise background //initialise background
var upload = new TextureUpload(textureWidth * 4); var upload = new TextureUpload(textureWidth * 4);
@ -142,8 +140,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
} }
} }
path.Texture.SetData(upload); texture.SetData(upload);
path.Invalidate(Invalidation.DrawNode, this); path.Texture = texture;
} }
private readonly List<Vector2> currentCurve = new List<Vector2>(); private readonly List<Vector2> currentCurve = new List<Vector2>();