private void disableStringsToolStripMenuItem_Click(object sender, EventArgs e) { Chunk locChunk = mAssetListBox.Items[mAssetListBox.SelectedIndex] as Chunk; if (locChunk.LocHelper == null) { locChunk.LocHelper = new LocHelper(locChunk.GetAssetData()); } string userInput = MessageForm.ShowMessage("Paste String ids into the text box", "", SystemIcons.Question, true, true); if (userInput != null) { string number = StringInputDlg.GetString("Enter occurence", "Enter the occurence of the string you want to disable", "1"); int target_occurence = 1; if (Int32.TryParse(number, out target_occurence)) { string[] lines = userInput.Replace("\r\n", "\n").Split("\n".ToCharArray()); foreach (string line in lines) { if (line.Length > 0) { locChunk.LocHelper.DisableString(line, target_occurence); } } // now... // copy the data from the chunk to the in-memory data byte[] rawData = locChunk.LocHelper.GetRawData(); Array.Copy(rawData, 0, mUcfbFileHelper.Data, (int)locChunk.Start, rawData.Length); } } }
private void mAddStringsButton_Click(object sender, EventArgs e) { //public static string ShowMessage(string title, string message, Icon icon, bool editable, bool showCancelButton) string result = MessageForm.ShowMessage("Paste in strings to add", "", SystemIcons.Question, true, true); if (result != null) { result = result.Replace("\r\n", "\n"); //public static string Replace(string input, string pattern, string replacement); result = Regex.Replace(result, "[ ]+\n", "\n"); List <string> stringsToAdd = new List <string>(result.Split(new char[] { '\n' })); int numberAdded = HashHelper.AddStringsToDictionary(stringsToAdd); txt_output.Text = string.Format("Added {0} previously unknown strings\n", numberAdded); } }
public void CreateLvl(string outputPath, string saveFileName, string platform, bool supressPopups) { if (!outputPath.EndsWith("\\")) { outputPath += "\\"; } string workspace = outputPath + ".\\__LVLTOOL__workspace__\\"; string munge_dir = outputPath + ".\\__LVLTOOL__workspace__\\MUNGED\\"; string saveFilePath = outputPath + saveFileName; if (Directory.Exists(workspace)) { Directory.Delete(workspace, true); } Directory.CreateDirectory(workspace); Directory.CreateDirectory(munge_dir); string reqContent = GetReqString(); string reqFileName = mOutputFilenameTextbox.Text.ToLower().Replace(".lvl", ".req"); File.WriteAllText(workspace + reqFileName, reqContent); // now copy the files over to the workspace foreach (MungableItem item in mListBox.Items) { if (AlreadyMunged(item.Path)) { File.Copy(item.Path, munge_dir + item.FileName); } else { File.Copy(item.Path, workspace + item.FileName); } } // now munge & pack string configMunge = Program.ModToolsDir + "ToolsFL\\bin\\ConfigMunge.exe"; string textureMunge = Program.ModToolsDir + "ToolsFL\\bin\\pc_TextureMunge.exe"; string scriptMunge = Program.ModToolsDir + "ToolsFL\\bin\\ScriptMunge.exe"; string lvlPack = Program.ModToolsDir + "ToolsFL\\bin\\levelpack.exe"; if (OverrideLevelPack != null) { lvlPack = OverrideLevelPack; } if (OverrideScriptMunge != null) { scriptMunge = OverrideScriptMunge; } string req_file_noext = reqFileName.Replace(".req", ""); string configArgs = string.Format( " -inputfile $*.mcfg -continue -QUIET -platform {0} -sourcedir {1} -outputdir {2} -hashstrings ", platform, workspace, munge_dir); string scriptArgs = string.Format( " -inputfile *.lua -continue -QUIET -platform {0} -sourcedir {1} -outputdir {2} ", platform, Path.GetFullPath(workspace), munge_dir); string texArgs = string.Format( " -inputfile $*.tga -checkdate -continue -QUIET -platform {0} -sourcedir {1} -outputdir {2} ", platform, workspace, munge_dir); string lvlPackArgs = string.Format( "-inputfile {0}.req -writefiles {1}{0}.files -continue -QUIET -platform {2} -sourcedir {3} -inputdir {1} -outputdir {3} ", req_file_noext, munge_dir, platform, Path.GetFullPath(workspace)); //string programOutput = Program.RunCommand(program_exe, args, true); string programOutput = ""; if (File.Exists(scriptMunge)) { programOutput += Program.RunCommand(scriptMunge, scriptArgs, true); } if (File.Exists(configMunge)) { programOutput += Program.RunCommand(configMunge, configArgs, true); } if (File.Exists(textureMunge)) { programOutput += Program.RunCommand(textureMunge, texArgs, true); } programOutput += Program.RunCommand(lvlPack, lvlPackArgs, true); string batchFileContents = string.Format( "{0} {1}\n\n{2} {3}\n\n{4} {5}\n\n{6} {7}\n\n", textureMunge, String.Format("-inputfile $*.tga -checkdate -continue -platform {0} -sourcedir . -outputdir MUNGED ", platform), scriptMunge, String.Format("-inputfile *.lua -continue -platform {0} -sourcedir . -outputdir MUNGED ", platform), configMunge, String.Format("-inputfile $*.mcfg -continue -platform {0} -sourcedir . -outputdir MUNGED -hashstrings ", platform), lvlPack, String.Format("-inputfile {0}.req -writefiles MUNGED\\{0}.files -continue -platform {1} -sourcedir . -inputdir MUNGED\\ -outputdir . ", req_file_noext, platform) ); // copy output to user's choice directory string lvlOutput = workspace + req_file_noext + ".lvl"; if (File.Exists(lvlOutput)) { File.WriteAllText(workspace + "munge.bat", batchFileContents); File.WriteAllText(workspace + "munge.log", programOutput); File.Copy(lvlOutput, saveFilePath, true); if (!supressPopups) { MessageForm.ShowMessage("Saved lvl file", "Saved to: " + saveFilePath, SystemIcons.Information, false, false); } else { Console.WriteLine("Saved lvl file to: " + saveFilePath); } if (Directory.Exists(workspace)) // allow the user to rename in order to keep the workspace { Directory.Delete(workspace, true); } } else { if (!supressPopups) { MessageForm.ShowMessage("Error creating lvl file", "Something went wrong:\n" + programOutput); } else { Console.WriteLine("Error creating lvl file :\n" + programOutput); } } }