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; } }); }
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}"); }
public static string GetTextureNameFromLookup(LegacyKaraokeSkinConfigurationLookups lookup) { string suffix; switch (lookup) { case LegacyKaraokeSkinConfigurationLookups.JudgementLineBodyImage: suffix = "body"; break; case LegacyKaraokeSkinConfigurationLookups.JudgementLineHeadImage: suffix = "head"; break; case LegacyKaraokeSkinConfigurationLookups.JudgementLineTailImage: suffix = "tail"; break; default: throw new ArgumentOutOfRangeException($"{nameof(lookup)} should be body, head or tail."); } return($"karaoke-judgement-line-{suffix}"); }
// TODO : get current index protected override IBindable <T> GetKaraokeSkinConfig <T>(ISkin skin, LegacyKaraokeSkinConfigurationLookups lookup, int?index = null) => base.GetKaraokeSkinConfig <T>(skin, lookup, index);
protected Texture GetTextureFromLookup(ISkin skin, LegacyKaraokeSkinConfigurationLookups lookup) => skin.GetTexture(GetTextureNameFromLookup(lookup));
public LegacyKaraokeSkinConfigurationLookup(int columns, LegacyKaraokeSkinConfigurationLookups lookup, int?targetColumn = null) { Columns = columns; Lookup = lookup; TargetColumn = targetColumn; }
/// <summary> /// Retrieve a per-column-count skin configuration. /// </summary> /// <param name="skin">The skin from which configuration is retrieved.</param> /// <param name="lookup">The value to retrieve.</param> /// <param name="index">If not null, denotes the index of the column to which the entry applies.</param> protected virtual IBindable <T> GetKaraokeSkinConfig <T>(ISkin skin, LegacyKaraokeSkinConfigurationLookups lookup, int?index = null) => skin.GetConfig <LegacyKaraokeSkinConfigurationLookup, T>( new LegacyKaraokeSkinConfigurationLookup(Playfield?.NotePlayfield.Columns ?? 4, lookup, index));