Beispiel #1
0
        private void load()
        {
            var ballColour = skin.GetConfig <OsuSkinColour, Color4>(OsuSkinColour.SliderBall)?.Value ?? Color4.White;

            InternalChildren = new[]
            {
                layerNd = new Sprite
                {
                    Anchor  = Anchor.Centre,
                    Origin  = Anchor.Centre,
                    Texture = skin.GetTexture("sliderb-nd"),
                    Colour  = new Color4(5, 5, 5, 255),
                },
                LegacyColourCompatibility.ApplyWithDoubledAlpha(animationContent.With(d =>
                {
                    d.Anchor = Anchor.Centre;
                    d.Origin = Anchor.Centre;
                }), ballColour),
                layerSpec = new Sprite
                {
                    Anchor   = Anchor.Centre,
                    Origin   = Anchor.Centre,
                    Texture  = skin.GetTexture("sliderb-spec"),
                    Blending = BlendingParameters.Additive,
                },
            };
        }
Beispiel #2
0
        private void load(OsuConfigManager config)
        {
            Texture       = skin.GetTexture("cursortrail");
            disjointTrail = skin.GetTexture("cursormiddle") == null;

            if (disjointTrail)
            {
                bool centre = skin.GetConfig <OsuSkinConfiguration, bool>(OsuSkinConfiguration.CursorCentre)?.Value ?? true;

                TrailOrigin = centre ? Anchor.Centre : Anchor.TopLeft;
                Blending    = BlendingParameters.Inherit;
            }
            else
            {
                Blending = BlendingParameters.Additive;
            }

            if (Texture != null)
            {
                // stable "magic ratio". see OsuPlayfieldAdjustmentContainer for full explanation.
                Texture.ScaleAdjust *= 1.6f;
            }

            cursorSize = config.GetBindable <float>(OsuSetting.GameplayCursorSize).GetBoundCopy();
        }
Beispiel #3
0
        private static Texture getAnimationFrame(ISkin skin, TaikoMascotAnimationState state, int frameIndex)
        {
            var texture = skin.GetTexture($"pippidon{state.ToString().ToLower()}{frameIndex}");

            if (frameIndex == 0 && texture == null)
            {
                texture = skin.GetTexture($"pippidon{state.ToString().ToLower()}");
            }

            return(texture);
        }
Beispiel #4
0
        public static Drawable GetAnimation(this ISkin source, string componentName, WrapMode wrapModeS, WrapMode wrapModeT, bool animatable, bool looping, bool applyConfigFrameRate = false,
                                            string animationSeparator = "-",
                                            bool startAtCurrentTime   = true, double?frameLength = null)
        {
            Texture texture;

            if (animatable)
            {
                var textures = getTextures().ToArray();

                if (textures.Length > 0)
                {
                    var animation = new SkinnableTextureAnimation(startAtCurrentTime)
                    {
                        DefaultFrameLength = frameLength ?? getFrameLength(source, applyConfigFrameRate, textures),
                        Loop = looping,
                    };

                    foreach (var t in textures)
                    {
                        animation.AddFrame(t);
                    }

                    return(animation);
                }
            }

            // if an animation was not allowed or not found, fall back to a sprite retrieval.
            if ((texture = source.GetTexture(componentName, wrapModeS, wrapModeT)) != null)
            {
                return new Sprite {
                           Texture = texture
                }
            }
            ;

            return(null);

            IEnumerable <Texture> getTextures()
            {
                for (int i = 0; true; i++)
                {
                    if ((texture = source.GetTexture($"{componentName}{animationSeparator}{i}", wrapModeS, wrapModeT)) == null)
                    {
                        break;
                    }

                    yield return(texture);
                }
            }
        }
        public static Drawable GetAnimation(this ISkin source, string componentName, bool animatable, bool looping, string animationSeparator = "-")
        {
            const double default_frame_time = 1000 / 60d;

            Texture texture;

            Texture getFrameTexture(int frame) => source.GetTexture($"{componentName}{animationSeparator}{frame}");

            TextureAnimation animation = null;

            if (animatable)
            {
                for (int i = 0;; i++)
                {
                    if ((texture = getFrameTexture(i)) == null)
                    {
                        break;
                    }

                    if (animation == null)
                    {
                        animation = new TextureAnimation
                        {
                            DefaultFrameLength = default_frame_time,
                            Repeat             = looping
                        }
                    }
                    ;

                    animation.AddFrame(texture);
                }
            }

            if (animation != null)
            {
                return(animation);
            }

            if ((texture = source.GetTexture(componentName)) != null)
            {
                return new Sprite
                       {
                           Texture = texture
                       }
            }
            ;

            return(null);
        }
    }
}
Beispiel #6
0
            public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
            {
                if (provider.AllowTextureLookup(componentName))
                {
                    return(skin.GetTexture(componentName, wrapModeS, wrapModeT));
                }

                return(null);
            }
            public ITexturedCharacterGlyph Get(string fontName, char character)
            {
                var lookup = getLookupName(character);

                var texture = skin.GetTexture($"{fontName}-{lookup}");

                if (texture == null)
                    return null;

                return new TexturedCharacterGlyph(new CharacterGlyph(character, 0, 0, texture.Width, null), texture, 1f / texture.ScaleAdjust);
            }
        public Texture GetTexture(string componentName)
        {
            Texture sourceTexture;

            if (beatmapSkins.Value && (sourceTexture = skin.GetTexture(componentName)) != null)
            {
                return(sourceTexture);
            }

            return(fallbackSource.GetTexture(componentName));
        }
        public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
        {
            Texture sourceTexture;

            if (AllowTextureLookup(componentName) && (sourceTexture = skin?.GetTexture(componentName, wrapModeS, wrapModeT)) != null)
            {
                return(sourceTexture);
            }

            return(fallbackSource?.GetTexture(componentName, wrapModeS, wrapModeT));
        }
