private void OpenFile(string fname) { if (fname.EndsWith(".pimg")) { ResourceMode = true; FileEntry[] Rst = PRM.Import(System.IO.File.ReadAllBytes(fname)); for (int i = 0; i < Rst.Length; i++) { System.IO.File.WriteAllBytes(AppDomain.CurrentDomain.BaseDirectory + i + ".res", Rst[i].Data); } MessageBox.Show("Resources Extracted in the Program Directory...", "Resource Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { ResourceMode = false; listBox1.Items.Clear(); SCN = new PSBAnalyzer(System.IO.File.ReadAllBytes(fname)); foreach (string str in SCN.Import()) { listBox1.Items.Add(str); } if (SCN.UnkOpCodes) { MessageBox.Show("Maybe the reoder is wrong... try create a issue"); } if (SCN.HaveEmbedded) { MessageBox.Show("Looks this psb contains a Embedded File, try open as .pimg"); } } }
private void saveFileToolStripMenuItem_Click(object sender, EventArgs e) { System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog(); dialog.Description = "Please select the scn2ks folder"; System.Windows.Forms.FolderBrowserDialog dialog1 = new System.Windows.Forms.FolderBrowserDialog(); dialog1.Description = "Please select the scn folder"; if ((dialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) & (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)) { DialogResult dr = MessageBox.Show("Would you like to compress the script? (Recommended)\n\nDoes not work with old games.", "ScnEditorGUI", MessageBoxButtons.YesNo, MessageBoxIcon.Question); string path = dialog.SelectedPath; string path1 = dialog1.SelectedPath; path = "G:\\e\\e3(scn2ks)"; path1 = "G:\\e\\e3"; string des = path + "(ks2scn)\\"; if (Directory.Exists(des) == false) { Directory.CreateDirectory(des); } List <string> fl = GetFiles(path, ".scn2ks"); List <string> fl1 = GetFiles(path1, ".scn"); foreach (string s in fl) { string name = Path.GetFileNameWithoutExtension(s); string ss = ""; foreach (string sss in fl1) { if (Path.GetFileNameWithoutExtension(s).Equals(Path.GetFileNameWithoutExtension(sss))) { ss = sss; break; } } SCN = new PSBAnalyzer(File.ReadAllBytes(ss)); SCN.Import(); SCN.CompressPackget = dr == DialogResult.Yes; List <String> ppp = new List <string>() { }; StreamReader sr = new StreamReader(s, Encoding.Unicode); while (!sr.EndOfStream) { ppp.Add(sr.ReadLine()); } sr.Close(); string[] Strings = ppp.ToArray(); foreach (string o in Strings) { Console.WriteLine(o); } PSBStrMan.CompressionLevel = CompressionLevel.Z_BEST_COMPRESSION; //opitional byte[] outfile = SCN.Export(Strings); //System.IO.File.WriteAllBytes(des + name + ".scn", outfile); } MessageBox.Show("File Saved."); } }
public void OpenFile(string fname, string path) { ResourceMode = false; listBox1.Items.Clear(); SCN = new PSBAnalyzer(File.ReadAllBytes(fname)); List <string> lines = new List <string>() { }; foreach (string str in SCN.Import()) { lines.Add(str); } string name = System.IO.Path.GetFileNameWithoutExtension(fname); StreamWriter sw = new StreamWriter(path + name + ".scn2ks", false, Encoding.Unicode); foreach (String str in lines) { sw.WriteLine(str); } sw.Close(); }