예제 #1
0
        private LayerContainer createLayer(string name, ISkin skin, LegacyKaraokeSkinNoteLayer layer)
        {
            return(new LayerContainer
            {
                RelativeSizeAxes = Axes.Both,
                Name = name,
                Children = new[]
                {
                    GetSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteHeadImage, layer).With(d =>
                    {
                        if (d == null)
                        {
                            return;
                        }

                        d.Name = "Head";
                        d.Anchor = Anchor.CentreLeft;
                        d.Origin = Anchor.Centre;
                    }),
                    GetSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteBodyImage, layer).With(d =>
                    {
                        if (d == null)
                        {
                            return;
                        }

                        d.Name = "Body";
                        d.Anchor = Anchor.Centre;
                        d.Origin = Anchor.Centre;
                        d.Size = Vector2.One;
                        d.FillMode = FillMode.Stretch;
                        d.RelativeSizeAxes = Axes.X;
                        d.Depth = 1;

                        d.Height = d.Texture?.DisplayHeight ?? 0;
                    }),
                    GetSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteTailImage, layer).With(d =>
                    {
                        if (d == null)
                        {
                            return;
                        }

                        d.Name = "Tail";
                        d.Anchor = Anchor.CentreRight;
                        d.Origin = Anchor.Centre;
                    }),
                }
            });
        }
예제 #2
0
        public static string GetTextureNameFromLookup(LegacyKaraokeSkinConfigurationLookups lookup, LegacyKaraokeSkinNoteLayer layer)
        {
            string suffix;

            switch (lookup)
            {
            case LegacyKaraokeSkinConfigurationLookups.NoteBodyImage:
                suffix = "body";
                break;

            case LegacyKaraokeSkinConfigurationLookups.NoteHeadImage:
                suffix = "head";
                break;

            case LegacyKaraokeSkinConfigurationLookups.NoteTailImage:
                suffix = "tail";
                break;

            default:
                throw new ArgumentOutOfRangeException($"{nameof(lookup)} should be body, head or tail.");
            }

            string layerSuffix = string.Empty;

            switch (layer)
            {
            case LegacyKaraokeSkinNoteLayer.Border:
                layerSuffix = "border";
                break;

            case LegacyKaraokeSkinNoteLayer.Background:
                layerSuffix = "background";
                break;
            }

            return($"karaoke-note-{layerSuffix}-{suffix}");
        }
예제 #3
0
        protected Sprite GetSpriteFromLookup(ISkin skin, LegacyKaraokeSkinConfigurationLookups lookup, LegacyKaraokeSkinNoteLayer layer)
        {
            var name = GetTextureNameFromLookup(lookup, layer);

            switch (layer)
            {
            case LegacyKaraokeSkinNoteLayer.Background:
            case LegacyKaraokeSkinNoteLayer.Border:
                return(getSpriteByName(name) ?? new Sprite());

            case LegacyKaraokeSkinNoteLayer.Foreground:
                return(getSpriteByName(name)
                       ?? getSpriteByName(GetTextureNameFromLookup(lookup, LegacyKaraokeSkinNoteLayer.Background))
                       ?? new Sprite());

            default:
                return(null);
            }

            Sprite getSpriteByName(string spriteName) => (Sprite)skin.GetAnimation(spriteName, true, true).With(d =>
            {
                switch (d)
                {
                case null:
                    return;

                case TextureAnimation animation:
                    animation.IsPlaying = false;
                    break;
                }
            });
        }