Beispiel #1
0
        public void Parse(JSONNode json)
        {
            if (json == null || json.AsObject == null)
            {
                return;
            }
            try
            {
                _collections.Clear();
                foreach (var collectionJSON in json.Childs.ToList())
                {
                    var newCollection = new AudioMateClipCollection(collectionJSON["name"], _controller);
                    if (newCollection.Parse(collectionJSON))
                    {
                        AddCollection(newCollection);
                    }
                }

                if (_collections.Count > 0)
                {
                    SelectActiveCollection(_collections.First());
                    _controller.needsProvisionalClipProcessing = true;
                }
            }
            catch (Exception e)
            {
                SuperController.LogError(
                    $"AudioMate.{nameof(AudioMateCollectionManager)}.{nameof(Parse)}: {e}");
            }
        }
Beispiel #2
0
        public void SelectActiveCollection(AudioMateClipCollection collection = null)
        {
            while (true)
            {
                if (collection != null)
                {
                    var previous = ActiveCollection;
                    ActiveCollection = collection;
                    ActiveCollection.SyncAudioReceiver();
                    if (CollectionsJSON.val != ActiveCollection.Name)
                    {
                        CollectionsJSON.val = ActiveCollection.Name;
                    }
                    OnActiveCollectionSelected.Invoke(new ActiveCollectionSelectedEventArgs {
                        Before = previous, After = ActiveCollection
                    });
                    return;
                }

                if (_collections.Count > 0)
                {
                    collection = _collections.First();
                    continue;
                }
                else
                {
                    AddDefaultCollection();
                }

                break;
            }
        }
Beispiel #3
0
        public AudioMateClipCollection AddCollection(string collectionName = null)
        {
            if (collectionName == null)
            {
                collectionName = GetAvailableDefaultName();
            }
            var newCollection = new AudioMateClipCollection(collectionName, _controller);

            return(AddCollection(newCollection));
        }
Beispiel #4
0
        private bool RemoveCollection(AudioMateClipCollection collection)
        {
            var collectionName = collection?.Name;

            if (string.IsNullOrEmpty(collectionName))
            {
                return(false);
            }
            CollectionsJSON.choices.Remove(collectionName);
            RemoveCollectionActions(collectionName);
            var result = _collections.Remove(collection);

            SyncCollectionNames();
            return(result);
        }
Beispiel #5
0
 private AudioMateClipCollection AddCollection(AudioMateClipCollection collection)
 {
     if (collection == null || string.IsNullOrEmpty(collection.Name))
     {
         return(null);
     }
     _collections.Add(collection);
     AddNewCollectionActions(collection.Name);
     if (!CollectionsJSON.choices.Contains(collection.Name))
     {
         CollectionsJSON.choices.Add(collection.Name);
     }
     SelectActiveCollection(collection);
     return(collection);
 }