internal void UpdateStarDifficultyDisplay(bool instant) { if (!IsLoaded || Beatmap == null || state < TreeItemState.ExtrasVisible) { return; } double stars = Math.Min(Beatmap.StarDisplay, 10.0); // We don't want to deal with more than 10 stars in this display if (currentlyVisibleStars == stars) { return; } double previouslyVisibleStars = currentlyVisibleStars; currentlyVisibleStars = stars; UpdateDifficultyText(); // We want the -1 placeholder for "inexistant difficulty" to be treated like 0 stars here if (stars < 0) { stars = 0; int BackgroundStarSpritesEndIndex = starSpritesBeginIndex + AMOUNT_STARS; for (int i = starSpritesBeginIndex; i < BackgroundStarSpritesEndIndex; ++i) { pDrawable starSprite = SpriteCollection[i]; starSprite.FadeOut(instant ? 0 : (OldLayout ? 1000 : 600)); } } // ... with the exception of the background stars appearing. We want these to only appear once difficulty has been computed. (for looking good!) else { int BackgroundStarSpritesEndIndex = starSpritesBeginIndex + AMOUNT_STARS; for (int i = starSpritesBeginIndex; i < BackgroundStarSpritesEndIndex; ++i) { pDrawable starSprite = SpriteCollection[i]; starSprite.FadeIn(instant ? 0 : (OldLayout ? 1000 : 600)); } } int StarSpritesEndIndex = starSpritesBeginIndex + AMOUNT_STARS * 2; for (int i = starSpritesBeginIndex + AMOUNT_STARS; i < StarSpritesEndIndex; ++i) { int starIndex = i - (starSpritesBeginIndex + AMOUNT_STARS); double starsLeft = stars - starIndex; pSprite starSprite = SpriteCollection[i] as pSprite; starSprite.Transformations.Clear(); if (OldLayout) { int targetWidth = (int)(starSprite.Width * starsLeft); // It is important to also clip the width to negative values so the animation is delayed when the stars potentially appear again after the difficulty has been computed. // Don't optimize this and set to 0! starSprite.ClipWidthTo(targetWidth, instant ? 0 : 500, EasingTypes.OutCubic); } else { float newScale = starsLeft <= 0 ? 0 : star_scale * (float)Math.Max(0.5f, Math.Min(1, starsLeft) + starIndex * 0.04f); int amountStarsScaled = (int)Math.Floor(starIndex - Math.Min(stars, previouslyVisibleStars)); if (instant) { starSprite.ScaleTo(newScale, 0); } else { int timeAddition = previouslyVisibleStars <= stars ? amountStarsScaled : (int)Math.Floor(previouslyVisibleStars - stars) - amountStarsScaled - 1; int startTime = GameBase.Time + timeAddition * 80 + 50; starSprite.Transformations.Add(new Transformation(TransformationType.Scale, starSprite.Scale, newScale, startTime, startTime + 500, EasingTypes.OutBack)); } } } }