diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..725e86b --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +.vs/ +obj/ +bin/ +packages/ +*.exe +*.config +*.pdb +*.dll +*.xml + diff --git a/LAMover.Designer.cs b/LAMover.Designer.cs index 67c678a..e773724 100644 --- a/LAMover.Designer.cs +++ b/LAMover.Designer.cs @@ -43,6 +43,7 @@ private void InitializeComponent() this.label4 = new System.Windows.Forms.Label(); this.textBox2 = new System.Windows.Forms.TextBox(); this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.checkBox2 = new System.Windows.Forms.CheckBox(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -170,11 +171,23 @@ private void InitializeComponent() this.checkBox1.UseVisualStyleBackColor = true; this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); // + // checkBox2 + // + this.checkBox2.AutoSize = true; + this.checkBox2.Location = new System.Drawing.Point(315, 353); + this.checkBox2.Name = "checkBox2"; + this.checkBox2.Size = new System.Drawing.Size(179, 17); + this.checkBox2.TabIndex = 13; + this.checkBox2.Text = "Overwrite directly to PSO2 folder"; + this.checkBox2.UseVisualStyleBackColor = true; + this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged); + // // LAMover // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(610, 377); + this.Controls.Add(this.checkBox2); this.Controls.Add(this.checkBox1); this.Controls.Add(this.label4); this.Controls.Add(this.textBox2); @@ -212,5 +225,6 @@ private void InitializeComponent() private System.Windows.Forms.Label label4; private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.CheckBox checkBox2; } } \ No newline at end of file diff --git a/LAMover.cs b/LAMover.cs index f93db31..9cb3327 100644 --- a/LAMover.cs +++ b/LAMover.cs @@ -17,17 +17,18 @@ namespace LobbyActionMover public partial class LAMover : Form { public static string currentProgramFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); - + //public List csvValues_string; - public string PSO2Directory= ""; + public string PSO2Directory = ""; public bool csvDataLoaded = false; public bool createBackups = false; + public bool overWriteDirectly = false; public LAMover() { InitializeComponent(); System.Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + currentProgramFolder); // Should fix ooz.dll problems - + csvValues = new List(); } private void fileToolStripMenuItem_Click(object sender, EventArgs e) @@ -91,14 +92,14 @@ private void loadAnimationsCSVToolStripMenuItem_Click(object sender, EventArgs e { if (values[i].Trim() == "Male" || values[i].Trim() == "Female") { - if (gender != values[i].Trim()) { + if (gender != values[i].Trim()) { gender = values[i].Trim(); emoteVariation = 0; } } } //values[8].Trim();//Male or female - if (values[0].Trim() != "") { + if (values[0].Trim() != "") { commandName = values[0].Trim(); } @@ -109,8 +110,8 @@ private void loadAnimationsCSVToolStripMenuItem_Click(object sender, EventArgs e var valueString = commandName + "-" + values[2].Trim() + "-" + gender + "-" + emoteVariation; var lobbyactiondat = new LAData() { - valueData= values, - valueDescription = valueString, + valueData = values, + valueDescription = valueString, }; csvValues.Add(lobbyactiondat); @@ -137,7 +138,10 @@ private void setPSO2DirectoryToolStripMenuItem_Click(object sender, EventArgs e) var pathIncorrect = true; while (pathIncorrect) { - if (goodFolderDialog.ShowDialog() == CommonFileDialogResult.Ok) + var goodfolder_result = goodFolderDialog.ShowDialog(); + if (goodfolder_result == CommonFileDialogResult.Cancel) + break; + if (goodfolder_result == CommonFileDialogResult.Ok) { PSO2Directory = goodFolderDialog.FileName; @@ -161,7 +165,7 @@ private void textBox1_TextChanged(object sender, EventArgs e) listBox1.Items.Clear(); foreach (LAData str in csvValues) { - if (str.valueDescription.Contains(textBox1.Text)){ + if (str.valueDescription.Contains(textBox1.Text)) { listBox1.Items.Add(str); } } @@ -171,7 +175,7 @@ private void textBox1_TextChanged(object sender, EventArgs e) { foreach (LAData str in csvValues) { - listBox1.Items.Add(str); + listBox1.Items.Add(str); } } } @@ -204,11 +208,14 @@ private void label1_Click(object sender, EventArgs e) { } - + public string RemoveInvalidChars(string filename) + { + return string.Concat(filename.Split(Path.GetInvalidPathChars())); + } private void button1_Click(object sender, EventArgs e) // Save and create replaced LA { - - + + if (csvDataLoaded) { @@ -227,22 +234,30 @@ private void label1_Click(object sender, EventArgs e) var olditemStringdescr = oldItem.valueDescription.Split('-'); string olditemStringdescr_formatted = olditemStringdescr[1] + "_" + olditemStringdescr[2] + "_" + olditemStringdescr[3]; - string newReplacedLAFolder = currentProgramFolder + "\\" + newitemStringdescr_formatted + "_over_"+ olditemStringdescr_formatted; + string newReplacedLAFolder = RemoveInvalidChars(currentProgramFolder + "\\" + newitemStringdescr_formatted + "_over_" + olditemStringdescr_formatted); if (!Directory.Exists(newReplacedLAFolder)) Directory.CreateDirectory(newReplacedLAFolder); string newReplacedLAFolder_NGS = newReplacedLAFolder + "\\" + "win32reboot"; - if (!Directory.Exists(newReplacedLAFolder_NGS)) - Directory.CreateDirectory(newReplacedLAFolder_NGS); - + string newReplacedLAFolder_base = newReplacedLAFolder + "\\" + "win32"; + if (!overWriteDirectly) + { + if (!Directory.Exists(newReplacedLAFolder_NGS)) + Directory.CreateDirectory(newReplacedLAFolder_NGS); + if (!Directory.Exists(newReplacedLAFolder_base)) + Directory.CreateDirectory(newReplacedLAFolder_base); + } //Backups string replacedLaFolder_backupfolder = newReplacedLAFolder + "\\" + "backup"; + string replacedLaFolder_backupfolder_base = newReplacedLAFolder + "\\" + "backup" + "\\" + "win32"; string replacedLaFolder_backupfolder_NGS = newReplacedLAFolder + "\\" + "backup" + "\\" + "win32reboot"; if (createBackups) { - + if (!Directory.Exists(replacedLaFolder_backupfolder)) Directory.CreateDirectory(replacedLaFolder_backupfolder); - + if (!Directory.Exists(replacedLaFolder_backupfolder_base)) + Directory.CreateDirectory(replacedLaFolder_backupfolder_base); + if (!Directory.Exists(replacedLaFolder_backupfolder_NGS)) Directory.CreateDirectory(replacedLaFolder_backupfolder_NGS); } @@ -288,13 +303,13 @@ private void label1_Click(object sender, EventArgs e) Console.WriteLine("CMAQM:" + castmaleAQM); Console.WriteLine("HUAQM:" + humanAQM); Console.Out.WriteLine("NewItemAqms:"); - + foreach (string str in newItemsAqms) { camandcaf = false; Console.Out.WriteLine(str); var fileNameString = Path.GetFileName(str).Trim(); - + if (fileNameString.Contains("cam") || fileNameString.Contains("caf")) // Dominant that should be used instead of lacf or lacm { camandcaf = true; @@ -317,11 +332,18 @@ private void label1_Click(object sender, EventArgs e) } if (createBackups) { - File.Copy(PSO2Directory + "\\data\\win32\\" + oldItem.valueData[3], replacedLaFolder_backupfolder +"\\"+ oldItem.valueData[3]); + File.Copy(PSO2Directory + "\\data\\win32\\" + oldItem.valueData[3], replacedLaFolder_backupfolder_base + "\\" + oldItem.valueData[3]); + } + + var basedirectory = newReplacedLAFolder_base + "\\" + oldItem.valueData[3]; + + if (overWriteDirectly) + { + basedirectory = PSO2Directory + "\\data\\win32\\" + oldItem.valueData[3]; } - packIceFromDirectoryToFile(currentProgramFolder + "//temp", - ReadWhiteList(Path.Combine(currentProgramFolder, "group1.txt")), - false, false, true, false, newReplacedLAFolder + "\\"+ oldItem.valueData[3]); + packIceFromDirectoryToFile(currentProgramFolder + "//temp", + ReadWhiteList(Path.Combine(currentProgramFolder, "group1.txt")), + false, false, true, false, basedirectory); ///////////////////////////////////////Creating NGS files, oh boy exportTemp = currentProgramFolder + "\\temp\\ngs"; @@ -338,90 +360,56 @@ private void label1_Click(object sender, EventArgs e) string tempNgsfolderstr; string newFolderNGS; ////////////////////////////////////// cast female - if (castfemaleAQM != "") - { - valData = oldItem.valueData[6].Trim();// 6 -- female cast location array value - ngsIceSubFolder = valData.Substring(0, 2); - ngsIceOrgName = valData.Substring(2, valData.Length - 2); - - if (createBackups) + void ngsfileIcecreation (string genderaqm, int arrayvalue){ + if (genderaqm != "") { - if (!Directory.Exists(replacedLaFolder_backupfolder_NGS + "\\" + ngsIceSubFolder)) - Directory.CreateDirectory(replacedLaFolder_backupfolder_NGS + "\\" + ngsIceSubFolder); - File.Copy(PSO2Directory + "\\data\\win32reboot\\" + ngsIceSubFolder + "\\" + ngsIceOrgName, - replacedLaFolder_backupfolder_NGS + "\\" + ngsIceSubFolder + "\\" + ngsIceOrgName); - } - - tempNgsfolderstr = exportTemp + "\\" + Path.GetFileName(castfemaleAQM); - - File.Copy(castfemaleAQM, tempNgsfolderstr); // Copy AQM to temp ngs folder - if (!Directory.Exists(newReplacedLAFolder_NGS + "\\" + ngsIceSubFolder)) - Directory.CreateDirectory(newReplacedLAFolder_NGS + "\\" + ngsIceSubFolder);// Create win32reboot subfolder - - newFolderNGS = newReplacedLAFolder_NGS + "\\" + ngsIceSubFolder; - packIceFromDirectoryToFile(exportTemp, - ReadWhiteList(Path.Combine(currentProgramFolder, "group1.txt")), // Create ice - false, false, true, false, newFolderNGS + "\\" + ngsIceOrgName); + valData = oldItem.valueData[arrayvalue].Trim();// 6 -- female cast location array value + ngsIceSubFolder = valData.Substring(0, 2); + ngsIceOrgName = valData.Substring(2, valData.Length - 2); - File.Delete(tempNgsfolderstr); // Delete aqm and start again - } - ////////////////////////////////////// cast male - if (castmaleAQM != "") - { - valData = oldItem.valueData[5].Trim();// 5 -- male cast location array value - ngsIceSubFolder = valData.Substring(0, 2); - ngsIceOrgName = valData.Substring(2, valData.Length - 2); - - if (createBackups) - { - if (!Directory.Exists(replacedLaFolder_backupfolder_NGS + "\\" + ngsIceSubFolder)) - Directory.CreateDirectory(replacedLaFolder_backupfolder_NGS + "\\" + ngsIceSubFolder); - File.Copy(PSO2Directory + "\\data\\win32reboot\\" + ngsIceSubFolder + "\\" + ngsIceOrgName, - replacedLaFolder_backupfolder_NGS + "\\" + ngsIceSubFolder + "\\" + ngsIceOrgName); - } + if (createBackups) + { + if (!Directory.Exists(replacedLaFolder_backupfolder_NGS + "\\" + ngsIceSubFolder)) + Directory.CreateDirectory(replacedLaFolder_backupfolder_NGS + "\\" + ngsIceSubFolder); + File.Copy(PSO2Directory + "\\data\\win32reboot\\" + ngsIceSubFolder + "\\" + ngsIceOrgName, + replacedLaFolder_backupfolder_NGS + "\\" + ngsIceSubFolder + "\\" + ngsIceOrgName); + } - tempNgsfolderstr = exportTemp + "\\" + Path.GetFileName(castmaleAQM); + tempNgsfolderstr = exportTemp + "\\" + Path.GetFileName(genderaqm); - File.Copy(castmaleAQM, tempNgsfolderstr); // Copy AQM to temp ngs folder - if (!Directory.Exists(newReplacedLAFolder_NGS + "\\" + ngsIceSubFolder)) - Directory.CreateDirectory(newReplacedLAFolder_NGS + "\\" + ngsIceSubFolder);// Create win32reboot subfolder + File.Copy(genderaqm, tempNgsfolderstr); // Copy AQM to temp ngs folder + if (!overWriteDirectly) + { + if (!Directory.Exists(newReplacedLAFolder_NGS + "\\" + ngsIceSubFolder)) + Directory.CreateDirectory(newReplacedLAFolder_NGS + "\\" + ngsIceSubFolder);// Create win32reboot subfolder + } - newFolderNGS = newReplacedLAFolder_NGS + "\\" + ngsIceSubFolder; - packIceFromDirectoryToFile(exportTemp, - ReadWhiteList(Path.Combine(currentProgramFolder, "group1.txt")), // Create ice - false, false, true, false, newFolderNGS + "\\" + ngsIceOrgName); + newFolderNGS = newReplacedLAFolder_NGS + "\\" + ngsIceSubFolder; - File.Delete(tempNgsfolderstr); // Delete aqm and start again - } - ////////////////////////////////////// Human AQM - valData = oldItem.valueData[4].Trim();// 5 -- male cast location array value - ngsIceSubFolder = valData.Substring(0, 2); - ngsIceOrgName = valData.Substring(2, valData.Length - 2); + if (overWriteDirectly) + { + newFolderNGS = PSO2Directory + "\\data\\win32reboot\\" + ngsIceSubFolder; + } + packIceFromDirectoryToFile(exportTemp, + ReadWhiteList(Path.Combine(currentProgramFolder, "group1.txt")), // Create ice + false, false, true, false, newFolderNGS + "\\" + ngsIceOrgName); - if (createBackups) - { - if (!Directory.Exists(replacedLaFolder_backupfolder_NGS + "\\" + ngsIceSubFolder)) - Directory.CreateDirectory(replacedLaFolder_backupfolder_NGS + "\\" + ngsIceSubFolder); - File.Copy(PSO2Directory + "\\data\\win32reboot\\" + ngsIceSubFolder + "\\" + ngsIceOrgName, - replacedLaFolder_backupfolder_NGS + "\\" + ngsIceSubFolder + "\\" + ngsIceOrgName); + File.Delete(tempNgsfolderstr); // Delete aqm and start again + } } + ngsfileIcecreation(castfemaleAQM, 6); + ngsfileIcecreation(castmaleAQM, 5); + ngsfileIcecreation(humanAQM, 4); - tempNgsfolderstr = exportTemp + "\\" + Path.GetFileName(humanAQM); - - File.Copy(humanAQM, tempNgsfolderstr); // Copy AQM to temp ngs folder - if (!Directory.Exists(newReplacedLAFolder_NGS + "\\" + ngsIceSubFolder)) - Directory.CreateDirectory(newReplacedLAFolder_NGS + "\\" + ngsIceSubFolder);// Create win32reboot subfolder - - newFolderNGS = newReplacedLAFolder_NGS + "\\" + ngsIceSubFolder; - packIceFromDirectoryToFile(exportTemp, - ReadWhiteList(Path.Combine(currentProgramFolder, "group1.txt")), // Create ice - false, false, true, false, newFolderNGS + "\\" + ngsIceOrgName); - - File.Delete(tempNgsfolderstr); // Delete aqm and start again //Clean Temp folders and such, or else it'll keep using the old files CleanFolder(); - MessageBox.Show("Saved lobby action in program folder."); + if(!overWriteDirectly) + MessageBox.Show("Saved lobby action in program folder."); + else + { + MessageBox.Show("Saved lobby action in win32/win32reboot.\nReload LA's to see effect."); + } } else @@ -434,7 +422,6 @@ private void label1_Click(object sender, EventArgs e) MessageBox.Show("There is no CSV data loaded."); } } - private static bool writeGroupToDirectory(byte[][] groupToWrite, string directory) { if (!Directory.Exists(directory) && groupToWrite != null && (uint)groupToWrite.Length > 0U) @@ -584,5 +571,10 @@ private void checkBox1_CheckedChanged(object sender, EventArgs e) { createBackups = checkBox1.Checked; } + + private void checkBox2_CheckedChanged(object sender, EventArgs e) + { + overWriteDirectly = checkBox2.Checked; + } } }