private void rBNKToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RBNKNode node = new RBNKNode()
            {
                _name      = String.Format("[{0}] RBNK", _targetNode.Files.Count),
                _fileIndex = _targetNode.Files.Count
            };

            node.InitGroups();
            node._parent = _targetNode;
            _targetNode.Files.Add(node);
            Update(lstSets);
        }
Exemple #2
0
        private void makeAllExternalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (SoundPackItem i in lstSets.Items)
            {
                if (i._node is RSARExtFileNode)
                {
                    continue;
                }

                ListViewItem v        = i as ListViewItem;
                string       type     = v.SubItems[1].Text;
                string       dir      = "\\" + type + "\\";
                string       fileName = i._node.Name.Replace('/', '_').Replace('<', '(').Replace('>', ')') + ".b" + type.ToLower();

                string newPath = _targetNode._origPath.Substring(0, _targetNode._origPath.LastIndexOf('\\')) + dir;
                if (!Directory.Exists(newPath))
                {
                    Directory.CreateDirectory(newPath);
                }
                i._node.Export(newPath + fileName);

                RSARGroupNode[] groups = i._node.GroupRefNodes;

                //Contains lists of all instances of this file in each group
                List <int>[] refs = new List <int> [groups.Length];

                //Remove all references to this file
                for (int n = 0; n < groups.Length; ++n)
                {
                    refs[n] = new List <int>();
                    RSARGroupNode g = groups[n];
                    for (int m = 0; m < g._files.Count; ++m)
                    {
                        if (g._files[m] == i._node)
                        {
                            refs[n].Add(m);
                            g._files.RemoveAt(m--);
                        }
                    }
                }
                //if (i._node is RWSDNode)
                //{
                //    if (i._node.Children.Count > 0)
                //        foreach (RWSDDataNode d in i._node.Children[0].Children)
                //        {
                //            foreach (RSARSoundNode r in d._refs)
                //            {

                //            }
                //        }
                //}
                //else if (i._node is RSEQNode)
                //{
                //    foreach (RSEQLabelNode d in i._node.Children)
                //    {

                //    }
                //}
                //else
                List <RSARBankNode> rbnkRefs = null;
                if (i._node is RBNKNode)
                {
                    RBNKNode rbnk = i._node as RBNKNode;
                    rbnkRefs = rbnk._rsarBankEntries;
                    for (int j = 0; j < rbnk._rsarBankEntries.Count; ++j)
                    {
                        RSARBankNode b = rbnk._rsarBankEntries[j];
                        b.BankNode = null;
                    }
                    //if (i._node.Children.Count > 0)
                    //    foreach (RBNKDataEntryNode d in i._node.Children[0].Children)
                    //    {

                    //    }
                }

                _targetNode.Files.RemoveAt(i.Index);

                RSARExtFileNode ext = new RSARExtFileNode();
                ext._fileIndex = i.Index;
                ext._parent    = _targetNode;
                _targetNode.Files.Insert(i.Index, ext);

                ext.ExtPath = (dir + fileName).Replace('\\', '/');
                ext.Name    = String.Format("[{0}] {1}", i.Index, ext.ExtPath);

                if ((i._node is RBNKNode || i._node is RSARExtFileNode) && rbnkRefs != null)
                {
                    RBNKNode rbnk = i._node as RBNKNode;
                    foreach (RSARBankNode b in rbnkRefs)
                    {
                        b.BankNode = ext;
                    }
                }

                //Remake references
                for (int groupID = 0; groupID < refs.Length; ++groupID)
                {
                    int           r     = 0;
                    RSARGroupNode group = groups[groupID];
                    foreach (int occurrence in refs[groupID])
                    {
                        group._files.Insert(occurrence + r++, ext);
                    }

                    ext._groupRefs.Add(group);
                }

                i._node = ext;
            }
            _targetNode.IsDirty = true;
            Update(lstSets);
        }