Ejemplo n.º 1
0
        public ccBitmapFontDef ParseCharacterDefinitionCharDef(string line)  //, ccBitmapFontDef characterDefinition)
        {
            ccBitmapFontDef characterDefinition = new ccBitmapFontDef();

            int[] listOfInts = new int[100];
            int   listThing  = 0;

            var values = line.Split("="[0]);

            foreach (string valString in values)
            {
//				int start = valString.IndexOf("(");
                int end = valString.IndexOf(" ");
                if (end > 0)
                {
                    string result = valString.Substring(0, end);

                    if ((result != "char") && (result != "cha") && (result != "chars"))
                    {
                        int ross = Convert.ToInt32(result);
//						int bill = 10+ross;
                        listOfInts[listThing++] = ross;
                    }
                }
            }

            characterDefinition.charID           = listOfInts[0];
            characterDefinition.rect.Origin.x    = listOfInts[1];
            characterDefinition.rect.Origin.y    = listOfInts[2];
            characterDefinition.rect.Size.Width  = listOfInts[3];
            characterDefinition.rect.Size.Height = listOfInts[4];
            characterDefinition.xOffset          = listOfInts[5];
            characterDefinition.yOffset          = listOfInts[6];
            characterDefinition.xAdvance         = listOfInts[7];

            return(characterDefinition);

//			NSArray values = line.ComponentsSeparatedByString ("=");
//			NSEnumerator nse = values.ObjectEnumerator ();
//			string propertyValue;

            /*
             * nse.NextObject ();
             * propertyValue = nse.NextObject ();
             * propertyValue = propertyValue.SubstringToIndex (propertyValue.RangeOfString (" ").Location);
             * characterDefinition.CharID = propertyValue.IntValue ();
             * NSAssert (
             *      characterDefinition.CharID < (int)Enum.kBitmapFontAtlasMaxChars, "BitmpaFontAtlas: CharID bigger than supported");
             * propertyValue = nse.NextObject();
             * characterDefinition.Rect.Origin.x = propertyValue.IntValue();
             * propertyValue = nse.NextObject();
             * characterDefinition.Rect.Origin.y = propertyValue.IntValue();
             * propertyValue = nse.NextObject();
             * characterDefinition.Rect.Size.Width = propertyValue.IntValue();
             * propertyValue = nse.NextObject();
             * characterDefinition.Rect.Size.Height = propertyValue.IntValue();
             * propertyValue = nse.NextObject();
             * characterDefinition.xOffset = propertyValue.IntValue();
             * propertyValue = nse.NextObject();
             * characterDefinition.yOffset = propertyValue.IntValue();
             * propertyValue = nse.NextObject();
             * characterDefinition.xAdvance = propertyValue.IntValue();*/
        }
Ejemplo n.º 2
0
        public void ParseConfigFile(string fntFile)
        {
            string fileName = Default.Namespace.Globals.g_main.GetFolderPrefixForTextureResolution() + fntFile + Default.Namespace.Globals.g_main.GetSuffixForTextureResolution();            //System.IO.Path.GetFileNameWithoutExtension(fntFile);

            Debug.Log("ParseConfigFile = " + fileName);

            TextAsset    asset = Resources.Load(fileName) as TextAsset;
            Stream       s     = new MemoryStream(asset.bytes);
            StreamReader sr    = new StreamReader(s);

//			Resources.Load(

//			var sr = new StreamReader(Application.dataPath + "/" + fileName);
            var fileContents = sr.ReadToEnd();

            sr.Close();

            var lines = fileContents.Split("\n"[0]);

            foreach (string line in lines)
            {
                if (line.StartsWith("char"))
                {
//                    ccBitmapFontDef characterDefinition;
//                  this.ParseCharacterDefinitionCharDef(line, characterDefinition);

                    ccBitmapFontDef characterDefinition = this.ParseCharacterDefinitionCharDef(line);

                    bitmapFontArray[characterDefinition.charID] = characterDefinition;                    //characterDefinition;
                }
            }


//            string resourcesPath = ((NSBundle.MainBundle()).ResourcePath()).StringByAppendingPathComponent(fntFile);
//            string contents = NSString.StringWithContentsOfFileEncodingError(resourcesPath, NSUTF8StringEncoding, null);
//            NSArray lines = new NSArray(contents.ComponentsSeparatedByString("\n"));
//           NSEnumerator nse = lines.ObjectEnumerator();

            /*           string line;
             *         while ((line = nse.NextObject())) {
             *             if (line.HasPrefix("info face")) {
             *             }
             *             else if (line.HasPrefix("common lineHeight")) {
             *                 this.ParseCommonArguments(line);
             *             }
             *             else if (line.HasPrefix("chars c")) {
             *             }
             *             else if (line.HasPrefix("char")) {
             *                 ccBitmapFontDef characterDefinition;
             *                 this.ParseCharacterDefinitionCharDef(line, characterDefinition);
             *                 bitmapFontArray[characterDefinition.CharID] = characterDefinition;
             *             }
             *             else if (line.HasPrefix("kernings count")) {
             *                 this.ParseKerningCapacity(line);
             *             }
             *             else if (line.HasPrefix("kerning first")) {
             *                 this.ParseKerningEntry(line);
             *             }
             *
             *         }
             */
        }