private void inlayGenerateButton_Click(object sender, EventArgs e) { // dlcSavePath = Path.Combine(workDir, "cgm"); using (var ofd = new SaveFileDialog()) { ofd.FileName = InlayName.GetValidName(true, false, true, Frets24).ToLower(); ofd.Filter = "Custom Inlay DLC (*.*)|*.*"; ofd.InitialDirectory = ConfigRepository.Instance()["general_rs2014path"]; // ofd.InitialDirectory = dlcSavePath; if (ofd.ShowDialog() != DialogResult.OK) { return; } dlcSavePath = ofd.FileName; } DLCPackageData packageData = new DLCPackageData(); packageData.Inlay = new InlayData(); packageData.Inlay.InlayPath = InlayFile; packageData.Inlay.IconPath = IconFile; packageData.Inlay.Frets24 = Frets24; packageData.Inlay.Colored = Colored; packageData.Inlay.DLCSixName = GeneralExtensions.RandomName(6); // CRITICAL - 24 fret inlays have naming dependencies if (Frets24) { packageData.Inlay.DLCSixName = String.Format("24fret_{0}", packageData.Inlay.DLCSixName); } packageData.Name = InlayName; packageData.AppId = appIdCombo.SelectedValue.ToString(); // Saving for later ConfigRepository.Instance()["cgm_inlayname"] = InlayName; ConfigRepository.Instance()["cgm_24frets"] = Frets24.ToString(); ConfigRepository.Instance()["cgm_coloredinlay"] = Colored.ToString(); // Generate if (Path.GetFileName(dlcSavePath).Contains(" ") && platformPS3.Checked) { if (!ConfigRepository.Instance().GetBoolean("creator_ps3pkgnamewarn")) { MessageBox.Show(String.Format("PS3 package name can't support space character due to encryption limitation. {0} Spaces will be automatic removed for your PS3 package name.", Environment.NewLine), MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { ConfigRepository.Instance()["creator_ps3pkgnamewarn"] = true.ToString(); } } if (!bwGenerate.IsBusy && packageData != null) { updateProgress.Visible = true; currentOperationLabel.Visible = true; inlayGenerateButton.Enabled = false; bwGenerate.RunWorkerAsync(packageData); } }
private void saveCGMButton_Click(object sender, EventArgs e) { var saveFile = String.Empty; using (var sfd = new SaveFileDialog()) { sfd.Title = "Select a location to store your CGM file"; sfd.Filter = "CGM file (*.cgm)|*.cgm"; sfd.InitialDirectory = Path.Combine(workDir, "cgm"); sfd.FileName = InlayName.GetValidName(true, false, true, Frets24) + "_" + GeneralExtensions.Acronym(Author) + ".cgm"; if (sfd.ShowDialog() != DialogResult.OK) { return; } saveFile = sfd.FileName; } // Create workDir folder var tmpWorkDir = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(saveFile)); if (Directory.Exists(tmpWorkDir)) { DirectoryExtension.SafeDelete(tmpWorkDir); } if (!Directory.Exists(tmpWorkDir)) { Directory.CreateDirectory(tmpWorkDir); } // Convert PNG to DDS ExternalApps.Png2Dds(IconFile, Path.Combine(tmpWorkDir, "icon.dds"), 512, 512); ExternalApps.Png2Dds(InlayFile, Path.Combine(tmpWorkDir, "inlay.dds"), 1024, 512); // Create setup.smb var iniFile = Path.Combine(tmpWorkDir, "setup.smb"); Configuration iniCFG = new Configuration(); // sharpconfig.dll automatically creates a new [General] section in the INI file iniCFG["General"].Add(new Setting("author", String.IsNullOrEmpty(Author) ? "CSC" : Author)); iniCFG["General"].Add(new Setting("inlayname", String.IsNullOrEmpty(InlayName) ? "null" : InlayName)); iniCFG["General"].Add(new Setting("24frets", Convert.ToString(Convert.ToInt32(Frets24)))); iniCFG["General"].Add(new Setting("colored", Convert.ToString(Convert.ToInt32(Colored)))); iniCFG["General"].Add(new Setting("cscvers", ToolkitVersion.version.Replace("-00000000", ""))); iniCFG["General"].Add(new Setting("modified", DateTime.Now.ToShortDateString())); iniCFG.Save(iniFile); // Pack file into a .cgm file (7zip file format) ExternalApps.InjectZip(tmpWorkDir, saveFile, false, true); // Delete temp work dir if (Directory.Exists(tmpWorkDir)) { DirectoryExtension.SafeDelete(tmpWorkDir); } if (MessageBox.Show("Inlay template was saved." + Environment.NewLine + "Would you like to open the folder?", MESSAGEBOX_CAPTION, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Process.Start(Path.GetDirectoryName(saveFile)); } if (Path.GetDirectoryName(saveFile) == Path.Combine(workDir, "cgm")) { inlayTemplateCombo.Items.Add(Path.GetFileNameWithoutExtension(saveFile)); inlayTemplateCombo.SelectedIndex = (inlayTemplateCombo.Items.Count - 1); } }