Пример #1
0
 protected override void OnHandlePropTypeSpriteFrame(CCNode node, CCNode parent, string propertyName, CCSpriteFrame spriteFrame,
                                                     CCBReader reader)
 {
     if (propertyName == PROPERTY_NORMALDISPLAYFRAME)
     {
         if (spriteFrame != null)
         {
             ((CCMenuItemImage)node).SetNormalSpriteFrame(spriteFrame);
         }
     }
     else if (propertyName == PROPERTY_SELECTEDDISPLAYFRAME)
     {
         if (spriteFrame != null)
         {
             ((CCMenuItemImage)node).SetSelectedSpriteFrame(spriteFrame);
         }
     }
     else if (propertyName == PROPERTY_DISABLEDDISPLAYFRAME)
     {
         if (spriteFrame != null)
         {
             ((CCMenuItemImage)node).SetDisabledSpriteFrame(spriteFrame);
         }
     }
     else
     {
         base.OnHandlePropTypeSpriteFrame(node, parent, propertyName, spriteFrame, reader);
     }
 }
Пример #2
0
        public CCNode ReadNodeGraphFromFile(string fileName, object owner, CCSize parentSize)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                return(null);
            }

            string strCCBFileName = fileName;
            string strSuffix      = ".ccbi";

            // Add ccbi suffix
            if (!CCBReader.EndsWith(strCCBFileName, strSuffix))
            {
                strCCBFileName += strSuffix;
            }

            string strPath = CCFileUtils.FullPathFromRelativePath(strCCBFileName);

            var pBytes = CCFileUtils.GetFileBytes(strPath);

            byte[] data = pBytes;

            CCNode ret = ReadNodeGraphFromData(data, owner, parentSize);

            return(ret);
        }
Пример #3
0
        protected virtual CCNode ParsePropTypeCcbFile(CCNode node, CCNode parent, CCBReader reader)
        {
            string ccbFileName = reader.ReadCachedString();

            /* Change path extension to .ccbi. */
            string ccbFileWithoutPathExtension = CCBReader.DeletePathExtension(ccbFileName);

            ccbFileName = ccbFileWithoutPathExtension + ".ccbi";

            // Load sub file
            string path      = CCFileUtils.FullPathFromRelativePath(ccbFileName);
            var    ccbReader = new CCBReader(reader);

            byte[] pBytes = CCFileUtils.GetFileBytes(path);
            ccbReader.InitWithData(pBytes, reader.Owner);
            ccbReader.AnimationManager.RootContainerSize = parent.ContentSize;

            CCNode ccbFileNode = ccbReader.ReadFileWithCleanUp(false);

            if (ccbFileNode != null && ccbReader.AnimationManager.AutoPlaySequenceId != -1)
            {
                // Auto play animations
                ccbReader.AnimationManager.RunAnimations(ccbReader.AnimationManager.AutoPlaySequenceId, 0);
            }

            return(ccbFileNode);
        }
Пример #4
0
        protected virtual CCPoint ParsePropTypePosition(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            float x = reader.ReadFloat();
            float y = reader.ReadFloat();

            var type = (CCBPositionType)reader.ReadInt(false);

            CCSize containerSize = reader.AnimationManager.GetContainerSize(parent);

            CCPoint pt = CCBHelper.GetAbsolutePosition(new CCPoint(x, y), type, containerSize, propertyName);

            node.Position = CCBHelper.GetAbsolutePosition(pt, type, containerSize, propertyName);

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                var baseValue = new List <CCBValue>
                {
                    new CCBValue(x),
                    new CCBValue(y),
                    new CCBValue((int)type)
                };
                reader.AnimationManager.SetBaseValue(baseValue, node, propertyName);
            }

            return(pt);
        }
Пример #5
0
        public void openTest(string pCCBFileName, string pCCNodeName, CCNodeLoader pCCNodeLoader)
        {
            /* Create an autorelease CCNodeLoaderLibrary. */
            CCNodeLoaderLibrary ccNodeLoaderLibrary = CCNodeLoaderLibrary.NewDefaultCCNodeLoaderLibrary();

            ccNodeLoaderLibrary.RegisterCCNodeLoader("TestHeaderLayer", new Loader<TestHeaderLayer>());
            if (pCCNodeName != null && pCCNodeLoader != null)
            {
                ccNodeLoaderLibrary.RegisterCCNodeLoader(pCCNodeName, pCCNodeLoader);
            }

            /* Create an autorelease CCBReader. */
            var ccbReader = new CCBReader(ccNodeLoaderLibrary);

            /* Read a ccbi file. */
            // Load the scene from the ccbi-file, setting this class as
            // the owner will cause lblTestTitle to be set by the CCBReader.
            // lblTestTitle is in the TestHeader.ccbi, which is referenced
            // from each of the test scenes.
            CCNode node = ccbReader.ReadNodeGraphFromFile(pCCBFileName, this);

            mTestTitleLabelTTF.Label = (pCCBFileName);

            CCScene scene = new CCScene();
            scene.AddChild(node);

            /* Push the new scene with a fancy transition. */
            CCColor3B transitionColor;
            transitionColor.R = 0;
            transitionColor.G = 0;
            transitionColor.B = 0;

            CCDirector.SharedDirector.PushScene(new CCTransitionFade(0.5f, scene, transitionColor));
        }
