private void saveFileDialog1_FileOk(object sender, CancelEventArgs e) { string[] Strings = new string[listBox1.Items.Count]; for (int i = 0; i < Strings.Length; i++) { Strings[i] = listBox1.Items[i].ToString(); } File.WriteAllBytes(saveFileDialog1.FileName, Editor.Export(Strings)); MessageBox.Show("saved"); }
private void saveFileDialog1_FileOk(object sender, CancelEventArgs e) { string[] Strings = new string[listBox1.Items.Count]; for (int i = 0; i < Strings.Length; i++) { Strings[i] = listBox1.Items[i].ToString(); } File.WriteAllBytes(saveFileDialog1.FileName, Editor.Export(Strings)); MessageBox.Show("OBJ file saved successfully!", "Toradora! OBJ Editor", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void OBJEGUI_Load(object sender, EventArgs e) { if (arg1 != null && arg2 != null && arg3 != null) { if (arg1 == "-patch") { List <String> StringList = new List <String>(); Editor = new OBJHelper(File.ReadAllBytes(arg2)); foreach (string String in Editor.Import()) { StringList.Add(String); } StringList.Clear(); foreach (string line in File.ReadLines(arg3)) { StringList.Add(line); } string[] Strings = new string[StringList.Count]; for (int i = 0; i < Strings.Length; i++) { Strings[i] = StringList[i].ToString(); } File.WriteAllBytes(arg2, Editor.Export(Strings)); } else if (arg1 == "-export") { List <String> StringList = new List <String>(); Editor = new OBJHelper(File.ReadAllBytes(arg2)); foreach (string String in Editor.Import()) { StringList.Add(String); } string[] Strings = new string[StringList.Count]; StreamWriter SaveFile = new StreamWriter(arg3); for (int i = 0; i < Strings.Length; i++) { Strings[i] = StringList[i].ToString(); SaveFile.WriteLine(Strings[i]); } SaveFile.Close(); } else { MessageBox.Show("The first argument must be \"-patch\" or \"-export\" (without quotes).", "Argument error", MessageBoxButtons.OK, MessageBoxIcon.Error); } System.Windows.Forms.Application.ExitThread(); } }
public static void RepackObj(bool debugMode) { List <String> directories = new List <string>(); directories.AddRange(Directory.GetDirectories(Path.Combine(Application.StartupPath, "Data", "Obj")).Select(Path.GetFileName)); JObject mainFile = JObject.Parse(File.ReadAllText(mainFilePath)); Dictionary <string, string> translatedNames = new Dictionary <string, string>(); // Dictionary with pairs of original and translated names if (mainFile["names"] != null) { foreach (JProperty name in mainFile["names"].Children().ToArray()) { if (name.Value.ToString() != "") // If a translation for that name exists { translatedNames.Add(name.Name, name.Value.ToString()); } } } foreach (string name in directories) { string filepath = Path.Combine(Application.StartupPath, "Data", "Obj", name, name); OBJHelper myHelper = new OBJHelper(File.ReadAllBytes(filepath)); string[] scriptStrings = myHelper.Import(); Dictionary <int, string> scriptNames = myHelper.actors; bool haveTranslation = mainFile[name] != null; for (int i = 0; i < scriptStrings.Length; i++) { if (haveTranslation) { string translatedString = mainFile[name][i.ToString()].ToString(); if (translatedString != "") { scriptStrings[i] = translatedString; } } if (scriptNames[i] != null && translatedNames.ContainsKey(scriptNames[i])) { scriptNames[i] = translatedNames[scriptNames[i]]; } } File.WriteAllBytes(Path.Combine(toolsDirectory, name), myHelper.Export(scriptStrings)); Process myProc = new Process(); myProc.StartInfo.FileName = Path.Combine(toolsDirectory, "gzip.exe"); myProc.StartInfo.Arguments = "-n9 -f " + name; // Without -n9 the game will freeze myProc.StartInfo.WorkingDirectory = toolsDirectory; myProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; myProc.Start(); myProc.WaitForExit(); File.Delete(Path.Combine(toolsDirectory, name)); File.Replace(Path.Combine(toolsDirectory, name + ".gz"), Application.StartupPath + File.ReadAllText(filepath + ".txt"), null); } if (debugMode) { File.Copy(Path.Combine(Application.StartupPath, "Data", "Debug", "_0000ESS1.obj.gz"), Path.Combine(Application.StartupPath, "Data", "DatWorker", "resource", "script", "_0000ESS1", "_0000ESS1.0001", "_0000ESS1.obj.gz"), true); // This file enables debug mode File.Copy(Path.Combine(Application.StartupPath, "Data", "Debug", "STARTPOINT.obj.gz"), Path.Combine(Application.StartupPath, "Data", "DatWorker", "resource", "script", "STARTPOINT", "STARTPOINT.0001", "STARTPOINT.obj.gz"), true); // This is pretranslated debug menu } else { File.Copy(Path.Combine(Application.StartupPath, "Data", "Debug", "original_STARTPOINT.obj.gz"), Path.Combine(Application.StartupPath, "Data", "DatWorker", "resource", "script", "STARTPOINT", "STARTPOINT.0001", "STARTPOINT.obj.gz"), true); // Restore original debug menu } }