Пример #1
0
        public void Load(string oadfile)
        {
            Name = Path.GetFileNameWithoutExtension(oadfile).ToLowerInvariant();
            var basepath = Path.GetDirectoryName(oadfile) + "\\";

            var lines = File.ReadAllLines(oadfile);

            int depth      = 0;
            var spacedelim = new[] { ' ' };

            var onimpaths = new List <string>();

            foreach (var line in lines)
            {
                string tline = line.Trim();
                if (string.IsNullOrEmpty(tline))
                {
                    continue;                              //blank line
                }
                //if (tline.StartsWith("#")) continue; //commented out

                string[] parts = tline.Split(spacedelim, StringSplitOptions.RemoveEmptyEntries);

                if (tline.StartsWith("{"))
                {
                    depth++; continue;
                }
                if (tline.StartsWith("}"))
                {
                    depth--;
                }                                       //need to handle the closing cases

                if (depth == 0)
                {
                    if (tline.StartsWith("Version"))
                    {
                        Version = parts;
                    }
                }

                if (depth == 1)
                {
                    if (tline.StartsWith("crAnimation") && (tline.Length > 11))
                    {
                        onimpaths.Add(tline.Substring(11).Trim());
                    }
                }
            }


            OnimFiles.Clear();

            foreach (var onimpath in onimpaths)
            {
                var onimfile = new OnimFile();
                onimfile.Load(basepath + onimpath);
                OnimFiles.Add(onimfile);
            }
        }
Пример #2
0
        public bool Read(string[] lines, ref int i)
        {
            List <float> vals = new List <float>();

            var spacedelim = new[] { ' ' };
            int depth      = 0;

            while (i < lines.Length)
            {
                var line  = lines[i];
                var tline = line.Trim();
                i++;
                if (string.IsNullOrEmpty(tline))
                {
                    continue;
                }
                if (tline.StartsWith("{"))
                {
                    depth++; continue;
                }
                if (tline.StartsWith("}"))
                {
                    depth--;
                }
                if (depth <= 0)
                {
                    i--; break;
                }

                if (depth == 1)
                {
                    string[] parts = tline.Split(spacedelim, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var part in parts)
                    {
                        if (string.IsNullOrEmpty(part))
                        {
                            continue;
                        }
                        var val = OnimFile.TryParseFloat(part);
                        vals.Add(val);
                    }
                }
                else
                {
                    return(false);
                }
            }

            Values = vals.ToArray();

            return(true);
        }
Пример #3
0
        public bool Read(string[] lines, ref int i)
        {
            var    line  = lines[i];
            string tline = line.Trim();

            if (string.IsNullOrEmpty(tline))
            {
                return(false);                             //blank line
            }
            //if (tline.StartsWith("#")) continue; //commented out
            var spacedelim = new[] { ' ' };

            string[] parts = tline.Split(spacedelim, StringSplitOptions.RemoveEmptyEntries);
            if (parts.Length != 3)
            {
                return(false);
            }

            Track  = parts[0];
            Type   = parts[1];
            BoneID = OnimFile.TryParseInt(parts[2]);

            i++;

            int depth = 0;

            while (i < lines.Length)
            {
                line  = lines[i];
                tline = line.Trim();
                if (string.IsNullOrEmpty(tline))
                {
                    i++; continue;
                }
                if (tline.StartsWith("{"))
                {
                    depth++;
                }
                if (tline.StartsWith("}"))
                {
                    depth--;
                }
                if (depth <= 0)
                {
                    break;
                }

                if (depth == 1)
                {
                    if (tline.StartsWith("FramesData"))
                    {
                        OnimFramesData framesData = new OnimFramesData();
                        if (framesData.Read(lines, ref i))
                        {
                            FramesData.Add(framesData);
                        }
                    }
                }

                i++;
            }



            return(true);
        }