Exemple #1
0
        public void RemoveTargetWithActionForControlEvent(object target, SEL_CCControlHandler action, CCControlEvent controlEvent)
        {
            // Retrieve all invocations for the given control event
            //<CCInvocation*>
            RawList <CCInvocation> eventInvocationList = DispatchListforControlEvent(controlEvent);

            //remove all invocations if the target and action are null
            if (target == null && action == null)
            {
                //remove objects
                eventInvocationList.Clear();
            }
            else
            {
                //normally we would use a predicate, but this won't work here. Have to do it manually
                foreach (CCInvocation invocation in eventInvocationList)
                {
                    bool shouldBeRemoved = true;
                    if (target != null)
                    {
                        shouldBeRemoved = (target == invocation.Target);
                    }
                    if (action != null)
                    {
                        shouldBeRemoved = (shouldBeRemoved && (action == invocation.Action));
                    }
                    // Remove the corresponding invocation object
                    if (shouldBeRemoved)
                    {
                        eventInvocationList.Remove(invocation);
                    }
                }
            }
        }
Exemple #2
0
        public void AddTargetWithActionForControlEvent(object target, SEL_CCControlHandler action, CCControlEvent controlEvent)
        {
            // Create the invocation object
            var invocation = new CCInvocation(target, action, controlEvent);

            // Add the invocation into the dispatch list for the given control event
            RawList <CCInvocation> eventInvocationList = DispatchListforControlEvent(controlEvent);

            eventInvocationList.Add(invocation);
        }
Exemple #3
0
        /**
         * Removes a target and action for a particular event (or events) from an
         * internal dispatch table.
         *
         * @param target The target object�that is, the object to which the action
         * message is sent. Pass nil to remove all targets paired with action and the
         * specified control events.
         * @param action A selector identifying an action message. Pass NULL to remove
         * all action messages paired with target.
         * @param controlEvents A bitmask specifying the control events associated with
         * target and action. See "CCControlEvent" for bitmask constants.
         */

        public virtual void RemoveTargetWithActionForControlEvents(object target, SEL_CCControlHandler action, CCControlEvent controlEvents)
        {
            // For each control events
            for (int i = 0; i < kControlEventTotalNumber; i++)
            {
                // If the given controlEvents bitmask contains the curent event
                if ((controlEvents & (CCControlEvent)(1 << i)) != 0)
                {
                    RemoveTargetWithActionForControlEvent(target, action, (CCControlEvent)(1 << i));
                }
            }
        }
Exemple #4
0
 public CCInvocation(object target, SEL_CCControlHandler action, CCControlEvent controlEvent)
 {
     m_target        = target;
     m_pAction       = action;
     m_pControlEvent = controlEvent;
 }
 public CCInvocation(object target, SEL_CCControlHandler action, CCControlEvent controlEvent)
 {
     m_target = target;
     m_pAction = action;
     m_pControlEvent = controlEvent;
 }
Exemple #6
0
 /**
 * Removes a target and action for a particular event (or events) from an
 * internal dispatch table.
 *
 * @param target The target object�that is, the object to which the action
 * message is sent. Pass nil to remove all targets paired with action and the
 * specified control events.
 * @param action A selector identifying an action message. Pass NULL to remove
 * all action messages paired with target.
 * @param controlEvents A bitmask specifying the control events associated with
 * target and action. See "CCControlEvent" for bitmask constants.
 */
 public virtual void RemoveTargetWithActionForControlEvents(object target, SEL_CCControlHandler action, CCControlEvent controlEvents)
 {
     // For each control events
     for (int i = 0; i < kControlEventTotalNumber; i++)
     {
         // If the given controlEvents bitmask contains the curent event
         if ((controlEvents & (CCControlEvent) (1 << i)) != 0)
         {
             RemoveTargetWithActionForControlEvent(target, action, (CCControlEvent) (1 << i));
         }
     }
 }
Exemple #7
0
        public void RemoveTargetWithActionForControlEvent(object target, SEL_CCControlHandler action, CCControlEvent controlEvent)
        {
            // Retrieve all invocations for the given control event
            //<CCInvocation*>
            RawList<CCInvocation> eventInvocationList = DispatchListforControlEvent(controlEvent);

            //remove all invocations if the target and action are null
            if (target == null && action == null)
            {
                //remove objects
                eventInvocationList.Clear();
            }
            else
            {
                //normally we would use a predicate, but this won't work here. Have to do it manually
                foreach (CCInvocation invocation in eventInvocationList)
                {
                    bool shouldBeRemoved = true;
                    if (target != null)
                    {
                        shouldBeRemoved = (target == invocation.Target);
                    }
                    if (action != null)
                    {
                        shouldBeRemoved = (shouldBeRemoved && (action == invocation.Action));
                    }
                    // Remove the corresponding invocation object
                    if (shouldBeRemoved)
                    {
                        eventInvocationList.Remove(invocation);
                    }
                }
            }
        }
Exemple #8
0
        public void AddTargetWithActionForControlEvent(object target, SEL_CCControlHandler action, CCControlEvent controlEvent)
        {
            // Create the invocation object
            var invocation = new CCInvocation(target, action, controlEvent);

            // Add the invocation into the dispatch list for the given control event
            RawList<CCInvocation> eventInvocationList = DispatchListforControlEvent(controlEvent);
            eventInvocationList.Add(invocation);
        }
Exemple #9
0
        protected virtual BlockCCControlData ParsePropTypeBlockCcControl(CCNode node, CCNode parent, CCBReader reader)
        {
            string selectorName   = reader.ReadCachedString();
            var    selectorTarget = (CCBTargetType)reader.ReadInt(false);
            var    controlEvents  = (CCControlEvent)reader.ReadInt(false);

            if (selectorTarget != CCBTargetType.None)
            {
                object target = null;
                if (selectorTarget == CCBTargetType.DocumentRoot)
                {
                    target = reader.AnimationManager.RootNode;
                }
                else if (selectorTarget == CCBTargetType.Owner)
                {
                    target = reader.Owner;
                }

                if (target != null)
                {
                    if (selectorName.Length > 0)
                    {
                        SEL_CCControlHandler selCCControlHandler = null;

                        var targetAsCCBSelectorResolver = target as CCBSelectorResolver;
                        if (targetAsCCBSelectorResolver != null)
                        {
                            selCCControlHandler = targetAsCCBSelectorResolver.OnResolveCCBCCControlSelector(target, selectorName);
                        }
                        if (selCCControlHandler == null)
                        {
                            CCBSelectorResolver ccbSelectorResolver = reader.SelectorResolver;
                            if (ccbSelectorResolver != null)
                            {
                                selCCControlHandler = ccbSelectorResolver.OnResolveCCBCCControlSelector(target, selectorName);
                            }
                        }

                        if (selCCControlHandler == null)
                        {
                            CCLog.Log("Skipping selector '{0}' since no CCBSelectorResolver is present.", selectorName);
                        }
                        else
                        {
                            var blockCCControlData = new BlockCCControlData();
                            blockCCControlData.mSELCCControlHandler = selCCControlHandler;

                            blockCCControlData.mTarget        = target;
                            blockCCControlData.mControlEvents = controlEvents;

                            return(blockCCControlData);
                        }
                    }
                    else
                    {
                        CCLog.Log("Unexpected empty selector.");
                    }
                }
                else
                {
                    CCLog.Log("Unexpected NULL target for selector.");
                }
            }

            return(null);
        }