Exemple #1
0
        public void FlushNodeCreationEvent(NodeCreationEvent e, IEnumerable <GUID> deletedNodeIds = null)
        {
            if (m_LastNodeCreation?.Action.HasValue == true)
            {
                if (m_LastNodeCreation.SkipNextFlush)
                {
                    m_LastNodeCreation.SkipNextFlush = false;
                    return;
                }

                VSUserActions vsUserActions = m_LastNodeCreation.Action.Value;

                if (e == NodeCreationEvent.UndoOrDelete && (deletedNodeIds == null || deletedNodeIds.Contains(m_LastNodeCreation.GUID)))
                {
                    vsUserActions.SetResult(NodeCreationEvent.UndoOrDelete);
                }

                m_UserActionEvents.Enqueue(vsUserActions);
                Log($"Flush last node creation {m_LastNodeCreation.GUID} result: {vsUserActions.vsSearcherCancelled}");

                m_LastNodeCreation = null;
            }
        }
Exemple #2
0
        public void AddUserActionEvent(string searchKeywords, SearcherContext context, UserActionKind kind)
        {
            if (m_LastNodeCreation == null) // TODO: context is not handled yet, ie. edge-to-stack
            {
                return;
            }

            if (m_UserActionEvents == null)
            {
                m_UserActionEvents = new Queue <VSUserActions>();
            }

            var vsUserActions = new VSUserActions
            {
                vsUserSearchQuery = searchKeywords,
                vsUserCreateNode  = m_LastNodeCreation.NodeTitle,
                vsVersion         = k_VisualScriptingVersion,
                vsSearcherContext = context.ToString(),
            };

            vsUserActions.SetResult(m_LastNodeCreation.NodeTitle == null ? NodeCreationEvent.Cancel : NodeCreationEvent.Keep);
            Log($"AddUserActionEvent {kind} {vsUserActions}");

            switch (kind)
            {
            case UserActionKind.SendImmediately:
                m_UserActionEvents.Enqueue(vsUserActions);
                break;

            case UserActionKind.WaitForConfirmation:
                m_LastNodeCreation.Action = vsUserActions;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(kind), kind, null);
            }
        }