Exemplo n.º 1
0
    private void TryRegister(JSONStorable storable)
    {
        var bindings = new List <object>();

        storable.SendMessage("OnBindingsListRequested", bindings, SendMessageOptions.DontRequireReceiver);
        if (bindings.Count > 0)
        {
            var actions = new List <JSONStorableAction>();
            var floats  = new List <JSONStorableFloat>();
            foreach (var binding in bindings)
            {
                if (!(TryAdd(actions, binding) || TryAdd(floats, binding)))
                {
                    SuperController.LogError($"{nameof(Sender)}: Received unknown binding type {binding.GetType()} from {storable.name} in atom {storable.containingAtom?.name ?? "(no containing atom)"}.");
                }
            }
            _receivers.Add(new Receiver
            {
                storable = storable,
                actions  = actions,
                floats   = floats
            });
            SuperController.LogMessage($"{nameof(Sender)}: Registered {actions.Count + floats.Count} bindings");
        }
    }
Exemplo n.º 2
0
        private SyncProxy TryConnectAtom(JSONStorable storable)
        {
            foreach (var l in _links.ToArray())
            {
                GetOrDispose(l);
            }

            var existing = _links.FirstOrDefault(a => a.storable == storable);

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

            var proxy = new SyncProxy()
            {
                storable = storable
            };

            storable.SendMessage(nameof(IRemoteAtomPlugin.VamTimelineConnectController), proxy.dict, SendMessageOptions.RequireReceiver);

            if (!proxy.connected)
            {
                proxy.Dispose();
                return(null);
            }

            _links.Add(proxy);
            _links.Sort((SyncProxy s1, SyncProxy s2) => string.Compare(s1.storable.containingAtom.name, s2.storable.containingAtom.name));

            var list = new List <string>(_atomsJSON.choices)
            {
                proxy.storable.containingAtom.uid
            };

            list.Sort();
            _atomsJSON.choices = list;

            OnTimelineAnimationParametersChanged(storable);

            if (_selectedLink == null)
            {
                _selectedLink  = proxy;
                _atomsJSON.val = proxy.storable.containingAtom.uid;
            }

            return(proxy);
        }
    public void TryRegister(JSONStorable storable)
    {
        Remove(storable);

        var bindings = new List <object>();

        try
        {
            storable.SendMessage("OnBindingsListRequested", bindings, SendMessageOptions.DontRequireReceiver);
        }
        catch (Exception exc)
        {
            SuperController.LogError($"Keybindings: Failed requesting bindings on {storable.name} in atom {storable.containingAtom.name}: {exc}");
            return;
        }

        TryRegister(storable, bindings);
    }