示例#1
0
        private void copyStockIconsToResultScreenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string stgResult_path          = null;
            string singlePlayerStocks_path = null;

            //Check for files
            if (File.Exists("../stage/melee/STGRESULT.pac"))
            {
                string pathResult = "../stage/melee/STGRESULT.pac";
                stgResult_path = pathResult;
            }
            if (File.Exists("../menu/common/StockFaceTex.brres"))
            {
                string path = "../menu/common/StockFaceTex.brres";
                singlePlayerStocks_path = path;
            }
            //Send error if files are missing
            if (stgResult_path == null)
            {
                MessageBox.Show("STGRESULT not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (singlePlayerStocks_path == null)
            {
                MessageBox.Show("StockFaceTex.brres not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //Confirm you want to merge files
            else if (DialogResult.OK == MessageBox.Show("Overwrite the current STGRESULT?", "Overwrite File", MessageBoxButtons.OKCancel))
            {
                //Generate temp files
                string tempFile        = Path.GetTempFileName();
                string stockFaceTextmp = Path.GetTempFileName();

                //Copy files into a temp file that is to be overwritten
                File.Copy(stgResult_path, tempFile, true);
                File.Copy(singlePlayerStocks_path, stockFaceTextmp, true);

                //Search for STGRESULT.pac/2.pac/Misc Data [120]
                ResourceNode stgResult        = NodeFactory.FromFile(null, stgResult_path);
                ARCNode      resultStocks     = stgResult.FindChild("2", true) as ARCNode;
                BRRESNode    resultStockIcons = resultStocks.FindChild("Misc Data [120]", true) as BRRESNode;

                //Send error if files are missing
                if (resultStocks == null)
                {
                    MessageBox.Show(this.ParentForm, "The STGRESULT file does not appear to have a 2.pac.",
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (resultStockIcons == null)
                {
                    MessageBox.Show(this.ParentForm, "The 2.pac file does not appear to have a Misc Data [120].",
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    //Replace STGRESULT.pac/2.pac/Misc Data [120] with StockFaceTex.brres
                    resultStockIcons.Replace(stockFaceTextmp);
                    //Merge the files
                    stgResult.Merge();
                    //Export STGRESULT.pac
                    stgResult.Export(stgResult_path);
                }
                //Delete generated temp files
                File.Delete(stockFaceTextmp);
                File.Delete(tempFile);
            }
        }