Beispiel #10
0
            public ITexturedCharacterGlyph Get(string fontName, char character)
            {
                var texture = skin.GetTexture($"{fontName}-{character}");

                if (texture == null)
                {
                    return(null);
                }

                return(new TexturedCharacterGlyph(new CharacterGlyph(character, 0, 0, texture.Width, null), texture, 1f / texture.ScaleAdjust));
            }
Beispiel #11
0
        private void sourceChanged()
        {
            // these need to be lazy in order to ensure they aren't called before the dependencies have been loaded into our source.
            configuration = new Lazy <SkinConfiguration>(() =>
            {
                var config = new SkinConfiguration();
                if (hasHitCircle.Value)
                {
                    config.SliderPathRadius = legacy_circle_radius;
                }

                // defaults should only be applied for non-beatmap skins (which are parsed via this constructor).
                config.CustomColours["SliderBall"] =
                    source.GetValue <SkinConfiguration, Color4?>(s => s.CustomColours.TryGetValue("SliderBall", out var val) ? val : (Color4?)null)
                    ?? new Color4(2, 170, 255, 255);

                return(config);
            });

            hasHitCircle = new Lazy <bool>(() => source.GetTexture("hitcircle") != null);
        }
Beispiel #12
0
        private void load()
        {
            bool centre = skin.GetConfig <OsuSkinConfiguration, bool>(OsuSkinConfiguration.CursorCentre)?.Value ?? true;

            spin = skin.GetConfig <OsuSkinConfiguration, bool>(OsuSkinConfiguration.CursorRotate)?.Value ?? true;

            InternalChildren = new[]
            {
                ExpandTarget = new NonPlayfieldSprite
                {
                    Texture = skin.GetTexture("cursor"),
                    Anchor  = Anchor.Centre,
                    Origin  = centre ? Anchor.Centre : Anchor.TopLeft,
                },
                new NonPlayfieldSprite
                {
                    Texture = skin.GetTexture("cursormiddle"),
                    Anchor  = Anchor.Centre,
                    Origin  = centre ? Anchor.Centre : Anchor.TopLeft,
                },
            };
        }
Beispiel #13
0
                public ITexturedCharacterGlyph Get(string fontName, char character)
                {
                    var texture = skin.GetTexture($"{fontName}-{character}");

                    if (texture != null)
                    {
                        // Approximate value that brings character sizing roughly in-line with stable
                        texture.ScaleAdjust *= 18;
                    }

                    if (texture == null)
                    {
                        return(null);
                    }

                    return(new TexturedCharacterGlyph(new CharacterGlyph(character, 0, 0, texture.Width, null), texture, 1f / texture.ScaleAdjust));
                }
        protected Texture GetTextureFromLookup(ISkin skin, LegacyManiaSkinConfigurationLookups lookup)
        {
            string suffix = string.Empty;

            switch (lookup)
            {
            case LegacyManiaSkinConfigurationLookups.HoldNoteHeadImage:
                suffix = "H";
                break;

            case LegacyManiaSkinConfigurationLookups.HoldNoteTailImage:
                suffix = "T";
                break;
            }

            string noteImage = GetColumnSkinConfig <string>(skin, lookup)?.Value
                               ?? $"mania-note{FallbackColumnIndex}{suffix}";

            return(skin.GetTexture(noteImage, WrapMode.ClampToEdge, WrapMode.ClampToEdge));
        }
