Beispiel #1
0
        public static ElSetting Parse(ElData data)
        {
            var rt = new ElSetting
            {
                baseData = data,
            };

            foreach (var i in data.Children)
            {
                switch (i.Name)
                {
                case "ElfreinaSoftVersion":
                    rt.ElfreinaSoftVersion = float.Parse(i.Values.First());

                    break;

                case "ElfreinaBetaVersion":
                    rt.ElfreinaBetaVersion = int.Parse(i.Values.First());

                    break;

                case "LoadType":
                    rt.LoadType = i.Values.First().Trim('"');

                    break;

                case "IsRightHand":
                    rt.IsRightHand = bool.Parse(i.Values.First());

                    break;
                }
            }

            return(rt);
        }
Beispiel #2
0
        public static ElSetting Parse(ElData data)
        {
            var rt = new ElSetting
            {
                baseData = data,
            };

            foreach (var i in data.Children)
                switch (i.Name)
                {
                    case "ElfreinaSoftVersion":
                        rt.ElfreinaSoftVersion = float.Parse(i.Values.First());

                        break;
                    case "ElfreinaBetaVersion":
                        rt.ElfreinaBetaVersion = int.Parse(i.Values.First());

                        break;
                    case "LoadType":
                        rt.LoadType = i.Values.First().Trim('"');

                        break;
                    case "IsRightHand":
                        rt.IsRightHand = bool.Parse(i.Values.First());

                        break;
                }

            return rt;
        }
Beispiel #3
0
        public static ElDocument Parse(string text)
        {
            var rt        = new ElDocument();
            var tokenizer = new ElTokenizer(text);
            var header    = new[] { "Elfreina", "Extension", "Model", "File", "\n", "File", "Version" };

            if (!tokenizer.Take(header.Length).Select(_ => _.Text).SequenceEqual(header))
            {
                throw new InvalidOperationException("invalid format");
            }

            rt.Version = float.Parse(tokenizer.MoveNext().EnsureKind(ElTokenizer.ValueTokenKind).Text);

            if (rt.Version >= 2)
            {
                throw new NotSupportedException("specified format version not supported");
            }

            foreach (var i in tokenizer)
            {
                if (i.Kind == ElTokenizer.IdentifierTokenKind)
                {
                    var data = ElData.Parse(tokenizer);

                    switch (data.Name)
                    {
                    case "Setting":
                        rt.Setting = ElSetting.Parse(data);

                        break;

                    case "MeshDataList":
                        rt.MeshDataList = data.Children.Where(_ => _.Name == "MeshContainer").Select(ElMeshContainer.Parse).ToList();

                        break;

                    case "HierarchyList":
                        rt.HierarchyList = data.Children.Select(ElNode.Parse).ToList();

                        break;

                    case "RenderingMeshList":
                        foreach (var j in data.Children.Where(_ => _.Name == "RenderingMesh"))
                        {
                            rt.RenderingMeshList.Add(j.Child("RenderingMeshName").Values.First().Trim('"'), j.Child("HierarchyNames").Children.Select(_ => _.Values.First().Trim('"')).ToList());
                        }

                        break;

                    case "AnimationList":
                        rt.AnimationList = data.Children.Where(_ => _.Name == "AnimationData").Select(ElAnimationData.Parse).ToList();

                        break;

                    default:
                        rt.CustomData.Add(data);

                        break;
                    }
                }
            }

            return(rt);
        }