private bool SaveExternal(bool As) { if ((_externalAnimationsNode == null) || ((!_externalAnimationsNode.IsDirty) && !As)) { return(true); } try { if (As) { using (SaveFileDialog d = new SaveFileDialog()) { d.InitialDirectory = _externalAnimationsNode._origPath.Substring(0, _externalAnimationsNode._origPath.LastIndexOf('\\')); d.Filter = String.Format("(*{0})|*{0}", Path.GetExtension(_externalAnimationsNode._origPath)); d.Title = "Please choose a location to save this file."; if (d.ShowDialog(this) == DialogResult.OK) { _externalAnimationsNode.Merge(); _externalAnimationsNode.Export(d.FileName); } } } else { _externalAnimationsNode.Merge(); _externalAnimationsNode.Export(_externalAnimationsNode._origPath); } return(true); } catch (Exception x) { MessageBox.Show(this, x.ToString()); } return(false); }
private void SavePacMsbn(MSBinNode msbn, string pacPath, string childNodeName) { string tmpPac = Path.GetTempFileName(); string tmpMsbn = Path.GetTempFileName(); msbn.Export(tmpMsbn); File.Copy(pacPath, tmpPac, true); using (ResourceNode tmpPacNode = NodeFactory.FromFile(null, tmpPac)) { MSBinNode tmpPacChildNode = tmpPacNode.FindChild(childNodeName, true) as MSBinNode; if (tmpPacChildNode == null) { throw new Exception("Error saving '" + pacPath + "': The file does not appear to have a '" + childNodeName + "'"); } else { tmpPacChildNode.Replace(tmpMsbn); tmpPacNode.Merge(); tmpPacNode.Export(pacPath); } } File.Delete(tmpPac); File.Delete(tmpMsbn); }
public void updateMuMenumain(string msBinPath = null) { if (DialogResult.OK == MessageBox.Show("Overwrite the current mu_menumain?", "Overwrite File", MessageBoxButtons.OKCancel)) { using (ResourceNode mu_menumain = TempFiles.MakeTempNode(mu_menumain_path)) { IconsToMenumain.Copy(sc_selmap, mu_menumain, BestSSS); if (msBinPath != null) { mu_menumain.FindChild("MiscData[7]", false).Replace(msBinPath); } mu_menumain.Export(mu_menumain_path); } byte absent_stage_id = BestSSS[0x1E].Item1; int sss2_count = BestSSS.sss2.Where(b => b != 0x1E).Count() + 1; string warn = sss2_count <= 39 ? "" : "\nWARNING: screen 2 of the SSS " + (AutoSSS == null ? "may have " : "has ") + "more than 39 stages, causing My Music to crash on page 2."; var q = StageIDMap.Stages.Where(s => s.ID == absent_stage_id); string absent = q.Any() ? q.First().Name : "STGCUSTOM" + (absent_stage_id - 0x3f).ToString("X2"); MessageBox.Show("Done. " + (msBinPath != null ? "(Song titles copied too.) " : "") + (AutoSSS == null ? "Without a Custom SSS code, " : "Based on your current SSS code, ") + absent + " will be missing; and Menu will be added to the end of screen 2." + warn); } }
public static bool Save() { if (_rootNode != null) { #if !DEBUG try { #endif if (_rootPath == null) { return(SaveAs()); } bool force = Control.ModifierKeys == (Keys.Control | Keys.Shift); if (!force && !_rootNode.IsDirty) { MessageBox.Show("No changes have been made."); return(false); } _rootNode.Merge(force); _rootNode.Export(_rootPath); _rootNode.IsDirty = false; return(true); #if !DEBUG } catch (Exception x) { Say(x.Message); } #endif } return(false); }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { ResourceNode r = Program.OpenedFiles[listBox1.SelectedIndex]; r.Merge(); r.Export(r._origPath); r.IsDirty = false; }
private unsafe void btnOkay_Click(object sender, EventArgs e) { DialogResult = DialogResult.OK; _messagesNode.GetMessageByMID(TargetSong.MsgIdName).Message = nameBox.Text; _messagesNode.GetMessageByMID(TargetSong.MsgIdGenre).Message = genreBox.Text; _messagesNode.GetMessageByMID(TargetSong.MsgIdDescription).Message = descriptionBox.Text; _rootNode.Export("D:\\big\\wiimusic\\raw\\files\\US\\Message\\message222.carc"); Close(); }
public bool SaveExternal(ResourceNode current, bool As) { if (current == null || !current.IsDirty && !As) { return(true); } #if !DEBUG try { #endif if (As) { using (SaveFileDialog d = new SaveFileDialog()) { d.InitialDirectory = current._origPath.Substring(0, current._origPath.LastIndexOf('\\')); d.Filter = string.Format("(*{0})|*{0}", Path.GetExtension(current._origPath)); d.Title = "Please choose a location to save this file."; if (d.ShowDialog(this) == DialogResult.OK) { current.Merge(); current.Export(d.FileName); } } } else { current.Merge(); current.Export(current._origPath); } return(true); #if !DEBUG } catch (Exception x) { MessageBox.Show(this, x.ToString()); } return(false); #endif }
private void saveButton_Click(object sender, EventArgs e) { if (info_en == null) { return; } info_en.Merge(); info_en.Export(_openFilePath); }
public void save() { if (sc_selmap == null) { return; } ResourceNode toSave = common5 ?? sc_selmap; try { toSave.Merge(); toSave.Export(_openFilePath); } catch (IOException) { toSave.Export(_openFilePath + ".out.pac"); MessageBox.Show(_openFilePath + " could not be accessed.\nFile written to " + _openFilePath + ".out.pac"); } updateFileSize(); }
private bool Save(ResourceNode r) { if (r._origPath == null) { return(SaveAs(r)); } r.Merge(Control.ModifierKeys == (Keys.Control | Keys.Shift)); r.Export(r._origPath); r.IsDirty = false; return(true); }
public static bool Save() { bool restoreHex = false; if (_rootNode != null) { #if !DEBUG try { #endif if (_rootPath == null) { return(SaveAs()); } if (MainForm.Instance.ShowHex == true) { MainForm.Instance.ShowHex = false; MainForm.Instance.Invalidate(); MainForm.Instance.resourceTree_SelectionChanged(MainForm.Instance, EventArgs.Empty); restoreHex = true; } bool force = Control.ModifierKeys == (Keys.Control | Keys.Shift); if (!force && !_rootNode.IsDirty) { MessageBox.Show("No changes have been made."); return(false); } _rootNode.Merge(force); _rootNode.Export(_rootPath); _rootNode.IsDirty = false; if (restoreHex) { MainForm.Instance.ShowHex = true; MainForm.Instance.Invalidate(); MainForm.Instance.resourceTree_SelectionChanged(MainForm.Instance, EventArgs.Empty); } return(true); #if !DEBUG } catch (Exception x) { Say(x.Message); } #endif } return(false); }
private bool SaveExternal() { if ((_externalNode == null) || (!_externalNode.IsDirty)) { return(true); } try { _externalNode.Merge(); _externalNode.Export(_externalNode._origPath); return(true); } catch (Exception x) { MessageBox.Show(this, x.ToString()); } return(false); }
private bool SaveAs(ResourceNode r) { using (SaveFileDialog d = new SaveFileDialog()) { d.InitialDirectory = r._origPath.Substring(0, r._origPath.LastIndexOf('\\')); d.Filter = String.Format("(*{0})|*{0}", Path.GetExtension(r._origPath)); d.Title = "Please choose a location to save this file."; if (d.ShowDialog(this) == DialogResult.OK) { r.Merge(); r.Export(d.FileName); return(true); } } return(false); }
private void updateMumenumainToolStripMenuItem_Click(object sender, EventArgs e) { string mu_menumain_path = null; string[] lookIn = { "../../menu2/mu_menumain.pac", "../../menu2/mu_menumain_en.pac", "../../../pfmenu2/mu_menumain.pac", "../../../pfmenu2/mu_menumain_en.pac" }; foreach (string path in lookIn) { if (File.Exists(path)) { mu_menumain_path = path; break; } } if (mu_menumain_path == null) { MessageBox.Show("mu_menumain / mu_menumain_en not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (DialogResult.OK == MessageBox.Show("Overwrite the current mu_menumain?", "Overwrite File", MessageBoxButtons.OKCancel)) { string tempfile = Path.GetTempFileName(); string infotmp = Path.GetTempFileName(); songPanel1.ExportMSBin(infotmp); File.Copy(mu_menumain_path, tempfile, true); ResourceNode mu_menumain = NodeFactory.FromFile(null, tempfile); MSBinNode m7 = mu_menumain.FindChild("Misc Data [7]", false) as MSBinNode; if (m7 == null) { MessageBox.Show(this.ParentForm, "The mu_menumain file does not appear to have a Misc Data [7].", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { m7.Replace(infotmp); mu_menumain.Merge(); mu_menumain.Export(mu_menumain_path); } File.Delete(tempfile); File.Delete(infotmp); } }
private void saveButton_Click(object sender, EventArgs e) { if (sc_selcharacter == null) { return; } if (common5 != null) { common5.Merge(); common5.Export(_openFilePath); } else { sc_selcharacter.Merge(); sc_selcharacter.Export(_openFilePath); } }
private void toolStripMenuItem2_Click(object sender, EventArgs e) { if (soundsListBox.SelectedIndex < 0) { return; } ResourceNode r = soundsListBox.Items[soundsListBox.SelectedIndex] as ResourceNode; using (SaveFileDialog dlg = new SaveFileDialog()) { dlg.FileName = r.Name; dlg.Filter = FileFilters.WAV + "|" + FileFilters.Raw; if (dlg.ShowDialog(this) == DialogResult.OK) { r.Export(dlg.FileName); } } }
private void updateFileSize() { long length; if (common5 != null) { string tempfile = Path.GetTempFileName(); sc_selmap.Export(tempfile); length = new FileInfo(tempfile).Length; File.Delete(tempfile); } else { length = new FileInfo(_openFilePath).Length; } fileSizeBar.Value = Math.Min(fileSizeBar.Maximum, (int)length); fileSizeLabel.Text = length + " / " + fileSizeBar.Maximum; }
public static bool Save() { if (_rootNode != null) { try { if (_rootPath == null) { return(SaveAs()); } _rootNode.Merge(Control.ModifierKeys == (Keys.Control | Keys.Shift)); _rootNode.Export(_rootPath); return(true); } catch (Exception x) { MessageBox.Show(x.Message); } } return(false); }
public static void Copy(string kirbypath, string hatpath) { ResourceNode kirby = NodeFactory.FromFile(null, kirbypath); string temphat = Path.GetTempFileName(); File.Copy(hatpath, temphat, true); ResourceNode hat = NodeFactory.FromFile(null, temphat); TEX0Node skin = (TEX0Node)kirby.FindChildByType("PlyKirby5KSkin", true, ResourceType.TEX0); if (skin == null) { MessageBox.Show(null, "Could not find the texture PlyKirby5KSkin in " + kirbypath, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string temptex = Path.GetTempFileName(); skin.Export(temptex); TEX0Node hatskin = (TEX0Node)hat.FindChildByType("WpnKirbyKirbyMewtwoCap", true, ResourceType.TEX0); if (hatskin == null) { MessageBox.Show(null, "Could not find the texture WpnKirbyKirbyMewtwoCap in " + hatpath, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } hatskin.Replace(temptex); hat.Merge(); hat.Export(hatpath); hat.Dispose(); kirby.Dispose(); File.Delete(temphat); File.Delete(temptex); MessageBox.Show(Path.GetFileName(hatpath) + " has been updated."); }
public void UpdateSSSStockIcons() { if (common5 == null) { MessageBox.Show(this.FindForm(), "common5.pac is not loaded - can't update automatically.\n" + "After saving sc_selcharacter.pac, update the icons manually by replacing sc_selmap's " + "MiscData[40] with sc_selcharacter's MiscData[90].", "Cannot perform operation", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { ResourceNode css_stockicons = sc_selcharacter.FindChild("MiscData[90]", false); string tempFile = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".brres"; css_stockicons.Export(tempFile); ResourceNode sss_stockicons = common5.FindChild("sc_selmap_en/MiscData[40]", false); sss_stockicons.Replace(tempFile); try { File.Delete(tempFile); } catch (Exception) { } } }
public void copyIconsToSelcharacter2() { string fileToSaveTo = null; ResourceNode s2 = null; if (common5 != null) { s2 = common5.FindChild("sc_selcharacter2_en", false); } else if (sc_selmap != null) { if (File.Exists("../../menu2/sc_selcharacter2.pac")) { fileToSaveTo = "../../menu2/sc_selcharacter2.pac"; s2 = TempFiles.MakeTempNode(fileToSaveTo); } else if (File.Exists("../../menu2/sc_selcharacter2_en.pac")) { fileToSaveTo = "../../menu2/sc_selcharacter2_en.pac"; s2 = TempFiles.MakeTempNode(fileToSaveTo); } } if (s2 == null) { return; } ResourceNode md0 = s2.FindChild("MenuRule_en/ModelData[0]", false); MSBinNode md1 = s2.FindChild("MenuRule_en/MiscData[1]", false) as MSBinNode; ResourceNode md80 = sc_selmap.FindChild("MiscData[80]", false); if (md0 == null || md80 == null) { return; } Image[] icons = new Image[41]; Image[] frontstnames = new Image[41]; for (int i = 1; i < 60; i++) { if (i == 32) { i = 50; } int sssPos = StageIDMap.sssPositionForSelcharacter2Icon(i); string nameSelmap = BestSSS[sssPos].Item2.ToString("D2"); icons[sssPos] = ((md80.FindChild("Textures(NW4R)/MenSelmapIcon." + nameSelmap, false) as TEX0Node).GetImage(0)); frontstnames[sssPos] = ((md80.FindChild("Textures(NW4R)/MenSelmapFrontStname." + nameSelmap, false) as TEX0Node).GetImage(0)); } var d = new RandomSelectEditNamesDialog(md1._strings, icons, frontstnames); d.Message = "When finished, press OK to continue."; if (d.ShowDialog() == DialogResult.OK) { for (int i = 0; i < md1._strings.Count; i++) { md1._strings[i] = d[i].ToString(); } } else { return; } using (ProgressWindow w = new ProgressWindow() { CanCancel = false }) { w.Begin(0, 60, 0); for (int i = 1; i < 60; i++) { if (i == 32) { i = 50; } int sssPos = StageIDMap.sssPositionForSelcharacter2Icon(i); string tempFile1 = TempFiles.Create(".tex0"); string tempFile2 = TempFiles.Create(".plt0"); string nameSelcharacter2 = i.ToString("D2"); string nameSelmap = BestSSS[sssPos].Item2.ToString("D2"); TEX0Node iconFrom = md80.FindChild("Textures(NW4R)/MenSelmapIcon." + nameSelmap, false) as TEX0Node; TEX0Node iconTo = md0.FindChild("Textures(NW4R)/MenSelmapIcon." + nameSelcharacter2, false) as TEX0Node; var palFrom = md80.FindChild("Palettes(NW4R)/MenSelmapIcon." + nameSelmap, false); var palTo = md0.FindChild("Palettes(NW4R)/MenSelmapIcon." + nameSelcharacter2, false); if (iconFrom != null && iconTo != null && palFrom != null && palTo != null) { iconFrom.Export(tempFile1); iconTo.Replace(tempFile1); palFrom.Export(tempFile2); palTo.Replace(tempFile2); } TEX0Node prevbase = md80.FindChild("Textures(NW4R)/MenSelmapPrevbase." + nameSelmap, false) as TEX0Node; TEX0Node stageswitch = md0.FindChild("Textures(NW4R)/MenStageSwitch." + nameSelcharacter2, false) as TEX0Node; if (prevbase != null && stageswitch != null) { Bitmap thumbnail = new Bitmap(112, 56); using (Graphics g = Graphics.FromImage(thumbnail)) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.DrawImage(prevbase.GetImage(0), 0, -28, 112, 112); } stageswitch.Replace(thumbnail); } w.Update(i); } } if (fileToSaveTo != null) { s2.Export(fileToSaveTo); } }
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); } }
public static void Copy(ResourceNode scSelmap, ResourceNode muMenumain, CustomSSSCodeset sss) { ResourceNode miscData0 = muMenumain.FindChild("Misc Data [0]", false); List <ResourceNode> chrToKeep = miscData0.FindChild("AnmChr(NW4R)", false).Children; Dictionary <string, string> tempFiles = new Dictionary <string, string>(chrToKeep.Count); foreach (ResourceNode n in chrToKeep) { string file = TempFiles.Create(".chr0"); tempFiles.Add(n.Name, file); n.Export(file); } ResourceNode miscData80 = scSelmap.FindChild("Misc Data [80]", false); miscData0.ReplaceRaw(miscData80.WorkingSource.Address, miscData80.WorkingSource.Length); miscData0.SignalPropertyChange(); List <ResourceNode> chrToReplace = miscData0.FindChild("AnmChr(NW4R)", false).Children; foreach (ResourceNode n in chrToReplace) { string file = tempFiles[n.Name]; n.Replace(file); } string xx_png = TempFiles.Create(".png"); ResourceNode xx = miscData0.FindChild("Textures(NW4R)/MenSelmapIcon.XX", false); bool found = false; if (xx != null) { xx.Export(xx_png); found = true; } else { Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BrawlCrate.StageManager.XX.png"); if (stream != null) { Image.FromStream(stream).Save(xx_png); found = true; } } if (found) { foreach (ResourceNode tex in miscData0.FindChild("Textures(NW4R)", false).Children) { byte icon_id; if (tex.Name.StartsWith("MenSelmapIcon.") && byte.TryParse(tex.Name.Substring(14, 2), out icon_id)) { byte stage_id = sss.StageForIcon(icon_id); if (icon_id != 100 && (stage_id == 0x25 || stage_id > 0x33)) { tex.Replace(xx_png); } } } } File.Delete(xx_png); }