Пример #1
0
        private ResourceNode CreatePath(ResourceNode parent, sbyte *str, int length)
        {
            ResourceNode current;

            int    len;
            char * cPtr;
            sbyte *start, end;
            sbyte *ceil = str + length;

            while (str < ceil)
            {
                for (end = str; ((end < ceil) && (*end != '_')); end++)
                {
                    ;
                }
                len = (int)end - (int)str;

                current = null;
                foreach (ResourceNode n in parent._children)
                {
                    if ((n._name.Length != len) || !(n is RSARFolderNode))
                        continue;

                    fixed(char *p = n._name)
                    for (cPtr = p, start = str; (start < end) && (*start == *cPtr); start++, cPtr++)
                        ;

                    if (start == end)
                    {
                        current = n;
                        break;
                    }
                }
                if (current == null)
                {
                    current         = new RSARFolderNode();
                    current._name   = new String(str, 0, len);
                    current._parent = parent;
                    parent._children.Add(current);
                }

                str    = end + 1;
                parent = current;
            }

            return(parent);
        }
        public DialogResult ShowDialog(IWin32Window owner, RSARFolderNode parent)
        {
            _parentNode = parent;
            _newNode = null;

            treeResource.BeginUpdate();
            foreach (ResourceNode node in parent.RSARNode.Children)
                treeResource.Nodes.Add(BaseWrapper.Wrap(this, node));

            BaseWrapper w = treeResource.FindResource(parent);
            treeResource.SelectedNode = w;
            w.EnsureVisible();
            w.Expand();

            treeResource.EndUpdate();

            try { return base.ShowDialog(owner); }
            finally { _parentNode = null; treeResource.Clear(); }
        }
Пример #3
0
        protected override void OnPopulate()
        {
            RSARFolderNode g = new RSARFolderNode();

            g.Name   = "Info";
            g.Parent = this;
            g        = new RSARFolderNode();
            g.Name   = "Files";
            g.Parent = this;

            //Retrieve all files to attach to entries
            GetFiles();

            //Enumerate entries, attaching them to the files.
            RSARHeader *rsar          = Header;
            SYMBHeader *symb          = rsar->SYMBBlock;
            sbyte *     offset        = (sbyte *)symb + 8;
            buint *     stringOffsets = symb->StringOffsets;

            VoidPtr types    = (VoidPtr)rsar->INFOBlock + 8;
            ruint * typeList = (ruint *)types;

            //Iterate through group types
            for (int i = 0; i < 5; i++)
            {
                Type t = null;

                ruint *entryList = (ruint *)((uint)types + typeList[i] + 4);
                int    entryCount = *((bint *)entryList - 1);
                sbyte *str, end;

                switch (i)
                {
                case 0: t = typeof(RSARSoundNode); break;

                case 1: t = typeof(RSARBankNode); break;

                case 2: t = typeof(RSARTypeNode); break;

                case 3: continue;

                case 4: t = typeof(RSARGroupNode); break;
                }

                for (int x = 0; x < entryCount; x++)
                {
                    ResourceNode  parent = Children[0];
                    RSAREntryNode n      = Activator.CreateInstance(t) as RSAREntryNode;
                    n._origSource = n._uncompSource = new DataSource(types + entryList[x], 0);

                    str = offset + stringOffsets[n.StringId];

                    for (end = str; *end != 0; end++)
                    {
                        ;
                    }
                    while ((--end > str) && (*end != '_'))
                    {
                        ;
                    }

                    if (end > str)
                    {
                        parent  = CreatePath(parent, str, (int)end - (int)str);
                        n._name = new String(end + 1);
                    }
                    else
                    {
                        n._name = new String(str);
                    }
                    n.Initialize(parent, types + entryList[x], 0);
                    //n.Populate();
                }
            }
            //Sort(true);
        }
Пример #4
0
        private ResourceNode CreatePath(ResourceNode parent, sbyte* str, int length)
        {
            ResourceNode current;

            int len;
            char* cPtr;
            sbyte* start, end;
            sbyte* ceil = str + length;
            while (str < ceil)
            {
                for (end = str; ((end < ceil) && (*end != '_')); end++) ;
                len = (int)end - (int)str;

                current = null;
                foreach (ResourceNode n in parent._children)
                {
                    if ((n._name.Length != len) || !(n is RSARFolderNode))
                        continue;

                    fixed (char* p = n._name)
                        for (cPtr = p, start = str; (start < end) && (*start == *cPtr); start++, cPtr++) ;

                    if (start == end)
                    {
                        current = n;
                        break;
                    }
                }
                if (current == null)
                {
                    current = new RSARFolderNode();
                    current._name = new String(str, 0, len);
                    current._parent = parent;
                    parent._children.Add(current);
                }

                str = end + 1;
                parent = current;
            }

            return parent;
        }