示例#1
0
        protected override void OnHandlePropTypeBlock(CCNode node, CCNode parent, string propertyName, BlockData pBlockData, CCBReader reader)
        {
            if (propertyName == PROPERTY_BLOCK)
            {
                if (null != pBlockData) // Add this condition to allow CCMenuItemImage without target/selector predefined 
                {
					((CCMenuItem) node).Target = pBlockData.mSELMenuHandler;
                }
            }
            else
            {
                base.OnHandlePropTypeBlock(node, parent, propertyName, pBlockData, reader);
            }
        }
示例#2
0
        protected virtual BlockData ParsePropTypeBlock(CCNode node, CCNode parent, CCBReader reader)
        {
            string selectorName = reader.ReadCachedString();
            var selectorTarget = (CCBTargetType) reader.ReadInt(false);

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

                        /* Scripting specific code because selector function is common for all callbacks.
                         * So if we had 1 target and 1 selector function, the context (callback function name)
                         * would get lost. Hence the need for a new target for each callback.
                         */
                        if (reader.HasScriptingOwner)
                        {
                            var proxy = (ICCBScriptOwner) reader.Owner;
                            if (proxy != null)
                            {
                                target = proxy.CreateNew() as object;
                            }
                        }
                    }

                    if (target != null)
                    {
                        if (selectorName.Length > 0)
                        {
                            Action<object> selMenuHandler = null;

                            var targetAsCCBSelectorResolver = target as ICCBSelectorResolver;

                            if (targetAsCCBSelectorResolver != null)
                            {
                                selMenuHandler = targetAsCCBSelectorResolver.OnResolveCCBCCMenuItemSelector(target,
                                                                                                            selectorName);
                            }
                            if (selMenuHandler == null)
                            {
                                ICCBSelectorResolver ccbSelectorResolver = reader.SelectorResolver;
                                if (ccbSelectorResolver != null)
                                {
                                    selMenuHandler = ccbSelectorResolver.OnResolveCCBCCMenuItemSelector(target,
                                                                                                        selectorName);
                                }
                            }

                            if (selMenuHandler == null)
                            {
                                CCLog.Log("Skipping selector '{0}' since no CCBSelectorResolver is present.",
                                          selectorName);
                            }
                            else
                            {
                                var blockData = new BlockData();
                                blockData.mSELMenuHandler = selMenuHandler;

                                blockData.mTarget = target;

                                return blockData;
                            }
                        }
                        else
                        {
                            CCLog.Log("Unexpected empty selector.");
                        }
                    }
                    else
                    {
                        CCLog.Log("Unexpected NULL target for selector.");
                    }
                }
                else
                {
                    if (selectorTarget == CCBTargetType.DocumentRoot)
                    {
                        reader.AddDocumentCallbackNode(node);
                        reader.AddDocumentCallbackName(selectorName);

                    }
                    else
                    {
                        reader.AddOwnerCallbackNode(node);
                        reader.AddOwnerCallbackName(selectorName);
                    }
                }
            }

            return null;
        }
示例#3
0
 protected virtual void OnHandlePropTypeBlock(CCNode node, CCNode parent, string propertyName, BlockData pBlockData, CCBReader reader)
 {
     CCLog.Log("Unexpected property type: '{0}'!", propertyName);
     Debug.Assert(false);
 }