Beispiel #15
0
        protected Texture GetTextureFromLookup(ISkin skin, LegacyManiaSkinConfigurationLookups lookup)
        {
            string suffix = string.Empty;

            switch (lookup)
            {
            case LegacyManiaSkinConfigurationLookups.HoldNoteHeadImage:
                suffix = "H";
                break;

            case LegacyManiaSkinConfigurationLookups.HoldNoteTailImage:
                suffix = "T";
                break;
            }

            string noteImage = skin.GetConfig <LegacyManiaSkinConfigurationLookup, string>(
                new LegacyManiaSkinConfigurationLookup(Stage?.Columns.Count ?? 4, lookup, Column.Index))?.Value
                               ?? $"mania-note{FallbackColumnIndex}{suffix}";

            return(skin.GetTexture(noteImage));
        }
Beispiel #16
0
 public Texture GetTexture(string componentName) => source.GetTexture(componentName);
 protected Texture GetTextureFromLookup(ISkin skin, LegacyKaraokeSkinConfigurationLookups lookup)
 => skin.GetTexture(GetTextureNameFromLookup(lookup));
Beispiel #18
0
 public static bool HasFont(this ISkin source, string fontPrefix)
 => source.GetTexture($"{fontPrefix}-0") != null;
Beispiel #19
0
        public static Drawable GetAnimation(this ISkin source, string componentName, WrapMode wrapModeS, WrapMode wrapModeT, bool animatable, bool looping, bool applyConfigFrameRate = false,
                                            string animationSeparator = "-",
                                            bool startAtCurrentTime   = true, double?frameLength = null)
        {
            Texture texture;

            // find the first source which provides either the animated or non-animated version.
            ISkin skin = (source as ISkinSource)?.FindProvider(s =>
            {
                if (animatable && s.GetTexture(getFrameName(0)) != null)
                {
                    return(true);
                }

                return(s.GetTexture(componentName, wrapModeS, wrapModeT) != null);
            }) ?? source;

            if (skin == null)
            {
                return(null);
            }

            if (animatable)
            {
                var textures = getTextures().ToArray();

                if (textures.Length > 0)
                {
                    var animation = new SkinnableTextureAnimation(startAtCurrentTime)
                    {
                        DefaultFrameLength = frameLength ?? getFrameLength(skin, applyConfigFrameRate, textures),
                        Loop = looping,
                    };

                    foreach (var t in textures)
                    {
                        animation.AddFrame(t);
                    }

                    return(animation);
                }
            }

            // if an animation was not allowed or not found, fall back to a sprite retrieval.
            if ((texture = skin.GetTexture(componentName, wrapModeS, wrapModeT)) != null)
            {
                return new Sprite {
                           Texture = texture
                }
            }
            ;

            return(null);

            IEnumerable <Texture> getTextures()
            {
                for (int i = 0; true; i++)
                {
                    if ((texture = skin.GetTexture(getFrameName(i), wrapModeS, wrapModeT)) == null)
                    {
                        break;
                    }

                    yield return(texture);
                }
            }

            string getFrameName(int frameIndex) => $"{componentName}{animationSeparator}{frameIndex}";
        }
Beispiel #20
0
 private void sourceChanged()
 {
     hasHitCircle = new Lazy <bool>(() => source.GetTexture("hitcircle") != null);
 }
Beispiel #21
0
 private static Texture getTexture(ISkin skin, string name) => skin?.GetTexture($"scorebar-{name}");
Beispiel #22
0
 private static Texture getAnimationFrame(ISkin skin, TaikoMascotAnimationState state, int frameIndex)
 => skin.GetTexture($"pippidon{state.ToString().ToLower()}{frameIndex}");
 private bool textureExist(params string[] textureNames)
 => textureNames.All(x => source.GetTexture(x) != null);
Beispiel #24
0
 public static bool HasFont(this ISkin source, LegacyFont font)
 {
     return(source.GetTexture($"{source.GetFontPrefix(font)}-0") != null);
 }