Пример #6
0
        protected virtual float[] ParsePropTypeScaleLock(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            float x = reader.ReadFloat();
            float y = reader.ReadFloat();

            var type = (CCBScaleType)reader.ReadInt(false);

            CCBHelper.SetRelativeScale(node, x, y, type, propertyName);

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                var baseValue = new List <CCBValue>
                {
                    new CCBValue(x),
                    new CCBValue(y),
                    new CCBValue((int)type)
                };
                reader.AnimationManager.SetBaseValue(baseValue, node, propertyName);
            }

            if (type == CCBScaleType.MultiplyResolution)
            {
                x *= CCBReader.ResolutionScale;
                y *= CCBReader.ResolutionScale;
            }

            var scaleLock = new float[2];

            scaleLock[0] = x;
            scaleLock[1] = y;

            return(scaleLock);
        }
Пример #7
0
        protected virtual CCPoint ParsePropTypePointLock(CCNode node, CCNode parent, CCBReader reader)
        {
            float x = reader.ReadFloat();
            float y = reader.ReadFloat();

            return(new CCPoint(x, y));
        }
Пример #8
0
 protected override void OnHandlePropTypeSpriteFrame(CCNode node, CCNode parent, string propertyName, CCSpriteFrame spriteFrame,
                                                     CCBReader reader)
 {
     if (propertyName == PROPERTY_NORMALDISPLAYFRAME)
     {
         if (spriteFrame != null)
         {
             ((CCMenuItemImage) node).SetNormalSpriteFrame(spriteFrame);
         }
     }
     else if (propertyName == PROPERTY_SELECTEDDISPLAYFRAME)
     {
         if (spriteFrame != null)
         {
             ((CCMenuItemImage) node).SetSelectedSpriteFrame(spriteFrame);
         }
     }
     else if (propertyName == PROPERTY_DISABLEDDISPLAYFRAME)
     {
         if (spriteFrame != null)
         {
             ((CCMenuItemImage) node).SetDisabledSpriteFrame(spriteFrame);
         }
     }
     else
     {
         base.OnHandlePropTypeSpriteFrame(node, parent, propertyName, spriteFrame, reader);
     }
 }
Пример #9
0
        protected virtual CCSize ParsePropTypeSize(CCNode node, CCNode parent, CCBReader reader)
        {
            float width  = reader.ReadFloat();
            float height = reader.ReadFloat();

            int type = reader.ReadInt(false);

            CCSize containerSize = reader.AnimationManager.GetContainerSize(parent);

            switch ((CCBSizeType)type)
            {
            case CCBSizeType.Absolute:
            {
                /* Nothing. */
                break;
            }

            case CCBSizeType.RelativeContainer:
            {
                width  = containerSize.Width - width;
                height = containerSize.Height - height;
                break;
            }

            case CCBSizeType.Percent:
            {
                width  = (int)(containerSize.Width * width / 100.0f);
                height = (int)(containerSize.Height * height / 100.0f);
                break;
            }

            case CCBSizeType.HorizontalPercent:
            {
                width = (int)(containerSize.Width * width / 100.0f);
                break;
            }

            case CCBSizeType.VerticalPercent:
            {
                height = (int)(containerSize.Height * height / 100.0f);
                break;
            }

            case CCBSizeType.MultiplyResolution:
            {
                float resolutionScale = CCBReader.ResolutionScale;

                width  *= resolutionScale;
                height *= resolutionScale;
                break;
            }

            default:
                break;
            }

            return(new CCSize(width, height));
        }
Пример #10
0
        protected virtual byte ParsePropTypeByte(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            byte ret = reader.ReadByte();

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                reader.AnimationManager.SetBaseValue(new CCBValue(ret), node, propertyName);
            }

            return(ret);
        }
Пример #11
0
 protected override void OnHandlePropTypeFloat(CCNode node, CCNode parent, string propertyName, float pFloat, CCBReader reader)
 {
     if (propertyName == PROPERTY_SCALE)
     {
         node.Scale = pFloat;
     }
     else
     {
         base.OnHandlePropTypeFloat(node, parent, propertyName, pFloat, reader);
     }
 }
Пример #12
0
 protected override void OnHandlePropTypeCheck(CCNode node, CCNode parent, string propertyName, bool pCheck, CCBReader reader)
 {
     if (propertyName == PROPERTY_ISENABLED)
     {
         ((CCMenuItem) node).Enabled = pCheck;
     }
     else
     {
         base.OnHandlePropTypeCheck(node, parent, propertyName, pCheck, reader);
     }
 }
Пример #13
0
 protected override void OnHandlePropTypeSize(CCNode node, CCNode parent, string propertyName, CCSize pSize, CCBReader reader)
 {
     if (propertyName == PROPERTY_CONTENTSIZE)
     {
         ((CCScrollView) node).ViewSize = pSize;
     }
     else
     {
         base.OnHandlePropTypeSize(node, parent, propertyName, pSize, reader);
     }
 }
Пример #14
0
        public CCBReader(CCBReader reader)
        {
            mCurrentByte = -1;
            mCurrentBit  = -1;

            mLoadedSpriteSheets  = reader.mLoadedSpriteSheets;
            mCCNodeLoaderLibrary = reader.mCCNodeLoaderLibrary;

            mCCBMemberVariableAssigner = reader.mCCBMemberVariableAssigner;
            mCCBSelectorResolver       = reader.mCCBSelectorResolver;
            mCCNodeLoaderListener      = reader.mCCNodeLoaderListener;
        }
