//page file
        private void parseImageFileName(string line, string fntFile)
        {
            //    //////////////////////////////////////////////////////////////////////////
            //// line to parse:
            //// page id=0 file="bitmapFontTest.png"
            ////////////////////////////////////////////////////////////////////////////

            // page ID. Sanity check
            int    index  = line.IndexOf('=') + 1;
            int    index2 = line.IndexOf(' ', index);
            string value  = line.Substring(index, index2 - index);

            try
            {
                int ivalue = int.Parse(value);
            }
            catch (Exception)
            {
                throw (new ContentLoadException("Invalid page ID for FNT descriptor. Line=" + line + ", value=" + value + ", indices=" + index + "," + index2));
            }
            //            Debug.Assert(Convert.ToInt32(value) == 0, "LabelBMFont file could not be found");
            // file
            index  = line.IndexOf('"') + 1;
            index2 = line.IndexOf('"', index);
            value  = line.Substring(index, index2 - index);

            AtlasName = value;

            var directory = string.Empty;

            if (!CCFileUtils.GetDirectoryName(value, out directory))
            {
                AtlasName = CCFileUtils.FullPathFromRelativeFile(value, fntFile);
            }
        }
Esempio n. 2
0
        void ParseImageElement()
        {
            List <CCTileSetInfo> tilesets = Tilesets;
            int           tilesetCount    = tilesets != null ? tilesets.Count : 0;
            CCTileSetInfo tileset         = tilesetCount > 0 ? tilesets[tilesetCount - 1] : null;

            string imagename = currentAttributeDict[ImageElementTilesheetName];

            tileset.TilesheetFilename = imagename;

            var directory = string.Empty;

            if (string.IsNullOrEmpty(TileMapFileName))
            {
                tileset.TilesheetFilename = imagename;
            }
            else
            {
                if (!CCFileUtils.GetDirectoryName(imagename, out directory))
                {
                    tileset.TilesheetFilename = CCFileUtils.FullPathFromRelativeFile(imagename, TileMapFileName);
                }
            }
        }