using System; using System.Text; using Crosstales.Radio.Model.Enum; using Crosstales.Radio.Util; using UnityEngine; namespace Crosstales.Radio.Model.Entry { [Serializable] public class RadioEntryUser : BaseRadioEntry { [Header("Base Settings")] [Tooltip("Text-, M3U or PLS-file with the radios.")] public TextAsset Resource; [Tooltip("Data format of the resource with the radios (default: DataFormatResource.Text).")] public DataFormatResource DataFormat; [Tooltip("Reads only the given number of radio stations (default: : 0 (= all))")] public int ReadNumberOfStations; [Tooltip("Loads the radio stations only once (default: true).")] public bool LoadOnlyOnce = true; [Tooltip("Path to the text-file with the radios.")] [Header("Source Settings")] public string Path; [Tooltip("Prefixes for the path (default: PathPrefix.None).")] public PathPrefix Prefix; public string FinalPath { get { string path = Path.Trim(); if (Prefix == PathPrefix.PersistentDataPath) { path = Application.persistentDataPath + '/' + Path.Trim(); } else if (Prefix == PathPrefix.DataPath) { path = Application.dataPath + '/' + Path.Trim(); } else if (Prefix == PathPrefix.TempPath) { path = Constants.PREFIX_TEMP_PATH + Path.Trim(); } return Helper.ValidateFile(path); } } public RadioEntryUser() { } public RadioEntryUser(RadioStation entry, string url) : base(entry.Name, true, true, entry.Station, entry.Genres, entry.Rating, entry.Description, entry.Icon, entry.Format, entry.Bitrate, entry.ChunkSize, entry.BufferSize, entry.ExcludedCodec) { Path = url; } public override string ToString() { StringBuilder stringBuilder = new StringBuilder(base.ToString()); stringBuilder.Append(GetType().Name); stringBuilder.Append(Constants.TEXT_TOSTRING_START); stringBuilder.Append("URL='"); stringBuilder.Append(Path); stringBuilder.Append(Constants.TEXT_TOSTRING_DELIMITER); stringBuilder.Append("Prefix='"); stringBuilder.Append(Prefix); stringBuilder.Append(Constants.TEXT_TOSTRING_DELIMITER_END); stringBuilder.Append(Constants.TEXT_TOSTRING_END); return stringBuilder.ToString(); } } }