Пример #15
0
        protected virtual float ParsePropTypeDegrees(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            float ret = reader.ReadFloat();

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                CCBValue value = new CCBValue(ret);
                reader.AnimationManager.SetBaseValue(value, node, propertyName);
            }

            return(ret);
        }
Пример #16
0
 protected override void OnHandlePropTypeIntegerLabeled(CCNode node, CCNode parent, string propertyName, int pIntegerLabeled,
                                                        CCBReader reader)
 {
     if (propertyName == PROPERTY_DIRECTION)
     {
         ((CCScrollView)node).Direction = (CCScrollViewDirection)pIntegerLabeled;
     }
     else
     {
         base.OnHandlePropTypeFloatScale(node, parent, propertyName, pIntegerLabeled, reader);
     }
 }
Пример #17
0
        protected virtual float[] ParsePropTypeFloatVar(CCNode node, CCNode parent, CCBReader reader)
        {
            float f    = reader.ReadFloat();
            float fVar = reader.ReadFloat();

            var arr = new float[2];

            arr[0] = f;
            arr[1] = fVar;

            return(arr);
        }
Пример #18
0
        protected virtual bool ParsePropTypeCheck(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            bool ret = reader.ReadBool();

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                CCBValue value = new CCBValue(ret);
                reader.AnimationManager.SetBaseValue(value, node, propertyName);
            }

            return(ret);
        }
Пример #19
0
        protected virtual bool[] ParsePropTypeFlip(CCNode node, CCNode parent, CCBReader reader)
        {
            bool flipX = reader.ReadBool();
            bool flipY = reader.ReadBool();

            var arr = new bool[2];

            arr[0] = flipX;
            arr[1] = flipY;

            return(arr);
        }
Пример #20
0
 protected override void OnHandlePropTypeIntegerLabeled(CCNode node, CCNode parent, string propertyName, int pIntegerLabeled,
                                                        CCBReader reader)
 {
     if (propertyName == PROPERTY_DIRECTION)
     {
         ((CCScrollView) node).Direction = (CCScrollViewDirection) pIntegerLabeled;
     }
     else
     {
         base.OnHandlePropTypeFloatScale(node, parent, propertyName, pIntegerLabeled, reader);
     }
 }
Пример #21
0
 protected override void OnHandlePropTypeCCBFile(CCNode node, CCNode parent, string propertyName, CCNode fileNode, CCBReader reader)
 {
     if (propertyName == PROPERTY_CONTAINER)
     {
         ((CCScrollView) node).Container = fileNode;
         ((CCScrollView) node).UpdateInset();
     }
     else
     {
         base.OnHandlePropTypeCCBFile(node, parent, propertyName, fileNode, reader);
     }
 }
Пример #22
0
        protected virtual float ParsePropTypeFloatScale(CCNode node, CCNode parent, CCBReader reader)
        {
            float f = reader.ReadFloat();

            int type = reader.ReadInt(false);

            if ((CCBScaleType)type == CCBScaleType.MultiplyResolution)
            {
                f *= CCBReader.ResolutionScale;
            }

            return(f);
        }
Пример #23
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).SetTarget(pBlockData.mSELMenuHandler);
         }
     }
     else
     {
         base.OnHandlePropTypeBlock(node, parent, propertyName, pBlockData, reader);
     }
 }
Пример #24
0
        protected virtual CCColor3B ParsePropTypeColor3(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            byte red   = reader.ReadByte();
            byte green = reader.ReadByte();
            byte blue  = reader.ReadByte();

            var color = new CCColor3B(red, green, blue);

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                CCColor3BWapper value = new CCColor3BWapper(color);
                reader.AnimationManager.SetBaseValue(value, node, propertyName);
            }
            return(color);
        }
Пример #25
0
 protected override void OnHandlePropTypeCheck(CCNode node, CCNode parent, string propertyName, bool pCheck, CCBReader reader)
 {
     if (propertyName == PROPERTY_CLIPSTOBOUNDS)
     {
         ((CCScrollView) node).ClippingToBounds = pCheck;
     }
     else if (propertyName == PROPERTY_BOUNCES)
     {
         ((CCScrollView) node).Bounceable = pCheck;
     }
     else
     {
         base.OnHandlePropTypeCheck(node, parent, propertyName, pCheck, reader);
     }
 }
Пример #26
0
        protected virtual string ParsePropTypeFontTTF(CCNode node, CCNode parent, CCBReader reader)
        {
            string fontTTF = reader.ReadCachedString();

            // CCString * ttfEnding = ".ttf";

            // TODO Fix me if it is wrong

            /* If the fontTTF comes with the ".ttf" extension, prepend the absolute path.
             * System fonts come without the ".ttf" extension and do not need the path prepended. */
            /*
             * if(CCBReader.endsWith(CCBReader.toLowerCase(fontTTF), ttfEnding)){
             *  fontTTF = CCBReader.concat(reader.getCCBRootPath(), fontTTF);
             * }
             */

            return(fontTTF);
        }
Пример #27
0
        public override void runThisTest()
        {
            /* Create an autorelease CCNodeLoaderLibrary. */
            CCNodeLoaderLibrary ccNodeLoaderLibrary = new CCNodeLoaderLibrary();

            ccNodeLoaderLibrary.RegisterCCNodeLoader("HelloCocosBuilderLayer", new Loader<HelloCocosBuilderLayer>());

            /* Create an autorelease CCBReader. */
            var ccbReader = new CCBReader(ccNodeLoaderLibrary);

            /* Read a ccbi file. */
            CCNode node = ccbReader.ReadNodeGraphFromFile("ccb/HelloCocosBuilder.ccbi", this);

            if (node != null)
            {
                AddChild(node);
            }

            CCDirector.SharedDirector.ReplaceScene(this);
        }
