private void button2_Click(object sender, EventArgs e) { using (var stream = new MemoryStream()) { using (var xr = XmlWriter.Create(stream, new XmlWriterSettings() { Indent = true, Encoding = Form1.DefEnc })) { xr.WriteStartDocument(); xr.WriteStartElement("Root"); xr.WriteStartElement("isBigEndian"); xr.WriteAttributeString("Value", "False"); xr.WriteEndElement(); xr.WriteStartElement("BymlFormatVersion"); xr.WriteAttributeString("Value", ((uint)1).ToString()); xr.WriteEndElement(); xr.WriteStartElement("C1"); xr.WriteStartElement("C0"); xr.WriteAttributeString("Name", "StageDefaultBgmList"); foreach (string k in Levels.Keys.ToArray()) { xr.WriteStartElement("C1"); xr.WriteStartElement("A0"); xr.WriteAttributeString("Name", "BgmLabel"); xr.WriteAttributeString("StringValue", Levels[k]); xr.WriteEndElement(); xr.WriteStartElement("D1"); xr.WriteAttributeString("Name", "Scenario"); xr.WriteAttributeString("StringValue", k.Substring(k.Length - 5, 1)); xr.WriteEndElement(); xr.WriteStartElement("A0"); xr.WriteAttributeString("Name", "StageName"); xr.WriteAttributeString("StringValue", k.Substring(0, k.Length - 8)); xr.WriteEndElement(); xr.WriteEndElement(); } xr.WriteEndElement(); xr.WriteEndElement(); xr.WriteEndElement(); xr.Close(); } Clipboard.SetText(Form1.DefEnc.GetString(stream.ToArray())); SzsFiles["StageDefaultBgmList.byml"] = BymlConverter.GetByml(Form1.DefEnc.GetString(stream.ToArray())); } CommonCompressors.YAZ0 y = new CommonCompressors.YAZ0(); NDS.NitroSystem.FND.NARC SzsArch = new NDS.NitroSystem.FND.NARC(); SFSDirectory dir = new SFSDirectory("", true); for (int i = 0; i < SzsFiles.Count; i++) { SFSFile file = new SFSFile(i, SzsFiles.Keys.ToArray()[i], dir); file.Data = SzsFiles.Values.ToArray()[i]; dir.Files.Add(file); } SzsArch.FromFileSystem(dir); File.WriteAllBytes(@"BgmTable.szs", y.Compress(SzsArch.Write())); MessageBox.Show("Done, file was saved as BgmTable.szs in this program folder"); this.Close(); }
public static void SaveFile(ref Dictionary <string, string> ccnt_r) { CommonCompressors.YAZ0 y = new CommonCompressors.YAZ0(); NDS.NitroSystem.FND.NARC SzsArch = new NDS.NitroSystem.FND.NARC(); SFSDirectory dir = new SFSDirectory("", true); SFSFile StgData = new SFSFile(0, "CreatorClassNameTable.byml", dir); StgData.Data = BymlConverter.GetByml(MakeXML(ref ccnt_r)); dir.Files.Add(StgData); SzsArch.FromFileSystem(dir); File.Delete("CreatorClassNameTable.szs"); File.WriteAllBytes("CreatorClassNameTable.szs", y.Compress(SzsArch.Write())); }
private void button1_Click(object sender, EventArgs e) { if (!File.Exists(PaPath)) { MessageBox.Show("Pa file not found !"); return; } if (!File.Exists(KclPath)) { MessageBox.Show("kcl file not found !"); return; } if (!File.Exists(modelPath)) { MessageBox.Show("Model file not found !"); return; } SaveFileDialog s = new SaveFileDialog(); s.Filter = "Szs files|*.szs"; s.FileName = textBox1.Text; if (s.ShowDialog() != DialogResult.OK) { return; } CommonCompressors.YAZ0 y = new CommonCompressors.YAZ0(); NDS.NitroSystem.FND.NARC SzsArch = new NDS.NitroSystem.FND.NARC(); SFSDirectory dir = new SFSDirectory("", true); //Model SFSFile Model = new SFSFile(0, textBox1.Text + ".bcmdl", dir); if (IsObj) { CGFX mod = null; mod = new CGFX(); CGFXGenerator.FromOBJ(mod, modelPath, textBox1.Text); Model.Data = mod.Write(); } else { Model.Data = File.ReadAllBytes(modelPath); } dir.Files.Add(Model); //Collisions SFSFile KclFile = new SFSFile(1, textBox1.Text + ".kcl", dir); KclFile.Data = File.ReadAllBytes(KclPath); dir.Files.Add(KclFile); SFSFile PaFile = new SFSFile(2, textBox1.Text + ".pa", dir); PaFile.Data = File.ReadAllBytes(PaPath); dir.Files.Add(PaFile); //InitSensor SFSFile Sensor = new SFSFile(3, "InitSensor.byml", dir); Sensor.Data = BymlConverter.GetByml(Properties.Resources.Sensor); dir.Files.Add(Sensor); //InitActor SFSFile Actor = new SFSFile(4, "InitActor.byml", dir); Actor.Data = BymlConverter.GetByml(Properties.Resources.Actor); dir.Files.Add(Actor); //InitClipping string clip = "<?xml version=\"1.0\" encoding=\"shift_jis\"?>\r\n<Root>\r\n <isBigEndian Value=\"False\" />\r\n <BymlFormatVersion Value=\"1\" />\r\n <C1>\r\n <D2 Name=\"Radius\" StringValue=\"" + numericUpDown1.Value.ToString() + "\" />\r\n </C1>\r\n</Root>"; SFSFile Clipping = new SFSFile(5, "InitClipping.byml", dir); Clipping.Data = BymlConverter.GetByml(clip); dir.Files.Add(Clipping); SzsArch.FromFileSystem(dir); File.WriteAllBytes(s.FileName, y.Compress(SzsArch.Write())); MessageBox.Show("Done !"); MessageBox.Show("Remember you need to add the object to the CreatorClassNameTable to use the object in-game (Other modding -> CreatorClassNameTable editor)"); MessageBox.Show("To view the model in the editor you must copy it in the models folder with the name " + textBox1.Text + ".obj or else you will see a blue box"); this.Close(); }