public NumberPiece() { Anchor = Anchor.Centre; Origin = Anchor.Centre; Children = new Drawable[] { new SkinnableDrawable("Play/osu/number-glow", name => new CircularContainer { Masking = true, Origin = Anchor.Centre, EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Glow, Radius = 60, Colour = Color4.White.Opacity(0.5f), }, Child = new Box() }, s => s.GetTexture("Play/osu/hitcircle") == null), number = new SkinnableSpriteText("Play/osu/number-text", _ => new OsuSpriteText { Font = @"Venera", UseFullGlyphHeight = false, TextSize = 40, }, restrictSize: false) { Text = @"1" } }; }
private void load() { var drawableOsuObject = (DrawableOsuHitObject?)drawableObject; // if a base texture for the specified prefix exists, continue using it for subsequent lookups. // otherwise fall back to the default prefix "hitcircle". string circleName = (priorityLookupPrefix != null && skin.GetTexture(priorityLookupPrefix) != null) ? priorityLookupPrefix : @"hitcircle"; // at this point, any further texture fetches should be correctly using the priority source if the base texture was retrieved using it. // the conditional above handles the case where a sliderendcircle.png is retrieved from the skin, but sliderendcircleoverlay.png doesn't exist. // expected behaviour in this scenario is not showing the overlay, rather than using hitcircleoverlay.png. InternalChildren = new[] { CircleSprite = new KiaiFlashingDrawable(() => new Sprite { Texture = skin.GetTexture(circleName) }) { Anchor = Anchor.Centre, Origin = Anchor.Centre, }, OverlayLayer = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, Child = OverlaySprite = new KiaiFlashingDrawable(() => skin.GetAnimation(@$ "{circleName}overlay", true, true, frameLength: 1000 / 2d)) { Anchor = Anchor.Centre, Origin = Anchor.Centre, }, } }; if (hasNumber) { OverlayLayer.Add(hitCircleText = new SkinnableSpriteText(new OsuSkinComponent(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText { Font = OsuFont.Numeric.With(size: 40), UseFullGlyphHeight = false, }, confineMode: ConfineMode.NoScaling) { Anchor = Anchor.Centre, Origin = Anchor.Centre, }); } bool overlayAboveNumber = skin.GetConfig <OsuSkinConfiguration, bool>(OsuSkinConfiguration.HitCircleOverlayAboveNumber)?.Value ?? true; if (overlayAboveNumber) { OverlayLayer.ChangeChildDepth(OverlaySprite, float.MinValue); } if (drawableOsuObject != null) { accentColour.BindTo(drawableOsuObject.AccentColour); indexInCurrentCombo.BindTo(drawableOsuObject.IndexInCurrentComboBindable); } }
private void load(DrawableHitObject drawableObject, ISkinSource skin) { OsuHitObject osuObject = (OsuHitObject)drawableObject.HitObject; Sprite hitCircleSprite; SkinnableSpriteText hitCircleText; InternalChildren = new Drawable[] { hitCircleSprite = new Sprite { Texture = getTextureWithFallback(string.Empty), Colour = drawableObject.AccentColour.Value, Anchor = Anchor.Centre, Origin = Anchor.Centre, }, hitCircleText = new SkinnableSpriteText(new OsuSkinComponent(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText { Font = OsuFont.Numeric.With(size: 40), UseFullGlyphHeight = false, }, confineMode: ConfineMode.NoScaling), new Sprite { Texture = getTextureWithFallback("overlay"), Anchor = Anchor.Centre, Origin = Anchor.Centre, } }; bool overlayAboveNumber = skin.GetConfig <OsuSkinConfiguration, bool>(OsuSkinConfiguration.HitCircleOverlayAboveNumber)?.Value ?? true; if (!overlayAboveNumber) { ChangeInternalChildDepth(hitCircleText, -float.MaxValue); } state.BindTo(drawableObject.State); state.BindValueChanged(updateState, true); accentColour.BindTo(drawableObject.AccentColour); accentColour.BindValueChanged(colour => hitCircleSprite.Colour = colour.NewValue, true); indexInCurrentCombo.BindTo(osuObject.IndexInCurrentComboBindable); indexInCurrentCombo.BindValueChanged(index => hitCircleText.Text = (index.NewValue + 1).ToString(), true); Texture getTextureWithFallback(string name) { Texture tex = null; if (!string.IsNullOrEmpty(priorityLookup)) { tex = skin.GetTexture($"{priorityLookup}{name}"); } return(tex ?? skin.GetTexture($"hitcircle{name}")); } }
private void load(DrawableHitObject drawableObject, ISkinSource skin) { OsuHitObject osuObject = (OsuHitObject)drawableObject.HitObject; Sprite hitCircleSprite; SkinnableSpriteText hitCircleText; InternalChildren = new Drawable[] { hitCircleSprite = new Sprite { Texture = skin.GetTexture("hitcircle"), Colour = drawableObject.AccentColour.Value, Anchor = Anchor.Centre, Origin = Anchor.Centre, }, hitCircleText = new SkinnableSpriteText(new OsuSkinComponent(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText { Font = OsuFont.Numeric.With(size: 40), UseFullGlyphHeight = false, }, confineMode: ConfineMode.NoScaling), new Sprite { Texture = skin.GetTexture("hitcircleoverlay"), Anchor = Anchor.Centre, Origin = Anchor.Centre, } }; state.BindTo(drawableObject.State); state.BindValueChanged(updateState, true); accentColour.BindTo(drawableObject.AccentColour); accentColour.BindValueChanged(colour => hitCircleSprite.Colour = colour.NewValue, true); indexInCurrentCombo.BindTo(osuObject.IndexInCurrentComboBindable); indexInCurrentCombo.BindValueChanged(index => hitCircleText.Text = (index.NewValue + 1).ToString(), true); }
private void load() { var drawableOsuObject = (DrawableOsuHitObject)drawableObject; bool allowFallback = false; // attempt lookup using priority specification Texture baseTexture = getTextureWithFallback(string.Empty); // if the base texture was not found without a fallback, switch on fallback mode and re-perform the lookup. if (baseTexture == null) { allowFallback = true; baseTexture = getTextureWithFallback(string.Empty); } // at this point, any further texture fetches should be correctly using the priority source if the base texture was retrieved using it. // the flow above handles the case where a sliderendcircle.png is retrieved from the skin, but sliderendcircleoverlay.png doesn't exist. // expected behaviour in this scenario is not showing the overlay, rather than using hitcircleoverlay.png (potentially from the default/fall-through skin). Texture overlayTexture = getTextureWithFallback("overlay"); InternalChildren = new[] { hitCircleSprite = new KiaiFlashingSprite { Texture = baseTexture, Anchor = Anchor.Centre, Origin = Anchor.Centre, }, HitCircleOverlay = new KiaiFlashingSprite { Texture = overlayTexture, Anchor = Anchor.Centre, Origin = Anchor.Centre, }, }; if (hasNumber) { AddInternal(hitCircleText = new SkinnableSpriteText(new OsuSkinComponent(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText { Font = OsuFont.Numeric.With(size: 40), UseFullGlyphHeight = false, }, confineMode: ConfineMode.NoScaling) { Anchor = Anchor.Centre, Origin = Anchor.Centre, }); } bool overlayAboveNumber = skin.GetConfig <OsuSkinConfiguration, bool>(OsuSkinConfiguration.HitCircleOverlayAboveNumber)?.Value ?? true; if (overlayAboveNumber) { ChangeInternalChildDepth(HitCircleOverlay, float.MinValue); } accentColour.BindTo(drawableObject.AccentColour); indexInCurrentCombo.BindTo(drawableOsuObject.IndexInCurrentComboBindable); Texture getTextureWithFallback(string name) { Texture tex = null; if (!string.IsNullOrEmpty(priorityLookup)) { tex = skin.GetTexture($"{priorityLookup}{name}"); if (!allowFallback) { return(tex); } } return(tex ?? skin.GetTexture($"hitcircle{name}")); } }
private void load(DrawableHitObject drawableObject) { OsuHitObject osuObject = (OsuHitObject)drawableObject.HitObject; InternalChildren = new Drawable[] { circleSprites = new Container <Sprite> { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, Children = new[] { hitCircleSprite = new Sprite { Texture = getTextureWithFallback(string.Empty), Anchor = Anchor.Centre, Origin = Anchor.Centre, }, hitCircleOverlay = new Sprite { Texture = getTextureWithFallback("overlay"), Anchor = Anchor.Centre, Origin = Anchor.Centre, } } }, }; if (hasNumber) { AddInternal(hitCircleText = new SkinnableSpriteText(new OsuSkinComponent(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText { Font = OsuFont.Numeric.With(size: 40), UseFullGlyphHeight = false, }, confineMode: ConfineMode.NoScaling) { Anchor = Anchor.Centre, Origin = Anchor.Centre, }); } bool overlayAboveNumber = skin.GetConfig <OsuSkinConfiguration, bool>(OsuSkinConfiguration.HitCircleOverlayAboveNumber)?.Value ?? true; if (overlayAboveNumber) { AddInternal(hitCircleOverlay.CreateProxy()); } state.BindTo(drawableObject.State); accentColour.BindTo(drawableObject.AccentColour); indexInCurrentCombo.BindTo(osuObject.IndexInCurrentComboBindable); Texture getTextureWithFallback(string name) { Texture tex = null; if (!string.IsNullOrEmpty(priorityLookup)) { tex = skin.GetTexture($"{priorityLookup}{name}"); } return(tex ?? skin.GetTexture($"hitcircle{name}")); } }