Пример #28
0
        public CCBReader(CCBReader reader)
        {
            _currentByte = -1;
            _currentBit  = -1;

            _loadedSpriteSheets = reader._loadedSpriteSheets;
            _nodeLoaderLibrary  = reader._nodeLoaderLibrary;

            _CCBMemberVariableAssigner = reader._CCBMemberVariableAssigner;
            _CCBSelectorResolver       = reader._CCBSelectorResolver;
            _nodeLoaderListener        = reader._nodeLoaderListener;

            _ownerCallbackNames = reader._ownerCallbackNames;
            _ownerCallbackNodes = reader._ownerCallbackNodes;
            _ownerOutletNames   = reader._ownerOutletNames;
            _ownerOutletNodes   = reader._ownerOutletNodes;

            _CCBRootPath = reader.CCBRootPath;

            Init();
        }
Пример #29
0
        protected virtual CCAnimation ParsePropTypeAnimation(CCNode node, CCNode parent, CCBReader reader)
        {
            string animationFile = reader.ReadCachedString();
            string animation     = reader.ReadCachedString();

            CCAnimation ccAnimation = null;

            // Support for stripping relative file paths, since ios doesn't currently
            // know what to do with them, since its pulling from bundle.
            // Eventually this should be handled by a client side asset manager
            // interface which figured out what resources to load.
            // TODO Does this problem exist in C++?
            animation     = CCBReader.LastPathComponent(animation);
            animationFile = CCBReader.LastPathComponent(animationFile);

            if (!String.IsNullOrEmpty(animation))
            {
                CCAnimationCache animationCache = CCAnimationCache.SharedAnimationCache;
                animationCache.AddAnimationsWithFile(animationFile);

                ccAnimation = animationCache.AnimationByName(animation);
            }
            return(ccAnimation);
        }
Пример #30
0
        public void onAnimationsTestClicked(object pSender, CCControlEvent pCCControlEvent)
        {
            // Load node graph (TestAnimations is a sub class of CCLayer) and retrieve the ccb action manager
            CCBAnimationManager actionManager = null;

            /* Create an autorelease CCNodeLoaderLibrary. */
            CCNodeLoaderLibrary ccNodeLoaderLibrary = CCNodeLoaderLibrary.NewDefaultCCNodeLoaderLibrary();

            ccNodeLoaderLibrary.RegisterCCNodeLoader("TestHeaderLayer", new Loader<TestHeaderLayer>());
            ccNodeLoaderLibrary.RegisterCCNodeLoader("TestAnimationsLayer", new Loader<AnimationsTestLayer>());


            /* Create an autorelease CCBReader. */
            var ccbReader = new CCBReader(ccNodeLoaderLibrary);

            /* Read a ccbi file. */
            // Load the scene from the ccbi-file, setting this class as
            // the owner will cause lblTestTitle to be set by the CCBReader.
            // lblTestTitle is in the TestHeader.ccbi, which is referenced
            // from each of the test scenes.
            CCNode animationsTest = ccbReader.ReadNodeGraphFromFile("ccb/ccb/TestAnimations.ccbi", this, ref actionManager);
            ((AnimationsTestLayer) animationsTest).setAnimationManager(actionManager);

            mTestTitleLabelTTF.Label = ("TestAnimations.ccbi");

            CCScene scene = new CCScene();
            scene.AddChild(animationsTest);

            /* Push the new scene with a fancy transition. */
            CCColor3B transitionColor;
            transitionColor.R = 0;
            transitionColor.G = 0;
            transitionColor.B = 0;

            CCDirector.SharedDirector.PushScene(new CCTransitionFade(0.5f, scene, transitionColor));
        }
Пример #31
0
        protected virtual CCSpriteFrame ParsePropTypeSpriteFrame(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            string spriteSheet = reader.ReadCachedString();
            string spriteFile = reader.ReadCachedString();

            CCSpriteFrame spriteFrame = null;
            if (spriteFile.Length != 0)
            {
                if (spriteSheet.Length == 0)
                {
                    spriteFile = reader.CCBRootPath + spriteFile;
                    CCTexture2D texture = CCTextureCache.SharedTextureCache.AddImage(CCFileUtils.RemoveExtension(spriteFile));
                    var bounds = new CCRect(0, 0, texture.ContentSize.Width, texture.ContentSize.Height);
                    spriteFrame = new CCSpriteFrame(texture, bounds);
                }
                else
                {
                    CCSpriteFrameCache frameCache = CCSpriteFrameCache.SharedSpriteFrameCache;
                    spriteSheet = reader.CCBRootPath + spriteSheet;

                    // Load the sprite sheet only if it is not loaded
                    if (!reader.LoadedSpriteSheet.Contains(spriteSheet))
                    {
                        frameCache.AddSpriteFramesWithFile(spriteSheet);
                        reader.LoadedSpriteSheet.Add(spriteSheet);
                    }

                    spriteFrame = frameCache.SpriteFrameByName(spriteFile);
                }

                if (reader.AnimatedProperties.Contains(propertyName))
                {
                    reader.AnimationManager.SetBaseValue(spriteFrame, node, propertyName);
                }
            }

            return spriteFrame;
        }
