예제 #1
0
        protected override bool OnInitialize()
        {
            offsets = new Dictionary <int, FDefListOffset>();

            base.OnInitialize();

            if (Size == 0)
            {
                SetSizeInternal(4);
            }

            OldName = _name;
            SectionParamInfo data = null;

            if (Parent is MoveDefArticleNode)
            {
                if (Root.Params.ContainsKey((Parent as MoveDefArticleNode).ArticleStringID + "/" + _name))
                {
                    data  = Root.Params[(Parent as MoveDefArticleNode).ArticleStringID + "/" + _name];
                    _info = data.Attributes;
                    if (!String.IsNullOrEmpty(data.NewName))
                    {
                        _name = data.NewName;
                    }
                }
                else
                {
                    _info = new List <AttributeInfo>();
                }
            }
            else if (Parent is MoveDefSectionParamNode)
            {
                if (Root.Params.ContainsKey(TreePath))
                {
                    data  = Root.Params[TreePath];
                    _info = data.Attributes;
                    if (!String.IsNullOrEmpty(data.NewName))
                    {
                        _name = data.NewName;
                    }
                }
                else
                {
                    _info = new List <AttributeInfo>();
                }
            }
            else if (Root.Params.ContainsKey(Name))
            {
                data  = Root.Params[Name];
                _info = data.Attributes;
                if (!String.IsNullOrEmpty(data.NewName))
                {
                    _name = data.NewName;
                }
            }
            else
            {
                _info = new List <AttributeInfo>();
            }

            attributeBuffer = new UnsafeBuffer(Size);
            byte *pOut = (byte *)attributeBuffer.Address;
            byte *pIn  = (byte *)Header;

            //if (String.IsNullOrEmpty(_name = new String((sbyte*)Header)))
            //    _name = OldName;

            for (int i = 0; i < Size; i++)
            {
                if (i % 4 == 0)
                {
                    if (data == null)
                    {
                        AttributeInfo info = new AttributeInfo();

                        //Guess
                        if (((((uint)*((buint *)pIn)) >> 24) & 0xFF) != 0 && *((bint *)pIn) != -1 && !float.IsNaN(((float)*((bfloat *)pIn))))
                        {
                            info._type = 0;
                        }
                        else
                        {
                            if (*((bint *)pIn) > 1480 && *((bint *)pIn) < Root.dataSize)
                            {
                                info._type = 3;
                            }
                            else
                            {
                                info._type = 1;
                            }
                        }

                        info._name        = (info._type == 1 ? "*" : "" + (info._type > 3 ? "+" : "")) + "0x" + i.ToString("X");
                        info._description = "No Description Available.";

                        _info.Add(info);
                    }

                    //if (_info.Count == i / 4)
                    //    break;

                    //AttributeInfo n = _info[i / 4];
                    //if (n._type == 3)
                    //{
                    //    int id = 0;
                    //    if (!int.TryParse(n._description, out id))
                    //        id = i / 4;
                    //    if (!offsets.ContainsKey(id))
                    //        offsets.Add(id, new FDefListOffset() { _startOffset = *(bint*)pIn, _listCount = 1 });
                    //    else
                    //    {
                    //        FDefListOffset d = offsets[id];
                    //        d._startOffset = *(bint*)pIn;
                    //        offsets[id] = d;
                    //    }
                    //}
                    //else if (n._type == 4)
                    //{
                    //    int id = int.Parse(n._description);
                    //    if (!offsets.ContainsKey(id))
                    //        offsets.Add(id, new FDefListOffset() { _listCount = *(bint*)pIn });
                    //    else
                    //    {
                    //        FDefListOffset d = offsets[id];
                    //        d._listCount = *(bint*)pIn;
                    //        offsets[id] = d;
                    //    }
                    //}
                }
                *pOut++ = *pIn++;
            }

            if (Parent is MoveDefArticleNode)
            {
                string id = (Parent as MoveDefArticleNode).ArticleStringID + "/" + _name;
                if (!Root.Params.ContainsKey(id))
                {
                    Root.Params.Add(id, new SectionParamInfo());
                    Root.Params[id].Attributes = _info;
                    Root.Params[id].NewName    = _name;
                    data = Root.Params[id];
                }
            }
            else if (Parent is MoveDefSectionParamNode)
            {
                if (!Root.Params.ContainsKey(TreePath))
                {
                    Root.Params.Add(TreePath, new SectionParamInfo());
                    Root.Params[TreePath].Attributes = _info;
                    Root.Params[TreePath].NewName    = _name;
                    data = Root.Params[TreePath];
                }
            }

            return(false);
            //return offsets.Values.Count > 0;
        }