コード例 #1
0
        //Gets the size of an RWSD Sound node
        //Doesn't include the header, so it's probably off by a little
        public void updateSize()
        {
            if (wavID == -1)
            {
                return;
            }

            BrawlLib.SSBB.ResourceNodes.RWSDSoundNode sound = brsar.GetNode(groupID, collectionID, wavID) as BrawlLib.SSBB.ResourceNodes.RWSDSoundNode;

            unsafe
            {
                int samples = sound.Header->NumSamples;
                if ((samples / 2 * 2) == samples)
                {
                    fileSize = samples / 2;
                }
                else
                {
                    fileSize = samples / 2 + 1;
                }
            }
            MappingItem p = this;

            brsar.CloseRSAR();
            this.TreeView.Invalidate();
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: KingAtreyu/super-sawndz
 //Called when the insert thread completes. Reloads the tree view or updates the specific node.
 private void backgroundWorkerInsert_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     enableStuff();
     if (textBoxWavID.Text.Length > 0 && treeViewMapping.SelectedNode != null && Path.GetExtension(textBoxInputFile.Text).CompareTo(".wav") == 0)
     {
         MappingItem item = treeViewMapping.SelectedNode as MappingItem;
         item.updateSize();
         //Reset the node selection to trigger treeViewMapping_AfterSelect()
         //That will reload the sound data from the brsar.
         treeViewMapping.SelectedNode = null;
         treeViewMapping.SelectedNode = item;
     }
     else
     {
         loadTreeView();
     }
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: KingAtreyu/super-sawndz
        /*Called when a node is selected.
         * Sets the textBox's for group id etc.
         * autoplays the sound if there is one.
         */
        private void treeViewMapping_AfterSelect(object sender, TreeViewEventArgs e)
        {
            audioPlaybackBRSARSound.TargetSource = null;
            MappingItem item = e.Node as MappingItem;

            if (item == null)
            {
                return;
            }
            if (item.groupID > -1)
            {
                textBoxGroupID.Text = item.groupID.ToString();
            }
            else
            {
                textBoxGroupID.Text = "";
            }
            if (item.collectionID > -1)
            {
                textBoxCollectionID.Text = item.collectionID.ToString();
            }
            else
            {
                textBoxCollectionID.Text = "";
            }
            if (item.wavID > -1)
            {
                textBoxWavID.Text = item.wavID.ToString();
                audioPlaybackBRSARSound.TargetSource = item as System.Audio.IAudioSource;
                audioPlaybackBRSARSound.Play();
            }
            else
            {
                textBoxWavID.Text = "";
            }
        }
コード例 #4
0
ファイル: brsar.cs プロジェクト: KingAtreyu/super-sawndz
        //Populates a treeView with MappingItem nodes from the current rsar
        public static void LoadTreeView(TreeView treeView)
        {
            //Only used to count the number of nodes added, no actual function in the program
            int nodeCount = 0;

            StringBuilder sb = new StringBuilder();

            BrawlLib.SSBB.ResourceNodes.RSARNode       rsar   = GetRSAR();
            BrawlLib.SSBB.ResourceNodes.RSARFolderNode folder = (BrawlLib.SSBB.ResourceNodes.RSARFolderNode)rsar.FindChild("Info/snd/group", false);
            BrawlLib.SSBB.ResourceNodes.ResourceNode[] groups = folder.FindChildrenByType("", BrawlLib.SSBB.ResourceNodes.ResourceType.RSARGroup);

            //Create root node and add all nodes to it.
            //Adding to the treeView collection directly will raise events, causing super slowdown when setting Text property.
            TreeNode           root  = new TreeNode();
            TreeNodeCollection nodes = root.Nodes;

            foreach (BrawlLib.SSBB.ResourceNodes.RSARGroupNode group in groups)
            {
                string name = group.Name;

                int         groupID  = group.Id;
                MappingItem groupMap = new MappingItem(name, groupID);
                nodes.Add(groupMap);
                nodeCount++;

                foreach (BrawlLib.SSBB.ResourceNodes.RSARFileNode file in group.Files)
                {
                    string fName        = file.Name;
                    int    collectionID = file.FileNodeIndex;
                    BrawlLib.SSBB.ResourceNodes.RWSDGroupNode audioFolder = (BrawlLib.SSBB.ResourceNodes.RWSDGroupNode)file.FindChild("audio", false);

                    if (audioFolder == null || audioFolder.Children.Count == 0)
                    {
                        continue;
                    }

                    MappingItem colMap = new MappingItem(fName, groupID, collectionID);
                    groupMap.Nodes.Add(colMap);
                    nodeCount++;

                    if (audioFolder == null)
                    {
                        continue;
                    }

                    //Same as nodeCount, used to track total size of sounds in collection. No actual function.
                    int addUpSoundSize = 0;

                    for (int i = 0; i < audioFolder.Children.Count; i++)
                    {
                        if (!(audioFolder.Children[i] is BrawlLib.SSBB.ResourceNodes.RWSDSoundNode))
                        {
                            continue;
                        }
                        BrawlLib.SSBB.ResourceNodes.RWSDSoundNode sound = (BrawlLib.SSBB.ResourceNodes.RWSDSoundNode)audioFolder.Children[i];
                        int soundSize = 0;
                        unsafe
                        {
                            int samples = sound.Header->NumSamples;
                            if ((samples / 2 * 2) == samples)
                            {
                                soundSize = samples / 2;
                            }
                            else
                            {
                                soundSize = samples / 2 + 1;
                            }
                        }
                        addUpSoundSize += soundSize;

                        MappingItem soundMap = new MappingItem(sound.Name, groupID, collectionID, i);

                        colMap.Nodes.Add(soundMap);
                        nodeCount++;
                        //child node must have a parent in order for size to propogate correctly.
                        soundMap.fileSize = soundSize;
                    }
                }

                //If the group doesn't have any collections then it doesn't have any sounds, remove it
                if (groupMap.Nodes.Count == 0)
                {
                    nodes.Remove(groupMap);
                    nodeCount -= 2;
                    continue;
                }
            }

            //Add the top level nodes to the treeview collection now that we're done.
            foreach (TreeNode node in nodes)
            {
                treeView.Nodes.Add(node);
            }
            CloseRSAR();
        }