Пример #32
0
        protected virtual bool ParsePropTypeCheck(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            bool ret = reader.ReadBool();

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                CCBValue value = new CCBValue(ret);
                reader.AnimationManager.SetBaseValue(value, node, propertyName);
            }

            return ret;
        }
Пример #33
0
        public virtual void ParseProperties(CCNode node, CCNode parent, CCBReader reader)
        {
            int numRegularProps = reader.ReadInt(false);
            int numExturaProps = reader.ReadInt(false);
            int propertyCount = numRegularProps + numExturaProps;

            for (int i = 0; i < propertyCount; i++)
            {
                bool isExtraProp = (i >= numRegularProps);
                int type = reader.ReadInt(false);
                string propertyName = reader.ReadCachedString();

                // Check if the property can be set for this platform
                bool setProp = false;

                var platform = (PlatformType) reader.ReadByte();
                if (platform == PlatformType.All)
                {
                    setProp = true;
                }
#if __CC_PLATFORM_IOS
        if(platform == kCCBPlatform.kCCBPlatformIOS) 
        {
            setProp = true;
        }
#elif __CC_PLATFORM_MAC
        if(platform == kCCBPlatform.kCCBPlatformMac) 
        {
            setProp = true;
        }
#endif

                // Forward properties for sub ccb files
                if (node is CCBFile)
                {
                    var ccbNode = (CCBFile) node;
                    if (ccbNode.FileNode != null && isExtraProp)
                    {
                        node = ccbNode.FileNode;

                        // Skip properties that doesn't have a value to override
                        var extraPropsNames = (List<string>) node.UserObject;
                        bool bFound = false;
                        foreach (var pObj in extraPropsNames)
                        {
                            if (pObj == propertyName)
                            {
                                bFound = true;
                                break;
                            }
                        }
                        setProp &= bFound;
                    }
                }
                else if (isExtraProp && node == reader.AnimationManager.RootNode)
                {
                    var extraPropsNames = (List<string>) node.UserObject;
                    if (extraPropsNames == null)
                    {
                        extraPropsNames = new List<string>();
                        node.UserObject = extraPropsNames;
                    }

                    extraPropsNames.Add(propertyName);
                }

                switch ((CCBPropertyType) type)
                {
                    case CCBPropertyType.Position:
                        {
                            CCPoint position = ParsePropTypePosition(node, parent, reader, propertyName);
                            if (setProp)
                            {
                                OnHandlePropTypePosition(node, parent, propertyName, position, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Point:
                        {
                            CCPoint point = ParsePropTypePoint(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypePoint(node, parent, propertyName, point, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.PointLock:
                        {
                            CCPoint pointLock = ParsePropTypePointLock(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypePointLock(node, parent, propertyName, pointLock, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Size:
                        {
                            CCSize size = ParsePropTypeSize(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeSize(node, parent, propertyName, size, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.ScaleLock:
                        {
                            float[] scaleLock = ParsePropTypeScaleLock(node, parent, reader, propertyName);
                            if (setProp)
                            {
                                OnHandlePropTypeScaleLock(node, parent, propertyName, scaleLock, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Float:
                        {
                            float f = ParsePropTypeFloat(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeFloat(node, parent, propertyName, f, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.FloatXY:
                        {
                            var xy = ParsePropTypeFloatXY(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeFloatXY(node, parent, propertyName, xy, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Degrees:
                        {
                            float degrees = ParsePropTypeDegrees(node, parent, reader, propertyName);
                            if (setProp)
                            {
                                OnHandlePropTypeDegrees(node, parent, propertyName, degrees, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.FloatScale:
                        {
                            float floatScale = ParsePropTypeFloatScale(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeFloatScale(node, parent, propertyName, floatScale, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Integer:
                        {
                            int integer = ParsePropTypeInteger(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeInteger(node, parent, propertyName, integer, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.IntegerLabeled:
                        {
                            int integerLabeled = ParsePropTypeIntegerLabeled(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeIntegerLabeled(node, parent, propertyName, integerLabeled, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.FloatVar:
                        {
                            float[] floatVar = ParsePropTypeFloatVar(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeFloatVar(node, parent, propertyName, floatVar, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Check:
                        {
                            bool check = ParsePropTypeCheck(node, parent, reader, propertyName);
                            if (setProp)
                            {
                                OnHandlePropTypeCheck(node, parent, propertyName, check, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.SpriteFrame:
                        {
                            CCSpriteFrame ccSpriteFrame = ParsePropTypeSpriteFrame(node, parent, reader, propertyName);
                            if (setProp)
                            {
                                OnHandlePropTypeSpriteFrame(node, parent, propertyName, ccSpriteFrame, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Animation:
                        {
                            CCAnimation ccAnimation = ParsePropTypeAnimation(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeAnimation(node, parent, propertyName, ccAnimation, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Texture:
                        {
                            CCTexture2D ccTexture2D = ParsePropTypeTexture(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeTexture(node, parent, propertyName, ccTexture2D, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Byte:
                        {
                            byte b = ParsePropTypeByte(node, parent, reader, propertyName);
                            if (setProp)
                            {
                                OnHandlePropTypeByte(node, parent, propertyName, b, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Color3:
                        {
                            CCColor3B color3B = ParsePropTypeColor3(node, parent, reader, propertyName);
                            if (setProp)
                            {
                                OnHandlePropTypeColor3(node, parent, propertyName, color3B, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Color4FVar:
                        {
                            CCColor4F[] color4FVar = ParsePropTypeColor4FVar(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeColor4FVar(node, parent, propertyName, color4FVar, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Flip:
                        {
                            bool[] flip = ParsePropTypeFlip(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeFlip(node, parent, propertyName, flip, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Blendmode:
                        {
                            CCBlendFunc blendFunc = ParsePropTypeBlendFunc(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeBlendFunc(node, parent, propertyName, blendFunc, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.FntFile:
                        {
                            string fntFile = ParsePropTypeFntFile(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeFntFile(node, parent, propertyName, fntFile, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.FontTTF:
                        {
                            string fontTTF = ParsePropTypeFontTTF(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeFontTTF(node, parent, propertyName, fontTTF, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.String:
                        {
                            string s = ParsePropTypeString(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeString(node, parent, propertyName, s, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Text:
                        {
                            string text = ParsePropTypeText(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeText(node, parent, propertyName, text, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Block:
                        {
                            BlockData blockData = ParsePropTypeBlock(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeBlock(node, parent, propertyName, blockData, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.BlockCCControl:
                        {
                            BlockCCControlData blockCCControlData = ParsePropTypeBlockCcControl(node, parent, reader);
                            if (setProp && blockCCControlData != null)
                            {
                                OnHandlePropTypeBlockCcControl(node, parent, propertyName, blockCCControlData, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.CCBFile:
                        {
                            CCNode ccbFileNode = ParsePropTypeCcbFile(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeCCBFile(node, parent, propertyName, ccbFileNode, reader);
                            }
                            break;
                        }
                    default:
                        //ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(type);
                        break;
                }
            }
        }
Пример #34
0
 protected override void OnHandlePropTypeCheck(CCNode node, CCNode parent, string propertyName, bool pCheck, CCBReader reader)
 {
     if (propertyName == PROPERTY_ISENABLED)
     {
         ((CCMenuItem)node).Enabled = pCheck;
     }
     else
     {
         base.OnHandlePropTypeCheck(node, parent, propertyName, pCheck, reader);
     }
 }
Пример #35
0
 protected virtual void OnHandlePropTypeScaleLock(CCNode node, CCNode parent, string propertyName, float[] pScaleLock, CCBReader reader)
 {
     if (propertyName == PROPERTY_SCALE)
     {
         node.ScaleX = pScaleLock[0];
         node.ScaleY = pScaleLock[1];
     }
     else
     {
         CCLog.Log("Unexpected property type: '{0}'!", propertyName);
         Debug.Assert(false);
     }
 }
Пример #36
0
        protected virtual byte ParsePropTypeByte(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            byte ret = reader.ReadByte();

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                reader.AnimationManager.SetBaseValue(new CCBValue(ret), node, propertyName);
            }

            return ret;
        }
Пример #37
0
        protected virtual CCColor4F[] ParsePropTypeColor4FVar(CCNode node, CCNode parent, CCBReader reader)
        {
            float red = reader.ReadFloat();
            float green = reader.ReadFloat();
            float blue = reader.ReadFloat();
            float alpha = reader.ReadFloat();
            float redVar = reader.ReadFloat();
            float greenVar = reader.ReadFloat();
            float blueVar = reader.ReadFloat();
            float alphaVar = reader.ReadFloat();

            var colors = new CCColor4F[2];
            colors[0].R = red;
            colors[0].G = green;
            colors[0].B = blue;
            colors[0].A = alpha;

            colors[1].R = redVar;
            colors[1].G = greenVar;
            colors[1].B = blueVar;
            colors[1].A = alphaVar;

            return colors;
        }
Пример #38
0
 protected virtual void OnHandlePropTypeSize(CCNode node, CCNode parent, string propertyName, CCSize pSize, CCBReader reader)
 {
     if (propertyName == PROPERTY_CONTENTSIZE)
     {
         node.ContentSize = pSize;
     }
     else
     {
         CCLog.Log("Unexpected property type: '{0}'!", propertyName);
         Debug.Assert(false);
     }
 }
Пример #39
0
 protected virtual void OnHandlePropTypePosition(CCNode node, CCNode parent, string propertyName, CCPoint pPosition, CCBReader reader)
 {
     if (propertyName == PROPERTY_POSITION)
     {
         node.Position = pPosition;
     }
     else
     {
         CCLog.Log("Unexpected property type: '{0}'!", propertyName);
         Debug.Assert(false);
     }
 }
Пример #40
0
 protected override void OnHandlePropTypeFloat(CCNode node, CCNode parent, string propertyName, float pFloat, CCBReader reader)
 {
     if (propertyName == PROPERTY_SCALE)
     {
         node.Scale = pFloat;
     }
     else
     {
         base.OnHandlePropTypeFloat(node, parent, propertyName, pFloat, reader);
     }
 }
Пример #41
0
 protected virtual void OnHandlePropTypePoint(CCNode node, CCNode parent, string propertyName, CCPoint point, CCBReader reader)
 {
     if (propertyName == PROPERTY_ANCHORPOINT)
     {
         node.AnchorPoint = point;
     }
     else
     {
         CCLog.Log("Unexpected property type: '{0}'!", propertyName);
         Debug.Assert(false);
     }
 }
Пример #42
0
 protected override void OnHandlePropTypeCCBFile(CCNode node, CCNode parent, string propertyName, CCNode fileNode, CCBReader reader)
 {
     if (propertyName == PROPERTY_CONTAINER)
     {
         ((CCScrollView)node).Container = fileNode;
         ((CCScrollView)node).UpdateInset();
     }
     else
     {
         base.OnHandlePropTypeCCBFile(node, parent, propertyName, fileNode, reader);
     }
 }
Пример #43
0
 protected override void OnHandlePropTypeCheck(CCNode node, CCNode parent, string propertyName, bool pCheck, CCBReader reader)
 {
     if (propertyName == PROPERTY_CLIPSTOBOUNDS)
     {
         ((CCScrollView)node).ClippingToBounds = pCheck;
     }
     else if (propertyName == PROPERTY_BOUNCES)
     {
         ((CCScrollView)node).Bounceable = pCheck;
     }
     else
     {
         base.OnHandlePropTypeCheck(node, parent, propertyName, pCheck, reader);
     }
 }
Пример #44
0
 protected override void OnHandlePropTypeSize(CCNode node, CCNode parent, string propertyName, CCSize pSize, CCBReader reader)
 {
     if (propertyName == PROPERTY_CONTENTSIZE)
     {
         ((CCScrollView)node).ViewSize = pSize;
     }
     else
     {
         base.OnHandlePropTypeSize(node, parent, propertyName, pSize, reader);
     }
 }
Пример #45
0
        protected virtual CCAnimation ParsePropTypeAnimation(CCNode node, CCNode parent, CCBReader reader)
        {
            string animationFile = reader.ReadCachedString();
            string animation = reader.ReadCachedString();

            CCAnimation ccAnimation = null;

            // Support for stripping relative file paths, since ios doesn't currently
            // know what to do with them, since its pulling from bundle.
            // Eventually this should be handled by a client side asset manager
            // interface which figured out what resources to load.
            // TODO Does this problem exist in C++?
            animation = CCBReader.LastPathComponent(animation);
            animationFile = CCBReader.LastPathComponent(animationFile);

            if (!String.IsNullOrEmpty(animation))
            {
                CCAnimationCache animationCache = CCAnimationCache.SharedAnimationCache;
                animationCache.AddAnimationsWithFile(animationFile);

                ccAnimation = animationCache.AnimationByName(animation);
            }
            return ccAnimation;
        }
Пример #46
0
        protected virtual CCBlendFunc ParsePropTypeBlendFunc(CCNode node, CCNode parent, CCBReader reader)
        {
            int source = reader.ReadInt(false);
            int destination = reader.ReadInt(false);

            CCBlendFunc blendFunc;
            blendFunc.Source = source;
            blendFunc.Destination = destination;

            return blendFunc;
        }
Пример #47
0
        protected virtual CCTexture2D ParsePropTypeTexture(CCNode node, CCNode parent, CCBReader reader)
        {
            string spriteFile = reader.ReadCachedString();

            if (!String.IsNullOrEmpty(spriteFile))
            {
                return CCTextureCache.SharedTextureCache.AddImage(CCFileUtils.RemoveExtension(spriteFile));
            }
            return null;
        }
Пример #48
0
        protected virtual string ParsePropTypeFontTTF(CCNode node, CCNode parent, CCBReader reader)
        {
            string fontTTF = reader.ReadCachedString();

            // CCString * ttfEnding = ".ttf";

            // TODO Fix me if it is wrong
            /* If the fontTTF comes with the ".ttf" extension, prepend the absolute path. 
             * System fonts come without the ".ttf" extension and do not need the path prepended. */
            /*
            if(CCBReader.endsWith(CCBReader.toLowerCase(fontTTF), ttfEnding)){
                fontTTF = CCBReader.concat(reader.getCCBRootPath(), fontTTF);
            }
             */

            return fontTTF;
        }
Пример #49
0
        protected virtual CCColor3B ParsePropTypeColor3(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            byte red = reader.ReadByte();
            byte green = reader.ReadByte();
            byte blue = reader.ReadByte();

            var color = new CCColor3B(red, green, blue);
            if (reader.AnimatedProperties.Contains(propertyName))
            {
                CCColor3BWapper value = new CCColor3BWapper(color);
                reader.AnimationManager.SetBaseValue(value, node, propertyName);
            }
            return color;
        }
Пример #50
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)
            {
                if (!reader.IsJSControlled())
                {
                    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)
                        {
                            Action<object, CCControlEvent> selCCControlHandler = null;

                            var targetAsCCBSelectorResolver = target as ICCBSelectorResolver;
                            if (targetAsCCBSelectorResolver != null)
                            {
                                selCCControlHandler = targetAsCCBSelectorResolver.OnResolveCCBCCControlSelector(target,
                                                                                                                selectorName);
                            }
                            if (selCCControlHandler == null)
                            {
                                ICCBSelectorResolver 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.");
                    }
                }
                else
                {
                    if (selectorTarget == CCBTargetType.DocumentRoot)
                    {
                        reader.AddDocumentCallbackNode(node);
                        reader.AddDocumentCallbackName(selectorName);

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

            return null;
        }
Пример #51
0
        protected virtual bool[] ParsePropTypeFlip(CCNode node, CCNode parent, CCBReader reader)
        {
            bool flipX = reader.ReadBool();
            bool flipY = reader.ReadBool();

            var arr = new bool[2];
            arr[0] = flipX;
            arr[1] = flipY;

            return arr;
        }
Пример #52
0
 protected virtual void OnHandlePropTypePointLock(CCNode node, CCNode parent, string propertyName, CCPoint pPointLock, CCBReader reader)
 {
     CCLog.Log("Unexpected property type: '{0}'!", propertyName);
     Debug.Assert(false);
 }
Пример #53
0
 protected virtual string ParsePropTypeText(CCNode node, CCNode parent, CCBReader reader)
 {
     return reader.ReadCachedString();
 }
Пример #54
0
        protected virtual float ParsePropTypeFloatScale(CCNode node, CCNode parent, CCBReader reader)
        {
            float f = reader.ReadFloat();

            int type = reader.ReadInt(false);

            if ((CCBScaleType) type == CCBScaleType.MultiplyResolution)
            {
                f *= CCBReader.ResolutionScale;
            }

            return f;
        }
Пример #55
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 = (ICCBScriptOwnerProtocol) 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;
        }
Пример #56
0
 protected virtual int ParsePropTypeIntegerLabeled(CCNode node, CCNode parent, CCBReader reader)
 {
     return reader.ReadInt(true);
 }
Пример #57
0
        protected virtual CCNode ParsePropTypeCcbFile(CCNode node, CCNode parent, CCBReader pCCBReader)
        {
            string ccbFileName = pCCBReader.ReadCachedString();

            /* Change path extension to .ccbi. */
            string ccbFileWithoutPathExtension = CCBReader.DeletePathExtension(ccbFileName);
            ccbFileName = ccbFileWithoutPathExtension + ".ccbi";

            // Load sub file
            string path = CCFileUtils.FullPathFromRelativePath(ccbFileName);
            //long size = 0;
            byte[] pBytes = CCFileUtils.GetFileBytes(path);
            var reader = new CCBReader(pCCBReader);

            reader.AnimationManager.RootContainerSize = parent.ContentSize;

            reader._bytes = pBytes;
            reader._currentByte = 0;
            reader._currentBit = 0;
            reader._owner = pCCBReader._owner;

            reader.AnimationManager._owner = reader._owner;

            CCNode ccbFileNode = reader.ReadFileWithCleanUp(false, pCCBReader.AnimationManagers);

            if (ccbFileNode != null && reader.AnimationManager.AutoPlaySequenceId != -1)
            {
                // Auto play animations
                reader.AnimationManager.RunAnimationsForSequenceIdTweenDuration(reader.AnimationManager.AutoPlaySequenceId, 0);
            }

            if (reader.IsJSControlled() && pCCBReader.IsJSControlled() && null != reader._owner)
            {
                //set variables and callback to owner
                //set callback
                var ownerCallbackNames = reader.OwnerCallbackNames;
                var ownerCallbackNodes = reader.OwnerCallbackNodes;
                if (null != ownerCallbackNames && ownerCallbackNames.Count > 0 &&
                    null != ownerCallbackNodes && ownerCallbackNodes.Count > 0)
                {
                    Debug.Assert(ownerCallbackNames.Count == ownerCallbackNodes.Count);
                    int nCount = ownerCallbackNames.Count;
                    for (int i = 0; i < nCount; i++)
                    {
                        pCCBReader.AddOwnerCallbackName(ownerCallbackNames[i]);
                        pCCBReader.AddOwnerCallbackNode(ownerCallbackNodes[i]);
                    }
                }
                //set variables
                var ownerOutletNames = reader.OwnerOutletNames;
                var ownerOutletNodes = reader.OwnerOutletNodes;
                if (null != ownerOutletNames && ownerOutletNames.Count > 0 &&
                    null != ownerOutletNodes && ownerOutletNodes.Count > 0)
                {
                    Debug.Assert(ownerOutletNames.Count == ownerOutletNodes.Count);
                    int nCount = ownerOutletNames.Count;
                    for (int i = 0; i < nCount; i++)
                    {
                        pCCBReader.AddOwnerOutletName(ownerOutletNames[i]);
                        pCCBReader.AddOwnerOutletNode(ownerOutletNodes[i]);
                    }
                }
            }

            return ccbFileNode;
        }
Пример #58
0
        protected virtual float[] ParsePropTypeFloatVar(CCNode node, CCNode parent, CCBReader reader)
        {
            float f = reader.ReadFloat();
            float fVar = reader.ReadFloat();

            var arr = new float[2];
            arr[0] = f;
            arr[1] = fVar;

            return arr;
        }
Пример #59
0
        public CCBReader(CCBReader reader)
        {
            _currentByte = -1;
            _currentBit = -1;

            _loadedSpriteSheets = reader._loadedSpriteSheets;
            _nodeLoaderLibrary = reader._nodeLoaderLibrary;

            _CCBMemberVariableAssigner = reader._CCBMemberVariableAssigner;
            _CCBSelectorResolver = reader._CCBSelectorResolver;
            _nodeLoaderListener = reader._nodeLoaderListener;

            _ownerCallbackNames = reader._ownerCallbackNames;
            _ownerCallbackNodes = reader._ownerCallbackNodes;
            _ownerOutletNames = reader._ownerOutletNames;
            _ownerOutletNodes = reader._ownerOutletNodes;

            _CCBRootPath = reader.CCBRootPath;

            Init();
        }
Пример #60
0
        protected override void OnHandlePropTypeBlock(CCNode node, CCNode parent, string propertyName, BlockData pBlockData, CCBReader reader)
        {
            MenuItemBlockData mi = (MenuItemBlockData)pBlockData;

            if (propertyName == PROPERTY_BLOCK)
            {
                if (null != pBlockData) // Add this condition to allow CCMenuItemImage without target/selector predefined
                {
                    ((CCMenuItem)node).SetTarget(mi.mSELMenuItemHandler);
                }
            }
            else
            {
                base.OnHandlePropTypeBlock(node, parent, propertyName, pBlockData, reader);
            }
        }